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 0cddd74255
commit 96a705dc7d
9 changed files with 187 additions and 45 deletions

View File

@ -485,7 +485,8 @@ QString Unit::getTypeString(void) const
if(*this == Unit::ThermalExpansionCoefficient ) return QString::fromLatin1("ThermalExpansionCoefficient"); else
if(*this == Unit::SpecificHeat ) return QString::fromLatin1("SpecificHeat"); else
if(*this == Unit::ThermalTransferCoefficient ) return QString::fromLatin1("ThermalTransferCoefficient"); else
if(*this == Unit::HeatFluxDensity ) return QString::fromLatin1("HeatFluxDensity"); else
return QString();
}
@ -517,3 +518,4 @@ Unit Unit::ThermalConductivity (1,1,-3,0,-1);
Unit Unit::ThermalExpansionCoefficient (0,0,0,0,-1);
Unit Unit::SpecificHeat (2,0,-2,0,-1);
Unit Unit::ThermalTransferCoefficient (0,1,-3,0,-1);
Unit Unit::HeatFluxDensity (0,1,-3,0,0);

View File

@ -120,6 +120,7 @@ public:
static Unit ThermalExpansionCoefficient;
static Unit SpecificHeat;
static Unit ThermalTransferCoefficient;
static Unit HeatFluxDensity;
//@}
protected:

View File

@ -71,7 +71,7 @@ DlgUnitsCalculator::DlgUnitsCalculator( QWidget* parent, Qt::WindowFlags fl )
<< Base::Unit::AmountOfSubstance << Base::Unit::LuminoseIntensity << Base::Unit::Stress
<< Base::Unit::Pressure << Base::Unit::Force << Base::Unit::Work << Base::Unit::Power
<< Base::Unit::ThermalConductivity << Base::Unit::ThermalExpansionCoefficient
<< Base::Unit::SpecificHeat << Base::Unit::ThermalTransferCoefficient;
<< Base::Unit::SpecificHeat << Base::Unit::ThermalTransferCoefficient <<Base::Unit::HeatFluxDensity;
for (QList<Base::Unit>::iterator it = units.begin(); it != units.end(); ++it) {
ui->unitsBox->addItem(it->getTypeString());
}

View File

@ -41,11 +41,17 @@ using namespace Fem;
PROPERTY_SOURCE(Fem::ConstraintHeatflux, Fem::Constraint);
static const char* ConstraintTypes[] = {"DFlux","Convection", NULL};
ConstraintHeatflux::ConstraintHeatflux()
{
ADD_PROPERTY(AmbientTemp,(0.0));
/*ADD_PROPERTY(FaceTemp,(0.0));*/
ADD_PROPERTY(FilmCoef,(0.0));
ADD_PROPERTY(DFlux,(0.0));
ADD_PROPERTY_TYPE(ConstraintType,(1),"ConstraintHeatflux",(App::PropertyType)(App::Prop_None),
"Type of constraint, surface convection or surface heat flux");
ConstraintType.setEnums(ConstraintTypes);
ADD_PROPERTY_TYPE(Points,(Base::Vector3d()),"ConstraintHeatflux",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output),
"Points where symbols are drawn");

View File

@ -41,6 +41,9 @@ public:
App::PropertyFloat AmbientTemp;
/*App::PropertyFloat FaceTemp;*/
App::PropertyFloat FilmCoef;
App::PropertyFloat DFlux;
App::PropertyEnumeration ConstraintType;
App::PropertyVectorList Points;
App::PropertyVectorList Normals;

View File

@ -818,15 +818,26 @@ class FemInputWriterCcx(FemInputWriter.FemInputWriter):
f.write('** written by {} function\n'.format(sys._getframe().f_code.co_name))
for hfobj in self.heatflux_objects:
heatflux_obj = hfobj['Object']
f.write('*FILM\n')
for o, elem_tup in heatflux_obj.References:
for elem in elem_tup:
ho = o.Shape.getElement(elem)
if ho.ShapeType == 'Face':
v = self.mesh_object.FemMesh.getccxVolumesByFace(ho)
f.write("** Heat flux on face {}\n".format(elem))
for i in v:
f.write("{},F{},{},{}\n".format(i[0], i[1], heatflux_obj.AmbientTemp, heatflux_obj.FilmCoef * 0.001)) # SvdW add factor to force heatflux to units system of t/mm/s/K # OvG: Only write out the VolumeIDs linked to a particular face
if heatflux_obj.ConstraintType == "Convection":
f.write('*FILM\n')
for o, elem_tup in heatflux_obj.References:
for elem in elem_tup:
ho = o.Shape.getElement(elem)
if ho.ShapeType == 'Face':
v = self.mesh_object.FemMesh.getccxVolumesByFace(ho)
f.write("** Heat flux on face {}\n".format(elem))
for i in v:
f.write("{},F{},{},{}\n".format(i[0], i[1], heatflux_obj.AmbientTemp, heatflux_obj.FilmCoef * 0.001)) # SvdW add factor to force heatflux to units system of t/mm/s/K # OvG: Only write out the VolumeIDs linked to a particular face
elif heatflux_obj.ConstraintType == "DFlux":
f.write('*DFLUX\n')
for o, elem_tup in heatflux_obj.References:
for elem in elem_tup:
ho = o.Shape.getElement(elem)
if ho.ShapeType == 'Face':
v = self.mesh_object.FemMesh.getccxVolumesByFace(ho)
f.write("** Heat flux on face {}\n".format(elem))
for i in v:
f.write("{},S{},{}\n".format(i[0], i[1], heatflux_obj.DFlux))
def write_outputs_types(self, f):
f.write('\n***********************************************************\n')

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>