FEM: FemConstraintHeatflux: Add DFLUX option to heat flux constraint

This commit is contained in:
kgoao
2016-12-20 18:10:20 +01:00
committed by Yorik van Havre
parent b264aa2e12
commit 93b7aceb0e
9 changed files with 187 additions and 45 deletions

View File

@@ -65,6 +65,11 @@ TaskFemConstraintHeatflux::TaskFemConstraintHeatflux(ViewProviderFemConstraintHe
ui->lw_references->addAction(action);
ui->lw_references->setContextMenuPolicy(Qt::ActionsContextMenu);
connect(ui->rb_convection, SIGNAL(clicked(bool)), this, SLOT(Conv()));
connect(ui->rb_dflux, SIGNAL(clicked(bool)), this, SLOT(Flux()));
connect(ui->if_heatflux, SIGNAL(valueChanged(double)),
this, SLOT(onHeatFluxChanged(double)));
connect(ui->if_ambienttemp, SIGNAL(valueChanged(double)),
this, SLOT(onAmbientTempChanged(double)));
//connect(ui->if_facetemp, SIGNAL(valueChanged(double)),
@@ -90,13 +95,24 @@ TaskFemConstraintHeatflux::TaskFemConstraintHeatflux(ViewProviderFemConstraintHe
// Fill data into dialog elements
ui->if_ambienttemp->setMinimum(0);
ui->if_ambienttemp->setMaximum(FLOAT_MAX);
Base::Quantity t = Base::Quantity(pcConstraint->AmbientTemp.getValue(), Base::Unit::Temperature);
ui->if_ambienttemp->setValue(t);
ui->if_filmcoef->setMinimum(0);
ui->if_filmcoef->setMaximum(FLOAT_MAX);
Base::Quantity f = Base::Quantity(pcConstraint->FilmCoef.getValue(), Base::Unit::ThermalTransferCoefficient);
ui->if_filmcoef->setValue(f);
std::string constraint_type = pcConstraint->ConstraintType.getValueAsString();
if (constraint_type == "Convection") {
ui->rb_convection->setChecked(1);
ui->sw_heatflux->setCurrentIndex(0);
Base::Quantity t = Base::Quantity(pcConstraint->AmbientTemp.getValue(), Base::Unit::Temperature);
ui->if_ambienttemp->setValue(t);
Base::Quantity f = Base::Quantity(pcConstraint->FilmCoef.getValue(), Base::Unit::ThermalTransferCoefficient);
ui->if_filmcoef->setValue(f);
} else if (constraint_type == "DFlux") {
ui->rb_dflux->setChecked(1);
ui->sw_heatflux->setCurrentIndex(1);
Base::Quantity c = Base::Quantity(pcConstraint->DFlux.getValue(), Base::Unit::HeatFluxDensity);
ui->if_heatflux->setValue(c);
}
ui->lw_references->clear();
for (std::size_t i = 0; i < Objects.size(); i++) {
@@ -154,6 +170,38 @@ void TaskFemConstraintHeatflux::onFilmCoefChanged(double val)
pcConstraint->FilmCoef.setValue(val); // [W]/[[m^2]/[K]]
}
void TaskFemConstraintHeatflux::onHeatFluxChanged(double val)
{
Fem::ConstraintHeatflux* pcConstraint = static_cast<Fem::ConstraintHeatflux*>(ConstraintView->getObject());
pcConstraint->DFlux.setValue(val);
}
void TaskFemConstraintHeatflux::Conv()
{
Fem::ConstraintHeatflux* pcConstraint = static_cast<Fem::ConstraintHeatflux*>(ConstraintView->getObject());
std::string name = ConstraintView->getObject()->getNameInDocument();
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.ConstraintType = %s",name.c_str(), get_constraint_type().c_str());
Base::Quantity t = Base::Quantity(300, Base::Unit::Temperature);
ui->if_ambienttemp->setValue(t);
pcConstraint->AmbientTemp.setValue(300);
Base::Quantity f = Base::Quantity(10, Base::Unit::ThermalTransferCoefficient);
ui->if_filmcoef->setValue(f);
pcConstraint->FilmCoef.setValue(10);
ui->sw_heatflux->setCurrentIndex(0);
}
void TaskFemConstraintHeatflux::Flux()
{
Fem::ConstraintHeatflux* pcConstraint = static_cast<Fem::ConstraintHeatflux*>(ConstraintView->getObject());
std::string name = ConstraintView->getObject()->getNameInDocument();
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.ConstraintType = %s",name.c_str(), get_constraint_type().c_str());
Base::Quantity c = Base::Quantity(0, Base::Unit::HeatFluxDensity);
ui->if_heatflux->setValue(c);
pcConstraint->DFlux.setValue(0);
ui->sw_heatflux->setCurrentIndex(1);
}
void TaskFemConstraintHeatflux::addToSelection()
{
std::vector<Gui::SelectionObject> selection = Gui::Selection().getSelectionEx(); //gets vector of selected objects of active document
@@ -327,6 +375,16 @@ double TaskFemConstraintHeatflux::getFilmCoef(void) const
return filmcoef_in_units;
}
std::string TaskFemConstraintHeatflux::get_constraint_type(void) const {
std::string type;
if (ui->rb_convection->isChecked()) {
type = "\"Convection\"";
} else if (ui->rb_dflux->isChecked()) {
type = "\"DFlux\"";
}
return type;
}
void TaskFemConstraintHeatflux::changeEvent(QEvent *e)
{
TaskBox::changeEvent(e);

View File

@@ -53,6 +53,7 @@ public:
double getAmbientTemp(void) const;
/*double getFaceTemp(void) const;*/
double getFilmCoef(void) const;
std::string get_constraint_type(void) const;
virtual const std::string getReferences() const;
private Q_SLOTS:
@@ -60,7 +61,9 @@ private Q_SLOTS:
void onAmbientTempChanged(double val);
/*void onFaceTempChanged(double val);*/
void onFilmCoefChanged(double val);
void onHeatFluxChanged(double val);
void Conv();
void Flux();
void addToSelection();
void removeFromSelection();
void setSelection(QListWidgetItem* item);

View File

@@ -7,13 +7,13 @@
<x>0</x>
<y>0</y>
<width>379</width>
<height>400</height>
<height>531</height>
</rect>
</property>
<property name="windowTitle">
<string>TaskFemConstraintHeatflux</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="lbl_references">
<property name="text">
@@ -43,46 +43,104 @@
<widget class="QListWidget" name="lw_references"/>
</item>
<item>
<layout class="QHBoxLayout" name="layoutAmbientTemp">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="lbl_ambienttemp">
<widget class="QRadioButton" name="rb_convection">
<property name="text">
<string>Ambient Temperature</string>
<string>Surface Convection</string>
</property>
</widget>
</item>
<item>
<widget class="Gui::InputField" name="if_ambienttemp">
<widget class="QRadioButton" name="rb_dflux">
<property name="text">
<string>300 K</string>
</property>
<property name="unit" stdset="0">
<string notr="true">K</string>
<string>Surface heat flux</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layoutFilmCoef">
<item>
<widget class="QLabel" name="lbl_filmcoef">
<property name="text">
<string>Film coefficient</string>
</property>
</widget>
</item>
<item>
<widget class="Gui::InputField" name="if_filmcoef">
<property name="text">
<string>1 W/m^2/K</string>
</property>
<property name="unit" stdset="0">
<string notr="true">W/m^2/K</string>
</property>
</widget>
</item>
</layout>
<widget class="QStackedWidget" name="sw_heatflux">
<property name="currentIndex">
<number>1</number>
</property>
<widget class="QWidget" name="page">
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="layoutFilmCoef">
<item>
<widget class="QLabel" name="lbl_filmcoef">
<property name="text">
<string>Film coefficient</string>
</property>
</widget>
</item>
<item>
<widget class="Gui::InputField" name="if_filmcoef">
<property name="text">
<string>1 W/m^2/K</string>
</property>
<property name="unit" stdset="0">
<string notr="true">W/m^2/K</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layoutAmbientTemp">
<item>
<widget class="QLabel" name="lbl_ambienttemp">
<property name="text">
<string>Ambient Temperature</string>
</property>
</widget>
</item>
<item>
<widget class="Gui::InputField" name="if_ambienttemp">
<property name="text">
<string>300 K</string>
</property>
<property name="unit" stdset="0">
<string notr="true">K</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_2">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Surface heat flux</string>
</property>
</widget>
</item>
<item>
<widget class="Gui::InputField" name="if_heatflux">
<property name="text">
<string>300 K</string>
</property>
<property name="unit" stdset="0">
<string notr="true">K</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>