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"
22 void affiche_field_(FIELD_ * myField, const SUPPORT * mySupport)
24 cout << "Field "<< myField->getName() << " : " <<myField->getDescription() << endl ;
25 int NumberOfComponents = myField->getNumberOfComponents() ;
26 cout << "- Nombre de composantes : "<< NumberOfComponents << endl ;
27 for (int i=1; i<NumberOfComponents+1; i++) {
28 cout << " - composante "<<i<<" :"<<endl ;
29 cout << " - nom : "<<myField->getComponentName(i)<< endl;
30 cout << " - description : "<<myField->getComponentDescription(i) << endl;
31 cout << " - units : "<<myField->getMEDComponentUnit(i) << endl;
33 cout << "- iteration :" << endl ;
34 cout << " - numero : " << myField->getIterationNumber()<< endl ;
35 cout << " - ordre : " << myField->getOrderNumber()<< endl ;
36 cout << " - temps : " << myField->getTime()<< endl ;
38 cout << "- Type : " << myField->getValueType()<< endl;
40 cout << "- Adresse support : " << mySupport << endl;
43 void affiche_fieldT(FIELD<double> * myField, const SUPPORT * mySupport)
45 affiche_field_((FIELD_ *) myField, mySupport);
47 cout << "- Valeurs :"<<endl;
48 int NumberOf = mySupport->getNumberOfElements(MED_ALL_ELEMENTS);
49 int NumberOfComponents = myField->getNumberOfComponents() ;
51 for (int i=1; i<NumberOf+1; i++) {
52 const double * value = myField->getValueI(MED_FULL_INTERLACE,i) ;
53 for (int j=0; j<NumberOfComponents; j++)
54 cout << value[j]<< " ";
59 int main (int argc, char ** argv) {
61 // int read; !! UNUSED VARIABLE !!
63 if ((argc !=3) && (argc != 4)) {
64 cerr << "Usage : " << argv[0]
65 << " filename meshname fieldname" << endl << endl;
69 string filename = argv[1] ;
70 string meshname = argv[2] ;
72 MESH * myMesh= new MESH() ;
73 myMesh->setName(meshname);
74 MED_MESH_RDONLY_DRIVER myMeshDriver(filename,myMesh) ;
75 myMeshDriver.setMeshName(meshname);
76 int current = myMesh->addDriver(myMeshDriver);
77 myMesh->read(current);
80 if (argc != 4) exit(0) ;
81 // else we have a field !
82 string fieldname = argv[3];
84 FIELD<double> * myField ;
85 // SUPPORT * mySupport = new SUPPORT(myMesh,"On_all_node",MED_NODE);
86 SUPPORT * mySupport = new SUPPORT(myMesh,"On_all_cell",MED_CELL);
88 myField = new FIELD<double>(mySupport,MED_DRIVER,filename,fieldname) ;
89 myField->setValueType(MED_REEL64);
92 mySupport = new SUPPORT(myMesh,"On_all_node",MED_NODE);
94 myField = new FIELD<double>(mySupport,MED_DRIVER,filename,fieldname) ;
95 myField->setValueType(MED_REEL64);
97 cout << "Field double " << fieldname << " not found !!!" << endl ;
102 affiche_fieldT(myField, mySupport);
103 FIELD<double> * myField2 = new FIELD<double>(* myField);
105 affiche_fieldT(myField2, myField2->getSupport());