diff --git a/src/Mod/Fem/App/FemConstraintInitialTemperature.cpp b/src/Mod/Fem/App/FemConstraintInitialTemperature.cpp index 18a4b4c57b..a8ef1ea755 100644 --- a/src/Mod/Fem/App/FemConstraintInitialTemperature.cpp +++ b/src/Mod/Fem/App/FemConstraintInitialTemperature.cpp @@ -34,12 +34,16 @@ PROPERTY_SOURCE(Fem::ConstraintInitialTemperature, Fem::Constraint) ConstraintInitialTemperature::ConstraintInitialTemperature() { - ADD_PROPERTY(initialTemperature,(300.0)); + ADD_PROPERTY(initialTemperature, (300.0)); - ADD_PROPERTY_TYPE(Points,(Base::Vector3d()),"ConstraintInitialTemperature",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output), + ADD_PROPERTY_TYPE(Points, (Base::Vector3d()), + "ConstraintInitialTemperature", + App::PropertyType(App::Prop_ReadOnly | App::Prop_Output), "Points where symbols are drawn"); - ADD_PROPERTY_TYPE(Normals,(Base::Vector3d()),"ConstraintInitialTemperature",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output), - "Normals where symbols are drawn"); + ADD_PROPERTY_TYPE(Normals, (Base::Vector3d()), + "ConstraintInitialTemperature", + App::PropertyType(App::Prop_ReadOnly | App::Prop_Output), + "Normals where symbols are drawn"); Points.setValues(std::vector()); Normals.setValues(std::vector()); @@ -57,6 +61,19 @@ const char* ConstraintInitialTemperature::getViewProviderName() const return "FemGui::ViewProviderFemConstraintInitialTemperature"; } +void ConstraintInitialTemperature::handleChangedPropertyType(Base::XMLReader& reader, + const char* TypeName, + App::Property* prop) +{ + // property initialTemperature had App::PropertyFloat, was changed to App::PropertyTemperature + if (prop == &initialTemperature && strcmp(TypeName, "App::PropertyFloat") == 0) { + App::PropertyFloat initialTemperatureProperty; + // restore the PropertyFloat to be able to set its value + initialTemperatureProperty.Restore(reader); + initialTemperature.setValue(initialTemperatureProperty.getValue()); + } +} + void ConstraintInitialTemperature::onChanged(const App::Property* prop) { // Note: If we call this at the end, then the arrows are not oriented correctly initially diff --git a/src/Mod/Fem/App/FemConstraintInitialTemperature.h b/src/Mod/Fem/App/FemConstraintInitialTemperature.h index 6cd0414b67..2bfcc7bb83 100644 --- a/src/Mod/Fem/App/FemConstraintInitialTemperature.h +++ b/src/Mod/Fem/App/FemConstraintInitialTemperature.h @@ -45,7 +45,7 @@ public: App::PropertyVectorList Normals; //Temperature parameters - App::PropertyFloat initialTemperature; + App::PropertyTemperature initialTemperature; /// recalculate the object @@ -55,6 +55,8 @@ public: const char* getViewProviderName() const override; protected: + void handleChangedPropertyType(Base::XMLReader& reader, const char* TypeName, + App::Property* prop); void onChanged(const App::Property* prop) override; }; diff --git a/src/Mod/Fem/App/FemConstraintTemperature.cpp b/src/Mod/Fem/App/FemConstraintTemperature.cpp index 2a990abfc7..26e8042bc6 100644 --- a/src/Mod/Fem/App/FemConstraintTemperature.cpp +++ b/src/Mod/Fem/App/FemConstraintTemperature.cpp @@ -36,16 +36,19 @@ static const char* ConstraintTypes[] = {"CFlux","Temperature", nullptr}; ConstraintTemperature::ConstraintTemperature() { - ADD_PROPERTY(Temperature,(300.0)); - ADD_PROPERTY(CFlux,(0.0)); - ADD_PROPERTY_TYPE(ConstraintType,(1),"ConstraintTemperature",(App::PropertyType)(App::Prop_None), + 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), + ADD_PROPERTY_TYPE(Points, (Base::Vector3d()), "ConstraintTemperature", + App::PropertyType(App::Prop_ReadOnly | App::Prop_Output), "Points where symbols are drawn"); - ADD_PROPERTY_TYPE(Normals,(Base::Vector3d()),"ConstraintTemperature",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output), - "Normals where symbols are drawn"); + ADD_PROPERTY_TYPE(Normals, (Base::Vector3d()), "ConstraintTemperature", + App::PropertyType(App::Prop_ReadOnly | App::Prop_Output), + "Normals where symbols are drawn"); Points.setValues(std::vector()); Normals.setValues(std::vector()); } @@ -60,6 +63,24 @@ const char* ConstraintTemperature::getViewProviderName() const return "FemGui::ViewProviderFemConstraintTemperature"; } +void ConstraintTemperature::handleChangedPropertyType(Base::XMLReader& reader, const char* TypeName, + App::Property* prop) +{ + // property Temperature had App::PropertyFloat and was changed to App::PropertyTemperature + if (prop == &Temperature && strcmp(TypeName, "App::PropertyFloat") == 0) { + App::PropertyFloat TemperatureProperty; + // restore the PropertyFloat to be able to set its value + TemperatureProperty.Restore(reader); + Temperature.setValue(TemperatureProperty.getValue()); + } + // property CFlux had App::PropertyFloat and was changed to App::PropertyPower + else if (prop == &CFlux && strcmp(TypeName, "App::PropertyFloat") == 0) { + App::PropertyFloat CFluxProperty; + CFluxProperty.Restore(reader); + CFlux.setValue(CFluxProperty.getValue()); + } +} + void ConstraintTemperature::onChanged(const App::Property* prop) { // Note: If we call this at the end, then the arrows are not oriented correctly initially diff --git a/src/Mod/Fem/App/FemConstraintTemperature.h b/src/Mod/Fem/App/FemConstraintTemperature.h index 38d58c0a37..c2e088f8db 100644 --- a/src/Mod/Fem/App/FemConstraintTemperature.h +++ b/src/Mod/Fem/App/FemConstraintTemperature.h @@ -45,8 +45,8 @@ public: App::PropertyVectorList Normals; //Temperature parameters - App::PropertyFloat Temperature; - App::PropertyFloat CFlux; + App::PropertyTemperature Temperature; + App::PropertyPower CFlux; App::PropertyEnumeration ConstraintType; @@ -57,6 +57,8 @@ public: const char* getViewProviderName() const override; protected: + void handleChangedPropertyType(Base::XMLReader& reader, const char* TypeName, + App::Property* prop); void onChanged(const App::Property* prop) override; }; diff --git a/src/Mod/Fem/Gui/TaskFemConstraintInitialTemperature.cpp b/src/Mod/Fem/Gui/TaskFemConstraintInitialTemperature.cpp index 0ca79fe1f6..93d06efda6 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintInitialTemperature.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraintInitialTemperature.cpp @@ -60,21 +60,17 @@ TaskFemConstraintInitialTemperature::TaskFemConstraintInitialTemperature( std::vector SubElements = pcConstraint->References.getSubValues(); // Fill data into dialog elements - ui->if_temperature->setMinimum(0); - ui->if_temperature->setMaximum(FLOAT_MAX); - Base::Quantity t = - Base::Quantity(pcConstraint->initialTemperature.getValue(), Base::Unit::Temperature); - ui->if_temperature->setValue(t); + ui->if_temperature->setValue(pcConstraint->initialTemperature.getQuantityValue()); + + ui->if_temperature->bind(pcConstraint->initialTemperature); } TaskFemConstraintInitialTemperature::~TaskFemConstraintInitialTemperature() {} -double TaskFemConstraintInitialTemperature::get_temperature() const +std::string TaskFemConstraintInitialTemperature::get_temperature() const { - Base::Quantity temperature = ui->if_temperature->getQuantity(); - double temperature_in_kelvin = temperature.getValueAs(Base::Quantity::Kelvin); - return temperature_in_kelvin; + return ui->if_temperature->value().getSafeUserString().toStdString(); } void TaskFemConstraintInitialTemperature::changeEvent(QEvent*) @@ -119,9 +115,9 @@ bool TaskDlgFemConstraintInitialTemperature::accept() try { Gui::Command::doCommand(Gui::Command::Doc, - "App.ActiveDocument.%s.initialTemperature = %f", + "App.ActiveDocument.%s.initialTemperature = \"%s\"", name.c_str(), - parameterTemperature->get_temperature()); + parameterTemperature->get_temperature().c_str()); std::string scale = parameterTemperature->getScale();// OvG: determine modified scale Gui::Command::doCommand(Gui::Command::Doc, diff --git a/src/Mod/Fem/Gui/TaskFemConstraintInitialTemperature.h b/src/Mod/Fem/Gui/TaskFemConstraintInitialTemperature.h index f9200093cc..459ab7d718 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintInitialTemperature.h +++ b/src/Mod/Fem/Gui/TaskFemConstraintInitialTemperature.h @@ -44,7 +44,7 @@ public: explicit TaskFemConstraintInitialTemperature( ViewProviderFemConstraintInitialTemperature* ConstraintView, QWidget* parent = nullptr); ~TaskFemConstraintInitialTemperature() override; - double get_temperature()const; + std::string get_temperature() const; protected: void changeEvent(QEvent *e) override; diff --git a/src/Mod/Fem/Gui/TaskFemConstraintInitialTemperature.ui b/src/Mod/Fem/Gui/TaskFemConstraintInitialTemperature.ui index d304282de2..d4af9edc9e 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintInitialTemperature.ui +++ b/src/Mod/Fem/Gui/TaskFemConstraintInitialTemperature.ui @@ -6,7 +6,7 @@ 0 0 - 300 + 268 57 @@ -25,15 +25,12 @@ - - - 300 K - + K - - 300.000000000000000 + + 0.000000000000000 @@ -41,9 +38,9 @@ - Gui::InputField - QLineEdit -
Gui/InputField.h
+ Gui::QuantitySpinBox + QWidget +
Gui/QuantitySpinBox.h
diff --git a/src/Mod/Fem/Gui/TaskFemConstraintTemperature.cpp b/src/Mod/Fem/Gui/TaskFemConstraintTemperature.cpp index 258f0b5c6b..e0da7de7fd 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintTemperature.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraintTemperature.cpp @@ -33,6 +33,7 @@ #include #include +#include #include #include @@ -54,23 +55,6 @@ TaskFemConstraintTemperature::TaskFemConstraintTemperature( ui->setupUi(proxy); QMetaObject::connectSlotsByName(this); - // create a context menu for the listview of the references - createDeleteAction(ui->lw_references); - connect(deleteAction, &QAction::triggered, - this, &TaskFemConstraintTemperature::onReferenceDeleted); - - connect(ui->lw_references, &QListWidget::currentItemChanged, - this, &TaskFemConstraintTemperature::setSelection); - connect(ui->lw_references, &QListWidget::itemClicked, - this, &TaskFemConstraintTemperature::setSelection); - connect(ui->rb_temperature, &QRadioButton::clicked, - this, &TaskFemConstraintTemperature::Temp); - connect(ui->rb_cflux, &QRadioButton::clicked, - this, &TaskFemConstraintTemperature::Flux); - - connect(ui->if_temperature, qOverload(&InputField::valueChanged), - this, &TaskFemConstraintTemperature::onTempCfluxChanged); - this->groupLayout()->addWidget(proxy); // Get the feature data @@ -87,20 +71,17 @@ TaskFemConstraintTemperature::TaskFemConstraintTemperature( 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); + ui->if_temperature->setValue(pcConstraint->Temperature.getQuantityValue()); + + ui->if_temperature->bind(pcConstraint->Temperature); + ui->if_temperature->setUnit(pcConstraint->Temperature.getUnit()); } 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->if_temperature->setValue(pcConstraint->CFlux.getQuantityValue()); + ui->if_temperature->bind(pcConstraint->CFlux); + ui->if_temperature->setUnit(pcConstraint->CFlux.getUnit()); } ui->lw_references->clear(); @@ -111,7 +92,28 @@ TaskFemConstraintTemperature::TaskFemConstraintTemperature( ui->lw_references->setCurrentRow(0, QItemSelectionModel::ClearAndSelect); } - //Selection buttons + // create a context menu for the listview of the references + createDeleteAction(ui->lw_references); + connect( + deleteAction, &QAction::triggered, this, &TaskFemConstraintTemperature::onReferenceDeleted); + + connect(ui->lw_references, + &QListWidget::currentItemChanged, + this, + &TaskFemConstraintTemperature::setSelection); + connect(ui->lw_references, + &QListWidget::itemClicked, + this, + &TaskFemConstraintTemperature::setSelection); + connect(ui->rb_temperature, &QRadioButton::clicked, this, &TaskFemConstraintTemperature::Temp); + connect(ui->rb_cflux, &QRadioButton::clicked, this, &TaskFemConstraintTemperature::Flux); + + connect(ui->if_temperature, + qOverload(&QuantitySpinBox::valueChanged), + this, + &TaskFemConstraintTemperature::onTempCfluxChanged); + + // Selection buttons buttonGroup->addButton(ui->btnAdd, (int)SelectionChangeModes::refAdd); buttonGroup->addButton(ui->btnRemove, (int)SelectionChangeModes::refRemove); @@ -132,48 +134,22 @@ 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); + ui->if_temperature->setUnit(pcConstraint->Temperature.getUnit()); + ui->if_temperature->setValue(pcConstraint->Temperature.getQuantityValue()); } 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); + ui->if_temperature->setUnit(pcConstraint->CFlux.getUnit()); + ui->if_temperature->setValue(pcConstraint->CFlux.getQuantityValue()); } void TaskFemConstraintTemperature::addToSelection() @@ -302,20 +278,21 @@ const std::string TaskFemConstraintTemperature::getReferences() const return TaskFemConstraint::getReferences(items); } -double TaskFemConstraintTemperature::get_temperature() const { - Base::Quantity temperature = ui->if_temperature->getQuantity(); - double temperature_in_kelvin = temperature.getValueAs(Base::Quantity::Kelvin); - return temperature_in_kelvin; +std::string TaskFemConstraintTemperature::get_temperature() const +{ + return ui->if_temperature->value().getSafeUserString().toStdString(); } -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_cflux() const +{ + return ui->if_temperature->value().getSafeUserString().toStdString(); } std::string TaskFemConstraintTemperature::get_constraint_type() const { + Fem::ConstraintTemperature* pcConstraint = + static_cast(ConstraintView->getObject()); std::string type; + if (ui->rb_temperature->isChecked()) { type = "\"Temperature\""; } @@ -385,7 +362,23 @@ bool TaskDlgFemConstraintTemperature::accept() const TaskFemConstraintTemperature* parameterTemperature = static_cast(parameter); + auto type = parameterTemperature->get_constraint_type(); + try { + Gui::Command::doCommand(Gui::Command::Doc, + "App.ActiveDocument.%s.ConstraintType = %s", + name.c_str(), + parameterTemperature->get_constraint_type().c_str()); + if (type == "Temperature") + Gui::Command::doCommand(Gui::Command::Doc, + "App.ActiveDocument.%s.Temperature = \"%s\"", + name.c_str(), + parameterTemperature->get_temperature().c_str()); + else if (type == "CFlux") + Gui::Command::doCommand(Gui::Command::Doc, + "App.ActiveDocument.%s.CFlux = \"%s\"", + name.c_str(), + parameterTemperature->get_cflux().c_str()); std::string scale = parameterTemperature->getScale();// OvG: determine modified scale Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.Scale = %s", diff --git a/src/Mod/Fem/Gui/TaskFemConstraintTemperature.h b/src/Mod/Fem/Gui/TaskFemConstraintTemperature.h index 291d35c6e7..d35d068f06 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintTemperature.h +++ b/src/Mod/Fem/Gui/TaskFemConstraintTemperature.h @@ -47,8 +47,8 @@ public: explicit TaskFemConstraintTemperature(ViewProviderFemConstraintTemperature *ConstraintView,QWidget *parent = nullptr); ~TaskFemConstraintTemperature() override; const std::string getReferences() const override; - double get_temperature()const; - double get_cflux() const; + std::string get_temperature() const; + std::string get_cflux() const; std::string get_constraint_type() const; private Q_SLOTS: diff --git a/src/Mod/Fem/Gui/TaskFemConstraintTemperature.ui b/src/Mod/Fem/Gui/TaskFemConstraintTemperature.ui index aad6ac3dc4..515afe6084 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintTemperature.ui +++ b/src/Mod/Fem/Gui/TaskFemConstraintTemperature.ui @@ -82,15 +82,12 @@ - - - 300 K - + K - - 300.000000000000000 + + 0.000000000000000 @@ -100,9 +97,9 @@ - Gui::InputField - QLineEdit -
Gui/InputField.h
+ Gui::QuantitySpinBox + QWidget +
Gui/QuantitySpinBox.h
diff --git a/src/Mod/Fem/femsolver/calculix/write_constraint_initialtemperature.py b/src/Mod/Fem/femsolver/calculix/write_constraint_initialtemperature.py index 7db9523ffa..36b024dbdd 100644 --- a/src/Mod/Fem/femsolver/calculix/write_constraint_initialtemperature.py +++ b/src/Mod/Fem/femsolver/calculix/write_constraint_initialtemperature.py @@ -25,6 +25,8 @@ __title__ = "FreeCAD FEM calculix constraint initialtemperature" __author__ = "Bernd Hahnebach" __url__ = "https://www.freecadweb.org" +import FreeCAD + def get_analysis_types(): return ["thermomech"] @@ -46,7 +48,12 @@ def write_constraint(f, femobj, inittemp_obj, ccxwriter): # floats read from ccx should use {:.13G}, see comment in writer module - f.write("{},{:.13G}\n".format(ccxwriter.ccx_nall, inittemp_obj.initialTemperature)) + f.write( + "{},{}\n".format( + ccxwriter.ccx_nall, + FreeCAD.Units.Quantity(inittemp_obj.initialTemperature.getValueAs("K")) + ) + ) # Should only be one object in the analysis diff --git a/src/Mod/Fem/femsolver/calculix/write_constraint_temperature.py b/src/Mod/Fem/femsolver/calculix/write_constraint_temperature.py index a8e534ddee..8b5879ae9b 100644 --- a/src/Mod/Fem/femsolver/calculix/write_constraint_temperature.py +++ b/src/Mod/Fem/femsolver/calculix/write_constraint_temperature.py @@ -25,6 +25,8 @@ __title__ = "FreeCAD FEM calculix constraint temperature" __author__ = "Bernd Hahnebach" __url__ = "https://www.freecadweb.org" +import FreeCAD + def get_analysis_types(): return ["thermomech"] @@ -68,12 +70,19 @@ def write_constraint(f, femobj, temp_obj, ccxwriter): NumberOfNodes = len(femobj["Nodes"]) if temp_obj.ConstraintType == "Temperature": f.write("*BOUNDARY\n") - f.write("{},11,11,{:.13G}\n".format(temp_obj.Name, temp_obj.Temperature)) + f.write( + "{},11,11,{}\n".format( + temp_obj.Name, FreeCAD.Units.Quantity(temp_obj.Temperature.getValueAs("K")) + ) + ) f.write("\n") elif temp_obj.ConstraintType == "CFlux": f.write("*CFLUX\n") - f.write("{},11,{:.13G}\n".format( - temp_obj.Name, - temp_obj.CFlux * 0.001 / NumberOfNodes - )) + # CFLUX has to be specified in mW + f.write( + "{},11,{}\n".format( + temp_obj.Name, + FreeCAD.Units.Quantity(temp_obj.CFlux.getValueAs("mW")) / NumberOfNodes + ) + ) f.write("\n") diff --git a/src/Mod/Fem/femsolver/elmer/equations/deformation_writer.py b/src/Mod/Fem/femsolver/elmer/equations/deformation_writer.py index 39191256b9..a473e0779d 100644 --- a/src/Mod/Fem/femsolver/elmer/equations/deformation_writer.py +++ b/src/Mod/Fem/femsolver/elmer/equations/deformation_writer.py @@ -186,7 +186,7 @@ class DeformationWriter: # temperature tempObj = self.write.getSingleMember("Fem::ConstraintInitialTemperature") if tempObj is not None: - refTemp = self.write.getFromUi(tempObj.initialTemperature, "K", "O") + refTemp = float(tempObj.initialTemperature.getValueAs("K")) for name in bodies: self.write.material(name, "Reference Temperature", refTemp) # get the material data for all bodies diff --git a/src/Mod/Fem/femsolver/elmer/equations/elasticity_writer.py b/src/Mod/Fem/femsolver/elmer/equations/elasticity_writer.py index 70c2de265f..975c1f2689 100644 --- a/src/Mod/Fem/femsolver/elmer/equations/elasticity_writer.py +++ b/src/Mod/Fem/femsolver/elmer/equations/elasticity_writer.py @@ -402,7 +402,7 @@ class ElasticityWriter: # temperature tempObj = self.write.getSingleMember("Fem::ConstraintInitialTemperature") if tempObj is not None: - refTemp = self.write.getFromUi(tempObj.initialTemperature, "K", "O") + refTemp = float(tempObj.initialTemperature.getValueAs("K")) for name in bodies: self.write.material(name, "Reference Temperature", refTemp) # get the material data for all bodies diff --git a/src/Mod/Fem/femsolver/elmer/equations/flow_writer.py b/src/Mod/Fem/femsolver/elmer/equations/flow_writer.py index 176706a56d..59c2e925ab 100644 --- a/src/Mod/Fem/femsolver/elmer/equations/flow_writer.py +++ b/src/Mod/Fem/femsolver/elmer/equations/flow_writer.py @@ -126,7 +126,7 @@ class Flowwriter: def handleFlowMaterial(self, bodies): tempObj = self.write.getSingleMember("Fem::ConstraintInitialTemperature") if tempObj is not None: - refTemp = self.write.getFromUi(tempObj.initialTemperature, "K", "O") + refTemp = float(tempObj.initialTemperature.getValueAs("K")) for name in bodies: self.write.material(name, "Reference Temperature", refTemp) for obj in self.write.getMember("App::MaterialObject"): diff --git a/src/Mod/Fem/femsolver/elmer/equations/heat_writer.py b/src/Mod/Fem/femsolver/elmer/equations/heat_writer.py index ac42e6841f..d5f4dc9334 100644 --- a/src/Mod/Fem/femsolver/elmer/equations/heat_writer.py +++ b/src/Mod/Fem/femsolver/elmer/equations/heat_writer.py @@ -103,12 +103,10 @@ class Heatwriter: if obj.References: for name in obj.References[0][1]: if obj.ConstraintType == "Temperature": - temp = self.write.getFromUi(obj.Temperature, "K", "O") - self.write.boundary(name, "Temperature", temp) + temperature = float(obj.Temperature.getValueAs("K")) + self.write.boundary(name, "Temperature", temperature) elif obj.ConstraintType == "CFlux": - # the CFLUX property stores the value in µW - # but the unit system is not aware of µW, only of mW - flux = 0.001 * self.write.getFromUi(obj.CFlux, "mW", "M*L^2*T^-3") + flux = float(obj.CFlux.getValueAs("W")) # CFLUX is the flux per mesh node flux = flux / NumberOfNodes self.write.boundary(name, "Temperature Load", flux) @@ -128,12 +126,12 @@ class Heatwriter: self.write.handled(obj) def handleHeatInitial(self, bodies): - obj = self.write.getSingleMember("Fem::ConstraintInitialTemperature") - if obj is not None: - for name in bodies: - temp = self.write.getFromUi(obj.initialTemperature, "K", "O") - self.write.initial(name, "Temperature", temp) - self.write.handled(obj) + tempObj = self.write.getSingleMember("Fem::ConstraintInitialTemperature") + if tempObj is not None: + refTemp = float(tempObj.initialTemperature.getValueAs("K")) + for name in bodies: + self.write.initial(name, "Temperature", refTemp) + self.write.handled(tempObj) def _outputHeatBodyForce(self, obj, name): heatSource = self.write.getFromUi(obj.HeatSource, "W/kg", "L^2*T^-3") @@ -165,7 +163,7 @@ class Heatwriter: def handleHeatMaterial(self, bodies): tempObj = self.write.getSingleMember("Fem::ConstraintInitialTemperature") if tempObj is not None: - refTemp = self.write.getFromUi(tempObj.initialTemperature, "K", "O") + refTemp = float(tempObj.initialTemperature.getValueAs("K")) for name in bodies: self.write.material(name, "Reference Temperature", refTemp) for obj in self.write.getMember("App::MaterialObject"): diff --git a/src/Mod/Fem/femtest/data/calculix/thermomech_bimetall.inp b/src/Mod/Fem/femtest/data/calculix/thermomech_bimetall.inp index 2217e283e6..2be2695488 100644 --- a/src/Mod/Fem/femtest/data/calculix/thermomech_bimetall.inp +++ b/src/Mod/Fem/femtest/data/calculix/thermomech_bimetall.inp @@ -7070,7 +7070,7 @@ Evolumes ** Initial temperature constraint *INITIAL CONDITIONS,TYPE=TEMPERATURE ** ConstraintInitialTemperature -Nall,273 +Nall,273.0 *********************************************************** ** Sections @@ -7096,11 +7096,11 @@ ConstraintFixed,3 ** Fixed temperature constraint applied ** ConstraintTemperatureHot *BOUNDARY -ConstraintTemperatureHot,11,11,373 +ConstraintTemperatureHot,11,11,373.0 ** ConstraintTemperatureNormal *BOUNDARY -ConstraintTemperatureNormal,11,11,273 +ConstraintTemperatureNormal,11,11,273.0 *********************************************************** diff --git a/src/Mod/Fem/femtest/data/calculix/thermomech_spine.inp b/src/Mod/Fem/femtest/data/calculix/thermomech_spine.inp index 7cc0b503a3..92a36026b0 100644 --- a/src/Mod/Fem/femtest/data/calculix/thermomech_spine.inp +++ b/src/Mod/Fem/femtest/data/calculix/thermomech_spine.inp @@ -123,7 +123,7 @@ Evolumes ** Initial temperature constraint *INITIAL CONDITIONS,TYPE=TEMPERATURE ** FemConstraintInitialTemperature -Nall,300 +Nall,300.0 *********************************************************** ** Sections