From acaf4e67a10b56c469d81e5b0a59ae131b4e33a8 Mon Sep 17 00:00:00 2001 From: eap Date: Fri, 18 Mar 2011 09:01:37 +0000 Subject: [PATCH] 0021167: [CEA 448] Supports management on all elements --- doc/MEDMEM/FIELDcreate.cxx | 2 +- doc/MEDMEM/FIELDgeneral.cxx | 5 +- ...MEM_InvokingDriverAtObjectCreationTime.cxx | 10 +- ..._InvokingDriverByAttachingItToAnObject.cxx | 16 +- ...InvokingDriverFromStandardObjectMethod.cxx | 8 +- .../MEDMEM_MedAddingAnExistingObject.cxx | 13 +- doc/MEDMEM/MESHINGexample.cxx | 151 +++++++++--------- doc/MEDMEM/MESHconnectivities.cxx | 4 +- 8 files changed, 104 insertions(+), 105 deletions(-) diff --git a/doc/MEDMEM/FIELDcreate.cxx b/doc/MEDMEM/FIELDcreate.cxx index c511feb34..81b7acd47 100644 --- a/doc/MEDMEM/FIELDcreate.cxx +++ b/doc/MEDMEM/FIELDcreate.cxx @@ -37,7 +37,7 @@ int main (int argc, char ** argv) { // myMesh->read() ; // we need a support : - SUPPORT * mySupport = new SUPPORT(myMesh,"Support on all CELLs",MED_CELL); + const SUPPORT * mySupport = myMesh->getSupportOnAll(MED_CELL); /* create FIELD on mySupport, with 3 components */ int NumberOfCompoennts = 3 ; diff --git a/doc/MEDMEM/FIELDgeneral.cxx b/doc/MEDMEM/FIELDgeneral.cxx index ee63c79f0..41a9bb52c 100644 --- a/doc/MEDMEM/FIELDgeneral.cxx +++ b/doc/MEDMEM/FIELDgeneral.cxx @@ -39,7 +39,7 @@ int main (int argc, char ** argv) { /* read FIELD */ // we need a support : - SUPPORT * mySupport = new SUPPORT(myMesh,"Support on all Cells",MED_CELL); + const SUPPORT * mySupport = myMesh->getSupportOnAll(MED_CELL); FIELD myField(mySupport,MED_DRIVER,MedFile,FieldName) ; // myField.read() ; @@ -77,8 +77,7 @@ int main (int argc, char ** argv) { cout << endl ; } - delete mySupport; - delete myMesh; + myMesh->removeReference(); return 0 ; } diff --git a/doc/MEDMEM/MEDMEM_InvokingDriverAtObjectCreationTime.cxx b/doc/MEDMEM/MEDMEM_InvokingDriverAtObjectCreationTime.cxx index 3ae53a608..76bc6f2ae 100644 --- a/doc/MEDMEM/MEDMEM_InvokingDriverAtObjectCreationTime.cxx +++ b/doc/MEDMEM/MEDMEM_InvokingDriverAtObjectCreationTime.cxx @@ -33,24 +33,24 @@ using namespace MED_EN ; main () { const char * fileName = "pointe.med"; - const char * fieldName = "fieldcelldouble"; + const char * fieldName = "fieldcelldoublescalar"; const char * meshName = "maa1"; try { // Test creation of drivers at object Creation time - //This test failed due to inadequate Support implementation - // FIELD myField (MED_DRIVER,fileName,fieldName); + FIELD myField (MED_DRIVER,fileName,fieldName); MESH myMesh (MED_DRIVER,fileName,meshName); MED myMed (MED_DRIVER,fileName); // Test removal of drivers - //myField.rmDriver(); + myField.rmDriver(); myMesh.rmDriver (); myMed.rmDriver (); } catch (MEDEXCEPTION& ex){ - MESSAGE(ex.what()) ; + MESSAGE_MED(ex.what()) ; } } + diff --git a/doc/MEDMEM/MEDMEM_InvokingDriverByAttachingItToAnObject.cxx b/doc/MEDMEM/MEDMEM_InvokingDriverByAttachingItToAnObject.cxx index 2c3240a13..624bc1b43 100644 --- a/doc/MEDMEM/MEDMEM_InvokingDriverByAttachingItToAnObject.cxx +++ b/doc/MEDMEM/MEDMEM_InvokingDriverByAttachingItToAnObject.cxx @@ -37,7 +37,7 @@ main () { const char * fileName = "pointe.med"; const char * fileName2 = "Field&MeshGeneratedPointe.med"; const char * fileName3 = "MedGeneratedPointe.med"; - const char * fieldName = "fieldcelldouble"; + const char * fieldName = "fieldcelldoublescalar"; const char * meshName = "maa1"; try { @@ -47,14 +47,12 @@ main () { MED_FIELD_RDONLY_DRIVER myRdOnlyDriver(fileName,myField); myRdOnlyDriver.setFieldName(fieldName); myRdOnlyDriver.open(); - //This test failed due to inadequate Support implementation - // myRdOnlyDriver.read(); + myRdOnlyDriver.read(); // try { myRdOnlyDriver.write(); } catch (MEDEXCEPTION& ex) // { MESSAGE(ex.what()); } MED_FIELD_WRONLY_DRIVER myWrOnlyDriver(fileName2,myField); myWrOnlyDriver.open(); - //This test failed due to inadequate Support implementation - // myWrOnlyDriver.write(); + myWrOnlyDriver.write(); // try myWrOnlyDriver.read(); catch (MEDEXCEPTION& ex) // { MESSAGE(ex.what()); } myRdOnlyDriver.close(); @@ -77,9 +75,7 @@ main () { myWrOnlyDriver.write(); // try myWrOnlyDriver.read(); catch (MEDEXCEPTION& ex) // { MESSAGE(ex.what()); } - // myRdOnlyDriver.close(); - //While we use H5close() in the MESH/FIELD drivers, the next - //line will fail, because all files are previously closed ! + myRdOnlyDriver.close(); myWrOnlyDriver.close(); delete myMesh; } @@ -91,7 +87,7 @@ main () { myRdOnlyDriver.readFileStruct(); myRdOnlyDriver.close(); myMed->updateSupport(); // DOIT ETRE SUPPRIMEE - // myRdOnlyDriver.read(); + myRdOnlyDriver.read(); // try { myRdOnlyDriver.write(); } catch (MEDEXCEPTION& ex) // { MESSAGE(ex.what()); } //MED_MED_WRONLY_DRIVER myWrOnlyDriver(fileName3,myMed); @@ -103,6 +99,6 @@ main () { } catch (MEDEXCEPTION& ex){ cout << "MAIN BLOCK EXCEPTION" << endl; - MESSAGE(ex.what()) ; + MESSAGE_MED(ex.what()) ; } } diff --git a/doc/MEDMEM/MEDMEM_InvokingDriverFromStandardObjectMethod.cxx b/doc/MEDMEM/MEDMEM_InvokingDriverFromStandardObjectMethod.cxx index 01ea3d2ce..06fbfc65c 100644 --- a/doc/MEDMEM/MEDMEM_InvokingDriverFromStandardObjectMethod.cxx +++ b/doc/MEDMEM/MEDMEM_InvokingDriverFromStandardObjectMethod.cxx @@ -34,19 +34,19 @@ main () { const char * fileName = "pointe.med"; const char * fileName2 = "fieldCellDoubleOfpointe.med"; - const char * fieldName = "fieldcelldouble"; + const char * fieldName = "fieldcelldoublescalar"; const char * meshName = "maa1"; try { // Test creation of drivers from the standard driver method of an object FIELD * myField = new FIELD(); int myDriver1 = myField->addDriver(MED_DRIVER, fileName, fieldName); - //myField->read(); + myField->read(); //This test failed due to inadequate Support implementation myField->rmDriver(); // TESTER LA VALIDITE DE myDriver2 !!!! int myDriver2 = myField->addDriver(MED_DRIVER, fileName2, fieldName); - //myField->write(myDriver2); + myField->write(myDriver2); //This test failed due to inadequate Support implementation myField->rmDriver(myDriver2); @@ -65,6 +65,6 @@ main () { delete myMed; } catch (MEDEXCEPTION& ex){ - MESSAGE(ex.what()) ; + MESSAGE_MED(ex.what()) ; } } diff --git a/doc/MEDMEM/MEDMEM_MedAddingAnExistingObject.cxx b/doc/MEDMEM/MEDMEM_MedAddingAnExistingObject.cxx index f3794fbe1..e6258cc0c 100644 --- a/doc/MEDMEM/MEDMEM_MedAddingAnExistingObject.cxx +++ b/doc/MEDMEM/MEDMEM_MedAddingAnExistingObject.cxx @@ -30,10 +30,7 @@ main () { const char * fileName = "pointe.med"; - const char * fileName2 = "Field&MeshGeneratedPointe.med"; const char * fileName3 = "MedGeneratedPointe.med"; - const char * fieldName1 = "fieldcelldouble"; - const char * fieldName2 = "fieldcelldoublebis"; const char * meshName1 = "maa1"; const char * meshName2 = "maa1bis"; @@ -41,19 +38,19 @@ main () { // FAIRE LE TEST AVEC LES CHAMPS AUSSI !. - MESH myMesh(MED_DRIVER,fileName,meshName1); - myMesh.setName(meshName2); - myMesh.rmDriver(); + MESH* myMesh = new MESH(MED_DRIVER,fileName,meshName1); + myMesh->setName(meshName2); + myMesh->rmDriver(); MED myMed(MED_DRIVER,fileName); myMed.read(); - myMed.addMesh(&myMesh); + myMed.addMesh(myMesh); int myMedDriver = myMed.addDriver(MED_DRIVER,fileName3); myMed.write(myMedDriver); // FAIRE LE TEST AVEC LES CHAMPS AUSSI !. } catch (MEDEXCEPTION& ex){ - MESSAGE(ex.what()) ; + MESSAGE_MED(ex.what()) ; } } diff --git a/doc/MEDMEM/MESHINGexample.cxx b/doc/MEDMEM/MESHINGexample.cxx index 4a4fdc7d0..737d976e9 100644 --- a/doc/MEDMEM/MESHINGexample.cxx +++ b/doc/MEDMEM/MESHINGexample.cxx @@ -33,8 +33,8 @@ int main (int argc, char ** argv) { // filename to save the generated MESH string filename = "meshing.med" ; - MESHING myMeshing ; - myMeshing.setName("meshing") ; + MESHING* myMeshing = new MESHING; + myMeshing->setName("meshing") ; // define coordinates @@ -62,13 +62,13 @@ int main (int argc, char ** argv) { 0.0, 0.0, 5.0 }; - myMeshing.setCoordinates(SpaceDimension,NumberOfNodes,Coordinates,"CARTESIAN",MED_FULL_INTERLACE); + myMeshing->setCoordinates(SpaceDimension,NumberOfNodes,Coordinates,"CARTESIAN",MED_FULL_INTERLACE); string Names[3] = { "X","Y","Z" } ; - myMeshing.setCoordinatesNames(Names); + myMeshing->setCoordinatesNames(Names); string Units[3] = { "cm","cm","cm" } ; - myMeshing.setCoordinatesUnits(Units) ; + myMeshing->setCoordinatesUnits(Units) ; // define conectivities @@ -78,9 +78,9 @@ int main (int argc, char ** argv) { medGeometryElement Types[NumberOfTypes] = {MED_TETRA4,MED_PYRA5,MED_HEXA8} ; const int NumberOfElements[NumberOfTypes] = {12,2,2} ; - myMeshing.setNumberOfTypes(NumberOfTypes,MED_CELL); - myMeshing.setTypes(Types,MED_CELL); - myMeshing.setNumberOfElements(NumberOfElements,MED_CELL); + myMeshing->setNumberOfTypes(NumberOfTypes,MED_CELL); + myMeshing->setTypes(Types,MED_CELL); + myMeshing->setNumberOfElements(NumberOfElements,MED_CELL); const int sizeTetra = 12*4 ; int ConnectivityTetra[sizeTetra]= @@ -99,7 +99,7 @@ int main (int argc, char ** argv) { 2,10,6,9 }; - myMeshing.setConnectivity(ConnectivityTetra,MED_CELL,MED_TETRA4); + myMeshing->setConnectivity(ConnectivityTetra,MED_CELL,MED_TETRA4); int ConnectivityPyra[2*5]= { @@ -107,7 +107,7 @@ int main (int argc, char ** argv) { 15,18,17,16,19 }; - myMeshing.setConnectivity(ConnectivityPyra,MED_CELL,MED_PYRA5); + myMeshing->setConnectivity(ConnectivityPyra,MED_CELL,MED_PYRA5); int ConnectivityHexa[2*8]= { @@ -115,7 +115,7 @@ int main (int argc, char ** argv) { 15,16,17,18,11,12,13,14 }; - myMeshing.setConnectivity(ConnectivityHexa,MED_CELL,MED_HEXA8); + myMeshing->setConnectivity(ConnectivityHexa,MED_CELL,MED_HEXA8); // face part @@ -123,9 +123,9 @@ int main (int argc, char ** argv) { medGeometryElement FacesTypes[NumberOfFacesTypes] = {MED_TRIA3,MED_QUAD4} ; const int NumberOfFacesElements[NumberOfFacesTypes] = {4,4} ; - myMeshing.setNumberOfTypes(NumberOfFacesTypes,MED_FACE); - myMeshing.setTypes(FacesTypes,MED_FACE); - myMeshing.setNumberOfElements(NumberOfFacesElements,MED_FACE); + myMeshing->setNumberOfTypes(NumberOfFacesTypes,MED_FACE); + myMeshing->setTypes(FacesTypes,MED_FACE); + myMeshing->setNumberOfElements(NumberOfFacesElements,MED_FACE); const int sizeTria = 3*4 ; int ConnectivityTria[sizeTria]= @@ -136,7 +136,7 @@ int main (int argc, char ** argv) { 1,3,6 }; - myMeshing.setConnectivity(ConnectivityTria,MED_FACE,MED_TRIA3); + myMeshing->setConnectivity(ConnectivityTria,MED_FACE,MED_TRIA3); int ConnectivityQua[4*4]= { @@ -146,7 +146,7 @@ int main (int argc, char ** argv) { 12,8,9,13 }; - myMeshing.setConnectivity(ConnectivityQua,MED_FACE,MED_QUAD4); + myMeshing->setConnectivity(ConnectivityQua,MED_FACE,MED_QUAD4); // edge part @@ -156,49 +156,51 @@ int main (int argc, char ** argv) { // Node : { - GROUP myGroup ; - myGroup.setName("SomeNodes"); - myGroup.setMesh(&myMeshing); - myGroup.setEntity(MED_NODE); - myGroup.setNumberOfGeometricType(1); + GROUP* myGroup = new GROUP; + myGroup->setName("SomeNodes"); + myGroup->setMesh(myMeshing); + myGroup->setEntity(MED_NODE); + myGroup->setNumberOfGeometricType(1); medGeometryElement myTypes[1] = {MED_NONE}; - myGroup.setGeometricType(myTypes); + myGroup->setGeometricType(myTypes); const int myNumberOfElements[1] = {4} ; - myGroup.setNumberOfElements(myNumberOfElements); + myGroup->setNumberOfElements(myNumberOfElements); const int index[1+1] = {1,5} ; const int value[4]= { 1,4,5,7} ; - myGroup.setNumber(index,value); + myGroup->setNumber(index,value); - myMeshing.addGroup(myGroup); + myMeshing->addGroup(*myGroup); + myGroup->removeReference(); } { - GROUP myGroup ; - myGroup.setName("OtherNodes"); - myGroup.setMesh(&myMeshing); - myGroup.setEntity(MED_NODE); - myGroup.setNumberOfGeometricType(1); + GROUP* myGroup = new GROUP; + myGroup->setName("OtherNodes"); + myGroup->setMesh(myMeshing); + myGroup->setEntity(MED_NODE); + myGroup->setNumberOfGeometricType(1); medGeometryElement myTypes[1] = {MED_NONE}; - myGroup.setGeometricType(myTypes); + myGroup->setGeometricType(myTypes); const int myNumberOfElements[1] = {3} ; - myGroup.setNumberOfElements(myNumberOfElements); + myGroup->setNumberOfElements(myNumberOfElements); const int index[1+1] = {1,4} ; const int value[3]= { 2,3,6} ; - myGroup.setNumber(index,value); + myGroup->setNumber(index,value); - myMeshing.addGroup(myGroup); + myMeshing->addGroup(*myGroup); + myGroup->removeReference(); } // Cell : { - GROUP myGroup ; - myGroup.setName("SomeCells"); - myGroup.setMesh(&myMeshing); - myGroup.setEntity(MED_CELL); - myGroup.setNumberOfGeometricType(3); + GROUP* myGroup = new GROUP; + myGroup->setName("SomeCells"); + myGroup->setMesh(myMeshing); + myGroup->setEntity(MED_CELL); + myGroup->setNumberOfGeometricType(3); medGeometryElement myTypes[3] = {MED_TETRA4,MED_PYRA5,MED_HEXA8}; - myGroup.setGeometricType(myTypes); + myGroup->setGeometricType(myTypes); const int myNumberOfElements[3] = {4,1,2} ; - myGroup.setNumberOfElements(myNumberOfElements); + myGroup->setNumberOfElements(myNumberOfElements); const int index[3+1] = {1,5,6,8} ; const int value[4+1+2]= { @@ -206,75 +208,80 @@ int main (int argc, char ** argv) { 13, 15,16 }; - myGroup.setNumber(index,value); + myGroup->setNumber(index,value); - myMeshing.addGroup(myGroup); + myMeshing->addGroup(*myGroup); + myGroup->removeReference(); } { - GROUP myGroup ; - myGroup.setName("OtherCells"); - myGroup.setMesh(&myMeshing); - myGroup.setEntity(MED_CELL); - myGroup.setNumberOfGeometricType(2); + GROUP* myGroup = new GROUP; + myGroup->setName("OtherCells"); + myGroup->setMesh(myMeshing); + myGroup->setEntity(MED_CELL); + myGroup->setNumberOfGeometricType(2); medGeometryElement myTypes[] = {MED_TETRA4,MED_PYRA5}; - myGroup.setGeometricType(myTypes); + myGroup->setGeometricType(myTypes); const int myNumberOfElements[] = {4,1} ; - myGroup.setNumberOfElements(myNumberOfElements); + myGroup->setNumberOfElements(myNumberOfElements); const int index[3+1] = {1,5,6} ; const int value[4+1]= { 3,4,5,9, 14 }; - myGroup.setNumber(index,value); + myGroup->setNumber(index,value); - myMeshing.addGroup(myGroup); + myMeshing->addGroup(*myGroup); + myGroup->removeReference(); } // Face : { - GROUP myGroup ; - myGroup.setName("SomeFaces"); - myGroup.setMesh(&myMeshing); - myGroup.setEntity(MED_FACE); - myGroup.setNumberOfGeometricType(2); + GROUP* myGroup = new GROUP; + myGroup->setName("SomeFaces"); + myGroup->setMesh(myMeshing); + myGroup->setEntity(MED_FACE); + myGroup->setNumberOfGeometricType(2); medGeometryElement myTypes[2] = {MED_TRIA3,MED_QUAD4}; - myGroup.setGeometricType(myTypes); + myGroup->setGeometricType(myTypes); const int myNumberOfElements[2] = {2,3} ; - myGroup.setNumberOfElements(myNumberOfElements); + myGroup->setNumberOfElements(myNumberOfElements); const int index[2+1] = {1,3,6} ; const int value[2+3]= { 2,4, 5,6,8 } ; - myGroup.setNumber(index,value); + myGroup->setNumber(index,value); - myMeshing.addGroup(myGroup); + myMeshing->addGroup(*myGroup); + myGroup->removeReference(); } { - GROUP myGroup ; - myGroup.setName("OtherFaces"); - myGroup.setMesh(&myMeshing); - myGroup.setEntity(MED_FACE); - myGroup.setNumberOfGeometricType(1); + GROUP* myGroup = new GROUP; + myGroup->setName("OtherFaces"); + myGroup->setMesh(myMeshing); + myGroup->setEntity(MED_FACE); + myGroup->setNumberOfGeometricType(1); medGeometryElement myTypes[1] = {MED_TRIA3}; - myGroup.setGeometricType(myTypes); + myGroup->setGeometricType(myTypes); const int myNumberOfElements[1] = {2} ; - myGroup.setNumberOfElements(myNumberOfElements); + myGroup->setNumberOfElements(myNumberOfElements); const int index[1+1] = {1,3} ; const int value[2]= { 1,3 } ; - myGroup.setNumber(index,value); + myGroup->setNumber(index,value); - myMeshing.addGroup(myGroup); + myMeshing->addGroup(*myGroup); + myGroup->removeReference(); } // all rigtht, we save it ! - int id = myMeshing.addDriver(MED_DRIVER,filename,myMeshing.getName()); - myMeshing.write(id) ; + int id = myMeshing->addDriver(MED_DRIVER,filename,myMeshing->getName()); + myMeshing->write(id) ; } + diff --git a/doc/MEDMEM/MESHconnectivities.cxx b/doc/MEDMEM/MESHconnectivities.cxx index 389546240..dee9539b5 100644 --- a/doc/MEDMEM/MESHconnectivities.cxx +++ b/doc/MEDMEM/MESHconnectivities.cxx @@ -123,8 +123,8 @@ int main (int argc, char ** argv) { myMesh.getNumberOfElements(ConstituentEntity,MED_ALL_ELEMENTS); if (MeshDimension==1) { - MESSAGE("ERROR : MeshDimension = 1 !"); - MESSAGE("We could not see Reverse Descending Connectivity.") ; + MESSAGE_MED("ERROR : MeshDimension = 1 !"); + MESSAGE_MED("We could not see Reverse Descending Connectivity.") ; } else { for (int i=0; i