From 186f83add7da34ac5fe8d6b43485f8e3cd85301d Mon Sep 17 00:00:00 2001 From: marioalexis Date: Wed, 19 Mar 2025 00:47:36 -0300 Subject: [PATCH] Fem: Remove function based on Elmer results --- src/Mod/Fem/Gui/ViewProviderFemPostObject.cpp | 77 ------------------- src/Mod/Fem/Gui/ViewProviderFemPostObject.h | 1 - 2 files changed, 78 deletions(-) diff --git a/src/Mod/Fem/Gui/ViewProviderFemPostObject.cpp b/src/Mod/Fem/Gui/ViewProviderFemPostObject.cpp index 7d8d048585..234f68dc9f 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemPostObject.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemPostObject.cpp @@ -869,12 +869,6 @@ bool ViewProviderFemPostObject::setupPipeline() if (!dset) { return false; } - std::string FieldName; - auto numFields = dset->GetPointData()->GetNumberOfArrays(); - for (int i = 0; i < numFields; ++i) { - FieldName = std::string(dset->GetPointData()->GetArrayName(i)); - addAbsoluteField(dset, FieldName); - } m_outline->SetInputData(dset); m_points->SetInputData(dset); @@ -1112,74 +1106,3 @@ void ViewProviderFemPostObject::onSelectionChanged(const Gui::SelectionChanges& } } } - -// if there is a real and an imaginary field, an absolute field is added -void ViewProviderFemPostObject::addAbsoluteField(vtkDataSet* dset, std::string FieldName) -{ - // real field names have the suffix " re", given by Elmer - // if the field does not have this suffix, we can return - auto suffix = FieldName.substr(FieldName.size() - 3, FieldName.size() - 1); - if (strcmp(suffix.c_str(), " re") != 0) { - return; - } - - // absolute fields might have already been created, then do nothing - auto strAbsoluteFieldName = FieldName.substr(0, FieldName.size() - 2) + "abs"; - vtkDataArray* testArray = dset->GetPointData()->GetArray(strAbsoluteFieldName.c_str()); - if (testArray) { - return; - } - - // safety check - vtkDataArray* realDdata = dset->GetPointData()->GetArray(FieldName.c_str()); - if (!realDdata) { - return; - } - - // now check if the imaginary counterpart exists - auto strImaginaryFieldName = FieldName.substr(0, FieldName.size() - 2) + "im"; - vtkDataArray* imagDdata = dset->GetPointData()->GetArray(strImaginaryFieldName.c_str()); - if (!imagDdata) { - return; - } - - // create a new array and copy over the real data - // since one cannot directly access the values of a vtkDataSet - // we need to copy them over in a loop - vtkSmartPointer absoluteData = vtkSmartPointer::New(); - absoluteData->SetNumberOfComponents(realDdata->GetNumberOfComponents()); - auto numTuples = realDdata->GetNumberOfTuples(); - absoluteData->SetNumberOfTuples(numTuples); - double tuple[] = {0, 0, 0}; - for (vtkIdType i = 0; i < numTuples; ++i) { - absoluteData->SetTuple(i, tuple); - } - // name the array - auto strAbsFieldName = FieldName.substr(0, FieldName.size() - 2) + "abs"; - absoluteData->SetName(strAbsFieldName.c_str()); - - // add array to data set - dset->GetPointData()->AddArray(absoluteData); - - // step through all mesh points and calculate them - double realValue = 0; - double imaginaryValue = 0; - double absoluteValue = 0; - for (int i = 0; i < dset->GetNumberOfPoints(); ++i) { - if (absoluteData->GetNumberOfComponents() == 1) { - realValue = realDdata->GetComponent(i, 0); - imaginaryValue = imagDdata->GetComponent(i, 0); - absoluteValue = sqrt(pow(realValue, 2) + pow(imaginaryValue, 2)); - absoluteData->SetComponent(i, 0, absoluteValue); - } - // if field is a vector - else { - for (int j = 0; j < absoluteData->GetNumberOfComponents(); ++j) { - realValue = realDdata->GetComponent(i, j); - imaginaryValue = imagDdata->GetComponent(i, j); - absoluteValue = sqrt(pow(realValue, 2) + pow(imaginaryValue, 2)); - absoluteData->SetComponent(i, j, absoluteValue); - } - } - } -} diff --git a/src/Mod/Fem/Gui/ViewProviderFemPostObject.h b/src/Mod/Fem/Gui/ViewProviderFemPostObject.h index 3909502d9e..19aa86be95 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemPostObject.h +++ b/src/Mod/Fem/Gui/ViewProviderFemPostObject.h @@ -170,7 +170,6 @@ private: void WritePointData(vtkPoints* points, vtkDataArray* normals, vtkDataArray* tcoords); void WriteColorData(bool ResetColorBarRange); void WriteTransparency(); - void addAbsoluteField(vtkDataSet* dset, std::string FieldName); void deleteColorBar(); App::Enumeration m_coloringEnum, m_vectorEnum;