1 /* Programme de test du constructeur de copies de la classe COORDINATE de MEDMEM
9 #include "MEDMEM_Exception.hxx"
10 #include "MEDMEM_Mesh.hxx"
11 #include "MEDMEM_Family.hxx"
12 #include "MEDMEM_Group.hxx"
14 #include "MEDMEM_MedMeshDriver.hxx"
15 #include "MEDMEM_MedFieldDriver.hxx"
16 #include "MEDMEM_Support.hxx"
17 #include "MEDMEM_Field.hxx"
18 #include "MEDMEM_define.hxx"
21 #include "LocalTraceCollector.hxx"
22 #endif /* ifdef _DEBUG_*/
25 using namespace MEDMEM;
26 using namespace MED_EN;
28 void affiche_tableau(const double * myArray, int nb_lignes, int nb_colonnes)
30 cout << "Nombre de lignes : " << nb_lignes << endl;
31 cout << "Nombre de colonnes : " << nb_colonnes << endl;
32 cout << "Valeurs :" << endl;
34 for (int i=0; i<nb_lignes; i++) {
35 for (int j=0; j<nb_colonnes; j++)
36 cout << myArray[j*nb_lignes+i] << " ";
40 void affiche_coordinate(COORDINATE & myCoordinate, int _numberofNodes, int _spaceDimension)
42 cout << "- Système de coordonnées : " << myCoordinate.getCoordinatesSystem() << endl;
43 cout << "- Tableau des coordonnées : " << endl;
44 // affiche_medarray(* myCoordinate.getCoordinatePtr());
45 affiche_tableau(myCoordinate.getCoordinates(MED_NO_INTERLACE),_numberofNodes,_spaceDimension);
46 //on récupère les dimensions
47 // int _spaceDimension = (int) myCoordinate.getCoordinatePtr()->getLeadingValue();
48 //int _numberofNodes = (int) myCoordinate.getCoordinatePtr()->getLengthValue();
49 cout << "- Nom des coordonnées : " << endl;
50 for (int i=1; i<=_spaceDimension; i++)
51 cout << i << " " << myCoordinate.getCoordinateName(i) << endl;
52 // cout<<myCoordinate.getCoordinatesNames()<<endl;
53 cout << "- Unité des coordonnées : " << endl;
54 for (int i=1; i<=_spaceDimension; i++)
55 cout << i << " " << myCoordinate.getCoordinateUnit(i) << endl;
56 cout << "- Indices des noeuds : " << endl;
57 // cout<<myCoordinate.getNodesNumbers()<<endl;
58 for (int i=0; i<_numberofNodes; i++)
59 cout << i << " " << myCoordinate.getNodesNumbers()[i] << endl;
63 int main (int argc, char ** argv) {
65 LocalTraceCollector::instance();
66 #endif /* ifdef _DEBUG_*/
69 if ((argc !=3) && (argc != 4)) {
70 cerr << "Usage : " << argv[0]
71 << " filename meshname fieldname" << endl << endl;
75 const med_int numberofNodes = 5;
76 const med_int spaceDimension = 3;
77 const medModeSwitch mode = MED_FULL_INTERLACE;
79 //construction tableau MEDARRAY des coordonnées
80 MEDARRAY<double> * myMedArray = new MEDARRAY<double>(spaceDimension,numberofNodes,mode);
81 for (med_int i=1; i<=myMedArray->getLengthValue(); i++) {
82 for (med_int j=1; j<=myMedArray->getLeadingValue(); j++)
83 myMedArray->setIJ(i,j,(double) random());
86 //construction noms des coordonnées
87 string * myCoordinatesNames = new string[spaceDimension];
88 if (spaceDimension >= 1) myCoordinatesNames[0] = "x";
89 if (spaceDimension >= 2) myCoordinatesNames[1] = "y";
90 if (spaceDimension >= 3) myCoordinatesNames[2] = "z";
92 //construction unités des coordonnées
93 string * myCoordinatesUnits = new string[spaceDimension];
94 if (spaceDimension >= 1) myCoordinatesUnits[0] = "m";
95 if (spaceDimension >= 2) myCoordinatesUnits[1] = "m";
96 if (spaceDimension >= 3) myCoordinatesUnits[2] = "m";
98 //construction des indices des noeuds
99 int * myNodeNumber = new int[numberofNodes];
100 for (int i=0; i<numberofNodes; i++)
101 myNodeNumber[i]=numberofNodes-i-1;
103 //construction de l'objet COORDINATE
104 COORDINATE * myCoordinate = new COORDINATE();
105 myCoordinate->setCoordinates(myMedArray);
106 myCoordinate->setCoordinatesNames(myCoordinatesNames);
107 myCoordinate->setCoordinatesUnits(myCoordinatesUnits);
108 myCoordinate->setNodesNumbers(myNodeNumber);
110 // myCoordinate->setCoordinatesNames((string *)NULL);
111 // myCoordinate->setNodesNumbers((int *) NULL);
114 delete[] myCoordinatesNames ;
115 delete[] myCoordinatesUnits ;
116 delete[] myNodeNumber ;
118 affiche_coordinate(* myCoordinate,numberofNodes,spaceDimension);
119 COORDINATE * myCoordinate2 = new COORDINATE(* myCoordinate);
120 delete myCoordinate ;
122 affiche_coordinate(* myCoordinate2,numberofNodes,spaceDimension);
123 delete myCoordinate2 ;