1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "MEDMEMTest.hxx"
22 #include "MEDMEM_Mesh.hxx"
23 #include "MEDMEM_Group.hxx"
24 #include "MEDMEM_Meshing.hxx"
25 #include "MEDMEM_MedMeshDriver.hxx"
26 #include "MEDMEM_GibiMeshDriver.hxx"
28 #include <cppunit/Message.h>
29 #include <cppunit/TestAssert.h>
32 using namespace MEDMEM;
34 void MEDMEMTest::testGetVolumeAbs()
60 int connNodalCellClassical[24]=
62 10, 11, 13, 17, 18, 20,
64 11, 12, 14, 18, 19, 21,
67 int polyHedraConn[60+12]=
70 15, 16, 17, 18, 19, -1,
89 MESHING* meshing = new MESHING;
90 meshing->setName( "TESTMESH" );
92 meshing->setCoordinates(3, nNodes, coords, "CARTESIAN",
93 MED_EN::MED_FULL_INTERLACE);
98 meshing->setCoordinatesNames(coordname);
103 meshing->setCoordinatesUnits(coordunit);
104 //Cell connectivity info
105 const MED_EN::medGeometryElement classicalTypesCell[2]=
107 MED_EN::MED_PENTA6,MED_POLYHEDRA
109 const int nbOfCellElts[2]=
113 meshing->setNumberOfTypes(2,MED_EN::MED_CELL);
114 meshing->setTypes(classicalTypesCell,MED_EN::MED_CELL);
115 meshing->setNumberOfElements(nbOfCellElts,MED_EN::MED_CELL);
117 meshing->setConnectivity(MED_EN::MED_CELL,MED_EN::MED_PENTA6,connNodalCellClassical);
118 meshing->setConnectivity(MED_EN::MED_CELL,MED_EN::MED_POLYHEDRA, polyHedraConn,polyHedraInd);
120 const SUPPORT *sup=meshing->getSupportOnAll(MED_CELL);
121 FIELD<double> *volumes=meshing->getVolume(sup);
122 const double *vals=volumes->getValue();
123 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,vals[0],1e-13);
124 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,vals[1],1e-13);
125 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,vals[2],1e-13);
126 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,vals[3],1e-13);
127 CPPUNIT_ASSERT_DOUBLES_EQUAL(3.,vals[4],1e-13);
128 CPPUNIT_ASSERT_DOUBLES_EQUAL(3.,vals[5],1e-13);
129 volumes->removeReference();
130 volumes=meshing->getVolume(sup,false);
131 vals=volumes->getValue();
132 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,vals[0],1e-13);
133 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,vals[1],1e-13);
134 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,vals[2],1e-13);
135 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,vals[3],1e-13);
136 CPPUNIT_ASSERT_DOUBLES_EQUAL(2.,vals[4],1e-13);
137 CPPUNIT_ASSERT_DOUBLES_EQUAL(2.,vals[5],1e-13);
139 volumes->removeReference();
140 meshing->removeReference();