diff --git a/src/Mod/Fem/App/FemConstraintTemperature.cpp b/src/Mod/Fem/App/FemConstraintTemperature.cpp index 1d010ed3b..3846be44e 100644 --- a/src/Mod/Fem/App/FemConstraintTemperature.cpp +++ b/src/Mod/Fem/App/FemConstraintTemperature.cpp @@ -42,9 +42,15 @@ using namespace Fem; PROPERTY_SOURCE(Fem::ConstraintTemperature, Fem::Constraint); +static const char* ConstraintTypes[] = {"CFlux","Temperature", NULL}; + ConstraintTemperature::ConstraintTemperature() { ADD_PROPERTY(Temperature,(300.0)); + ADD_PROPERTY(CFlux,(0.0)); + ADD_PROPERTY_TYPE(ConstraintType,(1),"ConstraintTemperature",(App::PropertyType)(App::Prop_None), + "Type of constraint, temperature or concentrated heat flux"); + ConstraintType.setEnums(ConstraintTypes); ADD_PROPERTY_TYPE(Points,(Base::Vector3d()),"ConstraintTemperature",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output), "Points where symbols are drawn"); diff --git a/src/Mod/Fem/App/FemConstraintTemperature.h b/src/Mod/Fem/App/FemConstraintTemperature.h index cce8b58ec..f7c2a6dc9 100644 --- a/src/Mod/Fem/App/FemConstraintTemperature.h +++ b/src/Mod/Fem/App/FemConstraintTemperature.h @@ -46,6 +46,8 @@ public: //Temperature parameters App::PropertyFloat Temperature; + App::PropertyFloat CFlux; + App::PropertyEnumeration ConstraintType; /// recalculate the object diff --git a/src/Mod/Fem/FemInputWriterCcx.py b/src/Mod/Fem/FemInputWriterCcx.py index 283da75e6..102fa47ed 100644 --- a/src/Mod/Fem/FemInputWriterCcx.py +++ b/src/Mod/Fem/FemInputWriterCcx.py @@ -802,9 +802,15 @@ class FemInputWriterCcx(FemInputWriter.FemInputWriter): f.write('** written by {} function\n'.format(sys._getframe().f_code.co_name)) for ftobj in self.temperature_objects: fixedtemp_obj = ftobj['Object'] - f.write('*BOUNDARY\n') - f.write('{},11,11,{}\n'.format(fixedtemp_obj.Name, fixedtemp_obj.Temperature)) - f.write('\n') + NumberOfNodes = len(ftobj['Nodes']) + if fixedtemp_obj.ConstraintType == "Temperature": + f.write('*BOUNDARY\n') + f.write('{},11,11,{}\n'.format(fixedtemp_obj.Name, fixedtemp_obj.Temperature)) + f.write('\n') + elif fixedtemp_obj.ConstraintType == "CFlux": + f.write('*CFLUX\n') + f.write('{},11,{}\n'.format(fixedtemp_obj.Name, fixedtemp_obj.CFlux / NumberOfNodes)) + f.write('\n') def write_constraints_heatflux(self, f): f.write('\n***********************************************************\n') diff --git a/src/Mod/Fem/Gui/Command.cpp b/src/Mod/Fem/Gui/Command.cpp index b5480e208..9d8616abc 100644 --- a/src/Mod/Fem/Gui/Command.cpp +++ b/src/Mod/Fem/Gui/Command.cpp @@ -798,7 +798,7 @@ CmdFemConstraintTemperature::CmdFemConstraintTemperature() sAppModule = "Fem"; sGroup = QT_TR_NOOP("Fem"); sMenuText = QT_TR_NOOP("Constraint temperature "); - sToolTipText = QT_TR_NOOP("Creates a FEM constraint for a temperature acting on a face"); + sToolTipText = QT_TR_NOOP("Creates a FEM constraint for a temperature/concentrated heat flux acting on a face"); sWhatsThis = "Fem_ConstraintTemperature"; sStatusTip = sToolTipText; sPixmap = "fem-constraint-temperature"; diff --git a/src/Mod/Fem/Gui/TaskFemConstraintTemperature.cpp b/src/Mod/Fem/Gui/TaskFemConstraintTemperature.cpp index 5804cd90c..42c0d8f2e 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintTemperature.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraintTemperature.cpp @@ -73,6 +73,11 @@ TaskFemConstraintTemperature::TaskFemConstraintTemperature(ViewProviderFemConstr connect(ui->lw_references, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(setSelection(QListWidgetItem*))); + connect(ui->rb_temperature, SIGNAL(clicked(bool)), this, SLOT(Temp())); + connect(ui->rb_cflux, SIGNAL(clicked(bool)), this, SLOT(Flux())); + + connect(ui->if_temperature, SIGNAL(valueChanged(double)), + this, SLOT(onTempCfluxChanged(double))); this->groupLayout()->addWidget(proxy); @@ -85,8 +90,23 @@ TaskFemConstraintTemperature::TaskFemConstraintTemperature(ViewProviderFemConstr // Fill data into dialog elements ui->if_temperature->setMinimum(0); ui->if_temperature->setMaximum(FLOAT_MAX); - Base::Quantity t = Base::Quantity(pcConstraint->Temperature.getValue(), Base::Unit::Temperature); - ui->if_temperature->setValue(t); + + std::string constraint_type = pcConstraint->ConstraintType.getValueAsString(); + if (constraint_type == "Temperature") { + ui->rb_temperature->setChecked(1); + std::string str = "Temperature"; + QString qstr = QString::fromStdString(str); + ui->lbl_type->setText(qstr); + Base::Quantity t = Base::Quantity(pcConstraint->Temperature.getValue(), Base::Unit::Temperature); + ui->if_temperature->setValue(t); + } else if (constraint_type == "CFlux") { + ui->rb_cflux->setChecked(1); + std::string str = "Concentrated heat flux"; + QString qstr = QString::fromStdString(str); + ui->lbl_type->setText(qstr); + Base::Quantity c = Base::Quantity(pcConstraint->CFlux.getValue(), Base::Unit::Power); + ui->if_temperature->setValue(c); + } ui->lw_references->clear(); for (std::size_t i = 0; i < Objects.size(); i++) { @@ -117,6 +137,42 @@ void TaskFemConstraintTemperature::updateUI() } } +void TaskFemConstraintTemperature::onTempCfluxChanged(double val) +{ + Fem::ConstraintTemperature* pcConstraint = static_cast(ConstraintView->getObject()); + if (ui->rb_temperature->isChecked()) { + pcConstraint->Temperature.setValue(val); + } else { + pcConstraint->CFlux.setValue(val); + } +} + +void TaskFemConstraintTemperature::Temp() +{ + Fem::ConstraintTemperature* pcConstraint = static_cast(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()); + std::string str = "Temperature"; + QString qstr = QString::fromStdString(str); + ui->lbl_type->setText(qstr); + Base::Quantity t = Base::Quantity(300, Base::Unit::Temperature); + ui->if_temperature->setValue(t); + pcConstraint->Temperature.setValue(300); +} + +void TaskFemConstraintTemperature::Flux() +{ + Fem::ConstraintTemperature* pcConstraint = static_cast(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()); + std::string str = "Concentrated heat flux"; + QString qstr = QString::fromStdString(str); + ui->lbl_type->setText(qstr); + Base::Quantity c = Base::Quantity(0, Base::Unit::Power); + ui->if_temperature->setValue(c); + pcConstraint->CFlux.setValue(0); +} + void TaskFemConstraintTemperature::addToSelection() { std::vector selection = Gui::Selection().getSelectionEx(); //gets vector of selected objects of active document @@ -255,6 +311,22 @@ double TaskFemConstraintTemperature::get_temperature() const{ return temperature_in_kelvin; } +double TaskFemConstraintTemperature::get_cflux() const{ + Base::Quantity cflux = ui->if_temperature->getQuantity(); + double cflux_in_watt = cflux.getValueAs(Base::Quantity::Watt); + return cflux_in_watt; +} + +std::string TaskFemConstraintTemperature::get_constraint_type(void) const { + std::string type; + if (ui->rb_temperature->isChecked()) { + type = "\"Temperature\""; + } else if (ui->rb_cflux->isChecked()) { + type = "\"CFlux\""; + } + return type; +} + void TaskFemConstraintTemperature::changeEvent(QEvent *) { // TaskBox::changeEvent(e); @@ -297,9 +369,6 @@ bool TaskDlgFemConstraintTemperature::accept() const TaskFemConstraintTemperature* parameterTemperature = static_cast(parameter); try { - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Temperature = %f", - name.c_str(), parameterTemperature->get_temperature()); - std::string scale = parameterTemperature->getScale(); //OvG: determine modified scale Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Scale = %s", name.c_str(), scale.c_str()); //OvG: implement modified scale } diff --git a/src/Mod/Fem/Gui/TaskFemConstraintTemperature.h b/src/Mod/Fem/Gui/TaskFemConstraintTemperature.h index 9559e30ad..f7aa7e47a 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintTemperature.h +++ b/src/Mod/Fem/Gui/TaskFemConstraintTemperature.h @@ -52,10 +52,14 @@ public: ~TaskFemConstraintTemperature(); const std::string getReferences() const; double get_temperature()const; + double get_cflux() const; + std::string get_constraint_type(void) const; private Q_SLOTS: void onReferenceDeleted(void); - + void onTempCfluxChanged(double val); + void Temp(); + void Flux(); void addToSelection(); void removeFromSelection(); void setSelection(QListWidgetItem* item); diff --git a/src/Mod/Fem/Gui/TaskFemConstraintTemperature.ui b/src/Mod/Fem/Gui/TaskFemConstraintTemperature.ui index 426b9eb8f..5180f7240 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintTemperature.ui +++ b/src/Mod/Fem/Gui/TaskFemConstraintTemperature.ui @@ -6,8 +6,8 @@ 0 0 - 309 - 233 + 503 + 340 @@ -42,10 +42,34 @@ + + + + + + Temperature + + + true + + + false + + + + + + + Concentrated heat flux + + + + + - + Temperature