From dba00d44d0ac74bff286e70d8340596912dca092 Mon Sep 17 00:00:00 2001 From: Uwe Date: Wed, 22 Mar 2023 06:56:02 +0100 Subject: [PATCH] [FEM] extend displacement constraint - add fields to specify a formula for the displacement, this is necessary to make transient deformation analyses with Elmer - add option to set displacement from result of flow equation - this way also a major overhaul -> simpler dialog logic etc. --- src/Mod/Fem/App/FemConstraintDisplacement.cpp | 62 +- src/Mod/Fem/App/FemConstraintDisplacement.h | 8 +- .../Fem/Gui/TaskFemConstraintDisplacement.cpp | 654 ++++++++++-------- .../Fem/Gui/TaskFemConstraintDisplacement.h | 38 +- .../Fem/Gui/TaskFemConstraintDisplacement.ui | 611 +++++++++------- .../ViewProviderFemConstraintDisplacement.cpp | 11 +- .../elmer/equations/deformation_writer.py | 31 +- .../elmer/equations/elasticity_writer.py | 31 +- 8 files changed, 837 insertions(+), 609 deletions(-) diff --git a/src/Mod/Fem/App/FemConstraintDisplacement.cpp b/src/Mod/Fem/App/FemConstraintDisplacement.cpp index c4d847138f..d7ba4b5535 100644 --- a/src/Mod/Fem/App/FemConstraintDisplacement.cpp +++ b/src/Mod/Fem/App/FemConstraintDisplacement.cpp @@ -41,39 +41,55 @@ ConstraintDisplacement::ConstraintDisplacement() // Displacement or Rotation not 0.0, prescribed displacement, Free and Fix should be False // x displacement - ADD_PROPERTY(xFix,(0)); - ADD_PROPERTY(xFree,(1)); - ADD_PROPERTY(xDisplacement,(0.0)); + ADD_PROPERTY(xFix, (false)); + ADD_PROPERTY(xFree, (1)); + ADD_PROPERTY(xDisplacement, (0.0)); + ADD_PROPERTY(hasXFormula, (false)); + ADD_PROPERTY(xDisplacementFormula, ("")); // y displacement - ADD_PROPERTY(yFix,(0)); - ADD_PROPERTY(yFree,(1)); - ADD_PROPERTY(yDisplacement,(0.0)); + ADD_PROPERTY(yFix, (false)); + ADD_PROPERTY(yFree, (true)); + ADD_PROPERTY(yDisplacement, (0.0)); + ADD_PROPERTY(hasYFormula, (false)); + ADD_PROPERTY(yDisplacementFormula, ("")); // z displacement - ADD_PROPERTY(zFix,(0)); - ADD_PROPERTY(zFree,(1)); - ADD_PROPERTY(zDisplacement,(0.0)); + ADD_PROPERTY(zFix, (false)); + ADD_PROPERTY(zFree, (true)); + ADD_PROPERTY(zDisplacement, (0.0)); + ADD_PROPERTY(hasZFormula, (false)); + ADD_PROPERTY(zDisplacementFormula, ("")); + + // flow surface force + ADD_PROPERTY(useFlowSurfaceForce, (false)); // x rotation - ADD_PROPERTY(rotxFix,(0)); - ADD_PROPERTY(rotxFree,(1)); - ADD_PROPERTY(xRotation,(0.0)); + ADD_PROPERTY(rotxFix, (false)); + ADD_PROPERTY(rotxFree, (true)); + ADD_PROPERTY(xRotation, (0.0)); // y rotation - ADD_PROPERTY(rotyFix,(0)); - ADD_PROPERTY(rotyFree,(1)); - ADD_PROPERTY(yRotation,(0.0)); + ADD_PROPERTY(rotyFix, (false)); + ADD_PROPERTY(rotyFree, (true)); + ADD_PROPERTY(yRotation, (0.0)); // z rotation - ADD_PROPERTY(rotzFix,(0)); - ADD_PROPERTY(rotzFree,(1)); - ADD_PROPERTY(zRotation,(0.0)); + ADD_PROPERTY(rotzFix, (false)); + ADD_PROPERTY(rotzFree, (true)); + ADD_PROPERTY(zRotation, (0.0)); - ADD_PROPERTY_TYPE(Points,(Base::Vector3d()),"ConstraintFixed",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output), + ADD_PROPERTY_TYPE(Points, + (Base::Vector3d()), + "ConstraintFixed", + App::PropertyType(App::Prop_ReadOnly | App::Prop_Output), "Points where symbols are drawn"); - ADD_PROPERTY_TYPE(Normals,(Base::Vector3d()),"ConstraintFixed",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output), - "Normals where symbols are drawn"); + ADD_PROPERTY_TYPE(Normals, + (Base::Vector3d()), + "ConstraintFixed", + App::PropertyType(App::Prop_ReadOnly | App::Prop_Output), + "Normals where symbols are drawn"); + Points.setValues(std::vector()); Normals.setValues(std::vector()); } @@ -97,11 +113,11 @@ void ConstraintDisplacement::onChanged(const App::Property* prop) if (prop == &References) { std::vector points; std::vector normals; - int scale = 1; //OvG: Enforce use of scale + int scale = 1; // OvG: Enforce use of scale if (getPoints(points, normals, &scale)) { Points.setValues(points); Normals.setValues(normals); - Scale.setValue(scale); //OvG: Scale + Scale.setValue(scale); // OvG: Scale Points.touch(); // This triggers ViewProvider::updateData() } } diff --git a/src/Mod/Fem/App/FemConstraintDisplacement.h b/src/Mod/Fem/App/FemConstraintDisplacement.h index 9e6958ebd8..6bdf853f6a 100644 --- a/src/Mod/Fem/App/FemConstraintDisplacement.h +++ b/src/Mod/Fem/App/FemConstraintDisplacement.h @@ -51,6 +51,9 @@ public: App::PropertyFloat xRotation; App::PropertyFloat yRotation; App::PropertyFloat zRotation; + App::PropertyString xDisplacementFormula; + App::PropertyString yDisplacementFormula; + App::PropertyString zDisplacementFormula; App::PropertyBool xFree; App::PropertyBool yFree; App::PropertyBool zFree; @@ -63,7 +66,10 @@ public: App::PropertyBool rotxFix; App::PropertyBool rotyFix; App::PropertyBool rotzFix; - //App::PropertyBool element; + App::PropertyBool hasXFormula; + App::PropertyBool hasYFormula; + App::PropertyBool hasZFormula; + App::PropertyBool useFlowSurfaceForce; /// recalculate the object App::DocumentObjectExecReturn *execute() override; diff --git a/src/Mod/Fem/Gui/TaskFemConstraintDisplacement.cpp b/src/Mod/Fem/Gui/TaskFemConstraintDisplacement.cpp index 208f8bf36d..5dce428a26 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintDisplacement.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraintDisplacement.cpp @@ -1,8 +1,9 @@ /*************************************************************************** - * Copyright (c) 2015 FreeCAD Developers * + * Copyright (c) 2015, 2023 FreeCAD Developers * * Authors: Michael Hindley * * Ruan Olwagen * * Oswald van Ginkel * + * Uwe Stöhr * * Based on Force constraint by Jan Rheinländer * * This file is part of the FreeCAD CAx development system. * * * @@ -24,7 +25,6 @@ ***************************************************************************/ #include "PreCompiled.h" - #ifndef _PreComp_ # include # include @@ -44,7 +44,8 @@ using namespace Gui; /* TRANSLATOR FemGui::TaskFemConstraintDisplacement */ -TaskFemConstraintDisplacement::TaskFemConstraintDisplacement(ViewProviderFemConstraintDisplacement* ConstraintView, QWidget* parent) +TaskFemConstraintDisplacement::TaskFemConstraintDisplacement( + ViewProviderFemConstraintDisplacement* ConstraintView, QWidget* parent) : TaskFemConstraintOnBoundary(ConstraintView, parent, "FEM_ConstraintDisplacement") { proxy = new QWidget(this); @@ -79,15 +80,20 @@ TaskFemConstraintDisplacement::TaskFemConstraintDisplacement(ViewProviderFemCons ui->spinzRotation->setMaximum(FLOAT_MAX); // Get the feature data - Fem::ConstraintDisplacement* pcConstraint = static_cast(ConstraintView->getObject()); - double fStates[6]; - bool bStates[12]; + Fem::ConstraintDisplacement* pcConstraint = + static_cast(ConstraintView->getObject()); + double fStates[6] {}; + const char* sStates[3] {}; + bool bStates[16] {}; fStates[0] = pcConstraint->xDisplacement.getValue(); fStates[1] = pcConstraint->yDisplacement.getValue(); fStates[2] = pcConstraint->zDisplacement.getValue(); fStates[3] = pcConstraint->xRotation.getValue(); fStates[4] = pcConstraint->yRotation.getValue(); fStates[5] = pcConstraint->zRotation.getValue(); + sStates[0] = pcConstraint->xDisplacementFormula.getValue(); + sStates[1] = pcConstraint->yDisplacementFormula.getValue(); + sStates[2] = pcConstraint->zDisplacementFormula.getValue(); bStates[0] = pcConstraint->xFix.getValue(); bStates[1] = pcConstraint->xFree.getValue(); bStates[2] = pcConstraint->yFix.getValue(); @@ -100,30 +106,14 @@ TaskFemConstraintDisplacement::TaskFemConstraintDisplacement(ViewProviderFemCons bStates[9] = pcConstraint->rotyFree.getValue(); bStates[10] = pcConstraint->rotzFix.getValue(); bStates[11] = pcConstraint->rotzFree.getValue(); + bStates[12] = pcConstraint->hasXFormula.getValue(); + bStates[13] = pcConstraint->hasYFormula.getValue(); + bStates[14] = pcConstraint->hasZFormula.getValue(); + bStates[15] = pcConstraint->useFlowSurfaceForce.getValue(); std::vector Objects = pcConstraint->References.getValues(); std::vector SubElements = pcConstraint->References.getSubValues(); - // Fill data into dialog elements - ui->spinxDisplacement->setValue(fStates[0]); - ui->spinyDisplacement->setValue(fStates[1]); - ui->spinzDisplacement->setValue(fStates[2]); - ui->spinxRotation->setValue(fStates[3]); - ui->spinyRotation->setValue(fStates[4]); - ui->spinzRotation->setValue(fStates[5]); - ui->dispxfix->setChecked(bStates[0]); - ui->dispxfree->setChecked(bStates[1]); - ui->dispyfix->setChecked(bStates[2]); - ui->dispyfree->setChecked(bStates[3]); - ui->dispzfix->setChecked(bStates[4]); - ui->dispzfree->setChecked(bStates[5]); - ui->rotxfix->setChecked(bStates[6]); - ui->rotxfree->setChecked(bStates[7]); - ui->rotyfix->setChecked(bStates[8]); - ui->rotyfree->setChecked(bStates[9]); - ui->rotzfix->setChecked(bStates[10]); - ui->rotzfree->setChecked(bStates[11]); - ui->lw_references->clear(); for (std::size_t i = 0; i < Objects.size(); i++) { ui->lw_references->addItem(makeRefText(Objects[i], SubElements[i])); @@ -132,35 +122,51 @@ TaskFemConstraintDisplacement::TaskFemConstraintDisplacement(ViewProviderFemCons ui->lw_references->setCurrentRow(0, QItemSelectionModel::ClearAndSelect); } - // Connect decimal value inputs - connect(ui->spinxDisplacement, qOverload(&QDoubleSpinBox::valueChanged), - this, &TaskFemConstraintDisplacement::x_changed); - connect(ui->spinyDisplacement, qOverload(&QDoubleSpinBox::valueChanged), - this, &TaskFemConstraintDisplacement::y_changed); - connect(ui->spinzDisplacement, qOverload(&QDoubleSpinBox::valueChanged), - this, &TaskFemConstraintDisplacement::z_changed); - connect(ui->spinxRotation, qOverload(&QDoubleSpinBox::valueChanged), - this, &TaskFemConstraintDisplacement::x_rot); - connect(ui->spinyRotation, qOverload(&QDoubleSpinBox::valueChanged), - this, &TaskFemConstraintDisplacement::y_rot); - connect(ui->spinzRotation, qOverload(&QDoubleSpinBox::valueChanged), - this, &TaskFemConstraintDisplacement::z_rot); // Connect check box values displacements - connect(ui->dispxfix, &QCheckBox::stateChanged, this, &TaskFemConstraintDisplacement::fixx); - connect(ui->dispxfree, &QCheckBox::stateChanged, this, &TaskFemConstraintDisplacement::freex); - connect(ui->dispyfix, &QCheckBox::stateChanged, this, &TaskFemConstraintDisplacement::fixy); - connect(ui->dispyfree, &QCheckBox::stateChanged, this, &TaskFemConstraintDisplacement::freey); - connect(ui->dispzfix, &QCheckBox::stateChanged, this, &TaskFemConstraintDisplacement::fixz); - connect(ui->dispzfree, &QCheckBox::stateChanged, this, &TaskFemConstraintDisplacement::freez); + connect(ui->dispxfix, &QCheckBox::toggled, this, &TaskFemConstraintDisplacement::fixx); + connect(ui->DisplacementXFormulaCB, &QCheckBox::toggled, + this, &TaskFemConstraintDisplacement::formulaX); + connect(ui->dispyfix, &QCheckBox::toggled, this, &TaskFemConstraintDisplacement::fixy); + connect(ui->DisplacementYFormulaCB, &QCheckBox::toggled, + this, &TaskFemConstraintDisplacement::formulaY); + connect(ui->dispzfix, &QCheckBox::toggled, this, &TaskFemConstraintDisplacement::fixz); + connect(ui->DisplacementZFormulaCB, &QCheckBox::toggled, + this, &TaskFemConstraintDisplacement::formulaZ); + connect(ui->FlowForceCB, &QCheckBox::toggled, + this, &TaskFemConstraintDisplacement::flowForce); // Connect to check box values for rotations - connect(ui->rotxfix, &QCheckBox::stateChanged, this, &TaskFemConstraintDisplacement::rotfixx); - connect(ui->rotxfree, &QCheckBox::stateChanged, this, &TaskFemConstraintDisplacement::rotfreex); - connect(ui->rotyfix, &QCheckBox::stateChanged, this, &TaskFemConstraintDisplacement::rotfixy); - connect(ui->rotyfree, &QCheckBox::stateChanged, this, &TaskFemConstraintDisplacement::rotfreey); - connect(ui->rotzfix, &QCheckBox::stateChanged, this, &TaskFemConstraintDisplacement::rotfixz); - connect(ui->rotzfree, &QCheckBox::stateChanged, this, &TaskFemConstraintDisplacement::rotfreez); + connect(ui->rotxfix, &QCheckBox::toggled, this, &TaskFemConstraintDisplacement::rotfixx); + connect(ui->rotyfix, &QCheckBox::toggled, this, &TaskFemConstraintDisplacement::rotfixy); + connect(ui->rotzfix, &QCheckBox::toggled, this, &TaskFemConstraintDisplacement::rotfixz); - //Selection buttons + // Fill data into dialog elements + ui->spinxDisplacement->setValue(fStates[0]); + ui->spinyDisplacement->setValue(fStates[1]); + ui->spinzDisplacement->setValue(fStates[2]); + ui->spinxRotation->setValue(fStates[3]); + ui->spinyRotation->setValue(fStates[4]); + ui->spinzRotation->setValue(fStates[5]); + ui->DisplacementXFormulaLE->setText(QString::fromUtf8(sStates[0])); + ui->DisplacementYFormulaLE->setText(QString::fromUtf8(sStates[1])); + ui->DisplacementZFormulaLE->setText(QString::fromUtf8(sStates[2])); + ui->dispxfix->setChecked(bStates[0]); + ui->DisplacementXGB->setChecked(!bStates[1]); + ui->dispyfix->setChecked(bStates[2]); + ui->DisplacementYGB->setChecked(!bStates[3]); + ui->dispzfix->setChecked(bStates[4]); + ui->DisplacementZGB->setChecked(!bStates[5]); + ui->rotxfix->setChecked(bStates[6]); + ui->RotationXGB->setChecked(!bStates[7]); + ui->rotyfix->setChecked(bStates[8]); + ui->RotationYGB->setChecked(!bStates[9]); + ui->rotzfix->setChecked(bStates[10]); + ui->RotationZGB->setChecked(!bStates[11]); + ui->DisplacementXFormulaCB->setChecked(bStates[12]); + ui->DisplacementYFormulaCB->setChecked(bStates[13]); + ui->DisplacementZFormulaCB->setChecked(bStates[14]); + ui->FlowForceCB->setChecked(bStates[15]); + + // Selection buttons buttonGroup->addButton(ui->btnAdd, (int)SelectionChangeModes::refAdd); buttonGroup->addButton(ui->btnRemove, (int)SelectionChangeModes::refRemove); @@ -181,227 +187,149 @@ void TaskFemConstraintDisplacement::updateUI() } } -void TaskFemConstraintDisplacement::x_changed(double val) { - if (val != 0) - { - ui->dispxfree->setChecked(false); - ui->dispxfix->setChecked(false); - } -} - -void TaskFemConstraintDisplacement::y_changed(double val) { - if (val != 0) - { - ui->dispyfree->setChecked(false); - ui->dispyfix->setChecked(false); - } -} - -void TaskFemConstraintDisplacement::z_changed(double val) { - if (val != 0) - { - ui->dispzfree->setChecked(false); - ui->dispzfix->setChecked(false); - } -} - -void TaskFemConstraintDisplacement::x_rot(double val) { - if (val != 0) - { - ui->rotxfree->setChecked(false); - ui->rotxfix->setChecked(false); - } -} - -void TaskFemConstraintDisplacement::y_rot(double val) { - if (val != 0) - { - ui->rotyfree->setChecked(false); - ui->rotyfix->setChecked(false); - } -} - -void TaskFemConstraintDisplacement::z_rot(double val) { - if (val != 0) - { - ui->rotzfree->setChecked(false); - ui->rotzfix->setChecked(false); - } -} - -void TaskFemConstraintDisplacement::fixx(int val) { - if (val == 2) - { - ui->dispxfree->setChecked(false); +void TaskFemConstraintDisplacement::fixx(bool state) +{ + if (state) { ui->spinxDisplacement->setValue(0); + ui->DisplacementXFormulaCB->setChecked(!state); } - else if (ui->spinxDisplacement->value() == 0) - { - ui->dispxfree->setChecked(true); - } + ui->spinxDisplacement->setEnabled(!state); + ui->DisplacementXFormulaCB->setEnabled(!state); } -void TaskFemConstraintDisplacement::freex(int val) { - if (val == 2) - { - ui->dispxfix->setChecked(false); - ui->spinxDisplacement->setValue(0); - } - else if (ui->spinxDisplacement->value() == 0) - { - ui->dispxfix->setChecked(true); - } +void TaskFemConstraintDisplacement::formulaX(bool state) +{ + ui->spinxDisplacement->setEnabled(!state); + ui->dispxfix->setEnabled(!state); + ui->DisplacementXFormulaLE->setEnabled(state); } -void TaskFemConstraintDisplacement::fixy(int val) { - if (val == 2) - { - ui->dispyfree->setChecked(false); +void TaskFemConstraintDisplacement::fixy(bool state) +{ + if (state) { ui->spinyDisplacement->setValue(0); + ui->DisplacementYFormulaCB->setChecked(!state); } - else if (ui->spinyDisplacement->value() == 0) - { - ui->dispyfree->setChecked(true); - } + ui->spinyDisplacement->setEnabled(!state); + ui->DisplacementYFormulaCB->setEnabled(!state); } -void TaskFemConstraintDisplacement::freey(int val) { - if (val == 2) - { - ui->dispyfix->setChecked(false); - ui->spinyDisplacement->setValue(0); - } - else if (ui->spinyDisplacement->value() == 0) - { - ui->dispyfix->setChecked(true); - } +void TaskFemConstraintDisplacement::formulaY(bool state) +{ + ui->spinyDisplacement->setEnabled(!state); + ui->dispyfix->setEnabled(!state); + ui->DisplacementYFormulaLE->setEnabled(state); } -void TaskFemConstraintDisplacement::fixz(int val) { - if (val == 2) - { - ui->dispzfree->setChecked(false); +void TaskFemConstraintDisplacement::fixz(bool state) +{ + if (state) { ui->spinzDisplacement->setValue(0); + ui->DisplacementZFormulaCB->setChecked(!state); } - else if (ui->spinzDisplacement->value() == 0) - { - ui->dispzfree->setChecked(true); + ui->spinzDisplacement->setEnabled(!state); + ui->DisplacementZFormulaCB->setEnabled(!state); +} + +void TaskFemConstraintDisplacement::formulaZ(bool state) +{ + ui->spinzDisplacement->setEnabled(!state); + ui->dispzfix->setEnabled(!state); + ui->DisplacementZFormulaLE->setEnabled(state); +} + +void TaskFemConstraintDisplacement::flowForce(bool state) +{ + if (state) { + ui->DisplacementXGB->setChecked(!state); + ui->DisplacementYGB->setChecked(!state); + ui->DisplacementZGB->setChecked(!state); + ui->RotationXGB->setChecked(!state); + ui->RotationYGB->setChecked(!state); + ui->RotationZGB->setChecked(!state); } } -void TaskFemConstraintDisplacement::freez(int val) { - if (val == 2) - { - ui->dispzfix->setChecked(false); - ui->spinzDisplacement->setValue(0); - } - else if (ui->spinzDisplacement->value() == 0) - { - ui->dispzfix->setChecked(true); - } -} - -void TaskFemConstraintDisplacement::rotfixx(int val) { - if (val == 2) - { - ui->rotxfree->setChecked(false); +void TaskFemConstraintDisplacement::rotfixx(bool state) +{ + if (state) ui->spinxRotation->setValue(0); - } - else if (ui->spinxRotation->value() == 0) - { - ui->rotxfree->setChecked(true); - } + ui->spinxRotation->setEnabled(!state); } -void TaskFemConstraintDisplacement::rotfreex(int val) { - if (val == 2) - { - ui->rotxfix->setChecked(false); - ui->spinxRotation->setValue(0); - } - else if (ui->spinxRotation->value() == 0) - { - ui->rotxfix->setChecked(true); - } +void TaskFemConstraintDisplacement::formulaRotx(bool state) +{ + ui->spinxRotation->setEnabled(!state); + ui->rotxfix->setEnabled(!state); } -void TaskFemConstraintDisplacement::rotfixy(int val) { - if (val == 2) - { - ui->rotyfree->setChecked(false); +void TaskFemConstraintDisplacement::rotfixy(bool state) +{ + if (state) ui->spinyRotation->setValue(0); - } - else if (ui->spinyRotation->value() == 0) - { - ui->rotyfree->setChecked(true); - } + ui->spinyRotation->setEnabled(!state); } -void TaskFemConstraintDisplacement::rotfreey(int val) { - if (val == 2) - { - ui->rotyfix->setChecked(false); - ui->spinyRotation->setValue(0); - } - else if (ui->spinyRotation->value() == 0) - { - ui->rotyfix->setChecked(true); - } +void TaskFemConstraintDisplacement::formulaRoty(bool state) +{ + ui->spinyRotation->setEnabled(!state); + ui->rotyfix->setEnabled(!state); } -void TaskFemConstraintDisplacement::rotfixz(int val) { - if (val == 2) - { - ui->rotzfree->setChecked(false); +void TaskFemConstraintDisplacement::rotfixz(bool state) +{ + if (state) ui->spinzRotation->setValue(0); - } - else if (ui->spinzRotation->value() == 0) - { - ui->rotzfree->setChecked(true); - } + ui->spinzRotation->setEnabled(!state); } -void TaskFemConstraintDisplacement::rotfreez(int val) { - if (val == 2) - { - ui->rotzfix->setChecked(false); - ui->spinzRotation->setValue(0); - } - else if (ui->spinzRotation->value() == 0) - { - ui->rotzfix->setChecked(true); - } +void TaskFemConstraintDisplacement::formulaRotz(bool state) +{ + ui->spinzRotation->setEnabled(!state); + ui->rotzfix->setEnabled(!state); } void TaskFemConstraintDisplacement::addToSelection() { - std::vector selection = Gui::Selection().getSelectionEx(); //gets vector of selected objects of active document + std::vector selection = + Gui::Selection().getSelectionEx();// gets vector of selected objects of active document if (selection.empty()) { QMessageBox::warning(this, tr("Selection error"), tr("Nothing selected!")); return; } - Fem::ConstraintDisplacement* pcConstraint = static_cast(ConstraintView->getObject()); + Fem::ConstraintDisplacement* pcConstraint = + static_cast(ConstraintView->getObject()); std::vector Objects = pcConstraint->References.getValues(); std::vector SubElements = pcConstraint->References.getSubValues(); - for (std::vector::iterator it = selection.begin(); it != selection.end(); ++it) {//for every selected object + for (std::vector::iterator it = selection.begin(); it != selection.end(); + ++it) {// for every selected object if (!it->isObjectTypeOf(Part::Feature::getClassTypeId())) { QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!")); return; } const std::vector& subNames = it->getSubNames(); App::DocumentObject* obj = it->getObject(); - for (size_t subIt = 0; subIt < (subNames.size()); ++subIt) {// for every selected sub element + for (size_t subIt = 0; subIt < (subNames.size()); + ++subIt) {// for every selected sub element bool addMe = true; - for (std::vector::iterator itr = std::find(SubElements.begin(), SubElements.end(), subNames[subIt]); - itr != SubElements.end(); - itr = std::find(++itr, SubElements.end(), subNames[subIt])) - {// for every sub element in selection that matches one in old list - if (obj == Objects[std::distance(SubElements.begin(), itr)]) {//if selected sub element's object equals the one in old list then it was added before so don't add + for (std::vector::iterator itr = + std::find(SubElements.begin(), SubElements.end(), subNames[subIt]); + itr != SubElements.end(); + itr = std::find(++itr, + SubElements.end(), + subNames[subIt])) {// for every sub element in selection that + // matches one in old list + if (obj + == Objects[std::distance( + SubElements.begin(), + itr)]) {// if selected sub element's object equals the one in old list then + // it was added before so don't add addMe = false; } } - // limit constraint such that only vertexes or faces or edges can be used depending on what was selected first + // limit constraint such that only vertexes or faces or edges can be used depending on + // what was selected first std::string searchStr; if (subNames[subIt].find("Vertex") != std::string::npos) searchStr = "Vertex"; @@ -411,7 +339,8 @@ void TaskFemConstraintDisplacement::addToSelection() searchStr = "Face"; for (size_t iStr = 0; iStr < (SubElements.size()); ++iStr) { if (SubElements[iStr].find(searchStr) == std::string::npos) { - QString msg = tr("Only one type of selection (vertex,face or edge) per constraint allowed!"); + QString msg = tr( + "Only one type of selection (vertex,face or edge) per constraint allowed!"); QMessageBox::warning(this, tr("Selection error"), msg); addMe = false; break; @@ -425,23 +354,26 @@ void TaskFemConstraintDisplacement::addToSelection() } } } - //Update UI + // Update UI pcConstraint->References.setValues(Objects, SubElements); updateUI(); } void TaskFemConstraintDisplacement::removeFromSelection() { - std::vector selection = Gui::Selection().getSelectionEx(); //gets vector of selected objects of active document + std::vector selection = + Gui::Selection().getSelectionEx();// gets vector of selected objects of active document if (selection.empty()) { QMessageBox::warning(this, tr("Selection error"), tr("Nothing selected!")); return; } - Fem::ConstraintDisplacement* pcConstraint = static_cast(ConstraintView->getObject()); + Fem::ConstraintDisplacement* pcConstraint = + static_cast(ConstraintView->getObject()); std::vector Objects = pcConstraint->References.getValues(); std::vector SubElements = pcConstraint->References.getSubValues(); std::vector itemsToDel; - for (std::vector::iterator it = selection.begin(); it != selection.end(); ++it) {//for every selected object + for (std::vector::iterator it = selection.begin(); it != selection.end(); + ++it) {// for every selected object if (!it->isObjectTypeOf(Part::Feature::getClassTypeId())) { QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!")); return; @@ -449,12 +381,20 @@ void TaskFemConstraintDisplacement::removeFromSelection() const std::vector& subNames = it->getSubNames(); App::DocumentObject* obj = it->getObject(); - for (size_t subIt = 0; subIt < (subNames.size()); ++subIt) {// for every selected sub element - for (std::vector::iterator itr = std::find(SubElements.begin(), SubElements.end(), subNames[subIt]); - itr != SubElements.end(); - itr = std::find(++itr, SubElements.end(), subNames[subIt])) - {// for every sub element in selection that matches one in old list - if (obj == Objects[std::distance(SubElements.begin(), itr)]) {//if selected sub element's object equals the one in old list then it was added before so mark for deletion + for (size_t subIt = 0; subIt < (subNames.size()); + ++subIt) {// for every selected sub element + for (std::vector::iterator itr = + std::find(SubElements.begin(), SubElements.end(), subNames[subIt]); + itr != SubElements.end(); + itr = std::find(++itr, + SubElements.end(), + subNames[subIt])) {// for every sub element in selection that + // matches one in old list + if (obj + == Objects[std::distance( + SubElements.begin(), + itr)]) {// if selected sub element's object equals the one in old list then + // it was added before so mark for deletion itemsToDel.push_back(std::distance(SubElements.begin(), itr)); } } @@ -466,7 +406,7 @@ void TaskFemConstraintDisplacement::removeFromSelection() SubElements.erase(SubElements.begin() + itemsToDel.back()); itemsToDel.pop_back(); } - //Update UI + // Update UI { QSignalBlocker block(ui->lw_references); ui->lw_references->clear(); @@ -478,8 +418,10 @@ void TaskFemConstraintDisplacement::removeFromSelection() updateUI(); } -void TaskFemConstraintDisplacement::onReferenceDeleted() { - TaskFemConstraintDisplacement::removeFromSelection(); //OvG: On right-click face is automatically selected, so just remove +void TaskFemConstraintDisplacement::onReferenceDeleted() +{ + TaskFemConstraintDisplacement::removeFromSelection();// OvG: On right-click face is + // automatically selected, so just remove } const std::string TaskFemConstraintDisplacement::getReferences() const @@ -492,25 +434,137 @@ const std::string TaskFemConstraintDisplacement::getReferences() const return TaskFemConstraint::getReferences(items); } -double TaskFemConstraintDisplacement::get_spinxDisplacement() const { return ui->spinxDisplacement->value(); } -double TaskFemConstraintDisplacement::get_spinyDisplacement() const { return ui->spinyDisplacement->value(); } -double TaskFemConstraintDisplacement::get_spinzDisplacement() const { return ui->spinzDisplacement->value(); } -double TaskFemConstraintDisplacement::get_spinxRotation() const { return ui->spinxRotation->value(); } -double TaskFemConstraintDisplacement::get_spinyRotation() const { return ui->spinyRotation->value(); } -double TaskFemConstraintDisplacement::get_spinzRotation() const { return ui->spinzRotation->value(); } +double TaskFemConstraintDisplacement::get_spinxDisplacement() const +{ + return ui->spinxDisplacement->value(); +} -bool TaskFemConstraintDisplacement::get_dispxfix() const { return ui->dispxfix->isChecked(); } -bool TaskFemConstraintDisplacement::get_dispxfree() const { return ui->dispxfree->isChecked(); } -bool TaskFemConstraintDisplacement::get_dispyfix() const { return ui->dispyfix->isChecked(); } -bool TaskFemConstraintDisplacement::get_dispyfree() const { return ui->dispyfree->isChecked(); } -bool TaskFemConstraintDisplacement::get_dispzfix() const { return ui->dispzfix->isChecked(); } -bool TaskFemConstraintDisplacement::get_dispzfree() const { return ui->dispzfree->isChecked(); } -bool TaskFemConstraintDisplacement::get_rotxfix() const { return ui->rotxfix->isChecked(); } -bool TaskFemConstraintDisplacement::get_rotxfree() const { return ui->rotxfree->isChecked(); } -bool TaskFemConstraintDisplacement::get_rotyfix() const { return ui->rotyfix->isChecked(); } -bool TaskFemConstraintDisplacement::get_rotyfree() const { return ui->rotyfree->isChecked(); } -bool TaskFemConstraintDisplacement::get_rotzfix() const { return ui->rotzfix->isChecked(); } -bool TaskFemConstraintDisplacement::get_rotzfree() const { return ui->rotzfree->isChecked(); } +double TaskFemConstraintDisplacement::get_spinyDisplacement() const +{ + return ui->spinyDisplacement->value(); +} + +double TaskFemConstraintDisplacement::get_spinzDisplacement() const +{ + return ui->spinzDisplacement->value(); +} + +double TaskFemConstraintDisplacement::get_spinxRotation() const +{ + return ui->spinxRotation->value(); +} + +double TaskFemConstraintDisplacement::get_spinyRotation() const +{ + return ui->spinyRotation->value(); +} + +double TaskFemConstraintDisplacement::get_spinzRotation() const +{ + return ui->spinzRotation->value(); +} + +std::string TaskFemConstraintDisplacement::get_xFormula() const +{ + QString xFormula = ui->DisplacementXFormulaLE->text(); + xFormula.replace(QString::fromLatin1("\""), QString::fromLatin1("\\\"")); + return xFormula.toStdString(); +} + +std::string TaskFemConstraintDisplacement::get_yFormula() const +{ + QString yFormula = ui->DisplacementYFormulaLE->text(); + yFormula.replace(QString::fromLatin1("\""), QString::fromLatin1("\\\"")); + return yFormula.toStdString(); +} + +std::string TaskFemConstraintDisplacement::get_zFormula() const +{ + QString zFormula = ui->DisplacementZFormulaLE->text(); + zFormula.replace(QString::fromLatin1("\""), QString::fromLatin1("\\\"")); + return zFormula.toStdString(); + ; +} + +bool TaskFemConstraintDisplacement::get_dispxfix() const +{ + return ui->dispxfix->isChecked(); +} + +bool TaskFemConstraintDisplacement::get_dispxfree() const +{ + return !ui->DisplacementXGB->isChecked(); +} + +bool TaskFemConstraintDisplacement::get_hasDispXFormula() const +{ + return ui->DisplacementXFormulaCB->isChecked(); +} + +bool TaskFemConstraintDisplacement::get_dispyfix() const +{ + return ui->dispyfix->isChecked(); +} + +bool TaskFemConstraintDisplacement::get_dispyfree() const +{ + return !ui->DisplacementYGB->isChecked(); +} + +bool TaskFemConstraintDisplacement::get_hasDispYFormula() const +{ + return ui->DisplacementYFormulaCB->isChecked(); +} + +bool TaskFemConstraintDisplacement::get_dispzfix() const +{ + return ui->dispzfix->isChecked(); +} + +bool TaskFemConstraintDisplacement::get_dispzfree() const +{ + return !ui->DisplacementZGB->isChecked(); +} + +bool TaskFemConstraintDisplacement::get_hasDispZFormula() const +{ + return ui->DisplacementZFormulaCB->isChecked(); +} + +bool TaskFemConstraintDisplacement::get_rotxfix() const +{ + return ui->rotxfix->isChecked(); +} + +bool TaskFemConstraintDisplacement::get_rotxfree() const +{ + return !ui->RotationXGB->isChecked(); +} + +bool TaskFemConstraintDisplacement::get_rotyfix() const +{ + return ui->rotyfix->isChecked(); +} + +bool TaskFemConstraintDisplacement::get_rotyfree() const +{ + return !ui->RotationYGB->isChecked(); +} + +bool TaskFemConstraintDisplacement::get_rotzfix() const +{ + return ui->rotzfix->isChecked(); +} + +bool TaskFemConstraintDisplacement::get_rotzfree() const +{ + return !ui->RotationZGB->isChecked(); +} + +bool TaskFemConstraintDisplacement::get_useFlowSurfaceForce() const +{ + return ui->FlowForceCB->isChecked(); +} bool TaskFemConstraintDisplacement::event(QEvent* e) { @@ -539,7 +593,8 @@ void TaskFemConstraintDisplacement::clearButtons(const SelectionChangeModes notT // TaskDialog //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -TaskDlgFemConstraintDisplacement::TaskDlgFemConstraintDisplacement(ViewProviderFemConstraintDisplacement* ConstraintView) +TaskDlgFemConstraintDisplacement::TaskDlgFemConstraintDisplacement( + ViewProviderFemConstraintDisplacement* ConstraintView) { this->ConstraintView = ConstraintView; assert(ConstraintView); @@ -557,55 +612,98 @@ void TaskDlgFemConstraintDisplacement::open() QString msg = QObject::tr("Constraint displacement"); Gui::Command::openCommand((const char*)msg.toUtf8()); ConstraintView->setVisible(true); - Gui::Command::doCommand(Gui::Command::Doc, ViewProviderFemConstraint::gethideMeshShowPartStr((static_cast(ConstraintView->getObject()))->getNameInDocument()).c_str()); //OvG: Hide meshes and show parts + Gui::Command::doCommand( + Gui::Command::Doc, + ViewProviderFemConstraint::gethideMeshShowPartStr( + (static_cast(ConstraintView->getObject()))->getNameInDocument()) + .c_str());// OvG: Hide meshes and show parts } } bool TaskDlgFemConstraintDisplacement::accept() { std::string name = ConstraintView->getObject()->getNameInDocument(); - const TaskFemConstraintDisplacement* parameterDisplacement = static_cast(parameter); + const TaskFemConstraintDisplacement* parameterDisplacement = + static_cast(parameter); try { Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.xDisplacement = %f", - name.c_str(), parameterDisplacement->get_spinxDisplacement()); + name.c_str(), parameterDisplacement->get_spinxDisplacement()); + Gui::Command::doCommand(Gui::Command::Doc, + "App.ActiveDocument.%s.xDisplacementFormula = \"%s\"", + name.c_str(), parameterDisplacement->get_xFormula().c_str()); Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.yDisplacement = %f", - name.c_str(), parameterDisplacement->get_spinyDisplacement()); + name.c_str(), parameterDisplacement->get_spinyDisplacement()); + Gui::Command::doCommand(Gui::Command::Doc, + "App.ActiveDocument.%s.yDisplacementFormula = \"%s\"", + name.c_str(), parameterDisplacement->get_yFormula().c_str()); Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.zDisplacement = %f", - name.c_str(), parameterDisplacement->get_spinzDisplacement()); + name.c_str(), parameterDisplacement->get_spinzDisplacement()); + Gui::Command::doCommand(Gui::Command::Doc, + "App.ActiveDocument.%s.zDisplacementFormula = \"%s\"", + name.c_str(), parameterDisplacement->get_zFormula().c_str()); Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.xRotation = %f", - name.c_str(), parameterDisplacement->get_spinxRotation()); + name.c_str(), parameterDisplacement->get_spinxRotation()); Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.yRotation = %f", - name.c_str(), parameterDisplacement->get_spinyRotation()); + name.c_str(), parameterDisplacement->get_spinyRotation()); Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.zRotation = %f", - name.c_str(), parameterDisplacement->get_spinzRotation()); + name.c_str(), parameterDisplacement->get_spinzRotation()); Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.xFree = %s", - name.c_str(), parameterDisplacement->get_dispxfree() ? "True" : "False"); + name.c_str(), + parameterDisplacement->get_dispxfree() ? "True" : "False"); Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.xFix = %s", - name.c_str(), parameterDisplacement->get_dispxfix() ? "True" : "False"); + name.c_str(), + parameterDisplacement->get_dispxfix() ? "True" : "False"); + Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.hasXFormula = %s", + name.c_str(), + parameterDisplacement->get_hasDispXFormula() ? "True" : "False"); Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.yFree = %s", - name.c_str(), parameterDisplacement->get_dispyfree() ? "True" : "False"); + name.c_str(), + parameterDisplacement->get_dispyfree() ? "True" : "False"); Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.yFix = %s", - name.c_str(), parameterDisplacement->get_dispyfix() ? "True" : "False"); + name.c_str(), + parameterDisplacement->get_dispyfix() ? "True" : "False"); + Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.hasYFormula = %s", + name.c_str(), + parameterDisplacement->get_hasDispYFormula() ? "True" : "False"); Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.zFree = %s", - name.c_str(), parameterDisplacement->get_dispzfree() ? "True" : "False"); + name.c_str(), + parameterDisplacement->get_dispzfree() ? "True" : "False"); Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.zFix = %s", - name.c_str(), parameterDisplacement->get_dispzfix() ? "True" : "False"); + name.c_str(), + parameterDisplacement->get_dispzfix() ? "True" : "False"); + Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.hasZFormula = %s", + name.c_str(), + parameterDisplacement->get_hasDispZFormula() ? "True" : "False"); Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.rotxFree = %s", - name.c_str(), parameterDisplacement->get_rotxfree() ? "True" : "False"); + name.c_str(), + parameterDisplacement->get_rotxfree() ? "True" : "False"); Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.rotxFix = %s", - name.c_str(), parameterDisplacement->get_rotxfix() ? "True" : "False"); + name.c_str(), + parameterDisplacement->get_rotxfix() ? "True" : "False"); Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.rotyFree = %s", - name.c_str(), parameterDisplacement->get_rotyfree() ? "True" : "False"); + name.c_str(), + parameterDisplacement->get_rotyfree() ? "True" : "False"); Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.rotyFix = %s", - name.c_str(), parameterDisplacement->get_rotyfix() ? "True" : "False"); + name.c_str(), + parameterDisplacement->get_rotyfix() ? "True" : "False"); Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.rotzFree = %s", - name.c_str(), parameterDisplacement->get_rotzfree() ? "True" : "False"); + name.c_str(), + parameterDisplacement->get_rotzfree() ? "True" : "False"); Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.rotzFix = %s", - name.c_str(), parameterDisplacement->get_rotzfix() ? "True" : "False"); - - std::string scale = parameterDisplacement->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 + name.c_str(), + parameterDisplacement->get_rotzfix() ? "True" : "False"); + Gui::Command::doCommand(Gui::Command::Doc, + "App.ActiveDocument.%s.useFlowSurfaceForce = %s", + name.c_str(), + parameterDisplacement->get_useFlowSurfaceForce() ? "True" + : "False"); + + std::string scale = parameterDisplacement->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 } catch (const Base::Exception& e) { QMessageBox::warning(parameter, tr("Input error"), QString::fromLatin1(e.what())); diff --git a/src/Mod/Fem/Gui/TaskFemConstraintDisplacement.h b/src/Mod/Fem/Gui/TaskFemConstraintDisplacement.h index 7e89773ba4..390d95f83a 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintDisplacement.h +++ b/src/Mod/Fem/Gui/TaskFemConstraintDisplacement.h @@ -53,39 +53,41 @@ public: double get_spinxRotation()const; double get_spinyRotation()const; double get_spinzRotation()const; + std::string get_xFormula() const; + std::string get_yFormula() const; + std::string get_zFormula() const; bool get_dispxfix()const; bool get_dispxfree()const; + bool get_hasDispXFormula() const; bool get_dispyfix()const; bool get_dispyfree()const; + bool get_hasDispYFormula() const; bool get_dispzfix()const; bool get_dispzfree()const; + bool get_hasDispZFormula() const; bool get_rotxfix()const; bool get_rotxfree()const; bool get_rotyfix()const; bool get_rotyfree()const; bool get_rotzfix()const; bool get_rotzfree()const; + bool get_useFlowSurfaceForce() const; private Q_SLOTS: void onReferenceDeleted(); - void x_changed(double); - void y_changed(double); - void z_changed(double); - void x_rot(double); - void y_rot(double); - void z_rot(double); - void fixx(int); - void freex(int); - void fixy(int); - void freey(int); - void fixz(int); - void freez(int); - void rotfixx(int); - void rotfreex(int); - void rotfixy(int); - void rotfreey(int); - void rotfixz(int); - void rotfreez(int); + void fixx(bool); + void formulaX(bool); + void fixy(bool); + void formulaY(bool); + void fixz(bool); + void formulaZ(bool); + void flowForce(bool); + void rotfixx(bool); + void formulaRotx(bool); + void rotfixy(bool); + void formulaRoty(bool); + void rotfixz(bool); + void formulaRotz(bool); void addToSelection() override; void removeFromSelection() override; diff --git a/src/Mod/Fem/Gui/TaskFemConstraintDisplacement.ui b/src/Mod/Fem/Gui/TaskFemConstraintDisplacement.ui index 95d8cdb9c9..6446200353 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintDisplacement.ui +++ b/src/Mod/Fem/Gui/TaskFemConstraintDisplacement.ui @@ -10,7 +10,7 @@ 0 0 300 - 641 + 617 @@ -43,287 +43,376 @@ - - - - - - 0 - 0 - - - - Add - - - true - - + + + + + + + + 0 + 0 + + + + Add + + + true + + + + + + + + 0 + 0 + + + + Remove + + + true + + + + - - + + - + 0 0 - - Remove + + + 16777215 + 100 + - - true + + QAbstractItemView::ExtendedSelection - - - - 0 - 0 - + + + Displacement x - - - 0 - 100 - + + true - - QAbstractItemView::ExtendedSelection + + + + + + + + Fixed + + + + + + + + + + Formulas are only valid +for the Emer solver + + + Formula + + + + + + + + + + Displacement y + + + true + + + + + + + + + Fixed + + + + + + + + + + Formulas are only valid +for the Emer solver + + + Formula + + + + + + + + + + Displacement z + + + true + + + + + + + + + Fixed + + + + + + + + + + Formulas are only valid +for the Emer solver + + + Formula + + + + + + + + + + Flow solution is used to determine +surface force (and thus displacement) +generated by the flow +(Option only applies for Elmer solver) + + + Surface force by flow - - - - - - - Displacement x - - - - - - - - - Free - - - - - - - Fixed - - - - - - - - - - - - - - - - Displacement y - - - - - - - - - Free - - - - - - - Fixed - - - - - - - - - - - - - - - - Displacement z - - - - - - - - - Free - - - - - - - Fixed - - - - - - - - - - - - - - - 400 - 16777215 - - - - Rotations are only valid for Beam and Shell elements. - - - false - - - true - - - - - - - - - Rotation x - - - - - - - - - Free - - - - - - - Fixed - - - - - - - - - - - - - - - - Rotation y - - - - - - - - - Free - - - - - - - Fixed - - - - - - - - - - - - - - - - Rotation z - - - - - - - - - true - - - Free - - - - - - - true - - - Fixed - - - - - - - true - - - - - - - - + + + Qt::Horizontal + + + + + + + + 400 + 16777215 + + + + Rotations are only valid for Beam and Shell elements. + + + false + + + true + + + + + + + Rotation x + + + true + + + + + + Fixed + + + + + + + + + + + + + Rotation y + + + true + + + + + + + + + Fixed + + + + + + + + + + Rotation z + + + true + + + + + + + + + Fixed + + + + + - + + + FlowForceCB + toggled(bool) + RotationXGB + setDisabled(bool) + + + 149 + 394 + + + 149 + 463 + + + + + FlowForceCB + toggled(bool) + DisplacementXGB + setDisabled(bool) + + + 149 + 394 + + + 149 + 170 + + + + + FlowForceCB + toggled(bool) + DisplacementYGB + setDisabled(bool) + + + 149 + 394 + + + 149 + 255 + + + + + FlowForceCB + toggled(bool) + DisplacementZGB + setDisabled(bool) + + + 149 + 394 + + + 149 + 340 + + + + + FlowForceCB + toggled(bool) + RotationYGB + setDisabled(bool) + + + 149 + 394 + + + 149 + 522 + + + + + FlowForceCB + toggled(bool) + RotationZGB + setDisabled(bool) + + + 149 + 394 + + + 149 + 581 + + + + diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintDisplacement.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintDisplacement.cpp index 0f7c86622d..ef14cd64b4 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintDisplacement.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintDisplacement.cpp @@ -40,7 +40,8 @@ using namespace FemGui; -PROPERTY_SOURCE(FemGui::ViewProviderFemConstraintDisplacement, FemGui::ViewProviderFemConstraintOnBoundary) +PROPERTY_SOURCE(FemGui::ViewProviderFemConstraintDisplacement, + FemGui::ViewProviderFemConstraintOnBoundary) ViewProviderFemConstraintDisplacement::ViewProviderFemConstraintDisplacement() { @@ -52,7 +53,7 @@ ViewProviderFemConstraintDisplacement::~ViewProviderFemConstraintDisplacement() { } -//FIXME setEdit needs a careful review +// FIXME setEdit needs a careful review bool ViewProviderFemConstraintDisplacement::setEdit(int ModNum) { if (ModNum == ViewProvider::Default) { @@ -91,14 +92,16 @@ bool ViewProviderFemConstraintDisplacement::setEdit(int ModNum) #define HEIGHT (4) #define WIDTH (0.3) -//#define USE_MULTIPLE_COPY //OvG: MULTICOPY fails to update scaled display on initial drawing - so disable +//#define USE_MULTIPLE_COPY +//OvG: MULTICOPY fails to update scaled display on initial drawing - so disable void ViewProviderFemConstraintDisplacement::updateData(const App::Property* prop) { // Gets called whenever a property of the attached object changes Fem::ConstraintDisplacement *pcConstraint = static_cast(this->getObject()); - float scaledwidth = WIDTH * pcConstraint->Scale.getValue(); //OvG: Calculate scaled values once only + // OvG: Calculate scaled values once only + float scaledwidth = WIDTH * pcConstraint->Scale.getValue(); float scaledheight = HEIGHT * pcConstraint->Scale.getValue(); bool xFree = pcConstraint->xFree.getValue(); bool yFree = pcConstraint->yFree.getValue(); diff --git a/src/Mod/Fem/femsolver/elmer/equations/deformation_writer.py b/src/Mod/Fem/femsolver/elmer/equations/deformation_writer.py index fef9e2e775..a0bdb56ec0 100644 --- a/src/Mod/Fem/femsolver/elmer/equations/deformation_writer.py +++ b/src/Mod/Fem/femsolver/elmer/equations/deformation_writer.py @@ -107,21 +107,28 @@ class DeformationWriter: for obj in self.write.getMember("Fem::ConstraintDisplacement"): if obj.References: for name in obj.References[0][1]: + if obj.useFlowSurfaceForce: + self.write.boundary(name, "FSI BC", obj.useFlowSurfaceForce) + # if useFlowSurfaceForce no displacements must be output + continue if not obj.xFree: - self.write.boundary( - name, "Displacement 1", obj.xDisplacement * 0.001) - elif obj.xFix: - self.write.boundary(name, "Displacement 1", 0.0) + if not obj.hasXFormula: + displacement = obj.xDisplacement * 0.001 + else: + displacement = obj.xDisplacementFormula + self.write.boundary(name, "Displacement 1", displacement) if not obj.yFree: - self.write.boundary( - name, "Displacement 2", obj.yDisplacement * 0.001) - elif obj.yFix: - self.write.boundary(name, "Displacement 2", 0.0) + if not obj.hasYFormula: + displacement = obj.yDisplacement * 0.001 + else: + displacement = obj.yDisplacementFormula + self.write.boundary(name, "Displacement 2", displacement) if not obj.zFree: - self.write.boundary( - name, "Displacement 3", obj.zDisplacement * 0.001) - elif obj.zFix: - self.write.boundary(name, "Displacement 3", 0.0) + if not obj.hasZFormula: + displacement = obj.zDisplacement * 0.001 + else: + displacement = obj.zDisplacementFormula + self.write.boundary(name, "Displacement 3", displacement) self.write.handled(obj) def handleDeformationInitial(self, bodies): diff --git a/src/Mod/Fem/femsolver/elmer/equations/elasticity_writer.py b/src/Mod/Fem/femsolver/elmer/equations/elasticity_writer.py index fabee1449a..7f09be1df1 100644 --- a/src/Mod/Fem/femsolver/elmer/equations/elasticity_writer.py +++ b/src/Mod/Fem/femsolver/elmer/equations/elasticity_writer.py @@ -323,21 +323,28 @@ class ElasticityWriter: for obj in self.write.getMember("Fem::ConstraintDisplacement"): if obj.References: for name in obj.References[0][1]: + if obj.useFlowSurfaceForce: + self.write.boundary(name, "FSI BC", obj.useFlowSurfaceForce) + # if useFlowSurfaceForce no displacements must be output + continue if not obj.xFree: - self.write.boundary( - name, "Displacement 1", obj.xDisplacement * 0.001) - elif obj.xFix: - self.write.boundary(name, "Displacement 1", 0.0) + if not obj.hasXFormula: + displacement = obj.xDisplacement * 0.001 + else: + displacement = obj.xDisplacementFormula + self.write.boundary(name, "Displacement 1", displacement) if not obj.yFree: - self.write.boundary( - name, "Displacement 2", obj.yDisplacement * 0.001) - elif obj.yFix: - self.write.boundary(name, "Displacement 2", 0.0) + if not obj.hasYFormula: + displacement = obj.yDisplacement * 0.001 + else: + displacement = obj.yDisplacementFormula + self.write.boundary(name, "Displacement 2", displacement) if not obj.zFree: - self.write.boundary( - name, "Displacement 3", obj.zDisplacement * 0.001) - elif obj.zFix: - self.write.boundary(name, "Displacement 3", 0.0) + if not obj.hasZFormula: + displacement = obj.zDisplacement * 0.001 + else: + displacement = obj.zDisplacementFormula + self.write.boundary(name, "Displacement 3", displacement) self.write.handled(obj) def handleElasticityInitial(self, bodies):