[FEM] SI unit fixes for Elmer
- since we use consistently SI units (as recommended my the Elmer forum), we need to scale the input mesh (we use ElmerGrid that has an option fur this purpose) - Since the result will be in the scaled mesh, we need to scale it back With this PR, one gets now correct result independent of - the used unit scheme - the simulation type (electrical or thermo-mechanical)
This commit is contained in:
@@ -71,6 +71,7 @@ ViewProviderFemPostObject::ViewProviderFemPostObject() : m_blockPropertyChanges(
|
||||
ADD_PROPERTY_TYPE(Field,((long)0), "Coloring", App::Prop_None, "Select the field used for calculating the color");
|
||||
ADD_PROPERTY_TYPE(VectorMode,((long)0), "Coloring", App::Prop_None, "Select what to show for a vector field");
|
||||
ADD_PROPERTY(Transparency, (0));
|
||||
ADD_PROPERTY(Scale, (1.0));
|
||||
|
||||
sPixmap = "fem-femmesh-from-shape";
|
||||
|
||||
@@ -425,11 +426,19 @@ void ViewProviderFemPostObject::WritePointData(vtkPoints* points, vtkDataArray*
|
||||
if(!points)
|
||||
return;
|
||||
|
||||
// if the object contains "Elmer" but no scale has been set, we set it to 1000.0
|
||||
// because for Elmer we work with SI units and thus get a scaled result we need to transform
|
||||
auto Label = std::string(pcObject->Label.getValue());
|
||||
auto found = Label.find(std::string("Elmer"));
|
||||
if (found != std::string::npos && Scale.getValue() != 1000.0)
|
||||
Scale.setValue(1000.0);
|
||||
|
||||
m_coordinates->point.startEditing();
|
||||
m_coordinates->point.setNum(points->GetNumberOfPoints());
|
||||
auto scale = Scale.getValue();
|
||||
for (i = 0; i < points->GetNumberOfPoints(); i++) {
|
||||
p = points->GetPoint(i);
|
||||
m_coordinates->point.set1Value(i, p[0], p[1], p[2]);
|
||||
m_coordinates->point.set1Value(i, p[0] * scale, p[1] * scale, p[2] * scale);
|
||||
}
|
||||
m_coordinates->point.finishEditing();
|
||||
|
||||
@@ -506,8 +515,6 @@ void ViewProviderFemPostObject::WriteTransparency() {
|
||||
m_material->transparency.setValue(trans);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ViewProviderFemPostObject::updateData(const App::Property* p) {
|
||||
|
||||
if( strcmp(p->getName(), "Data") == 0 ) {
|
||||
@@ -534,22 +541,25 @@ bool ViewProviderFemPostObject::setupPipeline() {
|
||||
|
||||
void ViewProviderFemPostObject::onChanged(const App::Property* prop) {
|
||||
|
||||
if(m_blockPropertyChanges)
|
||||
if (m_blockPropertyChanges)
|
||||
return;
|
||||
|
||||
bool ResetColorBarRange = true;
|
||||
if(prop == &Field && setupPipeline()) {
|
||||
if (prop == &Field && setupPipeline()) {
|
||||
updateProperties();
|
||||
WriteColorData(ResetColorBarRange);
|
||||
WriteTransparency();
|
||||
}
|
||||
else if(prop == &VectorMode && setupPipeline()) {
|
||||
else if (prop == &VectorMode && setupPipeline()) {
|
||||
WriteColorData(ResetColorBarRange);
|
||||
WriteTransparency();
|
||||
}
|
||||
else if(prop == &Transparency) {
|
||||
else if (prop == &Transparency) {
|
||||
WriteTransparency();
|
||||
}
|
||||
else if (prop == &Scale) {
|
||||
update3D();
|
||||
}
|
||||
|
||||
ViewProviderDocumentObject::onChanged(prop);
|
||||
}
|
||||
|
||||
@@ -82,6 +82,7 @@ public:
|
||||
App::PropertyEnumeration Field;
|
||||
App::PropertyEnumeration VectorMode;
|
||||
App::PropertyPercent Transparency;
|
||||
App::PropertyFloat Scale;
|
||||
|
||||
void attach(App::DocumentObject *pcObject);
|
||||
void setDisplayMode(const char* ModeName);
|
||||
|
||||
@@ -214,7 +214,8 @@ class Writer(object):
|
||||
_ELMERGRID_IFORMAT,
|
||||
_ELMERGRID_OFORMAT,
|
||||
unvPath,
|
||||
"-out", self.directory]
|
||||
"-scale", "0.001", "0.001", "0.001",
|
||||
"-out", self.directory]
|
||||
subprocess.call(args, stdout=subprocess.DEVNULL)
|
||||
|
||||
def _writeStartinfo(self):
|
||||
@@ -280,11 +281,12 @@ class Writer(object):
|
||||
def _handleSimulation(self):
|
||||
self._simulation("Coordinate System", "Cartesian 3D")
|
||||
self._simulation("Coordinate Mapping", (1, 2, 3))
|
||||
if self.unit_schema == Units.Scheme.SI2:
|
||||
self._simulation("Coordinate Scaling", 0.001)
|
||||
Console.PrintMessage(
|
||||
"'Coordinate Scaling = Real 0.001' was inserted into the solver input file.\n"
|
||||
)
|
||||
# not necessary anymore since we use SI units
|
||||
#if self.unit_schema == Units.Scheme.SI2:
|
||||
#self._simulation("Coordinate Scaling", 0.001)
|
||||
# Console.PrintMessage(
|
||||
# "'Coordinate Scaling = Real 0.001' was inserted into the solver input file.\n"
|
||||
# )
|
||||
self._simulation("Simulation Type", "Steady state")
|
||||
self._simulation("Steady State Max Iterations", 1)
|
||||
self._simulation("Output Intervals", 1)
|
||||
|
||||
@@ -34,7 +34,6 @@ End
|
||||
Simulation
|
||||
BDF Order = Integer 1
|
||||
Coordinate Mapping(3) = Integer 1 2 3
|
||||
Coordinate Scaling = Real 0.001
|
||||
Coordinate System = String "Cartesian 3D"
|
||||
Output Intervals = Integer 1
|
||||
Simulation Type = String "Steady state"
|
||||
|
||||
Reference in New Issue
Block a user