12 #include "MEDMEM_Field.hxx"
13 #include "MEDMEM_Mesh.hxx"
15 #include "MEDMEM_Family.hxx"
16 #include "MEDMEM_Group.hxx"
17 #include "MEDMEM_Connectivity.hxx"
18 #include "MEDMEM_CellModel.hxx"
20 //update Families with content list
21 //int family_count(int family_number, int count, int * entities_number, int * entities_list) ;
23 // ------- Drivers Management Part
25 // MESH::INSTANCE_DE<MED_MESH_RDONLY_DRIVER> MESH::inst_med_rdonly ;
26 //const MESH::INSTANCE * const MESH::instances[] = { &MESH::inst_med_rdonly , &MESH::inst_med_rdwr } ;
28 MESH::INSTANCE_DE<MED_MESH_RDWR_DRIVER> MESH::inst_med ;
29 const MESH::INSTANCE * const MESH::instances[] = { &MESH::inst_med } ;
31 /*! Add a MESH driver of type (MED_DRIVER, ....) associated with file <fileName>. The meshname used in the file
32 is <driverName>. addDriver returns an int handler. */
33 int MESH::addDriver(driverTypes driverType,
34 const string & fileName/*="Default File Name.med"*/,const string & driverName/*="Default Mesh Name"*/) {
36 const char * LOC = "MESH::addDriver(driverTypes driverType, const string & fileName=\"Default File Name.med\",const string & driverName=\"Default Mesh Name\") : ";
43 driver = instances[driverType]->run(fileName, this) ;
44 _drivers.push_back(driver);
45 current = _drivers.size()-1;
47 _drivers[current]->setMeshName(driverName);
54 /*! Add an existing MESH driver. */
55 int MESH::addDriver(MED_MESH_DRIVER & driver) {
56 const char * LOC = "MESH::addDriver(GENDRIVER &) : ";
59 // A faire : Vérifier que le driver est de type MESH.
60 _drivers.push_back(&driver);
61 return _drivers.size()-1;
66 /*! Remove an existing MESH driver. */
67 void MESH::rmDriver (int index/*=0*/) {
68 const char * LOC = "MESH::rmDriver (int index=0): ";
71 if ( _drivers[index] ) {
72 //_drivers.erase(&_drivers[index]);
77 throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
78 << "The index given is invalid, index must be between 0 and |"
87 // ------ End of Drivers Management Part
92 string _name = "NOT DEFINED"; // A POSITIONNER EN FCT DES IOS ?
94 _numberOfMEDNodeFamily = MED_INVALID;
95 _MEDArrayNodeFamily = (int * ) NULL; // SOLUTION TEMPORAIRE
96 _numberOfMEDCellFamily = (int * ) NULL;
97 _numberOfMEDFaceFamily = (int * ) NULL;
98 _numberOfMEDEdgeFamily = (int * ) NULL;
99 _MEDArrayCellFamily = (int **) NULL; // SOLUTION TEMPORAIRE
100 _MEDArrayFaceFamily = (int **) NULL; // SOLUTION TEMPORAIRE
101 _MEDArrayEdgeFamily = (int **) NULL; // SOLUTION TEMPORAIRE
103 COORDINATE * _coordinate = (COORDINATE *) NULL;
104 CONNECTIVITY * _connectivity = (CONNECTIVITY *) NULL;
106 _spaceDimension = MED_INVALID; // 0 ?!?
107 _meshDimension = MED_INVALID;
108 _numberOfNodes = MED_INVALID;
110 _numberOfNodesFamilies = 0; // MED_INVALID ?!?
111 _numberOfCellsFamilies = 0;
112 _numberOfFacesFamilies = 0;
113 _numberOfEdgesFamilies = 0;
115 _numberOfNodesGroups = 0; // MED_INVALID ?!?
116 _numberOfCellsGroups = 0;
117 _numberOfFacesGroups = 0;
118 _numberOfEdgesGroups = 0;
122 /*! Create an empty MESH. */
127 MESH::MESH(const MESH &m)
129 // VERIFIER QUE TS LES OPERATEURS DE RECOPIE DES ATTRIBUTS
136 if ( _MEDArrayNodeFamily != (int * ) NULL) delete [] _MEDArrayNodeFamily; // SOLUTION TEMPORAIRE
137 if ( _numberOfMEDCellFamily != (int * ) NULL) delete [] _numberOfMEDCellFamily;
138 if ( _numberOfMEDFaceFamily != (int * ) NULL) delete [] _numberOfMEDFaceFamily;
139 if ( _numberOfMEDEdgeFamily != (int * ) NULL) delete [] _numberOfMEDEdgeFamily;
140 // IL FAUT FAIRE UNE BOUCLE DE DESALLOCATION
141 if ( _MEDArrayCellFamily != (int **) NULL) delete [] _MEDArrayCellFamily; // SOLUTION TEMPORAIRE
142 if ( _MEDArrayFaceFamily != (int **) NULL) delete [] _MEDArrayFaceFamily; // SOLUTION TEMPORAIRE
143 if ( _MEDArrayEdgeFamily != (int **) NULL) delete [] _MEDArrayEdgeFamily; // SOLUTION TEMPORAIRE
145 if (_coordinate != NULL) delete _coordinate ;
146 if (_connectivity != NULL) delete _connectivity ;
148 size = _familyNode.size() ;
149 for (int i=0;i<size;i++)
150 delete _familyNode[i] ;
151 size = _familyCell.size() ;
152 for (int i=0;i<size;i++)
153 delete _familyCell[i] ;
154 size = _familyFace.size() ;
155 for (int i=0;i<size;i++)
156 delete _familyFace[i] ;
157 size = _familyEdge.size() ;
158 for (int i=0;i<size;i++)
159 delete _familyEdge[i] ;
160 size = _groupNode.size() ;
161 for (int i=0;i<size;i++)
162 delete _groupNode[i] ;
163 size = _groupCell.size() ;
164 for (int i=0;i<size;i++)
165 delete _groupCell[i] ;
166 size = _groupFace.size() ;
167 for (int i=0;i<size;i++)
168 delete _groupFace[i] ;
169 size = _groupEdge.size() ;
170 for (int i=0;i<size;i++)
171 delete _groupEdge[i] ;
175 MESH & MESH::operator=(const MESH &m)
180 // ATTENTION CET OPERATEUR DE RECOPIE EST DANGEREUX POUR LES
181 // POINTEURS : ex : nodal_connectivity ???? EXPRES ????
182 // _drivers = m._drivers;
184 // space_dimension=m.space_dimension;
185 // mesh_dimension=m.mesh_dimension;
187 // nodes_count=m.nodes_count;
188 // coordinates=m.coordinates;
189 // coordinates_name=m.coordinates_name ;
190 // coordinates_unit=m.coordinates_unit ;
191 // nodes_numbers=m.nodes_numbers ;
193 // cells_types_count=m.cells_types_count;
194 // cells_type=m.cells_type;
195 // cells_count=m.cells_count;
196 // nodal_connectivity=m.nodal_connectivity;
198 // nodes_families_count=m.nodes_families_count;
199 // nodes_Families=m.nodes_Families;
201 // cells_families_count=m.cells_families_count;
202 // cells_Families=m.cells_Families;
204 // maximum_cell_number_by_node = m.maximum_cell_number_by_node;
205 // if (maximum_cell_number_by_node > 0)
207 // reverse_nodal_connectivity = m.reverse_nodal_connectivity;
208 // reverse_nodal_connectivity_index = m.reverse_nodal_connectivity_index ;
213 /*! Create a MESH object using a MESH driver of type (MED_DRIVER, ....) associated with file <fileName>.
214 The meshname <driverName> must already exists in the file.*/
215 MESH::MESH(driverTypes driverType, const string & fileName/*=""*/, const string & driverName/*=""*/) {
216 const char * LOC ="MESH::MESH(driverTypes driverType, const string & fileName="", const string & driverName="") : ";
224 current = addDriver(driverType,fileName,driverName);
225 switch(_drivers[current]->getAccessMode() ) {
227 MESSAGE("MESH::MESH(driverTypes driverType, .....) : driverType must have a MED_RDWR accessMode");
233 _drivers[current]->open();
234 _drivers[current]->read();
235 _drivers[current]->close();
240 // Node MESH::Donne_Barycentre(const Maille &m) const
242 // Node N=node[m[0]];
243 // for (int i=1;i<m.donne_nbr_sommets();i++) N=N+node[m[i]];
244 // N=N*(1.0/m.donne_nbr_sommets());
248 ostream & operator<<(ostream &os, MESH &myMesh)
250 // int space_dimension = myMesh.get_space_dimension();
251 // os << "Space dimension "<< space_dimension << endl ;
252 // int nodes_count = myMesh.get_nodes_count() ;
253 // os << "Nodes count : "<< nodes_count << endl ;
254 // double * coord = myMesh.get_coordinates();
255 // os << "Coordinates :" << endl ;
256 // string * coordinate_name = myMesh.get_coordinates_name() ;
257 // string * coordinate_unit = myMesh.get_coordinates_unit() ;
259 // for(int i=0;i<space_dimension;i++) {
260 // os << " - name "<< i << " : "<< coordinate_name[i] << endl;
261 // os << " - unit "<< i << " : "<< coordinate_unit[i] << endl ;
264 // for(int j=0;j<nodes_count;j++) {
265 // for(int i=0;i<space_dimension;i++)
266 // os << " coord["<< i <<","<< j << "] : "<< coord[j+i*nodes_count] <<" ," ;
270 // int cells_types_count = myMesh.get_cells_types_count() ;
271 // os << "cells_types_count : " << cells_types_count << endl ;
272 // for(int i=1;i<cells_types_count;i++) {
273 // os << "cell type : " << myMesh.get_cells_type(i) << endl ;
274 // os << " - cells count : " << myMesh.get_cells_count(i) << endl ;
275 // int *conectivity = myMesh.get_nodal_connectivity(i) ;
276 // int nodes_cells_count = myMesh.get_cells_type(i).get_nodes_count() ;
277 // for(int j=0;j<myMesh.get_cells_count(i);j++) {
279 // for(int k=0;k<nodes_cells_count;k++)
280 // os <<conectivity[j*nodes_cells_count+k] << " " ;
285 // int nodes_families_count = myMesh.get_nodes_families_count() ;
286 // os << "nodes_families_count : " << nodes_families_count << endl ;
287 // vector<FamilyNode*> nodes_Families = myMesh.get_nodes_Families() ;
288 // for(int i=0;i<nodes_families_count;i++)
289 // os << " - Famile "<<i<<" : "<< (FamilyNode &) (*nodes_Families[i]) << endl ;
292 // int cells_families_count = myMesh.get_cells_families_count() ;
293 // os << "cells_families_count : " << cells_families_count << endl ;
294 // vector<FamilyCell*> cells_Families = myMesh.get_cells_Families() ;
295 // for(int i=0;i<cells_families_count;i++)
296 // os << " - Famile "<<i<<" : "<< (*cells_Families[i]) << endl ;
303 Get global number of element which have same connectivity than connectivity argument.
305 It do not take care of connectivity order (3,4,7,10 is same as 7,3,10,4).
307 Return -1 if not found.
309 int MESH::getElementNumber(medConnectivity ConnectivityType, medEntityMesh Entity, medGeometryElement Type, int * connectivity)
311 const char* LOC="MESH::getElementNumber " ;
314 int numberOfValue ; // size of connectivity array
315 CELLMODEL myType(Type) ;
316 if (ConnectivityType==MED_DESCENDING)
317 numberOfValue = myType.getNumberOfConstituents(1) ; // faces (3D) or edges (2D)
319 numberOfValue = myType.getNumberOfNodes() ; // nodes
321 int * myReverseConnectivityValue = getReverseConnectivity(ConnectivityType,Entity) ;
322 int * myReverseConnectivityIndex = getReverseConnectivityIndex(ConnectivityType,Entity) ;
324 // First node or face/edge
325 int indexBegin = myReverseConnectivityIndex[connectivity[0]-1] ;
326 int indexEnd = myReverseConnectivityIndex[connectivity[0]] ;
328 // list to put cells numbers
329 list<int> cellsList ;
330 list<int>::iterator itList ;
331 for (int i=indexBegin; i<indexEnd; i++)
332 cellsList.push_back(myReverseConnectivityValue[i-1]) ;
334 // Foreach node or face/edge in cell, we search cells which are in common.
335 // At the end, we must have only one !
337 for (int i=1; i<numberOfValue; i++) {
338 int connectivity_i = connectivity[i] ;
339 for (itList=cellsList.begin();itList!=cellsList.end();itList++) {
341 for (int j=myReverseConnectivityIndex[connectivity_i-1]; j<myReverseConnectivityIndex[connectivity_i]; j++) {
342 if ((*itList)==myReverseConnectivityValue[j-1]) {
348 itList=cellsList.erase(itList);
349 itList--; // well : rigth if itList = cellsList.begin() ??
354 if (cellsList.size()>1) // we have more than one cell
355 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Found more than one element !")) ;
357 if (cellsList.size()==0)
362 return cellsList.front() ;
367 Return a support which reference all elements on the boundary of mesh.
369 For instance, we could get only face in 3D and edge in 2D.
371 SUPPORT * MESH::getBoundaryElements(medEntityMesh Entity) throw (MEDEXCEPTION)
373 const char * LOC = "MESH::getBoundaryElements : " ;
376 // actually we could only get face (in 3D) and edge (in 2D)
377 if (_spaceDimension == 3)
378 if (Entity != MED_FACE)
379 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined in 3D mesh for entity "<<Entity<<" !"));
380 if (_spaceDimension == 2)
381 if (Entity != MED_EDGE)
382 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined in 2D mesh for entity "<<Entity<<" !"));
385 SUPPORT * mySupport = new SUPPORT(this,"Boundary",Entity);
386 //mySupport.setDescription("boundary of type ...");
387 mySupport->setAll(false);
390 int * myConnectivityValue = getReverseConnectivity(MED_DESCENDING) ;
391 int * myConnectivityIndex = getReverseConnectivityIndex(MED_DESCENDING) ;
392 int numberOf = getNumberOfElements(Entity,MED_ALL_ELEMENTS) ;
393 list<int> myElementsList ;
396 for (int i=0 ; i<numberOf; i++)
397 if (myConnectivityValue[myConnectivityIndex[i]] == 0) {
399 myElementsList.push_back(i+1) ;
403 // Well, we must know how many geometric type we have found
404 int * myListArray = new int[size] ;
406 list<int>::iterator myElementsListIt ;
407 for (myElementsListIt=myElementsList.begin();myElementsListIt!=myElementsList.end();myElementsListIt++) {
408 myListArray[id]=(*myElementsListIt) ;
410 SCRUTE(myListArray[id]);
414 int numberOfGeometricType ;
415 medGeometryElement* geometricType ;
416 int * numberOfGaussPoint ;
417 int * geometricTypeNumber ;
418 int * numberOfEntities ;
419 MEDSKYLINEARRAY * mySkyLineArray = new MEDSKYLINEARRAY() ;
420 int * mySkyLineArrayIndex ;
422 int numberOfType = getNumberOfTypes(Entity) ;
423 if (numberOfType == 1) { // wonderfull : it's easy !
424 numberOfGeometricType = 1 ;
425 geometricType = new medGeometryElement[1] ;
426 medGeometryElement * allType = getTypes(Entity);
427 geometricType[0] = allType[0] ;
428 numberOfGaussPoint = new int[1] ;
429 numberOfGaussPoint[0] = 1 ;
430 geometricTypeNumber = new int[1] ; // not use, but initialized to nothing
431 geometricTypeNumber[0] = 0 ;
432 numberOfEntities = new int[1] ;
433 numberOfEntities[0] = size ;
434 mySkyLineArrayIndex = new int[2] ;
435 mySkyLineArrayIndex[0]=1 ;
436 mySkyLineArrayIndex[1]=1+size ;
439 map<medGeometryElement,int> theType ;
440 for (myElementsListIt=myElementsList.begin();myElementsListIt!=myElementsList.end();myElementsListIt++) {
441 medGeometryElement myType = getElementType(Entity,*myElementsListIt) ;
442 if (theType.find(myType) != theType.end() )
447 numberOfGeometricType = theType.size() ;
448 geometricType = new medGeometryElement[numberOfGeometricType] ;
449 medGeometryElement * allType = getTypes(Entity);
450 numberOfGaussPoint = new int[numberOfGeometricType] ;
451 geometricTypeNumber = new int[numberOfGeometricType] ; // not use, but initialized to nothing
452 numberOfEntities = new int[numberOfGeometricType] ;
453 mySkyLineArrayIndex = new int[numberOfGeometricType+1] ;
455 mySkyLineArrayIndex[0]=1 ;
456 map<medGeometryElement,int>::iterator theTypeIt ;
457 for (theTypeIt=theType.begin();theTypeIt!=theType.end();theTypeIt++) {
458 geometricType[index] = (*theTypeIt).first ;
459 numberOfGaussPoint[index] = 1 ;
460 geometricTypeNumber[index] = 0 ;
461 numberOfEntities[index] = (*theTypeIt).second ;
462 mySkyLineArrayIndex[index+1]=mySkyLineArrayIndex[index]+numberOfEntities[index] ;
466 mySkyLineArray->setMEDSKYLINEARRAY(numberOfGeometricType,size,mySkyLineArrayIndex,myListArray) ;
468 mySupport->setNumberOfGeometricType(numberOfGeometricType) ;
469 mySupport->setGeometricType(geometricType) ;
470 mySupport->setNumberOfGaussPoint(numberOfGaussPoint) ;
471 // mySupport->setGeometricTypeNumber(geometricTypeNumber) ;
472 mySupport->setNumberOfEntities(numberOfEntities) ;
473 mySupport->setTotalNumberOfEntities(size) ;
474 mySupport->setNumber(mySkyLineArray) ;
480 FIELD<double>* MESH::getVolume(const SUPPORT * Support) throw (MEDEXCEPTION)
482 // Support must be on 3D elements
483 MESSAGE("MESH::getVolume(SUPPORT*)");
485 // Make sure that the MESH class is the same as the MESH class attribut
486 // in the class Support
487 MESH* myMesh = Support->getMesh();
489 throw MEDEXCEPTION("MESH::getVolume(SUPPORT*) no compatibility between *this and SUPPORT::_mesh !");
491 int dim_space = getSpaceDimension();
492 medEntityMesh support_entity = Support->getEntity();
493 bool onAll = Support->isOnAllElements();
495 int nb_type, length_values;
496 medGeometryElement* types;
498 // !!!! WARNING : use of nodal global numbering in the mesh !!!!
499 int* global_connectivity;
503 nb_type = myMesh->getNumberOfTypes(support_entity);
504 length_values = getNumberOfElements(support_entity,MED_ALL_ELEMENTS);
505 types = getTypes(support_entity);
509 nb_type = Support->getNumberOfTypes();
510 length_values = Support->getNumberOfElements(MED_ALL_ELEMENTS);
511 types = Support->getTypes();
515 FIELD<double>* Volume;
517 Volume = new FIELD<double>::FIELD(Support,1);
518 // double *volume = new double [length_values];
519 Volume->setName("VOLUME");
520 Volume->setDescription("cells volume");
521 Volume->setComponentName(1,"volume");
522 Volume->setComponentDescription(1,"desc-comp");
524 /* string MEDComponentUnit(MED_TAILLE_PNOM,' ');*/
526 string MEDComponentUnit = myMesh->getCoordinatesUnits()[0]+"*"+myMesh->getCoordinatesUnits()[1]+"*"+myMesh->getCoordinatesUnits()[2];
528 Volume->setMEDComponentUnit(1,MEDComponentUnit);
530 Volume->setValueType(MED_REEL64);
532 Volume->setIterationNumber(0);
533 Volume->setOrderNumber(0);
534 Volume->setTime(0.0);
536 double *volume = Volume->getValue(MED_FULL_INTERLACE);
539 const double * coord = getCoordinates(MED_FULL_INTERLACE);
541 for (int i=0;i<nb_type;i++)
543 medGeometryElement type = types[i] ;
548 nb_entity_type = getNumberOfElements(support_entity,type);
549 global_connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,type);
553 nb_entity_type = Support->getNumberOfElements(type);
555 int * supp_number = Support->getNumber(type);
556 int * connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,MED_ALL_ELEMENTS);
557 int * connectivityIndex = getConnectivityIndex(MED_NODAL,support_entity);
558 global_connectivity = new int[(type%100)*nb_entity_type];
560 for (int k_type = 0; k_type<nb_entity_type; k_type++) {
561 for (int j_ent = 0; j_ent<(type%100); j_ent++) {
562 global_connectivity[k_type*(type%100)+j_ent] = connectivity[connectivityIndex[supp_number[k_type]-1]+j_ent-1];
569 case MED_TETRA4 : case MED_TETRA10 :
571 for (int tetra=0;tetra<nb_entity_type;tetra++)
573 int tetra_index = (type%100)*tetra;
575 int N1 = global_connectivity[tetra_index]-1;
576 int N2 = global_connectivity[tetra_index+1]-1;
577 int N3 = global_connectivity[tetra_index+2]-1;
578 int N4 = global_connectivity[tetra_index+3]-1;
580 double x1 = coord[dim_space*N1];
581 double x2 = coord[dim_space*N2];
582 double x3 = coord[dim_space*N3];
583 double x4 = coord[dim_space*N4];
585 double y1 = coord[dim_space*N1+1];
586 double y2 = coord[dim_space*N2+1];
587 double y3 = coord[dim_space*N3+1];
588 double y4 = coord[dim_space*N4+1];
590 double z1 = coord[dim_space*N1+2];
591 double z2 = coord[dim_space*N2+2];
592 double z3 = coord[dim_space*N3+2];
593 double z4 = coord[dim_space*N4+2];
595 xvolume = ((x3-x1)*((y2-y1)*(z4-z1) - (z2-z1)*(y4-y1)) -
596 (x2-x1)*((y3-y1)*(z4-z1) - (z3-z1)*(y4-y1)) +
597 (x4-x1)*((y3-y1)*(z2-z1) - (z3-z1)*(y2-y1)))/6.0;
599 volume[index] = xvolume ;
604 case MED_PYRA5 : case MED_PYRA13 :
606 for (int pyra=0;pyra<nb_entity_type;pyra++)
608 int pyra_index = (type%100)*pyra;
610 int N1 = global_connectivity[pyra_index]-1;
611 int N2 = global_connectivity[pyra_index+1]-1;
612 int N3 = global_connectivity[pyra_index+2]-1;
613 int N4 = global_connectivity[pyra_index+3]-1;
614 int N5 = global_connectivity[pyra_index+4]-1;
616 double x1 = coord[dim_space*N1];
617 double x2 = coord[dim_space*N2];
618 double x3 = coord[dim_space*N3];
619 double x4 = coord[dim_space*N4];
620 double x5 = coord[dim_space*N5];
622 double y1 = coord[dim_space*N1+1];
623 double y2 = coord[dim_space*N2+1];
624 double y3 = coord[dim_space*N3+1];
625 double y4 = coord[dim_space*N4+1];
626 double y5 = coord[dim_space*N5+1];
628 double z1 = coord[dim_space*N1+2];
629 double z2 = coord[dim_space*N2+2];
630 double z3 = coord[dim_space*N3+2];
631 double z4 = coord[dim_space*N4+2];
632 double z5 = coord[dim_space*N5+2];
634 xvolume = (((x3-x1)*((y2-y1)*(z5-z1) - (z2-z1)*(y5-y1)) -
635 (x2-x1)*((y3-y1)*(z5-z1) - (z3-z1)*(y5-y1)) +
636 (x5-x1)*((y3-y1)*(z2-z1) - (z3-z1)*(y2-y1))) +
637 ((x4-x1)*((y3-y1)*(z5-z1) - (z3-z1)*(y5-y1)) -
638 (x3-x1)*((y4-y1)*(z5-z1) - (z4-z1)*(y5-y1)) +
639 (x5-x1)*((y4-y1)*(z3-z1) - (z4-z1)*(y3-y1)))
642 volume[index] = xvolume ;
647 case MED_PENTA6 : case MED_PENTA15 :
649 for (int penta=0;penta<nb_entity_type;penta++)
651 int penta_index = (type%100)*penta;
653 int N1 = global_connectivity[penta_index]-1;
654 int N2 = global_connectivity[penta_index+1]-1;
655 int N3 = global_connectivity[penta_index+2]-1;
656 int N4 = global_connectivity[penta_index+3]-1;
657 int N5 = global_connectivity[penta_index+4]-1;
658 int N6 = global_connectivity[penta_index+5]-1;
660 double x1 = coord[dim_space*N1];
661 double x2 = coord[dim_space*N2];
662 double x3 = coord[dim_space*N3];
663 double x4 = coord[dim_space*N4];
664 double x5 = coord[dim_space*N5];
665 double x6 = coord[dim_space*N6];
667 double y1 = coord[dim_space*N1+1];
668 double y2 = coord[dim_space*N2+1];
669 double y3 = coord[dim_space*N3+1];
670 double y4 = coord[dim_space*N4+1];
671 double y5 = coord[dim_space*N5+1];
672 double y6 = coord[dim_space*N6+1];
674 double z1 = coord[dim_space*N1+2];
675 double z2 = coord[dim_space*N2+2];
676 double z3 = coord[dim_space*N3+2];
677 double z4 = coord[dim_space*N4+2];
678 double z5 = coord[dim_space*N5+2];
679 double z6 = coord[dim_space*N6+2];
681 double a1 = (x2-x3)/2.0, a2 = (y2-y3)/2.0, a3 = (z2-z3)/2.0;
682 double b1 = (x5-x6)/2.0, b2 = (y5-y6)/2.0, b3 = (z5-z6)/2.0;
683 double c1 = (x4-x1)/2.0, c2 = (y4-y1)/2.0, c3 = (z4-z1)/2.0;
684 double d1 = (x5-x2)/2.0, d2 = (y5-y2)/2.0, d3 = (z5-z2)/2.0;
685 double e1 = (x6-x3)/2.0, e2 = (y6-y3)/2.0, e3 = (z6-z3)/2.0;
686 double f1 = (x1-x3)/2.0, f2 = (y1-y3)/2.0, f3 = (z1-z3)/2.0;
687 double h1 = (x4-x6)/2.0, h2 = (y4-y6)/2.0, h3 = (z4-z6)/2.0;
689 double A = a1*c2*f3 - a1*c3*f2 - a2*c1*f3 + a2*c3*f1 +
691 double B = b1*c2*h3 - b1*c3*h2 - b2*c1*h3 + b2*c3*h1 +
693 double C = (a1*c2*h3 + b1*c2*f3) - (a1*c3*h2 + b1*c3*f2) -
694 (a2*c1*h3 + b2*c1*f3) + (a2*c3*h1 + b2*c3*f1) +
695 (a3*c1*h2 + b3*c1*f2) - (a3*c2*h1 + b3*c2*f1);
696 double D = a1*d2*f3 - a1*d3*f2 - a2*d1*f3 + a2*d3*f1 +
698 double E = b1*d2*h3 - b1*d3*h2 - b2*d1*h3 + b2*d3*h1 +
700 double F = (a1*d2*h3 + b1*d2*f3) - (a1*d3*h2 + b1*d3*f2) -
701 (a2*d1*h3 + b2*d1*f3) + (a2*d3*h1 + b2*d3*f1) +
702 (a3*d1*h2 + b3*d1*f2) - (a3*d2*h1 + b3*d2*f1);
703 double G = a1*e2*f3 - a1*e3*f2 - a2*e1*f3 + a2*e3*f1 +
705 double H = b1*e2*h3 - b1*e3*h2 - b2*e1*h3 + b2*e3*h1 +
707 double P = (a1*e2*h3 + b1*e2*f3) - (a1*e3*h2 + b1*e3*f2) -
708 (a2*e1*h3 + b2*e1*f3) + (a2*e3*h1 + b2*e3*f1) +
709 (a3*e1*h2 + b3*e1*f2) - (a3*e2*h1 + b3*e2*f1);
711 xvolume = -2.0*(2.0*(A + B + D + E + G + H) + C + F + P)/9.0;
713 volume[index] = xvolume ;
718 case MED_HEXA8 : case MED_HEXA20 :
720 for (int hexa=0;hexa<nb_entity_type;hexa++)
722 int hexa_index = (type%100)*hexa;
724 int N1 = global_connectivity[hexa_index]-1;
725 int N2 = global_connectivity[hexa_index+1]-1;
726 int N3 = global_connectivity[hexa_index+2]-1;
727 int N4 = global_connectivity[hexa_index+3]-1;
728 int N5 = global_connectivity[hexa_index+4]-1;
729 int N6 = global_connectivity[hexa_index+5]-1;
730 int N7 = global_connectivity[hexa_index+6]-1;
731 int N8 = global_connectivity[hexa_index+7]-1;
733 double x1 = coord[dim_space*N1];
734 double x2 = coord[dim_space*N2];
735 double x3 = coord[dim_space*N3];
736 double x4 = coord[dim_space*N4];
737 double x5 = coord[dim_space*N5];
738 double x6 = coord[dim_space*N6];
739 double x7 = coord[dim_space*N7];
740 double x8 = coord[dim_space*N8];
742 double y1 = coord[dim_space*N1+1];
743 double y2 = coord[dim_space*N2+1];
744 double y3 = coord[dim_space*N3+1];
745 double y4 = coord[dim_space*N4+1];
746 double y5 = coord[dim_space*N5+1];
747 double y6 = coord[dim_space*N6+1];
748 double y7 = coord[dim_space*N7+1];
749 double y8 = coord[dim_space*N8+1];
751 double z1 = coord[dim_space*N1+2];
752 double z2 = coord[dim_space*N2+2];
753 double z3 = coord[dim_space*N3+2];
754 double z4 = coord[dim_space*N4+2];
755 double z5 = coord[dim_space*N5+2];
756 double z6 = coord[dim_space*N6+2];
757 double z7 = coord[dim_space*N7+2];
758 double z8 = coord[dim_space*N8+2];
760 double a1 = (x3-x4)/8.0, a2 = (y3-y4)/8.0, a3 = (z3-z4)/8.0;
761 double b1 = (x2-x1)/8.0, b2 = (y2-y1)/8.0, b3 = (z2-z1)/8.0;
762 double c1 = (x7-x8)/8.0, c2 = (y7-y8)/8.0, c3 = (z7-z8)/8.0;
763 double d1 = (x6-x5)/8.0, d2 = (y6-y5)/8.0, d3 = (z6-z5)/8.0;
764 double e1 = (x3-x2)/8.0, e2 = (y3-y2)/8.0, e3 = (z3-z2)/8.0;
765 double f1 = (x4-x1)/8.0, f2 = (y4-y1)/8.0, f3 = (z4-z1)/8.0;
766 double h1 = (x7-x6)/8.0, h2 = (y7-y6)/8.0, h3 = (z7-z6)/8.0;
767 double p1 = (x8-x5)/8.0, p2 = (y8-y5)/8.0, p3 = (z8-z5)/8.0;
768 double q1 = (x3-x7)/8.0, q2 = (y3-y7)/8.0, q3 = (z3-z7)/8.0;
769 double r1 = (x4-x8)/8.0, r2 = (y4-y8)/8.0, r3 = (z4-z8)/8.0;
770 double s1 = (x2-x6)/8.0, s2 = (y2-y6)/8.0, s3 = (z2-z6)/8.0;
771 double t1 = (x1-x5)/8.0, t2 = (y1-y5)/8.0, t3 = (z1-z5)/8.0;
773 double A = a1*e2*q3 - a1*e3*q2 - a2*e1*q3 + a2*e3*q1 +
775 double B = c1*h2*q3 - c1*h3*q2 - c2*h1*q3 + c2*h3*q1 +
777 double C = (a1*h2 + c1*e2)*q3 - (a1*h3 + c1*e3)*q2 -
778 (a2*h1 + c2*e1)*q3 + (a2*h3 + c2*e3)*q1 +
779 (a3*h1 + c3*e1)*q2 - (a3*h2 + c3*e2)*q1;
780 double D = b1*e2*s3 - b1*e3*s2 - b2*e1*s3 + b2*e3*s1 +
782 double E = d1*h2*s3 - d1*h3*s2 - d2*h1*s3 + d2*h3*s1 +
784 double F = (b1*h2 + d1*e2)*s3 - (b1*h3 + d1*e3)*s2 -
785 (b2*h1 + d2*e1)*s3 + (b2*h3 + d2*e3)*s1 +
786 (b3*h1 + d3*e1)*s2 - (b3*h2 + d3*e2)*s1;
787 double G = (a1*e2*s3 + b1*e2*q3) - (a1*e3*s2 + b1*e3*q2) -
788 (a2*e1*s3 + b2*e1*q3) + (a2*e3*s1 + b2*e3*q1) +
789 (a3*e1*s2 + b3*e1*q2) - (a3*e2*s1 + b3*e2*q1);
790 double H = (c1*h2*s3 + d1*h2*q3) - (c1*h3*s2 + d1*h3*q2) -
791 (c2*h1*s3 + d2*h1*q3) + (c2*h3*s1 + d2*h3*q1) +
792 (c3*h1*s2 + d3*h1*q2) - (c3*h2*s1 + d3*h2*q1);
793 double I = ((a1*h2 + c1*e2)*s3 + (b1*h2 + d1*e2)*q3) -
794 ((a1*h3 + c1*e3)*s2 + (b1*h3 + d1*e3)*q2) -
795 ((a2*h1 + c2*e1)*s3 + (b2*h1 + d2*e1)*q3) +
796 ((a2*h3 + c2*e3)*s1 + (b2*h3 + d2*e3)*q1) +
797 ((a3*h1 + c3*e1)*s2 + (b3*h1 + d3*e1)*q2) -
798 ((a3*h2 + c3*e2)*s1 + (b3*h2 + d3*e2)*q1);
799 double J = a1*f2*r3 - a1*f3*r2 - a2*f1*r3 + a2*f3*r1 +
801 double K = c1*p2*r3 - c1*p3*r2 - c2*p1*r3 + c2*p3*r1 +
803 double L = (a1*p2 + c1*f2)*r3 - (a1*p3 + c1*f3)*r2 -
804 (a2*p1 + c2*f1)*r3 + (a2*p3 + c2*f3)*r1 +
805 (a3*p1 + c3*f1)*r2 - (a3*p2 + c3*f2)*r1;
806 double M = b1*f2*t3 - b1*f3*t2 - b2*f1*t3 + b2*f3*t1 +
808 double N = d1*p2*t3 - d1*p3*t2 - d2*p1*t3 + d2*p3*t1 +
810 double O = (b1*p2 + d1*f2)*t3 - (b1*p3 + d1*f3)*t2 -
811 (b2*p1 + d2*f1)*t3 + (b2*p3 + d2*f3)*t1 +
812 (b3*p1 + d3*f1)*t2 - (b3*p2 + d3*f2)*t1;
813 double P = (a1*f2*t3 + b1*f2*r3) - (a1*f3*t2 + b1*f3*r2) -
814 (a2*f1*t3 + b2*f1*r3) + (a2*f3*t1 + b2*f3*r1) +
815 (a3*f1*t2 + b3*f1*r2) - (a3*f2*t1 + b3*f2*r1);
816 double Q = (c1*p2*t3 + d1*p2*r3) - (c1*p3*t2 + d1*p3*r2) -
817 (c2*p1*t3 + d2*p1*r3) + (c2*p3*t1 + d2*p3*r1) +
818 (c3*p1*t2 + d3*p1*r2) - (c3*p2*t1 + d3*p2*r1);
819 double R = ((a1*p2 + c1*f2)*t3 + (b1*p2 + d1*f2)*r3) -
820 ((a1*p3 + c1*f3)*t2 + (b1*p3 + d1*f3)*r2) -
821 ((a2*p1 + c2*f1)*t3 + (b2*p1 + d2*f1)*r3) +
822 ((a2*p3 + c2*f3)*t1 + (b2*p3 + d2*f3)*r1) +
823 ((a3*p1 + c3*f1)*t2 + (b3*p1 + d3*f1)*r2) -
824 ((a3*p2 + c3*f2)*t1 + (b3*p2 + d3*f2)*r1);
825 double S = (a1*e2*r3 + a1*f2*q3) - (a1*e3*r2 + a1*f3*q2) -
826 (a2*e1*r3 + a2*f1*q3) + (a2*e3*r1 + a2*f3*q1) +
827 (a3*e1*r2 + a3*f1*q2) - (a3*e2*r1 + a3*f2*q1);
828 double T = (c1*h2*r3 + c1*p2*q3) - (c1*h3*r2 + c1*p3*q2) -
829 (c2*h1*r3 + c2*p1*q3) + (c2*h3*r1 + c2*p3*q1) +
830 (c3*h1*r2 + c3*p1*q2) - (c3*h2*r1 + c3*p2*q1);
831 double U = ((a1*h2 + c1*e2)*r3 + (a1*p2 + c1*f2)*q3) -
832 ((a1*h3 + c1*e3)*r2 + (a1*p3 + c1*f3)*q2) -
833 ((a2*h1 + c2*e1)*r3 + (a2*p1 + c2*f1)*q3) +
834 ((a2*h3 + c2*e3)*r1 + (a2*p3 + c2*f3)*q1) +
835 ((a3*h1 + c3*e1)*r2 + (a3*p1 + c3*f1)*q2) -
836 ((a3*h2 + c3*e2)*r1 + (a3*p2 + c3*f2)*q1);
837 double V = (b1*e2*t3 + b1*f2*s3) - (b1*e3*t2 + b1*f3*s2) -
838 (b2*e1*t3 + b2*f1*s3) + (b2*e3*t1 + b2*f3*s1) +
839 (b3*e1*t2 + b3*f1*s2) - (b3*e2*t1 + b3*f2*s1);
840 double W = (d1*h2*t3 + d1*p2*s3) - (d1*h3*t2 + d1*p3*s2) -
841 (d2*h1*t3 + d2*p1*s3) + (d2*h3*t1 + d2*p3*s1) +
842 (d3*h1*t2 + d3*p1*s2) - (d3*h2*t1 + d3*p2*s1);
843 double X = ((b1*h2 + d1*e2)*t3 + (b1*p2 + d1*f2)*s3) -
844 ((b1*h3 + d1*e3)*t2 + (b1*p3 + d1*f3)*s2) -
845 ((b2*h1 + d2*e1)*t3 + (b2*p1 + d2*f1)*s3) +
846 ((b2*h3 + d2*e3)*t1 + (b2*p3 + d2*f3)*s1) +
847 ((b3*h1 + d3*e1)*t2 + (b3*p1 + d3*f1)*s2) -
848 ((b3*h2 + d3*e2)*t1 + (b3*p2 + d3*f2)*s1);
849 double Y = (a1*e2*t3 + a1*f2*s3 + b1*e2*r3 + b1*f2*q3) -
850 (a1*e3*t2 + a1*f3*s2 + b1*e3*r2 + b1*f3*q2) -
851 (a2*e1*t3 + a2*f1*s3 + b2*e1*r3 + b2*f1*q3) +
852 (a2*e3*t1 + a2*f3*s1 + b2*e3*r1 + b2*f3*q1) +
853 (a3*e1*t2 + a3*f1*s2 + b3*e1*r2 + b3*f1*q2) -
854 (a3*e2*t1 + a3*f2*s1 + b3*e2*r1 + b3*f2*q1);
855 double Z = (c1*h2*t3 + c1*p2*s3 + d1*h2*r3 + d1*p2*q3) -
856 (c1*h3*t2 + c1*p3*s2 + d1*h3*r2 + d1*p3*q2) -
857 (c2*h1*t3 + c2*p1*s3 + d2*h1*r3 + d2*p1*q3) +
858 (c2*h3*t1 + c2*p3*s1 + d2*h3*r1 + d2*p3*q1) +
859 (c3*h1*t2 + c3*p1*s2 + d3*h1*r2 + d3*p1*q2) -
860 (c3*h2*t1 + c3*p2*s1 + d3*h2*r1 + d3*p2*q1);
861 double AA = ((a1*h2 + c1*e2)*t3 + (a1*p2 + c1*f2)*s3 +
862 (b1*h2 + d1*e2)*r3 + (b1*p2 + d1*f2)*q3) -
863 ((a1*h3 + c1*e3)*t2 + (a1*p3 + c1*f3)*s2 +
864 (b1*h3 + d1*e3)*r2 + (b1*p3 + d1*f3)*q2) -
865 ((a2*h1 + c2*e1)*t3 + (a2*p1 + c2*f1)*s3 +
866 (b2*h1 + d2*e1)*r3 + (b2*p1 + d2*f1)*q3) +
867 ((a2*h3 + c2*e3)*t1 + (a2*p3 + c2*f3)*s1 +
868 (b2*h3 + d2*e3)*r1 + (b2*p3 + d2*f3)*q1) +
869 ((a3*h1 + c3*e1)*t2 + (a3*p1 + c3*f1)*s2 +
870 (b3*h1 + d3*e1)*r2 + (b3*p1 + d3*f1)*q2) -
871 ((a3*h2 + c3*e2)*t1 + (a3*p2 + c3*f2)*s1 +
872 (b3*h2 + d3*e2)*r1 + (b3*p2 + d3*f2)*q1);
874 xvolume = 64.0*(8.0*(A + B + D + E + J + K + M + N) +
875 4.0*(C + F + G + H + L + O + P + Q + S + T +
876 V + W) + 2.0*(I + R + U + X + Y + Z) +
879 volume[index] = xvolume ;
885 throw MEDEXCEPTION("MESH::getVolume(SUPPORT*) Bad Support to get Volumes on it !");
893 FIELD<double>* MESH::getArea(const SUPPORT * Support) throw (MEDEXCEPTION)
895 // Support must be on 2D elements
896 MESSAGE("MESH::getArea(SUPPORT*)");
898 // Make sure that the MESH class is the same as the MESH class attribut
899 // in the class Support
900 MESH* myMesh = Support->getMesh();
902 throw MEDEXCEPTION("MESH::getArea(SUPPORT*) no compatibility between *this and SUPPORT::_mesh !");
904 int dim_space = getSpaceDimension();
905 medEntityMesh support_entity = Support->getEntity();
906 bool onAll = Support->isOnAllElements();
908 int nb_type, length_values;
909 medGeometryElement* types;
911 // !!!! WARNING : use of nodal global numbering in the mesh !!!!
912 int* global_connectivity;
916 nb_type = myMesh->getNumberOfTypes(support_entity);
917 length_values = getNumberOfElements(support_entity,MED_ALL_ELEMENTS);
918 types = getTypes(support_entity);
922 nb_type = Support->getNumberOfTypes();
923 length_values = Support->getNumberOfElements(MED_ALL_ELEMENTS);
924 types = Support->getTypes();
930 Area = new FIELD<double>::FIELD(Support,1);
931 Area->setName("AREA");
932 Area->setDescription("cells or faces area");
934 Area->setComponentName(1,"area");
935 Area->setComponentDescription(1,"desc-comp");
937 /* string MEDComponentUnit = myMesh->getCoordinatesUnits()[0]+"*"+myMesh->getCoordinatesUnits()[1];*/
939 string MEDComponentUnit="trucmuch";
941 Area->setMEDComponentUnit(1,MEDComponentUnit);
943 Area->setValueType(MED_REEL64);
945 Area->setIterationNumber(0);
946 Area->setOrderNumber(0);
949 double *area = new double[length_values];
950 //double *area = Area->getValue(MED_FULL_INTERLACE);
952 const double * coord = getCoordinates(MED_FULL_INTERLACE);
955 for (int i=0;i<nb_type;i++)
957 medGeometryElement type = types[i] ;
962 nb_entity_type = getNumberOfElements(support_entity,type);
963 global_connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,type);
967 nb_entity_type = Support->getNumberOfElements(type);
969 int * supp_number = Support->getNumber(type);
970 int * connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,MED_ALL_ELEMENTS);
971 int * connectivityIndex = getConnectivityIndex(MED_NODAL,support_entity);
972 global_connectivity = new int[(type%100)*nb_entity_type];
974 for (int k_type = 0; k_type<nb_entity_type; k_type++) {
975 for (int j_ent = 0; j_ent<(type%100); j_ent++) {
976 global_connectivity[k_type*(type%100)+j_ent] = connectivity[connectivityIndex[supp_number[k_type]-1]+j_ent-1];
983 case MED_TRIA3 : case MED_TRIA6 :
985 for (int tria=0;tria<nb_entity_type;tria++)
987 int tria_index = (type%100)*tria;
989 int N1 = global_connectivity[tria_index]-1;
990 int N2 = global_connectivity[tria_index+1]-1;
991 int N3 = global_connectivity[tria_index+2]-1;
993 double x1 = coord[dim_space*N1];
994 double x2 = coord[dim_space*N2];
995 double x3 = coord[dim_space*N3];
997 double y1 = coord[dim_space*N1+1];
998 double y2 = coord[dim_space*N2+1];
999 double y3 = coord[dim_space*N3+1];
1003 xarea = - ((x2-x1)*(y3-y1) - (x3-x1)*(y2-y1))/2.0;
1007 double z1 = coord[dim_space*N1+2];
1008 double z2 = coord[dim_space*N2+2];
1009 double z3 = coord[dim_space*N3+2];
1011 xarea = sqrt(((y2-y1)*(z3-z1) - (y3-y1)*(z2-z1))*
1012 ((y2-y1)*(z3-z1) - (y3-y1)*(z2-z1)) +
1013 ((x3-x1)*(z2-z1) - (x2-x1)*(z3-z1))*
1014 ((x3-x1)*(z2-z1) - (x2-x1)*(z3-z1)) +
1015 ((x2-x1)*(y3-y1) - (x3-x1)*(y2-y1))*
1016 ((x2-x1)*(y3-y1) - (x3-x1)*(y2-y1)))/2.0;
1019 area[index] = xarea ;
1024 case MED_QUAD4 : case MED_QUAD8 :
1026 for (int quad=0;quad<nb_entity_type;quad++)
1028 int quad_index = (type%100)*quad;
1030 int N1 = global_connectivity[quad_index]-1;
1031 int N2 = global_connectivity[quad_index+1]-1;
1032 int N3 = global_connectivity[quad_index+2]-1;
1033 int N4 = global_connectivity[quad_index+3]-1;
1035 double x1 = coord[dim_space*N1];
1036 double x2 = coord[dim_space*N2];
1037 double x3 = coord[dim_space*N3];
1038 double x4 = coord[dim_space*N4];
1040 double y1 = coord[dim_space*N1+1];
1041 double y2 = coord[dim_space*N2+1];
1042 double y3 = coord[dim_space*N3+1];
1043 double y4 = coord[dim_space*N4+1];
1047 double a1 = (x2-x1)/4.0, a2 = (y2-y1)/4.0;
1048 double b1 = (x3-x4)/4.0, b2 = (y3-y4)/4.0;
1049 double c1 = (x3-x2)/4.0, c2 = (y3-y2)/4.0;
1050 double d1 = (x4-x1)/4.0, d2 = (y4-y1)/4.0;
1052 xarea = - 4.0*(b1*c2 - c1*b2 + a1*c2 - c1*a2 + b1*d2 -
1053 d1*b2 + a1*d2 - d1*a2);
1057 double z1 = coord[dim_space*N1+2];
1058 double z2 = coord[dim_space*N2+2];
1059 double z3 = coord[dim_space*N3+2];
1060 double z4 = coord[dim_space*N4+2];
1062 xarea = (sqrt(((y2-y1)*(z4-z1) - (y4-y1)*(z2-z1))*
1063 ((y2-y1)*(z4-z1) - (y4-y1)*(z2-z1)) +
1064 ((x4-x1)*(z2-z1) - (x2-x1)*(z4-z1))*
1065 ((x4-x1)*(z2-z1) - (x2-x1)*(z4-z1)) +
1066 ((x2-x1)*(y4-y1) - (x4-x1)*(y2-y1))*
1067 ((x2-x1)*(y4-y1) - (x4-x1)*(y2-y1))) +
1068 sqrt(((y4-y3)*(z2-z3) - (y2-y3)*(z4-z3))*
1069 ((y4-y3)*(z2-z3) - (y2-y3)*(z4-z3)) +
1070 ((x2-x3)*(z4-z3) - (x4-x3)*(z2-z3))*
1071 ((x2-x3)*(z4-z3) - (x4-x3)*(z2-z3)) +
1072 ((x4-x3)*(y2-y3) - (x2-x3)*(y4-y3))*
1073 ((x4-x3)*(y2-y3) - (x2-x3)*(y4-y3))))/2.0;
1076 area[index] = xarea ;
1082 throw MEDEXCEPTION("MESH::getArea(SUPPORT*) Bad Support to get Areas on it !");
1087 Area->setValue(MED_FULL_INTERLACE,area);
1092 FIELD<double>* MESH::getLength(const SUPPORT * Support) throw (MEDEXCEPTION)
1094 // Support must be on 1D elements
1095 MESSAGE("MESH::getLength(SUPPORT*)");
1097 // Make sure that the MESH class is the same as the MESH class attribut
1098 // in the class Support
1099 MESH* myMesh = Support->getMesh();
1101 throw MEDEXCEPTION("MESH::getLength(SUPPORT*) no compatibility between *this and SUPPORT::_mesh !");
1103 int dim_space = getSpaceDimension();
1104 medEntityMesh support_entity = Support->getEntity();
1105 bool onAll = Support->isOnAllElements();
1107 int nb_type, length_values;
1108 medGeometryElement* types;
1110 // !!!! WARNING : use of nodal global numbering in the mesh !!!!
1111 int* global_connectivity;
1115 nb_type = myMesh->getNumberOfTypes(support_entity);
1116 length_values = getNumberOfElements(support_entity,MED_ALL_ELEMENTS);
1117 types = getTypes(support_entity);
1121 nb_type = Support->getNumberOfTypes();
1122 length_values = Support->getNumberOfElements(MED_ALL_ELEMENTS);
1123 types = Support->getTypes();
1127 FIELD<double>* Length;
1129 Length = new FIELD<double>::FIELD(Support,1);
1130 // double *length = new double [length_values];
1131 Length->setValueType(MED_REEL64);
1133 double *length = Length->getValue(MED_FULL_INTERLACE);
1135 const double * coord = getCoordinates(MED_FULL_INTERLACE);
1138 for (int i=0;i<nb_type;i++)
1140 medGeometryElement type = types[i] ;
1145 nb_entity_type = getNumberOfElements(support_entity,type);
1146 global_connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,type);
1150 nb_entity_type = Support->getNumberOfElements(type);
1152 int * supp_number = Support->getNumber(type);
1153 int * connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,MED_ALL_ELEMENTS);
1154 int * connectivityIndex = getConnectivityIndex(MED_NODAL,support_entity);
1155 global_connectivity = new int[(type%100)*nb_entity_type];
1157 for (int k_type = 0; k_type<nb_entity_type; k_type++) {
1158 for (int j_ent = 0; j_ent<(type%100); j_ent++) {
1159 global_connectivity[k_type*(type%100)+j_ent] = connectivity[connectivityIndex[supp_number[k_type]-1]+j_ent-1];
1166 case MED_SEG2 : case MED_SEG3 :
1168 for (int edge=0;edge<nb_entity_type;edge++)
1170 int edge_index = (type%100)*edge;
1172 int N1 = global_connectivity[edge_index]-1;
1173 int N2 = global_connectivity[edge_index+1]-1;
1175 double x1 = coord[dim_space*N1];
1176 double x2 = coord[dim_space*N2];
1178 double y1 = coord[dim_space*N1+1];
1179 double y2 = coord[dim_space*N2+1];
1181 double z1, z2 ; z1 = 0.0 ; z2 = 0.0 ; if (dim_space==3) {
1182 z1 = coord[dim_space*N1+2]; z2 = coord[dim_space*N2+2];}
1184 xlength = sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2) +
1185 (z1 - z2)*(z1 - z2));
1187 length[index] = xlength ;
1193 throw MEDEXCEPTION("MESH::getLength(SUPPORT*) Bad Support to get Lengths on it !");
1201 FIELD<double>* MESH::getNormal(const SUPPORT * Support) throw (MEDEXCEPTION)
1203 // Support must be on 2D or 1D elements
1204 MESSAGE("MESH::getNormal(SUPPORT*)");
1206 // Make sure that the MESH class is the same as the MESH class attribut
1207 // in the class Support
1208 MESH* myMesh = Support->getMesh();
1210 throw MEDEXCEPTION("MESH::getNormal(SUPPORT*) no compatibility between *this and SUPPORT::_mesh : pointeur problem !");
1212 int dim_space = getSpaceDimension();
1213 medEntityMesh support_entity = Support->getEntity();
1214 bool onAll = Support->isOnAllElements();
1216 int nb_type, length_values;
1217 medGeometryElement* types;
1219 // !!!! WARNING : use of nodal global numbering in the mesh !!!!
1220 int* global_connectivity;
1224 nb_type = myMesh->getNumberOfTypes(support_entity);
1225 length_values = getNumberOfElements(support_entity,MED_ALL_ELEMENTS);
1226 types = getTypes(support_entity);
1230 nb_type = Support->getNumberOfTypes();
1231 length_values = Support->getNumberOfElements(MED_ALL_ELEMENTS);
1232 types = Support->getTypes();
1237 FIELD<double>* Normal = new FIELD<double>::FIELD(Support,dim_space);
1238 Normal->setName("NORMAL");
1239 Normal->setDescription("cells or faces normal");
1240 for (int k=0;k<dim_space;k++) {
1242 Normal->setComponentName(kp1,"normal");
1243 Normal->setComponentDescription(kp1,"desc-comp");
1244 Normal->setMEDComponentUnit(kp1,"unit");
1247 Normal->setValueType(MED_REEL64);
1249 Normal->setIterationNumber(0);
1250 Normal->setOrderNumber(0);
1251 Normal->setTime(0.0);
1253 double * normal = new double [dim_space*length_values];
1254 //double *normal = Normal->getValue(MED_FULL_INTERLACE);
1256 const double * coord = getCoordinates(MED_FULL_INTERLACE);
1259 for (int i=0;i<nb_type;i++)
1261 medGeometryElement type = types[i] ;
1263 // Make sure we trying to get Normals on
1264 // TRIA3 or TRIA6 or QUAD4 QUAD8 (2D) cells on a 3D mesh
1265 // or on SEG2 or SEG3 (1D) cells on a 2D mesh
1267 if ( (((type==MED_TRIA3) || (type==MED_TRIA6) ||
1268 (type==MED_QUAD4) || (type==MED_QUAD8)) &&
1269 (dim_space != 3)) || (((type==MED_SEG2) || (type==MED_SEG3)) &&
1271 throw MEDEXCEPTION("MESH::getNormal(SUPPORT*) no compatibility between *this and SUPPORT::_mesh : dimension problem !");
1273 double xnormal1, xnormal2, xnormal3 ;
1277 nb_entity_type = getNumberOfElements(support_entity,type);
1278 global_connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,type);
1282 nb_entity_type = Support->getNumberOfElements(type);
1284 int * supp_number = Support->getNumber(type);
1285 int * connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,MED_ALL_ELEMENTS);
1286 int * connectivityIndex = getConnectivityIndex(MED_NODAL,support_entity);
1287 global_connectivity = new int[(type%100)*nb_entity_type];
1289 for (int k_type = 0; k_type<nb_entity_type; k_type++) {
1290 for (int j_ent = 0; j_ent<(type%100); j_ent++) {
1291 global_connectivity[k_type*(type%100)+j_ent] = connectivity[connectivityIndex[supp_number[k_type]-1]+j_ent-1];
1298 case MED_TRIA3 : case MED_TRIA6 :
1300 for (int tria=0;tria<nb_entity_type;tria++)
1302 int tria_index = (type%100)*tria;
1304 int N1 = global_connectivity[tria_index]-1;
1305 int N2 = global_connectivity[tria_index+1]-1;
1306 int N3 = global_connectivity[tria_index+2]-1;
1309 double x1 = coord[dim_space*N1];
1310 double x2 = coord[dim_space*N2];
1311 double x3 = coord[dim_space*N3];
1313 double y1 = coord[dim_space*N1+1];
1314 double y2 = coord[dim_space*N2+1];
1315 double y3 = coord[dim_space*N3+1];
1317 double z1 = coord[dim_space*N1+2];
1318 double z2 = coord[dim_space*N2+2];
1319 double z3 = coord[dim_space*N3+2];
1321 xnormal1 = ((y2-y1)*(z3-z1) - (y3-y1)*(z2-z1))/2.0;
1322 xnormal2 = ((x3-x1)*(z2-z1) - (x2-x1)*(z3-z1))/2.0;
1323 xnormal3 = ((x2-x1)*(y3-y1) - (x3-x1)*(y2-y1))/2.0;
1325 normal[3*index] = xnormal1 ;
1326 normal[3*index+1] = xnormal2 ;
1327 normal[3*index+2] = xnormal3 ;
1333 case MED_QUAD4 : case MED_QUAD8 :
1335 for (int quad=0;quad<nb_entity_type;quad++)
1337 int quad_index = (type%100)*quad;
1339 int N1 = global_connectivity[quad_index]-1;
1340 int N2 = global_connectivity[quad_index+1]-1;
1341 int N3 = global_connectivity[quad_index+2]-1;
1342 int N4 = global_connectivity[quad_index+3]-1;
1345 double x1 = coord[dim_space*N1];
1346 double x2 = coord[dim_space*N2];
1347 double x3 = coord[dim_space*N3];
1348 double x4 = coord[dim_space*N4];
1350 double y1 = coord[dim_space*N1+1];
1351 double y2 = coord[dim_space*N2+1];
1352 double y3 = coord[dim_space*N3+1];
1353 double y4 = coord[dim_space*N4+1];
1355 double z1 = coord[dim_space*N1+2];
1356 double z2 = coord[dim_space*N2+2];
1357 double z3 = coord[dim_space*N3+2];
1358 double z4 = coord[dim_space*N4+2];
1360 xnormal1 = (y2-y1)*(z4-z1) - (y4-y1)*(z2-z1);
1361 xnormal2 = (x4-x1)*(z2-z1) - (x2-x1)*(z4-z1);
1362 xnormal3 = (x2-x1)*(y4-y1) - (x4-x1)*(y2-y1);
1363 xarea = sqrt(xnormal1*xnormal1 + xnormal2*xnormal2 +
1366 xnormal1 = xnormal1/xarea;
1367 xnormal2 = xnormal2/xarea;
1368 xnormal3 = xnormal3/xarea;
1370 xarea = (sqrt(((y2-y1)*(z4-z1) - (y4-y1)*(z2-z1))*
1371 ((y2-y1)*(z4-z1) - (y4-y1)*(z2-z1)) +
1372 ((x4-x1)*(z2-z1) - (x2-x1)*(z4-z1))*
1373 ((x4-x1)*(z2-z1) - (x2-x1)*(z4-z1)) +
1374 ((x2-x1)*(y4-y1) - (x4-x1)*(y2-y1))*
1375 ((x2-x1)*(y4-y1) - (x4-x1)*(y2-y1))) +
1376 sqrt(((y3-y2)*(z4-z3) - (y4-y3)*(z3-z2))*
1377 ((y3-y2)*(z4-z3) - (y4-y3)*(z3-z2)) +
1378 ((x4-x3)*(z2-z2) - (x3-x2)*(z4-z3))*
1379 ((x4-x3)*(z4-z2) - (x3-x2)*(z4-z3)) +
1380 ((x3-x2)*(y4-y3) - (x4-x3)*(y3-y2))*
1381 ((x3-x2)*(y4-y3) - (x4-x3)*(y3-y2))))/2.0;
1383 xnormal1 = xnormal1*xarea;
1384 xnormal2 = xnormal2*xarea;
1385 xnormal3 = xnormal3*xarea;
1387 normal[3*index] = xnormal1 ;
1388 normal[3*index+1] = xnormal2 ;
1389 normal[3*index+2] = xnormal3 ;
1395 case MED_SEG2 : case MED_SEG3 :
1397 for (int edge=0;edge<nb_entity_type;edge++)
1399 int edge_index = (type%100)*edge;
1401 int N1 = global_connectivity[edge_index]-1;
1402 int N2 = global_connectivity[edge_index+1]-1;
1404 double x1 = coord[dim_space*N1];
1405 double x2 = coord[dim_space*N2];
1407 double y1 = coord[dim_space*N1+1];
1408 double y2 = coord[dim_space*N2+1];
1410 xnormal1 = -(y2-y1);
1413 normal[2*index] = xnormal1 ;
1414 normal[2*index+1] = xnormal2 ;
1421 throw MEDEXCEPTION("MESH::getNormal(SUPPORT*) Bad Support to get Normals on it !");
1426 Normal->setValue(MED_FULL_INTERLACE,normal);
1431 FIELD<double>* MESH::getBarycenter(const SUPPORT * Support) throw (MEDEXCEPTION)
1433 MESSAGE("MESH::getBarycenter(SUPPORT*)");
1435 // Make sure that the MESH class is the same as the MESH class attribut
1436 // in the class Support
1437 MESH* myMesh = Support->getMesh();
1439 throw MEDEXCEPTION("MESH::getBarycenter(SUPPORT*) no compatibility between *this and SUPPORT::_mesh !");
1441 int dim_space = getSpaceDimension();
1442 medEntityMesh support_entity = Support->getEntity();
1443 bool onAll = Support->isOnAllElements();
1445 int nb_type, length_values;
1446 medGeometryElement* types;
1448 // !!!! WARNING : use of nodal global numbering in the mesh !!!!
1449 int* global_connectivity;
1453 nb_type = myMesh->getNumberOfTypes(support_entity);
1454 length_values = getNumberOfElements(support_entity,MED_ALL_ELEMENTS);
1455 types = getTypes(support_entity);
1459 nb_type = Support->getNumberOfTypes();
1460 length_values = Support->getNumberOfElements(MED_ALL_ELEMENTS);
1461 types = Support->getTypes();
1465 FIELD<double>* Barycenter;
1467 Barycenter = new FIELD<double>::FIELD(Support,dim_space);
1468 Barycenter->setName("BARYCENTER");
1469 Barycenter->setDescription("cells or faces barycenter");
1471 for (int k=0;k<dim_space;k++) {
1473 Barycenter->setComponentName(kp1,myMesh->getCoordinatesNames()[k]);
1474 Barycenter->setComponentDescription(kp1,"desc-comp");
1475 Barycenter->setMEDComponentUnit(kp1,myMesh->getCoordinatesUnits()[k]);
1478 Barycenter->setValueType(MED_REEL64);
1480 Barycenter->setIterationNumber(0);
1481 Barycenter->setOrderNumber(0);
1482 Barycenter->setTime(0.0);
1484 double *barycenter = new double [dim_space*length_values];
1485 // double *barycenter = Barycenter->getValue(MED_FULL_INTERLACE);
1487 const double * coord = getCoordinates(MED_FULL_INTERLACE);
1490 for (int i=0;i<nb_type;i++)
1492 medGeometryElement type = types[i] ;
1493 double xbarycenter1, xbarycenter2, xbarycenter3;
1497 nb_entity_type = getNumberOfElements(support_entity,type);
1498 global_connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,type);
1502 nb_entity_type = Support->getNumberOfElements(type);
1504 int * supp_number = Support->getNumber(type);
1505 int * connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,MED_ALL_ELEMENTS);
1506 int * connectivityIndex = getConnectivityIndex(MED_NODAL,support_entity);
1507 global_connectivity = new int[(type%100)*nb_entity_type];
1509 for (int k_type = 0; k_type<nb_entity_type; k_type++) {
1510 for (int j_ent = 0; j_ent<(type%100); j_ent++) {
1511 global_connectivity[k_type*(type%100)+j_ent] = connectivity[connectivityIndex[supp_number[k_type]-1]+j_ent-1];
1518 case MED_TETRA4 : case MED_TETRA10 :
1520 for (int tetra =0;tetra<nb_entity_type;tetra++)
1522 int tetra_index = (type%100)*tetra;
1524 int N1 = global_connectivity[tetra_index]-1;
1525 int N2 = global_connectivity[tetra_index+1]-1;
1526 int N3 = global_connectivity[tetra_index+2]-1;
1527 int N4 = global_connectivity[tetra_index+3]-1;
1529 double x1 = coord[dim_space*N1];
1530 double x2 = coord[dim_space*N2];
1531 double x3 = coord[dim_space*N3];
1532 double x4 = coord[dim_space*N4];
1534 double y1 = coord[dim_space*N1+1];
1535 double y2 = coord[dim_space*N2+1];
1536 double y3 = coord[dim_space*N3+1];
1537 double y4 = coord[dim_space*N4+1];
1539 double z1 = coord[dim_space*N1+2];
1540 double z2 = coord[dim_space*N2+2];
1541 double z3 = coord[dim_space*N3+2];
1542 double z4 = coord[dim_space*N4+2];
1544 xbarycenter1 = (x1 + x2 + x3 + x4)/4.0;
1545 xbarycenter2 = (y1 + y2 + y3 + y4)/4.0;
1546 xbarycenter3 = (z1 + z2 + z3 + z4)/4.0;
1547 barycenter[3*index] = xbarycenter1 ;
1548 barycenter[3*index+1] = xbarycenter2 ;
1549 barycenter[3*index+2] = xbarycenter3 ;
1554 case MED_PYRA5 : case MED_PYRA13 :
1556 for (int pyra=0;pyra<nb_entity_type;pyra++)
1558 int pyra_index = (type%100)*pyra;
1560 int N1 = global_connectivity[pyra_index]-1;
1561 int N2 = global_connectivity[pyra_index+1]-1;
1562 int N3 = global_connectivity[pyra_index+2]-1;
1563 int N4 = global_connectivity[pyra_index+3]-1;
1564 int N5 = global_connectivity[pyra_index+4]-1;
1566 double x1 = coord[dim_space*N1];
1567 double x2 = coord[dim_space*N2];
1568 double x3 = coord[dim_space*N3];
1569 double x4 = coord[dim_space*N4];
1570 double x5 = coord[dim_space*N5];
1572 double y1 = coord[dim_space*N1+1];
1573 double y2 = coord[dim_space*N2+1];
1574 double y3 = coord[dim_space*N3+1];
1575 double y4 = coord[dim_space*N4+1];
1576 double y5 = coord[dim_space*N5+1];
1578 double z1 = coord[dim_space*N1+2];
1579 double z2 = coord[dim_space*N2+2];
1580 double z3 = coord[dim_space*N3+2];
1581 double z4 = coord[dim_space*N4+2];
1582 double z5 = coord[dim_space*N5+2];
1584 xbarycenter1 = (x1 + x2 + x3 + x4 + x5)/5.0;
1585 xbarycenter2 = (y1 + y2 + y3 + y4 + y5)/5.0;
1586 xbarycenter3 = (z1 + z2 + z3 + z4 + z5)/5.0;
1587 barycenter[3*index] = xbarycenter1 ;
1588 barycenter[3*index+1] = xbarycenter2 ;
1589 barycenter[3*index+2] = xbarycenter3 ;
1594 case MED_PENTA6 : case MED_PENTA15 :
1596 for (int penta=0;penta<nb_entity_type;penta++)
1598 int penta_index = (type%100)*penta;
1600 int N1 = global_connectivity[penta_index]-1;
1601 int N2 = global_connectivity[penta_index+1]-1;
1602 int N3 = global_connectivity[penta_index+2]-1;
1603 int N4 = global_connectivity[penta_index+3]-1;
1604 int N5 = global_connectivity[penta_index+4]-1;
1605 int N6 = global_connectivity[penta_index+5]-1;
1607 double x1 = coord[dim_space*N1];
1608 double x2 = coord[dim_space*N2];
1609 double x3 = coord[dim_space*N3];
1610 double x4 = coord[dim_space*N4];
1611 double x5 = coord[dim_space*N5];
1612 double x6 = coord[dim_space*N6];
1614 double y1 = coord[dim_space*N1+1];
1615 double y2 = coord[dim_space*N2+1];
1616 double y3 = coord[dim_space*N3+1];
1617 double y4 = coord[dim_space*N4+1];
1618 double y5 = coord[dim_space*N5+1];
1619 double y6 = coord[dim_space*N6+1];
1621 double z1 = coord[dim_space*N1+2];
1622 double z2 = coord[dim_space*N2+2];
1623 double z3 = coord[dim_space*N3+2];
1624 double z4 = coord[dim_space*N4+2];
1625 double z5 = coord[dim_space*N5+2];
1626 double z6 = coord[dim_space*N6+2];
1628 xbarycenter1 = (x1 + x2 + x3 + x4 + x5 + x6)/6.0;
1629 xbarycenter2 = (y1 + y2 + y3 + y4 + y5 + y6)/6.0;
1630 xbarycenter3 = (z1 + z2 + z3 + z4 + z5 + z6)/6.0;
1631 barycenter[3*index] = xbarycenter1 ;
1632 barycenter[3*index+1] = xbarycenter2 ;
1633 barycenter[3*index+2] = xbarycenter3 ;
1638 case MED_HEXA8 : case MED_HEXA20 :
1640 for (int hexa=0;hexa<nb_entity_type;hexa++)
1642 int hexa_index = (type%100)*hexa;
1644 int N1 = global_connectivity[hexa_index]-1;
1645 int N2 = global_connectivity[hexa_index+1]-1;
1646 int N3 = global_connectivity[hexa_index+2]-1;
1647 int N4 = global_connectivity[hexa_index+3]-1;
1648 int N5 = global_connectivity[hexa_index+4]-1;
1649 int N6 = global_connectivity[hexa_index+5]-1;
1650 int N7 = global_connectivity[hexa_index+6]-1;
1651 int N8 = global_connectivity[hexa_index+7]-1;
1653 double x1 = coord[dim_space*N1];
1654 double x2 = coord[dim_space*N2];
1655 double x3 = coord[dim_space*N3];
1656 double x4 = coord[dim_space*N4];
1657 double x5 = coord[dim_space*N5];
1658 double x6 = coord[dim_space*N6];
1659 double x7 = coord[dim_space*N7];
1660 double x8 = coord[dim_space*N8];
1662 double y1 = coord[dim_space*N1+1];
1663 double y2 = coord[dim_space*N2+1];
1664 double y3 = coord[dim_space*N3+1];
1665 double y4 = coord[dim_space*N4+1];
1666 double y5 = coord[dim_space*N5+1];
1667 double y6 = coord[dim_space*N6+1];
1668 double y7 = coord[dim_space*N7+1];
1669 double y8 = coord[dim_space*N8+1];
1671 double z1 = coord[dim_space*N1+2];
1672 double z2 = coord[dim_space*N2+2];
1673 double z3 = coord[dim_space*N3+2];
1674 double z4 = coord[dim_space*N4+2];
1675 double z5 = coord[dim_space*N5+2];
1676 double z6 = coord[dim_space*N6+2];
1677 double z7 = coord[dim_space*N7+2];
1678 double z8 = coord[dim_space*N8+2];
1680 xbarycenter1 = (x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8)/8.0;
1681 xbarycenter2 = (y1 + y2 + y3 + y4 + y5 + y6 + y7 + y8)/8.0;
1682 xbarycenter3 = (z1 + z2 + z3 + z4 + z5 + z6 + z7 + z8)/8.0;
1684 barycenter[3*index] = xbarycenter1 ;
1685 barycenter[3*index+1] = xbarycenter2 ;
1686 barycenter[3*index+2] = xbarycenter3 ;
1692 case MED_TRIA3 : case MED_TRIA6 :
1694 for (int tria=0;tria<nb_entity_type;tria++)
1696 int tria_index = (type%100)*tria;
1698 int N1 = global_connectivity[tria_index]-1;
1699 int N2 = global_connectivity[tria_index+1]-1;
1700 int N3 = global_connectivity[tria_index+2]-1;
1702 double x1 = coord[dim_space*N1];
1703 double x2 = coord[dim_space*N2];
1704 double x3 = coord[dim_space*N3];
1706 double y1 = coord[dim_space*N1+1];
1707 double y2 = coord[dim_space*N2+1];
1708 double y3 = coord[dim_space*N3+1];
1710 xbarycenter1 = (x1 + x2 + x3)/3.0;
1711 xbarycenter2 = (y1 + y2 + y3)/3.0;
1715 barycenter[2*index] = xbarycenter1 ;
1716 barycenter[2*index+1] = xbarycenter2 ;
1721 coord[dim_space*N1+2];
1723 coord[dim_space*N2+2];
1725 coord[dim_space*N3+2];
1727 xbarycenter3 = (z1 + z2 + z3)/3.0;
1729 barycenter[3*index] = xbarycenter1 ;
1730 barycenter[3*index+1] = xbarycenter2 ;
1731 barycenter[3*index+2] = xbarycenter3 ;
1738 case MED_QUAD4 : case MED_QUAD8 :
1740 for (int quad=0;quad<nb_entity_type;quad++)
1742 int quad_index = (type%100)*quad;
1744 int N1 = global_connectivity[quad_index]-1;
1745 int N2 = global_connectivity[quad_index+1]-1;
1746 int N3 = global_connectivity[quad_index+2]-1;
1747 int N4 = global_connectivity[quad_index+3]-1;
1749 double x1 = coord[dim_space*N1];
1750 double x2 = coord[dim_space*N2];
1751 double x3 = coord[dim_space*N3];
1752 double x4 = coord[dim_space*N4];
1754 double y1 = coord[dim_space*N1+1];
1755 double y2 = coord[dim_space*N2+1];
1756 double y3 = coord[dim_space*N3+1];
1757 double y4 = coord[dim_space*N4+1];
1759 xbarycenter1 = (x1 + x2 + x3 + x4)/4.0;
1760 xbarycenter2 = (y1 + y2 + y3 + y4)/4.0;
1764 barycenter[2*index] = xbarycenter1 ;
1765 barycenter[2*index+1] = xbarycenter2 ;
1769 double z1 = coord[dim_space*N1+2];
1770 double z2 = coord[dim_space*N2+2];
1771 double z3 = coord[dim_space*N3+2];
1772 double z4 = coord[dim_space*N4+2];
1774 xbarycenter3 = (z1 + z2 + z3 + z4)/4.0;
1776 barycenter[3*index] = xbarycenter1 ;
1777 barycenter[3*index+1] = xbarycenter2 ;
1778 barycenter[3*index+2] = xbarycenter3 ;
1784 case MED_SEG2 : case MED_SEG3 :
1786 for (int edge=0;edge<nb_entity_type;edge++)
1788 int edge_index = (type%100)*edge;
1790 int N1 = global_connectivity[edge_index]-1;
1791 int N2 = global_connectivity[edge_index+1]-1;
1793 double x1 = coord[dim_space*N1];
1794 double x2 = coord[dim_space*N2];
1796 double y1 = coord[dim_space*N1+1];
1797 double y2 = coord[dim_space*N2+1];
1799 xbarycenter1 = (x1 + x2)/2.0;
1800 xbarycenter2 = (y1 + y2)/2.0;
1804 barycenter[2*index] = xbarycenter1 ;
1805 barycenter[2*index+1] = xbarycenter2 ;
1809 double z1 = coord[dim_space*N1+2];
1810 double z2 = coord[dim_space*N2+2];
1812 xbarycenter3 = (z1 + z2)/2.0;
1814 barycenter[3*index] = xbarycenter1 ;
1815 barycenter[3*index+1] = xbarycenter2 ;
1816 barycenter[3*index+2] = xbarycenter3 ;
1823 throw MEDEXCEPTION("MESH::getBarycenter(SUPPORT*) Bad Support to get a barycenter on it (in fact unknown type) !");
1828 Barycenter->setValue(MED_FULL_INTERLACE,barycenter);