Back to index

salome-med  6.5.0
Public Member Functions
MEDCouplingRemapperTest.MEDCouplingBasicsTest Class Reference

List of all members.

Public Member Functions

def testRemapper1
def testPrepareEx1
def testPartialTransfer1
def build2DSourceMesh_1
def build2DTargetMesh_1
def build2DTargetMesh_3
def setUp

Detailed Description

Definition at line 25 of file MEDCouplingRemapperTest.py.


Member Function Documentation

Definition at line 126 of file MEDCouplingRemapperTest.py.

00126 
00127     def build2DSourceMesh_1(self):
00128         sourceCoords=[-0.3,-0.3, 0.7,-0.3, -0.3,0.7, 0.7,0.7]
00129         sourceConn=[0,3,1,0,2,3]
00130         sourceMesh=MEDCouplingUMesh.New("my name of mesh 2D",2)
00131         sourceMesh.allocateCells(2);
00132         sourceMesh.insertNextCell(NORM_TRI3,3,sourceConn[0:3]);
00133         sourceMesh.insertNextCell(NORM_TRI3,3,sourceConn[3:6]);
00134         sourceMesh.finishInsertingCells();
00135         myCoords=DataArrayDouble.New();
00136         myCoords.setValues(sourceCoords,4,2);
00137         sourceMesh.setCoords(myCoords);
00138         return sourceMesh;
    

Here is the caller graph for this function:

Definition at line 139 of file MEDCouplingRemapperTest.py.

00139 
00140     def build2DTargetMesh_1(self):
00141         targetCoords=[-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 ]
00142         targetConn=[0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4]
00143         targetMesh=MEDCouplingUMesh.New();
00144         targetMesh.setMeshDimension(2);
00145         targetMesh.allocateCells(5);
00146         targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[0:4]);
00147         targetMesh.insertNextCell(NORM_TRI3,3,targetConn[4:7]);
00148         targetMesh.insertNextCell(NORM_TRI3,3,targetConn[7:10]);
00149         targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[10:14]);
00150         targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[14:18]);
00151         targetMesh.finishInsertingCells();
00152         myCoords=DataArrayDouble.New();
00153         myCoords.setValues(targetCoords,9,2);
00154         targetMesh.setCoords(myCoords);
00155         return targetMesh;

Here is the caller graph for this function:

Definition at line 156 of file MEDCouplingRemapperTest.py.

00156 
00157     def build2DTargetMesh_3(self):
00158         targetCoords=[-0.6,-0.4, -0.1,-0.4, 1.1,-0.4, 2.1,-0.4, -0.6,0.1,  -0.1,0.1,  1.1,0.1,  2.1,0.1, -0.6,1.1,  -0.1,1.1]
00159         targetConn=[0,4,5,1, 1,5,6,2, 2,6,7,3, 4,8,9,5]
00160         targetMesh=MEDCouplingUMesh.New();
00161         targetMesh.setMeshDimension(2);
00162         targetMesh.allocateCells(4);
00163         for i in xrange(4):
00164             targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[4*i:4*(i+1)])
00165             pass
00166         targetMesh.finishInsertingCells();
00167         myCoords=DataArrayDouble.New();
00168         myCoords.setValues(targetCoords,10,2);
00169         targetMesh.setCoords(myCoords);
00170         return targetMesh;
00171         pass
    

Here is the caller graph for this function:

Definition at line 172 of file MEDCouplingRemapperTest.py.

00172 
00173     def setUp(self):
        pass

Definition at line 84 of file MEDCouplingRemapperTest.py.

