[FEM] fix value display in result pipelines
- as reported here: https://forum.freecadweb.org/viewtopic.php?p=583133#p583133 The point is that the user cannot know that he has to multiply the shown numbers for displacements by 0.001 but for the displayed stresses by 1e6 while the temperature is already correct. The fix is to be consistent and display in SI units. This commit does this and was tested using unit systems with mm and meter based length.
This commit is contained in:
@@ -837,9 +837,13 @@ void FemVTKTools::exportFreeCADResult(const App::DocumentObject* result, vtkSmar
|
||||
SMESH_Mesh* smesh = const_cast<SMESH_Mesh*>(static_cast<FemMeshObject*>(meshObj)->FemMesh.getValue().getSMesh());
|
||||
SMESHDS_Mesh* meshDS = smesh->GetMeshDS();
|
||||
|
||||
// all result object meshes are in mm therefore for e.g. length outputs like
|
||||
// displacement we must divide by 1000
|
||||
double factor = 1.0;
|
||||
|
||||
// vectors
|
||||
for (std::map<std::string, std::string>::iterator it = vectors.begin(); it != vectors.end(); ++it) {
|
||||
const int dim=3; //Fixme, detect dim, but FreeCAD PropertyVectorList ATM only has DIM of 3
|
||||
const int dim = 3; //Fixme, detect dim, but FreeCAD PropertyVectorList ATM only has DIM of 3
|
||||
App::PropertyVectorList* field = nullptr;
|
||||
if (res->getPropertyByName(it->first.c_str()))
|
||||
field = static_cast<App::PropertyVectorList*>(res->getPropertyByName(it->first.c_str()));
|
||||
@@ -858,17 +862,22 @@ void FemVTKTools::exportFreeCADResult(const App::DocumentObject* result, vtkSmar
|
||||
//we need to set values for the unused points.
|
||||
//TODO: ensure that the result bar does not include the used 0 if it is not part of the result (e.g. does the result bar show 0 as smallest value?)
|
||||
if (nPoints != field->getSize()) {
|
||||
double tuple[] = {0,0,0};
|
||||
for (vtkIdType i=0; i<nPoints; ++i) {
|
||||
double tuple[] = { 0, 0, 0 };
|
||||
for (vtkIdType i = 0; i < nPoints; ++i) {
|
||||
data->SetTuple(i, tuple);
|
||||
}
|
||||
}
|
||||
|
||||
if (it->first.compare("DisplacementVectors") == 0)
|
||||
factor = 0.001;
|
||||
else
|
||||
factor = 1.0;
|
||||
|
||||
SMDS_NodeIteratorPtr aNodeIter = meshDS->nodesIterator();
|
||||
for (std::vector<Base::Vector3d>::const_iterator jt=vel.begin(); jt!=vel.end(); ++jt) {
|
||||
for (std::vector<Base::Vector3d>::const_iterator jt = vel.begin(); jt != vel.end(); ++jt) {
|
||||
const SMDS_MeshNode* node = aNodeIter->next();
|
||||
double tuple[] = {jt->x, jt->y, jt->z};
|
||||
data->SetTuple(node->GetID()-1, tuple);
|
||||
double tuple[] = { jt->x * factor, jt->y * factor, jt->z * factor };
|
||||
data->SetTuple(node->GetID() - 1, tuple);
|
||||
}
|
||||
grid->GetPointData()->AddArray(data);
|
||||
Base::Console().Log(" The PropertyVectorList %s was exported to VTK vector list: %s\n", it->first.c_str(), it->second.c_str());
|
||||
@@ -897,15 +906,33 @@ void FemVTKTools::exportFreeCADResult(const App::DocumentObject* result, vtkSmar
|
||||
//we need to set values for the unused points.
|
||||
//TODO: ensure that the result bar does not include the used 0 if it is not part of the result (e.g. does the result bar show 0 as smallest value?)
|
||||
if (nPoints != field->getSize()) {
|
||||
for (vtkIdType i=0; i<nPoints; ++i) {
|
||||
for (vtkIdType i = 0; i < nPoints; ++i) {
|
||||
data->SetValue(i, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((it->first.compare("MaxShear") == 0)
|
||||
|| (it->first.compare("MaxShear") == 0)
|
||||
|| (it->first.compare("NodeStressXX") == 0)
|
||||
|| (it->first.compare("NodeStressXY") == 0)
|
||||
|| (it->first.compare("NodeStressXZ") == 0)
|
||||
|| (it->first.compare("NodeStressYY") == 0)
|
||||
|| (it->first.compare("NodeStressYZ") == 0)
|
||||
|| (it->first.compare("NodeStressZZ") == 0)
|
||||
|| (it->first.compare("PrincipalMax") == 0)
|
||||
|| (it->first.compare("PrincipalMed") == 0)
|
||||
|| (it->first.compare("PrincipalMin") == 0)
|
||||
|| (it->first.compare("vonMises") == 0))
|
||||
factor = 1e6;
|
||||
else if (it->first.compare("DisplacementLengths") == 0)
|
||||
factor = 0.001;
|
||||
else
|
||||
factor = 1.0;
|
||||
|
||||
SMDS_NodeIteratorPtr aNodeIter = meshDS->nodesIterator();
|
||||
for (size_t i=0; i<vec.size(); ++i) {
|
||||
for (size_t i = 0; i < vec.size(); ++i) {
|
||||
const SMDS_MeshNode* node = aNodeIter->next();
|
||||
data->SetValue(node->GetID()-1, vec[i]);
|
||||
data->SetValue(node->GetID() - 1, vec[i] * factor);
|
||||
}
|
||||
|
||||
grid->GetPointData()->AddArray(data);
|
||||
|
||||
Reference in New Issue
Block a user