Merge pull request #19930 from marioalexis84/fem-current_density

Fem: Improve current density boundary condition
This commit is contained in:
Chris Hennes
2025-03-03 10:32:35 -06:00
committed by GitHub
12 changed files with 735 additions and 660 deletions

View File

@@ -373,6 +373,7 @@ SET(FemGuiSymbol_IV
Resources/symbols/ConstraintContact.iv
Resources/symbols/ConstraintDisplacement.iv
Resources/symbols/ConstraintElectrostaticPotential.iv
Resources/symbols/ConstraintCurrentDensity.iv
Resources/symbols/ConstraintFixed.iv
Resources/symbols/ConstraintForce.iv
Resources/symbols/ConstraintHeatFlux.iv

View File

@@ -0,0 +1,55 @@
#Inventor V2.1 ascii
# SPDX-License-Identifier: LGPL-2.1-or-later
#/***************************************************************************
# * Copyright (c) 2025 Mario Passaglia <mpassaglia[at]cbc.uba.ar> *
# * *
# * This file is part of FreeCAD. *
# * *
# * FreeCAD is free software: you can redistribute it and/or modify it *
# * under the terms of the GNU Lesser General Public License as *
# * published by the Free Software Foundation, either version 2.1 of the *
# * License, or (at your option) any later version. *
# * *
# * FreeCAD is distributed in the hope that it will be useful, but *
# * WITHOUT ANY WARRANTY; without even the implied warranty of *
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
# * Lesser General Public License for more details. *
# * *
# * You should have received a copy of the GNU Lesser General Public *
# * License along with FreeCAD. If not, see *
# * <https://www.gnu.org/licenses/>. *
# * *
# **************************************************************************
Separator {
Separator {
Switch {
Separator {
Translation {
translation 0 3.3333334 0
}
Cone {
bottomRadius 0.66666669
height 1.3333334
}
Translation {
translation 0 -2 0
}
Cylinder {
radius 0.26666668
height 2.6666667
}
}
}
}
}

View File

@@ -13,371 +13,272 @@
<property name="windowTitle">
<string>Analysis feature properties</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="currDenseLbl_2">
<property name="text">
<string>Current density:</string>
<layout class="QVBoxLayout" name="vlt_0">
<item row="0" column="0">
<widget class="QGroupBox" name="gb_mode">
<property name="title">
<string></string>
</property>
<property name="toolTip">
<string>Select Custom mode to enable vector current density</string>
</property>
<layout class="QFormLayout" name="glt_1">
<item row="0" column="0">
<widget class="QLabel" name="l_mode">
<property name="text">
<string>Mode:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="cb_mode"/>
</item>
</layout>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="labelReal">
<item row="1" column="0">
<widget class="QGroupBox" name="gb_custom">
<property name="title">
<string></string>
</property>
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Real</string>
<property name="toolTip">
<string>Imaginary part is only used for equations
with harmonic/oscillating driving current</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QLabel" name="labelImaginary">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Imaginary</string>
<property name="checkable">
<bool>false</bool>
</property>
<layout class="QGridLayout" name="gridLayout_3" columnstretch="0,255,255">
<item row="0" column="1">
<widget class="QLabel" name="l_custom_real">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Real</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="l_custom_imag">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Imaginary</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="ckb_current_density_1">
<property name="text">
<string>x</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="Gui::QuantitySpinBox" name="qsb_current_density_re_1">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>Real part of current density x-component</string>
</property>
<property name="keyboardTracking">
<bool>true</bool>
</property>
<property name="unit" stdset="0">
<string notr="true">A/m^2</string>
</property>
<property name="singleStep">
<double>1.000000000000000</double>
</property>
<property name="value">
<double>0.000000000000000</double>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="Gui::QuantitySpinBox" name="qsb_current_density_im_1">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>Imaginary part of current density x-component</string>
</property>
<property name="keyboardTracking">
<bool>true</bool>
</property>
<property name="unit" stdset="0">
<string notr="true">A/m^2</string>
</property>
<property name="singleStep">
<double>1.000000000000000</double>
</property>
<property name="value">
<double>0.000000000000000</double>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="ckb_current_density_2">
<property name="text">
<string>y</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="Gui::QuantitySpinBox" name="qsb_current_density_re_2">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>Real part of current density y-component</string>
</property>
<property name="keyboardTracking">
<bool>true</bool>
</property>
<property name="unit" stdset="0">
<string notr="true">A/m^2</string>
</property>
<property name="singleStep">
<double>1.000000000000000</double>
</property>
<property name="value">
<double>0.000000000000000</double>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="Gui::QuantitySpinBox" name="qsb_current_density_im_2">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>Imaginary part of current density y-component</string>
</property>
<property name="keyboardTracking">
<bool>true</bool>
</property>
<property name="unit" stdset="0">
<string notr="true">A/m^2</string>
</property>
<property name="singleStep">
<double>1.000000000000000</double>
</property>
<property name="value">
<double>0.000000000000000</double>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="ckb_current_density_3">
<property name="text">
<string>z</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="Gui::QuantitySpinBox" name="qsb_current_density_re_3">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>Real part of current density z-component</string>
</property>
<property name="keyboardTracking">
<bool>true</bool>
</property>
<property name="unit" stdset="0">
<string notr="true">A/m^2</string>
</property>
<property name="singleStep">
<double>1.000000000000000</double>
</property>
<property name="value">
<double>0.000000000000000</double>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="Gui::QuantitySpinBox" name="qsb_current_density_im_3">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>Imaginary part of current density z-component</string>
</property>
<property name="keyboardTracking">
<bool>true</bool>
</property>
<property name="unit" stdset="0">
<string notr="true">A/m^2</string>
</property>
<property name="singleStep">
<double>1.000000000000000</double>
</property>
<property name="value">
<double>0.000000000000000</double>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="labelX">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>x</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="Gui::QuantitySpinBox" name="realXQSB">
<property name="enabled">
<bool>true</bool>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>20</height>
</size>
<widget class="QGroupBox" name="gb_normal">
<property name="title">
<string></string>
</property>
<property name="toolTip">
<string>Real part of potential x-component
Note: if a face was selected this will be the value
in normal face direction
settings for y and z will be ignored</string>
</property>
<property name="keyboardTracking">
<bool>true</bool>
</property>
<property name="unit" stdset="0">
<string notr="true"/>
</property>
<property name="minimum">
<double>-1000000000000000000000.000000000000000</double>
</property>
<property name="maximum">
<double>1000000000000000000000.000000000000000</double>
</property>
<property name="singleStep">
<double>1.000000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QCheckBox" name="reXunspecBox">
<property name="toolTip">
<string>unspecified</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="Gui::QuantitySpinBox" name="imagXQSB">
<property name="enabled">
<bool>true</bool>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>20</height>
</size>
</property>
<property name="toolTip">
<string>Imaginary part of potential x-component
Note: if a face was selected this will be the value
in normal face direction
settings for y and z will be ignored</string>
</property>
<property name="keyboardTracking">
<bool>true</bool>
</property>
<property name="unit" stdset="0">
<string notr="true"/>
</property>
<property name="minimum">
<double>-1000000000000000000000.000000000000000</double>
</property>
<property name="maximum">
<double>1000000000000000000000.000000000000000</double>
</property>
<property name="singleStep">
<double>1.000000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
<item row="2" column="4">
<widget class="QCheckBox" name="imXunspecBox">
<property name="toolTip">
<string>unspecified</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="labelY">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>y</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="Gui::QuantitySpinBox" name="realYQSB">
<property name="enabled">
<bool>true</bool>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>20</height>
</size>
</property>
<property name="toolTip">
<string>Real part of potential y-component
Note: for 2D only setting for x is possible,
setting for y will be ignored</string>
</property>
<property name="keyboardTracking">
<bool>true</bool>
</property>
<property name="unit" stdset="0">
<string notr="true"/>
</property>
<property name="minimum">
<double>-1000000000000000000000.000000000000000</double>
</property>
<property name="maximum">
<double>1000000000000000000000.000000000000000</double>
</property>
<property name="singleStep">
<double>1.000000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QCheckBox" name="reYunspecBox">
<property name="toolTip">
<string>unspecified</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="3" column="3">
<widget class="Gui::QuantitySpinBox" name="imagYQSB">
<property name="enabled">
<bool>true</bool>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>20</height>
</size>
</property>
<property name="toolTip">
<string>Imaginary part of potential y-component
Note: for 2D only setting for x is possible,
setting for y will be ignored</string>
</property>
<property name="keyboardTracking">
<bool>true</bool>
</property>
<property name="unit" stdset="0">
<string notr="true"/>
</property>
<property name="minimum">
<double>-1000000000000000000000.000000000000000</double>
</property>
<property name="maximum">
<double>1000000000000000000000.000000000000000</double>
</property>
<property name="singleStep">
<double>1.000000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
<item row="3" column="4">
<widget class="QCheckBox" name="imYunspecBox">
<property name="toolTip">
<string>unspecified</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="labelZ">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>z</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="Gui::QuantitySpinBox" name="realZQSB">
<property name="enabled">
<bool>true</bool>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>20</height>
</size>
</property>
<property name="toolTip">
<string>Real part of potential z-component</string>
</property>
<property name="keyboardTracking">
<bool>true</bool>
</property>
<property name="unit" stdset="0">
<string notr="true"/>
</property>
<property name="minimum">
<double>-1000000000000000000000.000000000000000</double>
</property>
<property name="maximum">
<double>1000000000000000000000.000000000000000</double>
</property>
<property name="singleStep">
<double>1.000000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QCheckBox" name="reZunspecBox">
<property name="toolTip">
<string>unspecified</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="4" column="3">
<widget class="Gui::QuantitySpinBox" name="imagZQSB">
<property name="enabled">
<bool>true</bool>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>20</height>
</size>
</property>
<property name="toolTip">
<string>Imaginary part of potential z-component</string>
</property>
<property name="keyboardTracking">
<bool>true</bool>
</property>
<property name="unit" stdset="0">
<string notr="true"/>
</property>
<property name="minimum">
<double>-1000000000000000000000.000000000000000</double>
</property>
<property name="maximum">
<double>1000000000000000000000.000000000000000</double>
</property>
<property name="singleStep">
<double>1.000000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
<item row="4" column="4">
<widget class="QCheckBox" name="imZunspecBox">
<property name="toolTip">
<string>unspecified</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="l_normal">
<property name="text">
<string>Normal:</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="Gui::QuantitySpinBox" name="normalQSB">
<property name="enabled">
<bool>true</bool>
</property>
<property name="unit" stdset="0">
<string notr="true">A/m^2</string>
</property>
<property name="alignment">
<set>Qt::AlignLeft|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="keyboardTracking">
<bool>true</bool>
</property>
<property name="minimum">
<double>-1000000000000000000000.000000000000000</double>
</property>
<property name="maximum">
<double>1000000000000000000000.000000000000000</double>
</property>
<property name="singleStep">
<double>1.000000000000000</double>
</property>
<property name="value">
<double>0.000000000000</double>
</property>
<string>Current density normal to surface</string>
</property>
<layout class="QGridLayout" name="gridLayout_8" columnstretch="0,255,255">
<item row="0" column="1">
<widget class="QLabel" name="l_normal_real">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Real</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="l_normal_imag">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Imaginary</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="l_normal_current_density">
<property name="text">
<string>Normal:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="Gui::QuantitySpinBox" name="qsb_normal_current_density_re">
<property name="unit" stdset="0">
<string notr="true">A/m^2</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="Gui::QuantitySpinBox" name="qsb_normal_current_density_im">
<property name="unit" stdset="0">
<string notr="true">A/m^2</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
@@ -390,102 +291,4 @@ Note: for 2D only setting for x is possible,
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
<sender>reXunspecBox</sender>
<signal>toggled(bool)</signal>
<receiver>realXQSB</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>152</x>
<y>61</y>
</hint>
<hint type="destinationlabel">
<x>80</x>
<y>61</y>
</hint>
</hints>
</connection>
<connection>
<sender>reYunspecBox</sender>
<signal>toggled(bool)</signal>
<receiver>realYQSB</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>152</x>
<y>87</y>
</hint>
<hint type="destinationlabel">
<x>80</x>
<y>87</y>
</hint>
</hints>
</connection>
<connection>
<sender>imZunspecBox</sender>
<signal>toggled(bool)</signal>
<receiver>imagZQSB</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>297</x>
<y>113</y>
</hint>
<hint type="destinationlabel">
<x>224</x>
<y>113</y>
</hint>
</hints>
</connection>
<connection>
<sender>imYunspecBox</sender>
<signal>toggled(bool)</signal>
<receiver>imagYQSB</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>297</x>
<y>87</y>
</hint>
<hint type="destinationlabel">
<x>224</x>
<y>87</y>
</hint>
</hints>
</connection>
<connection>
<sender>imXunspecBox</sender>
<signal>toggled(bool)</signal>
<receiver>imagXQSB</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>297</x>
<y>61</y>
</hint>
<hint type="destinationlabel">
<x>224</x>
<y>61</y>
</hint>
</hints>
</connection>
<connection>
<sender>reZunspecBox</sender>
<signal>toggled(bool)</signal>
<receiver>realZQSB</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>152</x>
<y>113</y>
</hint>
<hint type="destinationlabel">
<x>80</x>
<y>113</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@@ -200,9 +200,19 @@ void ViewProviderFemConstraint::handleChangedPropertyName(Base::XMLReader& reade
}
}
void ViewProviderFemConstraint::setRotateSymbol(bool rotate)
{
rotateSymbol = rotate;
updateSymbol();
}
void ViewProviderFemConstraint::updateSymbol()
{
auto obj = this->getObject<const Fem::Constraint>();
if (!obj) {
return;
}
const std::vector<Base::Vector3d>& points = obj->Points.getValue();
const std::vector<Base::Vector3d>& normals = obj->Normals.getValue();
if (points.size() != normals.size()) {

View File

@@ -131,11 +131,6 @@ inline bool ViewProviderFemConstraint::getRotateSymbol() const
return rotateSymbol;
}
inline void ViewProviderFemConstraint::setRotateSymbol(bool rotate)
{
rotateSymbol = rotate;
}
using ViewProviderFemConstraintPython = Gui::ViewProviderFeaturePythonT<ViewProviderFemConstraint>;