00084 
00085     def testPartialTransfer1(self):
00086         sourceMesh=self.build2DSourceMesh_1();
00087         targetMesh=self.build2DTargetMesh_3();
00088         #
00089         remapper=MEDCouplingRemapper();
00090         remapper.setPrecision(1e-12);
00091         remapper.setIntersectionType(Triangulation);
00092         srcFt=MEDCouplingFieldTemplate.New(ON_CELLS);
00093         trgFt=MEDCouplingFieldTemplate.New(ON_CELLS);
00094         srcFt.setMesh(sourceMesh);
00095         trgFt.setMesh(targetMesh);
00096         self.assertEqual(1,remapper.prepareEx(srcFt,trgFt));
00097         srcField=MEDCouplingFieldDouble.New(ON_CELLS);
00098         srcField.setNature(ConservativeVolumic);
00099         srcField.setMesh(sourceMesh);
00100         array=DataArrayDouble.New();
00101         ptr=sourceMesh.getNumberOfCells()*[None]
00102         for i in xrange(sourceMesh.getNumberOfCells()):
00103             ptr[i]=float(i+7);
00104             pass
00105         array.setValues(ptr,sourceMesh.getNumberOfCells(),1);
00106         srcField.setArray(array);
00107         trgfield=MEDCouplingFieldDouble.New(ON_CELLS);
00108         trgfield.setNature(ConservativeVolumic);
00109         trgfield.setMesh(targetMesh);
00110         array=DataArrayDouble.New();
00111         ptr=targetMesh.getNumberOfCells()*[None]
00112         for i in xrange(targetMesh.getNumberOfCells()):
00113             ptr[i]=4.220173;
00114             pass
00115         array.setValues(ptr,targetMesh.getNumberOfCells(),1);
00116         trgfield.setArray(array);
00117         remapper.partialTransfer(srcField,trgfield);
00118         values=trgfield.getArray().getValues();
00119         valuesExpected=[7.75, 7.0625, 4.220173,8.0]
00120         self.assertEqual(4,trgfield.getArray().getNumberOfTuples());
00121         self.assertEqual(1,trgfield.getArray().getNumberOfComponents());
00122         for i0 in xrange(4):
00123             self.assertAlmostEqual(valuesExpected[i0],values[i0],12);
00124             pass
00125         pass
    

Here is the call graph for this function:

Definition at line 52 of file MEDCouplingRemapperTest.py.

00052 
00053     def testPrepareEx1(self):
00054         sourceMesh=self.build2DSourceMesh_1();
00055         targetMesh=self.build2DTargetMesh_3();
00056         #
00057         remapper=MEDCouplingRemapper();
00058         remapper.setPrecision(1e-12);
00059         remapper.setIntersectionType(Triangulation);
00060         srcFt=MEDCouplingFieldTemplate.New(ON_CELLS);
00061         trgFt=MEDCouplingFieldTemplate.New(ON_CELLS);
00062         srcFt.setMesh(sourceMesh);
00063         trgFt.setMesh(targetMesh);
00064         self.assertEqual(1,remapper.prepareEx(srcFt,trgFt));
00065         srcField=MEDCouplingFieldDouble.New(ON_CELLS);
00066         srcField.setNature(ConservativeVolumic);
00067         srcField.setMesh(sourceMesh);
00068         array=DataArrayDouble.New();
00069         ptr=sourceMesh.getNumberOfCells()*[None]
00070         for i in xrange(sourceMesh.getNumberOfCells()):
00071             ptr[i]=float(i+7);
00072             pass
00073         array.setValues(ptr,sourceMesh.getNumberOfCells(),1);
00074         srcField.setArray(array);
00075         trgfield=remapper.transferField(srcField,4.220173);
00076         values=trgfield.getArray().getValues();
00077         valuesExpected=[7.75, 7.0625, 4.220173,8.0]
00078         self.assertEqual(4,trgfield.getArray().getNumberOfTuples());
00079         self.assertEqual(1,trgfield.getArray().getNumberOfComponents());
00080         for i0 in xrange(4):
00081             self.assertAlmostEqual(valuesExpected[i0],values[i0],12);
00082             pass
00083         pass

Here is the call graph for this function:

Definition at line 26 of file MEDCouplingRemapperTest.py.

00026 
00027     def testRemapper1(self):
00028         sourceMesh=self.build2DSourceMesh_1();
00029         targetMesh=self.build2DTargetMesh_1();
00030         remapper=MEDCouplingRemapper()
00031         remapper.setPrecision(1e-12);
00032         remapper.setIntersectionType(Triangulation);
00033         self.failUnless(remapper.prepare(sourceMesh,targetMesh,"P0P0")==1);
00034         srcField=MEDCouplingFieldDouble.New(ON_CELLS);
00035         srcField.setNature(ConservativeVolumic);
00036         srcField.setMesh(sourceMesh);
00037         array=DataArrayDouble.New();
00038         ptr=sourceMesh.getNumberOfCells()*[None]
00039         for i in xrange(sourceMesh.getNumberOfCells()):
00040             ptr[i]=float(i+7)
00041             pass
00042         array.setValues(ptr,sourceMesh.getNumberOfCells(),1);
00043         srcField.setArray(array);
00044         trgfield=remapper.transferField(srcField,4.57);
00045         values=trgfield.getArray().getValues();
00046         valuesExpected=[7.5 ,7. ,7.,8.,7.5];
00047         for i in xrange(targetMesh.getNumberOfCells()):
00048             self.failUnless(abs(values[i]-valuesExpected[i])<1e-12);
00049             pass
00050         self.failUnless(1==trgfield.getArray().getNumberOfComponents());
00051         pass

Here is the call graph for this function:


The documentation for this class was generated from the following file: