SUBDIRS(ElectromagnetismStreamTraceur)
SUBDIRS(ElectromagnetismVecteur)
SUBDIRS(ContactReader)
+SUBDIRS(QuadraticToLinear)
project(QuadraticToLinearPlugin)
find_package(ParaView REQUIRED)
+IF(PARAVISADDONS_COMMON_BUILD_TESTS)
+ ADD_SUBDIRECTORY(Test)
+ENDIF(PARAVISADDONS_COMMON_BUILD_TESTS)
+
include(GNUInstallDirs)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}")
--- /dev/null
+# Copyright (C) 2012-2020 CEA/DEN, EDF R&D
+#
+# This library 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.
+#
+# This library 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 this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+# Author : Yoann Audouin (EDF)
+
+SET(test_QuadraticToLinear_src
+ test_QuadraticToLinear.py
+ )
+
+SALOME_GENERATE_TESTS_ENVIRONMENT(tests_env)
+
+ADD_TEST(QuadraticToLinear python test_QuadraticToLinear.py)
+SET_TESTS_PROPERTIES(QuadraticToLinear PROPERTIES ENVIRONMENT "${tests_env}")
+
+#INSTALL(TARGETS test_QuadraticToLinear DESTINATION ${PARAVISADDONS_COMMON_INSTALL_BINS})
+
+# Application tests
+
+SET(TEST_INSTALL_DIRECTORY ${PARAVISADDONS_COMMON_INSTALL_TESTS}/QuadraticToLinear)
+INSTALL(FILES ${test_QuadraticToLinear_src} DESTINATION ${TEST_INSTALL_DIRECTORY})
+
+INSTALL(FILES CTestTestfileInstall.cmake
+ DESTINATION ${TEST_INSTALL_DIRECTORY}
+ RENAME CTestTestfile.cmake)
--- /dev/null
+# Copyright (C) 2015-2020 CEA/DEN, EDF R&D
+#
+# This library 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.
+#
+# This library 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 this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+SET(TEST_NAMES
+ test_QuadraticToLinear
+)
+
+FOREACH(tfile ${TEST_NAMES})
+ SET(TEST_NAME ${COMPONENT_NAME}_${tfile})
+ ADD_TEST(${TEST_NAME} python ${tfile}.py)
+ SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES
+ LABELS "${COMPONENT_NAME}"
+ TIMEOUT ${TIMEOUT}
+ )
+ENDFOREACH()
--- /dev/null
+# Copyright (C) 2021 CEA/DEN, EDF R&D
+#
+# This library 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.
+#
+# This library 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 this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+from MEDLoader import *
+import numpy as np
+
+fname="quadratic.med"
+meshName="mesh"
+coo=DataArrayDouble([(0,-1,0),(1,-1,0),(2,-1,0),#0->3
+ (-1,0,0),(0,0,0),(1,0,0),(2,0,0),#3->7
+ (2,1,0),(1,1,0),(0,1,0),#7->10
+ (-1,0,1),(0,0,1),(1,0,1),#10->13
+ (0,1,1),(1,1,1)#
+ ])
+m0=MEDCouplingUMesh(meshName,3) ; m0.setCoords(coo)
+m0.allocateCells()
+m0.insertNextCell(NORM_TETRA4,[5,6,7,12])
+m0.insertNextCell(NORM_PENTA6,[3,9,4,10,13,11])
+m0.insertNextCell(NORM_HEXA8,[4,9,8,5,11,13,14,12]) ; m0.zipCoords()
+m0.convertLinearCellsToQuadratic()
+#
+m1=MEDCouplingUMesh(meshName,2) ; m1.setCoords(coo)
+m1.allocateCells()
+m1.insertNextCell(NORM_TRI3,[3,4,0])
+m1.insertNextCell(NORM_QUAD4,[0,4,5,1]) ; m1.zipCoords()
+m1.convertLinearCellsToQuadratic()
+#
+m2=MEDCouplingUMesh(meshName,1) ; m2.setCoords(coo)
+m2.allocateCells()
+m2.insertNextCell(NORM_SEG2,[1,2]) ; m2.zipCoords()
+m2.convertLinearCellsToQuadratic()
+#
+coos=[m0.getCoords(),m1.getCoords(),m2.getCoords()]
+ncoos=[len(cooElt) for cooElt in coos]
+arr=DataArrayDouble.Aggregate(coos)
+a,b=arr.findCommonTuples(1e-12)
+o2n,newNbNodes=DataArrayInt.ConvertIndexArrayToO2N(len(arr),a,b)
+newArr=arr[o2n.invertArrayO2N2N2O(newNbNodes)]
+#
+m0.renumberNodesInConn(o2n) ; m0.setCoords(newArr)
+m1.renumberNodesInConn(o2n[sum(ncoos[:1]):]) ; m1.setCoords(newArr)
+m2.renumberNodesInConn(o2n[sum(ncoos[:2]):]) ; m2.setCoords(newArr)
+a,b=newArr.areIncludedInMe(coo,1e-12)
+assert(a) ; b.sort()
+nodeIdsNotLinear=b.buildComplement(len(newArr))
+#
+mm=MEDFileUMesh()
+mm[0]=m0 ; mm[-1]=m1 ; mm[-2]=m2
+mm.write(fname,2)
+
+#
+centerOfCloud=[newArr[:,i].accumulate(0)/len(newArr) for i in range(newArr.getNumberOfComponents())]
+farr=(newArr-centerOfCloud).magnitude()
+farr[nodeIdsNotLinear]=0.
+zeMax=farr.getMaxValue()[0]
+#
+
+fieldName="FieldDouble"
+ff=MEDFileField1TS()
+f=MEDCouplingFieldDouble(ON_NODES) ; f.setMesh(m0) ; f.setArray(farr) ; f.setName(fieldName) ; f.setTime(0.,0,0)
+ff.setFieldNoProfileSBT(f)
+ff.write(fname,0)
+
+fieldName="FieldFloat"
+ff=MEDFileFloatField1TS()
+farr = DataArrayFloat(np.ones((len(farr)), dtype=np.float32))
+f=MEDCouplingFieldFloat(ON_NODES) ; f.setMesh(m0) ; f.setArray(farr) ; f.setName(fieldName) ; f.setTime(0.,0,0)
+ff.setFieldNoProfileSBT(f)
+ff.write(fname,0)
+
+fieldName="FieldInt32"
+ff=MEDFileInt32Field1TS()
+farr = DataArrayInt32(np.ones((len(farr)), dtype=np.int32))
+f=MEDCouplingFieldInt32(ON_NODES) ; f.setMesh(m0) ; f.setArray(farr) ; f.setName(fieldName) ; f.setTime(0.,0,0)
+ff.setFieldNoProfileSBT(f)
+ff.write(fname,0)
+
+fieldName="FieldInt64"
+ff=MEDFileInt64Field1TS()
+farr = DataArrayInt64(np.ones((len(farr)), dtype=np.int64))
+f=MEDCouplingFieldInt64(ON_NODES) ; f.setMesh(m0) ; f.setArray(farr) ; f.setName(fieldName) ; f.setTime(0.,0,0)
+ff.setFieldNoProfileSBT(f)
+ff.write(fname,0)
+
+
+
+
+
+
+
+#fieldName="FieldDouble"
+#f=MEDCouplingFieldDouble(ON_NODES, ONE_TIME) ; f.setMesh(m0) ; f.setArray(farr) ; f.setName(fieldName) ; f.setTime(0.,0,0)
+#farr-=zeMax ; farr.abs() ; farr[nodeIdsNotLinear]=0.
+#farr.reverse()
+#WriteFieldUsingAlreadyWrittenMesh(fname, f)
+#
+#fieldName="FieldFloat"
+#farr = DataArrayFloat(np.ones((len(farr)), dtype=np.float32))
+#f=MEDCouplingFieldFloat(ON_NODES, ONE_TIME) ; f.setMesh(m0) ; f.setArray(farr) ; f.setName(fieldName) ; f.setTime(0.,0,0)
+#WriteFieldUsingAlreadyWrittenMesh(fname, f)
+#
+#fieldName="FieldInt32"
+#farr = DataArrayInt32(np.ones((len(farr)), dtype=np.int32))
+#f=MEDCouplingFieldInt32(ON_NODES, ONE_TIME) ; f.setMesh(m0) ; f.setArray(farr) ; f.setName(fieldName) ; f.setTime(0.,0,0)
+#WriteFieldUsingAlreadyWrittenMesh(fname, f)
+
+#fieldName="FieldInt64"
+#farr = DataArrayInt64(np.ones((len(farr)), dtype=np.int64))
+#f=MEDCouplingFieldInt64(ON_NODES, ONE_TIME) ; f.setMesh(m0) ; f.setArray(farr) ; f.setName(fieldName) ; f.setTime(0.,0,0)
+#WriteField(fname, f, True)
+
+from paraview.simple import *
+
+quadraticmed = MEDReader(registrationName=fname, FileName=fname)
+quadraticmed.AllArrays = ['TS0/mesh/ComSup0/FieldDouble@@][@@P1', 'TS0/mesh/ComSup0/FieldFloat@@][@@P1', 'TS0/mesh/ComSup0/FieldInt32@@][@@P1']
+quadraticmed.AllTimeSteps = ['0000']
+
+quadraticmed.UpdatePipeline()
+
+quadraticToLinear1 = QuadraticToLinear(registrationName='QuadraticToLinear1', Input=quadraticmed)
+quadraticToLinear1.UpdatePipeline()
+++ /dev/null
-# Copyright (C) 2021 CEA/DEN, EDF R&D
-#
-# This library 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.
-#
-# This library 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 this library; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-#
-
-from MEDLoader import *
-
-fname="quadratic.med"
-meshName="mesh"
-coo=DataArrayDouble([(0,-1,0),(1,-1,0),(2,-1,0),#0->3
- (-1,0,0),(0,0,0),(1,0,0),(2,0,0),#3->7
- (2,1,0),(1,1,0),(0,1,0),#7->10
- (-1,0,1),(0,0,1),(1,0,1),#10->13
- (0,1,1),(1,1,1)#
- ])
-m0=MEDCouplingUMesh(meshName,3) ; m0.setCoords(coo)
-m0.allocateCells()
-m0.insertNextCell(NORM_TETRA4,[5,6,7,12])
-m0.insertNextCell(NORM_PENTA6,[3,9,4,10,13,11])
-m0.insertNextCell(NORM_HEXA8,[4,9,8,5,11,13,14,12]) ; m0.zipCoords()
-m0.convertLinearCellsToQuadratic()
-#
-m1=MEDCouplingUMesh(meshName,2) ; m1.setCoords(coo)
-m1.allocateCells()
-m1.insertNextCell(NORM_TRI3,[3,4,0])
-m1.insertNextCell(NORM_QUAD4,[0,4,5,1]) ; m1.zipCoords()
-m1.convertLinearCellsToQuadratic()
-#
-m2=MEDCouplingUMesh(meshName,1) ; m2.setCoords(coo)
-m2.allocateCells()
-m2.insertNextCell(NORM_SEG2,[1,2]) ; m2.zipCoords()
-m2.convertLinearCellsToQuadratic()
-#
-coos=[m0.getCoords(),m1.getCoords(),m2.getCoords()]
-ncoos=[len(cooElt) for cooElt in coos]
-arr=DataArrayDouble.Aggregate(coos)
-a,b=arr.findCommonTuples(1e-12)
-o2n,newNbNodes=DataArrayInt.ConvertIndexArrayToO2N(len(arr),a,b)
-newArr=arr[o2n.invertArrayO2N2N2O(newNbNodes)]
-#
-m0.renumberNodesInConn(o2n) ; m0.setCoords(newArr)
-m1.renumberNodesInConn(o2n[sum(ncoos[:1]):]) ; m1.setCoords(newArr)
-m2.renumberNodesInConn(o2n[sum(ncoos[:2]):]) ; m2.setCoords(newArr)
-a,b=newArr.areIncludedInMe(coo,1e-12)
-assert(a) ; b.sort()
-nodeIdsNotLinear=b.buildComplement(len(newArr))
-#
-mm=MEDFileUMesh()
-mm[0]=m0 ; mm[-1]=m1 ; mm[-2]=m2
-mm.write(fname,2)
-
-#
-centerOfCloud=[newArr[:,i].accumulate(0)/len(newArr) for i in xrange(newArr.getNumberOfComponents())]
-farr=(newArr-centerOfCloud).magnitude()
-farr[nodeIdsNotLinear]=0.
-zeMax=farr.getMaxValue()[0]
-#
-fieldName="Field"
-ff=MEDFileField1TS()
-f=MEDCouplingFieldDouble(ON_NODES) ; f.setMesh(m0) ; f.setArray(farr) ; f.setName(fieldName) ; f.setTime(0.,0,0)
-ff.setFieldNoProfileSBT(f)
-ff.write(fname,0)
-farr-=zeMax ; farr.abs() ; farr[nodeIdsNotLinear]=0.
-farr.reverse() ; f.setTime(1.,1,0)
-ff.setFieldNoProfileSBT(f)
-ff.write(fname,0)
#include <vtkDataSetAttributes.h>
#include <vtkDemandDrivenPipeline.h>
#include <vtkDoubleArray.h>
+#include <vtkLongArray.h>
#include <vtkExecutive.h>
#include <vtkFloatArray.h>
#include <vtkInEdgeIterator.h>
throw MZCException(oss.str());
}
}
+ else if (vtkFloatArray::SafeDownCast(array))
+ {
+ vtkSmartPointer<vtkFloatArray> ret(vtkSmartPointer<vtkFloatArray>::New());
+ zeRet = ret;
+ ret->SetNumberOfComponents(nbOfCompo);
+ ret->SetNumberOfTuples(newNbPts);
+ vtkFloatArray *array1(vtkFloatArray::SafeDownCast(array));
+ if (array1)
+ {
+ const float *inpCoords(array1->GetPointer(0));
+ float *outCoords(ret->GetPointer(0));
+ for (int i = 0; i < newNbPts; i++, outCoords += nbOfCompo)
+ std::copy(inpCoords + new2Old[i] * nbOfCompo, inpCoords + (new2Old[i] + 1) * nbOfCompo, outCoords);
+ }
+ else
+ {
+ std::ostringstream oss;
+ oss << "Only Float array managed for the moment in input !" << array->GetName();
+ throw MZCException(oss.str());
+ }
+ }
+ else if (vtkLongArray::SafeDownCast(array))
+ {
+ vtkSmartPointer<vtkLongArray> ret(vtkSmartPointer<vtkLongArray>::New());
+ zeRet = ret;
+ ret->SetNumberOfComponents(nbOfCompo);
+ ret->SetNumberOfTuples(newNbPts);
+ vtkLongArray *array1(vtkLongArray::SafeDownCast(array));
+ if (array1)
+ {
+ const long *inpCoords(array1->GetPointer(0));
+ long *outCoords(ret->GetPointer(0));
+ for (int i = 0; i < newNbPts; i++, outCoords += nbOfCompo)
+ std::copy(inpCoords + new2Old[i] * nbOfCompo, inpCoords + (new2Old[i] + 1) * nbOfCompo, outCoords);
+ }
+ else
+ {
+ std::ostringstream oss;
+ oss << "Only Long array managed for the moment in input !" << array->GetName();
+ throw MZCException(oss.str());
+ }
+ }
else if (vtkIntArray::SafeDownCast(array))
{
vtkSmartPointer<vtkIntArray> ret(vtkSmartPointer<vtkIntArray>::New());