2 /* Programme de test du constructeur de copies de la classe FIELD_ de MEDMEM
10 #include "MEDMEM_Exception.hxx"
11 #include "MEDMEM_Mesh.hxx"
12 #include "MEDMEM_Family.hxx"
13 #include "MEDMEM_Group.hxx"
15 #include "MEDMEM_MedMeshDriver.hxx"
16 #include "MEDMEM_MedFieldDriver.hxx"
17 #include "MEDMEM_Support.hxx"
18 #include "MEDMEM_Field.hxx"
19 #include "MEDMEM_define.hxx"
20 using namespace MEDMEM;
23 void affiche_field_(FIELD_ * myField, const SUPPORT * mySupport)
25 cout << "Field "<< myField->getName() << " : " <<myField->getDescription() << endl ;
26 int NumberOfComponents = myField->getNumberOfComponents() ;
27 cout << "- Nombre de composantes : "<< NumberOfComponents << endl ;
28 for (int i=1; i<NumberOfComponents+1; i++) {
29 cout << " - composante "<<i<<" :"<<endl ;
30 cout << " - nom : "<<myField->getComponentName(i)<< endl;
31 cout << " - description : "<<myField->getComponentDescription(i) << endl;
32 cout << " - units : "<<myField->getMEDComponentUnit(i) << endl;
34 cout << "- iteration :" << endl ;
35 cout << " - numero : " << myField->getIterationNumber()<< endl ;
36 cout << " - ordre : " << myField->getOrderNumber()<< endl ;
37 cout << " - temps : " << myField->getTime()<< endl ;
39 cout << "- Type : " << myField->getValueType()<< endl;
41 cout << "- Adresse support : " << mySupport << endl;
44 void affiche_fieldT(FIELD<double> * myField, const SUPPORT * mySupport)
46 affiche_field_((FIELD_ *) myField, mySupport);
48 cout << "- Valeurs :"<<endl;
49 int NumberOf = mySupport->getNumberOfElements(MED_ALL_ELEMENTS);
50 int NumberOfComponents = myField->getNumberOfComponents() ;
52 for (int i=1; i<NumberOf+1; i++) {
53 const double * value = myField->getValueI(MED_FULL_INTERLACE,i) ;
54 for (int j=0; j<NumberOfComponents; j++)
55 cout << value[j]<< " ";
60 int main (int argc, char ** argv) {
62 // int read; !! UNUSED VARIABLE !!
64 if ((argc !=3) && (argc != 4)) {
65 cerr << "Usage : " << argv[0]
66 << " filename meshname fieldname" << endl << endl;
70 string filename = argv[1] ;
71 string meshname = argv[2] ;
73 MESH * myMesh= new MESH() ;
74 myMesh->setName(meshname);
75 MED_MESH_RDONLY_DRIVER myMeshDriver(filename,myMesh) ;
76 myMeshDriver.setMeshName(meshname);
77 int current = myMesh->addDriver(myMeshDriver);
78 myMesh->read(current);
81 if (argc != 4) exit(0) ;
82 // else we have a field !
83 string fieldname = argv[3];
85 FIELD<double> * myField ;
86 // SUPPORT * mySupport = new SUPPORT(myMesh,"On_all_node",MED_NODE);
87 SUPPORT * mySupport = new SUPPORT(myMesh,"On_all_cell",MED_CELL);
89 myField = new FIELD<double>(mySupport,MED_DRIVER,filename,fieldname) ;
90 myField->setValueType(MED_REEL64);
93 mySupport = new SUPPORT(myMesh,"On_all_node",MED_NODE);
95 myField = new FIELD<double>(mySupport,MED_DRIVER,filename,fieldname) ;
96 myField->setValueType(MED_REEL64);
98 cout << "Field double " << fieldname << " not found !!!" << endl ;
103 affiche_fieldT(myField, mySupport);
104 FIELD<double> * myField2 = new FIELD<double>(* myField);
106 affiche_fieldT(myField2, myField2->getSupport());