+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_Connectivity.cxx
+// Module : MED
+
using namespace std;
#include "MEDMEM_Connectivity.hxx"
#include "MEDMEM_Family.hxx"
#include "MEDMEM_STRING.hxx"
-//------------------------------------------------------//
-CONNECTIVITY::CONNECTIVITY(medEntityMesh Entity/*=MED_CELL*/):
-//------------------------------------------------------//
- _entity(Entity),
- _typeConnectivity(MED_NODAL),
- _numberOfTypes(0),
- _geometricTypes((medGeometryElement*)NULL),
- _type((CELLMODEL*)NULL),
- _entityDimension(0),
- _count((int*)NULL),
- _nodal((MEDSKYLINEARRAY*)NULL),
- _descending((MEDSKYLINEARRAY*)NULL),
- _reverseNodalConnectivity((MEDSKYLINEARRAY*)NULL),
- _reverseDescendingConnectivity((MEDSKYLINEARRAY*)NULL),
- _neighbourhood((MEDSKYLINEARRAY*)NULL),
- _constituent((CONNECTIVITY*)NULL)
+/*!
+ Default Constructor. /n
+ Default for Entity is MED_CELL and type of Connectivity is MED_NODAL */
+//--------------------------------------------------------------//
+CONNECTIVITY::CONNECTIVITY(medEntityMesh Entity /* =MED_CELL */) :
+//--------------------------------------------------------------//
+ _entity(Entity),
+ _typeConnectivity(MED_NODAL),
+ _numberOfTypes(0),
+ _geometricTypes((medGeometryElement*)NULL),
+ _type((CELLMODEL*)NULL),
+ _entityDimension(0),
+ _count((int*)NULL),
+ _nodal((MEDSKYLINEARRAY*)NULL),
+ _descending((MEDSKYLINEARRAY*)NULL),
+ _reverseNodalConnectivity((MEDSKYLINEARRAY*)NULL),
+ _reverseDescendingConnectivity((MEDSKYLINEARRAY*)NULL),
+ _neighbourhood((MEDSKYLINEARRAY*)NULL),
+ _constituent((CONNECTIVITY*)NULL)
{
- MESSAGE("CONNECTIVITY(medEntityMesh Entity=MED_CELL)") ;
+ MESSAGE("CONNECTIVITY(medEntityMesh Entity=MED_CELL)");
}
-//-------------------------------------------------------------------------//
-CONNECTIVITY::CONNECTIVITY(int numberOfTypes,medEntityMesh Entity/*=MED_CELL*/):
-//-------------------------------------------------------------------------//
- _entity(Entity),
- _typeConnectivity(MED_NODAL),
- _numberOfTypes(numberOfTypes),
- _entityDimension(0),
- _nodal((MEDSKYLINEARRAY*)NULL),
- _descending((MEDSKYLINEARRAY*)NULL),
- _reverseNodalConnectivity((MEDSKYLINEARRAY*)NULL),
- _reverseDescendingConnectivity((MEDSKYLINEARRAY*)NULL),
- _neighbourhood((MEDSKYLINEARRAY*)NULL),
- _constituent((CONNECTIVITY*)NULL)
+/*!
+ Constructor. /n
+ Default for Entity is MED_CELL */
+//------------------------------------------------------------------------------//
+CONNECTIVITY::CONNECTIVITY(int numberOfTypes,medEntityMesh Entity /* =MED_CELL */):
+//------------------------------------------------------------------------------//
+ _entity(Entity),
+ _typeConnectivity(MED_NODAL),
+ _numberOfTypes(numberOfTypes),
+ _entityDimension(0),
+ _nodal((MEDSKYLINEARRAY*)NULL),
+ _descending((MEDSKYLINEARRAY*)NULL),
+ _reverseNodalConnectivity((MEDSKYLINEARRAY*)NULL),
+ _reverseDescendingConnectivity((MEDSKYLINEARRAY*)NULL),
+ _neighbourhood((MEDSKYLINEARRAY*)NULL),
+ _constituent((CONNECTIVITY*)NULL)
{
- MESSAGE("CONNECTIVITY(int numberOfTypes,medEntityMesh Entity=MED_CELL)") ;
+ MESSAGE("CONNECTIVITY(int numberOfTypes,medEntityMesh Entity=MED_CELL)");
_geometricTypes = new medGeometryElement[numberOfTypes];
_type = new CELLMODEL[numberOfTypes];
- _count = new int[numberOfTypes];
+ _count = new int[numberOfTypes+1];
}
-//-------------------------------------------------------------------------//
-CONNECTIVITY::CONNECTIVITY(CONNECTIVITY & m)
-//-------------------------------------------------------------------------//
+/*!
+ Copy Constructor.
+*/
+//------------------------------------------------------//
+CONNECTIVITY::CONNECTIVITY (const CONNECTIVITY & m):
+//----------------------------------------------------//
+ _entity (m._entity),
+ _typeConnectivity (m._typeConnectivity),
+ _numberOfTypes (m._numberOfTypes),
+ _entityDimension (m._entityDimension),
+ _numberOfNodes (m._numberOfNodes)
{
- _entity = m._entity;
- _typeConnectivity = m._typeConnectivity;
- _numberOfTypes = m._numberOfTypes;
- if (m._geometricTypes != NULL)
- {
- _geometricTypes = new medGeometryElement[m._numberOfTypes];
- memcpy(_geometricTypes,m._geometricTypes,m._numberOfTypes*sizeof(medGeometryElement));
- }
- else
+ if (m._geometricTypes != NULL)
+ {
+ _geometricTypes = new medGeometryElement[_numberOfTypes];
+ memcpy(_geometricTypes,m._geometricTypes,_numberOfTypes*sizeof(medGeometryElement));
+ }
+ else
_geometricTypes = (medGeometryElement *) NULL;
- if (m._type != NULL)
- _type = new CELLMODEL(* m._type);
- else
+
+ if (m._type != NULL)
+ {
+ _type = new CELLMODEL[_numberOfTypes];
+ for (int i=0;i<_numberOfTypes;i++)
+ _type[i] = CELLMODEL(m._type[i]);
+ }
+ else
_type = (CELLMODEL *) NULL;
- _entityDimension = m._entityDimension;
- _numberOfNodes = m._numberOfNodes;
- if (m._count != NULL)
- {
- _count = new med_int[m._numberOfTypes+1];
- memcpy(_count,m._count,(m._numberOfTypes+1)*sizeof(med_int));
- }
- else
+
+ if (m._count != NULL)
+ {
+ _count = new med_int[_numberOfTypes+1];
+ memcpy(_count,m._count,(_numberOfTypes+1)*sizeof(med_int));
+ }
+ else
_count = (med_int *) NULL;
- if (m._nodal != NULL)
+
+ if (m._nodal != NULL)
_nodal = new MEDSKYLINEARRAY(* m._nodal);
- else
+ else
_nodal = (MEDSKYLINEARRAY *) NULL;
- if (m._descending != NULL)
+
+ if (m._descending != NULL)
_descending = new MEDSKYLINEARRAY(* m._descending);
- else
+ else
_descending = (MEDSKYLINEARRAY *) NULL;
- if (m._reverseNodalConnectivity != NULL)
+
+ if (m._reverseNodalConnectivity != NULL)
_reverseNodalConnectivity = new MEDSKYLINEARRAY(* m._reverseNodalConnectivity);
- else
+ else
_reverseNodalConnectivity = (MEDSKYLINEARRAY *) NULL;
- if (m._reverseDescendingConnectivity != NULL)
+
+ if (m._reverseDescendingConnectivity != NULL)
_reverseDescendingConnectivity = new MEDSKYLINEARRAY(* m._reverseDescendingConnectivity);
- else
+ else
_reverseDescendingConnectivity = (MEDSKYLINEARRAY *) NULL;
- if (m._neighbourhood != NULL)
+
+ if (m._neighbourhood != NULL)
_neighbourhood = new MEDSKYLINEARRAY(* m._neighbourhood);
- else
+ else
_neighbourhood = (MEDSKYLINEARRAY *) NULL;
- if (m._constituent != NULL)
+
+ if (m._constituent != NULL)
_constituent = new CONNECTIVITY(* m._constituent);
- else
+ else
_constituent = (CONNECTIVITY *) NULL;
}
+/*!
+ Destructor./n
+ desallocates existing pointers */
//----------------------------//
CONNECTIVITY::~CONNECTIVITY()
//----------------------------//
{
- MESSAGE("Destructeur de CONNECTIVITY()") ;
- if ( _geometricTypes != NULL )
- delete [] _geometricTypes ;
- if ( _count != NULL )
- delete[] _count ;
- if ( _nodal != NULL )
- delete _nodal ;
- if ( _descending != NULL )
- delete _descending ;
- if ( _reverseNodalConnectivity != NULL )
- delete _reverseNodalConnectivity ;
- if ( _reverseDescendingConnectivity != NULL )
- delete _reverseDescendingConnectivity ;
- if ( _constituent != NULL )
- delete _constituent ;
+ MESSAGE("Destructeur de CONNECTIVITY()");
+
+ if (_geometricTypes != NULL)
+ delete [] _geometricTypes;
+ if (_type != NULL)
+ delete [] _type;
+ if (_count != NULL)
+ delete[] _count;
+ if (_nodal != NULL)
+ delete _nodal;
+ if (_descending != NULL)
+ delete _descending;
+ if (_reverseNodalConnectivity != NULL)
+ delete _reverseNodalConnectivity;
+ if (_reverseDescendingConnectivity != NULL)
+ delete _reverseDescendingConnectivity;
+ if (_constituent != NULL)
+ delete _constituent;
+}
+
+/*!
+ set _constituent to Constituent
+ be aware desallocation of _constituent is done by CONNECTIVITY:~CONNECTIVITY
+ throws an exception if Constituent = MED_CELL
+ A DOCUMENTER
+ */
+//----------------------------------------------------------//
+void CONNECTIVITY::setConstituent(CONNECTIVITY * Constituent)
+ throw (MEDEXCEPTION)
+//----------------------------------------------------------//
+{
+ medEntityMesh Entity = Constituent->getEntity();
+ if (Entity == MED_CELL)
+ throw MEDEXCEPTION(LOCALIZED("CONNECTIVITY::setConstituent : could not set constituent on MED_CELL !"));
+
+ if ((Entity == MED_EDGE)&(_entityDimension == 3))
+ {
+ if (_constituent == NULL)
+ throw MEDEXCEPTION(LOCALIZED("CONNECTIVITY::setConstituent : Entity not found !"));
+ _constituent->setConstituent(Constituent);
+ }
+ else
+ _constituent = Constituent;
+}
+
+/*! Duplicated Types array in CONNECTIVITY object. */
+//--------------------------------------------------------------------//
+void CONNECTIVITY::setGeometricTypes(const medGeometryElement * Types,
+ const medEntityMesh Entity)
+ throw (MEDEXCEPTION)
+//--------------------------------------------------------------------//
+{
+ if (Entity == _entity)
+ for (int i=0; i<_numberOfTypes; i++)
+ {
+ _geometricTypes[i] = Types[i];
+ _type[i] = CELLMODEL(_geometricTypes[i]);
+ }
+ else
+ {
+ if (_constituent == NULL)
+ throw MEDEXCEPTION(LOCALIZED("CONNECTIVITY::setGeometricTypes : Entity not found !"));
+ _constituent->setGeometricTypes(Types,Entity);
+ }
+}
+
+/*! A DOCUMENTER */
+//--------------------------------------------------------------------//
+void CONNECTIVITY::setCount(const int * Count, const medEntityMesh Entity)
+ throw (MEDEXCEPTION)
+//--------------------------------------------------------------------//
+{
+ if (Entity == _entity)
+ {
+ int * index = new int[Count[_numberOfTypes]];
+ index[0]=1;
+ _count[0]=1;
+ for (int i=0; i<_numberOfTypes; i++) {
+ _count[i+1] = Count[i+1];
+ int NumberOfNodesPerElement = _type[i].getNumberOfNodes() ;
+ for (int j=_count[i]; j<_count[i+1]; j++)
+ index[j] = index[j-1]+NumberOfNodesPerElement;
+ }
+ // allocate _nodal
+ if (_nodal != NULL) delete _nodal;
+ _nodal = new MEDSKYLINEARRAY(_count[_numberOfTypes]-1,index[_count[_numberOfTypes]-1]-1);
+ _nodal->setIndex(index);
+ delete[] index;
+ }
+ else
+ {
+ if (_constituent == NULL)
+ throw MEDEXCEPTION(LOCALIZED("CONNECTIVITY::setCount : Entity not found !"));
+ _constituent->setCount(Count,Entity);
+ }
+}
+
+//--------------------------------------------------------------------//
+void CONNECTIVITY::setNodal(const int * Connectivity,
+ const medEntityMesh Entity,
+ const medGeometryElement Type)
+ throw (MEDEXCEPTION)
+//--------------------------------------------------------------------//
+{
+ if (_entity == Entity)
+ {
+ // find geometric type
+ bool find = false;
+ for (int i=0; i<_numberOfTypes; i++)
+ if (_geometricTypes[i] == Type) {
+ find = true;
+ int NumberOfNodePerElements = _type[i].getNumberOfNodes() ;
+ //_nodal->setI(i+1,Connectivity);
+ for( int j=_count[i];j<_count[i+1]; j++)
+ _nodal->setI(j,Connectivity+(j-_count[i])*NumberOfNodePerElements);
+ }
+ if (!find)
+ throw MEDEXCEPTION(LOCALIZED("CONNECTIVITY::setNodal : geometric type not found"));
+ } else
+ {
+ if (_constituent == NULL)
+ throw MEDEXCEPTION(LOCALIZED("CONNECTIVITY::setNodal : Entity not found !"));
+ _constituent->setNodal(Connectivity,Entity,Type);
+ }
}
/*! A DOCUMENTER */
if (Entity==_entity)
if (ConnectivityType==MED_NODAL)
- calculateNodalConnectivity() ;
+ calculateNodalConnectivity();
else
if (Entity==MED_CELL)
- calculateDescendingConnectivity() ;
+ calculateDescendingConnectivity();
else
throw MEDEXCEPTION("CONNECTIVITY::calculateConnectivity : Could not build DESCENDING !");
if (Entity!=_entity) {
- calculateDescendingConnectivity() ;
- _constituent->calculateConnectivity(ConnectivityType,Entity) ;
+ calculateDescendingConnectivity();
+ _constituent->calculateConnectivity(ConnectivityType,Entity);
}
}
int numberOfFamilies = myFamilies.size();
if (numberOfFamilies == 0 ) {
- MESSAGE(LOC<<"No family") ;
- return ;
+ MESSAGE(LOC<<"No family");
+ return;
}
// does we do an update ?
if ((_constituent != NULL)&(_descending != NULL)) {
- MESSAGE(LOC<<"Constituent is already defined") ;
- return ;
+ MESSAGE(LOC<<"Constituent is already defined");
+ return;
}
if ((_constituent != NULL)&(_descending == NULL)) {
if (myFamilies[0]->getEntity() != _constituent->getEntity()) {
- MESSAGE(LOC<<"Family and constituent entity are different. We do nothing") ;
- return ;
+ MESSAGE(LOC<<"Family and constituent entity are different. We do nothing");
+ return;
}
for(int i=0; i<numberOfFamilies; i++) {
}
// well we could go !
- CONNECTIVITY * oldConstituent = _constituent ;
- _constituent = (CONNECTIVITY *)NULL ;
+ CONNECTIVITY * oldConstituent = _constituent;
+
+// for(int i=0; i<numberOfFamilies; i++) {
+// FAMILY * myFamily = myFamilies[i];
+// MESSAGE(LOC<<"updating the family (BEGIN) : " << *myFamily);
+// }
+
+ _constituent = (CONNECTIVITY *)NULL;
// for instance we must have nodal connectivity in constituent :
if (oldConstituent->_nodal == NULL)
{
MESSAGE(LOC<<"We have no nodal connectivity of sub cell");
- throw MED_EXCEPTION(LOCALIZED(STRING(LOC)<<"We have no nodal connectivity of sub cell")) ;
+ throw MED_EXCEPTION(LOCALIZED(STRING(LOC)<<"We have no nodal connectivity of sub cell"));
}
- int oldNumberOfFace = oldConstituent->_nodal->getNumberOf() ;
- int * oldConstituentValue = oldConstituent->_nodal->getValue() ;
- int * oldConstituentIndex = oldConstituent->_nodal->getIndex() ;
+ int oldNumberOfFace = oldConstituent->_nodal->getNumberOf();
+ const int * oldConstituentValue = oldConstituent->_nodal->getValue();
+ const int * oldConstituentIndex = oldConstituent->_nodal->getIndex();
- SCRUTE(oldNumberOfFace);
+ calculateDescendingConnectivity();
- calculateDescendingConnectivity() ;
-
- // if (oldConstituent->_nodal != NULL) {
- int newNumberOfFace = _constituent->_nodal->getNumberOf() ;
- int * newConstituentValue = _constituent->_nodal->getValue() ;
- int * newConstituentIndex = _constituent->_nodal->getIndex() ;
+ int newNumberOfFace = _constituent->_nodal->getNumberOf();
+ const int * newConstituentValue = _constituent->_nodal->getValue();
+ const int * newConstituentIndex = _constituent->_nodal->getIndex();
- SCRUTE(newNumberOfFace);
-
- int * newReverseDescendingIndex =
+ const int * newReverseDescendingIndex =
_reverseDescendingConnectivity->getIndex();
- int * newReverseDescendingValue =
- _reverseDescendingConnectivity->getValue();
- int * newDescendingIndex = _descending->getIndex();
- int * newDescendingValue = _descending->getValue();
+ const int * newDescendingIndex = _descending->getIndex();
+ const int * newDescendingValue = _descending->getValue();
// loop on all family,
// for all constituent in family, we get it's old connectivity
int index1 = 0;
int indexm1 = 0;
- _constituent->calculateReverseNodalConnectivity() ;
+ _constituent->calculateReverseNodalConnectivity();
for (int iOldFace=0;iOldFace<oldNumberOfFace;iOldFace++)
{
int index = 0;
renumberingFromOldToNew[iOldFace] = iOldFace+1;
-
// renumberingFromOldToNew[iOldFace] = 999999;
int face_it_beginOld = oldConstituentIndex[iOldFace];
int face_it_endOld = oldConstituentIndex[iOldFace+1];
int face_size_itOld = face_it_endOld - face_it_beginOld;
- int* NodesLists = oldConstituentValue + (face_it_beginOld-1) ;
+ const int* NodesLists = oldConstituentValue + (face_it_beginOld-1);
int face_size_itNew;
- int * reverseFaceNodal = _constituent->getReverseNodalConnectivity() ;
- int * reverseFaceNodalIndex = _constituent->getReverseNodalConnectivityIndex() ;
+ const int * reverseFaceNodal = _constituent->getReverseNodalConnectivity();
+ const int * reverseFaceNodalIndex = _constituent->getReverseNodalConnectivityIndex();
// set an array wich contains faces numbers arround first node
- int BeginIndexFaceArrayFirstNode=reverseFaceNodalIndex[NodesLists[0]-1] ;
- int EndIndexFaceArrayFirstNode=reverseFaceNodalIndex[NodesLists[0]] ;
+ int BeginIndexFaceArrayFirstNode=reverseFaceNodalIndex[NodesLists[0]-1];
+ int EndIndexFaceArrayFirstNode=reverseFaceNodalIndex[NodesLists[0]];
int NumberOfFacesInList=EndIndexFaceArrayFirstNode-BeginIndexFaceArrayFirstNode;
- int * FacesList = new int[NumberOfFacesInList] ;
- for (int l=BeginIndexFaceArrayFirstNode; l<EndIndexFaceArrayFirstNode; l++)
- FacesList[l-BeginIndexFaceArrayFirstNode]=reverseFaceNodal[l-1] ;
-
+ int * FacesList = new int[NumberOfFacesInList];
+
+ for (int l=BeginIndexFaceArrayFirstNode; l<EndIndexFaceArrayFirstNode; l++){
+ FacesList[l-BeginIndexFaceArrayFirstNode]=reverseFaceNodal[l-1];
+ }
// foreach node in sub cell, we search elements which are in common
// at the end, we must have only one !
for (int nodeFaceOld=1; nodeFaceOld<face_size_itOld; nodeFaceOld++)
{
-
- int NewNumberOfFacesInList = 0 ;
- int * NewFacesList = new int[NumberOfFacesInList] ;
+ int NewNumberOfFacesInList = 0;
+ int * NewFacesList = new int[NumberOfFacesInList];
for (int l1=0; l1<NumberOfFacesInList; l1++) {
for (int l2=reverseFaceNodalIndex[NodesLists[nodeFaceOld]-1]; l2<reverseFaceNodalIndex[NodesLists[nodeFaceOld]]; l2++) {
if (FacesList[l1]<reverseFaceNodal[l2-1])
// increasing order : FacesList[l1] are not in elements list of node l
- break ;
+ break;
if (FacesList[l1]==reverseFaceNodal[l2-1]) {
// we have found one
NewFacesList[NewNumberOfFacesInList]=FacesList[l1];
}
}
NumberOfFacesInList = NewNumberOfFacesInList;
- delete [] FacesList ;
+ delete [] FacesList;
FacesList = NewFacesList;
}
-
if (!NumberOfFacesInList==0)
{
if (NumberOfFacesInList>1)
MEDMODULUSARRAY modulusArrayOld(face_size_itOld,NodesLists);
- SCRUTE(NumberOfFacesInList);
- SCRUTE(FacesList);
- SCRUTE(newConstituentIndex);
-
int face_it_beginNew = newConstituentIndex[FacesList[0]-1];
int face_it_endNew = newConstituentIndex[FacesList[0]];
face_size_itNew = face_it_endNew - face_it_beginNew;
- int * newNodesLists = newConstituentValue+newConstituentIndex[FacesList[0]-1]-1 ;
- MEDMODULUSARRAY modulusArrayNew(face_size_itOld,newNodesLists);
+ const int * newNodesLists = newConstituentValue+newConstituentIndex[FacesList[0]-1]-1;
+ MEDMODULUSARRAY modulusArrayNew(face_size_itNew,newNodesLists);
int retCompareNewOld = modulusArrayNew.compare(modulusArrayOld);
+ //SCRUTE(retCompareNewOld);
+
// Real new face found
if(retCompareNewOld == 1)
{
- renumberingFromOldToNew[iOldFace] = FacesList[0] ;
-
- MESSAGE("Renumbering index " << iOldFace << " val "<< FacesList[0]);
-
+ renumberingFromOldToNew[iOldFace] = FacesList[0];
index = 1;
index1++;
}
if(retCompareNewOld == -1)
{
renumberingFromOldToNew[iOldFace] = FacesList[0];
-
- MESSAGE("Renumbering index " << iOldFace << " val "<< FacesList[0]);
-
index = 1;
indexm1++;
throw MED_EXCEPTION(LOCALIZED(STRING(LOC)<<"This face/edge should not be a (d-1) cell because it has "<<face_size_it<<" neighbouring"));
// we have always 2 neighbourings
- int cell1 = newReverseDescendingValue[face_it_begin-1];
- int cell2 = newReverseDescendingValue[face_it_begin];
-
+ int cell1 = _reverseDescendingConnectivity->getIJ(FacesList[0],1);
+ int cell2 = _reverseDescendingConnectivity->getIJ(FacesList[0],2);
// PROVISOIRE : en attendant que le SKYLINEARRAY de ReverseDescending soit correct (sans le zero)
// if (cell2 == 0)
// throw MED_EXCEPTION(LOCALIZED(STRING(LOC)<<"This is a boundary face/edge, it should not be renumbered and it is wrongly oriented."));
if (cell2 != 0) { // we are not on border !!!!
- newReverseDescendingValue[face_it_begin-1] = cell2;
+ _reverseDescendingConnectivity->setIJ(FacesList[0],1,cell2);
// Updating _constituent->_nodal because of reversity
- int * oldArray = oldConstituentValue+face_it_beginOld-1;
- int * newArray = newConstituentValue+face_it_beginNew-1;
- for(int iarray=0;iarray<face_size_itNew;iarray++)
- newArray[iarray] = oldArray[iarray] ;
-
+ const int * oldArray = oldConstituentValue+face_it_beginOld-1;
+ for(int iarray=1;iarray<=face_size_itNew;iarray++){
+ _constituent->_nodal->setIJ(FacesList[0],iarray,oldArray[iarray-1]);
+ }
// Updating _reverseDescendingConnectivity
- newReverseDescendingValue[face_it_begin] = cell1;
+ _reverseDescendingConnectivity->setIJ(FacesList[0],2,cell1);
// Updating _descending for cell1 and cell2
- for(int iface=newDescendingIndex[cell1-1];iface<newDescendingIndex[cell1];iface++)
- if (newDescendingValue[iface-1]==FacesList[0])
- newDescendingValue[iface-1]=-FacesList[0] ;
- else if (newDescendingValue[iface-1]==-FacesList[0])
- newDescendingValue[iface-1]=FacesList[0] ;
+ for(int iface=newDescendingIndex[cell1-1];iface<=newDescendingIndex[cell1];iface++)
+ if (_descending->getIndexValue(iface)==FacesList[0])
+ _descending->setIndexValue(iface,-FacesList[0]);
+ else if (_descending->getIndexValue(iface)==-FacesList[0])
+ _descending->setIndexValue(iface,FacesList[0]);
+ // else nothing to do
for(int iface=newDescendingIndex[cell2-1];iface<newDescendingIndex[cell2];iface++)
- if (newDescendingValue[iface-1]==FacesList[0])
- newDescendingValue[iface-1]=-FacesList[0] ;
- else if (newDescendingValue[iface-1]==-FacesList[0])
- newDescendingValue[iface-1]=FacesList[0] ;
+ if (_descending->getIndexValue(iface)==FacesList[0])
+ _descending->setIndexValue(iface,-FacesList[0]);
+ else if (_descending->getIndexValue(iface)==-FacesList[0])
+ _descending->setIndexValue(iface,FacesList[0]);
+ // else nothing to do
+
} else {// else we are on border and we do nothing !!!!!!!!
INFOS("WARNING,WARNING,WARNING,WARNING,WARNING,WARNING");
- INFOS(LOC<<" Boudary FACE "<<iOldFace+1<<" are wrong oriented !") ;
+ INFOS(LOC<<" Boudary FACE "<<iOldFace+1<<" are wrong oriented !");
INFOS("WARNING,WARNING,WARNING,WARNING,WARNING,WARNING");
}
}
throw MED_EXCEPTION(LOCALIZED(STRING(LOC)<<"We have a Face connectivity problem"));
}
}
+ delete[] FacesList;
}
MESSAGE(LOC<<"The Renumbering is finished and the status is");
- SCRUTE(index1);
- SCRUTE(indexm1);
// Updating the Family
for(int i=0; i<numberOfFamilies; i++) {
- FAMILY * myFamily = myFamilies[i] ;
+ FAMILY * myFamily = myFamilies[i];
- int length_skyline = myFamily->getnumber()->getLength();
- int * value_skyline = myFamily->getnumber()->getValue();
+ MEDSKYLINEARRAY * number = myFamily->getnumber();
+ int numberOfLines_skyline = number->getNumberOf();
+ const int * index_skyline = number->getIndex();
- for (int i=0;i<length_skyline;i++) {
- MESSAGE("OLD " << value_skyline[i] << " NEW " << renumberingFromOldToNew[value_skyline[i]-1]);
- value_skyline[i] = renumberingFromOldToNew[value_skyline[i]-1];
+ for (int i=0;i<numberOfLines_skyline;i++) {
+ for (int j=index_skyline[i]; j<index_skyline[i+1];j++) {
+ number->setIndexValue(j,renumberingFromOldToNew[number->getIndexValue(j)-1]);
+ }
}
MESSAGE(LOC<<"updating the family (END) : " << *myFamily);
}
+
+ delete oldConstituent ;
+ delete [] renumberingFromOldToNew;
}
+
END_OF(LOC);
- return ;
+ return;
}
//------------------------------------------------------------------------------------------------------------------//
-med_int * CONNECTIVITY::getConnectivity(medConnectivity ConnectivityType, medEntityMesh Entity, medGeometryElement Type)
+const med_int * CONNECTIVITY::getConnectivity(medConnectivity ConnectivityType, medEntityMesh Entity, medGeometryElement Type)
//------------------------------------------------------------------------------------------------------------------//
{
- const char * LOC = "CONNECTIVITY::getConnectivity" ;
+ const char * LOC = "CONNECTIVITY::getConnectivity";
BEGIN_OF(LOC);
- MEDSKYLINEARRAY * Connectivity ;
+ MEDSKYLINEARRAY * Connectivity;
if (Entity==_entity) {
if (ConnectivityType==MED_NODAL)
}
else
{
- calculateDescendingConnectivity() ;
+ calculateDescendingConnectivity();
Connectivity=_descending;
}
if (Connectivity!=NULL)
if (Type==MED_ALL_ELEMENTS)
- return Connectivity->getValue() ;
+ return Connectivity->getValue();
else {
for (med_int i=0; i<_numberOfTypes; i++)
if (_geometricTypes[i]==Type)
- return Connectivity->getI(_count[i]) ;
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Type not found !")) ;
+ //return Connectivity->getI(i+1);
+ return Connectivity->getI(_count[i]);
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Type not found !"));
}
else
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Connectivity not defined !")) ;
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Connectivity not defined !"));
} else
if (_constituent != NULL)
return _constituent->getConnectivity(ConnectivityType,Entity,Type);
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Entity not defined !")) ;
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Entity not defined !"));
}
/*! Give morse index array to use with
- In C mode : Connectivity[ConnectivityIndex[i]-1+j-1]
- In fortran mode : Connectivity[ConnectivityIndex[i]+j] */
//-----------------------------------------------------------------------------------------------//
-med_int * CONNECTIVITY::getConnectivityIndex(medConnectivity ConnectivityType, medEntityMesh Entity)
+const med_int * CONNECTIVITY::getConnectivityIndex(medConnectivity ConnectivityType, medEntityMesh Entity)
//------------------------------------------------------------------------------------------------//
{
- const char * LOC = "CONNECTIVITY::getConnectivityIndex" ;
+ const char * LOC = "CONNECTIVITY::getConnectivityIndex";
BEGIN_OF(LOC);
- MEDSKYLINEARRAY * Connectivity ;
+ MEDSKYLINEARRAY * Connectivity;
if (Entity==_entity) {
if (ConnectivityType==MED_NODAL)
Connectivity=_descending;
if (Connectivity!=NULL)
- return Connectivity->getIndex() ;
+ return Connectivity->getIndex();
else
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Connectivity not defined !")) ;
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Connectivity not defined !"));
} else
if (_constituent != NULL)
return _constituent->getConnectivityIndex(ConnectivityType,Entity);
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Entity not defined !")) ;
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Entity not defined !"));
}
/*! A DOCUMENTER */
//--------------------------------------------------------------//
-CELLMODEL & CONNECTIVITY::getType(medGeometryElement Type) const
+const CELLMODEL & CONNECTIVITY::getType(medGeometryElement Type) const
//--------------------------------------------------------------//
{
- const char * LOC = "CONNECTIVITY::getType" ;
+ const char * LOC = "CONNECTIVITY::getType";
BEGIN_OF(LOC);
if ((Type==MED_ALL_ELEMENTS) || (Type==MED_NONE))
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : medGeometryElement must be different of MED_ALL_ELEMENTS and MED_NONE !")) ;
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : medGeometryElement must be different of MED_ALL_ELEMENTS and MED_NONE !"));
for (med_int i=0; i<_numberOfTypes; i++)
if (_geometricTypes[i]==Type)
- return _type[i] ;
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : medGeometryElement not found !")) ;
+ return _type[i];
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : medGeometryElement not found !"));
}
/*! Returns the number of elements of type <med geometrie element>.
med_int CONNECTIVITY::getNumberOfNodesInType(medGeometryElement Type) const
//------------------------------------------------------------------------//
{
- const char * LOC = "CONNECTIVITY::getNumberOfNodesInType" ;
+ const char * LOC = "CONNECTIVITY::getNumberOfNodesInType";
BEGIN_OF(LOC);
if ((Type==MED_ALL_ELEMENTS) || (Type==MED_NONE))
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : medGeometryElement must be different of MED_ALL_ELEMENTS and MED_NONE!")) ;
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : medGeometryElement must be different of MED_ALL_ELEMENTS and MED_NONE!"));
for (med_int i=0; i<_numberOfTypes; i++)
if (_geometricTypes[i]==Type)
- return _type[i].getNumberOfNodes() ;
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : medGeometryElement not found !")) ;
+ return _type[i].getNumberOfNodes();
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : medGeometryElement not found !"));
}
/*! Returns the number of geometric sub cells of <med geometrie element> type.
//------------------------------------------------------------------------//
{
if ((Type==MED_ALL_ELEMENTS) || (Type==MED_NONE))
- throw MEDEXCEPTION("CONNECTIVITY::getNumberOfSubCell : medGeometryElement must be different of MED_ALL_ELEMENTS and MED_NONE!") ;
+ throw MEDEXCEPTION("CONNECTIVITY::getNumberOfSubCell : medGeometryElement must be different of MED_ALL_ELEMENTS and MED_NONE!");
for (med_int i=0; i<_numberOfTypes; i++)
if (_geometricTypes[i]==Type)
- return _type[i].getNumberOfConstituents(1) ;
- throw MEDEXCEPTION("CONNECTIVITY::getNumberOfSubCell : medGeometryElement not found !") ;
+ return _type[i].getNumberOfConstituents(1);
+ throw MEDEXCEPTION("CONNECTIVITY::getNumberOfSubCell : medGeometryElement not found !");
}
/*! Returns the number of elements of type <med geometrie element>.
med_int CONNECTIVITY::getNumberOf(medEntityMesh Entity, medGeometryElement Type) const
//-----------------------------------------------------------------------------------//
{
- const char * LOC = "CONNECTIVITY::getNumberOf" ;
+ const char * LOC = "CONNECTIVITY::getNumberOf";
BEGIN_OF(LOC);
MESSAGE(LOC<<" Entity = "<< Entity << ", _entity = "<<_entity);
if (Entity==_entity) {
if (Type==MED_NONE)
- return 0 ; // not defined !
+ return 0; // not defined !
//throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : medGeometryElement must be different of MED_NONE"));
if (Type==MED_ALL_ELEMENTS)
return _count[_numberOfTypes]-1;
if (_constituent != NULL)
return _constituent->getNumberOf(Entity,Type);
- return 0 ; // valid if they are nothing else !
- //throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Entity not defined !")) ;
+ return 0; // valid if they are nothing else !
+ //throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Entity not defined !"));
}
/*! A DOCUMENTER */
//--------------------------------------------------------------//
-med_int* CONNECTIVITY::getValue(medConnectivity TypeConnectivity,
+const med_int* CONNECTIVITY::getValue(medConnectivity TypeConnectivity,
medGeometryElement Type)
//--------------------------------------------------------------//
{
/*! A DOCUMENTER */
//---------------------------------------------------------------------//
-med_int* CONNECTIVITY:: getValueIndex(medConnectivity TypeConnectivity)
+const med_int* CONNECTIVITY:: getValueIndex(medConnectivity TypeConnectivity)
//---------------------------------------------------------------------//
{
if (TypeConnectivity == MED_NODAL)
/*! Not yet implemented */
//----------------------------------------------//
-med_int* CONNECTIVITY:: getNeighbourhood() const
+const med_int* CONNECTIVITY:: getNeighbourhood() const
//----------------------------------------------//
{
throw MEDEXCEPTION("CONNECTIVITY::getNeighbourhood : Not implemented");
/*! Returns an array which contains, for each node, all cells
arround it. */
//-------------------------------------------------//
-med_int* CONNECTIVITY::getReverseNodalConnectivity()
+const med_int* CONNECTIVITY::getReverseNodalConnectivity()
//-------------------------------------------------//
{
calculateReverseNodalConnectivity();
/*! Give index array to use with getReverseConnectivity(MED_NODAL).
It is unusefull with MED_DESCENDING mode, because we have allways two cells. */
//-------------------------------------------------------//
-med_int* CONNECTIVITY::getReverseNodalConnectivityIndex()
+const med_int* CONNECTIVITY::getReverseNodalConnectivityIndex()
//-------------------------------------------------------//
{
calculateReverseNodalConnectivity();
the 2 cells of each side. First is cell which face normal is outgoing.
arround it. */
//------------------------------------------------------//
-med_int* CONNECTIVITY::getReverseDescendingConnectivity()
+const med_int* CONNECTIVITY::getReverseDescendingConnectivity()
//------------------------------------------------------//
{
// it is in _constituent connectivity only if we are in MED_CELL
/*! calculate the reverse descending Connectivity
and returns the index ( A DOCUMENTER MIEUX)*/
//-----------------------------------------------------------//
-med_int* CONNECTIVITY::getReverseDescendingConnectivityIndex()
+const med_int* CONNECTIVITY::getReverseDescendingConnectivityIndex()
//-----------------------------------------------------------//
{
// it is in _constituent connectivity only if we are in MED_CELL
void CONNECTIVITY::calculateReverseNodalConnectivity()
//---------------------------------------------------//
{
- const char * LOC = "CONNECTIVITY::calculateReverseNodalConnectivity : " ;
- BEGIN_OF(LOC) ;
+ const char * LOC = "CONNECTIVITY::calculateReverseNodalConnectivity : ";
+ BEGIN_OF(LOC);
if (_nodal==NULL)
- calculateNodalConnectivity() ;
+ calculateNodalConnectivity();
- MESSAGE(LOC<<"Number of nodes = "<<_numberOfNodes);
-
if(_reverseNodalConnectivity==NULL) {
med_int node_number = 0;
// treat all cells of a particular type
for (med_int k = _count[j]; k < _count[j+1]; k++)
// treat all nodes of the cell type
- for (med_int local_node_number = 1 ; local_node_number < node_number+1; local_node_number++)
+ for (med_int local_node_number = 1; local_node_number < node_number+1; local_node_number++)
{
- med_int global_node = _nodal->getIJ(k,local_node_number) ;
+ med_int global_node = _nodal->getIJ(k,local_node_number);
reverse_connectivity[global_node].push_back(k);
}
}
for (med_int i = 1; i < _numberOfNodes+1; i++)
size_reverse_nodal_connectivity += reverse_connectivity[i].size();
- MEDSKYLINEARRAY * ReverseConnectivity = new MEDSKYLINEARRAY(_numberOfNodes,size_reverse_nodal_connectivity) ;
- // reverse_nodal_connectivity_index = new (med_int)[_numberOfNodes+1];
- // reverse_nodal_connectivity = new (med_int)[size_reverse_nodal_connectivity];
- med_int * reverse_nodal_connectivity = ReverseConnectivity->getValue() ;
- med_int * reverse_nodal_connectivity_index = ReverseConnectivity->getIndex() ;
+ //MEDSKYLINEARRAY * ReverseConnectivity = new MEDSKYLINEARRAY(_numberOfNodes,size_reverse_nodal_connectivity);
+ med_int * reverse_nodal_connectivity_index = new (med_int)[_numberOfNodes+1];
+ med_int * reverse_nodal_connectivity = new (med_int)[size_reverse_nodal_connectivity];
+ //const med_int * reverse_nodal_connectivity = ReverseConnectivity->getValue();
+ //const med_int * reverse_nodal_connectivity_index = ReverseConnectivity->getIndex();
reverse_nodal_connectivity_index[0] = 1;
for (med_int i = 1; i < _numberOfNodes+1; i++)
{
med_int size = reverse_connectivity[i].size();
- reverse_nodal_connectivity_index[i] = reverse_nodal_connectivity_index[i-1] + size ;
+ reverse_nodal_connectivity_index[i] = reverse_nodal_connectivity_index[i-1] + size;
for (med_int j = 0; j < size; j++)
reverse_nodal_connectivity[reverse_nodal_connectivity_index[i-1]-1+j]= reverse_connectivity[i][j];
}
- _reverseNodalConnectivity = ReverseConnectivity ;
-
- }
+ //_reverseNodalConnectivity = ReverseConnectivity;
+ _reverseNodalConnectivity = new MEDSKYLINEARRAY(_numberOfNodes,size_reverse_nodal_connectivity,
+ reverse_nodal_connectivity_index,
+ reverse_nodal_connectivity);
+ delete[] reverse_nodal_connectivity_index;
+ delete[] reverse_nodal_connectivity;
+ }
}
/*! If not yet done, calculate the Descending Connectivity */
MESSAGE(LOC<<": No descending connectivity defined, but constituent exist !");
if (_entityDimension == 3)
- _constituent = new CONNECTIVITY(MED_FACE) ;
+ _constituent = new CONNECTIVITY(MED_FACE);
else if (_entityDimension == 2)
- _constituent = new CONNECTIVITY(MED_EDGE) ;
+ _constituent = new CONNECTIVITY(MED_EDGE);
else {
MESSAGE(LOC<<"We are in 1D");
return;
}
- _constituent->_typeConnectivity = MED_DESCENDING ;
- _constituent->_numberOfNodes = _numberOfNodes ;
+ _constituent->_typeConnectivity = MED_NODAL;
+ _constituent->_numberOfNodes = _numberOfNodes;
// foreach cells, we built array of constituent
- int DescendingSize = 0 ;
+ int DescendingSize = 0;
for(int i=0; i<_numberOfTypes; i++)
- DescendingSize+=(_count[i+1]-_count[i])*_type[i].getNumberOfConstituents(1) ;
- _descending = new MEDSKYLINEARRAY(_count[_numberOfTypes]-1,DescendingSize) ;
- int * descend_connectivity = _descending->getValue() ;
+ DescendingSize+=(_count[i+1]-_count[i])*_type[i].getNumberOfConstituents(1);
+ //_descending = new MEDSKYLINEARRAY(_count[_numberOfTypes]-1,DescendingSize);
+ //const int * descend_connectivity = _descending->getValue();
+ int * descend_connectivity = new int[DescendingSize];
for (int i=0; i<DescendingSize; i++)
descend_connectivity[i]=0;
- int * descend_connectivity_index = _descending->getIndex() ;
+ //const int * descend_connectivity_index = _descending->getIndex();
+ int * descend_connectivity_index = new int[_count[_numberOfTypes]];
descend_connectivity_index[0]=1;
medGeometryElement* ConstituentsTypes = new medGeometryElement[2];
- ConstituentsTypes[0]=MED_NONE ;
- ConstituentsTypes[1]=MED_NONE ;
+ ConstituentsTypes[0]=MED_NONE;
+ ConstituentsTypes[1]=MED_NONE;
int * NumberOfConstituentsForeachType = new int[2];
NumberOfConstituentsForeachType[0]=0;
NumberOfConstituentsForeachType[1]=0;
for(int i=0; i<_numberOfTypes; i++) {
// initialize descend_connectivity_index array :
- int NumberOfConstituents = _type[i].getNumberOfConstituents(1) ;
+ int NumberOfConstituents = _type[i].getNumberOfConstituents(1);
for (int j=_count[i];j<_count[i+1];j++){
- descend_connectivity_index[j]=descend_connectivity_index[j-1]+NumberOfConstituents ;
+ descend_connectivity_index[j]=descend_connectivity_index[j-1]+NumberOfConstituents;
// compute number of constituent of all cell for each type
for(int k=1;k<NumberOfConstituents+1;k++) {
- medGeometryElement MEDType = _type[i].getConstituentType(1,k) ;
+ medGeometryElement MEDType = _type[i].getConstituentType(1,k);
if (ConstituentsTypes[0]==MED_NONE) {
ConstituentsTypes[0]=MEDType;
- NumberOfConstituentsForeachType[0]++ ;
+ NumberOfConstituentsForeachType[0]++;
} else if (ConstituentsTypes[0]==MEDType)
- NumberOfConstituentsForeachType[0]++ ;
+ NumberOfConstituentsForeachType[0]++;
else if (ConstituentsTypes[1]==MED_NONE) {
ConstituentsTypes[1]=MEDType;
- NumberOfConstituentsForeachType[1]++ ;
+ NumberOfConstituentsForeachType[1]++;
} else if (ConstituentsTypes[1]==MEDType)
- NumberOfConstituentsForeachType[1]++ ;
+ NumberOfConstituentsForeachType[1]++;
else
throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<MEDType<<" is different of "<<ConstituentsTypes[0]<<" and "<<ConstituentsTypes[1]));
}
}
// we could built _constituent !
- int TotalNumberOfConstituents = NumberOfConstituentsForeachType[0]+NumberOfConstituentsForeachType[1] ;
- int TotalNumberOfNodes = NumberOfConstituentsForeachType[0]*(ConstituentsTypes[0]%100)+NumberOfConstituentsForeachType[1]*(ConstituentsTypes[1]%100) ;
- _constituent->_nodal = new MEDSKYLINEARRAY(TotalNumberOfConstituents,TotalNumberOfNodes) ;
+ int TotalNumberOfConstituents = NumberOfConstituentsForeachType[0]+NumberOfConstituentsForeachType[1];
+ int TotalNumberOfNodes = NumberOfConstituentsForeachType[0]*(ConstituentsTypes[0]%100)+NumberOfConstituentsForeachType[1]*(ConstituentsTypes[1]%100);
+
+ //_constituent->_nodal = new MEDSKYLINEARRAY(TotalNumberOfConstituents,TotalNumberOfNodes);
// we use _constituent->_nodal
- int * ConstituentNodalConnectivity = _constituent->_nodal->getValue();
- int * ConstituentNodalConnectivityIndex = _constituent->_nodal->getIndex();
+ //const int * ConstituentNodalConnectivity = _constituent->_nodal->getValue();
+ //const int * ConstituentNodalConnectivityIndex = _constituent->_nodal->getIndex();
+ int * ConstituentNodalConnectivity = new int[TotalNumberOfNodes];
+ int * ConstituentNodalConnectivityIndex = new int[TotalNumberOfConstituents+1];
ConstituentNodalConnectivityIndex[0]=1;
_constituent->_entityDimension=ConstituentsTypes[0]/100;
if (ConstituentsTypes[1]==MED_NONE)
- _constituent->_numberOfTypes = 1 ;
+ _constituent->_numberOfTypes = 1;
else
- _constituent->_numberOfTypes = 2 ;
- _constituent->_geometricTypes = new medGeometryElement[_constituent->_numberOfTypes] ;
- _constituent->_type = new CELLMODEL[_constituent->_numberOfTypes] ;
- _constituent->_count = new med_int[_constituent->_numberOfTypes+1] ;
+ _constituent->_numberOfTypes = 2;
+ _constituent->_geometricTypes = new medGeometryElement[_constituent->_numberOfTypes];
+ _constituent->_type = new CELLMODEL[_constituent->_numberOfTypes];
+ _constituent->_count = new med_int[_constituent->_numberOfTypes+1];
_constituent->_count[0]=1;
- int* tmp_NumberOfConstituentsForeachType = new med_int[_constituent->_numberOfTypes+1] ;
+ int* tmp_NumberOfConstituentsForeachType = new med_int[_constituent->_numberOfTypes+1];
tmp_NumberOfConstituentsForeachType[0]=0; // to count constituent of each type
for (int i=0; i<_constituent->_numberOfTypes;i++) {
- _constituent->_geometricTypes[i]=ConstituentsTypes[i] ;
- _constituent->_count[i+1]=_constituent->_count[i]+NumberOfConstituentsForeachType[i] ;
+ _constituent->_geometricTypes[i]=ConstituentsTypes[i];
+ _constituent->_count[i+1]=_constituent->_count[i]+NumberOfConstituentsForeachType[i];
CELLMODEL Type(ConstituentsTypes[i]);
_constituent->_type[i]=Type;
- tmp_NumberOfConstituentsForeachType[i+1]=NumberOfConstituentsForeachType[i] ;
+ tmp_NumberOfConstituentsForeachType[i+1]=NumberOfConstituentsForeachType[i];
for (int j=tmp_NumberOfConstituentsForeachType[i]; j<tmp_NumberOfConstituentsForeachType[i+1]+tmp_NumberOfConstituentsForeachType[i]; j++)
- ConstituentNodalConnectivityIndex[j+1]=ConstituentNodalConnectivityIndex[j]+(ConstituentsTypes[i]%100) ;
+ ConstituentNodalConnectivityIndex[j+1]=ConstituentNodalConnectivityIndex[j]+(ConstituentsTypes[i]%100);
}
delete[] ConstituentsTypes;
- delete[] NumberOfConstituentsForeachType ;
+ delete[] NumberOfConstituentsForeachType;
// we need reverse nodal connectivity
if (! _reverseNodalConnectivity)
- calculateReverseNodalConnectivity() ;
- int * ReverseNodalConnectivityIndex = _reverseNodalConnectivity->getIndex();
- int * ReverseNodalConnectivityValue = _reverseNodalConnectivity->getValue();
+ calculateReverseNodalConnectivity();
+ const int * ReverseNodalConnectivityIndex = _reverseNodalConnectivity->getIndex();
+ const int * ReverseNodalConnectivityValue = _reverseNodalConnectivity->getValue();
// array to keep reverse descending connectivity
int * ReverseDescendingConnectivityValue = new int[TotalNumberOfConstituents*2];
- int TotalNumberOfSubCell = 0 ;
+ int TotalNumberOfSubCell = 0;
for (int i=0; i<_numberOfTypes; i++) { // loop on all cell type
- CELLMODEL Type = _type[i] ;
- int NumberOfNodesPerCell = Type.getNumberOfNodes() ;
+ CELLMODEL Type = _type[i];
+ int NumberOfNodesPerCell = Type.getNumberOfNodes();
int NumberOfConstituentPerCell = Type.getNumberOfConstituents(1);
for (int j=_count[i]; j<_count[i+1]; j++) // we loop on all cell of this type
- for (int k=1 ; k<=NumberOfConstituentPerCell; k++) { // we loop on all sub cell of it
+ for (int k=1; k<=NumberOfConstituentPerCell; k++) { // we loop on all sub cell of it
if (descend_connectivity[descend_connectivity_index[j-1]+k-2]==0) {
// it is a new sub cell !
// TotalNumberOfSubCell++;
//we have maximum two types
descend_connectivity[descend_connectivity_index[j-1]+k-2]=TotalNumberOfSubCell;
- ReverseDescendingConnectivityValue[(TotalNumberOfSubCell-1)*2]=j ;
- int NumberOfNodesPerConstituent = Type.getConstituentType(1,k)%100 ;
+ ReverseDescendingConnectivityValue[(TotalNumberOfSubCell-1)*2]=j;
+ int NumberOfNodesPerConstituent = Type.getConstituentType(1,k)%100;
- int * NodesLists = new int[NumberOfNodesPerConstituent] ;
+ int * NodesLists = new int[NumberOfNodesPerConstituent];
for (int l=0; l<NumberOfNodesPerConstituent; l++) {
NodesLists[l]=_nodal->getIJ(j,Type.getNodeConstituent(1,k,l+1));
ConstituentNodalConnectivity[ConstituentNodalConnectivityIndex[TotalNumberOfSubCell-1]-1+l]=NodesLists[l];
// we use reverse_nodal_connectivity to find the other element which contain this sub cell
// all elements which contains first node of sub cell :
- int ReverseNodalConnectivityIndex_0 = ReverseNodalConnectivityIndex[NodesLists[0]-1] ;
- int ReverseNodalConnectivityIndex_1 = ReverseNodalConnectivityIndex[NodesLists[0]] ;
- int NumberOfCellsInList = ReverseNodalConnectivityIndex_1-ReverseNodalConnectivityIndex_0 ;
+ int ReverseNodalConnectivityIndex_0 = ReverseNodalConnectivityIndex[NodesLists[0]-1];
+ int ReverseNodalConnectivityIndex_1 = ReverseNodalConnectivityIndex[NodesLists[0]];
+ int NumberOfCellsInList = ReverseNodalConnectivityIndex_1-ReverseNodalConnectivityIndex_0;
if (NumberOfCellsInList > 0) { // we could have no element !
- int * CellsList = new int[NumberOfCellsInList] ;
+ int * CellsList = new int[NumberOfCellsInList];
for (int l=ReverseNodalConnectivityIndex_0; l<ReverseNodalConnectivityIndex_1; l++)
- CellsList[l-ReverseNodalConnectivityIndex_0]=ReverseNodalConnectivityValue[l-1] ;
+ CellsList[l-ReverseNodalConnectivityIndex_0]=ReverseNodalConnectivityValue[l-1];
// foreach node in sub cell, we search elements which are in common
// at the end, we must have only one !
for (int l=1; l<NumberOfNodesPerConstituent; l++) {
- int NewNumberOfCellsInList = 0 ;
- int * NewCellsList = new int[NumberOfCellsInList] ;
+ int NewNumberOfCellsInList = 0;
+ int * NewCellsList = new int[NumberOfCellsInList];
for (int l1=0; l1<NumberOfCellsInList; l1++)
for (int l2=ReverseNodalConnectivityIndex[NodesLists[l]-1]; l2<ReverseNodalConnectivityIndex[NodesLists[l]]; l2++) {
if (CellsList[l1]<ReverseNodalConnectivityValue[l2-1])
// increasing order : CellsList[l1] are not in elements list of node l
- break ;
+ break;
if ((CellsList[l1]==ReverseNodalConnectivityValue[l2-1])&(CellsList[l1]!=j)) {
// we have found one
NewCellsList[NewNumberOfCellsInList]=CellsList[l1];
}
NumberOfCellsInList = NewNumberOfCellsInList;
- delete [] CellsList ;
+ delete [] CellsList;
CellsList = NewCellsList;
}
if (NumberOfCellsInList > 0) { // We have found some elements !
- int CellNumber = CellsList[0] ;
- delete [] CellsList ;
+ int CellNumber = CellsList[0];
+ //delete [] CellsList;
if (NumberOfCellsInList>1)
throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"More than one other Cell ("<<NumberOfCellsInList<<") !"));
if (NumberOfCellsInList==1) {
- ReverseDescendingConnectivityValue[(TotalNumberOfSubCell-1)*2+1]=CellNumber ;
+ ReverseDescendingConnectivityValue[(TotalNumberOfSubCell-1)*2+1]=CellNumber;
// we search sub cell number in this cell to not calculate it another time
// which type ?
- CELLMODEL Type2 ;
+ CELLMODEL Type2;
for (int l=0; l<_numberOfTypes; l++)
if (CellNumber < _count[l+1]) {
- Type2=_type[l] ;
- break ;
+ Type2=_type[l];
+ break;
}
- //int sub_cell_count2 = Type2.get_entities_count(1) ;
- //int nodes_cell_count2 = Type2.get_nodes_count() ;
- bool find2 = false ;
- for (int l=1; l<=Type2.getNumberOfConstituents(1) ;l++) { // on all sub cell
- int counter = 0 ;
+ //int sub_cell_count2 = Type2.get_entities_count(1);
+ //int nodes_cell_count2 = Type2.get_nodes_count();
+ bool find2 = false;
+ for (int l=1; l<=Type2.getNumberOfConstituents(1);l++) { // on all sub cell
+ int counter = 0;
for (int m=1; m<=Type2.getConstituentType(1,l)%100; m++)
for (int n=1; n<=Type.getConstituentType(1,k)%100; n++) {
if (_nodal->getIJ(CellNumber,Type2.getNodeConstituent(1,l,m)) == NodesLists[n-1])
- counter++ ;
+ counter++;
}
if (counter==Type.getConstituentType(1,k)%100) {
descend_connectivity[descend_connectivity_index[CellNumber-1]+l-2]=-1*TotalNumberOfSubCell; // because, see it in other side !
- find2 = true ;
+ find2 = true;
}
if (find2)
- break ;
+ break;
}
if (!find2)
- INFOS(LOC<<"ERROR ERROR ERROR ERROR ERROR : we find any subcell !!!") ; // exception ?
+ INFOS(LOC<<"ERROR ERROR ERROR ERROR ERROR : we find any subcell !!!"); // exception ?
}
} else {
- ReverseDescendingConnectivityValue[(TotalNumberOfSubCell-1)*2+1]=0 ;
+ ReverseDescendingConnectivityValue[(TotalNumberOfSubCell-1)*2+1]=0;
}
+ delete[] CellsList;
}
- delete[] NodesLists ;
+
+ delete[] NodesLists;
}
}
}
// we adjust _constituent
- int NumberOfConstituent=0 ;
- int SizeOfConstituentNodal=0 ;
+ int NumberOfConstituent=0;
+ int SizeOfConstituentNodal=0;
for (int i=0;i<_constituent->_numberOfTypes; i++) {
NumberOfConstituent += tmp_NumberOfConstituentsForeachType[i]-_constituent->_count[i]+1;
SizeOfConstituentNodal += (tmp_NumberOfConstituentsForeachType[i]-_constituent->_count[i]+1)*_constituent->_type[i].getNumberOfNodes();
}
// we built new _nodal attribute in _constituent
- MEDSKYLINEARRAY *ConstituentNodal = new MEDSKYLINEARRAY(NumberOfConstituent,SizeOfConstituentNodal);
- int *ConstituentNodalValue = ConstituentNodal->getValue();
- int *ConstituentNodalIndex = ConstituentNodal->getIndex();
+ //MEDSKYLINEARRAY *ConstituentNodal = new MEDSKYLINEARRAY(NumberOfConstituent,SizeOfConstituentNodal);
+ //const int *ConstituentNodalValue = ConstituentNodal->getValue();
+ //const int *ConstituentNodalIndex = ConstituentNodal->getIndex();
+ int *ConstituentNodalValue = new int[SizeOfConstituentNodal];
+ int *ConstituentNodalIndex = new int[NumberOfConstituent+1];
ConstituentNodalIndex[0]=1;
// we build _reverseDescendingConnectivity
- _reverseDescendingConnectivity = new MEDSKYLINEARRAY(NumberOfConstituent,2*NumberOfConstituent) ;
- int *reverseDescendingConnectivityValue = _reverseDescendingConnectivity->getValue();
- int *reverseDescendingConnectivityIndex = _reverseDescendingConnectivity->getIndex();
+ //_reverseDescendingConnectivity = new MEDSKYLINEARRAY(NumberOfConstituent,2*NumberOfConstituent);
+ //const int *reverseDescendingConnectivityValue = _reverseDescendingConnectivity->getValue();
+ //const int *reverseDescendingConnectivityIndex = _reverseDescendingConnectivity->getIndex();
+ int *reverseDescendingConnectivityValue = new int[2*NumberOfConstituent];
+ int *reverseDescendingConnectivityIndex = new int[NumberOfConstituent+1];
reverseDescendingConnectivityIndex[0]=1;
// first constituent type
}
// second type if any
if (_constituent->_numberOfTypes==2) {
- int offset = _constituent->_count[1]-tmp_NumberOfConstituentsForeachType[0]-1 ;
+ int offset = _constituent->_count[1]-tmp_NumberOfConstituentsForeachType[0]-1;
int offset1=offset*_constituent->_type[0].getNumberOfNodes();
- int offset2=offset*2 ;
+ int offset2=offset*2;
int NumberOfNodesPerConstituent = _constituent->_type[1].getNumberOfNodes();
for(int j=tmp_NumberOfConstituentsForeachType[0]; j<NumberOfConstituent; j++) {
ConstituentNodalIndex[j+1]=ConstituentNodalIndex[j]+NumberOfNodesPerConstituent;
reverseDescendingConnectivityValue[k-1]=ReverseDescendingConnectivityValue[offset2+k-1];
}
}
- _constituent->_count[2]=NumberOfConstituent+1 ;
+ _constituent->_count[2]=NumberOfConstituent+1;
// we correct _descending to adjust face number
for(int j=0;j<DescendingSize;j++)
if (descend_connectivity[j]>tmp_NumberOfConstituentsForeachType[0])
descend_connectivity[j]-=offset;
}
+
+ delete[] ConstituentNodalConnectivityIndex;
+ delete[] ConstituentNodalConnectivity;
+
+ _descending = new MEDSKYLINEARRAY(_count[_numberOfTypes]-1,
+ DescendingSize,
+ descend_connectivity_index,
+ descend_connectivity);
+ delete[] descend_connectivity_index;
+ delete[] descend_connectivity;
+ _reverseDescendingConnectivity = new MEDSKYLINEARRAY(NumberOfConstituent,
+ 2*NumberOfConstituent,
+ reverseDescendingConnectivityIndex,
+ reverseDescendingConnectivityValue);
+ delete[] reverseDescendingConnectivityIndex;
+ delete[] reverseDescendingConnectivityValue;
+
_constituent->_count[1]=tmp_NumberOfConstituentsForeachType[0]+1;
- delete _constituent->_nodal ;
- _constituent->_nodal = ConstituentNodal ;
+ delete[] tmp_NumberOfConstituentsForeachType;
+
+ //delete _constituent->_nodal;
+ _constituent->_nodal = new MEDSKYLINEARRAY(NumberOfConstituent,
+ SizeOfConstituentNodal,
+ ConstituentNodalIndex,
+ ConstituentNodalValue);
- delete[] ReverseDescendingConnectivityValue ;
+ delete[] ConstituentNodalIndex;
+ delete[] ConstituentNodalValue;
+
+ delete[] ReverseDescendingConnectivityValue;
}
END_OF(LOC);
}
// if (myConnectivity->getEntity()!=MED_CELL)
// throw MEDEXCEPTION("CONNECTIVITY::calculateReverseDescending
// Connectivity : we need MED_CELL connectivity !");
-// return ;
+// return;
// }
/*! Not implemented yet */
//--------------------------------------------------------------------//
{
// Mesh dimension !
- return ;
+ return;
}
Give, for one element number of a specified entity the geometric type
Of this element.
- Example : medGeometryElement myType = myConnectivity.getElementType(MED_CELL,35) ;
+ Example : medGeometryElement myType = myConnectivity.getElementType(MED_CELL,35);
*/
//--------------------------------------------------------------------//
medGeometryElement CONNECTIVITY::getElementType(medEntityMesh Entity,int Number) const
if (_entity==Entity) {
for(int i=1; i<=_numberOfTypes;i++)
if (Number<_count[i])
- return _geometricTypes[i-1] ;
+ return _geometricTypes[i-1];
}
else if (_constituent!=NULL)
- return _constituent->getElementType(Entity,Number) ;
+ return _constituent->getElementType(Entity,Number);
else
- throw MEDEXCEPTION(LOCALIZED("getElementType : Entity not defined !")) ;
- throw MEDEXCEPTION(LOCALIZED("getElementType : Wrong Number !")) ;
+ throw MEDEXCEPTION(LOCALIZED("getElementType : Entity not defined !"));
+ throw MEDEXCEPTION(LOCALIZED("getElementType : Wrong Number !"));
}
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_Coordinate.hxx
+// Module : MED
+
/*
File Coordinate.hxx
$Header$
#include "MEDMEM_PointerOf.hxx"
#include "MEDMEM_Exception.hxx"
#include "MEDMEM_define.hxx"
-//using namespace MED_EN;
#include "MEDMEM_Array.hxx"
-class COORDINATE {
+/*!
+ This class contains coordinates of the nodes ./n
+ It could also store useful optional information about nodes
+ as node numbers and about axes as names or units. /n
+ spaceDimension and numberOfNodes can be found in _coordinate object.
+*/
+
+class COORDINATE
+{
protected:
/*! contains "CARTESIAN",
"CYLINDRICAL" or "SPHERICAL"*/
- string _coordinateSystem;
+ string _coordinateSystem;
+
- // all in _coordinate object !!!
- // int _spaceDimension;
- // int _numberOfNodes;
+ /*! _coordinate is a MEDARRAY<double> object : \n
+ - spaceDimension /n
+ - numberOfNodes /n
+ - default storage mode /n
+ - Up to 4 "PointerOf" to an array of size spaceDimension*NumberOfNodes/n
- /*! array of size spaceDimension*NumberOfNodes */
- //PointerOf< MEDARRAY<double> > _coordinate;
- //bool _allocateCoordinate;
- MEDARRAY<double>* _coordinate;
+ Storing the object (not a pointer to this object) is more convenient for memory
+ management.
+ */
+ MEDARRAY<double> _coordinate;
- /*! array of size spaceDimension */
- PointerOf<string> _coordinateName;
- //string * _coordinateName;
+ /*! PointerOf to an array of size spaceDimension storing axes names*/
+ PointerOf<string> _coordinateName;
- /*! array of size spaceDimension */
- PointerOf<string> _coordinateUnit;
- //string * _coordinateUnit;
+ /*! PointerOf to an array of size spaceDimension storing units */
+ PointerOf<string> _coordinateUnit;
- /*! array of size NumberOfNodes : optionnal nodes numbers */
- PointerOf<int> _nodeNumber;
- //int * _nodeNumber;
+ /*! PointerOf to an array of size NumberOfNodes : optional nodes numbers */
+ PointerOf<int> _nodeNumber;
public :
COORDINATE();
- COORDINATE(medModeSwitch Mode,int SpaceDimension, int NumberOfNodes);
+ COORDINATE(int SpaceDimension, int NumberOfNodes, medModeSwitch Mode);
COORDINATE(const COORDINATE & m);
~COORDINATE();
void setCoordinates(MEDARRAY<double> *Coordinate);
- void setCoordinatesNames(string * CoordinateName);
- void setCoordinatesUnits(string * CoordinateUnit);
- void setCoordinatesSystem(string CoordinateSystem);
- void setNodesNumbers(int * NodeNumber);
-
- int* getNodesNumbers() const;
- int* getNodesNumbers() ;
+ void setCoordinates(const medModeSwitch Mode, const double *Coordinate);
+ void setCoordinatesNames(const string * CoordinateName);
+ void setCoordinateName(const string CoordinateName, const int i);
+ void setCoordinatesUnits(const string * CoordinateUnit);
+ void setCoordinateUnit(const string CoordinateUnit, const int i);
+ void setCoordinatesSystem(const string CoordinateSystem);
+ void setNodesNumbers(const int * NodeNumber);
+
+ int getSpaceDimension() const;
+ int getNumberOfNodes() const;
+
+ const int* getNodesNumbers() const;
+ //const int* getNodesNumbers() ;
string getCoordinatesSystem() const;
+
const double * getCoordinates(medModeSwitch Mode);
- double getCoordinate(int Number,int Axis);
- // return coordinate of node number Number, on axis Axis (1: X, 2: Y, 3: Z)
- const double * getCoordinateAxis(int Axis);
- // return all nodes coordinates from axis Axis
- string * getCoordinatesNames();
- string getCoordinateName(int Axis);
- string * getCoordinatesUnits();
- string getCoordinateUnit(int Axis);
+ double getCoordinate(int Number,int Axis);
+ const double * getCoordinateAxis(int Axis);
+
+ const string * getCoordinatesNames() const;
+ string getCoordinateName(int Axis) const;
+ const string * getCoordinatesUnits() const;
+ string getCoordinateUnit(int Axis) const;
};
#endif /* COORDINATE_HXX */
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_DriversDef.cxx
+// Module : MED
+
using namespace std;
#include "MEDMEM_DriversDef.hxx"
-namespace MED_FR {
+namespace MED_FR
+{
// Returns the (string) name of the geometry of
// an element given by a med_geometrie_element value
-GEO_NAME::GEO_NAME () : map<int,string>()
+GEO_NAME::GEO_NAME() : map<int,string>()
{
map<int,string> &table = (map<int,string>&)*this ;
table[(int)0 ] = "MED_NONE" ;
// Returns the (string) name of the type of
// an entity given by a med_entite_maillage value
-ENT_NAME:: ENT_NAME () : map<int,string>()
+ENT_NAME::ENT_NAME() : map<int,string>()
{
map<int,string> &table = (map<int,string>&)*this ;
table[(int)MED_MAILLE ] = "MED_MAILLE";
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_Family.hxx
+// Module : MED
+
#ifndef FAMILY_HXX
#define FAMILY_HXX
#include <string>
#include "MEDMEM_Support.hxx"
+/*!
+
+ This class describe a family of elements on an entity./n
+ It inherits from support. /n
+ It contains a list of elements (by SUPPORT class inheritance)
+ and a description of some attributs./n
+
+ All families on one entity represent a mesh partition for this entity.
+
+*/
+
class FAMILY : public SUPPORT
{
protected :
- /*! Identifier of the family in the mesh
- Note : There is precisely one for each family. */
+ /*!
+ \if developper
+ Identifier of the family in the mesh
+ Note : There is precisely one for each family.
+ \endif
+ */
int _identifier ;
- /*! Number of attribute of the family */
+ /*!
+ \if developper
+ Number of attribute of the family ./n
+ Note that attributes are numbered from 1 to N.
+ \endif
+ */
int _numberOfAttribute ;
- /*! Array of all attributes' identifiers.
- There is one for each attribute. */
+ /*!
+ \if developper
+ Array of all attributes' identifiers.
+ There is one for each attribute.
+ \endif
+ */
int * _attributeIdentifier ;
- /*! Array of all attributes' values.
- There is one for each attribute. */
+ /*!
+ \if developper
+ Array of all attributes' values.
+ There is one for each attribute.
+ \endif
+ */
int * _attributeValue ;
- /*! Array of all attributes' descriptions.
- There is one for each attribute. */
+ /*!
+ \if developper
+ Array of all attributes' descriptions.
+ There is one for each attribute.
+ \endif
+ */
string * _attributeDescription ;
-
- /*! Number of the group the family belongs to */
+ /*!
+ \if developper
+ Number of the group the family belongs to.
+ \endif
+ */
int _numberOfGroup ;
- /*! Name of the group the family belongs to */
+ /*!
+ \if developper
+ Name of the group the family belongs to.
+ \endif
+ */
string * _groupName ;
public:
+ /*! Constructor. */
FAMILY();
+ /*!
+ \if developper
+ Constructor to use with med driver.
+ */
+ FAMILY( MESH* Mesh, int Identifier, string Name,
+ int NumberOfAttribute, int *AttributeIdentifier,
+ int *AttributeValue, string AttributeDescription,
+ int NumberOfGroup, string GroupName,
+ int * MEDArrayNodeFamily,
+ int ** MEDArrayCellFamily,
+ int ** MEDArrayFaceFamily,
+ int ** MEDArrayEdgeFamily
+ ) ;
- // constructor to use with med driver
- FAMILY(MESH* Mesh, int Identifier, string Name, int NumberOfAttribute,int *AttributeIdentifier,int *AttributeValue,string AttributeDescription,int NumberOfGroup,string GroupName) ;
+ /*! Copy Constructor. */
+ FAMILY(const FAMILY & m);
- FAMILY(FAMILY & m);
+ /*! Constructor with SUPPORT entry. */
+ FAMILY(const SUPPORT & s);
+ /*! Destructor. */
~FAMILY();
FAMILY & operator=(const FAMILY &fam);
+ friend ostream & operator<<(ostream &os, FAMILY &my) ;
+
+ bool build(medEntityMesh Entity,int **FamilyNumber);
inline void setIdentifier (int Identifier);
inline void setNumberOfAttributes (int NumberOfAttribute);
// inline methods :
-/* Set the attribute _identifier to Identifier. */
+/*! Sets the attribute _identifier to Identifier. */
//----------------------------------------------
inline void FAMILY::setIdentifier(int Identifier)
//----------------------------------------------
_identifier = Identifier;
}
-/* Set the attribute _numberOfAttribute to NumberOfAttribute. */
+/*! Sets the attribute _numberOfAttribute to NumberOfAttribute. */
//--------------------------------------------------------------
inline void FAMILY::setNumberOfAttributes(int NumberOfAttribute)
//--------------------------------------------------------------
_numberOfAttribute = NumberOfAttribute;
}
-/* Set the attribute _attributeIdentifier to AttributeIdentifier. */
+/*! Sets the attribute _attributeIdentifier to AttributeIdentifier. */
//---------------------------------------------------------------------
inline void FAMILY::setAttributesIdentifiers(int * AttributeIdentifier)
//---------------------------------------------------------------------
_attributeIdentifier = AttributeIdentifier ;
}
-/* Set the attribute _attributeValue to AttributeValue. */
+/*! Sets the attribute _attributeValue to AttributeValue. */
//-----------------------------------------------------------
inline void FAMILY::setAttributesValues(int * AttributeValue)
//-----------------------------------------------------------
_attributeValue = AttributeValue ;
}
-/* Set the attribute _identifier to Identifier. */
+/*! Sets the attribute _attributeDescription to AttributeDescription. */
//--------------------------------------------------------------------------
inline void FAMILY::setAttributesDescriptions(string * AttributeDescription)
//--------------------------------------------------------------------------
_attributeDescription = AttributeDescription ;
}
-/* Set the attribute _identifier to Identifier. */
+/*! Sets the attribute _numberOfGroup to NumberOfGroups. */
//-------------------------------------------------------
inline void FAMILY::setNumberOfGroups(int NumberOfGroups)
//-------------------------------------------------------
_numberOfGroup = NumberOfGroups ;
}
-/* Set the attribute _identifier to Identifier. */
+/*! Sets the attribute _groupName to GroupName. */
//----------------------------------------------------
inline void FAMILY::setGroupsNames(string * GroupName)
//----------------------------------------------------
{
_groupName = GroupName ;
}
+/*! Returns the attribute _identifier./n
+ Note that there is one identifier precisely for each family. */
//--------------------------------------
inline int FAMILY::getIdentifier() const
//--------------------------------------
{
return _identifier ;
}
+
+/*! Returns the number of attributes of the family. */
//----------------------------------------------
inline int FAMILY::getNumberOfAttributes() const
//----------------------------------------------
{
return _numberOfAttribute ;
}
+/*! Returns a pointer to attributes identifiers .
+ (There are _numberOfAttribute attributes) */
//---------------------------------------------------
inline int * FAMILY::getAttributesIdentifiers() const
//---------------------------------------------------
{
return _attributeIdentifier ;
}
+/*! Returns identifer of the Ith attribute of the family./n
+ Note that they are numbered from 1 to N */
//----------------------------------------------------
inline int FAMILY::getAttributeIdentifier(int i) const
//----------------------------------------------------
{
return _attributeIdentifier[i-1] ;
}
+/*! Returns a pointer to attributes values.
+ (There are _numberOfAttribute attributes)*/
//----------------------------------------------
inline int * FAMILY::getAttributesValues() const
//----------------------------------------------
{
return _attributeValue ;
}
+/*! Returns value of the Ith attribute of the family./n
+ Note that they are numbered from 1 to N */
//-----------------------------------------------
inline int FAMILY::getAttributeValue(int i) const
//-----------------------------------------------
{
return _attributeDescription ;
}
+/*! Returns description of the Ith attribute of the family/n
+ Note that they are numbered from 1 to N */
//--------------------------------------------------------
inline string FAMILY::getAttributeDescription(int i) const
//--------------------------------------------------------
{
return _attributeDescription[i-1] ;
}
+/*! Returns the number of groups the family belongs to.*/
//------------------------------------------
inline int FAMILY::getNumberOfGroups() const
//------------------------------------------
{
return _numberOfGroup;
}
+/*! Returns a pointer to the names of the groups the family belongs to */
//--------------------------------------------
inline string * FAMILY::getGroupsNames() const
//--------------------------------------------
{
return _groupName ;
}
+/*! Returns the name of the Ith group the family belongs to./n
+ Note that they are numbered from 1 to N*/
//---------------------------------------------
inline string FAMILY::getGroupName(int i) const
//---------------------------------------------
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_Field.hxx
+// Module : MED
+
/*
File Field.hxx
$Header$
using namespace MED_EN;
-//class GENDRIVER;
+/*!
+
+ This class contains all the informations related with a template class FIELD :
+ - Components descriptions
+ - Time step description
+ - Location of the values (a SUPPORT class)
+
+*/
+
class FIELD_ // GENERIC POINTER TO a template <class T> class FIELD
{
-
protected:
- string _name ;
- string _description ;
+ bool _isRead ;
+
+ /*!
+ \if developper
+ Field name.
+ \endif
+ */
+ string _name ;
+ /*!
+ \if developper
+ Field description.
+ \endif
+ */
+ string _description ;
+ /*!
+ \if developper
+ Pointer to the support the field deals with.
+ \endif
+ */
const SUPPORT * _support ;
- int _numberOfComponents ;
- int * _componentsTypes ; // array of size _numberOfComponents
- // (constant, scalar, vector, tensor)
- // we could use an array of integer to store
- // numbers of values
- // 1 for scalar,
- // space dimension for vector,
- // space dimension square for tensor.
- // so numbers of values per entities are
- // sum of _componentsTypes array
- // Do not use yet! All type are scalar !
- string * _componentsNames; // array of size _numberOfComponents
- string * _componentsDescriptions; // array of size _numberOfComponents
- UNIT * _componentsUnits; // array of size _numberOfComponents
- string * _MEDComponentsUnits; // array of size _numberOfComponents :
- // get unit from med file
-
- int _iterationNumber ;
- double _time;
- int _orderNumber ;
-
- /*MED_EN::*/med_type_champ _valueType ;
+
+ /*!
+ \if developper
+ Number of field's components.
+ \endif
+ */
+ int _numberOfComponents ;
+ /*!
+ \if developper
+ Number of field's values.
+ \endif
+ */
+ int _numberOfValues ;
+
+ /*!
+ \if developper
+ Array of size _numberOfComponents. /n
+ (constant, scalar, vector, tensor)/n
+ We could use an array of integer to store
+ numbers of values: /n
+ - 1 for scalar,/n
+ - space dimension for vector,/n
+ - space dimension square for tensor./n
+ So numbers of values per entities would be
+ sum of _componentsTypes array.
+
+ Not implemented yet! All type are scalar !
+ \endif
+ */
+ int * _componentsTypes ;
+ /*!
+ \if developper
+ Array of size _numberOfComponents
+ storing components names if any.
+ \endif
+ */
+ string * _componentsNames;
+ /*!
+ \if developper
+ Array of size _numberOfComponents
+ storing components descriptions if any.
+ \endif
+ */
+ string * _componentsDescriptions;
+ /*!
+ \if developper
+ Array of size _numberOfComponents
+ storing components units if any.
+ \endif
+ */
+ UNIT * _componentsUnits;
+ /*!
+ \if developper
+ Array of size _numberOfComponents
+ storing components units if any.
+ \endif
+ */
+ string * _MEDComponentsUnits;
+ int _iterationNumber ;
+ double _time;
+ int _orderNumber ;
+
+ med_type_champ _valueType ;
+
+ vector<GENDRIVER *> _drivers; // Storage of the drivers currently in use
public:
-
+
+ friend class MED_MED_RDONLY_DRIVER;
+ friend class MED_MED_WRONLY_DRIVER;
+ friend class MED_MED_RDWR_DRIVER;
+
+ /*!
+ Constructor.
+ */
FIELD_ ();
+ /*!
+ Constructor.
+ */
FIELD_(const SUPPORT * Support, const int NumberOfComponents);
+ /*!
+ Copy constructor.
+ */
FIELD_(const FIELD_ &m);
+ /*!
+ Destructor.
+ */
~FIELD_();
// virtual void setIterationNumber (int IterationNumber);
-// virtual void setOrderNumber (int OrderNumber);
-// virtual void setFieldName (string& fieldName);
+// virtual void setOrderNumber (int OrderNumber);
+// virtual void setFieldName (string& fieldName);
virtual void rmDriver(int index);
- virtual int addDriver(driverTypes driverType,
- const string & fileName,
- const string & driverFieldName) ;
+ virtual int addDriver(driverTypes driverType,
+ const string & fileName="Default File Name.med",
+ const string & driverFieldName="Default Field Nam") ;
virtual int addDriver( GENDRIVER & driver);
- virtual void write(const GENDRIVER &);
virtual void read (const GENDRIVER &);
-
- // virtual void getValueType (MED_FR::med_type_champ ValueType) ;
- // virtual void setValueType (/*MED_EN::*/med_type_champ ValueType) ;
- // virtual med_type_champ getValueType () ;
+ virtual void read(int index=0);
+ virtual void write(const GENDRIVER &);
+ virtual void write(int index=0, const string & driverName="");
inline void setName(string Name);
inline string getName() const;
inline void setDescription(string Description);
- inline string getDescription()const;
+ inline string getDescription() const;
inline const SUPPORT * getSupport() const;
- inline void setSupport(SUPPORT * support);
+ inline void setSupport(SUPPORT * support);
inline void setNumberOfComponents(int NumberOfComponents);
inline int getNumberOfComponents() const;
+ inline void setNumberOfValues(int NumberOfValues);
+ inline int getNumberOfValues() const;
// inline void setComponentType(int *ComponentType);
// inline int * getComponentType() const;
// inline int getComponentTypeI(int i) const;
inline void setComponentsNames(string * ComponentsNames);
- inline void setComponentName(int i, string ComponentName);
- inline string * getComponentsNames() const;
+ inline void setComponentName(int i, string ComponentName);
+ inline const string * getComponentsNames() const;
inline string getComponentName(int i) const;
inline void setComponentsDescriptions(string *ComponentsDescriptions);
inline void setComponentDescription(int i, string ComponentDescription);
- inline string * getComponentsDescriptions() const;
+ inline const string * getComponentsDescriptions() const;
inline string getComponentDescription(int i) const;
// provisoire : en attendant de regler le probleme des unites !
inline void setComponentsUnits(UNIT * ComponentsUnits);
- inline UNIT * getComponentsUnits() const;
- inline UNIT * getComponentUnit(int i) const;
+ inline const UNIT * getComponentsUnits() const;
+ inline const UNIT * getComponentUnit(int i) const;
inline void setMEDComponentsUnits(string * MEDComponentsUnits);
inline void setMEDComponentUnit(int i, string MEDComponentUnit);
- inline string * getMEDComponentsUnits() const;
+ inline const string * getMEDComponentsUnits() const;
inline string getMEDComponentUnit(int i) const;
inline void setIterationNumber(int IterationNumber);
inline int getIterationNumber() const;
inline void setTime(double Time);
inline double getTime() const;
- inline void setOrderNumber(int OrderNumber);
+ inline void setOrderNumber(int OrderNumber);
inline int getOrderNumber() const;
- inline void setValueType (/*MED_EN::*/med_type_champ ValueType) ;
- inline /*MED_EN::*/med_type_champ getValueType () ;
+ inline void setValueType (med_type_champ ValueType) ;
+ inline med_type_champ getValueType () const;
};
// -----------------
// Methodes Inline
// -----------------
-
+/*!
+ Set FIELD name.
+*/
inline void FIELD_::setName(string Name)
{
_name=Name;
}
-inline string FIELD_::getName() const
+/*!
+ Get FIELD name.
+*/
+inline string FIELD_::getName() const
{
return _name;
}
+/*!
+ Set FIELD description.
+*/
inline void FIELD_::setDescription(string Description)
{
_description=Description;
}
-inline string FIELD_::getDescription() const
+/*!
+ Get FIELD description.
+*/
+inline string FIELD_::getDescription() const
{
return _description;
}
+/*!
+ Set FIELD number of components.
+*/
inline void FIELD_::setNumberOfComponents(int NumberOfComponents)
{
_numberOfComponents=NumberOfComponents;
-}
-inline int FIELD_::getNumberOfComponents() const
-{
- return _numberOfComponents ;
-}
-// inline void FIELD_::setComponentType(int *ComponentType)
-// {
-// _componentsTypes=ComponentType ;
+}
+/*!
+ Get FIELD number of components.
+*/
+inline int FIELD_::getNumberOfComponents() const
+{
+ return _numberOfComponents ;
+}
+/*!
+ Set FIELD number of values.
+
+ It must be the same than in the associated SUPPORT object.
+*/
+inline void FIELD_::setNumberOfValues(int NumberOfValues)
+{
+ _numberOfValues=NumberOfValues;
+}
+/*!
+ Get FIELD number of value.
+*/
+inline int FIELD_::getNumberOfValues() const
+{
+ return _numberOfValues ;
+}
+
+// inline void FIELD_::setComponentType(int *ComponentType)
+// {
+// _componentsTypes=ComponentType ;
// }
-// inline int * FIELD_::getComponentType() const
-// {
-// return _componentsTypes ;
+// inline int * FIELD_::getComponentType() const
+// {
+// return _componentsTypes ;
// }
-// inline int FIELD_::getComponentTypeI(int i) const
-// {
-// return _componentsTypes[i-1] ;
+// inline int FIELD_::getComponentTypeI(int i) const
+// {
+// return _componentsTypes[i-1] ;
// }
-inline void FIELD_::setComponentsNames(string * ComponentsNames)
-{
- _componentsNames=ComponentsNames ;
+
+/*!
+ Set FIELD components names.
+
+ Duplicate the ComponentsNames string array to put components names in
+ FIELD. ComponentsNames size must be equal to number of components.
+*/
+inline void FIELD_::setComponentsNames(string * ComponentsNames)
+{
+ if (NULL == _componentsNames)
+ _componentsNames = new string[_numberOfComponents] ;
+ for (int i=0; i<_numberOfComponents; i++)
+ _componentsNames[i]=ComponentsNames[i] ;
}
-inline void FIELD_::setComponentName(int i, string ComponentName)
-{
- _componentsNames[i-1]=ComponentName ;
+/*!
+ Set FIELD i^th component name.
+
+ i must be >=1 and <= number of components.
+*/
+inline void FIELD_::setComponentName(int i, string ComponentName)
+{
+ _componentsNames[i-1]=ComponentName ;
}
-inline string * FIELD_::getComponentsNames() const
-{
- return _componentsNames ;
+/*!
+ Get a reference to the string array which contain the components names.
+
+ This Array size is equal to number of components
+*/
+inline const string * FIELD_::getComponentsNames() const
+{
+ return _componentsNames ;
}
-inline string FIELD_::getComponentName(int i) const
-{
- return _componentsNames[i-1] ;
+/*!
+ Get the name of the i^th component.
+*/
+inline string FIELD_::getComponentName(int i) const
+{
+ return _componentsNames[i-1] ;
}
-inline void FIELD_::setComponentsDescriptions(string *ComponentsDescriptions)
-{
- _componentsDescriptions=ComponentsDescriptions ;
+/*!
+ Set FIELD components descriptions.
+
+ Duplicate the ComponentsDescriptions string array to put components
+ descriptions in FIELD.
+ ComponentsDescriptions size must be equal to number of components.
+*/
+inline void FIELD_::setComponentsDescriptions(string *ComponentsDescriptions)
+{
+ if (NULL == _componentsDescriptions)
+ _componentsDescriptions = new string[_numberOfComponents] ;
+ for (int i=0; i<_numberOfComponents; i++)
+ _componentsDescriptions[i]=ComponentsDescriptions[i] ;
}
+/*!
+ Set FIELD i^th component description.
+
+ i must be >=1 and <= number of components.
+*/
inline void FIELD_::setComponentDescription(int i,string ComponentDescription)
-{
- _componentsDescriptions[i-1]=ComponentDescription ;
+{
+ _componentsDescriptions[i-1]=ComponentDescription ;
}
-inline string * FIELD_::getComponentsDescriptions() const
-{
- return _componentsDescriptions ;
+/*!
+ Get a reference to the string array which contain the components descriptions.
+
+ This Array size is equal to number of components
+*/
+inline const string * FIELD_::getComponentsDescriptions() const
+{
+ return _componentsDescriptions ;
}
+/*!
+ Get the description of the i^th component.
+*/
inline string FIELD_::getComponentDescription(int i) const
-{
- return _componentsDescriptions[i-1];
-}
-inline void FIELD_::setComponentsUnits(UNIT * ComponentsUnits)
-{
- _componentsUnits=ComponentsUnits ;
-}
-inline UNIT * FIELD_::getComponentsUnits() const
-{
- return _componentsUnits ;
-}
-inline UNIT * FIELD_::getComponentUnit(int i) const
-{
- return &_componentsUnits[i-1] ;
-}
-inline void FIELD_::setMEDComponentsUnits(string * MEDComponentsUnits)
-{
- _MEDComponentsUnits=MEDComponentsUnits ;
-}
-inline void FIELD_::setMEDComponentUnit(int i, string MEDComponentUnit)
-{
- _MEDComponentsUnits[i-1]=MEDComponentUnit ;
-}
-inline string * FIELD_::getMEDComponentsUnits() const
-{
- return _MEDComponentsUnits ;
-}
-inline string FIELD_::getMEDComponentUnit(int i) const
-{
- return _MEDComponentsUnits[i-1] ;
-}
-inline void FIELD_::setIterationNumber(int IterationNumber)
-{
- _iterationNumber=IterationNumber;
-}
-inline int FIELD_::getIterationNumber() const
-{
- return _iterationNumber ;
-}
-inline void FIELD_::setTime(double Time)
-{
- _time=Time ;
-}
-inline double FIELD_::getTime() const
-{
- return _time ;
-}
-inline void FIELD_::setOrderNumber(int OrderNumber)
-{
- _orderNumber=OrderNumber ;
-}
-inline int FIELD_::getOrderNumber() const
-{
+{
+ return _componentsDescriptions[i-1];
+}
+
+/*!
+ \todo
+ Set FIELD components UNIT.
+
+ Duplicate the ComponentsUnits UNIT array to put components
+ units in FIELD.
+ ComponentsUnits size must be equal to number of components.
+*/
+inline void FIELD_::setComponentsUnits(UNIT * ComponentsUnits)
+{
+ if (NULL == _componentsUnits)
+ _componentsUnits = new UNIT[_numberOfComponents] ;
+ for (int i=0; i<_numberOfComponents; i++)
+ _componentsUnits[i]=ComponentsUnits[i] ;
+}
+/*!
+ Get a reference to the UNIT array which contain the components units.
+
+ This Array size is equal to number of components
+*/
+inline const UNIT * FIELD_::getComponentsUnits() const
+{
+ return _componentsUnits ;
+}
+/*!
+ Get the UNIT of the i^th component.
+*/
+inline const UNIT * FIELD_::getComponentUnit(int i) const
+{
+ return &_componentsUnits[i-1] ;
+}
+/*!
+ Set FIELD components unit.
+
+ Duplicate the MEDComponentsUnits string array to put components
+ units in FIELD.
+ MEDComponentsUnits size must be equal to number of components.
+
+*/
+inline void FIELD_::setMEDComponentsUnits(string * MEDComponentsUnits)
+{
+ if (NULL == _MEDComponentsUnits)
+ _MEDComponentsUnits = new string[_numberOfComponents] ;
+ for (int i=0; i<_numberOfComponents; i++)
+ _MEDComponentsUnits[i]=MEDComponentsUnits[i] ;
+}
+/*!
+ Set FIELD i^th component unit.
+
+ i must be >=1 and <= number of components.
+*/
+inline void FIELD_::setMEDComponentUnit(int i, string MEDComponentUnit)
+{
+ _MEDComponentsUnits[i-1]=MEDComponentUnit ;
+}
+/*!
+ Get a reference to the string array which contain the components units.
+
+ This Array size is equal to number of components
+*/
+inline const string * FIELD_::getMEDComponentsUnits() const
+{
+ return _MEDComponentsUnits ;
+}
+/*!
+ Get the string for unit of the i^th component.
+*/
+inline string FIELD_::getMEDComponentUnit(int i) const
+{
+ return _MEDComponentsUnits[i-1] ;
+}
+/*!
+ Set the iteration number where FIELD has been calculated.
+*/
+inline void FIELD_::setIterationNumber(int IterationNumber)
+{
+ _iterationNumber=IterationNumber;
+}
+/*!
+ Get the iteration number where FIELD has been calculated.
+*/
+inline int FIELD_::getIterationNumber() const
+{
+ return _iterationNumber ;
+}
+/*!
+ Set the time (in second) where FIELD has been calculated.
+*/
+inline void FIELD_::setTime(double Time)
+{
+ _time=Time ;
+}
+/*!
+ Get the time (in second) where FIELD has been calculated.
+*/
+inline double FIELD_::getTime() const
+{
+ return _time ;
+}
+/*!
+ Set the order number where FIELD has been calculated.
+
+ It corresponds to internal iteration during one time step.
+*/
+inline void FIELD_::setOrderNumber(int OrderNumber)
+{
+ _orderNumber=OrderNumber ;
+}
+/*!
+ Get the order number where FIELD has been calculated.
+*/
+inline int FIELD_::getOrderNumber() const
+{
return _orderNumber ;
}
+/*!
+ Get a reference to the SUPPORT object associated to FIELD.
+*/
inline const SUPPORT * FIELD_::getSupport() const
{
return _support ;
}
+/*!
+ Set the reference to the SUPPORT object associated to FIELD.
+ Reference is not duplicate, so it must not be deleted.
+*/
inline void FIELD_::setSupport(SUPPORT * support)
{
_support = support ;
}
-
-inline /*MED_EN::*/med_type_champ FIELD_::getValueType ()
+/*!
+ Get the FIELD med value type (MED_INT32 or MED_REEL64).
+*/
+inline med_type_champ FIELD_::getValueType () const
{
return _valueType ;
}
-
-inline void FIELD_::setValueType (/*MED_EN::*/med_type_champ ValueType)
+/*!
+ Set the FIELD med value type (MED_INT32 or MED_REEL64).
+*/
+inline void FIELD_::setValueType (med_type_champ ValueType)
{
_valueType = ValueType ;
}
// END OF CLASS FIELD_ //
/////////////////////////
+/*!
+
+ This template class contains informations related with a FIELD :
+ - Values of the field
+
+*/
+
template <class T> class FIELD : public FIELD_
{
protected:
//-----------------------//
- class INSTANCE
+ class INSTANCE
//-----------------------//
{
public:
virtual GENDRIVER * run(const string & fileName, FIELD<T> * ptrFIELD) const = 0 ;
} ;
-
+
//-------------------------------------------------------//
- template <class T2> class INSTANCE_DE : public INSTANCE
+ template <class T2> class INSTANCE_DE : public INSTANCE
//-------------------------------------------------------//
{
public :
- GENDRIVER * run(const string & fileName, FIELD<T> * ptrFIELD) const
- {
- return new T2(fileName,ptrFIELD);
+ GENDRIVER * run(const string & fileName, FIELD<T> * ptrFIELD) const
+ {
+ return new T2(fileName,ptrFIELD);
}
} ;
-
+
// static INSTANCE_DE<MED_FIELD_RDONLY_DRIVER> inst_med_rdonly ;
static INSTANCE_DE<MED_FIELD_RDWR_DRIVER<T> > inst_med ;
static const INSTANCE * const instances[] ;
// ------ End of Drivers Management Part
-
- vector<GENDRIVER *> _drivers; // Storage of the drivers currently in use
// array of value of type T
MEDARRAY<T> *_value ;
FIELD(const SUPPORT * Support, const int NumberOfComponents); // Ajout NB Constructeur FIELD avec allocation de memoire de tous ses attribut
FIELD(const SUPPORT * Support, driverTypes driverType,
const string & fileName="", const string & fieldName="");
- ~FIELD();
+ ~FIELD();
friend class MED_FIELD_RDONLY_DRIVER<T>;
friend class MED_FIELD_WRONLY_DRIVER<T>;
- friend class MED_FIELD_RDWR_DRIVER <T>;
+ //friend class MED_FIELD_RDWR_DRIVER <T>;
void init ();
void rmDriver(int index=0);
- int addDriver(driverTypes driverType,
+ int addDriver(driverTypes driverType,
const string & fileName="Default File Name.med",
const string & driverFieldName="Default Field Name") ;
int addDriver(GENDRIVER & driver);
void allocValue(const int NumberOfComponents, const int LengthValue);
void deallocValue();
-
- inline void read(int index=0);
- inline void read(const GENDRIVER & genDriver);
+
+ inline void read(int index=0);
+ inline void read(const GENDRIVER & genDriver);
inline void write(int index=0, const string & driverName = "");
inline void write(const GENDRIVER &);
inline void setValue(MEDARRAY<T> *Value);
- inline T* getValue(medModeSwitch Mode) const;
- inline T* getValueI(medModeSwitch Mode,int i) const;
+ inline MEDARRAY<T>* getvalue() const;
+ inline const T* getValue(medModeSwitch Mode) const;
+ inline const T* getValueI(medModeSwitch Mode,int i) const;
inline T getValueIJ(int i,int j) const;
inline void setValue(medModeSwitch mode, T* value);
inline void setValueI(medModeSwitch mode, int i, T* value);
inline void setValueIJ(int i, int j, T value);
+
+ /*!
+ This fonction feeds the FIELD<double> private attributs _value with the
+ volume of each cells belonging to the argument Support. The field has to be
+ initialised via the constructor FIELD<double>(const SUPPORT * , const int )
+ with Support as SUPPORT argument, 1 has the number of components, and Support
+ has be a SUPPORT on 3D cells. This initialisation could be done by the empty
+ constructor followed by a setSupport and setNumberOfComponents call but it has
+ be followed by a setValueType(MED_REEL64) call.
+ */
+ void getVolume() const throw (MEDEXCEPTION) ;
+ /*!
+ This fonction feeds the FIELD<double> private attributs _value with the
+ area of each cells (or faces) belonging to the attribut _support. The field
+ has to be initialised via the constructor FIELD<double>(const SUPPORT * ,
+ const int ) with 1 has the number of components, and _support has be a
+ SUPPORT on 2D cells or 3D faces. This initialisation could be done by the
+ empty constructor followed by a setSupport and setNumberOfComponents call but
+ it has be followed by a setValueType(MED_REEL64) call.
+ */
+ void getArea() const throw (MEDEXCEPTION) ;
+ /*!
+ This fonction feeds the FIELD<double> private attributs _value with the
+ length of each segments belonging to the attribut _support. The field has
+ to be initialised via the constructor FIELD<double>(const SUPPORT * ,
+ const int ) with 1 has the number of components, and _support has be a
+ SUPPORT on 3D edges or 2D faces. This initialisation could be done by the
+ empty constructor followed by a setSupport and setNumberOfComponents call but
+ it has be followed by a setValueType(MED_REEL64) call.
+ */
+ void getLength() const throw (MEDEXCEPTION) ;
+ /*!
+ This fonction feeds the FIELD<double> private attributs _value with the
+ normal vector of each faces belonging to the attribut _support. The field
+ has to be initialised via the constructor FIELD<double>(const SUPPORT * ,
+ const int ) with the space dimension has the number of components, and
+ _support has be a SUPPORT on 3D or 2D faces. This initialisation could be done
+ by the empty constructor followed by a setSupport and setNumberOfComponents
+ call but it has be followed by a setValueType(MED_REEL64) call.
+ */
+ void getNormal() const throw (MEDEXCEPTION) ;
+ /*!
+ This fonction feeds the FIELD<double> private attributs _value with the
+ barycenter of each faces or cells or edges belonging to the attribut _support.
+ The field has to be initialised via the constructor
+ FIELD<double>(const SUPPORT * ,const int ) with the space dimension has the
+ number of components, and _support has be a SUPPORT on 3D cells or 2D faces.
+ This initialisation could be done by the empty constructor followed by a
+ setSupport and setNumberOfComponents call but it has be followed by a
+ setValueType(MED_REEL64) call.
+ */
+ void getBarycenter() const throw (MEDEXCEPTION) ;
};
// --------------------
-// Implemented Methods
+// Implemented Methods
// --------------------
-template <class T> FIELD<T>::FIELD():
+/*!
+ Constructor.
+*/
+template <class T> FIELD<T>::FIELD():
_value((MEDARRAY<T>*)NULL)
{
MESSAGE("Constructeur FIELD sans parametre");
}
+/*!
+ Constructor.
+*/
template <class T> FIELD<T>::FIELD(const SUPPORT * Support,
const int NumberOfComponents):
FIELD_(Support, NumberOfComponents)
{
BEGIN_OF("FIELD<T>::FIELD(const SUPPORT * Support, const int NumberOfComponents)");
-
- int length = 0 ;
+
try {
- length = Support->getNumberOfElements(MED_ALL_ELEMENTS);
+ _numberOfValues = Support->getNumberOfElements(MED_ALL_ELEMENTS);
}
catch (MEDEXCEPTION &ex) {
MESSAGE("No value defined ! ("<<ex.what()<<")");
_value = (MEDARRAY<T>*)NULL ;
}
- MESSAGE("FIELD : constructeur : "<<length <<" et "<< NumberOfComponents);
- if (0<length)
- _value = new MEDARRAY<T>::MEDARRAY(NumberOfComponents,length);
- else
+ MESSAGE("FIELD : constructeur : "<< _numberOfValues <<" et "<< NumberOfComponents);
+ if (0<_numberOfValues) {
+ _value = new MEDARRAY<T>::MEDARRAY(_numberOfComponents,_numberOfValues);
+ _isRead = true ;
+ } else
_value = (MEDARRAY<T>*)NULL ;
END_OF("FIELD<T>::FIELD(const SUPPORT * Support, const int NumberOfComponents)");
}
+/*!
+ \if developper
+ \endif
+*/
template <class T> void FIELD<T>::init ()
{
}
+/*!
+ Copy constructor.
+*/
template <class T> FIELD<T>::FIELD(const FIELD & m):
FIELD_((FIELD_) m)
{
if (m._value != NULL)
{
- _value = new MEDARRAY<T>::MEDARRAY(* m._value);
+ // copie only default !
+ _value = new MEDARRAY<T>::MEDARRAY(* m._value,false);
}
else
_value = (MEDARRAY<T> *) NULL;
- _drivers = m._drivers;
+ //_drivers = m._drivers;
}
-template <class T> FIELD<T> & FIELD<T>::FIELD::operator=(const FIELD &m)
+/*!
+
+*/
+template <class T> FIELD<T> & FIELD<T>::operator=(const FIELD &m)
{
}
+/*!
+ Constructor.
+*/
template <class T> FIELD<T>::FIELD(const SUPPORT * Support,
- driverTypes driverType,
- const string & fileName/*=""*/,
+ driverTypes driverType,
+ const string & fileName/*=""*/,
const string & fieldDriverName/*=""*/)
{
- const char * LOC = "template <class T> FIELD<T>::FIELD(const SUPPORT * Support, driverTypes driverType, const string & fileName="", const string & fieldName="") : ";
-
+ const char * LOC = "template <class T> FIELD<T>::FIELD(const SUPPORT * Support, driverTypes driverType, const string & fileName=\"\", const string & fieldName=\"\") : ";
+
int current;
-
+
BEGIN_OF(LOC);
-
+
init();
_support = Support;
_value = (MEDARRAY<T>*)NULL;
- current = addDriver(driverType,fileName,fieldDriverName);
- switch(_drivers[current]->getAccessMode() ) {
- case MED_RDONLY : {
- MESSAGE("MESH::MESH(driverTypes driverType, .....) : driverType must have a MED_RDWR accessMode");
- rmDriver(current);
- break;}
- default : {
- }
- }
- _drivers[current]->open();
+ MED_FIELD_RDONLY_DRIVER<T> myDriver(fileName,this);
+ myDriver.setFieldName(fieldDriverName);
+ current = addDriver(myDriver);
+// current = addDriver(driverType,fileName,fieldDriverName);
+// switch(_drivers[current]->getAccessMode() ) {
+// case MED_WRONLY : {
+// MESSAGE("FIELD<T>::FIELD(driverTypes driverType, .....) : driverType must have a MED_RDONLY or MED_RDWR accessMode");
+// rmDriver(current);
+// break;}
+// default : {
+// }
+// }
+ _drivers[current]->open();
_drivers[current]->read();
_drivers[current]->close();
- END_OF(LOC);
+ END_OF(LOC);
}
-template <class T> FIELD<T>::~FIELD()
-{
+/*!
+ Destructor.
+*/
+template <class T> FIELD<T>::~FIELD()
+{
BEGIN_OF(" Destructeur FIELD<T>::~FIELD()");
if (_value) delete _value;
END_OF(" Destructeur FIELD<T>::~FIELD()");
}
+/*!
+
+*/
template <class T> void FIELD<T>::allocValue(const int NumberOfComponents)
{
- BEGIN_OF("void FIELD<T>::allocValue(const int NumberOfComponents)");
+ const char* LOC = "FIELD<T>::allocValue(const int NumberOfComponents)" ;
+ BEGIN_OF(LOC);
_numberOfComponents = NumberOfComponents ;
if (_componentsTypes == NULL)
}
try {
- int length = _support->getNumberOfElements(MED_ALL_ELEMENTS);
- MESSAGE("FIELD : constructeur : "<<length <<" et "<< NumberOfComponents);
-
- _value = new MEDARRAY<T>::MEDARRAY(NumberOfComponents,length);
+ _numberOfValues = _support->getNumberOfElements(MED_ALL_ELEMENTS);
+ MESSAGE(LOC <<" : "<<_numberOfValues <<" et "<< NumberOfComponents);
+
+ _value = new MEDARRAY<T>::MEDARRAY(_numberOfComponents,_numberOfValues);
+
+ _isRead = true ;
}
catch (MEDEXCEPTION &ex) {
MESSAGE("No value defined, problem with NumberOfComponents (and may be _support) size of MEDARRAY<T>::_value !");
END_OF("void FIELD<T>::allocValue(const int NumberOfComponents)");
}
+/*!
+
+*/
template <class T> void FIELD<T>::allocValue(const int NumberOfComponents, const int LengthValue)
{
BEGIN_OF("void FIELD<T>::allocValue(const int NumberOfComponents,const int LengthValue)");
}
MESSAGE("FIELD : constructeur : "<<LengthValue <<" et "<< NumberOfComponents);
-
- _value = new MEDARRAY<T>::MEDARRAY(NumberOfComponents,LengthValue);
+ _numberOfValues = LengthValue ;
+ _value = new MEDARRAY<T>::MEDARRAY(_numberOfComponents,_numberOfValues);
+ _isRead = true ;
SCRUTE(_value);
END_OF("void FIELD<T>::allocValue(const int NumberOfComponents,const int LengthValue)");
}
+/*!
+
+*/
template <class T> void FIELD<T>::deallocValue()
{
BEGIN_OF("void FIELD<T>::deallocValue()");
-
- delete _value;
+ _numberOfValues = 0 ;
+ _numberOfComponents = 0 ;
+ if (_value != NULL)
+ delete _value;
END_OF("void FIELD<T>::deallocValue()");
}
template <class T> const FIELD<T>::INSTANCE * const FIELD<T>::instances[] = { &FIELD<T>::inst_med } ;
-template <class T> int FIELD<T>::addDriver(driverTypes driverType,
+/*!
+ Create the specified driver and return its index reference to path to
+ read or write methods.
+*/
+template <class T> int FIELD<T>::addDriver(driverTypes driverType,
const string & fileName/*="Default File Name.med"*/,
const string & driverName/*="Default Field Name"*/)
{
const char * LOC = "FIELD<T>::addDriver(driverTypes driverType, const string & fileName=\"Default File Name.med\",const string & driverName=\"Default Field Name\") : ";
-
+
GENDRIVER * driver;
int current;
BEGIN_OF(LOC);
-
+
driver = instances[driverType]->run(fileName, this) ;
_drivers.push_back(driver);
current = _drivers.size()-1;
-
+
_drivers[current]->setFieldName(driverName);
return current;
}
+/*!
+ Duplicate the given driver and return its index reference to path to
+ read or write methods.
+*/
template <class T> inline int FIELD<T>::addDriver (GENDRIVER & driver )
{
const char * LOC = "FIELD<T>::addDriver(GENDRIVER &) : ";
BEGIN_OF(LOC);
-
- _drivers.push_back(&driver);
+
+ // duplicate driver to delete it with destructor !
+ GENDRIVER * newDriver = driver.copy() ;
+
+ _drivers.push_back(newDriver);
return _drivers.size() -1 ;
END_OF(LOC);
};
+/*!
+ Remove the driver referenced by its index.
+*/
template <class T> void FIELD<T>::rmDriver (int index/*=0*/)
{
const char * LOC = "FIELD<T>::rmDriver (int index=0): ";
BEGIN_OF(LOC);
-
+
if ( _drivers[index] ) {
- //_drivers.erase(&_drivers[index]);
+ //_drivers.erase(&_drivers[index]);
// why not ????
MESSAGE ("detruire");
}
else
- throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
- << "The index given is invalid, index must be between 0 and |"
- << _drivers.size()
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+ << "The index given is invalid, index must be between 0 and |"
+ << _drivers.size()
)
- );
-
+ );
+
END_OF(LOC);
}
-
-template <class T> inline void FIELD<T>::read(int index/*=0*/)
-{
+
+/*!
+ Read FIELD in the file specified in the driver given by its index.
+*/
+template <class T> inline void FIELD<T>::read(int index/*=0*/)
+{
const char * LOC = "FIELD<T>::read(int index=0) : ";
BEGIN_OF(LOC);
if ( _drivers[index] ) {
- _drivers[index]->open();
+ _drivers[index]->open();
_drivers[index]->read();
_drivers[index]->close();
}
else
- throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
- << "The index given is invalid, index must be between 0 and |"
- << _drivers.size()
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+ << "The index given is invalid, index must be between 0 and |"
+ << _drivers.size()
)
- );
+ );
END_OF(LOC);
}
-template <class T> inline void FIELD<T>::write(int index/*=0*/, const string & driverName /*= ""*/)
-{
+/*!
+ Write FIELD in the file specified in the driver given by its index.
+*/
+template <class T> inline void FIELD<T>::write(int index/*=0*/, const string & driverName /*= ""*/)
+{
const char * LOC = "FIELD<T>::write(int index=0, const string & driverName = \"\") : ";
BEGIN_OF(LOC);
if( _drivers[index] ) {
- _drivers[index]->open();
- if (driverName != "") _drivers[index]->setFieldName(driverName);
+ _drivers[index]->open();
+ if (driverName != "") _drivers[index]->setFieldName(driverName);
_drivers[index]->write();
_drivers[index]->close();
- }
+ }
else
- throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
- << "The index given is invalid, index must be between 0 and |"
- << _drivers.size()
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+ << "The index given is invalid, index must be between 0 and |"
+ << _drivers.size()
)
- );
+ );
END_OF(LOC);
}
-template <class T> inline void FIELD<T>::write(const GENDRIVER & genDriver)
-{
+/*!
+ \internal
+ Write FIELD with the driver which is equal to the given driver.
+
+ Use by MED object.
+*/
+template <class T> inline void FIELD<T>::write(const GENDRIVER & genDriver)
+{
const char * LOC = " FIELD<T>::write(const GENDRIVER &) : ";
BEGIN_OF(LOC);
for (int index=0; index < _drivers.size(); index++ )
- if ( *_drivers[index] == genDriver ) {
- _drivers[index]->open();
- _drivers[index]->write();
+ if ( *_drivers[index] == genDriver ) {
+ _drivers[index]->open();
+ _drivers[index]->write();
_drivers[index]->close();
}
-
+
END_OF(LOC);
-
-}
-template <class T> inline void FIELD<T>::read(const GENDRIVER & genDriver)
-{
+}
+
+/*!
+ \internal
+ Read FIELD with the driver which is equal to the given driver.
+
+ Use by MED object.
+*/
+template <class T> inline void FIELD<T>::read(const GENDRIVER & genDriver)
+{
const char * LOC = " FIELD<T>::read(const GENDRIVER &) : ";
BEGIN_OF(LOC);
for (int index=0; index < _drivers.size(); index++ )
- if ( *_drivers[index] == genDriver ) {
- _drivers[index]->open();
- _drivers[index]->read();
+ if ( *_drivers[index] == genDriver ) {
+ _drivers[index]->open();
+ _drivers[index]->read();
_drivers[index]->close();
}
-
+
END_OF(LOC);
-
-}
-template <class T> inline void FIELD<T>::setValue(MEDARRAY<T> *Value)
-{
- _value=Value ;
}
-template <class T> inline T* FIELD<T>::getValue(medModeSwitch Mode) const
-{
- return _value->get(Mode) ;
+
+/*!
+ \if developper
+ Destroy the MEDARRAY<T> in FIELD and put the new one without copy.
+ \endif
+*/
+template <class T> inline void FIELD<T>::setValue(MEDARRAY<T> *Value)
+{
+ if (NULL != _value) delete _value ;
+ _value=Value ;
+}
+
+/*!
+ \if developper
+ Return a reference to the MEDARRAY<T> in FIELD.
+ \endif
+*/
+template <class T> inline MEDARRAY<T>* FIELD<T>::getvalue() const
+{
+ return _value ;
+}
+
+/*!
+ Return a reference to values array to read them.
+*/
+template <class T> inline const T* FIELD<T>::getValue(medModeSwitch Mode) const
+{
+ return _value->get(Mode) ;
}
-template <class T> inline T* FIELD<T>::getValueI(medModeSwitch Mode,int i) const
+
+/*!
+ Return a reference to i^{th} row or column - component - (depend on Mode value)
+ of FIELD values array.
+*/
+template <class T> inline const T* FIELD<T>::getValueI(medModeSwitch Mode,int i) const
{
- return _value->getI(Mode,i) ;
+ if ( Mode == MED_FULL_INTERLACE )
+ {
+ return _value->getRow(i) ;
+ }
+ ASSERT ( Mode == MED_NO_INTERLACE);
+ return _value->getColumn(i);
}
-template <class T> inline T FIELD<T>::getValueIJ(int i,int j) const
+
+/*!
+ Return the value of i^{th} element and j^{th} component.
+*/
+template <class T> inline T FIELD<T>::getValueIJ(int i,int j) const
{
- return _value->getIJ(i,j) ;
+ return _value->getIJ(i,j) ;
}
+/*!
+ Copy new values array in FIELD according to the given mode.
+
+ Array must have right size. If not results are unpredicable.
+*/
template <class T> inline void FIELD<T>::setValue(medModeSwitch mode, T* value)
{
_value->set(mode,value);
}
+/*!
+ Update values array in FIELD with the given ones according to specified mode.
+*/
template <class T> inline void FIELD<T>::setValueI(medModeSwitch mode, int i, T* value)
{
- _value->setI(mode,i,value);
+ // PROVISOIRE :
+ if (MED_FULL_INTERLACE == mode)
+ _value->setI(i,value);
+ else if (MED_NO_INTERLACE == mode)
+ _value->setJ(i,value);
+ else
+ throw MEDEXCEPTION(LOCALIZED("FIELD<T>::setValueI : bad medModeSwitch")) ;
}
+/*!
+ Set the value of i^{th} element and j^{th} component with the given one.
+*/
template <class T> inline void FIELD<T>::setValueIJ(int i, int j, T value)
{
_value->setIJ(i,j,value);
}
+/*
+ METHODS
+*/
+
+/*!
+ Fill values array with volume values.
+*/
+template <class T> void FIELD<T>::getVolume() const throw (MEDEXCEPTION)
+{
+ const char * LOC = "FIELD<double>::getVolume() const : ";
+ BEGIN_OF(LOC);
+
+ // The field has to be initilised by a non empty support and a
+ // number of components = 1 and its value type has to be set to MED_REEL64
+ // (ie a FIELD<double>)
+
+ if ((_support == (SUPPORT *) NULL) || (_numberOfComponents != 1) || (_valueType != MED_REEL64))
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"The field has to be initialised with a non empty support, a number of components set to 1 and a value type set to MED_REEL64"));
+
+ END_OF(LOC);
+}
+
+/*!
+ Fill values array with area values.
+*/
+template <class T> void FIELD<T>::getArea() const throw (MEDEXCEPTION)
+{
+ const char * LOC = "FIELD<double>::getArea() const : ";
+ BEGIN_OF(LOC);
+
+ // The field has to be initilised by a non empty support and a
+ // number of components = 1 and its value type has to be set to MED_REEL64
+ // (ie a FIELD<double>)
+
+ if ((_support == (SUPPORT *) NULL) || (_numberOfComponents != 1) || (_valueType != MED_REEL64))
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"The field has to be initialised with a non empty support, a number of components set to 1 and a value type set to MED_REEL64"));
+
+ END_OF(LOC);
+}
+
+/*!
+ Fill values array with length values.
+*/
+template <class T> void FIELD<T>::getLength() const throw (MEDEXCEPTION)
+{
+ const char * LOC = "FIELD<double>::getLength() const : ";
+ BEGIN_OF(LOC);
+
+ // The field has to be initilised by a non empty support and a
+ // number of components = 1 and its value type has to be set to MED_REEL64
+ // (ie a FIELD<double>)
+
+ if ((_support == (SUPPORT *) NULL) || (_numberOfComponents != 1) || (_valueType != MED_REEL64))
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"The field has to be initialised with a non empty support, a number of components set to 1 and a value type set to MED_REEL64"));
+
+ END_OF(LOC);
+}
+
+/*!
+ Fill values array with normal values.
+*/
+template <class T> void FIELD<T>::getNormal() const throw (MEDEXCEPTION)
+{
+ const char * LOC = "FIELD<double>::getNormal() const : ";
+ BEGIN_OF(LOC);
+
+ // The field has to be initilised by a non empty support and a
+ // number of components = 1 and its value type has to be set to MED_REEL64
+ // (ie a FIELD<double>)
+
+ if (_support == (SUPPORT *) NULL)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"The field has to be initialised with a non empty support, a number of components set to the space dimension and a value type set to MED_REEL64"));
+
+ int dim_space = _support->getMesh()->getSpaceDimension();
+
+ if ((_numberOfComponents != dim_space) || (_valueType != MED_REEL64))
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"The field has to be initialised with a non empty support, a number of components set to the space dimension and a value type set to MED_REEL64"));
+
+ END_OF(LOC);
+}
+
+/*!
+ Fill values array with barycenter values.
+*/
+template <class T> void FIELD<T>::getBarycenter() const throw (MEDEXCEPTION)
+{
+ const char * LOC = "FIELD<double>::getBarycenter() const : ";
+ BEGIN_OF(LOC);
+
+ // The field has to be initilised by a non empty support and a number of
+ //components = space dimension and its value type has to be set to MED_REEL64
+ // (ie a FIELD<double>)
+
+ if (_support == (SUPPORT *) NULL)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"The field has to be initialised with a non empty support, a number of components set to the space dimension and a value type set to MED_REEL64"));
+
+ int dim_space = _support->getMesh()->getSpaceDimension();
+
+ if ((_numberOfComponents != dim_space) || (_valueType != MED_REEL64))
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"The field has to be initialised with a non empty support, a number of components set to the space dimension and a value type set to MED_REEL64"));
+
+ END_OF(LOC);
+}
+
#endif /* FIELD_HXX */
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_Group.hxx
+// Module : MED
+
/*
File Group.hxx
$Header$
class FAMILY;
+/*!
+
+ This class describe a group of elements on an entity./n
+ It inherits from SUPPORT./n
+ It is a blending of some FAMILY class./n/n
+
+*/
+
class GROUP : public SUPPORT
{
protected :
- /*! Number of families in the group */
+ /*!
+ \if developper
+ Number of families in the group.
+ */
int _numberOfFamilies ;
- /*! Vector of families in the group */
+ /*!
+ \if developper
+ Vector of families in the group.
+ Note that Families are numbered from 1 to N.
+ */
vector<FAMILY*> _family ;
public:
+ /*! Constructor. */
GROUP();
+ /*! Constructor. */
GROUP(const string & name, const list<FAMILY*> & family) throw (MEDEXCEPTION) ;
- GROUP(GROUP & m);
+ /*! Copy Constructor. */
+ GROUP(const GROUP & m);
+ /*! Destructor. */
~GROUP();
+
+ /*! Copy operator. */
+ // PN ATTention il n y a pas de copie du vecteur Family ????
GROUP & operator=(const GROUP &group);
-
+
+ /*! Operator << */
+ friend ostream & operator<<(ostream &os, GROUP &my) ;
+
inline void setNumberOfFamilies(int numberOfFamilies);
inline void setFamilies(vector<FAMILY*> Family);
inline vector<FAMILY*> getFamilies() const ;
inline FAMILY * getFamily(int i) const ;
-// void init(const list<FAMILY*> & family);
};
// inline method :
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_Med.hxx
+// Module : MED
+
# ifndef MED_HXX
# define MED_HXX
// LOCAL
# include "MEDMEM_define.hxx"
+
+// Add your own driver header (step 2)
# include "MEDMEM_MedMedDriver.hxx"
+# include "MEDMEM_VtkMedDriver.hxx"
+
# include "MEDMEM_Exception.hxx"
//using namespace MED_EN;
// - IN THE SECOND CASE THE USER BEGINS HIS WORK WITH A MESH OR A FIELD,
// ?? GET A MED POINTER THEN CAN ADD MESHes OR FIELDs ??
//
+
+/*!
+
+ This class is use to group together some MESH, SUPPORT and FIELD
+ objects.
+
+*/
+
class MED
{
- friend class MED_MED_DRIVER;
+ // Add your personnal driver line (step 2)
friend class MED_MED_RDONLY_DRIVER;
+ friend class MED_MED_WRONLY_DRIVER;
+ friend class MED_MED_RDWR_DRIVER;
private:
map<MESH_NAME_,MESH*> _meshes; // We can't have two MESHes with the same meshName.
- // The string key is a meshName.
+ // The string key is a meshName.
- map<FIELD_NAME_,MAP_DT_IT_> _fields; // We can't have two FIELDs with the same fieldName.
+ map<FIELD_NAME_,MAP_DT_IT_> _fields; // We can't have two FIELD_s with the same fieldName.
- map<FIELD_ *, MESH_NAME_> _meshName; // Get the meshName associated with a FIELD *
- // in order to get the MESH* from _meshes
+ map<FIELD_ *, MESH_NAME_> _meshName; // Get the meshName associated with a FIELD_ *
+ // in order to get the MESH* from _meshes
+ // POURQUOI MED_FR::med_entite_maillage ? devrait être MED_EN !
map < MESH_NAME_, map <MED_FR::med_entite_maillage,SUPPORT * > > _support ;
// For each MESH, we list support for each entity on all elements.
// INUTILE : void addMesh (const string & meshName ); // Read the mesh <meshName> found in the file <_fileName>. <_fileName> must be set.
// INUTILE : void addField (const string & fieldName ); // Pensez au cas ou on ajoute un Field/Mesh avec un driver déjà existant.
- void addField (const FIELD_ * const ptrField ) throw (MEDEXCEPTION) ; // Add an existing FIELD object to the FIELD list, the meshName is given by the FIELD object.
- void addMesh (const MESH * ptrMesh ) throw (MEDEXCEPTION) ; // Add an existing MESH object to the MESH list, the meshName is given by the MESH object.
-
+ void addField ( FIELD_ * const ptrField ) throw (MED_EXCEPTION) ;
+ void addMesh ( MESH * const ptrMesh ) throw (MED_EXCEPTION) ;
+
// ------ Drivers Management Part
protected:
template <class T> class INSTANCE_DE : public INSTANCE {
public :
- GENDRIVER * run(const string & fileName, MED * const ptrMed) const { return new T(fileName,ptrMed) ; }
+ GENDRIVER * run(const string & fileName, MED * const ptrMed) const
+ {
+ MESSAGE("GENDRIVER * run") ;
+ return new T(fileName,ptrMed) ;
+ }
} ;
- static INSTANCE_DE<MED_MED_DRIVER> inst_med ;
- //static INSTANCE_DE<VTK_DRIVER> inst_vtk ;
+ // Add your new driver instance here (step 3)
+ static INSTANCE_DE<MED_MED_RDWR_DRIVER> inst_med ;
+ static INSTANCE_DE<VTK_MED_DRIVER> inst_vtk ;
static const INSTANCE * const instances[] ;
public:
int addDriver (driverTypes driverType, const string & fileName);
int addDriver (GENDRIVER & driver);
- void rmDriver (int index=0);
- void readFileStruct(int index=0);
- // void read (int index=0);
- void writeFrom (int index=0);
- void write (int index=0);
+ void rmDriver (int index=0) throw (MEDEXCEPTION) ;
+
+ void readFileStruct(int index=0) throw (MEDEXCEPTION) ;
+ void read (int index=0) throw (MEDEXCEPTION) ;
+ void writeFrom (int index=0) throw (MEDEXCEPTION) ;
+ void write (int index=0) throw (MEDEXCEPTION) ;
// ------ End Of Drivers Management Part
int getNumberOfMeshes ( void ) const;
int getNumberOfFields ( void ) const;
- void getMeshNames ( string * meshNames ) const;
- deque<string> getMeshNames () const;
- MESH * getMesh ( const string & meshName ) const;
- MESH * getMesh ( const FIELD_ * field ) const;
- void getFieldNames ( string * fieldNames ) const;
- deque<string> getFieldNames () const;
+ void getMeshNames ( string * meshNames ) const throw (MEDEXCEPTION) ;
+ deque<string> getMeshNames () const;
+ MESH * getMesh ( const string & meshName ) const throw (MEDEXCEPTION) ;
+ MESH * getMesh ( const FIELD_ * const field ) const throw (MEDEXCEPTION) ;
+ void getFieldNames ( string * fieldNames ) const throw (MEDEXCEPTION) ;
+ deque<string> getFieldNames () const;
// A FAIRE DES ROUTINES QUI DONNENT LES PDT ET ITE
- deque<DT_IT_> getFieldIteration (const string & fieldName) const ;
+ deque<DT_IT_> getFieldIteration (const string & fieldName) const throw (MEDEXCEPTION) ;
FIELD_ * getField ( const string & fieldName,
- const int dt, const int it) const;
+ const int dt, const int it) const throw (MEDEXCEPTION) ;
+
+ const map<MED_FR::med_entite_maillage,SUPPORT *> & getSupports(const string & meshName) const throw (MEDEXCEPTION) ;
- const map<MED_FR::med_entite_maillage,SUPPORT *> & getSupports(const string & meshName) const;
- SUPPORT * getSupport (const string & meshName,MED_FR::med_entite_maillage entity) const ;
+ SUPPORT * getSupport (const string & meshName,MED_FR::med_entite_maillage entity) const throw (MEDEXCEPTION) ;
void updateSupport () ;
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_MedMeshDriver.hxx
+// Module : MED
+
#ifndef MED_MESH_DRIVER_HXX
#define MED_MESH_DRIVER_HXX
class GROUP;
class CONNECTIVITY;
+/*!
+
+ Driver Med for MESH.
+
+ Generic part : implement open and close methods.
+
+*/
+
class MED_MESH_DRIVER : public GENDRIVER
{
protected:
static const MED_FR::med_geometrie_element all_cell_type[MED_NBR_GEOMETRIE_MAILLE];
static const char * const all_cell_type_tab [MED_NBR_GEOMETRIE_MAILLE];
-
- MED_MESH_DRIVER():GENDRIVER(),
- _ptrMesh(( MESH *)MED_NULL),_medIdt(MED_INVALID),
- _meshName(""),_meshNum(MED_INVALID)
- {
- }
- MED_MESH_DRIVER(const string & fileName, MESH * ptrMesh, med_mode_acces accessMode):
- GENDRIVER(fileName,accessMode),
- _ptrMesh(ptrMesh),_medIdt(MED_INVALID),
- _meshName(""),_meshNum(MED_INVALID)
- {
- }
-
- void open() {
- BEGIN_OF("MED_MESH_DRIVER::open()");
- _medIdt = MED_FR::MEDouvrir( (const_cast <char *> (_fileName.c_str())),(MED_FR::med_mode_acces) _accessMode);
- MESSAGE("MED_MESH_DRIVER::open() _medIdt : "<< _medIdt );
- if (_medIdt > 0) _status=MED_OPENED; else {
- MESSAGE(" MED_MESH__DRIVER::open() : MEDouvrir : _medIdt= " << _medIdt );
- _status = MED_INVALID;
- }
- END_OF("MED_MESH_DRIVER::open()");
- }
-
- void close() {
- const char * LOC = "MED_MESH_DRIVER::close() " ;
- BEGIN_OF(LOC);
- med_int err = 0;
- if ( _status == MED_OPENED) {
- err=MED_FR::MEDfermer(_medIdt);
- H5close(); // If we call H5close() all the files are closed.
- if (err != 0)
- throw MEDEXCEPTION( LOCALIZED(STRING(LOC)
- <<" Error when closing file !"
- )
- );
- MESSAGE(LOC <<": _medIdt= " << _medIdt );
- MESSAGE(LOC<<": MEDfermer : err = " << err );
- _status = MED_CLOSED;
- _medIdt = MED_INVALID;
- }
- END_OF(LOC);
- }
+
+ /*!
+ Constructor.
+ */
+ MED_MESH_DRIVER() ;
+ /*!
+ Constructor.
+ */
+ MED_MESH_DRIVER(const string & fileName,
+ MESH * ptrMesh,
+ med_mode_acces accessMode) ;
+ /*!
+ Copy constructor.
+ */
+ MED_MESH_DRIVER(const MED_MESH_DRIVER & driver) ;
+
+ /*!
+ Destructor.
+ */
+ virtual ~MED_MESH_DRIVER() ;
+
+ void open() throw (MEDEXCEPTION);
+ void close() throw (MEDEXCEPTION);
virtual void write( void ) const = 0 ;
virtual void read ( void ) = 0 ;
-
+
+ /*!
+ Set the name of the MESH asked in file.
+
+ It could be different than the name of the MESH object.
+ */
void setMeshName(const string & meshName) ;
+ /*!
+ Get the name of the MESH asked in file.
+ */
string getMeshName() const ;
+private:
+ virtual GENDRIVER * copy ( void ) const = 0 ;
+
};
+/*!
+
+ Driver Med for MESH : Read only.
+
+ Implement read method.
+
+*/
+
class MED_MESH_RDONLY_DRIVER : public virtual MED_MESH_DRIVER
{
public :
- MED_MESH_RDONLY_DRIVER():MED_MESH_DRIVER() {};
-
- MED_MESH_RDONLY_DRIVER(const string & fileName, MESH * ptrMesh):
- MED_MESH_DRIVER(fileName,ptrMesh,MED_RDONLY) {
- MESSAGE("MED_MESH_RDONLY_DRIVER::MED_MESH_RDONLY_DRIVER(const string & fileName, MESH * ptrMesh) has been created");
- }
-
- ~MED_MESH_RDONLY_DRIVER() {
- MESSAGE("MED_MESH_RDONLY_DRIVER::~MED_MESH_RDONLY_DRIVER() has been destroyed");
- }
+ /*!
+ Constructor.
+ */
+ MED_MESH_RDONLY_DRIVER() ;
+ /*!
+ Constructor.
+ */
+ MED_MESH_RDONLY_DRIVER(const string & fileName, MESH * ptrMesh) ;
+ /*!
+ Copy constructor.
+ */
+ MED_MESH_RDONLY_DRIVER(const MED_MESH_RDONLY_DRIVER & driver) ;
+
+ /*!
+ Destructor.
+ */
+ virtual ~MED_MESH_RDONLY_DRIVER() ;
// CREER UNE METHODE POUR LIRE LA LISTE DES MAILLAGES .....
+
+ /*!
+ Return a MEDEXCEPTION : it is the read-only driver.
+ */
+ void write( void ) const throw (MEDEXCEPTION);
+ /*!
+ Read MESH in the specified file.
+ */
+ void read ( void ) throw (MEDEXCEPTION);
+
+private:
int getCOORDINATE();
int getCONNECTIVITY();
int getFAMILY();
- void write( void ) const ;
- void read ( void ) ;
-
-private:
int getNodalConnectivity(CONNECTIVITY * Connectivity) ;
int getDescendingConnectivity(CONNECTIVITY * Connectivity) ;
- int getNodesFamiliesNumber() ;
+ int getNodesFamiliesNumber(int * MEDArrayNodeFamily) ;
int getCellsFamiliesNumber(int** Arrays, CONNECTIVITY* Connectivity) ;
void updateFamily() ;
void buildAllGroups(vector<GROUP*> & Groups, vector<FAMILY*> & Families) ;
-
+ void getGRID ();
+
+ GENDRIVER * copy ( void ) const ;
+
};
+/*!
+
+ Driver Med for MESH : Write only.
+
+ Implement write method.
+
+*/
+
class MED_MESH_WRONLY_DRIVER : public virtual MED_MESH_DRIVER {
public :
- MED_MESH_WRONLY_DRIVER():MED_MESH_DRIVER() {}
-
- MED_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh):
- MED_MESH_DRIVER(fileName,ptrMesh,MED_WRONLY)
- {
- MESSAGE("MED_MESH_WRONLY_DRIVER::MED_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh) has been created");
- };
-
- ~MED_MESH_WRONLY_DRIVER() {
- MESSAGE("MED_MESH_WRONLY_DRIVER::MED_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh) has been destroyed");
- }
-
- void write( void ) const ;
- void read ( void ) ;
-
- int writeCoordinates () const;
- int writeConnectivities (medEntityMesh entity) const;
- int writeFamilyNumbers () const;
+ /*!
+ Constructor.
+ */
+ MED_MESH_WRONLY_DRIVER() ;
+ /*!
+ Constructor.
+ */
+ MED_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh) ;
+ /*!
+ Copy constructor.
+ */
+ MED_MESH_WRONLY_DRIVER(const MED_MESH_WRONLY_DRIVER & driver) ;
+
+ /*!
+ Destructor.
+ */
+ virtual ~MED_MESH_WRONLY_DRIVER() ;
+
+ /*!
+ Write MESH in the specified file.
+ */
+ void write( void ) const throw (MEDEXCEPTION);
+ /*!
+ Return a MEDEXCEPTION : it is the write-only driver.
+ */
+ void read ( void ) throw (MEDEXCEPTION);
+
+private:
+ int writeCoordinates () const;
+ int writeConnectivities (medEntityMesh entity) const;
+ int writeFamilyNumbers () const;
int writeFamilies (vector<FAMILY*> & families) const;
+ int writeGRID() const;
+
+ GENDRIVER * copy ( void ) const ;
};
+/*!
+
+ Driver Med for MESH : Read write.
+ - Use read method from MED_MESH_RDONLY_DRIVER
+ - Use write method from MED_MESH_WRONLY_DRIVER
+
+*/
+
class MED_MESH_RDWR_DRIVER : public MED_MESH_RDONLY_DRIVER, public MED_MESH_WRONLY_DRIVER {
public :
- MED_MESH_RDWR_DRIVER():MED_MESH_DRIVER() {}
+ /*!
+ Constructor.
+ */
+ MED_MESH_RDWR_DRIVER() ;
+ /*!
+ Constructor.
+ */
+ MED_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh) ;
+ /*!
+ Copy constructor.
+ */
+ MED_MESH_RDWR_DRIVER(const MED_MESH_RDWR_DRIVER & driver) ;
- MED_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh):
- MED_MESH_DRIVER(fileName,ptrMesh,MED_RDWR)
- {
- MESSAGE("MED_MESH_RDWR_DRIVER::MED_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh) has been created");
- };
+ /*!
+ Destructor.
+ */
+ ~MED_MESH_RDWR_DRIVER() ;
- ~MED_MESH_RDWR_DRIVER() {
- MESSAGE("MED_MESH_RDWR_DRIVER::MED_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh) has been destroyed");
- }
-
- void write(void) const ;
- void read (void) ;
-};
+ /*!
+ Write MESH in the specified file.
+ */
+ void write(void) const throw (MEDEXCEPTION);
+ /*!
+ Read MESH in the specified file.
+ */
+ void read (void) throw (MEDEXCEPTION);
+private:
+ GENDRIVER * copy(void) const ;
+
+};
#endif /* MED_MESH_DRIVER_HXX */
-# ifndef STRING_HXX
-# define STRING_HXX
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_STRING.hxx
+// Module : MED
+
+# ifndef MEDMEM_STRING_HXX
+# define MEDMEM_STRING_HXX
+
+using namespace std;
# include <string>
-//# include <sstream>
# include <strstream>
-using namespace std;
+/*!
+ A class to generate string from any type:
+ here is a simple use case
+ STRING msgErr;
+ msgErr << "This Object cannot be instanciated by now ! Try "<< 11 << "times just to see what happens ";
+ throw SALOME_EXCEPTION (LOCALIZED(msgErr)) ;
+ */
class STRING : public string
{
private :
- // ostringstream _s ;
ostrstream _s ;
public :
- operator const char * () const {
- return const_cast <const char *> (this->c_str()) ;
- }
-
- ~STRING()
- {
- _s.freeze(false);
- }
+ STRING::STRING() :string(), _s()
+ {
+ }
+
+ STRING::~STRING()
+ {
+ _s.freeze(false);
+ }
+
+ STRING::operator const char * () const
+ {
+ return const_cast <const char *> (this->c_str()) ;
+ }
+
+ template <class T> STRING::STRING( const T &valeur ) : string(), _s()
+ {
+ _s.freeze(false);
+
+ _s << valeur ;
+ _s << ends;
+
+ this->string::operator =( _s.str()); // freeze is true by now
+ }
+
+ template <class T> STRING & STRING::operator<<( const T &valeur )
+ {
- STRING() :string() , _s()
- {
- }
-
- template <class T> STRING( const T &valeur ) : string() , _s()
- {
- _s.freeze(false);
- _s << valeur ;
- this->string::operator =( _s.str()); // freeze is true by now
- }
-
- template <class T> STRING &operator<<( const T &valeur )
- {
- _s.freeze(false);
- _s << valeur ;
- this->string::operator = ( _s.str()) ; // freeze is true by now
- return *this ;
- }
-} ;
+ if ( _s.pcount() )
+ {
+ _s.seekp(-1, ios::cur); // Back up before NULL
+ _s.rdbuf()->freeze(0); // Unfreeze it
+ }
+
+ _s << valeur ;
+ _s << ends;
-// Exemple d'utilisation avec les exceptions SALOME
-// STRING msgErr;
-// msgErr << "ESSAI::ESSAI() : This Object cannot be instanciated by now ! Try "<< 11 << "times just to see what happens ";
-// throw SALOME_EXCEPTION (LOCALIZED(msgErr)) ;
+ this->string::operator = ( _s.str() ) ; // freeze is true by now
+ _s.freeze( false ) ;
+ return *this ;
+
+
+ }
+} ;
# endif
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_SkyLineArray.cxx
+// Module : MED
+
using namespace std;
#include "MEDMEM_SkyLineArray.hxx"
#include "utilities.h"
//if (_value != NULL) delete [] _value;
}
-MEDSKYLINEARRAY::MEDSKYLINEARRAY(const med_int count , const med_int length ) :
- _count(count), _length(length),
- _index(_count+1),_value(_length)
+MEDSKYLINEARRAY::MEDSKYLINEARRAY(const med_int count, const med_int length):
+ _count(count), _length(length),
+ _index(_count+1),_value(_length)
{
MESSAGE("Constructeur MEDSKYLINEARRAY(count="<<count<<", length="<<length<<") avec parametres");
}
-void MEDSKYLINEARRAY::setMEDSKYLINEARRAY( const med_int count , const med_int length, med_int* index , med_int* value )
+MEDSKYLINEARRAY::MEDSKYLINEARRAY(const med_int count, const med_int length,
+ const med_int* index, const med_int* value):
+ _count(count), _length(length),
+ _index(_count+1),_value(_length)
{
- MESSAGE("void MEDSKYLINEARRAY::setMEDSKYLINEARRAY(count, length, index, value)");
- _count = count ;
- _length = length ;
+ MESSAGE("Constructeur MEDSKYLINEARRAY(count="<<count<<", length="<<length<<") avec parametres");
+ memcpy((med_int*)_index,index,sizeof(med_int)*(_count+1));
+ memcpy((med_int*)_value,value,sizeof(med_int)*_length);
+}
- //if (_index != NULL) delete [] _index;
- //if (_value != NULL) delete [] _value;
+// void MEDSKYLINEARRAY::setMEDSKYLINEARRAY( const med_int count , const med_int length, med_int* index , med_int* value )
+// {
+// MESSAGE("void MEDSKYLINEARRAY::setMEDSKYLINEARRAY(count, length, index, value)");
+// _count = count ;
+// _length = length ;
- _index.set(index);
- _value.set(value);
-}
+// //if (_index != NULL) delete [] _index;
+// //if (_value != NULL) delete [] _value;
+
+// _index.set(index);
+// _value.set(value);
+// }
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_Support.cxx
+// Module : MED
+
using namespace std;
/*
File Support.cxx
#include <set>
#include <list>
-#include "utilities.h"
-#include "MEDMEM_define.hxx"
+//#include "utilities.h"
+//#include "MEDMEM_define.hxx"
#include "MEDMEM_DriversDef.hxx"
#include "MEDMEM_Support.hxx"
-#include "MEDMEM_Family.hxx"
-#include "MEDMEM_Group.hxx"
+//#include "MEDMEM_Family.hxx"
+//#include "MEDMEM_Group.hxx"
#include "MEDMEM_Mesh.hxx"
using namespace MED_EN;
/* This class is a generic class for family and group */
+
+/*!
+ Constructor.
+*/
//--------------------------------------------------------------------------
SUPPORT::SUPPORT(): _name(""), _description(""), _mesh((MESH*)NULL),
_entity(MED_CELL), _numberOfGeometricType(0),
_geometricType((medGeometryElement*)NULL),
_numberOfGaussPoint((int*)NULL),
- _geometricTypeNumber((int*)NULL), _isOnAllElts(false),
- _numberOfEntities((int*)NULL), _totalNumberOfEntities(0),
+ //_geometricTypeNumber((int*)NULL),
+ _isOnAllElts(false),
+ _numberOfElements((int*)NULL),
+ _totalNumberOfElements(0),
_number((MEDSKYLINEARRAY*)NULL)
//--------------------------------------------------------------------------
{
- MESSAGE("Constructeur SUPPORT sans parametre");
+ MESSAGE("SUPPORT::SUPPORT()");
};
+/*!
+ Constructor.
+*/
//--------------------------------------------------------------------------
SUPPORT::SUPPORT(MESH* Mesh, string Name/*=""*/, medEntityMesh Entity/*=MED_CELL*/):
_name(Name), _description(""), _mesh(Mesh), _entity(Entity),
_numberOfGeometricType(0),
_geometricType((medGeometryElement*)NULL),
_numberOfGaussPoint((int*)NULL),
- _geometricTypeNumber((int*)NULL),
- _isOnAllElts(true), _numberOfEntities((int*)NULL),
- _totalNumberOfEntities(0),
+ //_geometricTypeNumber((int*)NULL),
+ _isOnAllElts(true),
+ _numberOfElements((int*)NULL),
+ _totalNumberOfElements(0),
_number((MEDSKYLINEARRAY*)NULL)
//--------------------------------------------------------------------------
{
- MESSAGE("Constructeur SUPPORT avec parametres MESH* Mesh,string name,medEntityMesh Entity");
- if ( Entity == MED_NODE) {
- _numberOfGeometricType=1 ;
- _geometricType=new medGeometryElement[1] ;
- _geometricType[0]=MED_NONE ;
- }
+ MESSAGE("SUPPORT::SUPPORT(MESH*Mesh,string Name,medEntityMesh Entity)");
+ update() ;
};
+/*!
+ Copy constructor.
+*/
//--------------------------------------------------------------------------
-SUPPORT::SUPPORT(SUPPORT & m)
+SUPPORT::SUPPORT(const SUPPORT & m)
//--------------------------------------------------------------------------
{
const char * LOC = "SUPPORT::SUPPORT(SUPPORT & m) : " ;
}
else
_numberOfGaussPoint = (int *) NULL;
- if (m._geometricTypeNumber != NULL)
- {
- _geometricTypeNumber = new int[m._numberOfGeometricType];
- memcpy(_geometricTypeNumber,m._geometricTypeNumber,m._numberOfGeometricType*sizeof(int));
- }
- else
- _geometricTypeNumber = (int *) NULL;
+// if (m._geometricTypeNumber != NULL)
+// {
+// _geometricTypeNumber = new int[m._numberOfGeometricType];
+// memcpy(_geometricTypeNumber,m._geometricTypeNumber,m._numberOfGeometricType*sizeof(int));
+// }
+// else
+// _geometricTypeNumber = (int *) NULL;
_isOnAllElts = m._isOnAllElts;
- if (m._numberOfEntities != NULL)
+ if (m._numberOfElements != NULL)
{
- _numberOfEntities = new int[m._numberOfGeometricType];
- memcpy(_numberOfEntities,m._numberOfEntities,m._numberOfGeometricType*sizeof(int));
+ _numberOfElements = new int[_numberOfGeometricType];
+ memcpy(_numberOfElements,m._numberOfElements,_numberOfGeometricType*sizeof(int));
}
else
- _numberOfEntities = (int *) NULL;
- _totalNumberOfEntities = m._totalNumberOfEntities;
+ _numberOfElements = (int *) NULL;
+ _totalNumberOfElements = m._totalNumberOfElements;
if (m._isOnAllElts == false)
_number = new MEDSKYLINEARRAY(* m._number);
else
END_OF(LOC) ;
};
+
+/*!
+ Destructor.
+*/
//-----------------
SUPPORT::~SUPPORT()
//-----------------
{
- MESSAGE("Destructeur ~SUPPORT()");
- if (_geometricType!=NULL)
- delete[] _geometricType ;
- if (_numberOfGaussPoint!=NULL)
- delete[] _numberOfGaussPoint ;
- if (_geometricTypeNumber!=NULL)
- delete[] _geometricTypeNumber ;
- if (_numberOfEntities!=NULL)
- delete[] _numberOfEntities ;
- if (_number!=NULL)
- delete _number ;
+ MESSAGE("Destructeur ~SUPPORT()");
+ if (_geometricType != (medGeometryElement *) NULL)
+ delete [] _geometricType ;
+ if (_numberOfGaussPoint != (int *) NULL)
+ delete [] _numberOfGaussPoint ;
+ // if (_geometricTypeNumber!=NULL)
+ // delete[] _geometricTypeNumber ;
+ if (_numberOfElements != (int *) NULL)
+ delete[] _numberOfElements ;
+ if (_number != (MEDSKYLINEARRAY *) NULL)
+ delete _number ;
}
+/*!
+ operator <<.
+*/
//--------------------------------------------------
ostream & operator<<(ostream &os, const SUPPORT &my)
//--------------------------------------------------
{
- os << "Name : "<<my._name<< endl ;
+ os << "Name : "<< my._name << endl ;
os << "Description : "<< my._description << endl ;
os << "Mesh name : ";
if (my._mesh==NULL)
os << "Entity : "<< my._entity << endl;
os << "Entity list : "<< endl;
if (!(my._isOnAllElts)) {
- int NumberOfTypes = my._numberOfGeometricType ;
- os << "NumberOfTypes : "<<NumberOfTypes<<endl;
- medGeometryElement * Types = my._geometricType ;
- for (int j=0;j<NumberOfTypes;j++) {
- os << " * Type "<<Types[j]<<" : ";
- int NumberOfElements = my._numberOfEntities[j] ;
- int * Number = my._number->getI(j+1) ;
- for (int k=0; k<NumberOfElements;k++)
- os << Number[k] << " ";
+ int numberoftypes = my._numberOfGeometricType ;
+ os << "NumberOfTypes : "<<numberoftypes<<endl;
+ medGeometryElement * types = my._geometricType;
+ for (int j=0;j<numberoftypes;j++) {
+ os << " * Type "<<types[j]<<" : ";
+ int numberOfElements = my._numberOfElements[j];
+ const int * number = my._number->getI(j+1);
+ for (int k=0; k<numberOfElements;k++)
+ os << number[k] << " ";
os << endl ;
}
} else
os << "Is on all entities !"<< endl;
-
+
return os ;
}
-/*! A DOCUMENTER */
+/*!
+ Updade the SUPPORT attributs with rigth MESH information.
+
+ It has an effect only if SUPPORT is on all elements.
+
+ No more need in future release.
+*/
//-------------------
void SUPPORT::update()
//-------------------
const char * LOC = "SUPPORT::update() : " ;
BEGIN_OF(LOC) ;
- if (_isOnAllElts)
- if (_numberOfGaussPoint==NULL) {
- MESSAGE( "ENTITY : "<< _entity );
- int NumberOfTypes = _mesh->getNumberOfTypes(_entity) ;
- MESSAGE( "NumberOfTypes : "<< NumberOfTypes );
- _numberOfGaussPoint = new int[NumberOfTypes] ;
- for (int i=0;i<NumberOfTypes;i++)
+ if (_isOnAllElts) {
+ if (_entity == MED_NODE) {
+ _numberOfGeometricType=1 ;
+ _geometricType=new medGeometryElement[1] ;
+ _geometricType[0]=MED_NONE ;
+ _numberOfElements = new int[1] ;
+ _numberOfElements[0]=_mesh->getNumberOfNodes();
+ _totalNumberOfElements=_numberOfElements[0];
+ _numberOfGaussPoint = new int[1] ;
+ _numberOfGaussPoint[0]=1;
+ } else { // we duplicate information from _mesh
+ _numberOfGeometricType=_mesh->getNumberOfTypes(_entity);
+ if (_geometricType == (medGeometryElement *) NULL)
+ _geometricType = new medGeometryElement[_numberOfGeometricType] ;
+ memcpy(_geometricType,_mesh->getTypes(_entity),_numberOfGeometricType*sizeof(medGeometryElement));
+ if (_numberOfElements == (int *) NULL)
+ _numberOfElements = new int[_numberOfGeometricType] ;
+ if (_numberOfGaussPoint == (int *) NULL)
+ _numberOfGaussPoint = new int[_numberOfGeometricType] ;
+ _totalNumberOfElements=0;
+ for (int i=0;i<_numberOfGeometricType;i++) {
+ _numberOfElements[i]=_mesh->getNumberOfElements(_entity,_geometricType[i]) ;
+ _totalNumberOfElements+=_numberOfElements[i];
_numberOfGaussPoint[i]=1 ;
+ }
}
- if (_entity == MED_NODE)
- _totalNumberOfEntities = _mesh->getNumberOfNodes();
-
+ }
END_OF(LOC);
};
-/*! A DOCUMENTER */
+/*!
+ Blend the given SUPPORT into it.
+*/
//-------------------
void SUPPORT::blending(SUPPORT * mySupport)
//-------------------
}
}
// set new value :
- int * numberOfEntities=_numberOfEntities ;
- _numberOfEntities = new int[it] ;
- _totalNumberOfEntities = 0 ;
- // int totalSize = 0 ;
+ int * numberOfElements=_numberOfElements ;
+ _numberOfElements = new int[it] ;
+ _totalNumberOfElements = 0 ;
+ //int totalSize = 0 ;
int ** tmp_array = new (int*)[it];
for (int i=0;i<it;i++) {
int numberOfElementsInType = tmp_NumberOfElementsInType[i] ;
- _numberOfEntities[i] = numberOfElementsInType ;
+ _numberOfElements[i] = numberOfElementsInType ;
tmp_array[i] = new int[numberOfElementsInType] ;
//totalSize+=numberOfElementsInType*(myType[i]%100) ;
- _totalNumberOfEntities+=numberOfElementsInType ;
+ _totalNumberOfElements+=numberOfElementsInType ;
if (whereIsType[i] == 1) { // only first Support
memcpy(tmp_array[i],getNumber(myType[i]),sizeof(int)*numberOfElementsInType);
} else if (whereIsType[i] == 2) { // only second Support
int i1 = 0 ;
int i2 = 0 ;
int ii = 0 ;
- int * number1 = getNumber(myType[i]) ;
- int * number2 = mySupport->getNumber(myType[i]) ;
+ const int * number1 = getNumber(myType[i]) ;
+ const int * number2 = mySupport->getNumber(myType[i]) ;
SCRUTE(number1);
SCRUTE(number2);
- int numberOfElements1 = numberOfEntities[i] ;
+ int numberOfElements1 = numberOfElements[i] ;
int numberOfElements2 = mySupport->getNumberOfElements(myType[i]) ;
SCRUTE(numberOfElements1);
}
//create the array !
- int newNumberOfEntities = elementList.size() ;
- _numberOfEntities[i] = newNumberOfEntities ;
- int * tmp_arrayNew = new int[newNumberOfEntities];
+ int newNumberOfElements = elementList.size() ;
+ _numberOfElements[i] = newNumberOfElements ;
+ int * tmp_arrayNew = new int[newNumberOfElements];
set<int>::iterator its ;
for(its=elementList.begin();its!=elementList.end(); its++) {
delete[] tmp_array[i] ;
tmp_array[i] = tmp_arrayNew ;
- _totalNumberOfEntities-=(numberOfElementsInType-newNumberOfEntities) ;
+ _totalNumberOfElements-=(numberOfElementsInType-newNumberOfElements) ;
} else
throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"ERROR")) ;
_geometricType = new medGeometryElement[it] ;
int * numberOfGaussPoint=_numberOfGaussPoint ;
_numberOfGaussPoint= new int[it] ;
- int * geometricTypeNumber=_geometricTypeNumber ;
- _geometricTypeNumber = new int[it] ;
+// int * geometricTypeNumber=_geometricTypeNumber ;
+// _geometricTypeNumber = new int[it] ;
- MEDSKYLINEARRAY* numberNew = new MEDSKYLINEARRAY(it,_totalNumberOfEntities);
- int * numberIndex = numberNew->getIndex() ;
+// MEDSKYLINEARRAY* numberNew = new MEDSKYLINEARRAY(it,_totalNumberOfElements);
+// int * numberIndex = numberNew->getIndex() ;
+ int size = _mesh->getNumberOfElements(_entity,MED_ALL_ELEMENTS);
+ if (_totalNumberOfElements == size) _isOnAllElts = true;
+
+ int * numberValue = new int[_totalNumberOfElements] ;
+ int * numberIndex = new int[it+1] ;
numberIndex[0]=1;
for (int i=0;i<it;i++) {
- memcpy(numberNew->getI(i+1),tmp_array[i],sizeof(int)*_numberOfEntities[i]) ;
+ memcpy(numberValue+numberIndex[i]-1,tmp_array[i],sizeof(int)*_numberOfElements[i]) ;
delete[] tmp_array[i] ;
- numberIndex[i+1]=numberIndex[i]+_numberOfEntities[i] ;
+ numberIndex[i+1]=numberIndex[i]+_numberOfElements[i] ;
_geometricType[i]=myType[i] ;
_numberOfGaussPoint[i]=1 ;
- _geometricTypeNumber[i]=0 ;
-
}
- delete _number ;
- _number = numberNew ;
+ if ( _number != (MEDSKYLINEARRAY *) NULL) delete _number ;
+ //_number = numberNew ;
+ _number = new MEDSKYLINEARRAY(it,_totalNumberOfElements,numberIndex,numberValue);
+ delete[] numberIndex;
+
+ delete[] numberValue;
delete[] myType ;
delete[] tmp_array ;
delete[] geometricType ;
delete[] numberOfGaussPoint ;
- delete[] geometricTypeNumber ;
- delete[] numberOfEntities ;
+// delete[] geometricTypeNumber ;
+ delete[] numberOfElements ;
END_OF(LOC);
};
it should be used after an initialisation with the constructor
SUPPORT(MESH* Mesh, string Name="", medEntityMesh Entity=MED_CELL) and
after the call to the function setAll(false).
- It allocates and initialises all the attributs of the class SUPPORT.;
- useful for the Python API.
+ It allocates and initialises all the attributs of the class SUPPORT.
*/
//-------------------
void SUPPORT::setpartial(string Description, int NumberOfGeometricType,
- int TotalNumberOfEntity,
+ int TotalNumberOfElements,
medGeometryElement *GeometricType,
- int *NumberOfEntity, int *NumberValue)
+ int *NumberOfElements, int *NumberValue)
//-------------------
{
const char * LOC = "SUPPORT::setpartial(string , int , int , medGeometryElement * , int * , int *) : " ;
BEGIN_OF(LOC) ;
+ _isOnAllElts = false ;
+
_description=Description;
_numberOfGeometricType=NumberOfGeometricType;
- _totalNumberOfEntities=TotalNumberOfEntity;
-
+ if (_geometricType!=NULL) delete[] _geometricType ;
_geometricType = new medGeometryElement[NumberOfGeometricType];
- _geometricType = GeometricType;
+ if (_numberOfElements!=NULL) delete[] _numberOfElements ;
+ _numberOfElements = new int[NumberOfGeometricType];
+ _totalNumberOfElements = TotalNumberOfElements;
+ if (_numberOfGaussPoint!=NULL) delete[] _numberOfGaussPoint ;
+ _numberOfGaussPoint = new int[NumberOfGeometricType];
+ int * index = new int[_numberOfGeometricType+1];
+ index[0]=1;
+ for (int i=0;i<_numberOfGeometricType;i++) {
+ _geometricType[i] = GeometricType[i] ;
+ _numberOfElements[i] = NumberOfElements[i] ;
+ _numberOfGaussPoint[i] = 1 ;
+ index[i+1] = index[i]+NumberOfElements[i] ;
+ }
+
+ if (_number!=NULL) delete _number ;
+ _number = new MEDSKYLINEARRAY(_numberOfGeometricType,_totalNumberOfElements,index,NumberValue);
- // attributes initialised at 0 because not really useful but it has to be
- // allocated !! WARNING !!
+ delete[] index ;
- _geometricTypeNumber = new int[NumberOfGeometricType] ;
- for (int i=0;i<NumberOfGeometricType;i++) _geometricTypeNumber[i] = 0;
+ END_OF(LOC);
+};
- //_numberOfEntities = new int[NumberOfGeometricType] ;
- _numberOfEntities = NumberOfEntity;
- MEDSKYLINEARRAY * number = new MEDSKYLINEARRAY();
+/*!
+ This method gets the boundary elements of the mesh. The support has to be
+ build using the constructor SUPPORT(MESH *,string, medEntityMesh) or
+ SUPPORT() followed by setMesh(MESH*) setName(string) and
+ setEntity(medEntityMesh) before using this method.
+*/
+//-------------------
+void SUPPORT::getBoundaryElements() throw (MEDEXCEPTION)
+//-------------------
+{
+ const char * LOC = "SUPPORT::getBoundaryElements() : " ;
+ BEGIN_OF(LOC) ;
- int * index = new int[_numberOfGeometricType+1];
- index[0]=1;
+ if (_mesh == (MESH*)NULL) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"You shlould use the appropriate SUPPORT Constructor before calling this method"));
+
+ int spaceDimension = _mesh->getSpaceDimension();
+
+ if (spaceDimension == 3)
+ if (_entity != MED_FACE)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined in 3D mesh for entity "<<_entity<<" !"));
+ if (spaceDimension == 2)
+ if (_entity != MED_EDGE)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined in 2D mesh for entity "<<_entity<<" !"));
+
+ setAll(false);
+
+ const int * myConnectivityValue = _mesh->getReverseConnectivity(MED_DESCENDING) ;
+ const int * myConnectivityIndex = _mesh->getReverseConnectivityIndex(MED_DESCENDING) ;
+ int numberOf = _mesh->getNumberOfElements(_entity,MED_ALL_ELEMENTS) ;
+ list<int> myElementsList ;
+ int size = 0 ;
+ SCRUTE(numberOf) ;
+ for (int i=0 ; i<numberOf; i++)
+ if (myConnectivityValue[myConnectivityIndex[i]] == 0) {
+ SCRUTE(i+1) ;
+ myElementsList.push_back(i+1) ;
+ size++ ;
+ }
+ SCRUTE(size) ;
+ // Well, we must know how many geometric type we have found
+ int * myListArray = new int[size] ;
+ int id = 0 ;
+ list<int>::iterator myElementsListIt ;
+ for (myElementsListIt=myElementsList.begin();myElementsListIt!=myElementsList.end();myElementsListIt++) {
+ myListArray[id]=(*myElementsListIt) ;
+ SCRUTE(id);
+ SCRUTE(myListArray[id]);
+ id ++ ;
+ }
- for (int i=0;i<_numberOfGeometricType;i++)
- index[i+1] = index[i]+_numberOfEntities[i] ;
+ int numberOfGeometricType ;
+ medGeometryElement* geometricType ;
+ int * numberOfGaussPoint ;
+ int * geometricTypeNumber ;
+ int * numberOfElements ;
+ //MEDSKYLINEARRAY * mySkyLineArray = new MEDSKYLINEARRAY() ;
+ int * mySkyLineArrayIndex ;
+
+ int numberOfType = _mesh->getNumberOfTypes(_entity) ;
+ if (numberOfType == 1) { // wonderfull : it's easy !
+ numberOfGeometricType = 1 ;
+ geometricType = new medGeometryElement[1] ;
+ const medGeometryElement * allType = _mesh->getTypes(_entity);
+ geometricType[0] = allType[0] ;
+ numberOfGaussPoint = new int[1] ;
+ numberOfGaussPoint[0] = 1 ;
+ geometricTypeNumber = new int[1] ; // not use, but initialized to nothing
+ geometricTypeNumber[0] = 0 ;
+ numberOfElements = new int[1] ;
+ numberOfElements[0] = size ;
+ mySkyLineArrayIndex = new int[2] ;
+ mySkyLineArrayIndex[0]=1 ;
+ mySkyLineArrayIndex[1]=1+size ;
+ }
+ else {// hemmm
+ map<medGeometryElement,int> theType ;
+ for (myElementsListIt=myElementsList.begin();myElementsListIt!=myElementsList.end();myElementsListIt++) {
+ medGeometryElement myType = _mesh->getElementType(_entity,*myElementsListIt) ;
+ if (theType.find(myType) != theType.end() )
+ theType[myType]+=1 ;
+ else
+ theType[myType]=1 ;
+ }
+ numberOfGeometricType = theType.size() ;
+ geometricType = new medGeometryElement[numberOfGeometricType] ;
+ const medGeometryElement * allType = _mesh->getTypes(_entity);
+ numberOfGaussPoint = new int[numberOfGeometricType] ;
+ geometricTypeNumber = new int[numberOfGeometricType] ; // not use, but initialized to nothing
+ numberOfElements = new int[numberOfGeometricType] ;
+ mySkyLineArrayIndex = new int[numberOfGeometricType+1] ;
+ int index = 0 ;
+ mySkyLineArrayIndex[0]=1 ;
+ map<medGeometryElement,int>::iterator theTypeIt ;
+ for (theTypeIt=theType.begin();theTypeIt!=theType.end();theTypeIt++) {
+ geometricType[index] = (*theTypeIt).first ;
+ numberOfGaussPoint[index] = 1 ;
+ geometricTypeNumber[index] = 0 ;
+ numberOfElements[index] = (*theTypeIt).second ;
+ mySkyLineArrayIndex[index+1]=mySkyLineArrayIndex[index]+numberOfElements[index] ;
+ index++ ;
+ }
+ }
+ //mySkyLineArray->setMEDSKYLINEARRAY(numberOfGeometricType,size,mySkyLineArrayIndex,myListArray) ;
+ MEDSKYLINEARRAY * mySkyLineArray = new MEDSKYLINEARRAY(numberOfGeometricType,size,mySkyLineArrayIndex,myListArray) ;
- number->setMEDSKYLINEARRAY(_numberOfGeometricType,_totalNumberOfEntities,index,NumberValue);
+ setNumberOfGeometricType(numberOfGeometricType) ;
+ // setGeometricType(geometricType) ;
+ // setNumberOfGaussPoint(numberOfGaussPoint) ;
+ for (int i=0;i<numberOfGeometricType;i++)
+ {
+ _numberOfGaussPoint[i] = numberOfGaussPoint[i];
+ _geometricType[i] = geometricType[i];
+ }
- if (_number!=NULL) delete _number ;
- _number = number;
+ setNumberOfElements(numberOfElements) ;
+ setTotalNumberOfElements(size) ;
+ // setNumber(mySkyLineArray) ;
- update();
+ _number = new MEDSKYLINEARRAY(numberOfGeometricType,size);
- END_OF(LOC);
-};
+ _number->setIndex(mySkyLineArrayIndex);
+
+ for (int i=0;i<size;i++)
+ {
+ _number->setIndexValue(i+1,myListArray[i]);
+ }
+
+ delete[] numberOfElements;
+ delete[] geometricTypeNumber;
+ delete[] numberOfGaussPoint;
+ delete[] geometricType;
+ delete[] mySkyLineArrayIndex;
+ delete[] myListArray;
+ delete mySkyLineArray;
+
+ END_OF(LOC) ;
+}
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_Unit.cxx
+// Module : MED
+
using namespace std;
/*
File MEDMEM_Unit.cxx
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_VtkMedDriver.cxx
+// Module : MED
+
using namespace std;
#include "MEDMEM_VtkMedDriver.hxx"
+#include <sstream>
+
+#include "MEDMEM_define.hxx"
#include "MEDMEM_Med.hxx"
+#include "MEDMEM_Field.hxx"
+#include "MEDMEM_Support.hxx"
+#include "MEDMEM_Mesh.hxx"
+#include "MEDMEM_CellModel.hxx"
VTK_MED_DRIVER::VTK_MED_DRIVER(): GENDRIVER(),
- _ptrMed((MED * const)MED_NULL),
- _vtkFile(MED_INVALID)
+ _ptrMed((MED * const)MED_NULL)
{
+ _vtkFile = new ofstream();
// What about _id in Gendriver ?
// _driverType ???
}
VTK_MED_DRIVER::VTK_MED_DRIVER(const string & fileName, MED * const ptrMed):
- GENDRIVER(fileName,MED_EN::MED_RDWR), _ptrMed(ptrMed), _vtkFile(MED_INVALID)
+ GENDRIVER(fileName,MED_EN::MED_RDWR), _ptrMed(ptrMed)
{
+ _ptrMed->addDriver(*this); // OU RECUPERER L'ID.
+ _vtkFile = new ofstream();
// What about _id in Gendriver ?
// _driverType ???
}
-//REM : As t'on besoin du champ _status : _vtkFile <-> _status ? Oui
+VTK_MED_DRIVER::VTK_MED_DRIVER(const VTK_MED_DRIVER & driver):
+ GENDRIVER(driver),
+ _ptrMed(driver._ptrMed)
+{
+ _ptrMed->addDriver(*this); // OU RECUPERER L'ID.
+ _vtkFile = new ofstream();
+ // What about _id in Gendriver ?
+ // _driverType ???
+}
+VTK_MED_DRIVER::~VTK_MED_DRIVER()
+{
+ close();
+ delete _vtkFile ;
+}
-void VTK_MED_DRIVER::open() {
+GENDRIVER * VTK_MED_DRIVER::copy() const
+{
+ return new VTK_MED_DRIVER(*this) ;
+}
+
+//REM : As t'on besoin du champ _status : _vtkFile <-> _status ? Oui
+
+void VTK_MED_DRIVER::openConst() const {
const char * LOC ="VTK_MED_DRIVER::open() : ";
BEGIN_OF(LOC);
- // REFLECHIR SUR CE TEST PAR RAPPORT A L'OUVERTURE/FERMETURE
-// if ( _vtkFile != MED_INVALID )
-// throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
-// << "_vtkFile is already in use, please close the file |"
-// << _fileName << "| before calling open()"
-// )
-// );
-
- if ( _status != MED_CLOSED )
- throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
- << "_status is not closed, please close the file |"
- << _fileName << "| before calling open()"
- )
- );
-
if ( _fileName == "" )
throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
<< "_fileName is |\"\"|, please set a correct fileName before calling open()"
)
);
- _vtkFile.open(filename.c_str()) ; // ? if error ????
- _status = MED_OPENED ;
-
-// if (_vtkFile > 0) _status=MED_OPENED;
-// else {
-// _status = MED_CLOSED;
-// _vtkFile = MED_INVALID;
-// throw MED_EXCEPTION (LOCALIZED( STRING(LOC)
-// << "Can't open |" << _fileName
-// << "|, _vtkFile : " << _vtkFile
-// )
-// );
-// }
-
+
+ if (!(*_vtkFile).is_open())
+ (*_vtkFile).open(_fileName.c_str()) ;
+// if (*_vtkFile)
+// _status = MED_OPENED ;
+// else
+ if (!(*_vtkFile))
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "Could not open file "
+ << _fileName)
+ );
END_OF(LOC);
}
+void VTK_MED_DRIVER::open() {
+ openConst() ;
+}
-void VTK_MED_DRIVER::close() {
+void VTK_MED_DRIVER::closeConst() const {
- const char * LOC = "MED_MED_DRIVER::close() : ";
+ const char * LOC = "VTK_MED_DRIVER::close() : ";
BEGIN_OF(LOC);
- if ( _status == MED_CLOSED)
- throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << ": the file |"
- << _fileName << "| is already closed"
- )
- );
-
- // if ( _vtkFile == MED_INVALID )
-// throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "_vtkFile invalid, but the file |"
-// << _fileName << "| seems to be openned !"
-// )
-// );
- vtkFile_.close();
-
- _status = MED_CLOSED;
- // _vtkFile = MED_INVALID;
-
-// if (err != MED_VALID)
-// throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "the file |"
-// << _fileName << "| couldn't be closed"
-// )
-// );
+ (*_vtkFile).close();
+// if (*_vtkFile)
+// _status = MED_CLOSED ;
+// else
+ if (!(*_vtkFile))
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "Could not close file "
+ << _fileName)
+ );
END_OF(LOC);
}
+void VTK_MED_DRIVER::close() {
+ closeConst() ;
+}
-void VTK_MED_DRIVER::write() {
- const char * LOC = "MED_MED_DRIVER::write() : ";
+void VTK_MED_DRIVER::write() const {
+
+ const char * LOC = "VTK_MED_DRIVER::write() : ";
BEGIN_OF(LOC);
+ // Well we must open vtk file first, because there are
+ // no other driver than MED for VTK that do it !
+ openConst() ;
+
// could we put more than one Mesh ?????
- _vtkFile << "# vtk DataFile Version 2.0" << endl
- << "maillage SALOLME" << endl ;
- // only ASCII for the moment (binary came latest :-)
- _vtkFile << "ASCII" << endl ;
-
- int NumberOfMeshes = _ptrMED->getNumberOfMeshes() ;
- string * MeshName = new string[NumberOfMeshes] ;
- _ptrMED->getMeshNames(MeshName) ;
+ (*_vtkFile) << "# vtk DataFile Version 2.0" << endl
+ << "maillage from MedMemory" << endl ;
+ // only ASCII for the moment (binary came later :-)
+ (*_vtkFile) << "ASCII" << endl ;
+
+ int NumberOfMeshes = _ptrMed->getNumberOfMeshes() ;
+ deque<string> MeshNames = _ptrMed->getMeshNames() ;
+ deque<string>::const_iterator currentMesh ;
// In fact, we must take care of all supports
// We restrict Field on all nodes or cells
+
+ int NumberOfFields = _ptrMed->getNumberOfFields() ;
+ deque<string> FieldNames = _ptrMed->getFieldNames() ;
+ deque<string>::const_iterator currentField ;
+
+ // for ( currentMesh=MeshName.begin();currentMesh != MeshName.end(); currentMesh++) {
for (int i=0; i<NumberOfMeshes; i++) {
- MESH * myMesh = _ptrMED->getMesh(MeshName[i]) ;
+ MESH * myMesh = _ptrMed->getMesh(MeshNames[i]) ;
writeMesh(myMesh) ;
// get all field which values are on this mesh => revoir api de Med !!!
- _vtkFile << "NODE" << endl ;
// first : field on node
+ // fields is on all node !
+ (*_vtkFile) << "POINT_DATA " << myMesh->getNumberOfNodes() << endl ;
for (int j=0; j<NumberOfFields; j++) {
- FIELD_ * myField = _ptrMED->getField() ;
- if (myField->getSupport()->getEntity()!=MED_NODE)
- if (myField->getSupport()->isOnAllElements())
- writeField(myField) ;
-
+ deque<DT_IT_> timeStep = _ptrMed->getFieldIteration(FieldNames[j]) ;
+ deque<DT_IT_>::const_iterator currentTimeStep ;
+ for ( currentTimeStep=timeStep.begin(); currentTimeStep!=timeStep.end(); currentTimeStep++) {
+ int dt = (*currentTimeStep).dt ;
+ int it = (*currentTimeStep).it ;
+ FIELD_ * myField = _ptrMed->getField(FieldNames[j],dt,it) ;
+ if( MeshNames[i] == myField->getSupport()->getMesh()->getName() ) {
+ // rigth in all case : better compare pointeur ?
+ if (MED_NODE == myField->getSupport()->getEntity())
+ if (myField->getSupport()->isOnAllElements()) {
+ ostringstream name ;
+ name << myField->getName() << "_" << dt << "_" << it ;
+ writeField(myField,name.str()) ;
+ } else
+ INFOS("Could not write field "<<myField->getName()<<" which is not on all nodes !");
+ }
+ }
}
- _vtkFile << "CELL" << endl ;
+
+ (*_vtkFile) << "CELL_DATA " << myMesh->getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS) << endl ;
// second : field on cell
for (int j=0; j<NumberOfFields; j++) {
- FIELD_ * myField = _ptrMED->getField() ;
- if (myField->getSupport()->getEntity()!=MED_CELL)
- if (myField->getSupport()->isOnAllElements())
- writeField(myField) ;
-
+ deque<DT_IT_> timeStep = _ptrMed->getFieldIteration(FieldNames[j]) ;
+ deque<DT_IT_>::const_iterator currentTimeStep ;
+ for ( currentTimeStep=timeStep.begin(); currentTimeStep!=timeStep.end(); currentTimeStep++) {
+ int dt ;
+ int it ;
+ FIELD_ * myField = _ptrMed->getField(FieldNames[j],dt,it) ;
+ if( MeshNames[i] == myField->getSupport()->getMesh()->getName() ) {
+ // rigth in all case : better compare pointeur ?
+ if (MED_CELL == myField->getSupport()->getEntity())
+ if (myField->getSupport()->isOnAllElements()) {
+ ostringstream name ;
+ name << myField->getName() << "_" << dt << "_" << it ;
+ writeField(myField,name.str()) ;
+ } else
+ INFOS("Could not write field "<<myField->getName()<<" which is not on all cells !");
+ }
+ }
}
}
+ // Well we must close vtk file first, because there are
+ // no other driver than MED for VTK that do it !
+ closeConst() ;
+
END_OF(LOC);
}
-void VTK_MED_DRIVER::writeMesh(MESH * myMesh) {
+void VTK_MED_DRIVER::writeMesh(MESH * myMesh) const {
- const char * LOC = "MED_MED_DRIVER::writeMesh() : ";
+ const char * LOC = "VTK_MED_DRIVER::writeMesh() : ";
BEGIN_OF(LOC);
- _vtkFile << "DATASET UNSTRUCTURED_GRID" << endl ;
+ (*_vtkFile) << "DATASET UNSTRUCTURED_GRID" << endl ;
// put points (all point are in 3D, so if we are in 1D or 2D, we complete by zero !
int SpaceDimension = myMesh->getSpaceDimension() ;
int NumberOfNodes = myMesh->getNumberOfNodes() ;
- _vtkFile << "POINTS " << NumberOfNodes << " float" << endl ;
- double *coordinate = myMesh->getCoordinates(MED_FULL_ENTERLACE) ;
- if (SpaceDimension<3) { // 1D or 2D
- coordinate_z = new double[NumberOfNodes] ;
- // we put zero :
- for (int i=0;i<NumberOfNodes;i++)
- coordinate_z[i] = 0.0 ;
+ (*_vtkFile) << "POINTS " << NumberOfNodes << " float" << endl ;
+ const double *coordinate = myMesh->getCoordinates(MED_FULL_INTERLACE) ;
+ for (int i=0;i<NumberOfNodes;i++) {
+ for (int j=0;j<SpaceDimension;j++)
+ (*_vtkFile) << coordinate[i*SpaceDimension+j] << " " ;
if (SpaceDimension==1)
- coordinate_y = coordinate_z ; // only one array of zero !
- else
- coordinate_y = coordinate_x + NumberOfNodes ;
- } else {
- coordinate_y = coordinate_x + NumberOfNodes ;
- coordinate_z = coordinate_y + NumberOfNodes ;
+ (*_vtkFile) << "0 0" ;
+ if (SpaceDimension==2)
+ (*_vtkFile) << "0" ;
+ (*_vtkFile) << endl ;
}
- for (int i=0;i<NumberOfNodes;i++)
- for (int j=0;j<SpaceDimension;j++)
- _vtkFile << coordinate[i*SpaceDimension+j] << " " ;
- if (SpaceDimension==1)
- _vtkFile << "0 0" ;
- if (SpaceDimension==2)
- _vtkFile << "0" ;
- _vtkFile << endl ;
// we put connectivity
// how many cells and how many value in connectivity :
int cells_types_count = myMesh->getNumberOfTypes(MED_CELL) ;
- int * cells_count = myMesh->get_cells_count() ;
- int cells_sum = cells_count[cells_types_count] ;
- CellModel * cells_type = myMesh->get_cells_type() ;
- int connectivity_sum = 0 ;
+ // int * cells_count = myMesh->get_cells_count() ;
+ // int cells_sum = cells_count[cells_types_count] ;
+ int cells_sum = myMesh->getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS) ;
+ const CELLMODEL * cells_type = myMesh->getCellsTypes(MED_CELL) ;
+ // int connectivity_sum = 0 ;
- int * connectivity = myMesh->getConnectivity(MED_FULL_ENTERLACE,MED_CELL,MED_ALL_ELEMENTS) ;
- int * connectivityIndex = myMesh->getConnectivityIndex(MED_CELL) ;
+ const int * connectivity = myMesh->getConnectivity(MED_FULL_INTERLACE,MED_NODAL,MED_CELL,MED_ALL_ELEMENTS) ;
+ const int * connectivityIndex = myMesh->getConnectivityIndex(MED_NODAL,MED_CELL) ;
- for (int i=0;i<cells_types_count;i++) {
- int nodes_cell = cells_type[i].getNumberOfNodes();
- connectivity_sum+= (cells_count[i+1]-cells_count[i])*(nodes_cell + 1);
- // we add 1 because we put nodes count in vtk file !
- }
- _vtkFile << "CELLS " << cells_sum << " " << connectivity_sum << endl ;
+ int connectivity_sum = connectivityIndex[cells_sum]-1 ;
+
+ (*_vtkFile) << "CELLS " << cells_sum << " " << connectivity_sum+cells_sum << endl ;
// we put connectivity
for (int i=0;i<cells_types_count;i++) {
int *filter = (int*) NULL ; // index in vtk connectivity
- switch (cells_type[i].get_type())
+ switch (cells_type[i].getType())
{
case MED_POINT1 : {
filter = new int[1] ;
}
}
if (filter==NULL)
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<": MED element type not supported yet : " << cells_type[i].get_type() ) ) ;
- int nodes_cell = cells_type[i].get_NumberOfNodes();
- for (int j=0;j<cells_count[i+1]-cells_count[i];j++) {
- _vtkFile << nodes_cell << " " ;
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<": MED element type not supported yet : " << cells_type[i].getName() ) ) ;
+ int nodes_cell = cells_type[i].getNumberOfNodes();
+ int numberOfCell = myMesh->getNumberOfElements(MED_CELL,cells_type[i].getType()) ;
+ const int * connectivityArray = myMesh->getConnectivity(MED_FULL_INTERLACE,MED_NODAL,MED_CELL,cells_type[i].getType());
+ for (int j=0;j<numberOfCell;j++) {
+ (*_vtkFile) << nodes_cell << " " ;
for (int k=0;k<nodes_cell;k++)
- _vtkFile << (myMesh->get_nodal_connectivity(i+1))[j*nodes_cell+filter[k]] - 1 << " " ;
- _vtkFile << endl ;
+ (*_vtkFile) << connectivityArray[j*nodes_cell+filter[k]] - 1 << " " ;
+ (*_vtkFile) << endl ;
}
+ if (filter != NULL)
+ delete[] filter ;
}
- _vtkFile << endl ;
+ (*_vtkFile) << endl ;
// we put cells type
- _vtkFile << "CELL_TYPES " << cells_sum << endl ;
+ (*_vtkFile) << "CELL_TYPES " << cells_sum << endl ;
for (int i=0;i<cells_types_count;i++) {
int vtkType = 0 ;
- switch (cells_type[i].get_type())
+ switch (cells_type[i].getType())
{
case MED_POINT1 : {
vtkType = 1 ;
}
}
if (vtkType == 0)
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<": MED element type not supported yet : " << cells_type[i].get_type() ) ) ;
- for (int j=0;j<cells_count[i+1]-cells_count[i];j++)
- _vtkFile << vtkType << endl ;
- if (filter != NULL)
- delete[] filter ;
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<": MED element type not supported yet : " << cells_type[i].getType() ) ) ;
+ int numberOfCell = myMesh->getNumberOfElements(MED_CELL,cells_type[i].getType()) ;
+ for (int j=0;j<numberOfCell;j++)
+ (*_vtkFile) << vtkType << endl ;
}
// add a constant field on all node to test !
// for (int i=0;i<NumberOfNodes;i++)
// _vtkFile << i << endl ;
- return 1 ;
+ return ;
END_OF(LOC);
}
-void VTK_MED_DRIVER::writeField(FIELD * myField) {
+void VTK_MED_DRIVER::writeField(FIELD_ * myField,string name) const {
- const char * LOC = "MED_MED_DRIVER::writeField() : ";
+ const char * LOC = "VTK_MED_DRIVER::writeField() : ";
BEGIN_OF(LOC);
-
-
+ int NomberOfValue = myField->getSupport()->getNumberOfElements(MED_ALL_ELEMENTS) ;
+ int NomberOfComponents = myField->getNumberOfComponents() ;
+
+ med_type_champ type = myField->getValueType() ;
+ SCRUTE(name);
+ SCRUTE(type);
+ switch (type)
+ {
+ case MED_INT32 : {
+ MESSAGE("MED_INT32");
+ if (NomberOfComponents==3) {
+ (*_vtkFile) << "VECTORS " << name << " int" << endl ;
+ } else if (NomberOfComponents<=4) {
+ (*_vtkFile) << "SCALARS " << name << " int " << NomberOfComponents << endl ;
+ (*_vtkFile) << "LOOKUP_TABLE default" << endl ;
+ } else {
+ INFOS("Could not write field "<<myField->getName()<<" there are more than 4 components !");
+ return ;
+ }
+
+ //const int * value = ((FIELD<int>*)myField)->getValue(MED_NO_INTERLACE) ;
+ const int * value = ((FIELD<int>*)myField)->getValue(MED_NO_INTERLACE) ;
+ for (int i=0; i<NomberOfValue; i++) {
+ for(int j=0; j<NomberOfComponents; j++)
+ (*_vtkFile) << value[j*NomberOfValue+i] << " " ;
+ (*_vtkFile) << endl ;
+ }
+ break ;
+ }
+ case MED_REEL64 : {
+ MESSAGE("MED_REEL64");
+ if (NomberOfComponents==3) {
+ (*_vtkFile) << "VECTORS " << name << " float" << endl ;
+ } else if (NomberOfComponents<=4) {
+ (*_vtkFile) << "SCALARS " << name << " float " << NomberOfComponents << endl ;
+ (*_vtkFile) << "LOOKUP_TABLE default" << endl ;
+ } else {
+ INFOS("Could not write field "<<myField->getName()<<" there are more than 4 components !");
+ return ;
+ }
+ const double * value = ((FIELD<double>*)myField)->getValue(MED_NO_INTERLACE) ;
+ for (int i=0; i<NomberOfValue; i++) {
+ for(int j=0; j<NomberOfComponents; j++)
+ (*_vtkFile) << value[j*NomberOfValue+i] << " " ;
+ (*_vtkFile) << endl ;
+ }
+ break ;
+ }
+ default : {
+ INFOS("Could not write field "<<name<<" the type is not int or double !");
+ }
+ }
+
END_OF(LOC);
}
+
+void VTK_MED_DRIVER::writeSupport(SUPPORT * mySupport) const {
+ const char * LOC = "VTK_MED_DRIVER::writeSupport(SUPPORT *)" ;
+ BEGIN_OF(LOC) ;
+ END_OF(LOC) ;
+}
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : test_MEDMEM_SkyLineArray.cxx
+// Module : MED
+
using namespace std;
#include "utilities.h"
#include "MEDMEM_SkyLineArray.hxx"
int NumberOfCell = 3 ; // 1 triangle,1 quadrangle,1 triangle
int Size = 10 ; // 10 nodes
- MEDSKYLINEARRAY * myArray = new MEDSKYLINEARRAY(NumberOfCell,Size) ;
- int * index = myArray->getIndex() ;
+ int * index = new int[NumberOfCell+1] ;
index[0]=1;
index[1]=4;
index[2]=8;
index[3]=11;
- int * value = myArray->getValue() ;
+ int * value = new int[Size] ;
value[0]=1; // first
value[1]=2;
value[2]=5;
value[9]=6;
// value[]=; // forth
+ MEDSKYLINEARRAY * myArray = new MEDSKYLINEARRAY(NumberOfCell,Size,index,value) ;
+
cout << "Show all 1 :" << endl ;
for (int i=1; i<NumberOfCell+1 ; i++) {
- int * cell = myArray->getI(i) ;
+ const int * cell = myArray->getI(i) ;
int numberof = myArray->getNumberOfI(i) ;
cout << " - " ;
for (int j=0;j<numberof;j++)
delete myArray ;
cout << "Show all 3 :" << endl ;
- for (int i=1; i<NumberOfCell+1 ; i++) {
- int * cell = myArray2->getI(i) ;
- int numberof = myArray2->getNumberOfI(i) ;
+ const int * index2 = myArray2->getIndex() ;
+ for (int i=1; i<=NumberOfCell ; i++) {
cout << " - " ;
- for (int j=0;j<numberof;j++)
- cout << cell[j] << " " ;
+ for (int j=index2[i-1];j<index2[i];j++)
+ cout << myArray2->getIndexValue(j) << " " ;
cout << endl ;
}
+ delete myArray2 ;
+ delete[] index ;
+ delete[] value ;
+
return 0 ;
}