FEM: FemConstraintTemperature: Add CFLUX option to temperature constraint
This commit is contained in:
parent
7e82bd1d7d
commit
0cddd74255
|
@ -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");
|
||||
|
|
|
@ -46,6 +46,8 @@ public:
|
|||
|
||||
//Temperature parameters
|
||||
App::PropertyFloat Temperature;
|
||||
App::PropertyFloat CFlux;
|
||||
App::PropertyEnumeration ConstraintType;
|
||||
|
||||
|
||||
/// recalculate the object
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -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<Fem::ConstraintTemperature*>(ConstraintView->getObject());
|
||||
if (ui->rb_temperature->isChecked()) {
|
||||
pcConstraint->Temperature.setValue(val);
|
||||
} else {
|
||||
pcConstraint->CFlux.setValue(val);
|
||||
}
|
||||
}
|
||||
|
||||
void TaskFemConstraintTemperature::Temp()
|
||||
{
|
||||
Fem::ConstraintTemperature* pcConstraint = static_cast<Fem::ConstraintTemperature*>(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<Fem::ConstraintTemperature*>(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<Gui::SelectionObject> 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<const TaskFemConstraintTemperature*>(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
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>309</width>
|
||||
<height>233</height>
|
||||
<width>503</width>
|
||||
<height>340</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -42,10 +42,34 @@
|
|||
<item>
|
||||
<widget class="QListWidget" name="lw_references"/>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="rb_temperature">
|
||||
<property name="text">
|
||||
<string>Temperature</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="rb_cflux">
|
||||
<property name="text">
|
||||
<string>Concentrated heat flux</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layoutTemperature">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<widget class="QLabel" name="lbl_type">
|
||||
<property name="text">
|
||||
<string>Temperature</string>
|
||||
</property>
|
||||
|
|
Loading…
Reference in New Issue
Block a user