version, which will be tagged V3_0_1b1.
-This is the version 2.2.0 of MED
+This is the version 3.0.1 of MED
Compatible with :
- - KERNEL 2.2.0
+ - KERNEL 3.0.0
+ - SALOMEGUI 3.0.0
zzzz121b.med \
Mistrat.med \
TimeStamps.med \
+cas_defaut_domaine_fluide.med \
+polyedres.med \
+polygones.med \
+recoll_bord.med \
+carre_en_quad4_import22.med \
+carre_en_quad4_seg2_import22.med \
+cube_hexa8_import22.med \
+cube_hexa8_quad4_import22.med \
+maillage_UniSegFam_import22.med \
+mesh_import22.med \
+Mistrat_import22.med \
+pointe_import22.med \
+TimeStamps_import22.med \
+poly3D.med \
Darcy3_3D_H_10x10x10.sauve \
dx200_dy1_avec_2couches.sauve \
elle_2D_QT_10x10.sauve \
MOC = @MOC@
UIC = @UIC@
-
+MSG2QM = @MSG2QM@
#QWT
$(SWIG) $(SWIG_FLAGS) -o $@ $<
$(top_builddir)/share/salome/resources/%.qm: %.po
- if test -e ${KERNEL_ROOT_DIR}/bin/salome/msg2qm ; then \
- ${KERNEL_ROOT_DIR}/bin/salome/msg2qm $< $@ ; \
- else \
- $(top_builddir)/bin/salome/msg2qm $< $@ ; \
- fi
+ $(MSG2QM) $< $@ ; \
#------------------------------------------------------------------------------
# The following section of this makefile contains dependencies between the
-THIS IS SALOME - MED VERSION: 2.2.0
+THIS IS SALOME - MED VERSION: 3.0.1
CHECK_QT
+echo
+echo ---------------------------------------------
+echo testing MSG2QM
+echo ---------------------------------------------
+echo
+
+CHECK_MSG2QM
+
echo
echo ---------------------------------------------
echo testing VTK
Returns an array (Sender) of coordinates stored in any type.\n
It could be used in a Client code using the MED Client classes.
*/
- SALOME::Sender getSenderForCoordinates(in medModeSwitch typeSwitch)
+ SALOME::SenderDouble getSenderForCoordinates(in medModeSwitch typeSwitch)
raises (SALOME::SALOME_Exception);
/*!
Returns coordinate n° Number on axis n° Axis
Idem getConnectivity but return a Sender.\n
It could be used in a Client code using the MED Client classes.
*/
- SALOME::Sender getSenderForConnectivity(in medModeSwitch typeSwitch,
+ SALOME::SenderInt getSenderForConnectivity(in medModeSwitch typeSwitch,
in medConnectivity mode,
in medEntityMesh entity,
in medGeometryElement geomElement)
Group_array groupCell;
};
meshInfos getMeshGlobal() raises (SALOME::SALOME_Exception);
+ boolean areEquals(in MESH other);
};
It could be used in a Client code using the MED Client classes.
*/
- SALOME::Sender getSenderForNumber(in medGeometryElement geomElement)
+ SALOME::SenderInt getSenderForNumber(in medGeometryElement geomElement)
raises (SALOME::SALOME_Exception);
/*!
Idem SALOME_MED::long_array getNumberIndex() but return a Sender.\n
It could be used in a Client code using the MED Client classes.
*/
- SALOME::Sender getSenderForNumberIndex()
+ SALOME::SenderInt getSenderForNumberIndex()
raises (SALOME::SALOME_Exception);
/*!
Idem as getValue but it could be used in a Client code using the
MED Client classes.
*/
- SALOME::Sender getSenderForValue(in medModeSwitch mode)
+ SALOME::SenderDouble getSenderForValue(in medModeSwitch mode)
raises (SALOME::SALOME_Exception);
};
Idem as getValue but it could be used in a Client code using the
MED Client classes.
*/
- SALOME::Sender getSenderForValue(in medModeSwitch mode)
+ SALOME::SenderInt getSenderForValue(in medModeSwitch mode)
raises (SALOME::SALOME_Exception);
};
<component-username>Med</component-username>
<component-type>MESH</component-type>
<component-author>Patrick GOLDBRONN</component-author>
- <component-version>2.2.0</component-version>
+ <component-version>3.0.1</component-version>
<component-comment>MED memory component</component-comment>
<component-multistudy>1</component-multistudy>
<component-icone>ModuleMed.png</component-icone>
if (spaceDimension != DIMENSION ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"The spaceDimension of mesh |" << _fromMesh->getName() << "| is |" << spaceDimension << "| and should be |" << DIMENSION << "|" << endl)) ;
_fromWrapper = new Meta_Wrapper<DIMENSION>(_fromMesh->getNumberOfNodes(),
- const_cast<double *> (_fromMesh->getCoordinates(MED_FULL_INTERLACE)),
+ const_cast<double *> (_fromMesh->getCoordinates(MED_EN::MED_FULL_INTERLACE)),
const_cast<CONNECTIVITY *> (_fromMesh->getConnectivityptr())
);
int fromSpaceDimension = _fromMesh->getSpaceDimension();
int toSpaceDimension = _toMesh->getSpaceDimension();
- if (fromSpaceDimension != DIMENSION ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"The spaceDimension of mesh |" << _fromMesh->getName() << "| is |" << spaceDimension << "| and should be |" << DIMENSION << "|" << endl)) ;
- if ( toSpaceDimension != DIMENSION ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"The spaceDimension of mesh |" << _toMesh->getName() << "| is |" << spaceDimension << "| and should be |" << DIMENSION << "|" << endl)) ;
+ if (fromSpaceDimension != DIMENSION ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"The spaceDimension of mesh |" << _fromMesh->getName() << "| is |" << INTERPOLATION<DIMENSION>::spaceDimension << "| and should be |" << DIMENSION << "|" << endl)) ;
+ if ( toSpaceDimension != DIMENSION ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"The spaceDimension of mesh |" << _toMesh->getName() << "| is |" << INTERPOLATION<DIMENSION>::spaceDimension << "| and should be |" << DIMENSION << "|" << endl)) ;
_fromWrapper = new Meta_Wrapper<DIMENSION>(_fromMesh->getNumberOfNodes(),
- const_cast<double *> (_fromMesh->getCoordinates(MED_FULL_INTERLACE)),
+ const_cast<double *> (_fromMesh->getCoordinates(MED_EN::MED_FULL_INTERLACE)),
const_cast<CONNECTIVITY *> (_fromMesh->getConnectivityptr())
);
_toWrapper = new Meta_Wrapper<DIMENSION>(_toMesh->getNumberOfNodes(),
- const_cast<double *> (_toMesh->getCoordinates(MED_FULL_INTERLACE))
+ const_cast<double *> (_toMesh->getCoordinates(MED_EN::MED_FULL_INTERLACE))
);
_mapping = new Meta_Mapping<DIMENSION> (_fromWrapper);
#include "MEDMEM_WrapperField.hxx"
#include "MEDMEM_InterpolationTools.hxx"
+#define _CALCUL_HYBRIDE_ Calcul_Hybride<Wrapper_MED_Field,Valeur<double>,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,Meta_Nuage_Maille>
+
//////////////////////////////////////////////////////////////////
/// ///
/// DECLARATIONS ///
Meta_Nuage_Maille * nm = MW->Get_Nuage_Mailles();
Wrapper_MED_Field * c = MW->Get_Champ();
- mailles=nm;
+ _CALCUL_HYBRIDE_::mailles=nm;
- fonctions[ MED_EN::MED_TRIA3 ]=new Calcul_Interpolation_Tria3 <Wrapper_MED_Field,Valeur<double>,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,Meta_Nuage_Maille>(nn,nm,c);
- fonctions[ MED_EN::MED_QUAD4 ]=new Calcul_Interpolation_Quad4 <Wrapper_MED_Field,Valeur<double>,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,Meta_Nuage_Maille>(nn,nm,c);
- fonctions[ MED_EN::MED_TETRA4 ]=new Calcul_Interpolation_Tetra4 <Wrapper_MED_Field,Valeur<double>,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,Meta_Nuage_Maille>(nn,nm,c);
- fonctions[ MED_EN::MED_HEXA8 ]=new Calcul_Interpolation_Hexa8 <Wrapper_MED_Field,Valeur<double>,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,Meta_Nuage_Maille>(nn,nm,c);
- fonctions[ MED_EN::MED_PENTA6 ]=new Calcul_Interpolation_Penta6 <Wrapper_MED_Field,Valeur<double>,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,Meta_Nuage_Maille>(nn,nm,c);
- fonctions[ MED_EN::MED_PYRA5 ]=new Calcul_Interpolation_Pyra5 <Wrapper_MED_Field,Valeur<double>,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,Meta_Nuage_Maille>(nn,nm,c);
- fonctions[ MED_EN::MED_TRIA6 ]=fonctions[ MED_EN::MED_TRIA3 ];
- fonctions[ MED_EN::MED_QUAD8 ]=fonctions[ MED_EN::MED_QUAD4 ];
- fonctions[ MED_EN::MED_TETRA10]=fonctions[ MED_EN::MED_TETRA4 ];
- fonctions[ MED_EN::MED_HEXA20 ]=fonctions[ MED_EN::MED_HEXA8 ];
- fonctions[ MED_EN::MED_PENTA15]=fonctions[ MED_EN::MED_PENTA6 ];
- fonctions[ MED_EN::MED_PYRA13 ]=fonctions[ MED_EN::MED_PYRA5 ];
+ _CALCUL_HYBRIDE_::fonctions[ MED_EN::MED_TRIA3 ]=new Calcul_Interpolation_Tria3 <Wrapper_MED_Field,Valeur<double>,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,Meta_Nuage_Maille>(nn,nm,c);
+ _CALCUL_HYBRIDE_::fonctions[ MED_EN::MED_QUAD4 ]=new Calcul_Interpolation_Quad4 <Wrapper_MED_Field,Valeur<double>,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,Meta_Nuage_Maille>(nn,nm,c);
+ _CALCUL_HYBRIDE_::fonctions[ MED_EN::MED_TETRA4 ]=new Calcul_Interpolation_Tetra4 <Wrapper_MED_Field,Valeur<double>,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,Meta_Nuage_Maille>(nn,nm,c);
+ _CALCUL_HYBRIDE_::fonctions[ MED_EN::MED_HEXA8 ]=new Calcul_Interpolation_Hexa8 <Wrapper_MED_Field,Valeur<double>,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,Meta_Nuage_Maille>(nn,nm,c);
+ _CALCUL_HYBRIDE_::fonctions[ MED_EN::MED_PENTA6 ]=new Calcul_Interpolation_Penta6 <Wrapper_MED_Field,Valeur<double>,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,Meta_Nuage_Maille>(nn,nm,c);
+ _CALCUL_HYBRIDE_::fonctions[ MED_EN::MED_PYRA5 ]=new Calcul_Interpolation_Pyra5 <Wrapper_MED_Field,Valeur<double>,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,Meta_Nuage_Maille>(nn,nm,c);
+ _CALCUL_HYBRIDE_::fonctions[ MED_EN::MED_TRIA6 ]=_CALCUL_HYBRIDE_::fonctions[ MED_EN::MED_TRIA3 ];
+ _CALCUL_HYBRIDE_::fonctions[ MED_EN::MED_QUAD8 ]=_CALCUL_HYBRIDE_::fonctions[ MED_EN::MED_QUAD4 ];
+ _CALCUL_HYBRIDE_::fonctions[ MED_EN::MED_TETRA10]=_CALCUL_HYBRIDE_::fonctions[ MED_EN::MED_TETRA4 ];
+ _CALCUL_HYBRIDE_::fonctions[ MED_EN::MED_HEXA20 ]=_CALCUL_HYBRIDE_::fonctions[ MED_EN::MED_HEXA8 ];
+ _CALCUL_HYBRIDE_::fonctions[ MED_EN::MED_PENTA15]=_CALCUL_HYBRIDE_::fonctions[ MED_EN::MED_PENTA6 ];
+ _CALCUL_HYBRIDE_::fonctions[ MED_EN::MED_PYRA13 ]=_CALCUL_HYBRIDE_::fonctions[ MED_EN::MED_PYRA5 ];
}
Valeur<double> operator() (Wrapper_Noeud<DIMENSION> & node, int num_maille){return Calcul_Hybride<Wrapper_MED_Field,Valeur<double>,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,Meta_Nuage_Maille>::operator()(node,num_maille);}
Valeur<double> operator() (double * node, int num_maille)
public : Calcul_Interpolation_P0(NUAGENOEUD * nn,NUAGEMAILLE * nm,CHAMP * c):Calcul_Interpolation<_PARAM_>(nn,nm,c) {}
public : VALEURCHAMP operator() (const NOEUD & n, int num_maille)
{
- return (*champ)[num_maille];
+ return (*Calcul_Interpolation<_PARAM_>::champ)[num_maille];
}
};
_TEMPLATE_ class Calcul_Interpolation_Tria3 : public Calcul_Interpolation<_PARAM_>
public : Calcul_Interpolation_Tria3(NUAGENOEUD * nn,NUAGEMAILLE * nm,CHAMP * c):Calcul_Interpolation<_PARAM_>(nn,nm,c) {}
public : VALEURCHAMP operator() (const NOEUD & n, int num_maille)
{
- int num0=(*mailles)[num_maille][0];
- int num1=(*mailles)[num_maille][1];
- int num2=(*mailles)[num_maille][2];
+ int num0=(*Calcul_Interpolation<_PARAM_>::mailles)[num_maille][0];
+ int num1=(*Calcul_Interpolation<_PARAM_>::mailles)[num_maille][1];
+ int num2=(*Calcul_Interpolation<_PARAM_>::mailles)[num_maille][2];
- double x0=(*noeuds)[num0][0];
- double y0=(*noeuds)[num0][1];
- double x1=(*noeuds)[num1][0];
- double y1=(*noeuds)[num1][1];
- double x2=(*noeuds)[num2][0];
- double y2=(*noeuds)[num2][1];
+ double x0=(*Calcul_Interpolation<_PARAM_>::noeuds)[num0][0];
+ double y0=(*Calcul_Interpolation<_PARAM_>::noeuds)[num0][1];
+ double x1=(*Calcul_Interpolation<_PARAM_>::noeuds)[num1][0];
+ double y1=(*Calcul_Interpolation<_PARAM_>::noeuds)[num1][1];
+ double x2=(*Calcul_Interpolation<_PARAM_>::noeuds)[num2][0];
+ double y2=(*Calcul_Interpolation<_PARAM_>::noeuds)[num2][1];
- VALEURCHAMP v0=(*champ)[num0];
- VALEURCHAMP v1=(*champ)[num1];
- VALEURCHAMP v2=(*champ)[num2];
+ VALEURCHAMP v0=(*Calcul_Interpolation<_PARAM_>::champ)[num0];
+ VALEURCHAMP v1=(*Calcul_Interpolation<_PARAM_>::champ)[num1];
+ VALEURCHAMP v2=(*Calcul_Interpolation<_PARAM_>::champ)[num2];
double x=n[0];
double y=n[1];
public : VALEURCHAMP operator() (const NOEUD & n, int num_maille)
{
// ON SUPPOSE IMPLICITEMENT QUE LES NOEUDS SUPPLEMENTAIRES SONT BIEN DES NOEUDS MILIEUX
- int num0 =(*mailles)[num_maille][0];
- int num1 =(*mailles)[num_maille][1];
- int num2 =(*mailles)[num_maille][2];
- int num01=(*mailles)[num_maille][3];
- int num12=(*mailles)[num_maille][4];
- int num20=(*mailles)[num_maille][5];
-
- double x0=(*noeuds)[num0][0];
- double y0=(*noeuds)[num0][1];
- double x1=(*noeuds)[num1][0];
- double y1=(*noeuds)[num1][1];
- double x2=(*noeuds)[num2][0];
- double y2=(*noeuds)[num2][1];
-
- VALEURCHAMP v0=(*champ)[num0];
- VALEURCHAMP v1=(*champ)[num1];
- VALEURCHAMP v2=(*champ)[num2];
- VALEURCHAMP v01=(*champ)[num01];
- VALEURCHAMP v12=(*champ)[num12];
- VALEURCHAMP v20=(*champ)[num20];
+ int num0 =(*Calcul_Interpolation<_PARAM_>::mailles)[num_maille][0];
+ int num1 =(*Calcul_Interpolation<_PARAM_>::mailles)[num_maille][1];
+ int num2 =(*Calcul_Interpolation<_PARAM_>::mailles)[num_maille][2];
+ int num01=(*Calcul_Interpolation<_PARAM_>::mailles)[num_maille][3];
+ int num12=(*Calcul_Interpolation<_PARAM_>::mailles)[num_maille][4];
+ int num20=(*Calcul_Interpolation<_PARAM_>::mailles)[num_maille][5];
+
+ double x0=(*Calcul_Interpolation<_PARAM_>::noeuds)[num0][0];
+ double y0=(*Calcul_Interpolation<_PARAM_>::noeuds)[num0][1];
+ double x1=(*Calcul_Interpolation<_PARAM_>::noeuds)[num1][0];
+ double y1=(*Calcul_Interpolation<_PARAM_>::noeuds)[num1][1];
+ double x2=(*Calcul_Interpolation<_PARAM_>::noeuds)[num2][0];
+ double y2=(*Calcul_Interpolation<_PARAM_>::noeuds)[num2][1];
+
+ VALEURCHAMP v0=(*Calcul_Interpolation<_PARAM_>::champ)[num0];
+ VALEURCHAMP v1=(*Calcul_Interpolation<_PARAM_>::champ)[num1];
+ VALEURCHAMP v2=(*Calcul_Interpolation<_PARAM_>::champ)[num2];
+ VALEURCHAMP v01=(*Calcul_Interpolation<_PARAM_>::champ)[num01];
+ VALEURCHAMP v12=(*Calcul_Interpolation<_PARAM_>::champ)[num12];
+ VALEURCHAMP v20=(*Calcul_Interpolation<_PARAM_>::champ)[num20];
double x=n[0];
double y=n[1];
public : Calcul_Interpolation_Quad4(NUAGENOEUD * nn,NUAGEMAILLE * nm,CHAMP * c):Calcul_Interpolation<_PARAM_>(nn,nm,c) {}
public : VALEURCHAMP operator() (const NOEUD & n, int num_maille)
{
- int num0=(*mailles)[num_maille][0];
- int num1=(*mailles)[num_maille][1];
- int num2=(*mailles)[num_maille][2];
- int num3=(*mailles)[num_maille][3];
-
- double x0=(*noeuds)[num0][0];
- double y0=(*noeuds)[num0][1];
- double x1=(*noeuds)[num1][0];
- double y1=(*noeuds)[num1][1];
- double x2=(*noeuds)[num2][0];
- double y2=(*noeuds)[num2][1];
- double x3=(*noeuds)[num3][0];
- double y3=(*noeuds)[num3][1];
-
- VALEURCHAMP v0=(*champ)[num0];
- VALEURCHAMP v1=(*champ)[num1];
- VALEURCHAMP v2=(*champ)[num2];
- VALEURCHAMP v3=(*champ)[num3];
+ int num0=(*Calcul_Interpolation<_PARAM_>::mailles)[num_maille][0];
+ int num1=(*Calcul_Interpolation<_PARAM_>::mailles)[num_maille][1];
+ int num2=(*Calcul_Interpolation<_PARAM_>::mailles)[num_maille][2];
+ int num3=(*Calcul_Interpolation<_PARAM_>::mailles)[num_maille][3];
+
+ double x0=(*Calcul_Interpolation<_PARAM_>::noeuds)[num0][0];
+ double y0=(*Calcul_Interpolation<_PARAM_>::noeuds)[num0][1];
+ double x1=(*Calcul_Interpolation<_PARAM_>::noeuds)[num1][0];
+ double y1=(*Calcul_Interpolation<_PARAM_>::noeuds)[num1][1];
+ double x2=(*Calcul_Interpolation<_PARAM_>::noeuds)[num2][0];
+ double y2=(*Calcul_Interpolation<_PARAM_>::noeuds)[num2][1];
+ double x3=(*Calcul_Interpolation<_PARAM_>::noeuds)[num3][0];
+ double y3=(*Calcul_Interpolation<_PARAM_>::noeuds)[num3][1];
+
+ VALEURCHAMP v0=(*Calcul_Interpolation<_PARAM_>::champ)[num0];
+ VALEURCHAMP v1=(*Calcul_Interpolation<_PARAM_>::champ)[num1];
+ VALEURCHAMP v2=(*Calcul_Interpolation<_PARAM_>::champ)[num2];
+ VALEURCHAMP v3=(*Calcul_Interpolation<_PARAM_>::champ)[num3];
double x=n[0];
double y=n[1];
public : Calcul_Interpolation_Tetra4(NUAGENOEUD * nn,NUAGEMAILLE * nm,CHAMP * c):Calcul_Interpolation<_PARAM_>(nn,nm,c) {}
public : VALEURCHAMP operator() (const NOEUD & n, int num_maille)
{
- int num0=(*mailles)[num_maille][0];
- int num1=(*mailles)[num_maille][1];
- int num2=(*mailles)[num_maille][2];
- int num3=(*mailles)[num_maille][3];
-
- double x0=(*noeuds)[num0][0];
- double y0=(*noeuds)[num0][1];
- double z0=(*noeuds)[num0][2];
- double x1=(*noeuds)[num1][0];
- double y1=(*noeuds)[num1][1];
- double z1=(*noeuds)[num1][2];
- double x2=(*noeuds)[num2][0];
- double y2=(*noeuds)[num2][1];
- double z2=(*noeuds)[num2][2];
- double x3=(*noeuds)[num3][0];
- double y3=(*noeuds)[num3][1];
- double z3=(*noeuds)[num3][2];
-
- VALEURCHAMP v0=(*champ)[num0];
- VALEURCHAMP v1=(*champ)[num1];
- VALEURCHAMP v2=(*champ)[num2];
- VALEURCHAMP v3=(*champ)[num3];
+ int num0=(*Calcul_Interpolation<_PARAM_>::mailles)[num_maille][0];
+ int num1=(*Calcul_Interpolation<_PARAM_>::mailles)[num_maille][1];
+ int num2=(*Calcul_Interpolation<_PARAM_>::mailles)[num_maille][2];
+ int num3=(*Calcul_Interpolation<_PARAM_>::mailles)[num_maille][3];
+
+ double x0=(*Calcul_Interpolation<_PARAM_>::noeuds)[num0][0];
+ double y0=(*Calcul_Interpolation<_PARAM_>::noeuds)[num0][1];
+ double z0=(*Calcul_Interpolation<_PARAM_>::noeuds)[num0][2];
+ double x1=(*Calcul_Interpolation<_PARAM_>::noeuds)[num1][0];
+ double y1=(*Calcul_Interpolation<_PARAM_>::noeuds)[num1][1];
+ double z1=(*Calcul_Interpolation<_PARAM_>::noeuds)[num1][2];
+ double x2=(*Calcul_Interpolation<_PARAM_>::noeuds)[num2][0];
+ double y2=(*Calcul_Interpolation<_PARAM_>::noeuds)[num2][1];
+ double z2=(*Calcul_Interpolation<_PARAM_>::noeuds)[num2][2];
+ double x3=(*Calcul_Interpolation<_PARAM_>::noeuds)[num3][0];
+ double y3=(*Calcul_Interpolation<_PARAM_>::noeuds)[num3][1];
+ double z3=(*Calcul_Interpolation<_PARAM_>::noeuds)[num3][2];
+
+ VALEURCHAMP v0=(*Calcul_Interpolation<_PARAM_>::champ)[num0];
+ VALEURCHAMP v1=(*Calcul_Interpolation<_PARAM_>::champ)[num1];
+ VALEURCHAMP v2=(*Calcul_Interpolation<_PARAM_>::champ)[num2];
+ VALEURCHAMP v3=(*Calcul_Interpolation<_PARAM_>::champ)[num3];
double x=n[0];
double y=n[1];
public : VALEURCHAMP operator() (const NOEUD & n, int num_maille)
{
// ON SUPPOSE IMPLICITEMENT QUE LES NOEUDS SUPPLEMENTAIRES SONT BIEN DES NOEUDS MILIEUX
- int num0 =(*mailles)[num_maille][0];
- int num1 =(*mailles)[num_maille][1];
- int num2 =(*mailles)[num_maille][2];
- int num3 =(*mailles)[num_maille][3];
- int num01=(*mailles)[num_maille][4];
- int num02=(*mailles)[num_maille][6];
- int num03=(*mailles)[num_maille][7];
- int num12=(*mailles)[num_maille][5];
- int num13=(*mailles)[num_maille][8];
- int num23=(*mailles)[num_maille][9];
-
- double x0=(*noeuds)[num0][0];double y0=(*noeuds)[num0][1];double z0=(*noeuds)[num0][2];
- double x1=(*noeuds)[num1][0];double y1=(*noeuds)[num1][1];double z1=(*noeuds)[num1][2];
- double x2=(*noeuds)[num2][0];double y2=(*noeuds)[num2][1];double z2=(*noeuds)[num2][2];
- double x3=(*noeuds)[num3][0];double y3=(*noeuds)[num3][1];double z3=(*noeuds)[num3][2];
-
- VALEURCHAMP v0=(*champ)[num0];
- VALEURCHAMP v1=(*champ)[num1];
- VALEURCHAMP v2=(*champ)[num2];
- VALEURCHAMP v3=(*champ)[num3];
- VALEURCHAMP v01=(*champ)[num01];
- VALEURCHAMP v02=(*champ)[num02];
- VALEURCHAMP v03=(*champ)[num03];
- VALEURCHAMP v12=(*champ)[num12];
- VALEURCHAMP v13=(*champ)[num13];
- VALEURCHAMP v23=(*champ)[num23];
+ int num0 =(*Calcul_Interpolation<_PARAM_>::mailles)[num_maille][0];
+ int num1 =(*Calcul_Interpolation<_PARAM_>::mailles)[num_maille][1];
+ int num2 =(*Calcul_Interpolation<_PARAM_>::mailles)[num_maille][2];
+ int num3 =(*Calcul_Interpolation<_PARAM_>::mailles)[num_maille][3];
+ int num01=(*Calcul_Interpolation<_PARAM_>::mailles)[num_maille][4];
+ int num02=(*Calcul_Interpolation<_PARAM_>::mailles)[num_maille][6];
+ int num03=(*Calcul_Interpolation<_PARAM_>::mailles)[num_maille][7];
+ int num12=(*Calcul_Interpolation<_PARAM_>::mailles)[num_maille][5];
+ int num13=(*Calcul_Interpolation<_PARAM_>::mailles)[num_maille][8];
+ int num23=(*Calcul_Interpolation<_PARAM_>::mailles)[num_maille][9];
+
+ double x0=(*Calcul_Interpolation<_PARAM_>::noeuds)[num0][0];double y0=(*Calcul_Interpolation<_PARAM_>::noeuds)[num0][1];double z0=(*Calcul_Interpolation<_PARAM_>::noeuds)[num0][2];
+ double x1=(*Calcul_Interpolation<_PARAM_>::noeuds)[num1][0];double y1=(*Calcul_Interpolation<_PARAM_>::noeuds)[num1][1];double z1=(*Calcul_Interpolation<_PARAM_>::noeuds)[num1][2];
+ double x2=(*Calcul_Interpolation<_PARAM_>::noeuds)[num2][0];double y2=(*Calcul_Interpolation<_PARAM_>::noeuds)[num2][1];double z2=(*Calcul_Interpolation<_PARAM_>::noeuds)[num2][2];
+ double x3=(*Calcul_Interpolation<_PARAM_>::noeuds)[num3][0];double y3=(*Calcul_Interpolation<_PARAM_>::noeuds)[num3][1];double z3=(*Calcul_Interpolation<_PARAM_>::noeuds)[num3][2];
+
+ VALEURCHAMP v0=(*Calcul_Interpolation<_PARAM_>::champ)[num0];
+ VALEURCHAMP v1=(*Calcul_Interpolation<_PARAM_>::champ)[num1];
+ VALEURCHAMP v2=(*Calcul_Interpolation<_PARAM_>::champ)[num2];
+ VALEURCHAMP v3=(*Calcul_Interpolation<_PARAM_>::champ)[num3];
+ VALEURCHAMP v01=(*Calcul_Interpolation<_PARAM_>::champ)[num01];
+ VALEURCHAMP v02=(*Calcul_Interpolation<_PARAM_>::champ)[num02];
+ VALEURCHAMP v03=(*Calcul_Interpolation<_PARAM_>::champ)[num03];
+ VALEURCHAMP v12=(*Calcul_Interpolation<_PARAM_>::champ)[num12];
+ VALEURCHAMP v13=(*Calcul_Interpolation<_PARAM_>::champ)[num13];
+ VALEURCHAMP v23=(*Calcul_Interpolation<_PARAM_>::champ)[num23];
double x=n[0];
double y=n[1];
// Tres probablement numériquement mauvais, à revoir
- int num0=(*mailles)[num_maille][0];
- int num1=(*mailles)[num_maille][1];
- int num2=(*mailles)[num_maille][2];
- int num3=(*mailles)[num_maille][3];
- int num4=(*mailles)[num_maille][4];
- int num5=(*mailles)[num_maille][5];
- int num6=(*mailles)[num_maille][6];
- int num7=(*mailles)[num_maille][7];
-
-
- double x0=(*noeuds)[num0][0];double y0=(*noeuds)[num0][1];double z0=(*noeuds)[num0][2];
- double x1=(*noeuds)[num1][0];double y1=(*noeuds)[num1][1];double z1=(*noeuds)[num1][2];
- double x2=(*noeuds)[num2][0];double y2=(*noeuds)[num2][1];double z2=(*noeuds)[num2][2];
- double x3=(*noeuds)[num3][0];double y3=(*noeuds)[num3][1];double z3=(*noeuds)[num3][2];
- double x4=(*noeuds)[num4][0];double y4=(*noeuds)[num4][1];double z4=(*noeuds)[num4][2];
- double x5=(*noeuds)[num5][0];double y5=(*noeuds)[num5][1];double z5=(*noeuds)[num5][2];
- double x6=(*noeuds)[num6][0];double y6=(*noeuds)[num6][1];double z6=(*noeuds)[num6][2];
- double x7=(*noeuds)[num7][0];double y7=(*noeuds)[num7][1];double z7=(*noeuds)[num7][2];
-
-
- VALEURCHAMP v0=(*champ)[num0];
- VALEURCHAMP v1=(*champ)[num1];
- VALEURCHAMP v2=(*champ)[num2];
- VALEURCHAMP v3=(*champ)[num3];
- VALEURCHAMP v4=(*champ)[num4];
- VALEURCHAMP v5=(*champ)[num5];
- VALEURCHAMP v6=(*champ)[num6];
- VALEURCHAMP v7=(*champ)[num7];
+ int num0=(*Calcul_Interpolation<_PARAM_>::mailles)[num_maille][0];
+ int num1=(*Calcul_Interpolation<_PARAM_>::mailles)[num_maille][1];
+ int num2=(*Calcul_Interpolation<_PARAM_>::mailles)[num_maille][2];
+ int num3=(*Calcul_Interpolation<_PARAM_>::mailles)[num_maille][3];
+ int num4=(*Calcul_Interpolation<_PARAM_>::mailles)[num_maille][4];
+ int num5=(*Calcul_Interpolation<_PARAM_>::mailles)[num_maille][5];
+ int num6=(*Calcul_Interpolation<_PARAM_>::mailles)[num_maille][6];
+ int num7=(*Calcul_Interpolation<_PARAM_>::mailles)[num_maille][7];
+
+
+ double x0=(*Calcul_Interpolation<_PARAM_>::noeuds)[num0][0];double y0=(*Calcul_Interpolation<_PARAM_>::noeuds)[num0][1];double z0=(*Calcul_Interpolation<_PARAM_>::noeuds)[num0][2];
+ double x1=(*Calcul_Interpolation<_PARAM_>::noeuds)[num1][0];double y1=(*Calcul_Interpolation<_PARAM_>::noeuds)[num1][1];double z1=(*Calcul_Interpolation<_PARAM_>::noeuds)[num1][2];
+ double x2=(*Calcul_Interpolation<_PARAM_>::noeuds)[num2][0];double y2=(*Calcul_Interpolation<_PARAM_>::noeuds)[num2][1];double z2=(*Calcul_Interpolation<_PARAM_>::noeuds)[num2][2];
+ double x3=(*Calcul_Interpolation<_PARAM_>::noeuds)[num3][0];double y3=(*Calcul_Interpolation<_PARAM_>::noeuds)[num3][1];double z3=(*Calcul_Interpolation<_PARAM_>::noeuds)[num3][2];
+ double x4=(*Calcul_Interpolation<_PARAM_>::noeuds)[num4][0];double y4=(*Calcul_Interpolation<_PARAM_>::noeuds)[num4][1];double z4=(*Calcul_Interpolation<_PARAM_>::noeuds)[num4][2];
+ double x5=(*Calcul_Interpolation<_PARAM_>::noeuds)[num5][0];double y5=(*Calcul_Interpolation<_PARAM_>::noeuds)[num5][1];double z5=(*Calcul_Interpolation<_PARAM_>::noeuds)[num5][2];
+ double x6=(*Calcul_Interpolation<_PARAM_>::noeuds)[num6][0];double y6=(*Calcul_Interpolation<_PARAM_>::noeuds)[num6][1];double z6=(*Calcul_Interpolation<_PARAM_>::noeuds)[num6][2];
+ double x7=(*Calcul_Interpolation<_PARAM_>::noeuds)[num7][0];double y7=(*Calcul_Interpolation<_PARAM_>::noeuds)[num7][1];double z7=(*Calcul_Interpolation<_PARAM_>::noeuds)[num7][2];
+
+
+ VALEURCHAMP v0=(*Calcul_Interpolation<_PARAM_>::champ)[num0];
+ VALEURCHAMP v1=(*Calcul_Interpolation<_PARAM_>::champ)[num1];
+ VALEURCHAMP v2=(*Calcul_Interpolation<_PARAM_>::champ)[num2];
+ VALEURCHAMP v3=(*Calcul_Interpolation<_PARAM_>::champ)[num3];
+ VALEURCHAMP v4=(*Calcul_Interpolation<_PARAM_>::champ)[num4];
+ VALEURCHAMP v5=(*Calcul_Interpolation<_PARAM_>::champ)[num5];
+ VALEURCHAMP v6=(*Calcul_Interpolation<_PARAM_>::champ)[num6];
+ VALEURCHAMP v7=(*Calcul_Interpolation<_PARAM_>::champ)[num7];
double x=n[0];
double y=n[1];
public : Calcul_Interpolation_Penta6(NUAGENOEUD * nn,NUAGEMAILLE * nm,CHAMP * c):Calcul_Interpolation<_PARAM_>(nn,nm,c) {}
public : VALEURCHAMP operator() (const NOEUD & n, int num_maille)
{
- int num0=(*mailles)[num_maille][0];
- int num1=(*mailles)[num_maille][1];
- int num2=(*mailles)[num_maille][2];
- int num3=(*mailles)[num_maille][3];
- int num4=(*mailles)[num_maille][4];
- int num5=(*mailles)[num_maille][5];
-
- double x0=(*noeuds)[num0][0];double y0=(*noeuds)[num0][1];double z0=(*noeuds)[num0][2];
- double x1=(*noeuds)[num1][0];double y1=(*noeuds)[num1][1];double z1=(*noeuds)[num1][2];
- double x2=(*noeuds)[num2][0];double y2=(*noeuds)[num2][1];double z2=(*noeuds)[num2][2];
- double x3=(*noeuds)[num3][0];double y3=(*noeuds)[num3][1];double z3=(*noeuds)[num3][2];
- double x4=(*noeuds)[num4][0];double y4=(*noeuds)[num4][1];double z4=(*noeuds)[num4][2];
- double x5=(*noeuds)[num5][0];double y5=(*noeuds)[num5][1];double z5=(*noeuds)[num5][2];
-
- VALEURCHAMP v0=(*champ)[num0];
- VALEURCHAMP v1=(*champ)[num1];
- VALEURCHAMP v2=(*champ)[num2];
- VALEURCHAMP v3=(*champ)[num3];
- VALEURCHAMP v4=(*champ)[num4];
- VALEURCHAMP v5=(*champ)[num5];
+ int num0=(*Calcul_Interpolation<_PARAM_>::mailles)[num_maille][0];
+ int num1=(*Calcul_Interpolation<_PARAM_>::mailles)[num_maille][1];
+ int num2=(*Calcul_Interpolation<_PARAM_>::mailles)[num_maille][2];
+ int num3=(*Calcul_Interpolation<_PARAM_>::mailles)[num_maille][3];
+ int num4=(*Calcul_Interpolation<_PARAM_>::mailles)[num_maille][4];
+ int num5=(*Calcul_Interpolation<_PARAM_>::mailles)[num_maille][5];
+
+ double x0=(*Calcul_Interpolation<_PARAM_>::noeuds)[num0][0];double y0=(*Calcul_Interpolation<_PARAM_>::noeuds)[num0][1];double z0=(*Calcul_Interpolation<_PARAM_>::noeuds)[num0][2];
+ double x1=(*Calcul_Interpolation<_PARAM_>::noeuds)[num1][0];double y1=(*Calcul_Interpolation<_PARAM_>::noeuds)[num1][1];double z1=(*Calcul_Interpolation<_PARAM_>::noeuds)[num1][2];
+ double x2=(*Calcul_Interpolation<_PARAM_>::noeuds)[num2][0];double y2=(*Calcul_Interpolation<_PARAM_>::noeuds)[num2][1];double z2=(*Calcul_Interpolation<_PARAM_>::noeuds)[num2][2];
+ double x3=(*Calcul_Interpolation<_PARAM_>::noeuds)[num3][0];double y3=(*Calcul_Interpolation<_PARAM_>::noeuds)[num3][1];double z3=(*Calcul_Interpolation<_PARAM_>::noeuds)[num3][2];
+ double x4=(*Calcul_Interpolation<_PARAM_>::noeuds)[num4][0];double y4=(*Calcul_Interpolation<_PARAM_>::noeuds)[num4][1];double z4=(*Calcul_Interpolation<_PARAM_>::noeuds)[num4][2];
+ double x5=(*Calcul_Interpolation<_PARAM_>::noeuds)[num5][0];double y5=(*Calcul_Interpolation<_PARAM_>::noeuds)[num5][1];double z5=(*Calcul_Interpolation<_PARAM_>::noeuds)[num5][2];
+
+ VALEURCHAMP v0=(*Calcul_Interpolation<_PARAM_>::champ)[num0];
+ VALEURCHAMP v1=(*Calcul_Interpolation<_PARAM_>::champ)[num1];
+ VALEURCHAMP v2=(*Calcul_Interpolation<_PARAM_>::champ)[num2];
+ VALEURCHAMP v3=(*Calcul_Interpolation<_PARAM_>::champ)[num3];
+ VALEURCHAMP v4=(*Calcul_Interpolation<_PARAM_>::champ)[num4];
+ VALEURCHAMP v5=(*Calcul_Interpolation<_PARAM_>::champ)[num5];
double x=n[0];
double y=n[1];
public : VALEURCHAMP operator() (const NOEUD & n, int num_maille)
{
// NON TESTE
- int num0=(*mailles)[num_maille][0];
- int num1=(*mailles)[num_maille][1];
- int num2=(*mailles)[num_maille][2];
- int num3=(*mailles)[num_maille][3];
- int num4=(*mailles)[num_maille][4];
-
- double x0=(*noeuds)[num0][0];double y0=(*noeuds)[num0][1];double z0=(*noeuds)[num0][2];
- double x1=(*noeuds)[num1][0];double y1=(*noeuds)[num1][1];double z1=(*noeuds)[num1][2];
- double x2=(*noeuds)[num2][0];double y2=(*noeuds)[num2][1];double z2=(*noeuds)[num2][2];
- double x3=(*noeuds)[num3][0];double y3=(*noeuds)[num3][1];double z3=(*noeuds)[num3][2];
- double x4=(*noeuds)[num4][0];double y4=(*noeuds)[num4][1];double z4=(*noeuds)[num4][2];
-
- VALEURCHAMP v0=(*champ)[num0];
- VALEURCHAMP v1=(*champ)[num1];
- VALEURCHAMP v2=(*champ)[num2];
- VALEURCHAMP v3=(*champ)[num3];
- VALEURCHAMP v4=(*champ)[num4];
+ int num0=(*Calcul_Interpolation<_PARAM_>::mailles)[num_maille][0];
+ int num1=(*Calcul_Interpolation<_PARAM_>::mailles)[num_maille][1];
+ int num2=(*Calcul_Interpolation<_PARAM_>::mailles)[num_maille][2];
+ int num3=(*Calcul_Interpolation<_PARAM_>::mailles)[num_maille][3];
+ int num4=(*Calcul_Interpolation<_PARAM_>::mailles)[num_maille][4];
+
+ double x0=(*Calcul_Interpolation<_PARAM_>::noeuds)[num0][0];double y0=(*Calcul_Interpolation<_PARAM_>::noeuds)[num0][1];double z0=(*Calcul_Interpolation<_PARAM_>::noeuds)[num0][2];
+ double x1=(*Calcul_Interpolation<_PARAM_>::noeuds)[num1][0];double y1=(*Calcul_Interpolation<_PARAM_>::noeuds)[num1][1];double z1=(*Calcul_Interpolation<_PARAM_>::noeuds)[num1][2];
+ double x2=(*Calcul_Interpolation<_PARAM_>::noeuds)[num2][0];double y2=(*Calcul_Interpolation<_PARAM_>::noeuds)[num2][1];double z2=(*Calcul_Interpolation<_PARAM_>::noeuds)[num2][2];
+ double x3=(*Calcul_Interpolation<_PARAM_>::noeuds)[num3][0];double y3=(*Calcul_Interpolation<_PARAM_>::noeuds)[num3][1];double z3=(*Calcul_Interpolation<_PARAM_>::noeuds)[num3][2];
+ double x4=(*Calcul_Interpolation<_PARAM_>::noeuds)[num4][0];double y4=(*Calcul_Interpolation<_PARAM_>::noeuds)[num4][1];double z4=(*Calcul_Interpolation<_PARAM_>::noeuds)[num4][2];
+
+ VALEURCHAMP v0=(*Calcul_Interpolation<_PARAM_>::champ)[num0];
+ VALEURCHAMP v1=(*Calcul_Interpolation<_PARAM_>::champ)[num1];
+ VALEURCHAMP v2=(*Calcul_Interpolation<_PARAM_>::champ)[num2];
+ VALEURCHAMP v3=(*Calcul_Interpolation<_PARAM_>::champ)[num3];
+ VALEURCHAMP v4=(*Calcul_Interpolation<_PARAM_>::champ)[num4];
double x=n[0];
double y=n[1];
exit(-1);
}
- int i,j,k;
+ int i;
int nbr_noeuds=noeuds_front->SIZE();
int num_maille_depart;
int nma=0;
_TEMPLATE_SPE_ vector<double> _COORDBARY_2D_::Donne_Pseudo_Coord_Baryc(int num_maille,const NOEUD &M)
{
- int i,j,nbr_faces;
+ int i,nbr_faces;
if (etat_coord_baryc[num_maille]==FAUX)
{
- nbr_faces=(*mailles).DONNE_NBR_FACES();
+ nbr_faces=(*mailles)[num_maille].DONNE_NBR_FACES();
coord_baryc[num_maille]=vector< vector<double> >(nbr_faces);
+ type_retour simplexe_base;
+
for (i=0;i<nbr_faces;i++)
{
- vector<int> simplexe_base=(*mailles).DONNE_SIMPLEXE_BASE(i);
- coord_baryc[num_maille][i]=Calcule_Base_Coord_Baryc(simplexe_base);
+ (*mailles)[num_maille].DONNE_SIMPLEXE_BASE(i,simplexe_base);
+ coord_baryc[num_maille][i]=Calcule_Base_Coord_Baryc(vector<int>(&simplexe_base.quoi[0],&simplexe_base.quoi[simplexe_base.combien]));
etat_coord_baryc[num_maille]=VRAI;
}
}
{
const vector<int> &ref=simplexe_base;
vector<double> retour(3);
- int i,j;
double x0=(*sommets)[ref[0]][0];
double y0=(*sommets)[ref[0]][1];
_TEMPLATE_SPE_ vector<double> _COORDBARY_3D_::Donne_Pseudo_Coord_Baryc(int num_maille,const NOEUD &M)
{
- int i,j,nbr_faces;
+ int i,nbr_faces;
if (etat_coord_baryc[num_maille]==FAUX)
{
nbr_faces=(*mailles)[num_maille].DONNE_NBR_FACES();
{
const vector<int> &ref=simplexe_base;
vector<double> retour(4);
- int i,j;
double x0=(*sommets)[ref[0]][0];
double y0=(*sommets)[ref[0]][1];
{
type_retour face_loc;
int num_face;
- int taille_face_exam;
- int test=FAUX;
for (num_face=0;num_face<DONNE_NBR_FACES();num_face++)
{
DONNE_FACE(num_face,face_loc);
exit(-1);
}
- int i,j,k;
+ int i,j;
int num_local_face;
- int ind_num_noeud,num_noeud;
+ int num_noeud;
int num_maille;
int ind_num_maille_sec,num_maille_sec;
- int num_local_sec;
int flag_existence;
int nbr_mailles=mailles->SIZE();
int nbr_formants=0;
#define NULL 0
#endif
+#include <math.h>
+
//////////////////////////////////////////////////////////////////
/// ///
/// DECLARATIONS ///
if (mypere!=NULL)
{
- int i,j;
- double tmp;
+ int i;
init();
// Pas Super Top Moumoute ... Recopie de pointeurs et pas de contenus, merdique
int i,j;
init();
- for (i=0;i<nbr_descendans;i++) descendant[i]=F.descendant[i];
+ for (i=0;i<_DTREE_::nbr_descendans;i++) descendant[i]=F.descendant[i];
noeud_contenu=F.noeud_contenu;
etat=F.etat;
niveau=F.niveau;
if (!test) break;
}
- if (test) return descendant[i]->trouve_dTree_contenant(P); // Propagation
+ if (test)
+ return descendant[i]->trouve_dTree_contenant(P); // Propagation
}
+ return NULL;
}
// si de le dTree n'est pas TERMINAL, scanne tous les points du nuage du pere pour trouver le point le plus proche
// sinon scanne uniquement les points contenus dans le dTree
#include "stdio.h"
+#ifdef _DEBUG_
+#include "LocalTraceCollector.hxx"
+#endif /* ifdef _DEBUG_*/
+
using namespace MEDMEM;
using namespace MED_EN;
main () {
-
+#ifdef _DEBUG_
+ LocalTraceCollector::instance();
+#endif /* ifdef _DEBUG_*/
+
const char * fromFileName = "ResultatSyrthes.med";
const char * toFileName = "MaillageAster.med";
const char * resultFileName = "ResultatInterpolation.med";
#include "stdio.h"
+#ifdef _DEBUG_
+#include "LocalTraceCollector.hxx"
+#endif /* ifdef _DEBUG_*/
+
using namespace MEDMEM;
using namespace MED_EN;
main () {
-
+#ifdef _DEBUG_
+ LocalTraceCollector::instance();
+#endif /* ifdef _DEBUG_*/
+
const char * fromFileName = "fromMesh.med";
const char * toFileName = "toMesh.med";
const char * fieldName = "fieldnodedouble";
#include "MEDMEM_InterpolationHighLevelObjects.hxx"
+#ifdef _DEBUG_
+#include "LocalTraceCollector.hxx"
+#endif /* ifdef _DEBUG_*/
+
using namespace MEDMEM;
using namespace MED_EN;
int main (void)
{
+#ifdef _DEBUG_
+ LocalTraceCollector::instance();
+#endif /* ifdef _DEBUG_*/
+
int i;
const int DIMENSION = 3;
#include "MEDMEM_InterpolationHighLevelObjects.hxx"
+#ifdef _DEBUG_
+#include "LocalTraceCollector.hxx"
+#endif /* ifdef _DEBUG_*/
+
using namespace MEDMEM;
using namespace MED_EN;
int main (void)
{
+#ifdef _DEBUG_
+ LocalTraceCollector::instance();
+#endif /* ifdef _DEBUG_*/
+
int i,j;
const char * fromFileName = "fromMesh.med";
#include "MEDMEM_InterpolationHighLevelObjects.hxx"
+#ifdef _DEBUG_
+#include "LocalTraceCollector.hxx"
+#endif /* ifdef _DEBUG_*/
+
#define affiche(NOEUD) cout<<flush;for (int iii=0;iii<DIMENSION;iii++) cout<<NOEUD[iii]<<" "<<flush;
int main (void)
{
+#ifdef _DEBUG_
+ LocalTraceCollector::instance();
+#endif /* ifdef _DEBUG_*/
+
int i;
const int DIMENSION = 3;
#include "stdio.h"
+#ifdef _DEBUG_
+#include "LocalTraceCollector.hxx"
+#endif /* ifdef _DEBUG_*/
+
main () {
-
+#ifdef _DEBUG_
+ LocalTraceCollector::instance();
+#endif /* ifdef _DEBUG_*/
+
const char * fromFileName = "fromMesh.med";
const char * toFileName = "toMesh.med";
//const char * fieldName = "fieldcelldoublevector";
#include "stdio.h"
+#ifdef _DEBUG_
+#include "LocalTraceCollector.hxx"
+#endif /* ifdef _DEBUG_*/
+
using namespace MEDMEM;
// pour gestion timings
#include "MEDMEM_WrapperCells.hxx"
main () {
+#ifdef _DEBUG_
+ LocalTraceCollector::instance();
+#endif /* ifdef _DEBUG_*/
const char * fromFileName = "ResultatSyrthes.med";
const char * toFileName = "MaillageAster.med";
#include "stdio.h"
+#ifdef _DEBUG_
+#include "LocalTraceCollector.hxx"
+#endif /* ifdef _DEBUG_*/
+
using namespace MEDMEM;
using namespace MED_EN;
main () {
-
+#ifdef _DEBUG_
+ LocalTraceCollector::instance();
+#endif /* ifdef _DEBUG_*/
+
const char * fromFileName = "fromMesh.med";
const char * toFileName = "toMesh.med";
//const char * fieldName = "fieldcelldoublevector";
#include "stdio.h"
+#ifdef _DEBUG_
+#include "LocalTraceCollector.hxx"
+#endif /* ifdef _DEBUG_*/
+
using namespace MEDMEM;
using namespace MED_EN;
#include "MEDMEM_WrapperCells.hxx"
main () {
+#ifdef _DEBUG_
+ LocalTraceCollector::instance();
+#endif /* ifdef _DEBUG_*/
+
/*
int taille=100;
int * liste = new int [taille] ;
#include "stdio.h"
+#ifdef _DEBUG_
+#include "LocalTraceCollector.hxx"
+#endif /* ifdef _DEBUG_*/
+
using namespace MEDMEM;
using namespace MED_EN;
main () {
-
+#ifdef _DEBUG_
+ LocalTraceCollector::instance();
+#endif /* ifdef _DEBUG_*/
+
const char * fromFileName = "ResultatSyrthes.med";
const char * toFileName = "MaillageAster.med";
// const char * resultFileName = "ResultatInterpolation.med";
#include "stdio.h"
+#ifdef _DEBUG_
+#include "LocalTraceCollector.hxx"
+#endif /* ifdef _DEBUG_*/
+
using namespace MEDMEM;
using namespace MED_EN;
main () {
-
+#ifdef _DEBUG_
+ LocalTraceCollector::instance();
+#endif /* ifdef _DEBUG_*/
+
const char * fromFileName = "ResultatSyrthes.med";
const char * toFileName = "MaillageAster.med";
const char * resultFileName = "ResultatInterpolation.med";
LIB_SERVER_IDL = MED_Gen.idl SALOME_Component.idl \
SALOME_Exception.idl MED.idl
-LIB_CLIENT_IDL = SALOMEDS.idl SALOMEDS_Attributes.idl SALOME_ModuleCatalog.idl SALOME_Comm.idl
+LIB_CLIENT_IDL = SALOMEDS.idl SALOMEDS_Attributes.idl SALOME_ModuleCatalog.idl SALOME_Comm.idl SALOME_GenericObj.idl
# Executables targets
BIN =
#include "MEDMEM_Field.hxx"
#include "MEDMEM_Med.hxx"
#include "MEDMEM_MedMedDriver.hxx"
-#include "MEDMEM_MedMeshDriver.hxx"
+#include "MEDMEM_MedMeshDriver21.hxx"
#include "MEDMEM_MedFieldDriver.hxx"
#include "MEDMEM_define.hxx"
#include "MEDMEM_DriversDef.hxx"
MESH * myMesh= new MESH() ;
myMesh->setName(meshName);
- MED_MESH_RDONLY_DRIVER myMeshDriver(fileName,myMesh);
+ MED_MESH_RDONLY_DRIVER21 myMeshDriver(fileName,myMesh);
try
{
myMeshDriver.setMeshName(meshName);
sprintf(aFileName, "%shdf_from_ascii.hdf", aResultPath);
delete(aResultPath);
} else aFileName = CORBA::string_dup((aTmpDir + aSaveStudyName + (char*)aLocalPersistentID).ToCString());
- MED_MESH_RDONLY_DRIVER myMeshDriver(aFileName,myMesh);
+ MED_MESH_RDONLY_DRIVER21 myMeshDriver(aFileName,myMesh);
try
{
myMeshDriver.setMeshName(aMeshName);
char* aFullMeshName = new char[strlen(aMeshName)+1];
strcpy(aFullMeshName,aMeshName);
myMesh->setName(aFullMeshName);
- MED_MESH_RDONLY_DRIVER myMeshDriver(aFullName, myMesh);
+ MED_MESH_RDONLY_DRIVER21 myMeshDriver(aFullName, myMesh);
try {
myMeshDriver.setMeshName(aFullMeshName);
myMeshDriver.open();
+++ /dev/null
-# MED MEDGUI : MED component GUI implemetation
-#
-# 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 : MedGUI_icons.po
-# Module : MED
-
-msgid ""
-msgstr ""
-"Project-Id-Version: PROJECT VERSION\n"
-"POT-Creation-Date: 2001-06-14 09:11:49 PM CEST\n"
-"PO-Revision-Date: YYYY-MM-DD\n"
-"Last-Translator: FULLNAME <EMAIL@ADDRESS>\n"
-"Content-Type: text/plain; charset=iso-8859-1\n"
-
-<
\ No newline at end of file
--- /dev/null
+# MED MEDGUI : MED component GUI implemetation
+#
+# 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 : MedGUI_icons.po
+# Module : MED
+
+msgid ""
+msgstr ""
+"Project-Id-Version: PROJECT VERSION\n"
+"POT-Creation-Date: 2001-06-14 09:11:49 PM CEST\n"
+"PO-Revision-Date: YYYY-MM-DD\n"
+"Last-Translator: FULLNAME <EMAIL@ADDRESS>\n"
+"Content-Type: text/plain; charset=iso-8859-1\n"
+
+msgid "ICO_TB_MESHSEL"
+msgstr "Data.png"
+
+msgid "ICO_TB_FIELDSEL"
+msgstr "Infos.png"
+
+msgid "ICO_TB_EXPLORE"
+msgstr "Structure.png"
+
+
-# MED MEDGUI : MED component GUI implemetation
+# MED MEDGUI : MED component GUI implemetation
#
# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"POT-Creation-Date: 2001-09-21 14:31:28 METDST\n"
-"PO-Revision-Date: YYYY-MM-DD\n"
+"PO-Revision-Date: 2005-06-09 14:38+0400\n"
"Last-Translator: FULLNAME <EMAIL@ADDRESS>\n"
"Content-Type: text/plain; charset=iso-8859-1\n"
msgstr "All Files ( * )"
#: MedGUI.cxx:167
+#, fuzzy
msgid "MedGUI::MED_MEN_IMPORT"
msgstr "Import"
#: MedGUI.cxx:297
msgid "MED_INF_FIELDNAME"
msgstr "Please enter the name of the field you want to read"
+
+
+# Menu items
+
+msgid "TOP_MESHSEL"
+msgstr "Mesh selection"
+
+msgid "MEN_MESHSEL"
+msgstr "Mesh selection"
+
+msgid "STB_MESHSEL"
+msgstr "Read a mesh"
+
+msgid "TOP_FIELDSEL"
+msgstr "Field selection"
+
+msgid "MEN_FIELDSEL"
+msgstr "Field selection"
+
+msgid "STB_FIELDSEL"
+msgstr "Read a field"
+
+msgid "TOP_EXPLORE"
+msgstr "Explore Med File"
+
+msgid "MEN_EXPLORE"
+msgstr "Explore Med File"
+
+msgid "STB_EXPLORE"
+msgstr "Explore Med File"
+
+msgid "TOP_DUMPMESH"
+msgstr "Dump Mesh"
+
+msgid "MEN_DUMPMESH"
+msgstr "Dump Mesh"
+
+msgid "STB_DUMPMESH"
+msgstr "dump Mesh"
+
+msgid "TOP_DUMPSUBMESH"
+msgstr "Dump SubMesh"
+
+msgid "MEN_DUMPSUBMESH"
+msgstr "Dump SubMesh"
+
+msgid "STB_DUMPSUBMESH"
+msgstr "dump Mesh"
+
+msgid "TOP_POPUPTEST"
+msgstr "Popup test"
+
+msgid "MEN_POPUPTEST"
+msgstr "Popup test"
+
+msgid "STB_POPUPTEST"
+msgstr "Popup test"
+
+msgid "TOP_ERASE"
+msgstr "Erase"
+
+msgid "MEN_ERASE"
+msgstr "Erase"
+
+msgid "STB_ERASE"
+msgstr "Erase"
+
+msgid "TOP_DISPLAY"
+msgstr "Display"
+
+msgid "MEN_DISPLAY"
+msgstr "Display"
+
+msgid "STB_DISPLAY"
+msgstr "Display"
+
+
+
+msgid "TB_MED"
+msgstr "Med Toolbar"
+
-# MED MEDGUI : MED component GUI implemetation
+# MED MEDGUI : MED component GUI implemetation
#
# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
# 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
+# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
#
#
#
# .po files to transform in .qm
PO_FILES = \
- MED_icons.po \
+ MED_images.po \
MED_msg_fr.po \
MED_msg_en.po \
# Libraries targets
-LIB = libMEDGUI.la
-LIB_SRC = MedGUI.cxx
+LIB = libMED.la
+LIB_SRC = MedGUI.cxx MedGUI_Selection.cxx
LIB_MOC = MedGUI.h
-LIB_CLIENT_IDL = SALOMEDS.idl SALOME_Exception.idl \
+LIB_CLIENT_IDL = SALOMEDS.idl SALOME_Exception.idl SALOME_Component.idl \
MED_Gen.idl MED.idl \
- SALOMEDS_Attributes.idl SALOME_Comm.idl
+ SALOMEDS_Attributes.idl SALOME_Comm.idl SALOME_GenericObj.idl
# SMESH_Mesh.idl SMESH_Hypothesis.idl SMESH_BasicHypothesis.idl \
# GEOM_Shape.idl SALOMEDS_Attributes.idl
# additionnal information to compil and link file
-CPPFLAGS += $(QT_INCLUDES) $(VTK_INCLUDES) $(OCC_INCLUDES) $(PYTHON_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome
-LDFLAGS += -lSalomeGUI -lMEDMEMImpl -lmedmem -lMEDEngine -I${KERNEL_ROOT_DIR}/include/salome
+CPPFLAGS += $(QT_INCLUDES) $(VTK_INCLUDES) $(OCC_INCLUDES) $(PYTHON_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome -I${GUI_ROOT_DIR}/include/salome -I${BOOSTDIR}
+LDFLAGS += -lSalomeApp -lMEDMEMImpl -lmedmem -lMEDEngine -I${KERNEL_ROOT_DIR}/include/salome -I${GUI_ROOT_DIR}/include/salome -I${BOOSTDIR}
-LDFLAGS += -lSalomeGUI -lMEDMEMImpl -lmedmem -lMEDEngine -L${KERNEL_ROOT_DIR}/lib/salome
+LDFLAGS += -lSalomeApp -lMEDMEMImpl -lmedmem -lMEDEngine -L${KERNEL_ROOT_DIR}/lib/salome -L${GUI_ROOT_DIR}/lib/salome
MED.hh MEDSK.cc: MED.idl
omniidl -bcxx -Wbtp -I$(top_builddir)/idl -I${KERNEL_ROOT_DIR}/idl/salome $^
-// MED MEDGUI : MED component GUI implemetation
+// MED MEDGUI : MED component GUI implemetation
//
// 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
+// 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
//
//
//
#include "Utils_SINGLETON.hxx"
#include "utilities.h"
-#include "SALOME_Selection.h"
-#include "SALOME_InteractiveObject.hxx"
-#include "SALOMEGUI_QtCatchCorbaException.hxx"
+#include <SALOME_LifeCycleCORBA.hxx>
+#include <SALOME_InteractiveObject.hxx>
+#include <SALOME_ListIO.hxx>
+#include <SalomeApp_Tools.h>
+
+#include <SUIT_MessageBox.h>
+#include <SUIT_Tools.h>
+#include <SUIT_FileDlg.h>
+#include <SUIT_ResourceMgr.h>
-#include "QAD_MessageBox.h"
-#include "QAD_Tools.h"
-#include "QAD_FileDlg.h"
+#include <CAM_Application.h>
+#include <SalomeApp_Application.h>
+#include <SalomeApp_DataModel.h>
+#include <SalomeApp_Study.h>
+#include <SalomeApp_SelectionMgr.h>
+#include <SALOMEDSClient_Study.hxx>
+#include <SALOMEDSClient_SObject.hxx>
+
+#include <OB_Browser.h>
//#include "SMESH_TypeFilter.hxx"
+#include <MedGUI_Selection.h>
+
// QT Includes
#include <qinputdialog.h>
*
*/
//=============================================================================
-MedGUI::MedGUI( const QString& theName, QObject* theParent ) :
- SALOMEGUI( theName, theParent )
+MedGUI::MedGUI() :
+ SalomeApp_Module( "MED" )
{}
-bool MedGUI::OnGUIEvent (int theCommandID, QAD_Desktop* parent)
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+void MedGUI::createPopupItem( const int id,
+ const QString& clients,
+ const QString& types,
+ const QString& theRule,
+ const int pId )
{
- setOrb();
+ int parentId = pId;
+ if( pId!=-1 )
+ parentId = popupMgr()->actionId( action( pId ) );
+
+ if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
+ popupMgr()->insert( action( id ), parentId, 0 );
+
+ QChar lc = QtxPopupMgr::Selection::defEquality();
+ QString rule = "(%1)";
+ if( !types.isEmpty() )
+ rule += " and (%2) and (%3)";
+
+ rule = rule.arg( QString( "client in {%1}" ).arg( clients ) );
+
+ if( !types.isEmpty() )
+ {
+ rule = rule.arg( QString( "%1>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() ) );
+ rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
+ }
+ rule += theRule;
+ popupMgr()->setRule( action( id ), rule, true );
+}
+
+void MedGUI::createMedAction( const int id, const QString& po_id, const QString& icon_id )
+{
+ QWidget* parent = application()->desktop();
+ SUIT_ResourceMgr* mgr = application()->resourceMgr();
+
+ QPixmap pix; QIconSet icon;
+ if( !icon_id.isEmpty() )
+ pix = mgr->loadPixmap( "MED", tr( icon_id ) );
+ else
+ pix = mgr->loadPixmap( "MED", tr( QString( "ICO_" )+po_id ) );
+ if ( !pix.isNull() )
+ icon = QIconSet( pix );
+
+ createAction( id, tr( "TOP_" + po_id ), icon, tr( "MEN_" + po_id ), tr( "STB_" + po_id ), 0, parent, false, this, SLOT( onGUIEvent() ) );
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+void MedGUI::initialize( CAM_Application* app )
+{
+ SalomeApp_Module::initialize( app );
- QAD_Study* myActiveStudy = parent->getActiveStudy();
- SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
- SALOME_NamingService* myNameService = parent->getNameService();
+ QWidget* parent = application()->desktop();
+
+ createMedAction( 931, "MESHSEL" );
+ createMedAction( 932, "FIELDSEL" );
+ createMedAction( 933, "EXPLORE" );
+ createMedAction( 934, "DUMPMESH" );
+ createMedAction( 935, "DUMPSUBMESH" );
+ createMedAction( 8031, "POPUPTEST" );
+ createMedAction( 9002, "ERASE" );
+ createMedAction( 903, "DISPLAY" );
+ createMedAction( 4031, "MESHSEL", "ICO_TB_MESHSEL" );
+ createMedAction( 4032, "FIELDSEL", "ICO_TB_FIELDSEL" );
+ createMedAction( 4033, "EXPLORE", "ICO_TB_EXPLORE" );
+
+ int MedId = createMenu( tr( "MED" ), -1, 50, 10 );
+ createMenu( separator(), MedId, 10 );
+ createMenu( 931, MedId, 11 );
+ createMenu( 932, MedId, 11 );
+ createMenu( 933, MedId, 11 );
+ createMenu( 934, MedId, 11 );
+ createMenu( 935, MedId, 11 );
+
+ int medTb = createTool( tr( "TB_MED" ) );
+ createTool( 4031, medTb );
+ createTool( 4032, medTb );
+ createTool( 4033, medTb );
+
+ QString OB = "'ObjectBrowser'",
+ View = QString("'%1'").arg( "VTKViewer" /* SVTK_Viewer::Type()*/ );
+
+ createPopupItem( 8031, View, "", "" );
+ createPopupItem( 9002, OB, "", "" );
+ createPopupItem( 903, OB, "", "" );
+}
+
+void MedGUI::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& /*title*/ )
+{
+ MedGUI_Selection sel;
+ SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( application() );
+ if( app )
+ {
+ sel.init( client, app->selectionMgr() );
+ popupMgr()->updatePopup( menu, &sel );
+ }
+}
+
+QString MedGUI::engineIOR() const
+{
+ SALOME_MED::MED_Gen_ptr aMedGen = InitMedGen();
+ if ( !CORBA::is_nil( aMedGen) )
+ return QString( getApp()->orb()->object_to_string( aMedGen ));
+ return QString( "" );
+}
+
+void MedGUI::windows( QMap<int, int>& mappa ) const
+{
+ mappa.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
+ mappa.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
+}
+
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+void MedGUI::onGUIEvent()
+{
+ const QObject* obj = sender();
+ if ( !obj || !obj->inherits( "QAction" ) )
+ return;
+ int id = actionId((QAction*)obj);
+ if ( id != -1 )
+ OnGUIEvent( id );
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+void MedGUI::EmitSignalCloseAllDialogs()
+{
+ emit SignalCloseAllDialogs();
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+bool MedGUI::deactivateModule( SUIT_Study* study )
+{
+ setMenuShown( false );
+ setToolShown( false );
+
+ disconnect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
+ this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
+
+ EmitSignalCloseAllDialogs();
+
+ return SalomeApp_Module::deactivateModule( study );
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+bool MedGUI::activateModule( SUIT_Study* study )
+{
+ bool res = SalomeApp_Module::activateModule( study );
+
+ setMenuShown( true );
+ setToolShown( true );
+
+ connect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
+ this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
+ return res;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+void MedGUI::onWindowActivated( SUIT_ViewWindow* )
+{
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+bool MedGUI::OnGUIEvent (int theCommandID)
+{
+ setOrb();
+
+ SalomeApp_Study* myActiveStudy = dynamic_cast< SalomeApp_Study* >( application()->activeStudy() );
+ if( !myActiveStudy )
+ return false;
+
+ _PTR(Study) aStudy = myActiveStudy->studyDS();
+ //SALOME_NamingService* myNameService = parent->getNameService();
QString file;
- QStringList filtersList ;
+ QStringList filtersList ;
filtersList.append( tr("MED_MEN_IMPORT_MED") );
filtersList.append( tr("MED_MEN_ALL_FILES") ) ;
+ SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( application() );
+ if( !app )
+ return false;
+
switch (theCommandID)
{
case 4031:
{
MESSAGE("command " << theCommandID << " activated");
- QString myStudyName = myActiveStudy->getTitle();
+ QString myStudyName = myActiveStudy->studyName();
bool ok=FALSE;
- int myStudyId = myActiveStudy->getStudyId();
+ int myStudyId = myActiveStudy->id();
// load MED engine
- SALOME_MED::MED_Gen_ptr medgen = InitMedGen(parent);
+ SALOME_MED::MED_Gen_ptr medgen = InitMedGen();
// Selection du Fichier
- file = QAD_FileDlg::getFileName(parent,
+ file = SUIT_FileDlg::getFileName(application()->desktop(),
"",
filtersList,
tr("MED_MEN_IMPORT"),
{
SCRUTE(file);
QString meshName;
- meshName = QInputDialog::getText( QString( tr("MED_INF_MESHNAME") ),
+ meshName = QInputDialog::getText( QString( tr("MED_INF_MESHNAME") ),
QString::null,
//VRV: porting on Qt 3.0.5
#if QT_VERSION >= 0x030005
try
{
medgen->readMeshInFile(file.latin1(),myStudyName,meshName);
- if (myActiveStudy->getStudyDocument()->GetProperties()->IsLocked()) {
- QAD_MessageBox::warn1 ((QWidget*)QAD_Application::getDesktop(),
- QObject::tr("WRN_WARNING"),
+ if (myActiveStudy->studyDS()->GetProperties()->IsLocked()) {
+ SUIT_MessageBox::warn1 (application()->desktop(),
+ QObject::tr("WRN_WARNING"),
QObject::tr("WRN_STUDY_LOCKED"),
QObject::tr("BUT_OK"));
}
}
catch (const SALOME::SALOME_Exception & S_ex)
{
- QtCatchCorbaException(S_ex);
+ SalomeApp_Tools::QtCatchCorbaException(S_ex);
}
}
- myActiveStudy->updateObjBrowser();
+ updateObjBrowser();
}
break;
}
{
MESSAGE("command " << theCommandID << " activated");
- QString myStudyName = myActiveStudy->getTitle();
+ QString myStudyName = myActiveStudy->studyName();
bool ok=FALSE;
- int myStudyId = myActiveStudy->getStudyId();
+ int myStudyId = myActiveStudy->id();
// load MED engine
- SALOME_MED::MED_Gen_ptr medgen = InitMedGen(parent);
+ SALOME_MED::MED_Gen_ptr medgen = InitMedGen();
// Selection du Fichier
- file = QAD_FileDlg::getFileName(parent,
+ file = SUIT_FileDlg::getFileName(application()->desktop(),
"",
filtersList,
tr("MED_MEN_IMPORT"),
try
{
medgen->readFieldInFile(file.latin1(),myStudyName,fieldName,-1,-1);
- if (myActiveStudy->getStudyDocument()->GetProperties()->IsLocked()) {
- QAD_MessageBox::warn1 ((QWidget*)QAD_Application::getDesktop(),
- QObject::tr("WRN_WARNING"),
+ if (myActiveStudy->studyDS()->GetProperties()->IsLocked()) {
+ SUIT_MessageBox::warn1 (application()->desktop(),
+ QObject::tr("WRN_WARNING"),
QObject::tr("WRN_STUDY_LOCKED"),
QObject::tr("BUT_OK"));
}
}
catch (const SALOME::SALOME_Exception & S_ex)
{
- QtCatchCorbaException(S_ex);
+ SalomeApp_Tools::QtCatchCorbaException(S_ex);
}
-
- myActiveStudy->updateObjBrowser();
+ updateObjBrowser ();
}
}
break;
{
MESSAGE("command " << theCommandID << " activated");
- QString myStudyName = myActiveStudy->getTitle();
- int myStudyId = myActiveStudy->getStudyId();
+ QString myStudyName = myActiveStudy->studyName();
+ int myStudyId = myActiveStudy->id();
// load MED engine
- SALOME_MED::MED_Gen_ptr medgen = InitMedGen(parent);
+ SALOME_MED::MED_Gen_ptr medgen = InitMedGen();
// Selection du Fichier
- file = QAD_FileDlg::getFileName(parent,
+ file = SUIT_FileDlg::getFileName(application()->desktop(),
"",
filtersList,
tr("MED_MEN_IMPORT"),
{
// medgen->readStructFile(file.latin1(),myStudyName);
medgen->readStructFileWithFieldType(file.latin1(),myStudyName);
- if (myActiveStudy->getStudyDocument()->GetProperties()->IsLocked()) {
- QAD_MessageBox::warn1 ((QWidget*)QAD_Application::getDesktop(),
+
+
+ MESSAGE("Ouais on est la !!!!");
+
+ if (myActiveStudy->studyDS()->GetProperties()->IsLocked()) {
+
+
+ MESSAGE("Ouais on est la 1 !!!!");
+
+
+ SUIT_MessageBox::warn1 (application()->desktop(),
QObject::tr("WRN_WARNING"),
QObject::tr("WRN_STUDY_LOCKED"),
QObject::tr("BUT_OK"));
}
catch (const SALOME::SALOME_Exception & S_ex)
{
- QtCatchCorbaException(S_ex);
+
+ MESSAGE("Ouais on est la 2 !!!!");
+
+ SalomeApp_Tools::QtCatchCorbaException(S_ex);
}
- myActiveStudy->updateObjBrowser();
+
+ MESSAGE("Ouais on est la 3 !!!!");
+
+ updateObjBrowser ();
}
break;
}
-
+
case 934:
{
//Handle(SMESH_TypeFilter) aMeshFilter = new SMESH_TypeFilter( MESH );
- SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
+
+ SALOME_ListIO list;
+ SalomeApp_Application* app = getApp();
+ SalomeApp_SelectionMgr* mgr = app ? app->selectionMgr() : NULL;
+ if( mgr )
+ mgr->selectedObjects( list );
//Sel->AddFilter(aMeshFilter) ;
-
- int nbSel = Sel->IObjectCount();
- if ( nbSel == 1 )
+
+ int nbSel = list.Extent();
+ if ( nbSel == 1 )
{
// SMESH::SMESH_Mesh_var aM;
SALOME_MED::MESH_var aMesh;
- Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
- if ( IObject->hasEntry() )
+ Handle(SALOME_InteractiveObject) IObject = list.First();
+ if ( IObject->hasEntry() )
{
- SALOMEDS::SObject_var aMorSM = aStudy->FindObjectID( IObject->getEntry() );
- if ( !aMorSM->_is_nil() )
+ _PTR(SObject) aMorSM = aStudy->FindObjectID( IObject->getEntry() );
+ if ( aMorSM )
{
- SALOMEDS::GenericAttribute_var anAttr;
- SALOMEDS::AttributeIOR_var anIOR;
- if (aMorSM->FindAttribute(anAttr, "AttributeIOR"))
+ _PTR(GenericAttribute) anAttr;
+ _PTR(AttributeIOR) anIOR;
+ if (aMorSM->FindAttribute(anAttr, "AttributeIOR"))
{
- anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
- aMesh = SALOME_MED::MESH::_narrow( _orb->string_to_object(anIOR->Value()) );
+ anIOR = anAttr;
+ aMesh = SALOME_MED::MESH::_narrow( _orb->string_to_object(anIOR->Value().c_str()) );
if ( aMesh->_is_nil() )
{
// aM = SMESH::SMESH_Mesh::_narrow(_orb->string_to_object(anIOR->Value()));
// aMesh = aM->GetMEDMesh();
if ( aMesh->_is_nil() )
{
- QAD_MessageBox::warn1
- ( QAD_Application::getDesktop(),
+ SUIT_MessageBox::warn1
+ ( application()->desktop(),
tr ("MED_WRN_WARNING"),
tr ("MED_INF_NOTIMPL"),
tr ("MED_BUT_OK") );
}
else
{
- QAD_MessageBox::warn1
- ( QAD_Application::getDesktop(),
+ SUIT_MessageBox::warn1
+ ( application()->desktop(),
tr ("MED_WRN_WARNING"),
tr ("MED_INF_NOIOR"),
tr ("MED_BUT_OK") );
}
}
}
- }
+ }
break;
}
case 935:
{
//Handle(SMESH_TypeFilter) aSubMeshFilter = new SMESH_TypeFilter( SUBMESH );
- SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
+
+ SALOME_ListIO list;
+ SalomeApp_Application* app = getApp();
+ SalomeApp_SelectionMgr* mgr = app ? app->selectionMgr() : NULL;
+ if( mgr )
+ mgr->selectedObjects( list );
+
//Sel->AddFilter(aSubMeshFilter) ;
-
- int nbSel = Sel->IObjectCount();
- if ( nbSel == 1 )
+
+ int nbSel = list.Extent();
+ if ( nbSel == 1 )
{
// SMESH::SMESH_subMesh_var aSubM;
SALOME_MED::FAMILY_var aFam;
- Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
- if ( IObject->hasEntry() )
+ Handle(SALOME_InteractiveObject) IObject = list.First();
+ if ( IObject->hasEntry() )
{
- SALOMEDS::SObject_var aMorSM = aStudy->FindObjectID( IObject->getEntry() );
- if ( !aMorSM->_is_nil() )
+ _PTR(SObject) aMorSM = aStudy->FindObjectID( IObject->getEntry() );
+ if ( aMorSM )
{
- SALOMEDS::GenericAttribute_var anAttr;
- SALOMEDS::AttributeIOR_var anIOR;
- if (aMorSM->FindAttribute(anAttr, "AttributeIOR"))
+ _PTR(GenericAttribute) anAttr;
+ _PTR(AttributeIOR) anIOR;
+ if (aMorSM->FindAttribute(anAttr, "AttributeIOR"))
{
- anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+ anIOR = anAttr;
// aSubM = SMESH::SMESH_subMesh::_narrow( _orb->string_to_object(anIOR->Value()) );
// if ( aSubM->_is_nil() )
// {
}
else
{
- QAD_MessageBox::warn1
- ( QAD_Application::getDesktop(),
+ SUIT_MessageBox::warn1
+ ( application()->desktop(),
tr ("MED_WRN_WARNING"),
tr ("MED_INFNOIOR"),
tr ("MED_BUT_OK") );
*/
//=============================================================================
bool MedGUI::OnMousePress (QMouseEvent* pe ,
- QAD_Desktop* parent,
- QAD_StudyFrame* studyFrame)
+ SUIT_ViewWindow* wnd )
{
MESSAGE("MedGUI::OnMousePress");
return true;
}
-
+
//=============================================================================
/*!
*
*/
//=============================================================================
bool MedGUI::OnMouseMove (QMouseEvent* pe ,
- QAD_Desktop* parent,
- QAD_StudyFrame* studyFrame)
+ SUIT_ViewWindow* wnd )
{
// MESSAGE("MedGUI::OnMouseMouve");
return true;
*/
//=============================================================================
bool MedGUI::OnKeyPress (QKeyEvent* pe,
- QAD_Desktop* parent,
- QAD_StudyFrame* studyFrame)
+ SUIT_ViewWindow* wnd)
{
MESSAGE("MedGUI::OnKeyPress");
return true;
*
*/
//=============================================================================
-bool MedGUI::SetSettings (QAD_Desktop* parent)
+/*bool MedGUI::SetSettings ()
{
MESSAGE("MedGUI::SetSettings");
return true;
-}
+}*/
//=============================================================================
/*!
*
*/
//=============================================================================
-bool MedGUI::CustomPopup ( QAD_Desktop* parent,
- QPopupMenu* popup,
+/*bool MedGUI::CustomPopup ( QPopupMenu* popup,
const QString & theContext,
const QString & theParent,
const QString & theObject )
MESSAGE("MedGUI::CustomPopup");
popup->clear();
return true;
-}
+}*/
//=============================================================================
/*!
*
*/
//=============================================================================
-bool MedGUI::ActiveStudyChanged( QAD_Desktop* parent )
+/*bool MedGUI::ActiveStudyChanged()
{
return true;
-}
+}*/
//=============================================================================
/*!
*
*/
//=============================================================================
-void MedGUI::DefinePopup( QString & theContext, QString & theParent, QString & theObject )
+/*void MedGUI::DefinePopup( QString & theContext, QString & theParent, QString & theObject )
{
theObject = "";
theContext = "";
}
-
+*/
//=============================================================================
/*!
*
//=============================================================================
bool MedGUI::DumpMesh( SALOME_MED::MESH_var MEDMesh)
{
-
+
if ( MEDMesh->_is_nil() )
{
return false;
while (lu < k ) {
if (dim2==3)
{
- MESSAGE ( " Coordinates X = " << coords[i] << " Y = " << coords[i+1] << " Z = " << coords[i+2] );
+ MESSAGE ( " Coordinates X = " << coords[i] << " Y = " << coords[i+1] << " Z = " << coords[i+2] );
i = i + 3; // Only for triangles
}
else
{
- MESSAGE ( " Coordinates X = " << coords[i] << " Y = " << coords[i+1] );
- i = i + 2;
+ MESSAGE ( " Coordinates X = " << coords[i] << " Y = " << coords[i+1] );
+ i = i + 2;
}
lu=lu+1;
}
int nbfam=MEDMesh->getNumberOfFamilies(SALOME_MED::MED_NODE);
SCRUTE(nbfam);
SALOME_MED::Family_array_var Families=MEDMesh->getFamilies(SALOME_MED::MED_NODE) ;
-
+
for (k=0; k < nbfam; k++) {
SCRUTE(k);
string nomFam=Families[k]->getName();
SCRUTE(nbelemnts);
SALOME_MED::long_array_var tabnoeuds=Families[k]->getNumber(SALOME_MED::MED_NONE);
for (int l=0;l<tabnoeuds->length();l++)
- SCRUTE(tabnoeuds[l]);
+ SCRUTE(tabnoeuds[l]);
}
-
+
// int famIdent = 1;
// SALOME_MED::FAMILY_ptr Family=MEDMesh->getFamily(SALOME_MED::MED_NODE,1) ;
// MESSAGE("ici");
// SCRUTE(identfam);
// SALOME_MED::long_array_var tabnoeuds=Family->getNumber(SALOME_MED::MED_NONE);
// for (int l=0;l<tabnoeuds->length();l++)
- // SCRUTE(tabnoeuds[l]);
+ // SCRUTE(tabnoeuds[l]);
return true;
}
// SALOME_MED::long_array_var tabnoeuds=Fam->getNumber(SALOME_MED::MED_NONE);
// for (int l=0;l<tabnoeuds->length();l++)
-// SCRUTE(tabnoeuds[l]);
+// SCRUTE(tabnoeuds[l]);
// return true;
// }
*
*/
//=============================================================================
-SALOME_MED::MED_Gen_ptr MedGUI::InitMedGen(QAD_Desktop* parent)
+SALOME_MED::MED_Gen_ptr MedGUI::InitMedGen() const
{
- Engines::Component_var comp =
- parent->getEngine("FactoryServer", "MED");
+ SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( application() );
+ Engines::Component_var comp =
+ SALOME_LifeCycleCORBA(app->namingService()).FindOrLoad_Component( "FactoryServer", "MED" );
+
MESSAGE("_________________________________________");
SALOME_MED::MED_Gen_var clr = SALOME_MED::MED_Gen::_narrow(comp);
ASSERT(!CORBA::is_nil(clr));
ASSERT(! CORBA::is_nil(_orb));
}
-static MedGUI aGUI("");
-extern "C"
-{
- Standard_EXPORT SALOMEGUI* GetComponentGUI() {
- return &aGUI;
+extern "C" {
+ Standard_EXPORT CAM_Module* createModule() {
+ return new MedGUI();
}
}
-// MED MEDGUI : MED component GUI implemetation
+// MED MEDGUI : MED component GUI implemetation
//
// Copyright (C) 2003 CEA/DEN, EDF R&D
//
#ifndef _MEDGUI_H_
#define _MEDGUI_H_
-#include "SALOMEGUI.h"
-#include "QAD_Desktop.h"
-#include "QAD_StudyFrame.h"
+#include <SalomeApp_Module.h>
+#include <SUIT_Desktop.h>
#include <SALOMEconfig.h>
#include CORBA_CLIENT_HEADER(MED_Gen)
//#include CORBA_CLIENT_HEADER(SMESH_Mesh)
#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
-class MedGUI: public SALOMEGUI
+class MedGUI: public SalomeApp_Module
{
Q_OBJECT
public:
- MedGUI( const QString& name = "", QObject* parent = 0 );
+ MedGUI();
- virtual bool OnGUIEvent (int theCommandID, QAD_Desktop* parent);
- virtual bool OnKeyPress (QKeyEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame);
- virtual bool OnMousePress (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame);
- virtual bool OnMouseMove (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame);
- virtual bool SetSettings ( QAD_Desktop* parent );
- virtual bool CustomPopup ( QAD_Desktop* parent, QPopupMenu* popup, const QString & theContext,
- const QString & theParent, const QString & theObject );
- virtual void DefinePopup ( QString & theContext, QString & theParent, QString & theObject );
- virtual bool ActiveStudyChanged( QAD_Desktop* parent );
+ virtual void initialize ( CAM_Application* );
+ virtual QString engineIOR() const;
+ virtual void windows( QMap<int, int>& mappa ) const;
+ virtual bool OnGUIEvent (int theCommandID);
+ virtual bool OnKeyPress (QKeyEvent* pe, SUIT_ViewWindow* );
+ virtual bool OnMousePress (QMouseEvent* pe, SUIT_ViewWindow* );
+ virtual bool OnMouseMove (QMouseEvent* pe, SUIT_ViewWindow* );
- static SALOME_MED::MED_Gen_ptr InitMedGen(QAD_Desktop* parent);
+ void createMedAction( const int, const QString&, const QString& = "" );
+ void createPopupItem( const int, const QString&, const QString&, const QString& = "", const int = -1 );
+
+ virtual void contextMenuPopup( const QString&, QPopupMenu*, QString& );
+
+ //virtual bool SetSettings ();
+ //virtual bool CustomPopup ( QAD_Desktop* parent, QPopupMenu* popup, const QString & theContext,
+ // const QString & theParent, const QString & theObject );
+ //virtual void DefinePopup ( QString & theContext, QString & theParent, QString & theObject );
+ //virtual bool ActiveStudyChanged( QAD_Desktop* parent );
+
+ /*static*/ SALOME_MED::MED_Gen_ptr InitMedGen() const;
static bool DumpMesh( SALOME_MED::MESH_var aMesh );
// static bool DumpSubMesh( SMESH::SMESH_subMesh_ptr aSubMesh ) ;
static void setOrb();
-protected:
+ void EmitSignalCloseAllDialogs();
-private:
+signals :
+ void SignalCloseAllDialogs();
+
+public slots:
+ virtual bool deactivateModule( SUIT_Study* );
+ virtual bool activateModule( SUIT_Study* );
+
+protected:
+private slots:
+ void onGUIEvent();
+ void onWindowActivated( SUIT_ViewWindow* );
};
--- /dev/null
+
+#include "MedGUI_Selection.h"
+
+//=======================================================================
+//function : MedGUI_Selection
+//purpose :
+//=======================================================================
+MedGUI_Selection::MedGUI_Selection()
+: SalomeApp_Selection()
+{
+}
+
+//=======================================================================
+//function : ~MedGUI_Selection
+//purpose :
+//=======================================================================
+MedGUI_Selection::~MedGUI_Selection()
+{
+}
+
--- /dev/null
+// MED MEDGUI_Selection
+//
+// 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 : MEDGUI_Selection.h
+// Author : Alexander SOLOVYOV
+// Module : MED
+// $Header$
+
+#ifndef MEDGUI_SELECTION_HeaderFile
+#define MEDGUI_SELECTION_HeaderFile
+
+#include "SalomeApp_Selection.h"
+
+class MedGUI_Selection : public SalomeApp_Selection
+{
+public:
+ MedGUI_Selection();
+ virtual ~MedGUI_Selection();
+};
+
+#endif
template <class T> inline MEDARRAY<T>::MEDARRAY():
- _ldValues(0), _lengthValues(0), _mode(MED_FULL_INTERLACE),
- _valuesFull(), _valuesNo(),
- _valuesDefault(), _valuesOther()
+ _ldValues(0), _lengthValues(0), _mode(MED_EN::MED_FULL_INTERLACE),
+ _valuesFull(), _valuesNo(),
+ _valuesDefault(), _valuesOther()
{
};
template <class T> const T* MEDARRAY<T>::getRow(const int i)
{
-
- BEGIN_OF("MEDARRAY<T>::getRow(const int i)");
-
if ((T*)_valuesDefault == NULL)
{
throw MEDEXCEPTION("MEDARRAY::getRow(i) : No values defined !");
if ((T*)_valuesFull == NULL)
{
- ASSERT(((T*) _valuesDefault)==((T*) _valuesNo));
calculateOther();
}
ASSERT((T*)_valuesFull != NULL);
//const T* ptr = (const T*)_valuesFull + (i-1)*_ldValues;
const T* ptr = (T*) _valuesFull + (i-1)*_ldValues;
- END_OF("MEDARRAY<T>::getRow(const int i )");
return ptr;
}
// ------------------
template <class T> const T* MEDARRAY<T>::getColumn(const int j)
{
- BEGIN_OF("MEDARRAY<T>::getColumn(const int j)");
if ((T*)_valuesDefault == NULL)
{
throw MEDEXCEPTION("MEDARRAY::getColumn(j) : No values defined !");
(internal use : needed by write method) */
template <class T> inline MED_EN::medModeSwitch MEDARRAY<T>::getMode() const
{
- BEGIN_OF("MEDARRAY<T>::getMode()");
- END_OF("MEDARRAY<T>::getMode()");
return _mode;
}
--- /dev/null
+#ifndef ASCII_FIELD_DRIVER_HXX
+#define ASCII_FIELD_DRIVER_HXX
+
+#include "MEDMEM_Mesh.hxx"
+#include "MEDMEM_Support.hxx"
+#include "MEDMEM_GenDriver.hxx"
+#include "MEDMEM_Exception.hxx"
+#include "MEDMEM_Unit.hxx"
+
+#include <list>
+#include <string>
+#include <ctype.h>
+#include <iomanip>
+#include <stdlib.h>
+#include <string.h>
+#include <fstream.h>
+
+#define PRECISION_IN_ASCII_FILE 10
+#define PRECISION_IN_COMPARE 1e-10
+#define SPACE_BETWEEN_NBS 19
+
+namespace MEDMEM {
+
+ template<class T>
+ class FIELD;
+
+ template<int N,unsigned int CODE>
+ void fill(double *a, const double *b)
+ {
+ a[N]=b[CODE & 0x3 ];
+ fill<N-1, (CODE>>2) >(a,b);
+ }
+
+ template<int N>
+ bool compare(const double* a, const double* b)
+ {
+ double sign=b[N]<0 ? -1 : 1;
+ if(a[N]<b[N]*(1-sign*PRECISION_IN_COMPARE))
+ return true;
+ if(a[N]>b[N]*(1+sign*PRECISION_IN_COMPARE))
+ return false;
+ return compare<N-1>(a,b);
+ }
+
+ template<>
+ void fill<-1,0x3>(double *a, const double *b);
+
+ template<>
+ bool compare<-1>(const double *a, const double *b);
+
+ template <class T, int SPACEDIMENSION, unsigned int SORTSTRATEGY>
+ class SDForSorting
+ {
+ private:
+ double _coords[SPACEDIMENSION];
+ T *_components;
+ int _nbComponents;
+ public:
+ SDForSorting(const double *coords, const T* comp, int nbComponents);
+ SDForSorting(const SDForSorting& other);
+ ~SDForSorting();
+ bool operator< (const SDForSorting<T,SPACEDIMENSION,SORTSTRATEGY>& other) const;
+ void writeLine(ofstream& file) const;
+ };
+
+ template <class T>
+ class ASCII_FIELD_DRIVER : public GENDRIVER
+ {
+ private:
+ MESH *_mesh;
+ SUPPORT *_support;
+ mutable FIELD<T> * _ptrField;
+ std::string _fileName;
+ mutable ofstream _file;
+ unsigned int _code;
+ MED_EN::med_sort_direc _direc;
+ int _nbComponents;
+ int _spaceDimension;
+ //static int _nbComponentsForCpyInfo;
+ public:
+ ASCII_FIELD_DRIVER(const string & fileName, FIELD<T> * ptrField,
+ MED_EN::med_sort_direc direction=MED_EN::ASCENDING,
+ const char *priority="");
+ ASCII_FIELD_DRIVER(const ASCII_FIELD_DRIVER<T>& other);
+ void open() throw (MEDEXCEPTION);
+ void close();
+ void read ( void ) throw (MEDEXCEPTION);
+ void write( void ) const throw (MEDEXCEPTION);
+ GENDRIVER* copy() const;
+ private:
+ void buildIntroduction() const;
+ template<int SPACEDIMENSION, unsigned int SORTSTRATEGY>
+ void sortAndWrite() const;
+ //template<int SPACEDIMENSION, unsigned int SORTSTRATEGY>//, std::list< SDForSorting<T,SPACEDIMENSION,SORTSTRATEGY > > >
+ //static void copyInfo(const double *a,T *b);
+ //static void copyInfo2(const double *,T *);
+ };
+}
+
+#include "MEDMEM_Field.hxx"
+
+namespace MEDMEM {
+
+ template <class T, int SPACEDIMENSION, unsigned int SORTSTRATEGY>
+ SDForSorting<T,SPACEDIMENSION,SORTSTRATEGY>::SDForSorting(const double *coords, const T* comp, int nbComponents):_nbComponents(nbComponents)
+ {
+ fill<SPACEDIMENSION-1,SORTSTRATEGY>(_coords,coords);
+ _components=new T[_nbComponents];
+ memcpy(_components,comp,sizeof(T)*_nbComponents);
+ }
+
+ template <class T, int SPACEDIMENSION, unsigned int SORTSTRATEGY>
+ SDForSorting<T,SPACEDIMENSION,SORTSTRATEGY>::SDForSorting(const SDForSorting& other):_nbComponents(other._nbComponents)
+ {
+ memcpy(_coords,other._coords,sizeof(double)*SPACEDIMENSION);
+ _components=new T[_nbComponents];
+ memcpy(_components,other._components,sizeof(T)*_nbComponents);
+ }
+
+ template <class T, int SPACEDIMENSION, unsigned int SORTSTRATEGY>
+ SDForSorting<T,SPACEDIMENSION,SORTSTRATEGY>::~SDForSorting()
+ {
+ delete [] _components;
+ }
+
+ template <class T, int SPACEDIMENSION, unsigned int SORTSTRATEGY>
+ bool SDForSorting<T,SPACEDIMENSION,SORTSTRATEGY>::operator< (const SDForSorting<T,SPACEDIMENSION,SORTSTRATEGY>& other) const
+ {
+ return compare<SPACEDIMENSION-1>(_coords,other._coords);
+ }
+
+ template <class T, int SPACEDIMENSION, unsigned int SORTSTRATEGY>
+ void SDForSorting<T,SPACEDIMENSION,SORTSTRATEGY>::writeLine(ofstream& file) const
+ {
+ int i;
+ double temp[SPACEDIMENSION];
+ fill<SPACEDIMENSION-1,SORTSTRATEGY>(temp,_coords);
+ for(i=0;i<SPACEDIMENSION;i++)
+ file << setw(SPACE_BETWEEN_NBS) << temp[i];
+ for(i=0;i<_nbComponents;i++)
+ file << setw(SPACE_BETWEEN_NBS) << _components[i];
+ file << endl;
+ }
+
+ template <class T>
+ ASCII_FIELD_DRIVER<T>::ASCII_FIELD_DRIVER(const string & fileName, FIELD<T> * ptrField,
+ MED_EN::med_sort_direc direction,const char *priority)
+ :GENDRIVER(fileName,MED_EN::MED_ECRI),_ptrField(ptrField),_fileName(fileName),_direc(direction)
+ {
+ _nbComponents=_ptrField->getNumberOfComponents();
+ if(_nbComponents<=0)
+ throw MEDEXCEPTION("ASCII_FIELD_DRIVER : No components in FIELD<T>");
+ _support=(SUPPORT *)_ptrField->getSupport();
+ _mesh=(MESH *)_support->getMesh();
+ _spaceDimension=_mesh->getSpaceDimension();
+ _code=3;
+ int i;
+ if(priority[0]=='\0')
+ for(i=_spaceDimension-1;i>=0;i--)
+ {
+ _code<<=2;
+ _code+=i;
+ }
+ else
+ {
+ if(_spaceDimension!=strlen(priority))
+ throw MEDEXCEPTION("ASCII_FIELD_DRIVER : Coordinate priority invalid with spaceDim");
+ for(i=_spaceDimension-1;i>=0;i--)
+ {
+ char c=toupper(priority[i]);
+ if(int(c-'X')>(_spaceDimension-1))
+ throw MEDEXCEPTION("ASCII_FIELD_DRIVER : Invalid priority definition");
+ _code<<=2;
+ _code+=c-'X';
+ }
+ }
+ }
+
+ template <class T>
+ ASCII_FIELD_DRIVER<T>::ASCII_FIELD_DRIVER(const ASCII_FIELD_DRIVER<T>& other)
+ :_ptrField(other._ptrField),_fileName(other._fileName),_direc(other._direc),_mesh(other._mesh),_nbComponents(other._nbComponents),
+ _code(other._code),_spaceDimension(other._spaceDimension),_support(other._support)
+ {
+ }
+
+ template <class T>
+ void ASCII_FIELD_DRIVER<T>::open() throw (MEDEXCEPTION)
+ {
+ _file.open(_fileName.c_str(),ofstream::out | ofstream::app);
+ }
+
+ template <class T>
+ void ASCII_FIELD_DRIVER<T>::close()
+ {
+ _file.close();
+ }
+
+ template <class T>
+ void ASCII_FIELD_DRIVER<T>::read ( void ) throw (MEDEXCEPTION)
+ {
+ throw MEDEXCEPTION("ASCII_FIELD_DRIVER::read : Can't read with a WRONLY driver !");
+ }
+
+ template <class T>
+ GENDRIVER* ASCII_FIELD_DRIVER<T>::copy() const
+ {
+ return new ASCII_FIELD_DRIVER<T>(*this);
+ }
+
+ template <class T>
+ void ASCII_FIELD_DRIVER<T>::write( void ) const throw (MEDEXCEPTION)
+ {
+ buildIntroduction();
+ switch(_spaceDimension)
+ {
+ case 2:
+ {
+ switch(_code)
+ {
+ case 52: //XY
+ {
+ sortAndWrite<2,52>();
+ break;
+ }
+ case 49: //YX
+ {
+ sortAndWrite<2,49>();
+ break;
+ }
+ default:
+ MEDEXCEPTION("ASCII_FIELD_DRIVER : Invalid priority definition");
+ }
+ break;
+ }
+ case 3:
+ {
+ switch(_code)
+ {
+ case 228: //XYZ
+ {
+ sortAndWrite<3,228>();
+ break;
+ }
+ case 216: //XZY
+ {
+ sortAndWrite<3,216>();
+ break;
+ }
+ case 225://YXZ
+ {
+ sortAndWrite<3,225>();
+ break;
+ }
+ case 201://YZX
+ {
+ sortAndWrite<3,201>();
+ break;
+ }
+ case 210://ZXY
+ {
+ sortAndWrite<3,210>();
+ break;
+ }
+ case 198://ZYX
+ {
+ sortAndWrite<3,198>();
+ break;
+ }
+ default:
+ MEDEXCEPTION("ASCII_FIELD_DRIVER : Invalid priority definition");
+ }
+ break;
+ }
+ default:
+ MEDEXCEPTION("ASCII_FIELD_DRIVER : Invalid space dimension must be 2 or 3");
+ }
+ }
+
+ template <class T>
+ void ASCII_FIELD_DRIVER<T>::buildIntroduction() const
+ {
+ int i;
+ _file << setiosflags(ios::scientific);
+ _file << "#TITLE: table " << _ptrField->getName() << " TIME: " << _ptrField->getTime() << " IT: " << _ptrField->getIterationNumber() << endl;
+ _file << "#COLUMN_TITLES: ";
+ for(i=0;i<_spaceDimension;i++)
+ _file << char('X'+i) << " | ";
+ const std::string *compoNames=_ptrField->getComponentsNames();
+ for(i=0;i<_nbComponents;i++)
+ {
+ if(!compoNames)
+ _file << compoNames[i];
+ else
+ _file << "None";
+ if(i<_nbComponents-1)
+ _file << " | ";
+ }
+ _file << endl;
+ _file << "#COLUMN_UNITS: ";
+ compoNames=_mesh->getCoordinateptr()->getCoordinatesUnits();
+ for(i=0;i<_spaceDimension;i++)
+ {
+ if(!compoNames)
+ _file << compoNames[i];
+ else
+ _file << "None";
+ _file << " | ";
+ }
+ const UNIT *compoUnits=_ptrField->getComponentsUnits();
+ for(i=0;i<_nbComponents;i++)
+ {
+ if(!compoUnits)
+ _file << compoUnits[i].getName();
+ else
+ _file << "None";
+ if(i<_nbComponents-1)
+ _file << " | ";
+ }
+ _file << endl;
+ }
+
+ template <class T>
+ template<int SPACEDIMENSION, unsigned int SORTSTRATEGY>
+ void ASCII_FIELD_DRIVER<T>::sortAndWrite() const
+ {
+ int i,j;
+ int numberOfValues=_ptrField->getNumberOfValues();
+ std::list< SDForSorting<T,SPACEDIMENSION,SORTSTRATEGY > > li;
+ const double * coord;
+ FIELD<double> * barycenterField=0;
+ double * xyz[SPACEDIMENSION];
+ bool deallocateXyz=false;
+ if(_support->getEntity()==MED_EN::MED_NODE)
+ {
+ if (_support->isOnAllElements())
+ {
+ coord=_mesh->getCoordinates(MED_EN::MED_NO_INTERLACE);
+ for(i=0; i<SPACEDIMENSION; i++)
+ xyz[i]=(double *)coord+i*numberOfValues;
+ }
+ else
+ {
+ coord = _mesh->getCoordinates(MED_EN::MED_FULL_INTERLACE);
+ const int * nodesNumber=_support->getNumber(MED_EN::MED_ALL_ELEMENTS);
+ for(i=0; i<SPACEDIMENSION; i++)
+ xyz[i]=new double[numberOfValues];
+ deallocateXyz=true;
+ for(i=0;i<numberOfValues;i++)
+ {
+ for(j=0;j<SPACEDIMENSION;j++)
+ xyz[j][i]=coord[(nodesNumber[i]-1)*SPACEDIMENSION+j];
+ }
+ }
+ }
+ else
+ {
+ barycenterField = _mesh->getBarycenter(_support);
+ coord=barycenterField->getValue(MED_EN::MED_NO_INTERLACE);
+ for(i=0; i<SPACEDIMENSION; i++)
+ xyz[i]=(double *)(coord+i*numberOfValues);
+ }
+ T* valsToSet=(T*)_ptrField->getValue(MED_EN::MED_FULL_INTERLACE);
+ double temp[SPACEDIMENSION];
+ for(i=0;i<numberOfValues;i++)
+ {
+ for(j=0;j<SPACEDIMENSION;j++)
+ temp[j]=xyz[j][i];
+ li.push_back(SDForSorting<T,SPACEDIMENSION,SORTSTRATEGY>(temp,valsToSet+i*_nbComponents,_nbComponents));
+ }
+ if(barycenterField)
+ delete barycenterField;
+ if(deallocateXyz)
+ for(j=0;j<SPACEDIMENSION;j++)
+ delete [] xyz[j];
+ li.sort();
+ _file << setprecision(PRECISION_IN_ASCII_FILE);
+ if(_direc==MED_EN::ASCENDING)
+ {
+ typename std::list< SDForSorting<T,SPACEDIMENSION,SORTSTRATEGY > >::iterator iter;
+ for(iter=li.begin();iter!=li.end();iter++)
+ (*iter).writeLine(_file);
+ _file << endl;
+ }
+ else if(_direc==MED_EN::DESCENDING)
+ {
+ typename std::list< SDForSorting<T,SPACEDIMENSION,SORTSTRATEGY > >::reverse_iterator iter;
+ for(iter=li.rbegin();iter!=li.rend();iter++)
+ (*iter).writeLine(_file);
+ _file << endl;
+ }
+ else
+ MEDEXCEPTION("ASCII_FIELD_DRIVER : Invalid sort direction");
+ }
+ //{
+ //_nbComponentsForCpyInfo=_nbComponents;
+ //_ptrField->fillFromAnalytic <TEST<T>::copyInfo3> ();
+ //_ptrField->fillFromAnalytic< ASCII_FIELD_DRIVER<T>::copyInfo<SPACEDIMENSION,SORTSTRATEGY> > ();
+ //li.sort();
+ //typename std::list< SDForSorting<T,SPACEDIMENSION,SORTSTRATEGY > >::iterator iter;
+ //_file << setiosflags(ios::scientific) << setprecision(PRECISION_IN_ASCII_FILE);
+ //for(iter=li.begin();iter!=li.end();iter++)
+ // {
+ //(*iter).writeLine(_file);
+ // }
+
+// template <class T>
+// template<int SPACEDIMENSION, unsigned int SORTSTRATEGY>//, std::list< SDForSorting<T,SPACEDIMENSION,SORTSTRATEGY> > lis>
+// void ASCII_FIELD_DRIVER<T>::copyInfo(const double *a,T *b)
+// {
+// //lis.push_back(SDForSorting<T,SPACEDIMENSION,SORTSTRATEGY>(a,b,_nbComponentsForCpyInfo));
+// }
+
+// template <class T>
+// int ASCII_FIELD_DRIVER<T>::_nbComponentsForCpyInfo=0;
+}
+
+#endif
}
inline CELLMODEL::~CELLMODEL()
{
- MESSAGE("CELLMODEL::~CELLMODEL() destroying the cell");
+ // MESSAGE("CELLMODEL::~CELLMODEL() destroying the cell");
clean() ;
};
inline CELLMODEL & CELLMODEL::operator=(const CELLMODEL &m)
--- /dev/null
+/*
+ Include file managing the compatibility
+ Med File V 2.1 and V 2.2
+*/
+
+#ifndef COMPATIBILITY_21_22_HXX
+#define COMPATIBILITY_21_22_HXX
+
+/*
+ Med File V 2.1 attributes
+*/
+
+#undef MED_H
+#undef MED_PROTO_H
+
+# include <med.hxx>
+# include <med_proto.hxx>
+
+#undef MED_TAILLE_PNOM
+#undef MED_NOPFLi
+
+/*
+ Med File V 2.2 attributes
+*/
+
+#undef MED_H
+#undef MED_PROTO_H
+
+namespace med_2_2 {
+ extern "C" {
+#include <med.h>
+#include <med_proto.h>
+ }
+}
+
+/*
+ Core of the management V2.1 V2.2 of the Med File
+*/
+
+#undef MED_TAILLE_PNOM
+#undef MED_NOPFLi
+
+#define MED_TAILLE_PNOM21 8
+#define MED_TAILLE_PNOM22 16
+
+#endif /* COMPATIBILITY_21_22_HXX */
using namespace std;
using namespace MEDMEM;
using namespace MED_EN;
+
+// Enlarge the vector if necessary to insert the element
+static inline void insert_vector(vector<int> &Vect, int Indice, int Element)
+{
+ if (Indice >= Vect.capacity())
+ Vect.reserve(Indice + 1000);
+
+ if (Indice >= Vect.size())
+ Vect.resize(Indice+1);
+
+ Vect[Indice] = Element;
+}
+
/*!
- Default Constructor. \n
+ Default Constructor. /n
Default for Entity is MED_CELL and type of Connectivity is MED_NODAL */
//--------------------------------------------------------------//
CONNECTIVITY::CONNECTIVITY(medEntityMesh Entity /* =MED_CELL */) :
_geometricTypes((medGeometryElement*)NULL),
_type((CELLMODEL*)NULL),
_entityDimension(0),
+ _numberOfNodes(0),
_count((int*)NULL),
_nodal((MEDSKYLINEARRAY*)NULL),
+ _polygonsNodal((MEDSKYLINEARRAY*)NULL),
+ _polyhedronNodal((POLYHEDRONARRAY*)NULL),
_descending((MEDSKYLINEARRAY*)NULL),
+ _polygonsDescending((MEDSKYLINEARRAY*)NULL),
+ _polyhedronDescending((MEDSKYLINEARRAY*)NULL),
_reverseNodalConnectivity((MEDSKYLINEARRAY*)NULL),
_reverseDescendingConnectivity((MEDSKYLINEARRAY*)NULL),
_neighbourhood((MEDSKYLINEARRAY*)NULL),
}
/*!
- Constructor. \n
+ Constructor. /n
Default for Entity is MED_CELL */
//------------------------------------------------------------------------------//
CONNECTIVITY::CONNECTIVITY(int numberOfTypes,medEntityMesh Entity /* =MED_CELL */):
_typeConnectivity(MED_NODAL),
_numberOfTypes(numberOfTypes),
_entityDimension(0),
+ _numberOfNodes(0),
_nodal((MEDSKYLINEARRAY*)NULL),
+ _polygonsNodal((MEDSKYLINEARRAY*)NULL),
+ _polyhedronNodal((POLYHEDRONARRAY*)NULL),
_descending((MEDSKYLINEARRAY*)NULL),
+ _polygonsDescending((MEDSKYLINEARRAY*)NULL),
+ _polyhedronDescending((MEDSKYLINEARRAY*)NULL),
_reverseNodalConnectivity((MEDSKYLINEARRAY*)NULL),
_reverseDescendingConnectivity((MEDSKYLINEARRAY*)NULL),
_neighbourhood((MEDSKYLINEARRAY*)NULL),
else
_nodal = (MEDSKYLINEARRAY *) NULL;
+ if (m._polygonsNodal != NULL)
+ _polygonsNodal = new MEDSKYLINEARRAY(* m._polygonsNodal);
+ else
+ _polygonsNodal = (MEDSKYLINEARRAY *) NULL;
+
+ if (m._polyhedronNodal != NULL)
+ _polyhedronNodal = new POLYHEDRONARRAY(* m._polyhedronNodal);
+ else
+ _polyhedronNodal = (POLYHEDRONARRAY *) NULL;
+
if (m._descending != NULL)
_descending = new MEDSKYLINEARRAY(* m._descending);
else
_descending = (MEDSKYLINEARRAY *) NULL;
+ if (m._polygonsDescending != NULL)
+ _polygonsDescending = new MEDSKYLINEARRAY(* m._polygonsDescending);
+ else
+ _polygonsDescending = (MEDSKYLINEARRAY *) NULL;
+
+ if (m._polyhedronDescending != NULL)
+ _polyhedronDescending = new MEDSKYLINEARRAY(* m._polyhedronDescending);
+ else
+ _polyhedronDescending = (MEDSKYLINEARRAY *) NULL;
+
if (m._reverseNodalConnectivity != NULL)
_reverseNodalConnectivity = new MEDSKYLINEARRAY(* m._reverseNodalConnectivity);
else
}
/*!
- Destructor.\n
+ Destructor./n
desallocates existing pointers */
//----------------------------//
CONNECTIVITY::~CONNECTIVITY()
delete [] _count;
if (_nodal != NULL)
delete _nodal;
+ if (_polygonsNodal != NULL)
+ delete _polygonsNodal;
+ if (_polyhedronNodal != NULL)
+ delete _polyhedronNodal;
if (_descending != NULL)
delete _descending;
+ if (_polygonsDescending != NULL)
+ delete _polygonsDescending;
+ if (_polyhedronDescending != NULL)
+ delete _polyhedronDescending;
if (_reverseNodalConnectivity != NULL)
delete _reverseNodalConnectivity;
if (_reverseDescendingConnectivity != NULL)
}
}
+
+//--------------------------------------------------------------------//
+void CONNECTIVITY::setPolygonsConnectivity(medConnectivity ConnectivityType, medEntityMesh Entity, const int* PolygonsConnectivity, const int* PolygonsConnectivityIndex, int ConnectivitySize, int NumberOfPolygons)
+//--------------------------------------------------------------------//
+{
+ const char* LOC = "CONNECTIVITY::setPolygonsConnectivity";
+ BEGIN_OF(LOC);
+
+ if (_entity == Entity)
+ {
+ MEDSKYLINEARRAY* Connectivity = new MEDSKYLINEARRAY(NumberOfPolygons,ConnectivitySize,PolygonsConnectivityIndex,PolygonsConnectivity);
+
+ if (ConnectivityType == MED_NODAL)
+ {
+ if (_polygonsNodal != (MEDSKYLINEARRAY*) NULL)
+ delete _polygonsNodal;
+ _polygonsNodal = Connectivity;
+ }
+ else
+ {
+ if (_typeConnectivity != MED_DESCENDING)
+ _typeConnectivity = MED_DESCENDING; //by default it is set to MED_NODAL
+ if (_polygonsDescending != (MEDSKYLINEARRAY*) NULL)
+ delete _polygonsDescending;
+ _polygonsDescending = Connectivity;
+ }
+ }
+ else
+ {
+ if (_constituent == (CONNECTIVITY*) NULL)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Entity not found !"));
+ _constituent->setPolygonsConnectivity(ConnectivityType, Entity, PolygonsConnectivity, PolygonsConnectivityIndex, ConnectivitySize, NumberOfPolygons);
+ }
+}
+
+
+//--------------------------------------------------------------------//
+void CONNECTIVITY::setPolyhedronConnectivity(medConnectivity ConnectivityType, const int* PolyhedronConnectivity, const int* PolyhedronIndex, int ConnectivitySize, int NumberOfPolyhedron, const int* PolyhedronFacesIndex /* =(int*)NULL */, int NumberOfFaces /* =0 */)
+//--------------------------------------------------------------------//
+{
+ const char* LOC = "CONNECTIVITY::setPolyhedronConnectivity";
+ BEGIN_OF(LOC);
+
+ if (_entity == MED_CELL)
+ {
+ if (ConnectivityType == MED_NODAL)
+ {
+ if (_polyhedronNodal != (POLYHEDRONARRAY*) NULL)
+ delete _polyhedronNodal;
+ _polyhedronNodal = new POLYHEDRONARRAY(NumberOfPolyhedron,NumberOfFaces,ConnectivitySize);
+ _polyhedronNodal->setPolyhedronIndex(PolyhedronIndex);
+ _polyhedronNodal->setFacesIndex(PolyhedronFacesIndex);
+ _polyhedronNodal->setNodes(PolyhedronConnectivity);
+ }
+ else
+ {
+ if (_typeConnectivity != MED_DESCENDING)
+ _typeConnectivity = MED_DESCENDING; //by default it is set to MED_NODAL
+ if (_polyhedronDescending != (MEDSKYLINEARRAY*) NULL)
+ delete _polyhedronDescending;
+ _polyhedronDescending = new MEDSKYLINEARRAY(NumberOfPolyhedron,ConnectivitySize,PolyhedronIndex,PolyhedronConnectivity);
+ }
+ }
+ else
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : _entity must be MED_CELL to set polyhedron !"));
+}
+
+
/*! A DOCUMENTER */
//------------------------------------------------------------------------------------------//
void CONNECTIVITY::calculateConnectivity(medConnectivity ConnectivityType, medEntityMesh Entity)
and a %medGeometryElement (ie:MED_SEG3). */
//------------------------------------------------------------//
-void CONNECTIVITY::updateFamily(vector<FAMILY*> myFamilies)
+void CONNECTIVITY::updateFamily(const vector<FAMILY*>& myFamilies)
//------------------------------------------------------------//
{
const char * LOC = "CONNECTIVITY::updateFamily(vector<FAMILY*>) ";
- BEGIN_OF(LOC);
-
int numberOfFamilies = myFamilies.size();
- if (numberOfFamilies == 0 ) {
- MESSAGE(LOC<<"No family");
+ if (numberOfFamilies == 0 || _constituent == NULL)
return;
- }
// does we do an update ?
- if ((_constituent != NULL)&(_descending != NULL)) {
- MESSAGE(LOC<<"Constituent is already defined");
+ if ((_constituent != NULL) && (_descending != NULL))
return;
- }
-
- if ((_constituent != NULL)&(_descending == NULL)) {
- if (myFamilies[0]->getEntity() != _constituent->getEntity()) {
- MESSAGE(LOC<<"Family and constituent entity are different. We do nothing");
- return;
+ if (myFamilies[0]->getEntity() != _constituent->getEntity())
+ return;
+ CONNECTIVITY * oldConstituent = _constituent;
+ _constituent = (CONNECTIVITY *)NULL;
+ if (oldConstituent->_nodal==NULL)
+ throw MED_EXCEPTION(LOCALIZED(STRING(LOC)<<"We have no nodal connectivity of sub cell"));
+
+ //Loc vars defined to treat polygons exactly the same as classic types. Not nice but necessary.
+ int oldNumberOfFaceTab[2];
+ const int * oldConstituentValueTab[2];
+ const int * oldConstituentIndexTab[2];
+ int * renumberingFromOldToNewTab[2];//Final mapping array between old numbers and new numbers.;
+
+ int oldNumberOfFace = oldConstituent->_nodal->getNumberOf(); oldNumberOfFaceTab[0]=oldNumberOfFace;
+ const int * oldConstituentValue = oldConstituent->_nodal->getValue(); oldConstituentValueTab[0]=oldConstituentValue;
+ const int * oldConstituentIndex = oldConstituent->_nodal->getIndex(); oldConstituentIndexTab[0]=oldConstituentIndex;
+ int * renumberingFromOldToNew= new int [oldNumberOfFace]; renumberingFromOldToNewTab[0]=renumberingFromOldToNew;
+
+ int oldNumberOfFacePoly = oldConstituent->getNumberOfPolygons();
+ const int * oldConstituentValuePoly=0;
+ const int * oldConstituentIndexPoly=0;
+ int * renumberingFromOldToNewPoly=0;
+
+ int nbOfTurnInGlobalLoop=1;//Defined to know if a second search on polygons is needed.
+ if(oldNumberOfFacePoly>0)
+ {
+ oldNumberOfFaceTab[1]=oldNumberOfFacePoly;
+ oldConstituentValuePoly = oldConstituent->_polygonsNodal->getValue(); oldConstituentValueTab[1]=oldConstituentValuePoly;
+ oldConstituentIndexPoly = oldConstituent->_polygonsNodal->getIndex(); oldConstituentIndexTab[1]=oldConstituentIndexPoly;
+ renumberingFromOldToNewPoly=new int[oldNumberOfFacePoly]; renumberingFromOldToNewTab[1]=renumberingFromOldToNewPoly;
+ nbOfTurnInGlobalLoop++;
}
+
+ calculateDescendingConnectivity();//perform calculation of descending connectivity to update all connectivities after having taken into account of direction of faces...
+ _constituent->calculateReverseNodalConnectivity();//getting d-1 nodal connectivity to find get new face numbers from nodes numbers...
+
+ const int * reverseFaceNodal = _constituent->getReverseNodalConnectivity(); //Common to polygons and classic geometric types
+ const int * reverseFaceNodalIndex = _constituent->getReverseNodalConnectivityIndex(); //Common to polygons and classic geometric types
- // well we could go !
- 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"));
- }
- int oldNumberOfFace = oldConstituent->_nodal->getNumberOf();
- const int * oldConstituentValue = oldConstituent->_nodal->getValue();
- const int * oldConstituentIndex = oldConstituent->_nodal->getIndex();
-
- calculateDescendingConnectivity();
-
- MESSAGE(LOC << " Right after the call to calculateDescendingConnectivity");
- // int newNumberOfFace = _constituent->_nodal->getNumberOf();
- const int * newConstituentValue = _constituent->_nodal->getValue();
- const int * newConstituentIndex = _constituent->_nodal->getIndex();
-
- const int * newReverseDescendingIndex =
- _reverseDescendingConnectivity->getIndex();
-
- 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
- // (with oldCconstituentValue and oldConstituentIndex)
- // and search the constituent in newConstituentValue with class
- // ModulusArry
- //
- // when a new face is found, replace old constituent
- // number in family with new one
- // If face is not rigth oriented, we must change _descending attribute
- // and _reverseDescendingConnectivity (see calculateDescendingConnectivity()).
-
- // Voila a toi de jouer Nadir :-)
-
- // First we get the renumbering from the oldCconstituentValue and
- // oldConstituentIndex in the the new one, newConstituentValue and
- // newConstituentIndex with a negative sign if the face is not
- // right orented
-
- int * renumberingFromOldToNew = new int [oldNumberOfFace];
- int index1 = 0;
- int indexm1 = 0;
-
- MESSAGE(LOC << " Right before the call to _constituent->calculateReverseNodalConnectivity");
- _constituent->calculateReverseNodalConnectivity();
- MESSAGE(LOC << " Right after the call to _constituent->calculateReverseNodalConnectivity");
-
-
- SCRUTE(oldNumberOfFace);
-
-
- 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;
-
- const int* NodesLists = oldConstituentValue + (face_it_beginOld-1);
- int face_size_itNew;
-
- 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 NumberOfFacesInList=EndIndexFaceArrayFirstNode-BeginIndexFaceArrayFirstNode;
-
- 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];
-
- 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;
- if (FacesList[l1]==reverseFaceNodal[l2-1]) {
- // we have found one
- NewFacesList[NewNumberOfFacesInList]=FacesList[l1];
- NewNumberOfFacesInList++;
- break;
+ for(int loop=0;loop<nbOfTurnInGlobalLoop;loop++)
+ {
+ int oldNumberOfFaceLoop=oldNumberOfFaceTab[loop];
+ const int * oldConstituentValueLoop=oldConstituentValueTab[loop];
+ const int * oldConstituentIndexLoop= oldConstituentIndexTab[loop];
+ int * renumberingFromOldToNewLoop=renumberingFromOldToNewTab[loop];
+ for(int iOldFace=0;iOldFace<oldNumberOfFaceLoop;iOldFace++)
+ {
+ const int *nodesOfCurrentFaceOld=oldConstituentValueLoop+oldConstituentIndexLoop[iOldFace]-1;
+ int nbOfNodesOfCurrentFaceOld=oldConstituentIndexLoop[iOldFace+1]-oldConstituentIndexLoop[iOldFace];
+
+ //retrieving new number of polygon face...
+ int sizeOfNewFaceNb=reverseFaceNodalIndex[nodesOfCurrentFaceOld[0]]-reverseFaceNodalIndex[nodesOfCurrentFaceOld[0]-1];
+ int *newFaceNb=new int[sizeOfNewFaceNb];
+ memcpy(newFaceNb,reverseFaceNodal+reverseFaceNodalIndex[nodesOfCurrentFaceOld[0]-1]-1,sizeOfNewFaceNb*sizeof(int));//all faces candidates are in newFaceNb !!!
+ for(int curNode=1;curNode<nbOfNodesOfCurrentFaceOld && sizeOfNewFaceNb>1;curNode++)
+ {
+ const int *newFacesNbForCurNode=reverseFaceNodal+reverseFaceNodalIndex[nodesOfCurrentFaceOld[curNode]-1]-1;
+ int sizeOfNewFacesNbForCurNode=reverseFaceNodalIndex[nodesOfCurrentFaceOld[curNode]]-reverseFaceNodalIndex[nodesOfCurrentFaceOld[curNode]-1];
+ for(int i=0;i<sizeOfNewFaceNb;)
+ {
+ bool found=false;
+ for(int j=0;j<sizeOfNewFacesNbForCurNode && !found;j++)
+ {
+ if(newFacesNbForCurNode[j]==newFaceNb[i])
+ found=true;
+ }
+ if(found)
+ i++;
+ else
+ newFaceNb[i]=newFaceNb[--sizeOfNewFaceNb];
}
- }
}
- NumberOfFacesInList = NewNumberOfFacesInList;
- delete [] FacesList;
- FacesList = NewFacesList;
- }
-
- if (!NumberOfFacesInList==0)
- {
- if (NumberOfFacesInList>1)
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"More than one face found ("<<NumberOfFacesInList<<") ! " <<FacesList[0]<<" "<<FacesList[1] ));
-
- MEDMODULUSARRAY modulusArrayOld(face_size_itOld,NodesLists);
-
- int face_it_beginNew = newConstituentIndex[FacesList[0]-1];
- int face_it_endNew = newConstituentIndex[FacesList[0]];
- face_size_itNew = face_it_endNew - face_it_beginNew;
-
- 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];
- index = 1;
- index1++;
- }
-
- // Reverse new face found
-
- if(retCompareNewOld == -1)
- {
- renumberingFromOldToNew[iOldFace] = FacesList[0];
- index = 1;
- indexm1++;
-
- int face_it_begin = newReverseDescendingIndex[FacesList[0]-1];
- int face_it_end = newReverseDescendingIndex[FacesList[0]];
- int face_size_it = face_it_end - face_it_begin;
-
- if (face_size_it == 1)
- throw MED_EXCEPTION(LOCALIZED(STRING(LOC)<<"This is a boundary face/edge, it should not be renumbered and it is wrongly oriented."));
-
- if (face_size_it > 2)
- 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 = _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 !!!!
-
- _reverseDescendingConnectivity->setIJ(FacesList[0],1,cell2);
- // Updating _constituent->_nodal because of reversity
- 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
-
-
- _reverseDescendingConnectivity->setIJ(FacesList[0],2,cell1);
-
- // Updating _descending for cell1 and cell2
- 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 (_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 !!!!!!!!
- MESSAGE("WARNING,WARNING,WARNING,WARNING,WARNING,WARNING");
- MESSAGE(LOC<<" Boudary FACE "<<iOldFace+1<<" are wrong oriented !");
- MESSAGE("WARNING,WARNING,WARNING,WARNING,WARNING,WARNING");
- }
- }
-
- if(index == 0)
- {
- MESSAGE(LOC<<"Renumbering problem with the Face connectivity given by the User and the new Connectivity computed");
- throw MED_EXCEPTION(LOCALIZED(STRING(LOC)<<"We have a Face connectivity problem"));
- }
- }
- delete [] FacesList;
- }
-
- MESSAGE(LOC<<"The Renumbering is finished and the status is");
-
- // Updating the Family
-
- SCRUTE(numberOfFamilies);
-
- for(int i=0; i<numberOfFamilies; i++) {
- FAMILY * myFamily = myFamilies[i];
-
- SCRUTE(myFamily);
- // MESSAGE(LOC<<(*myFamily));
-
- if (myFamily->isOnAllElements()) {
- // we build number
- // we must have more constituent ?
- if (oldNumberOfFace==_constituent->getNumberOf(_constituent->getEntity(),MED_ALL_ELEMENTS))
- throw MED_EXCEPTION(LOCALIZED(STRING(LOC)<<"We have a family which is already in all constituent !"));
- myFamily->setAll(false);
- // values array :
- int * values = new int[oldNumberOfFace] ;
- for (int ind=0;ind<oldNumberOfFace;ind++)
- values[ind]=ind+1;
- // index array
- int NumberOfTypes = myFamily->getNumberOfTypes();
- const int * count = oldConstituent->getGlobalNumberingIndex(_constituent->getEntity());
- int * index = new int[NumberOfTypes+1] ;
- memcpy(index,count,(NumberOfTypes+1)*sizeof(int));
- // build new number attribut
- myFamily->setNumber(index,values);
- }
-
- // MESSAGE(LOC<<(*myFamily));
- MEDSKYLINEARRAY * number = myFamily->getnumber();
-
- int numberOfLines_skyline = number->getNumberOf();
-
-
- SCRUTE(numberOfLines_skyline);
-
- const int * index_skyline = number->getIndex();
-
- SCRUTE(index_skyline);
-
- 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]);
+ if(sizeOfNewFaceNb!=1)
+ throw MED_EXCEPTION(LOCALIZED(STRING(LOC)<<"unexisting face specified!!!"));
+ renumberingFromOldToNewLoop[iOldFace]=newFaceNb[0];
+ delete [] newFaceNb;
+ //end of retrieving new number of polygon face...
+ int nbOfNodesOfCurrentFaceNew;
+ const int *nodesOfCurrentFaceNew=_constituent->getConnectivityOfAnElementWithPoly(MED_NODAL,_constituent->getEntity(),
+ renumberingFromOldToNewLoop[iOldFace],nbOfNodesOfCurrentFaceNew);
+ MEDMODULUSARRAY modulusArrayOld(nbOfNodesOfCurrentFaceOld,nodesOfCurrentFaceOld);
+ MEDMODULUSARRAY modulusArrayNew(nbOfNodesOfCurrentFaceNew,nodesOfCurrentFaceNew);
+ int retCompareNewOld=modulusArrayNew.compare(modulusArrayOld);
+ if(retCompareNewOld==0)
+ throw MED_EXCEPTION(LOCALIZED(STRING(LOC)<<"Uncompatible given user face with calculated existing faces"));
+ if(retCompareNewOld==-1)
+ invertConnectivityForAFace(renumberingFromOldToNewLoop[iOldFace],nodesOfCurrentFaceOld,loop==1);
}
- }
- // MESSAGE(LOC<<"updating the family (END) : " << *myFamily);
}
-
- delete oldConstituent ;
- delete [] renumberingFromOldToNew;
- }
-
-
- END_OF(LOC);
+ // Updating the Family
+ for(vector<FAMILY*>::const_iterator iter=myFamilies.begin();iter!=myFamilies.end();iter++)
+ (*iter)->changeElementsNbs(_constituent->getEntity(),renumberingFromOldToNew,oldNumberOfFace,renumberingFromOldToNewPoly);
+ delete oldConstituent ;
+ delete [] renumberingFromOldToNew;
+ if(oldNumberOfFacePoly>0)
+ delete [] renumberingFromOldToNewPoly;
return;
}
-// meme methode que updateFamily, mais avec des groupes. Il n'est pas possible d'utiliser
-// l'heritage car les pointeurs sont dans un conteneur.
-void CONNECTIVITY::updateGroup(vector<GROUP*> myFamilies)
-//------------------------------------------------------------//
+//------------------------------------------------------------------------------------------------------------------//
+const int * MEDMEM::CONNECTIVITY::getConnectivity(medConnectivity ConnectivityType, medEntityMesh Entity, medGeometryElement Type)
+//------------------------------------------------------------------------------------------------------------------//
{
- const char * LOC = "CONNECTIVITY::updateGroup(vector<GROUP*>) ";
+ const char * LOC = "CONNECTIVITY::getConnectivity";
BEGIN_OF(LOC);
- int numberOfFamilies = myFamilies.size();
- if (numberOfFamilies == 0 ) {
- MESSAGE(LOC<<"No family");
- return;
- }
- // does we do an update ?
- if ((_constituent != NULL)&(_descending != NULL)) {
- 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;
- }
-
- // well we could go !
- 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)
+ MEDSKYLINEARRAY * Connectivity;
+ if (Entity==_entity) {
+
+ if (ConnectivityType==MED_NODAL)
{
- MESSAGE(LOC<<"We have no nodal connectivity of sub cell");
- throw MED_EXCEPTION(LOCALIZED(STRING(LOC)<<"We have no nodal connectivity of sub cell"));
+ calculateNodalConnectivity();
+ Connectivity=_nodal;
}
- int oldNumberOfFace = oldConstituent->_nodal->getNumberOf();
- const int * oldConstituentValue = oldConstituent->_nodal->getValue();
- const int * oldConstituentIndex = oldConstituent->_nodal->getIndex();
-
- calculateDescendingConnectivity();
-
- // int newNumberOfFace = _constituent->_nodal->getNumberOf();
- const int * newConstituentValue = _constituent->_nodal->getValue();
- const int * newConstituentIndex = _constituent->_nodal->getIndex();
-
- const int * newReverseDescendingIndex =
- _reverseDescendingConnectivity->getIndex();
-
- 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
- // (with oldCconstituentValue and oldConstituentIndex)
- // and search the constituent in newConstituentValue with class
- // ModulusArry
- //
- // when a new face is found, replace old constituent
- // number in family with new one
- // If face is not rigth oriented, we must change _descending attribute
- // and _reverseDescendingConnectivity (see calculateDescendingConnectivity()).
-
- // Voila a toi de jouer Nadir :-)
-
- // First we get the renumbering from the oldCconstituentValue and
- // oldConstituentIndex in the the new one, newConstituentValue and
- // newConstituentIndex with a negative sign if the face is not
- // right orented
-
- int * renumberingFromOldToNew = new int [oldNumberOfFace];
- int index1 = 0;
- int indexm1 = 0;
-
- _constituent->calculateReverseNodalConnectivity();
-
- for (int iOldFace=0;iOldFace<oldNumberOfFace;iOldFace++)
+ else
{
- 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;
-
- const int* NodesLists = oldConstituentValue + (face_it_beginOld-1);
- int face_size_itNew;
-
- 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 NumberOfFacesInList=EndIndexFaceArrayFirstNode-BeginIndexFaceArrayFirstNode;
-
- 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];
-
- 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;
- if (FacesList[l1]==reverseFaceNodal[l2-1]) {
- // we have found one
- NewFacesList[NewNumberOfFacesInList]=FacesList[l1];
- NewNumberOfFacesInList++;
- break;
- }
- }
- }
- NumberOfFacesInList = NewNumberOfFacesInList;
- delete [] FacesList;
- FacesList = NewFacesList;
- }
-
- if (!NumberOfFacesInList==0)
- {
- if (NumberOfFacesInList>1)
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"More than one face found ("<<NumberOfFacesInList<<") ! " <<FacesList[0]<<" "<<FacesList[1] ));
-
- MEDMODULUSARRAY modulusArrayOld(face_size_itOld,NodesLists);
-
- int face_it_beginNew = newConstituentIndex[FacesList[0]-1];
- int face_it_endNew = newConstituentIndex[FacesList[0]];
- face_size_itNew = face_it_endNew - face_it_beginNew;
-
- 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];
- index = 1;
- index1++;
- }
-
- // Reverse new face found
-
- if(retCompareNewOld == -1)
- {
- renumberingFromOldToNew[iOldFace] = FacesList[0];
- index = 1;
- indexm1++;
-
- int face_it_begin = newReverseDescendingIndex[FacesList[0]-1];
- int face_it_end = newReverseDescendingIndex[FacesList[0]];
- int face_size_it = face_it_end - face_it_begin;
-
- if (face_size_it == 1)
- throw MED_EXCEPTION(LOCALIZED(STRING(LOC)<<"This is a boundary face/edge, it should not be renumbered and it is wrongly oriented."));
-
- if (face_size_it > 2)
- 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 = _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 !!!!
-
- _reverseDescendingConnectivity->setIJ(FacesList[0],1,cell2);
- // Updating _constituent->_nodal because of reversity
- 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
-
-
- _reverseDescendingConnectivity->setIJ(FacesList[0],2,cell1);
-
- // Updating _descending for cell1 and cell2
- 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 (_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 !!!!!!!!
- MESSAGE("WARNING,WARNING,WARNING,WARNING,WARNING,WARNING");
- MESSAGE(LOC<<" Boudary FACE "<<iOldFace+1<<" are wrong oriented !");
- MESSAGE("WARNING,WARNING,WARNING,WARNING,WARNING,WARNING");
- }
- }
-
- if(index == 0)
- {
- MESSAGE(LOC<<"Renumbering problem with the Face connectivity given by the User and the new Connectivity computed");
- throw MED_EXCEPTION(LOCALIZED(STRING(LOC)<<"We have a Face connectivity problem"));
- }
- }
- delete [] FacesList;
+ calculateDescendingConnectivity();
+ Connectivity=_descending;
}
- MESSAGE(LOC<<"The Renumbering is finished and the status is");
-
- // Updating the Family
-
- for(int i=0; i<numberOfFamilies; i++) {
- GROUP * myFamily = myFamilies[i];
-
- MEDSKYLINEARRAY * number = myFamily->getnumber();
- int numberOfLines_skyline = number->getNumberOf();
- const int * index_skyline = number->getIndex();
-
- 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]);
- }
+ if (Connectivity!=NULL)
+ if (Type==MED_ALL_ELEMENTS)
+ return Connectivity->getValue();
+ else {
+ for (int i=0; i<_numberOfTypes; i++)
+ if (_geometricTypes[i]==Type)
+ //return Connectivity->getI(i+1);
+ return Connectivity->getI(_count[i]);
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Type not found !"));
}
- MESSAGE(LOC<<"updating the family (END) : " << *myFamily);
- }
-
- delete oldConstituent ;
- delete [] renumberingFromOldToNew;
- }
+ else
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Connectivity not defined !"));
+ } else
+ if (_constituent != NULL)
+ return _constituent->getConnectivity(ConnectivityType,Entity,Type);
-
- END_OF(LOC);
- return;
-}
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Entity not defined !"));
+}
//------------------------------------------------------------------------------------------------------------------//
-const int * CONNECTIVITY::getConnectivity(medConnectivity ConnectivityType, medEntityMesh Entity, medGeometryElement Type)
+int CONNECTIVITY::getConnectivityLength(medConnectivity ConnectivityType, medEntityMesh Entity, medGeometryElement Type)
//------------------------------------------------------------------------------------------------------------------//
{
const char * LOC = "CONNECTIVITY::getConnectivity";
if (Connectivity!=NULL)
if (Type==MED_ALL_ELEMENTS)
- return Connectivity->getValue();
+ return Connectivity->getLength();
else {
for (int i=0; i<_numberOfTypes; i++)
if (_geometricTypes[i]==Type)
- //return Connectivity->getI(i+1);
- return Connectivity->getI(_count[i]);
+ return Connectivity->getNumberOfI(_count[i]);
throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Type not found !"));
}
else
throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Connectivity not defined !"));
- } else
+ }
+ else
if (_constituent != NULL)
- return _constituent->getConnectivity(ConnectivityType,Entity,Type);
+ return _constituent->getConnectivityLength(ConnectivityType,Entity,Type);
throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Entity not defined !"));
}
throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Entity not defined !"));
}
-/*! A DOCUMENTER */
-//--------------------------------------------------------------//
-const CELLMODEL & CONNECTIVITY::getType(medGeometryElement Type) const
+
+//-------------------------------------------------------------//
+const int* CONNECTIVITY::getPolygonsConnectivity(medConnectivity ConnectivityType, medEntityMesh Entity)
+//-------------------------------------------------------------//
+{
+ const char* LOC = "CONNECTIVITY::getPolygonsConnectivity";
+ BEGIN_OF(LOC);
+
+ MEDSKYLINEARRAY* Connectivity;
+ if (Entity == _entity)
+ {
+ if (ConnectivityType == MED_NODAL)
+ {
+ calculateNodalConnectivity();
+ Connectivity = _polygonsNodal;
+ }
+ else
+ {
+ calculateDescendingConnectivity();
+ Connectivity = _polygonsDescending;
+ }
+ if (Connectivity != NULL)
+ return Connectivity->getValue();
+ else
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Polygons Connectivity not defined !"));
+ }
+ else
+ if (_constituent != NULL)
+ return _constituent->getPolygonsConnectivity(ConnectivityType, Entity);
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Entity not defined !"));
+}
+
+
+//-------------------------------------------------------------//
+const int* CONNECTIVITY::getPolygonsConnectivityIndex(medConnectivity ConnectivityType, medEntityMesh Entity)
+//-------------------------------------------------------------//
+{
+ const char* LOC = "CONNECTIVITY::getPolygonsConnectivityIndex";
+ BEGIN_OF(LOC);
+
+ MEDSKYLINEARRAY* Connectivity;
+ if (Entity == _entity)
+ {
+ if (ConnectivityType == MED_NODAL)
+ {
+ // calculateNodalConnectivity();
+ Connectivity = _polygonsNodal;
+ }
+ else
+ {
+ // calculateDescendingConnectivity();
+ Connectivity = _polygonsDescending;
+ }
+ if (Connectivity != NULL)
+ return Connectivity->getIndex();
+ else
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Polygons Connectivity not defined !"));
+ }
+ else
+ if (_constituent != NULL)
+ return _constituent->getPolygonsConnectivityIndex(ConnectivityType, Entity);
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Entity not defined !"));
+}
+
+
+/*! We suppose in this method that nodal and descending connectivities
+ are coherent.*/
+//-------------------------------------------------------------//
+int CONNECTIVITY::getNumberOfPolygons() const
+//-------------------------------------------------------------//
+{
+ if (_polygonsNodal != (MEDSKYLINEARRAY*) NULL)
+ return _polygonsNodal->getNumberOf();
+ else if (_polygonsDescending != (MEDSKYLINEARRAY*) NULL)
+ return _polygonsDescending->getNumberOf();
+ else
+ return 0;
+}
+
+
+//--------------------------------------------------------------//
+const int* CONNECTIVITY::getPolyhedronConnectivity(medConnectivity ConnectivityType) const
+//--------------------------------------------------------------//
+{
+ const char* LOC = "CONNECTIVITY::getPolyhedronConnectivity";
+ BEGIN_OF(LOC);
+
+ if (_entity == MED_CELL) //polyhedron can only be MED_CELL
+ {
+ if (ConnectivityType == MED_NODAL)
+ {
+ ((CONNECTIVITY *)(this))->calculateNodalConnectivity();
+ if (_polyhedronNodal != (POLYHEDRONARRAY*) NULL)
+ return _polyhedronNodal->getNodes();
+ else
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Polyhedron Nodal Connectivity not defined !"));
+ }
+ else
+ {
+ ((CONNECTIVITY *)(this))->calculateDescendingConnectivity();
+ if (_polyhedronDescending != (MEDSKYLINEARRAY*) NULL)
+ return _polyhedronDescending->getValue();
+ else
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Polyhedron Descending Connectivity not defined !"));
+ }
+ }
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : No polyhedron for _entity different from MED_CELL !"));
+}
+
+
+//---------------------------------------------------------------//
+const int* CONNECTIVITY::getPolyhedronFacesIndex() const
+//---------------------------------------------------------------//
+{
+ const char* LOC = "CONNECTIVITY::getPolyhedronFacesIndex";
+ BEGIN_OF(LOC);
+
+ if (_entity == MED_CELL) //polyhedron can only be MED_CELL
+ {
+ // calculateNodalConnectivity();
+ if (_polyhedronNodal != (POLYHEDRONARRAY*) NULL)
+ return _polyhedronNodal->getFacesIndex();
+ else
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : No Polyhedron in that Connectivity !"));
+ }
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : No polyhedron for _entity different from MED_CELL !"));
+}
+
+
+//--------------------------------------------------------------//
+const int* CONNECTIVITY::getPolyhedronIndex(medConnectivity ConnectivityType) const
+//--------------------------------------------------------------//
+{
+ const char* LOC = "CONNECTIVITY::getPolyhedronIndex";
+ BEGIN_OF(LOC);
+
+ if (_entity == MED_CELL) //polyhedron can only be MED_CELL
+ {
+ if (ConnectivityType == MED_NODAL)
+ {
+ // calculateNodalConnectivity();
+ if (_polyhedronNodal != (POLYHEDRONARRAY*) NULL)
+ return _polyhedronNodal->getPolyhedronIndex();
+ else
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Polyhedron Nodal Connectivity not defined !"));
+ }
+ else
+ {
+ // calculateDescendingConnectivity();
+ if (_polyhedronDescending != (MEDSKYLINEARRAY*) NULL)
+ return _polyhedronDescending->getIndex();
+ else
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Polyhedron Descending Connectivity not defined !"));
+ }
+ }
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : No polyhedron for _entity different from MED_CELL !"));
+}
+
+
+/*! We suppose in this method that nodal and descending connectivities
+ are coherent.*/
+//-------------------------------------------------------------//
+int CONNECTIVITY::getNumberOfPolyhedronFaces() const
+//-------------------------------------------------------------//
+{
+ // if (_polyhedronNodal == (POLYHEDRONARRAY*) NULL)
+ // calculateNodalConnectivity();
+ if (_polyhedronNodal != (POLYHEDRONARRAY*) NULL)
+ return _polyhedronNodal->getNumberOfFaces();
+ else
+ return 0;
+}
+
+
+/*! We suppose in this method that nodal and descending connectivities
+ are coherent.*/
+//--------------------------------------------------------------//
+int CONNECTIVITY::getNumberOfPolyhedron() const
+//--------------------------------------------------------------//
+{
+ if (_polyhedronNodal != (POLYHEDRONARRAY*) NULL)
+ return _polyhedronNodal->getNumberOfPolyhedron();
+ else if (_polyhedronDescending != (MEDSKYLINEARRAY*) NULL)
+ return _polyhedronDescending->getNumberOf();
+ else
+ return 0;
+}
+
+
+/*! A DOCUMENTER */
+//--------------------------------------------------------------//
+const CELLMODEL & CONNECTIVITY::getType(medGeometryElement Type) const
//--------------------------------------------------------------//
{
const char * LOC = "CONNECTIVITY::getType";
//-----------------------------------------------------------------------------------//
{
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 !
//throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : medGeometryElement must be different of MED_NONE"));
+ if (!existConnectivity(MED_NODAL,Entity) && !existConnectivity(MED_DESCENDING,Entity)) return 0; //case with only polygons for example
if (Type==MED_ALL_ELEMENTS)
return _count[_numberOfTypes]-1;
for (int i=0; i<_numberOfTypes; i++)
void CONNECTIVITY::calculateNodalConnectivity()
//--------------------------------------------//
{
- if (_nodal==NULL)
+ if (_nodal==NULL && _polygonsNodal==NULL && _polyhedronNodal==NULL)
{
- if (_descending==NULL)
+ if (_descending==NULL && _polygonsDescending==NULL && _polyhedronDescending==NULL)
throw MEDEXCEPTION("CONNECTIVITY::calculateNodalConnectivity : No connectivity found !");
- // calculate _nodal from _descending
+ // calculate _nodal, _polygonsNodal and _polyhedronNodal from _descending, _polygonsDescending and _polyhedronDescending
}
}
SCRUTE(_nodal);
SCRUTE(_reverseNodalConnectivity);
-
if (_nodal==NULL)
calculateNodalConnectivity();
- if(_reverseNodalConnectivity==NULL)
- {
- int node_number = 0;
- vector <vector <int> > reverse_connectivity;
- reverse_connectivity.resize(_numberOfNodes+1);
+ if(_reverseNodalConnectivity==NULL) {
+
+ int node_number = 0;
+ vector <vector <int> > reverse_connectivity;
+ reverse_connectivity.resize(_numberOfNodes+1);
- // Treat all cells types
+ // Treat all cells types
- for (int j = 0; j < _numberOfTypes; j++)
- {
- // node number of the cell type
- node_number = _type[j].getNumberOfNodes();
- // treat all cells of a particular type
- for (int k = _count[j]; k < _count[j+1]; k++)
- // treat all nodes of the cell type
- for (int local_node_number = 1;
- local_node_number < node_number+1;
- local_node_number++)
- {
- int global_node = _nodal->getIJ(k,local_node_number);
- reverse_connectivity[global_node].push_back(k);
- }
- }
-
- // Full reverse_nodal_connectivity and reverse_nodal_connectivity_index
+ for (int j = 0; j < _numberOfTypes; j++)
+ {
+ // node number of the cell type
+ node_number = _type[j].getNumberOfNodes();
+ // treat all cells of a particular type
+ for (int k = _count[j]; k < _count[j+1]; k++)
+ // treat all nodes of the cell type
+ for (int local_node_number = 1; local_node_number < node_number+1; local_node_number++)
+ {
+ int global_node = _nodal->getIJ(k,local_node_number);
+ reverse_connectivity[global_node].push_back(k);
+ }
+ }
+
+ if(_polygonsNodal != NULL && _entityDimension==2)
+ {
+ int nbOfPolygons=_polygonsNodal->getNumberOf();
+ int offset=getNumberOf(_entity,MED_ALL_ELEMENTS);
+ const int *index=_polygonsNodal->getIndex();
+ const int *value=_polygonsNodal->getValue();
+ for (int local_polyg_number = 0; local_polyg_number < nbOfPolygons; local_polyg_number++)
+ {
+ for(int i=index[local_polyg_number];i<index[local_polyg_number+1];i++)
+ reverse_connectivity[value[i-1]].push_back(offset+local_polyg_number+1);
+ }
+ }
- //calculate size of reverse_nodal_connectivity array
- int size_reverse_nodal_connectivity = 0;
- for (int i = 1; i < _numberOfNodes+1; i++)
- size_reverse_nodal_connectivity += reverse_connectivity[i].size();
+ if(_polyhedronNodal != NULL && _entityDimension==3)
+ {
+ int nbOfPolyhedra=_polyhedronNodal->getNumberOfPolyhedron();
+ int offset=getNumberOf(_entity,MED_ALL_ELEMENTS);
+ for (int local_polyh_number = 0; local_polyh_number < nbOfPolyhedra; local_polyh_number++)
+ {
+ int nbOfNodes;
+ int global_polyh_number=offset+local_polyh_number+1;
+ int *nodes=getNodesOfPolyhedron(global_polyh_number,nbOfNodes);
+ for(int i=0;i<nbOfNodes;i++)
+ reverse_connectivity[nodes[i]].push_back(global_polyh_number);
+ delete [] nodes;
+ }
+ }
- //MEDSKYLINEARRAY * ReverseConnectivity = new MEDSKYLINEARRAY(_numberOfNodes,size_reverse_nodal_connectivity);
+ // Full reverse_nodal_connectivity and reverse_nodal_connectivity_index
+
+ //calculate size of reverse_nodal_connectivity array
+ int size_reverse_nodal_connectivity = 0;
+ for (int i = 1; i < _numberOfNodes+1; i++)
+ size_reverse_nodal_connectivity += reverse_connectivity[i].size();
+
int * reverse_nodal_connectivity_index = new int[_numberOfNodes+1];
int * reverse_nodal_connectivity = new int[size_reverse_nodal_connectivity];
- //const int * reverse_nodal_connectivity = ReverseConnectivity->getValue();
- //const int * reverse_nodal_connectivity_index = ReverseConnectivity->getIndex();
- reverse_nodal_connectivity_index[0] = 1;
- for (int i = 1; i < _numberOfNodes+1; i++)
- {
- int size = reverse_connectivity[i].size();
- reverse_nodal_connectivity_index[i] =
- reverse_nodal_connectivity_index[i-1] + size;
- for (int j = 0; j < size; j++)
- reverse_nodal_connectivity[reverse_nodal_connectivity_index[i-1]-1+j]= reverse_connectivity[i][j];
- }
-
- //_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;
+ reverse_nodal_connectivity_index[0] = 1;
+ for (int i = 1; i < _numberOfNodes+1; i++)
+ {
+ int size = reverse_connectivity[i].size();
+ reverse_nodal_connectivity_index[i] = reverse_nodal_connectivity_index[i-1] + size;
+ for (int j = 0; j < size; j++)
+ reverse_nodal_connectivity[reverse_nodal_connectivity_index[i-1]-1+j]= reverse_connectivity[i][j];
+ }
+
+ _reverseNodalConnectivity = new MEDSKYLINEARRAY(_numberOfNodes,size_reverse_nodal_connectivity,
+ reverse_nodal_connectivity_index,
+ reverse_nodal_connectivity,true);
}
END_OF(LOC);
}
/*! If not yet done, calculate the Descending Connectivity */
//-------------------------------------------------//
void CONNECTIVITY::calculateDescendingConnectivity()
-//-------------------------------------------------//
-{
+ //-------------------------------------------------//
+ {
const char * LOC = "CONNECTIVITY::calculateDescendingConnectivity() : ";
BEGIN_OF(LOC);
- if (_descending==NULL)
+ if (_descending==NULL && _polygonsDescending==NULL && _polyhedronDescending==NULL)
{
if (_nodal==NULL)
{
int * ConstituentNodalConnectivityIndex = new int[TotalNumberOfConstituents+1];
ConstituentNodalConnectivityIndex[0]=1;
- _constituent->_entityDimension=ConstituentsTypes[0]/100;
+ _constituent->_entityDimension = _entityDimension-1;
if (ConstituentsTypes[1]==MED_NONE)
_constituent->_numberOfTypes = 1;
else
_constituent->_numberOfTypes = 2;
_constituent->_geometricTypes = new medGeometryElement[_constituent->_numberOfTypes];
_constituent->_type = new CELLMODEL[_constituent->_numberOfTypes];
- _constituent->_count = new int[_constituent->_numberOfTypes+1];
+ _constituent->_count = new med_int[_constituent->_numberOfTypes+1];
_constituent->_count[0]=1;
- int* tmp_NumberOfConstituentsForeachType = new 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];
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
- if (descend_connectivity[descend_connectivity_index[j-1]+k-2]==0)
- {
- // it is a new sub cell !
- // TotalNumberOfSubCell++;
- // Which type ?
- if (Type.getConstituentType(1,k)==_constituent->_geometricTypes[0])
- {
- tmp_NumberOfConstituentsForeachType[0]++;
- TotalNumberOfSubCell=tmp_NumberOfConstituentsForeachType[0];
- }
- else
- {
- tmp_NumberOfConstituentsForeachType[1]++;
- TotalNumberOfSubCell=tmp_NumberOfConstituentsForeachType[1];
- }
- //we have maximum two types
+ if (descend_connectivity[descend_connectivity_index[j-1]+k-2]==0) {
+ // it is a new sub cell !
+ // TotalNumberOfSubCell++;
+ // Which type ?
+ if (Type.getConstituentType(1,k)==_constituent->_geometricTypes[0]){
+ tmp_NumberOfConstituentsForeachType[0]++;
+ TotalNumberOfSubCell=tmp_NumberOfConstituentsForeachType[0];
+ } else {
+ tmp_NumberOfConstituentsForeachType[1]++;
+ TotalNumberOfSubCell=tmp_NumberOfConstituentsForeachType[1];
+ }
+ //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;
+ descend_connectivity[descend_connectivity_index[j-1]+k-2]=TotalNumberOfSubCell;
+ ReverseDescendingConnectivityValue[(TotalNumberOfSubCell-1)*2]=j;
+ int NumberOfNodesPerConstituent = Type.getConstituentType(1,k)%100;
- 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;
-
- if (NumberOfCellsInList > 0)
- { // we could have no element !
- int * CellsList = new int[NumberOfCellsInList];
- for (int l=ReverseNodalConnectivityIndex_0;
- l<ReverseNodalConnectivityIndex_1; l++)
- CellsList[l-ReverseNodalConnectivityIndex_0]=
- ReverseNodalConnectivityValue[l-1];
+ 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 = getIndexOfEndClassicElementInReverseNodal(ReverseNodalConnectivityValue,ReverseNodalConnectivityIndex,NodesLists[0]-1);
+ //ReverseNodalConnectivityIndex[NodesLists[0]];
+ int NumberOfCellsInList = ReverseNodalConnectivityIndex_1-ReverseNodalConnectivityIndex_0;
+
+ if (NumberOfCellsInList > 0)
+ { // we could have no element !
+ int * CellsList = new int[NumberOfCellsInList];
+ for (int l=ReverseNodalConnectivityIndex_0; l<ReverseNodalConnectivityIndex_1; l++)
+ 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];
- 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;
- if ((CellsList[l1]==
- ReverseNodalConnectivityValue[l2-1])&
- (CellsList[l1]!=j))
- {
- // we have found one
- NewCellsList[NewNumberOfCellsInList] =
- CellsList[l1];
- NewNumberOfCellsInList++;
- break;
- }
- }
- NumberOfCellsInList = NewNumberOfCellsInList;
-
- delete [] CellsList;
- CellsList = NewCellsList;
- }
-
- if (NumberOfCellsInList > 0)
- { // We have found some elements !
- if (NumberOfCellsInList>1)
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"More than one other Cell ("<<NumberOfCellsInList<<") !"));
+ // 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];
+ for (int l1=0; l1<NumberOfCellsInList; l1++)
+ for (int l2=ReverseNodalConnectivityIndex[NodesLists[l]-1]; l2<getIndexOfEndClassicElementInReverseNodal(ReverseNodalConnectivityValue,ReverseNodalConnectivityIndex,NodesLists[l]-1); l2++)
+ //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;
+ if ((CellsList[l1]==ReverseNodalConnectivityValue[l2-1])&(CellsList[l1]!=j)) {
+ // we have found one
+ NewCellsList[NewNumberOfCellsInList]=CellsList[l1];
+ NewNumberOfCellsInList++;
+ break;
+ }
+ }
+ NumberOfCellsInList = NewNumberOfCellsInList;
- int CellNumber = CellsList[0];
+ delete [] CellsList;
+ CellsList = NewCellsList;
+ }
+
+ if (NumberOfCellsInList > 0) { // We have found some elements !
+ int CellNumber = CellsList[0];
+ //delete [] CellsList;
+ if (NumberOfCellsInList>1)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"More than one other Cell ("<<NumberOfCellsInList<<") !"));
- ReverseDescendingConnectivityValue[(TotalNumberOfSubCell-1)*2+1] =
- CellNumber;
+ if (NumberOfCellsInList==1)
+ {
+ ReverseDescendingConnectivityValue[(TotalNumberOfSubCell-1)*2+1]=CellNumber;
// we search sub cell number in this cell to not calculate it another time
// which type ?
//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++;
- }
- 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;
+ 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++;
}
- if (find2)
- break;
- }
+ 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;
+ }
+ if (find2)
+ break;
+ }
if (!find2)
- {
- MESSAGE(LOC<<"ERROR ERROR ERROR ERROR ERROR : we find any subcell !!!"); // exception ?
- }
- }
- else
- {
- ReverseDescendingConnectivityValue[(TotalNumberOfSubCell-1)*2+1]=0;
- }
- delete [] CellsList;
+ MESSAGE(LOC<<"ERROR ERROR ERROR ERROR ERROR : we find any subcell !!!"); // exception ?
+ }
+ } else {
+ ReverseDescendingConnectivityValue[(TotalNumberOfSubCell-1)*2+1]=0;
}
-
- delete [] NodesLists;
- }
+ delete [] CellsList;
+ }
+
+ delete [] NodesLists;
+ }
}
}
// we adjust _constituent
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();
- }
+ 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);
//const int *ConstituentNodalValue = ConstituentNodal->getValue();
reverseDescendingConnectivityIndex[0]=1;
// first constituent type
- for(int j=0; j<tmp_NumberOfConstituentsForeachType[0]; j++)
- {
- ConstituentNodalIndex[j+1]=ConstituentNodalConnectivityIndex[j+1];
- for(int k=ConstituentNodalIndex[j]; k<ConstituentNodalIndex[j+1]; k++)
- {
- ConstituentNodalValue[k-1]=ConstituentNodalConnectivity[k-1];
- }
- reverseDescendingConnectivityIndex[j+1] =
- reverseDescendingConnectivityIndex[j]+2;
- for(int k=reverseDescendingConnectivityIndex[j];
- k<reverseDescendingConnectivityIndex[j+1]; k++)
- {
- reverseDescendingConnectivityValue[k-1] =
- ReverseDescendingConnectivityValue[k-1];
- }
+ for(int j=0; j<tmp_NumberOfConstituentsForeachType[0]; j++) {
+ ConstituentNodalIndex[j+1]=ConstituentNodalConnectivityIndex[j+1];
+ for(int k=ConstituentNodalIndex[j]; k<ConstituentNodalIndex[j+1]; k++){
+ ConstituentNodalValue[k-1]=ConstituentNodalConnectivity[k-1];
+ }
+ reverseDescendingConnectivityIndex[j+1]=reverseDescendingConnectivityIndex[j]+2;
+ for(int k=reverseDescendingConnectivityIndex[j]; k<reverseDescendingConnectivityIndex[j+1]; k++){
+ reverseDescendingConnectivityValue[k-1]=ReverseDescendingConnectivityValue[k-1];
}
+ }
// second type if any
- if (_constituent->_numberOfTypes==2)
- {
- int offset = _constituent->_count[1]-tmp_NumberOfConstituentsForeachType[0]-1;
- int offset1=offset*_constituent->_type[0].getNumberOfNodes();
- 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;
- for(int k=ConstituentNodalIndex[j]; k<ConstituentNodalIndex[j+1]; k++)
- {
- ConstituentNodalValue[k-1]=ConstituentNodalConnectivity[offset1+k-1];
- }
- reverseDescendingConnectivityIndex[j+1] =
- reverseDescendingConnectivityIndex[j]+2;
- for(int k=reverseDescendingConnectivityIndex[j];
- k<reverseDescendingConnectivityIndex[j+1]; k++)
- {
- reverseDescendingConnectivityValue[k-1] =
- ReverseDescendingConnectivityValue[offset2+k-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;
- else if (descend_connectivity[j]<-tmp_NumberOfConstituentsForeachType[0])
- descend_connectivity[j]+=offset;
- }
+ if (_constituent->_numberOfTypes==2) {
+ int offset = _constituent->_count[1]-tmp_NumberOfConstituentsForeachType[0]-1;
+ int offset1=offset*_constituent->_type[0].getNumberOfNodes();
+ 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;
+ for(int k=ConstituentNodalIndex[j]; k<ConstituentNodalIndex[j+1]; k++){
+ ConstituentNodalValue[k-1]=ConstituentNodalConnectivity[offset1+k-1];
+ }
+ reverseDescendingConnectivityIndex[j+1]=reverseDescendingConnectivityIndex[j]+2;
+ for(int k=reverseDescendingConnectivityIndex[j]; k<reverseDescendingConnectivityIndex[j+1]; k++){
+ reverseDescendingConnectivityValue[k-1]=ReverseDescendingConnectivityValue[offset2+k-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;
+ delete [] ReverseDescendingConnectivityValue;
+ _constituent->_count[1]=tmp_NumberOfConstituentsForeachType[0]+1;
+ delete [] tmp_NumberOfConstituentsForeachType;
_descending = new MEDSKYLINEARRAY(_count[_numberOfTypes]-1,
DescendingSize,
descend_connectivity);
delete [] descend_connectivity_index;
delete [] descend_connectivity;
- _reverseDescendingConnectivity = new MEDSKYLINEARRAY(NumberOfConstituent,
- 2*NumberOfConstituent,
- reverseDescendingConnectivityIndex,
- reverseDescendingConnectivityValue);
- delete [] reverseDescendingConnectivityIndex;
+
+ ////
+ vector<int> PolyDescending;
+ vector<int> Reversedescendingconnectivityvalue(reverseDescendingConnectivityValue,reverseDescendingConnectivityValue + 2*NumberOfConstituent);
+ vector<int> Reversedescendingconnectivityindex(reverseDescendingConnectivityIndex,reverseDescendingConnectivityIndex + NumberOfConstituent);
delete [] reverseDescendingConnectivityValue;
+ delete [] reverseDescendingConnectivityIndex;
- _constituent->_count[1]=tmp_NumberOfConstituentsForeachType[0]+1;
- delete [] tmp_NumberOfConstituentsForeachType;
-
- //delete _constituent->_nodal;
+
+ // polygons (2D mesh)
+
+ vector<int> Constituentnodalvalue(ConstituentNodalValue,ConstituentNodalValue + SizeOfConstituentNodal);
+ vector<int> Constituentnodalindex(ConstituentNodalIndex,ConstituentNodalIndex + NumberOfConstituent+1);
+ delete [] ConstituentNodalValue;
+ delete [] ConstituentNodalIndex;
+ int NumberOfNewSeg = 0;
+
+ for (int i=0; i <getNumberOfPolygons(); i++) // for each polygon
+ {
+ const int * vector_begin = &_polygonsNodal->getValue()[_polygonsNodal->getIndex()[i]-1];
+ int vector_size = _polygonsNodal->getIndex()[i+1]-_polygonsNodal->getIndex()[i]+1;
+ vector<int> myPolygon(vector_begin, vector_begin+vector_size);
+ myPolygon[myPolygon.size()-1] = myPolygon[0]; // because first and last point make a segment
+
+ for (int j=0; j<myPolygon.size()-1; j++) // for each segment of polygon
+ {
+ MEDMODULUSARRAY segment_poly(2,&myPolygon[j]);
+ int ret_compare = 0;
+
+ // we search it in existing segments
+
+ for (int k=0; k<Constituentnodalindex.size()-1; k++)
+ {
+ MEDMODULUSARRAY segment(2,&Constituentnodalvalue[0] + Constituentnodalindex[k]-1);
+ ret_compare = segment_poly.compare(segment);
+ if (ret_compare) // segment_poly already exists
+ {
+ PolyDescending.push_back(ret_compare*(k+1)); // we had it to the connectivity
+ insert_vector(Reversedescendingconnectivityvalue, 2*k+1, i+1 + getNumberOf(MED_CELL,MED_ALL_ELEMENTS)); // add polygon i to reverse descending connectivity for segment_poly (in 2sd place)
+ break;
+ }
+ }
+
+ // segment_poly must be created
+
+ if (!ret_compare)
+ {
+ NumberOfNewSeg++;
+ PolyDescending.push_back(NumberOfConstituent+NumberOfNewSeg); // we had it to the connectivity
+ Constituentnodalvalue.push_back(segment_poly[0]);
+ Constituentnodalvalue.push_back(segment_poly[1]);
+ Constituentnodalindex.push_back(Constituentnodalindex[Constituentnodalindex.size()-1] + 2); // we have only segments
+ insert_vector(Reversedescendingconnectivityvalue, 2*(NumberOfConstituent+NumberOfNewSeg-1), i+1 + getNumberOf(MED_CELL,MED_ALL_ELEMENTS)); // add polygon i to reverse descending connectivity for segment_poly (in 1st place)
+ insert_vector(Reversedescendingconnectivityindex, NumberOfConstituent+NumberOfNewSeg-1, 2*(NumberOfConstituent+NumberOfNewSeg-1)+1); // idem with index
+ }
+ }
+ }
+
+ if (getNumberOfPolygons() > 0)
+ {
+ _polygonsDescending = new MEDSKYLINEARRAY(getNumberOfPolygons(),_polygonsNodal->getLength(),_polygonsNodal->getIndex(),&PolyDescending[0]); // index are the same for polygons nodal and descending connectivities
+
+ NumberOfConstituent += NumberOfNewSeg;
+ SizeOfConstituentNodal += 2*NumberOfNewSeg;
+ _constituent->_count[1] = NumberOfConstituent+1;
+ }
+
+
+ // polyhedron (3D mesh)
+
+ vector<int> Constituentpolygonsnodalvalue;
+ vector<int> Constituentpolygonsnodalindex(1,1);
+ int NumberOfNewFaces = 0; // by convention new faces are polygons
+
+ for (int i=0; i<getNumberOfPolyhedron(); i++) // for each polyhedron
+ {
+ // we create a POLYHEDRONARRAY containing only this polyhedra
+ int myNumberOfFaces = _polyhedronNodal->getPolyhedronIndex()[i+1]-_polyhedronNodal->getPolyhedronIndex()[i];
+ int myNumberOfNodes = _polyhedronNodal->getFacesIndex()[_polyhedronNodal->getPolyhedronIndex()[i+1]-1]-_polyhedronNodal->getFacesIndex()[_polyhedronNodal->getPolyhedronIndex()[i]-1];
+ POLYHEDRONARRAY myPolyhedra(1,myNumberOfFaces,myNumberOfNodes);
+ vector<int> myFacesIndex(_polyhedronNodal->getFacesIndex() + _polyhedronNodal->getPolyhedronIndex()[i]-1, _polyhedronNodal->getFacesIndex() + _polyhedronNodal->getPolyhedronIndex()[i]-1 + myNumberOfFaces+1);
+ for (int j=myNumberOfFaces; j>=0; j--)
+ myFacesIndex[j] -= myFacesIndex[0]-1;
+ myPolyhedra.setFacesIndex(&myFacesIndex[0]);
+ myPolyhedra.setNodes(_polyhedronNodal->getNodes() + _polyhedronNodal->getFacesIndex()[_polyhedronNodal->getPolyhedronIndex()[i]-1]-1);
+
+ for (int j=0; j<myPolyhedra.getNumberOfFaces(); j++) // for each face of polyhedra
+ {
+ int myFaceNumberOfNodes = myPolyhedra.getFacesIndex()[j+1]-myPolyhedra.getFacesIndex()[j];
+ MEDMODULUSARRAY face_poly(myFaceNumberOfNodes,myPolyhedra.getNodes() + myPolyhedra.getFacesIndex()[j]-1);
+ int ret_compare = 0;
+
+ // we search it in existing faces
+
+ // we search first in TRIA3 and QUAD4
+ if (myFaceNumberOfNodes == 3 || myFaceNumberOfNodes == 4)
+ {
+ int Begin = -1; // first TRIA3 or QUAD4
+ int Number = 0; // number of TRIA3 or QUAD4
+ for (int k=0; k<Constituentnodalindex.size()-1; k++)
+ if (Constituentnodalindex[k+1]-Constituentnodalindex[k] == myFaceNumberOfNodes)
+ {
+ if (Begin == -1)
+ Begin = k;
+ Number++;
+ }
+
+ for (int k=0; k<Number; k++)
+ {
+ MEDMODULUSARRAY face(myFaceNumberOfNodes,&Constituentnodalvalue[0] + Constituentnodalindex[Begin+k]-1);
+ ret_compare = face_poly.compare(face);
+ if (ret_compare)
+ {
+ PolyDescending.push_back(ret_compare*(Begin+k+1)); // we had it to the connectivity
+ insert_vector(Reversedescendingconnectivityvalue, 2*(Begin+k)+1, i+1 + getNumberOf(MED_CELL,MED_ALL_ELEMENTS)); // add polyhedra i to reverse descending connectivity for face_poly (in 2sd place)
+ break;
+ }
+ }
+ }
+
+ // we search last in POLYGONS
+ if (!ret_compare)
+ {
+ for (int k=0; k<static_cast<int>(Constituentpolygonsnodalindex.size())-1; k++) // we must cast the unsigned int into int before doing -1
+ {
+ if (Constituentpolygonsnodalindex[k+1]-Constituentpolygonsnodalindex[k] == myFaceNumberOfNodes)
+ {
+ MEDMODULUSARRAY face(myFaceNumberOfNodes,&Constituentpolygonsnodalvalue[0] + Constituentpolygonsnodalindex[k]-1);
+ ret_compare = face_poly.compare(face);
+ if (ret_compare)
+ {
+ PolyDescending.push_back(ret_compare*(NumberOfConstituent+k+1)); // we had it to the connectivity
+ insert_vector(Reversedescendingconnectivityvalue, 2*(NumberOfConstituent+k)+1, i+1 + getNumberOf(MED_CELL,MED_ALL_ELEMENTS)); // add polyhedra i to reverse descending connectivity for face_poly (in 2sd place)
+ break;
+ }
+ }
+ }
+ }
+
+ // if not found, face_poly must be created
+
+ if (!ret_compare)
+ {
+ NumberOfNewFaces++;
+ PolyDescending.push_back(NumberOfConstituent+NumberOfNewFaces); // we had it to the connectivity
+ for (int k=0; k<myFaceNumberOfNodes; k++)
+ Constituentpolygonsnodalvalue.push_back(face_poly[k]);
+ Constituentpolygonsnodalindex.push_back(Constituentpolygonsnodalindex[Constituentpolygonsnodalindex.size()-1]+myFaceNumberOfNodes);
+ insert_vector(Reversedescendingconnectivityvalue, 2*(NumberOfConstituent+NumberOfNewFaces-1), i+1 + getNumberOf(MED_CELL,MED_ALL_ELEMENTS)); // add polyhedra i to reverse descending connectivity for face_poly (in 1st place)
+ insert_vector(Reversedescendingconnectivityindex, NumberOfConstituent+NumberOfNewFaces-1, 2*(NumberOfConstituent+NumberOfNewFaces-1)+1); // idem with index
+ }
+ }
+ }
+
+ if (getNumberOfPolyhedron() > 0)
+ {
+ _polyhedronDescending = new MEDSKYLINEARRAY(getNumberOfPolyhedron(),_polyhedronNodal->getNumberOfFaces(),_polyhedronNodal->getPolyhedronIndex(),&PolyDescending[0]); // polyhedron index are the same for nodal and descending connectivities
+
+ if (_constituent->_polygonsNodal != NULL)
+ delete [] _constituent->_polygonsNodal;
+ _constituent->_polygonsNodal = new MEDSKYLINEARRAY(Constituentpolygonsnodalindex.size()-1,Constituentpolygonsnodalvalue.size(),&Constituentpolygonsnodalindex[0],&Constituentpolygonsnodalvalue[0]);
+ }
+
+ // delete _constituent->_nodal
_constituent->_nodal = new MEDSKYLINEARRAY(NumberOfConstituent,
SizeOfConstituentNodal,
- ConstituentNodalIndex,
- ConstituentNodalValue);
-
- delete [] ConstituentNodalIndex;
- delete [] ConstituentNodalValue;
-
- delete [] ReverseDescendingConnectivityValue;
+ &Constituentnodalindex[0],
+ &Constituentnodalvalue[0]);
+
+ int NumberOfConstituentWithPolygons = NumberOfConstituent + NumberOfNewFaces;
+ Reversedescendingconnectivityindex.push_back(Reversedescendingconnectivityindex[Reversedescendingconnectivityindex.size()-1]+2); // we complete the index
+ _reverseDescendingConnectivity = new MEDSKYLINEARRAY(NumberOfConstituentWithPolygons+1,
+ 2*NumberOfConstituentWithPolygons,
+ &Reversedescendingconnectivityindex[0],
+ &Reversedescendingconnectivityvalue[0]);
+ ////
}
END_OF(LOC);
-}
-
-//-----------------------------------------------------------------------------------------//
-// void CONNECTIVITY::calculateReverseDescendingConnectivity(CONNECTIVITY *myConnectivity)
-//-----------------------------------------------------------------------------------------//
-// {
-// if (_entity==MED_CELL)
-// throw MEDEXCEPTION("CONNECTIVITY::calculateReverseDescending
-// Connectivity : we could not do that with MED_CELL entity !");
-// if (myConnectivity->getEntity()!=MED_CELL)
-// throw MEDEXCEPTION("CONNECTIVITY::calculateReverseDescending
-// Connectivity : we need MED_CELL connectivity !");
-// return;
-// }
+ }
/*! Not implemented yet */
//--------------------------------------------------------------------//
END_OF(LOC);
}
+/*!
+ Idem as getElementType method except that it manages polygon and polyhedron.
+*/
+//--------------------------------------------------------------------//
+medGeometryElement CONNECTIVITY::getElementTypeWithPoly(medEntityMesh Entity,int globalNumber) const
+//--------------------------------------------------------------------//
+{
+ int globalNumberMaxOfClassicType;
+ if(_entity==Entity)
+ {
+ globalNumberMaxOfClassicType=_count[_numberOfTypes];
+ if(globalNumber>=1)
+ {
+ if(globalNumber<globalNumberMaxOfClassicType)
+ {
+ for(int i=1; i<=_numberOfTypes;i++)
+ if (globalNumber<_count[i])
+ return _geometricTypes[i-1];
+ throw MEDEXCEPTION("never happens just for compilo");
+ }
+ else
+ {
+ int localNumberInPolyArray=globalNumber-globalNumberMaxOfClassicType;
+ int nbOfPol=getNumberOfElementOfPolyType(_entity);
+ if(localNumberInPolyArray<nbOfPol)
+ return getPolyTypeRelativeTo();
+ else
+ throw MEDEXCEPTION("getElementTypeWithPoly : unexisting element type");
+ }
+ }
+ else
+ throw MEDEXCEPTION("getElementTypeWithPoly : globalNumber < 1");
+ }
+ else
+ {
+ if(_constituent!=NULL)
+ return _constituent->getElementTypeWithPoly(Entity,globalNumber);
+ else
+ throw MEDEXCEPTION("getElementTypeWithPoly : Entity not defined !");
+ }
+}
ostream & MEDMEM::operator<<(ostream &os, CONNECTIVITY &co)
{
os << endl;
}
}
+
+ os << endl << "MED_POLYGON : " << co.getNumberOfPolygons() << " polygons" << endl;
+ if (co.getNumberOfPolygons() > 0)
+ {
+ const int* polygonsconnectivity = co.getPolygonsConnectivity(MED_NODAL,co.getEntity());
+ const int* polygonsconnectivityindex = co.getPolygonsConnectivityIndex(MED_NODAL,co.getEntity());
+
+ for (int i=0; i<co.getNumberOfPolygons(); i++)
+ {
+ int numberofnodesperpolygon = polygonsconnectivityindex[i+1]-polygonsconnectivityindex[i];
+ for (int j=0; j<numberofnodesperpolygon; j++)
+ os << polygonsconnectivity[polygonsconnectivityindex[i]-1+j] << " ";
+ os << endl;
+ }
+ }
+
+ os << endl << "MED_POLYHEDRA : " << co.getNumberOfPolyhedron() << " polyhedron" << endl;
+ if (co.getNumberOfPolyhedron() > 0)
+ {
+ const int* polyhedronconnectivity = co.getPolyhedronConnectivity(MED_NODAL);
+ const int* polyhedronfacesindex = co.getPolyhedronFacesIndex();
+ const int* polyhedronindex = co.getPolyhedronIndex(MED_NODAL);
+
+ for (int i=0; i<co.getNumberOfPolyhedron(); i++)
+ {
+ int numberoffacesperpolyhedra = polyhedronindex[i+1]-polyhedronindex[i];
+ for (int j=0; j<numberoffacesperpolyhedra; j++)
+ {
+ int numberofnodesperface = polyhedronfacesindex[polyhedronindex[i]-1+j+1]-polyhedronfacesindex[polyhedronindex[i]-1+j];
+ for (int k=0; k<numberofnodesperface; k++)
+ os << polyhedronconnectivity[polyhedronfacesindex[polyhedronindex[i]-1+j]-1+k] << " ";
+ if (j != numberoffacesperpolyhedra-1) os << "| ";
+ }
+ os << endl;
+ }
+ }
+
}
else if (co._typeConnectivity == MED_DESCENDING)
{
int numberofelements = co.getNumberOf( co._entity , MED_ALL_ELEMENTS);
- const int *connectivity = co.getConnectivity( co._typeConnectivity, co._entity, MED_ALL_ELEMENTS);
- const int *connectivity_index = co.getConnectivityIndex( co._typeConnectivity, co._entity );
+ if (numberofelements > 0)
+ {
+ const int *connectivity = co.getConnectivity( co._typeConnectivity, co._entity, MED_ALL_ELEMENTS);
+ const int *connectivity_index = co.getConnectivityIndex( co._typeConnectivity, co._entity );
- for ( int j=0; j!=numberofelements; j++ )
- {
- os << "Element " << j+1 << " : ";
- for ( int k=connectivity_index[j]; k!=connectivity_index[j+1]; k++ )
- os << connectivity[k-1] << " ";
- os << endl;
- }
+ for ( int j=0; j!=numberofelements; j++ )
+ {
+ os << "Element " << j+1 << " : ";
+ for ( int k=connectivity_index[j]; k!=connectivity_index[j+1]; k++ )
+ os << connectivity[k-1] << " ";
+ os << endl;
+ }
+ }
+
+ os << endl << "MED_POLYGON : " << co.getNumberOfPolygons() << " polygons" << endl;
+ if (co.getNumberOfPolygons() > 0)
+ {
+ const int* polygonsconnectivity = co.getPolygonsConnectivity(MED_DESCENDING,co.getEntity());
+ const int* polygonsconnectivityindex = co.getPolygonsConnectivityIndex(MED_DESCENDING,co.getEntity());
+
+ for (int i=0; i<co.getNumberOfPolygons(); i++)
+ {
+ int numberofedgesperpolygon = polygonsconnectivityindex[i+1]-polygonsconnectivityindex[i];
+ for (int j=0; j<numberofedgesperpolygon; j++)
+ os << polygonsconnectivity[polygonsconnectivityindex[i]-1+j] << " ";
+ os << endl;
+ }
+ }
+
+ os << endl << "MED_POLYHEDRA : " << co.getNumberOfPolyhedron() << " polyhedron" << endl;
+ if (co.getNumberOfPolyhedron() > 0)
+ {
+ const int* polyhedronconnectivity = co.getPolyhedronConnectivity(MED_DESCENDING);
+ const int* polyhedronindex = co.getPolyhedronIndex(MED_DESCENDING);
+
+ for (int i=0; i<co.getNumberOfPolyhedron(); i++)
+ {
+ int numberoffacesperpolyhedra = polyhedronindex[i+1]-polyhedronindex[i];
+ for (int j=0; j<numberoffacesperpolyhedra; j++)
+ os << polyhedronconnectivity[polyhedronindex[i]-1+j] << " ";
+ os << endl;
+ }
+ }
+
}
if (co._constituent)
return os;
}
+
+/*!
+ method that adds to vector 'nodes' all the nodes of polyhedron with id 'polyhedronId'.
+ WARNING the returned pointer should be deallocated. Returned nodes and polyhedronId are in form [1,...]
+ */
+int *CONNECTIVITY::getNodesOfPolyhedron(int polyhedronId, int& lgthOfTab) const
+{
+ const int *nodes=getPolyhedronConnectivity(MED_EN::MED_NODAL);
+ const int *faces=getPolyhedronFacesIndex();
+ const int *glob=getPolyhedronIndex(MED_EN::MED_NODAL);
+ int offsetWithClassicType=getNumberOf(_entity,MED_ALL_ELEMENTS);
+ set<int> retInSet;
+ int startFace=glob[polyhedronId-offsetWithClassicType-1]-1;
+ int endFace=glob[polyhedronId-offsetWithClassicType]-1;
+ int i;
+ for(i=startFace;i!=endFace;i++)
+ {
+ for(int j=faces[i];j<faces[i+1];j++)
+ retInSet.insert(nodes[j-1]);
+ }
+ lgthOfTab=retInSet.size();
+ int *ret=new int[lgthOfTab];
+ set<int>::iterator iter=retInSet.begin();
+ i=0;
+ for(iter=retInSet.begin();iter!=retInSet.end();iter++)
+ ret[i++]=*iter;
+ return ret;
+}
+
+/*!
+ Idem as MESH::getNodesOfPolyhedron except that returned nodes are sorted by face. 'nbOfNodesPerFaces' is an array of size 'nbOfFaces'.
+ Returned int** has a size of 'nbOfNodesPerFaces' too, and for each element j in int** the size is nbOfNodesPerFaces[j].
+ Warning both returned 'nbOfNodesPerFaces' and returned value should be deallocated. Returned nodes and 'polyhedronId' are in form [1,...]
+ */
+int **CONNECTIVITY::getNodesPerFaceOfPolyhedron(int polyhedronId, int& nbOfFaces, int* & nbOfNodesPerFaces) const
+{
+ int i;
+ const int *nodes=getPolyhedronConnectivity(MED_EN::MED_NODAL);
+ const int *faces=getPolyhedronFacesIndex();
+ const int *glob=getPolyhedronIndex(MED_EN::MED_NODAL);
+ int offsetWithClassicType=getNumberOf(_entity,MED_ALL_ELEMENTS);
+
+ int startFace=glob[polyhedronId-offsetWithClassicType-1]-1;
+ nbOfFaces=glob[polyhedronId-offsetWithClassicType]-startFace-1;
+ nbOfNodesPerFaces=new int[nbOfFaces];
+ int **ret=new int* [nbOfFaces];
+ for(i=0;i<nbOfFaces;i++)
+ {
+ int startNode=faces[startFace+i]-1;
+ nbOfNodesPerFaces[i]=faces[startFace+i+1]-startNode-1;
+ ret[i]=(int *)(nodes)+startNode;
+ }
+ return ret;
+}
+
+int CONNECTIVITY::getNumberOfTypesWithPoly(MED_EN::medEntityMesh Entity) const
+{
+ if (_entity==Entity)
+ return _numberOfTypes+getNumberOfPolyType();
+ else if (_constituent!=NULL)
+ return _constituent->getNumberOfTypesWithPoly(Entity);
+ else
+ return 0;
+}
+
+int CONNECTIVITY::getNumberOfPolyType() const
+{
+ if (_entity==MED_CELL && _entityDimension==3)
+ {
+ if(getNumberOfPolyhedron()>0)
+ return 1;
+ }
+ else if ((_entity==MED_CELL && _entityDimension==2) || (_entity==MED_FACE && _entityDimension==2))
+ if(getNumberOfPolygons()>0)
+ return 1;
+ return 0;
+}
+
+int CONNECTIVITY::getNumberOfElementOfPolyType(MED_EN::medEntityMesh Entity) const
+{
+ if(_entity==Entity)
+ {
+ if (_entity==MED_CELL && _entityDimension==3)
+ return getNumberOfPolyhedron();
+ else if ((_entity==MED_CELL && _entityDimension==2) || (_entity==MED_FACE && _entityDimension==2))
+ return getNumberOfPolygons();
+ return 0;
+ }
+ else
+ {
+ if(_constituent!=NULL)
+ return _constituent->getNumberOfElementOfPolyType(Entity);
+ else
+ throw MEDEXCEPTION("_constituent required to evaluate getNumberOfElementOfPolyType");
+ }
+}
+
+/*
+ Method equivalent to getGeometricTypes except that it includes not only classical Types but polygons/polyhedra also.
+ WARNING the returned array MUST be deallocated.
+ */
+MED_EN::medGeometryElement * CONNECTIVITY::getGeometricTypesWithPoly(MED_EN::medEntityMesh Entity) const throw (MEDEXCEPTION)
+{
+ if(_entity==Entity)
+ {
+ int nbOfTypesTotal=getNumberOfTypesWithPoly(Entity);
+ int nbOfTypesWithoutPoly=getNumberOfTypes(Entity);
+ medGeometryElement *ret=new medGeometryElement[nbOfTypesTotal];
+ memcpy(ret,getGeometricTypes(Entity),nbOfTypesWithoutPoly*sizeof(medGeometryElement));
+ if(nbOfTypesTotal>nbOfTypesWithoutPoly)
+ {
+ if (Entity==MED_CELL && _entityDimension==3)
+ ret[nbOfTypesWithoutPoly]=MED_EN::MED_POLYHEDRA;
+ else if((Entity==MED_CELL && _entityDimension==2) || (Entity==MED_FACE && _entityDimension==2))
+ ret[nbOfTypesWithoutPoly]=MED_EN::MED_POLYGON;
+ }
+ return ret;
+ }
+ else
+ {
+ if(_constituent)
+ return _constituent->getGeometricTypesWithPoly(Entity);
+ throw MEDEXCEPTION("_constituent required to evaluate getGeometricTypesWithPoly");
+ }
+}
+
+/*
+ Method used in CalculateDescendingConnectivity. So it's typically a private method.
+ The aim of this method is to hide to CalculateDescendingConnectivity algorithm the fact that in reverse connectivity polygons and polyhedrons
+ are not in separate data structure, contrary to not reverse connectivities.
+ */
+int CONNECTIVITY::getIndexOfEndClassicElementInReverseNodal(const int *reverseNodalValue, const int *reverseNodalIndex, int rk) const
+{
+ int nbOfLastElt=getNumberOf(_entity,MED_ALL_ELEMENTS);
+ int ret=reverseNodalIndex[rk];
+ for(int i=reverseNodalIndex[rk];i<reverseNodalIndex[rk+1];i++)
+ {
+ if(reverseNodalValue[i-1]<=nbOfLastElt)
+ ret++;
+ }
+ return ret;
+}
+
+/*
+ Method that inverts the face with faceId 'faceId' in the data structure. If it's a polygon face 'faceId' is a value between 1 and nbOfPolygons.
+ This method has to be applied on a instance of MEDMEM::CONNECTIVITY with _entityDimension==3.
+ WARNING calculateDescendingConnectivity must have been called before.
+ */
+void CONNECTIVITY::invertConnectivityForAFace(int faceId, const int *nodalConnForFace, bool polygonFace)
+{
+ // we have always 2 neighbourings
+ int cell1 = _reverseDescendingConnectivity->getIJ(faceId,1);
+ int cell2 = _reverseDescendingConnectivity->getIJ(faceId,2);
+
+ if (cell2 != 0) { // we are not on border, update compulsary. If we aren't on border no update necessary so WARNING because user specified a bad oriented face
+ // Updating _reverseDescendingConnectivity
+ _reverseDescendingConnectivity->setIJ(faceId,1,cell2);
+ _reverseDescendingConnectivity->setIJ(faceId,2,cell1);
+ // Updating _constituent->_nodal because of reversity
+ MEDSKYLINEARRAY *currentNodal=(!polygonFace)?_constituent->_nodal:_constituent->_polygonsNodal;
+ MEDSKYLINEARRAY *currentDescending=(!polygonFace)?_descending:_polygonsDescending;
+ const int *descendingNodalIndex=(!polygonFace)?_constituent->_nodal->getIndex():_constituent->_polygonsNodal->getIndex();
+ const int *newDescendingIndex=(!polygonFace)?_descending->getIndex():_polygonsDescending->getIndex();
+ for(int iarray=1;iarray<=(descendingNodalIndex[faceId]-descendingNodalIndex[faceId-1]);iarray++)
+ currentNodal->setIJ(faceId,iarray,nodalConnForFace[iarray-1]);
+
+ // Updating _descending for cell1 and cell2
+ for(int iface=newDescendingIndex[cell1-1];iface<=newDescendingIndex[cell1];iface++)
+ if (currentDescending->getIndexValue(iface)==faceId)
+ currentDescending->setIndexValue(iface,-faceId);
+ else if (currentDescending->getIndexValue(iface)==-faceId)
+ currentDescending->setIndexValue(iface,faceId);
+
+ for(int iface=newDescendingIndex[cell2-1];iface<newDescendingIndex[cell2];iface++)
+ if (currentDescending->getIndexValue(iface)==faceId)
+ currentDescending->setIndexValue(iface,-faceId);
+ else if (_descending->getIndexValue(iface)==-faceId)
+ currentDescending->setIndexValue(iface,faceId);
+ }
+}
+
+/*
+ Method with 2 output : the connectivity required and its length 'lgth'. This method gives the connectivity independently it is a polygons/polyhedrons or normal
+ element.
+ */
+const int * CONNECTIVITY::getConnectivityOfAnElementWithPoly(MED_EN::medConnectivity ConnectivityType, MED_EN::medEntityMesh Entity, int Number, int &lgth)
+{
+ if(Entity==MED_EN::MED_NODE)
+ throw MEDEXCEPTION("No connectivity attached to a node entity");
+ if(Entity==_entity)
+ {
+ if(_entity==MED_EDGE && _entityDimension==1)
+ {
+ const int * newConstituentValue = 0;
+ const int * newConstituentIndex = 0;
+ newConstituentValue = getConnectivity(ConnectivityType,Entity,MED_ALL_ELEMENTS);
+ newConstituentIndex = getConnectivityIndex(ConnectivityType,Entity);
+ lgth=newConstituentIndex[Number]-newConstituentIndex[Number-1];
+ return newConstituentValue+newConstituentIndex[Number-1]-1;
+ }
+ int nbOfClassicalElements=getNumberOf(_entity,MED_ALL_ELEMENTS);
+ if((_entity==MED_FACE && _entityDimension==2) || (_entity==MED_CELL && _entityDimension==2))
+ {
+ const int * newConstituentValue = 0;
+ const int * newConstituentIndex = 0;
+ if(Number<=nbOfClassicalElements)
+ {
+ newConstituentValue = getConnectivity(ConnectivityType,Entity,MED_ALL_ELEMENTS);
+ newConstituentIndex = getConnectivityIndex(ConnectivityType,Entity);
+ lgth=newConstituentIndex[Number]-newConstituentIndex[Number-1];
+ return newConstituentValue+newConstituentIndex[Number-1]-1;
+ }
+ else
+ {
+ int localNumber=Number-nbOfClassicalElements-1;
+ if(localNumber<getNumberOfPolygons())
+ {
+ newConstituentValue = getPolygonsConnectivity(ConnectivityType,Entity);
+ newConstituentIndex = getPolygonsConnectivityIndex(ConnectivityType,Entity);
+ lgth=newConstituentIndex[localNumber+1]-newConstituentIndex[localNumber];
+ return newConstituentValue+newConstituentIndex[localNumber]-1;
+ }
+ else
+ throw MEDEXCEPTION("Unknown number");
+ }
+ }
+ else if(_entity==MED_CELL && _entityDimension==3)
+ {
+ const int * newConstituentValue = 0;
+ const int * newConstituentIndex = 0;
+ if(Number<=nbOfClassicalElements)
+ {
+ newConstituentValue = getConnectivity(ConnectivityType,Entity,MED_ALL_ELEMENTS);
+ newConstituentIndex = getConnectivityIndex(ConnectivityType,Entity);
+ lgth=newConstituentIndex[Number]-newConstituentIndex[Number-1];
+ return newConstituentValue+newConstituentIndex[Number-1]-1;
+ }
+ else
+ {
+ int localNumber=Number-nbOfClassicalElements-1;
+ if(localNumber<getNumberOfPolyhedron())
+ {
+ if(ConnectivityType==MED_NODAL)
+ throw MEDEXCEPTION("NODAL Connectivity required for a polyhedron");
+ newConstituentValue = _polyhedronDescending->getValue();
+ newConstituentIndex = _polyhedronDescending->getIndex();
+ lgth=newConstituentIndex[localNumber+1]-newConstituentIndex[localNumber];
+ return newConstituentValue+newConstituentIndex[localNumber]-1;
+ }
+ else
+ throw MEDEXCEPTION("Unknown number");
+ }
+ }
+ else
+ throw MEDEXCEPTION("No connectivity available");
+ }
+ else
+ {
+ if(_constituent==NULL)
+ calculateDescendingConnectivity();
+ return _constituent->getConnectivityOfAnElementWithPoly(ConnectivityType,Entity,Number,lgth);
+ }
+}
+
+int CONNECTIVITY::getNumberOfElementsWithPoly(MED_EN::medEntityMesh Entity, MED_EN::medGeometryElement Type) const
+{
+ if(Entity==MED_EN::MED_NODE)
+ return _numberOfNodes;
+ if(Entity==_entity)
+ {
+ if(Type==MED_POLYGON || Type==MED_POLYHEDRA)
+ return getNumberOfElementOfPolyType(_entity);
+ else
+ return getNumberOf(_entity,Type);
+ }
+ else
+ {
+ if(_constituent)
+ return _constituent->getNumberOfElementsWithPoly(Entity,Type);
+ else
+ throw MEDEXCEPTION("CONNECTIVITY::getNumberOfElementsWithPoly : _constituent needed");
+ }
+}
+
+/*!
+ Perform a deep comparison of the 2 connectivities in NODAL mode and on all elements.
+*/
+bool CONNECTIVITY::deepCompare(const CONNECTIVITY& other) const
+{
+ CONNECTIVITY* temp=(CONNECTIVITY* )this;
+ const int *conn1=temp->getConnectivity(MED_NODAL,_entity,MED_ALL_ELEMENTS);
+ int size1=temp->getConnectivityLength(MED_NODAL,_entity,MED_ALL_ELEMENTS);
+ temp=(CONNECTIVITY* )(&other);
+ const int *conn2=temp->getConnectivity(MED_NODAL,_entity,MED_ALL_ELEMENTS);
+ int size2=temp->getConnectivityLength(MED_NODAL,_entity,MED_ALL_ELEMENTS);
+ if(size1!=size2)
+ return false;
+ bool ret=true;
+ for(int i=0;i<size1 && ret;i++)
+ {
+ ret=(conn1[i]==conn2[i]);
+ }
+ return ret;
+}
#include "utilities.h"
#include "MEDMEM_Exception.hxx"
#include "MEDMEM_define.hxx"
+#include "MEDMEM_PolyhedronArray.hxx"
namespace MEDMEM {
class MEDSKYLINEARRAY;
/*! pointer to an array which stores the nodal connectivity */
MEDSKYLINEARRAY* _nodal;
+ /*! pointer to an array which stores the nodal connectivity only for polygons */
+ MEDSKYLINEARRAY* _polygonsNodal;
+ /*! pointer to an array which stores the nodal connectivity only for polyhedron */
+ POLYHEDRONARRAY* _polyhedronNodal;
/*! pointer to an array which stores
the descending connectivity */
MEDSKYLINEARRAY* _descending;
+ /*! pointer to an array which stores the descending connectivity only for polygons */
+ MEDSKYLINEARRAY* _polygonsDescending;
+ /*! pointer to an array which stores the descending connectivity only for polyhedron */
+ MEDSKYLINEARRAY* _polyhedronDescending;
/*! pointer to an array which stores
the reverse nodal connectivity */
MEDSKYLINEARRAY* _reverseNodalConnectivity;
evaluates _neighbourhood from _descending */
void calculateNeighbourhood(CONNECTIVITY &myConnectivity);
+ int getIndexOfEndClassicElementInReverseNodal(const int *reverseNodalValue, const int *reverseNodalIndex, int rk) const;
+
public:
- friend class MED_MESH_RDONLY_DRIVER;
- friend class MED_MESH_WRONLY_DRIVER;
+ friend class IMED_MESH_RDONLY_DRIVER;
+ friend class MED_MESH_RDONLY_DRIVER21;
+ friend class IMED_MESH_WRONLY_DRIVER;
+ friend class MED_MESH_WRONLY_DRIVER21;
+ friend class MED_MESH_RDONLY_DRIVER22;
+ friend class MED_MESH_WRONLY_DRIVER22;
+
+
friend ostream & operator<<(ostream &os, CONNECTIVITY &connectivity);
// in order to fill CONNECTIVITY of MESH
inline void setEntityDimension(int EntityDimension);
+ void setPolygonsConnectivity(MED_EN::medConnectivity ConnectivityType,
+ MED_EN::medEntityMesh Entity,
+ const int* PolygonsConnectivity,
+ const int* PolygonsConnectivityIndex,
+ int ConnectivitySize, int NumberOfPolygons);
+
+ void setPolyhedronConnectivity(MED_EN::medConnectivity ConnectivityType,
+ const int* PolyhedronConnectivity,
+ const int* PolyhedronIndex, int ConnectivitySize,
+ int NumberOfPolyhedron,
+ const int* PolyhedronFacesIndex= (int*) NULL,
+ int NumberOfFaces=0);
+
inline bool existConnectivity (MED_EN::medConnectivity connectivityType, MED_EN::medEntityMesh Entity) const;
+
+ inline bool existPolygonsConnectivity(MED_EN::medConnectivity connectivityType,
+ MED_EN::medEntityMesh Entity) const;
+
+ inline bool existPolyhedronConnectivity(MED_EN::medConnectivity connectivityType,
+ MED_EN::medEntityMesh Entity) const;
virtual void calculateConnectivity (MED_EN::medConnectivity connectivityType, MED_EN::medEntityMesh Entity);
- virtual void updateFamily (vector<FAMILY*> myFamilies);
- virtual void updateGroup (vector<GROUP*> myFamilies);
+ virtual void updateFamily (const vector<FAMILY*>& myFamilies);
inline MED_EN::medEntityMesh getEntity () const;
inline int getNumberOfTypes (MED_EN::medEntityMesh Entity) const;
+ int getNumberOfTypesWithPoly(MED_EN::medEntityMesh Entity) const;
+ const int * getConnectivityOfAnElementWithPoly(MED_EN::medConnectivity ConnectivityType,
+ MED_EN::medEntityMesh Entity,
+ int Number, int &lgth);
+ int getNumberOfPolyType() const;
+ int getNumberOfElementsWithPoly(MED_EN::medEntityMesh Entity, MED_EN::medGeometryElement Type) const;
+ int getNumberOfElementOfPolyType(MED_EN::medEntityMesh Entity) const;
inline const MED_EN::medGeometryElement * getGeometricTypes (MED_EN::medEntityMesh Entity) const
throw (MEDEXCEPTION);
+ MED_EN::medGeometryElement * getGeometricTypesWithPoly (MED_EN::medEntityMesh Entity) const
+ throw (MEDEXCEPTION);
MED_EN::medGeometryElement getElementType (MED_EN::medEntityMesh Entity,
int Number) const;
+ MED_EN::medGeometryElement getElementTypeWithPoly (MED_EN::medEntityMesh Entity,
+ int Number) const;
+ inline MED_EN::medGeometryElement getPolyTypeRelativeTo() const;
virtual inline const int * getGlobalNumberingIndex (MED_EN::medEntityMesh Entity) const
throw (MEDEXCEPTION);
virtual const int * getConnectivity (MED_EN::medConnectivity ConnectivityType,
MED_EN::medEntityMesh Entity,
MED_EN::medGeometryElement Type);
+ virtual int getConnectivityLength (MED_EN::medConnectivity ConnectivityType,
+ MED_EN::medEntityMesh Entity,
+ MED_EN::medGeometryElement Type);
virtual const int * getConnectivityIndex (MED_EN::medConnectivity ConnectivityType,
MED_EN::medEntityMesh Entity);
-
+
+ const int* getPolygonsConnectivity(MED_EN::medConnectivity ConnectivityType,
+ MED_EN::medEntityMesh Entity);
+ const int* getPolygonsConnectivityIndex(MED_EN::medConnectivity ConnectivityType,
+ MED_EN::medEntityMesh Entity);
+ int getNumberOfPolygons() const;
+ const int* getPolyhedronConnectivity(MED_EN::medConnectivity ConnectivityType) const;
+ const int* getPolyhedronFacesIndex() const;
+ const int* getPolyhedronIndex(MED_EN::medConnectivity ConnectivityType) const;
+ int getNumberOfPolyhedronFaces() const;
+ int getNumberOfPolyhedron() const;
+ int *getNodesOfPolyhedron(int polyhedronId, int& lgthOfTab) const;
+ int **getNodesPerFaceOfPolyhedron(int polyhedronId, int& nbOfFaces, int* & nbOfNodesPerFaces) const;
const CELLMODEL & getType (MED_EN::medGeometryElement Type) const;
const CELLMODEL * getCellsTypes (MED_EN::medEntityMesh Entity) const
throw (MEDEXCEPTION);
throw (MEDEXCEPTION);
const int* getNeighbourhood() const;
-
+ void invertConnectivityForAFace(int faceId, const int *nodalConnForFace, bool polygonFace=false);
+ bool deepCompare(const CONNECTIVITY& other) const;
};
/*----------------------*/
/* Methodes Inline */
return _numberOfTypes;
else if (_constituent!=NULL)
return _constituent->getNumberOfTypes(Entity);
-// else if (_constituent == NULL)
-// {
-// MESSAGE("CONNECTIVITY::getNumberOfTypes : _constituent == NULL");
-// try
-// {
-// (const_cast <CONNECTIVITY *> (this))->calculateDescendingConnectivity();
-// }
-// catch (MEDEXCEPTION & ex)
-// {
-// return 0 ;
-// }
-
-// SCRUTE(_entityDimension);
-
-// if (_entityDimension != 2 && _entityDimension != 3) return 0;
-
-// try
-// {
-// _constituent->calculateConnectivity(MED_NODAL,Entity);
-// }
-// catch (MEDEXCEPTION & ex)
-// {
-// return 0 ;
-// }
-
-// return _constituent->getNumberOfTypes(Entity);
-// }
+ else if (_constituent == NULL)
+ {
+ MESSAGE("CONNECTIVITY::getNumberOfTypes : _constituent == NULL");
+ try
+ {
+ (const_cast <CONNECTIVITY *> (this))->calculateDescendingConnectivity();
+ }
+ catch (MEDEXCEPTION & ex)
+ {
+ return 0 ;
+ }
+
+ SCRUTE(_entityDimension);
+
+ if (_entityDimension != 2 && _entityDimension != 3) return 0;
+
+ try
+ {
+ _constituent->calculateConnectivity(MED_EN::MED_NODAL,Entity);
+ }
+ catch (MEDEXCEPTION & ex)
+ {
+ return 0 ;
+ }
+
+ return _constituent->getNumberOfTypes(Entity);
+ }
else
- return 0; // because it is the right information (no exception needed)!
+ return 0; // because it is the right information (no exception needed)!
}
/*! Returns an array of all %medGeometryElement types existing in the mesh
//-----------------------------------------------------------------------------//
{
if (_entity==Entity) {
- MESSAGE("existConnectivity : _entity==Entity="<<Entity);
if ((ConnectivityType==MED_EN::MED_NODAL)&(_nodal!=(MEDSKYLINEARRAY*)NULL))
return true;
if ((ConnectivityType==MED_EN::MED_DESCENDING)&(_descending!=(MEDSKYLINEARRAY*)NULL))
return false;
}
+/*! Returns true if a polygons connectivity exists on elements of type "Entity" */
+//-----------------------------------------------------------------------------//
+inline bool CONNECTIVITY::existPolygonsConnectivity(MED_EN::medConnectivity ConnectivityType,
+ MED_EN::medEntityMesh Entity) const
+//-----------------------------------------------------------------------------//
+{
+ if (_entity == Entity)
+ {
+ MESSAGE("existPolygonsConnectivity : _entity == Entity = "<<Entity);
+ if (ConnectivityType == MED_EN::MED_NODAL && _polygonsNodal != (MEDSKYLINEARRAY*) NULL)
+ return true;
+ if (ConnectivityType == MED_EN::MED_DESCENDING && _polygonsDescending != (MEDSKYLINEARRAY*) NULL)
+ return true;
+ }
+ else if (_constituent != (CONNECTIVITY*) NULL)
+ return _constituent->existPolygonsConnectivity(ConnectivityType,Entity);
+ return false;
+}
+
+/*! Returns true if a polyhedron connectivity exists on elements of type "Entity" */
+//-----------------------------------------------------------------------------//
+inline bool CONNECTIVITY::existPolyhedronConnectivity(MED_EN::medConnectivity ConnectivityType,
+ MED_EN::medEntityMesh Entity) const
+//-----------------------------------------------------------------------------//
+{
+ if (_entity == Entity)
+ {
+ MESSAGE("existPolyhedronConnectivity : _entity == Entity = "<<Entity);
+ if (ConnectivityType == MED_EN::MED_NODAL && _polyhedronNodal != (POLYHEDRONARRAY*) NULL)
+ return true;
+ if (ConnectivityType == MED_EN::MED_DESCENDING && _polyhedronDescending != (MEDSKYLINEARRAY*) NULL)
+ return true;
+ }
+ else if (_constituent != (CONNECTIVITY*) NULL)
+ return _constituent->existPolyhedronConnectivity(ConnectivityType,Entity);
+ return false;
+}
+
/*!
Returns an array containing CELLMODEL foreach element type present
in connectivity for given medEntityMesh (similar as getGeometricTypes).\n
return _entityDimension;
}
+MED_EN::medGeometryElement CONNECTIVITY::getPolyTypeRelativeTo() const
+{
+ if(_entity==MED_EN::MED_CELL && _entityDimension==3)
+ return MED_EN::MED_POLYHEDRA;
+ else if((_entity==MED_EN::MED_CELL && _entityDimension==2) || (_entity==MED_EN::MED_FACE && _entityDimension==2))
+ return MED_EN::MED_POLYGON;
+ else
+ throw MEDEXCEPTION("getPolyTypeRelativeTo : ");
+}
+
}//End namespace MEDMEM
#endif /* CONNECTIVITY_HXX */
public :
- friend class MED_MESH_RDONLY_DRIVER;
- friend class MED_MESH_WRONLY_DRIVER;
+ friend class IMED_MESH_RDONLY_DRIVER;
+ friend class MED_MESH_RDONLY_DRIVER21;
+ friend class IMED_MESH_WRONLY_DRIVER;
+ friend class MED_MESH_WRONLY_DRIVER21;
+ friend class MED_MESH_RDONLY_DRIVER22;
+ friend class MED_MESH_WRONLY_DRIVER22;
COORDINATE();
#include "MEDMEM_DriverFactory.hxx"
-
-#include "MEDMEM_Mesh.hxx"
+#include "MEDMEM_MedMedDriver.hxx"
#include "MEDMEM_MedMeshDriver.hxx"
+#include "MEDMEM_Mesh.hxx"
#include "MEDMEM_GibiMeshDriver.hxx"
#include "MEDMEM_PorflowMeshDriver.hxx"
#include "MEDMEM_VtkMeshDriver.hxx"
-
-#include "MEDMEM_Med.hxx"
-#include "MEDMEM_MedMedDriver.hxx"
#include "MEDMEM_VtkMedDriver.hxx"
-//#include "MEDMEM_Field.hxx"
-
#include "MEDMEM_Exception.hxx"
-//#include "MEDMEM_STRING.hxx"
-//#include "utilities.h"
+
+#include "MEDMEM_MedVersion.hxx"
+#include "MEDMEM_Compatibility21_22.hxx"
+#include "MEDMEM_MedMedDriver21.hxx"
+#include "MEDMEM_MedMedDriver22.hxx"
+#include "MEDMEM_MedMeshDriver21.hxx"
+#include "MEDMEM_MedMeshDriver22.hxx"
using namespace MEDMEM;
using namespace MED_EN;
+template<>
+void fill<-1,0x3>(double *a, const double *b)
+{
+}
+
+template<>
+bool compare<-1>(const double *a, const double *b)
+{
+ return false;
+}
+
+MED_EN::medFileVersion DRIVERFACTORY::globalMedFileVersionForWriting = MED_EN::V22;
+
+medFileVersion DRIVERFACTORY::getMedFileVersionForWriting()
+{
+ return DRIVERFACTORY::globalMedFileVersionForWriting;
+}
+
+void DRIVERFACTORY::setMedFileVersionForWriting(medFileVersion version)
+{
+ DRIVERFACTORY::globalMedFileVersionForWriting = version;
+}
+
GENDRIVER *DRIVERFACTORY::buildDriverForMesh(driverTypes driverType,
const std::string & fileName,
MESH *mesh,
switch(access)
{
case MED_LECT : {
- MED_MESH_RDONLY_DRIVER *retmed=new MED_MESH_RDONLY_DRIVER(fileName,
- mesh);
- retmed->setMeshName(driverName);
- return retmed;
+ ret = new MED_MESH_RDONLY_DRIVER(fileName, mesh);
+ ret->setMeshName(driverName);
+ return ret;
}
case MED_ECRI : {
- MED_MESH_WRONLY_DRIVER *retmed=new MED_MESH_WRONLY_DRIVER(fileName,
- mesh);
- retmed->setMeshName(driverName);
- return retmed;
+ ret = new MED_MESH_WRONLY_DRIVER(fileName, mesh);
+ ret->setMeshName(driverName);
+ return ret;
}
case MED_REMP : {
- MED_MESH_RDWR_DRIVER *retmed=new MED_MESH_RDWR_DRIVER(fileName,mesh);
- retmed->setMeshName(driverName);
- return retmed;
+ ret = new MED_MESH_RDWR_DRIVER(fileName, mesh);
+ ret->setMeshName(driverName);
+ return ret;
}
default:
throw MED_EXCEPTION ("access type has not been properly specified to the method");
return ret;
}
+GENDRIVER * DRIVERFACTORY::buildMedDriverFromFile(const string & fileName,
+ MED * const ptrMed,
+ MED_EN::med_mode_acces access)
+{
+ medFileVersion version;
+
+ try
+ {
+ version = getMedFileVersion(fileName);
+ }
+ catch (MEDEXCEPTION & ex)
+ {
+ version = DRIVERFACTORY::globalMedFileVersionForWriting;
+ }
+
+ MESSAGE("buildMedDriverFromFile version of the file " << version);
+
+ GENDRIVER * driver;
+
+ switch(access)
+ {
+ case MED_LECT : {
+ if (version == V21)
+ driver = new MED_MED_RDONLY_DRIVER21(fileName,ptrMed);
+ else if (version == V22)
+ driver = new MED_MED_RDONLY_DRIVER22(fileName,ptrMed);
+ return driver;
+ }
+ case MED_ECRI : {
+ if (version == V21)
+ driver = new MED_MED_WRONLY_DRIVER21(fileName,ptrMed);
+ else if (version == V22)
+ driver = new MED_MED_WRONLY_DRIVER22(fileName,ptrMed);
+ return driver;
+ }
+ case MED_REMP : {
+ if (version == V21)
+ driver = new MED_MED_RDWR_DRIVER21(fileName,ptrMed);
+ else if (version == V22)
+ driver = new MED_MED_RDWR_DRIVER22(fileName,ptrMed);
+ return driver;
+ }
+ default:
+ throw MED_EXCEPTION ("access type has not been properly specified to the method");
+ }
+}
+
+GENDRIVER * DRIVERFACTORY::buildMeshDriverFromFile(const string & fileName,
+ MESH * ptrMesh,
+ MED_EN::med_mode_acces access)
+{
+ medFileVersion version;
+
+ try
+ {
+ version = getMedFileVersion(fileName);
+ }
+ catch (MEDEXCEPTION & ex)
+ {
+ version = DRIVERFACTORY::globalMedFileVersionForWriting;
+ }
+
+ MESSAGE("buildMeshDriverFromFile version of the file " << version);
+
+ GENDRIVER * driver;
+
+ switch(access)
+ {
+ case MED_LECT : {
+ if (version == V21)
+ driver = new MED_MESH_RDONLY_DRIVER21(fileName,ptrMesh);
+ else if (version == V22)
+ driver = new MED_MESH_RDONLY_DRIVER22(fileName,ptrMesh);
+ return driver;
+ }
+ case MED_ECRI : {
+ if (version == V21)
+ driver = new MED_MESH_WRONLY_DRIVER21(fileName,ptrMesh);
+ else if (version == V22)
+ driver = new MED_MESH_WRONLY_DRIVER22(fileName,ptrMesh);
+ return driver;
+ }
+ case MED_REMP : {
+ if (version == V21)
+ driver = new MED_MESH_RDWR_DRIVER21(fileName,ptrMesh);
+ else if (version == V22)
+ driver = new MED_MESH_RDWR_DRIVER22(fileName,ptrMesh);
+ return driver;
+ }
+ default:
+ throw MED_EXCEPTION ("access type has not been properly specified to the method");
+ }
+}
+
+GENDRIVER * DRIVERFACTORY::buildConcreteMedDriverForMesh(const std::string & fileName,
+ MESH *ptrMesh,const string & driverName,
+ MED_EN::med_mode_acces access,
+ MED_EN::medFileVersion version)
+{
+ GENDRIVER * driver;
+
+ MESSAGE("buildConcreteMedDriverForMesh version of the file " << version);
+
+ switch(access)
+ {
+ case MED_LECT : {
+ if (version == V21)
+ driver = new MED_MESH_RDONLY_DRIVER21(fileName,ptrMesh);
+ else if (version == V22)
+ driver = new MED_MESH_RDONLY_DRIVER22(fileName,ptrMesh);
+ driver->setMeshName(driverName);
+ return driver;
+ }
+ case MED_ECRI : {
+ if (version == V21)
+ driver = new MED_MESH_WRONLY_DRIVER21(fileName,ptrMesh);
+ else if (version == V22)
+ driver = new MED_MESH_WRONLY_DRIVER22(fileName,ptrMesh);
+ driver->setMeshName(driverName);
+ return driver;
+ }
+ case MED_REMP : {
+ if (version == V21)
+ driver = new MED_MESH_RDWR_DRIVER21(fileName,ptrMesh);
+ else if (version == V22)
+ driver = new MED_MESH_RDWR_DRIVER22(fileName,ptrMesh);
+ driver->setMeshName(driverName);
+ return driver;
+ }
+ default:
+ throw MED_EXCEPTION ("access type has not been properly specified to the method");
+ }
+}
#ifndef DRIVERFACTORY_HXX
#define DRIVERFACTORY_HXX
+#include "MEDMEM_MedVersion.hxx"
#include "MEDMEM_GenDriver.hxx"
-#include "MEDMEM_VtkFieldDriver.hxx"
-#include "MEDMEM_MedFieldDriver.hxx"
+#include "MEDMEM_define.hxx"
+
#include <string>
namespace MEDMEM {
class MESH;
template<class T> class FIELD;
class MED;
+ class GENDRIVER;
namespace DRIVERFACTORY {
- GENDRIVER *buildDriverForMesh(driverTypes driverType,
+
+ /*
+ definition of static variable across the Med Memory of a Med File version
+ for the writing of Med File set to V22
+ */
+
+ extern MED_EN::medFileVersion globalMedFileVersionForWriting;
+
+ MED_EN::medFileVersion getMedFileVersionForWriting();
+
+ void setMedFileVersionForWriting(MED_EN::medFileVersion version);
+
+ GENDRIVER * buildDriverForMesh(driverTypes driverType,
+ const std::string & fileName,
+ MESH *mesh,const string & driverName,
+ MED_EN::med_mode_acces access);
+ template<class T>
+ GENDRIVER * buildDriverForField(driverTypes driverType,
+ const std::string & fileName,
+ FIELD<T> *fielde,
+ MED_EN::med_mode_acces access);
+ GENDRIVER * buildDriverForMed(driverTypes driverType,
const std::string & fileName,
- MESH *mesh,const string & driverName,
+ MED *mede,
MED_EN::med_mode_acces access);
+ GENDRIVER * buildMedDriverFromFile(const string & fileName,
+ MED * const ptrMed,
+ MED_EN::med_mode_acces access);
+ GENDRIVER * buildMeshDriverFromFile(const string & fileName,
+ MESH * ptrMesh,
+ MED_EN::med_mode_acces access);
template<class T>
- GENDRIVER *buildDriverForField(driverTypes driverType,
- const std::string & fileName,
- FIELD<T> *fielde,
- MED_EN::med_mode_acces access);
- GENDRIVER *buildDriverForMed(driverTypes driverType,
- const std::string & fileName,
- MED *mede,
- MED_EN::med_mode_acces access);
+ GENDRIVER * buildFieldDriverFromFile(const string & fileName,
+ FIELD<T> * ptrField,
+ MED_EN::med_mode_acces access);
+ GENDRIVER * buildConcreteMedDriverForMesh(const std::string & fileName,
+ MESH *mesh,
+ const string & driverName,
+ MED_EN::med_mode_acces access,
+ MED_EN::medFileVersion version);
+ template<class T>
+ GENDRIVER * buildConcreteMedDriverForField(const std::string & fileName,
+ FIELD<T> *fielde,
+ MED_EN::med_mode_acces access,
+ MED_EN::medFileVersion version);
}
-
-template<class T>
-GENDRIVER *DRIVERFACTORY::buildDriverForField(driverTypes driverType,
- const std::string & fileName,
- FIELD<T> *field,
- MED_EN::med_mode_acces access)
-{
- GENDRIVER *ret;
- switch(driverType)
- {
- case MED_DRIVER : {
- switch(access)
- {
- case MED_EN::MED_LECT : {
- ret=new MED_FIELD_RDONLY_DRIVER<T>(fileName,field);
- break;
- }
- case MED_EN::MED_ECRI : {
- ret=new MED_FIELD_WRONLY_DRIVER<T>(fileName,field);
- break;
- }
- case MED_EN::MED_REMP : {
- ret=new MED_FIELD_RDWR_DRIVER<T>(fileName,field);
- break;
- }
- default:
- throw MED_EXCEPTION ("access type has not been properly specified to the method");
- }
- break;
- }
-
- case VTK_DRIVER : {
- switch(access)
- {
- case MED_EN::MED_LECT : {
- throw MED_EXCEPTION ("access mode other than MED_ECRI and MED_REMP has been specified with the VTK_DRIVER type which is not allowed because VTK_DRIVER is only a write access driver");
- break;
- }
- case MED_EN::MED_ECRI : {
- ret=new VTK_FIELD_DRIVER<T>(fileName,field);
- break;
- }
- case MED_EN::MED_REMP : {
- ret=new VTK_FIELD_DRIVER<T>(fileName,field);
- break ;
- }
- default:
- throw MED_EXCEPTION ("access type has not been properly specified to the method");
- }
- break;
- }
-
- case GIBI_DRIVER : {
- throw MED_EXCEPTION ("driverType other than MED_DRIVER and VTK_DRIVER has been specified to the method which is not allowed for the object FIELD");
- break;
- }
-
- case PORFLOW_DRIVER : {
- throw MED_EXCEPTION ("driverType other than MED_DRIVER and VTK_DRIVER has been specified to the method which is not allowed for the object FIELD");
- break;
- }
-
- case NO_DRIVER : {
- throw MED_EXCEPTION ("driverType other than MED_DRIVER and VTK_DRIVER has been specified to the method which is not allowed for the object FIELD");
- break;
- }
- default:
- MED_EXCEPTION ("driverType other than MED_DRIVER and VTK_DRIVER has been specified to the method which is not allowed for the object FIELD");
- }
- return ret;
}
+#include "MEDMEM_VtkFieldDriver.hxx"
+#include "MEDMEM_MedFieldDriver.hxx"
+#include "MEDMEM_MedFieldDriver21.hxx"
+#include "MEDMEM_MedFieldDriver22.hxx"
+#include "MEDMEM_AsciiFieldDriver.hxx"
+
+namespace MEDMEM {
+ template<class T>
+ GENDRIVER * DRIVERFACTORY::buildDriverForField(driverTypes driverType,
+ const std::string & fileName,
+ FIELD<T> *field,
+ MED_EN::med_mode_acces access)
+ {
+ GENDRIVER *ret;
+ switch(driverType)
+ {
+ case MED_DRIVER : {
+ switch(access)
+ {
+ case MED_EN::MED_LECT : {
+ ret = new MED_FIELD_RDONLY_DRIVER<T>(fileName,field);
+ break;
+ }
+ case MED_EN::MED_ECRI : {
+ ret= new MED_FIELD_WRONLY_DRIVER<T>(fileName,field);
+ break;
+ }
+ case MED_EN::MED_REMP : {
+ ret = new MED_FIELD_RDWR_DRIVER<T>(fileName,field);
+ break;
+ }
+ default:
+ throw MED_EXCEPTION ("access type has not been properly specified to the method");
+ }
+ break;
+ }
+
+ case VTK_DRIVER : {
+ switch(access)
+ {
+ case MED_EN::MED_LECT : {
+ throw MED_EXCEPTION ("access mode other than MED_ECRI and MED_REMP has been specified with the VTK_DRIVER type which is not allowed because VTK_DRIVER is only a write access driver");
+ break;
+ }
+ case MED_EN::MED_ECRI : {
+ ret=new VTK_FIELD_DRIVER<T>(fileName,field);
+ break;
+ }
+ case MED_EN::MED_REMP : {
+ ret=new VTK_FIELD_DRIVER<T>(fileName,field);
+ break ;
+ }
+ default:
+ throw MED_EXCEPTION ("access type has not been properly specified to the method");
+ }
+ break;
+ }
+
+ case GIBI_DRIVER : {
+ throw MED_EXCEPTION ("driverType other than MED_DRIVER and VTK_DRIVER has been specified to the method which is not allowed for the object FIELD");
+ break;
+ }
+
+ case PORFLOW_DRIVER : {
+ throw MED_EXCEPTION ("driverType other than MED_DRIVER and VTK_DRIVER has been specified to the method which is not allowed for the object FIELD");
+ break;
+ }
+
+ case ASCII_DRIVER : {
+ switch(access)
+ {
+ case MED_EN::MED_ECRI : {
+ ret=new ASCII_FIELD_DRIVER<T>(fileName,field);
+ break;
+ }
+ default:
+ throw MED_EXCEPTION ("driver ASCII_DRIVER on FIELD only in write mod");
+ }
+ break;
+ }
+
+ case NO_DRIVER : {
+ throw MED_EXCEPTION ("driverType other than MED_DRIVER and VTK_DRIVER has been specified to the method which is not allowed for the object FIELD");
+ break;
+ }
+ default:
+ MED_EXCEPTION ("driverType other than MED_DRIVER and VTK_DRIVER has been specified to the method which is not allowed for the object FIELD");
+ }
+ return ret;
+ }
+
+ template<class T>
+ GENDRIVER * DRIVERFACTORY::buildFieldDriverFromFile(const string & fileName,
+ FIELD<T> * ptrField,
+ MED_EN::med_mode_acces access)
+ {
+ MED_EN::medFileVersion version;
+
+ try
+ {
+ version = getMedFileVersion(fileName);
+ }
+ catch (MEDEXCEPTION & ex)
+ {
+ version = DRIVERFACTORY::globalMedFileVersionForWriting;
+ }
+
+ MESSAGE("buildFieldDriverFromFile version of the file " << version);
+
+ GENDRIVER * driver;
+
+ switch(access)
+ {
+ case MED_EN::MED_LECT : {
+ if (version == MED_EN::V21)
+ driver = new MED_FIELD_RDONLY_DRIVER21<T>(fileName,ptrField);
+ else if (version == MED_EN::V22)
+ driver = new MED_FIELD_RDONLY_DRIVER22<T>(fileName,ptrField);
+ return driver;
+ }
+ case MED_EN::MED_ECRI : {
+ if (version == MED_EN::V21)
+ driver = new MED_FIELD_WRONLY_DRIVER21<T>(fileName,ptrField);
+ else if (version == MED_EN::V22)
+ driver = new MED_FIELD_WRONLY_DRIVER22<T>(fileName,ptrField);
+ return driver;
+ }
+ case MED_EN::MED_REMP : {
+ if (version == MED_EN::V21)
+ driver = new MED_FIELD_RDWR_DRIVER21<T>(fileName,ptrField);
+ else if (version == MED_EN::V22)
+ driver = new MED_FIELD_RDWR_DRIVER22<T>(fileName,ptrField);
+ return driver;
+ }
+ default:
+ throw MED_EXCEPTION ("access type has not been properly specified to the method");
+ }
+ }
+
+ template<class T>
+ GENDRIVER * DRIVERFACTORY::buildConcreteMedDriverForField(const std::string & fileName,
+ FIELD<T> *ptrField,
+ MED_EN::med_mode_acces access,
+ MED_EN::medFileVersion version)
+ {
+
+ MESSAGE("buildConcreteMedDriverForField version of the file " << version);
+
+ GENDRIVER * driver;
+
+ switch(access)
+ {
+ case MED_EN::MED_LECT : {
+ if (version == MED_EN::V21)
+ driver = new MED_FIELD_RDONLY_DRIVER21<T>(fileName,ptrField);
+ else if (version == MED_EN::V22)
+ driver = new MED_FIELD_RDONLY_DRIVER22<T>(fileName,ptrField);
+ return driver;
+ }
+ case MED_EN::MED_ECRI : {
+ if (version == MED_EN::V21)
+ driver = new MED_FIELD_WRONLY_DRIVER21<T>(fileName,ptrField);
+ else if (version == MED_EN::V22)
+ driver = new MED_FIELD_WRONLY_DRIVER22<T>(fileName,ptrField);
+ return driver;
+ }
+ case MED_EN::MED_REMP : {
+ if (version == MED_EN::V21)
+ driver = new MED_FIELD_RDWR_DRIVER21<T>(fileName,ptrField);
+ else if (version == MED_EN::V22)
+ driver = new MED_FIELD_RDWR_DRIVER22<T>(fileName,ptrField);
+ return driver;
+ }
+ default:
+ throw MED_EXCEPTION ("access type has not been properly specified to the method");
+ }
+ }
}
#endif
using namespace MEDMEM;
using namespace MED_EN;
+#define DUMP_LINES_LIMIT 100
+
// Cet opérateur permet d'ordonner les mailles dans un set suivant l'ordre requis par MED
bool _maille::operator < (const _maille& ma) const
{
else
return geometricType<ma.geometricType;
};
-
+_link _maille::link(int i) const
+{
+ ASSERT ( i >= 0 && i < sommets.size() );
+ int i2 = ( i + 1 == sommets.size() ) ? 0 : i + 1;
+ if ( reverse )
+ return make_pair( sommets[i2]->first, sommets[i]->first );
+ else
+ return make_pair( sommets[i]->first, sommets[i2]->first );
+}
// retourne l'entité d'une maille en fonction de la dimension du maillage.
MED_EN::medEntityMesh _maille::getEntity(const int meshDimension) const throw (MEDEXCEPTION)
os << " -> liste des sous-groupes : ";
for( std::vector<int>::const_iterator i=gr.groupes.begin(); i!=gr.groupes.end(); ++i)
os << *i << " ";
- os << std::endl << " -> liste des mailles : " << std::endl;
- std::set< std::set< _maille, std::less< _maille >,
- std::allocator< _maille > >::iterator,
- _mailleIteratorCompare,
- std::allocator< std::set< _maille, std::less< _maille >,
- std::allocator< _maille > >::iterator > >::const_iterator i ;
- for( i=gr.mailles.begin(); i!=gr.mailles.end(); i++)
- os << " " << *(*i) << std::endl;
+ os << std::endl << " -> liste des "<< gr.mailles.size() << " mailles : " << std::endl;
+ _groupe::mailleIter i=gr.mailles.begin();
+ int l;
+ for(l = 0; l < DUMP_LINES_LIMIT && i!=gr.mailles.end(); i++, l++)
+ os << setw(3) << l+1 << " " << *(*i) << std::endl;
+ if ( l == DUMP_LINES_LIMIT )
+ os << " ... skip " << gr.mailles.size() - l << " mailles" << endl;
+ os << " relocMap, size=" << gr.relocMap.size() << endl;
+ map<const _maille*,int>::const_iterator it = gr.relocMap.begin();
+ for ( l = 0; l < DUMP_LINES_LIMIT && it != gr.relocMap.end(); ++it, ++l )
+ os << " (" << it->first << "," << it->second << ")";
+ if ( gr.relocMap.size() > 0 )
+ os << endl;
return os;
}
return os;
}
+void MEDMEM::_fieldBase::dump(std::ostream& os) const
+{
+ os << "field " << "<" << name << ">" << endl <<
+ " nb sub: " << nb_subcomponents << endl <<
+ " nb comp: " << nb_components << endl <<
+ " group index: " << group_id << endl <<
+ " type: " << type << endl;
+ os << " comp names: ";
+ for ( int i = 0; i < comp_names.size(); ++i )
+ os << " |" << comp_names[ i ] << "|";
+}
+
+std::ostream& MEDMEM::operator << (std::ostream& os, const _fieldBase * f)
+{
+ f->dump( os );
+ return os;
+}
+
std::ostream& MEDMEM::operator << (std::ostream& os, const _intermediateMED& mi)
{
- os << "Set des mailles : " << std::endl;
- for( std::set<_maille>::const_iterator i=mi.maillage.begin(); i!=mi.maillage.end(); ++i)
- os << *i << std::endl;
+ os << "Set des " << mi.maillage.size() << " mailles : " << std::endl;
+ std::set<_maille>::const_iterator i=mi.maillage.begin();
+ int l;
+ for( l = 0; l < DUMP_LINES_LIMIT && i!=mi.maillage.end(); ++i, ++l)
+ os << setw(3) << l+1 << " " <<*i << std::endl;
+ if ( l == DUMP_LINES_LIMIT )
+ os << " ... skip " << mi.maillage.size() - l << " mailles" << endl;
- os << std::endl << "Vector des groupes : " << std::endl;
- // for( std::vector<_groupe>::const_iterator i=mi.groupes.begin(); i!=mi.groupes.end(); ++i)
- for (unsigned int i=0; i!=mi.groupes.size(); i++)
- os << std::setw(3) << i << " " << mi.groupes[i] << std::endl;
+ os << std::endl << "Vector des " << mi.groupes.size() << " groupes : " << std::endl;
+ for (unsigned int k=0; k!=mi.groupes.size(); k++)
+ os << std::setw(3) << k << " " << mi.groupes[k] << std::endl;
- os << std::endl << "map des noeuds : " << std::endl;
- for( std::map<int,_noeud>::const_iterator i=mi.points.begin(); i!=mi.points.end(); ++i)
- os << i->second << std::endl;
+ os << std::endl << "map des " << mi.points.size() << " noeuds : " << std::endl;
+ std::map<int,_noeud>::const_iterator j=mi.points.begin();
+ for( l = 0; l < DUMP_LINES_LIMIT && j!=mi.points.end(); ++j, ++l)
+ os << j->second << std::endl;
+ if ( l == DUMP_LINES_LIMIT )
+ os << " ... skip " << mi.points.size() - l << " noeuds" << endl;
+
+ os << endl << mi.fields.size() << " fields:" << endl;
+ std::list<_fieldBase* >::const_iterator fIt = mi.fields.begin();
+ for ( l = 0; fIt != mi.fields.end(); ++fIt, ++l )
+ os << " - " << l+1 << " " << *fIt << endl;
+
return os;
}
+
+//=======================================================================
+//function : treatGroupes
+//purpose : detect groupes of mixed dimension and erase groupes that
+// won't be converted
+//=======================================================================
+
+void _intermediateMED::treatGroupes()
+{
+ const char * LOC = "_intermediateMED::treatGroupes() : ";
+ BEGIN_OF(LOC);
+
+ // --------------------
+ // erase useless group
+ // --------------------
+
+ // decrease hierarchical depth of subgroups
+ vector<int>::iterator j;
+ for (unsigned int i=0; i!=this->groupes.size(); ++i)
+ {
+ _groupe& grp = groupes[i];
+ //INFOS( i << " " << grp.nom );
+ j = grp.groupes.begin();
+ while( j!=grp.groupes.end() ) {
+ int grpInd = *j-1;
+ if ( grpInd < 0 || grpInd >= groupes.size() ) {
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Bad subgroup index: " << grpInd <<
+ ", in " << i << " groupe.nom=" << grp.nom));
+ }
+ _groupe & sub_grp = groupes[ grpInd ];
+ if ( !sub_grp.groupes.empty() ) {
+ MESSAGE("High hierarchical depth of subgroups in group " << i );
+ *j = sub_grp.groupes[0]; // replace j with its 1st subgroup
+ // push back the rest subs
+ for ( int k = 1; k < sub_grp.groupes.size(); ++k )
+ grp.groupes.push_back( sub_grp.groupes[ k ]);
+ // vector maybe is reallocated: restart iterator
+ j = grp.groupes.begin();
+ }
+ else
+ j++;
+ }
+ // remove empty sub-groupes
+ j = grp.groupes.begin();
+ while ( j!=grp.groupes.end() ) {
+ if ( groupes[*j-1].empty() ) {
+ grp.groupes.erase( j );
+ j = grp.groupes.begin();
+ }
+ else
+ j++;
+ }
+ }
+ // get indices of groups that are field support -
+ // do not erase them and their subgroups
+ std::set<int> groups2convert;
+ std::list< _fieldBase* >::const_iterator fIt = fields.begin();
+ for ( ; fIt != fields.end(); ++fIt )
+ {
+ groups2convert.insert( (*fIt)->group_id );
+ _groupe& grp = groupes[ (*fIt)->group_id ];
+ for( j = grp.groupes.begin(); j!=grp.groupes.end(); ++j)
+ groups2convert.insert( *j-1 );
+ }
+ // keep named groups and their subgroups
+ for (unsigned int i=0; i!=this->groupes.size(); ++i)
+ {
+ _groupe& grp = groupes[i];
+ if ( grp.empty() || grp.nom.empty() )
+ continue;
+ groups2convert.insert( i );
+ for( j = grp.groupes.begin(); j!=grp.groupes.end(); ++j)
+ groups2convert.insert( *j-1 );
+ }
+ // erase groups that are not in groups2convert
+ for (unsigned int i=0; i!=this->groupes.size(); ++i)
+ {
+ if ( groups2convert.find( i ) == groups2convert.end() ) {
+ _groupe& grp = groupes[i];
+ grp.mailles.clear();
+ grp.groupes.clear();
+ //INFOS( "Erase " << i << "-th group " << grp.nom );
+ }
+ }
+
+ // ---------------------------------------------------
+ // define if there are groups with mixed entity types
+ // ---------------------------------------------------
+
+ hasMixedCells = false;
+ for (unsigned int i=0; i!=this->groupes.size(); ++i)
+ {
+ _groupe& grp = groupes[i];
+ if ( grp.groupes.empty() )
+ continue;
+
+ // check if sub-groups have different dimension
+ j = grp.groupes.begin();
+ int dim = groupes[*j-1].mailles[0]->dimension();
+ for( j++; !hasMixedCells && j!=grp.groupes.end(); ++j)
+ hasMixedCells = ( dim != groupes[*j-1].mailles[0]->dimension() );
+ }
+
+ if ( hasMixedCells )
+ INFOS( "There will be groups of mixed dimention" );
+ END_OF(LOC);
+}
+
void _intermediateMED::numerotationMaillage()
{
- // numerotation des mailles par entité
+ const char * LOC = "_intermediateMED::numerotationMaillage() : ";
+ BEGIN_OF(LOC);
+
+ treatGroupes();
+
+ // numerotation mailles of type MED_POINT1 by node number
+ std::set<_maille>::iterator i=maillage.begin();
+ if ( i->geometricType == MED_POINT1 ) {
+ numerotationPoints();
+ while ( i!=maillage.end() && i->geometricType == MED_POINT1 ) {
+ i->ordre = i->sommets[0]->second.number;
+ i++;
+ }
+ }
+ // numerotation des mailles par entité
int i_maille=0;
- std::set<_maille>::iterator i=maillage.begin();
int dimension=i->dimension();
for( ; i!=maillage.end(); ++i)
{
- if ( dimension!=i->dimension() ) // on change d'entite
+ if ( !hasMixedCells && dimension!=i->dimension() ) // on change d'entite
{
+ MESSAGE( "NB dim " << dimension << " entities: " << i_maille);
dimension=i->dimension();
i_maille=0;
}
(*i).ordre=++i_maille;
}
+ END_OF(LOC);
}
void _intermediateMED::numerotationPoints()
vtype.push_back(type);
// Boucle sur i de parcours des mailles d'une entite
// Une entite se termine lorsqu'on atteint la fin de maillage ou lorsque la dimension des mailles change
- for( ; i!=maillage.end() && dimension==i->dimension() ; ++i)
+ for( ; i!=maillage.end() && ( hasMixedCells || dimension==i->dimension()) ; ++i)
{
if (type != i->geometricType) // si changement de type geometrique
{
++nbtype;
}
- vcount.push_back(nbtype); // n'a pas été stocké dans la boucle
-
+ vcount.push_back(dimension ? nbtype : numberOfNodes); // n'a pas été stocké dans la boucle
// Pour l'entite qu'on vient de parcourir, allocation des tableau et creation de la connectivite
// cout << "Dimension = " << dimension << endl;
for (unsigned int k=0; k!=vcount.size(); ++k )
count[k+1]=count[k]+vcount[k];
Connectivity->setCount (count, entity);
+ SCRUTE( entity );
+ SCRUTE(numberOfTypes);
+ SCRUTE(count[numberOfTypes]-1);
delete [] count;
for (int k=0; k!=numberOfTypes; ++k )
{
// pour chaque type géometrique k, copie des sommets dans connectivity et set dans Connectivity
int nbSommetsParMaille = j->sommets.size();
- int nbSommets = vcount[k] * j->sommets.size();
+ int n, nbSommets = vcount[k] * j->sommets.size();
connectivity = new int[ nbSommets ];
- for (int l=0; l!=vcount[k]; ++l, ++j)
+ for (int l=0; l!=vcount[k]; ++l)
{
- for ( unsigned n=0; n != j->sommets.size(); ++n)
- connectivity[nbSommetsParMaille*l+n] = j->sommets[n]->second.number;
- //CCRT maillage.erase(j); ; // dangereux, mais optimise la mémoire consommée!
- }
+ if ( entity==MED_NODE )
+ connectivity[l] = l+1;
+ else
+ {
+ for ( n=0; n != nbSommetsParMaille; ++n) {
+ connectivity[nbSommetsParMaille*l+n] =
+ j->sommets[ j->reverse ? nbSommetsParMaille-n-1 : n ]->second.number;
+ }
+ // DO NOT ERASE, maillage will be used while fields construction
+ //maillage.erase(j); ; // dangereux, mais optimise la mémoire consommée!
+ j++;
+ }
+ }
Connectivity->setNodal (connectivity, entity, vtype[k]);
delete [] connectivity;
}
-
- if (i!=j)
+
+ if ( entity==MED_NODE )
+ j = i;
+ else if (i!=j)
throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Erreur de lecture des mailles ."));
if ( ! first)
void
_intermediateMED::getGroups(std::vector<GROUP *> & _groupCell, std::vector<GROUP *> & _groupFace, std::vector<GROUP *> & _groupEdge, std::vector<GROUP *> & _groupNode, MESH * _ptrMesh)
{
- const char * LOC = "_intermediateMED::getGroups() : ";
- BEGIN_OF(LOC);
- if (maillage.size() == 0)
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Erreur : il n'y a plus de mailles (appeler getConnectivity apres getGroups!)."));
+ const char * LOC = "_intermediateMED::getGroups() : ";
+ BEGIN_OF(LOC);
+ if (maillage.size() == 0) {
+ INFOS( "Erreur : il n'y a plus de mailles");
+ return;
+ }
+
+ // get indices of groups that are field support - do not skip them
+ std::set<int> support_groups;
+ std::list< _fieldBase* >::const_iterator fIt = fields.begin();
+ for ( ; fIt != fields.end(); ++fIt )
+ support_groups.insert( (*fIt)->group_id );
+
+ numerotationMaillage(); // Renumerotation des mailles par entite
+
+ int dimension_maillage=maillage.rbegin()->dimension();
+
+ for (unsigned int i=0; i!=this->groupes.size(); ++i)
+ {
+ _groupe& grp = groupes[i];
+ // si le groupe est vide, ou si le groupe n'est pas nommé : on passe au suivant
+ if ( grp.empty() ||
+ ( grp.nom.empty() && support_groups.find( i ) == support_groups.end() )) {
+ if ( !grp.nom.empty() )
+ INFOS("Skip group " << grp.nom );
+ medGroupes.push_back( NULL );
+ continue;
+ }
+
+ // Build a set of mailles: sort mailles by type and exclude maille doubling
+ typedef set< set<_maille>::iterator, _mailleIteratorCompare > TMailleSet;
+ TMailleSet mailleSet;
+ if( grp.groupes.size() ) {// le groupe i contient des sous-maillages
+ int nb_elem = 0;
+ for( vector<int>::iterator j=grp.groupes.begin(); j!=grp.groupes.end(); ++j)
+ {
+ nb_elem += groupes[*j-1].mailles.size();
+ _groupe::mailleIter maIt=groupes[*j-1].mailles.begin();
+ for( ; maIt!=groupes[*j-1].mailles.end(); ++maIt) {
+// TMailleSet::const_iterator ma_it = mailleSet.find( *maIt );
+// if ( ma_it != mailleSet.end() ) {
+// MESSAGE("EQUAL ELEMS: " << *ma_it << " AND " << *maIt);
+// }
+// else
+ mailleSet.insert( *maIt );
+ }
+ }
+ if ( nb_elem != mailleSet.size() ) {
+ INFOS("Self intersecting group: " << i+1 << " <" << grp.nom << ">"
+ << ", mailleSet.size = " << mailleSet.size() << ", sum nb elems = " << nb_elem);
+ for( vector<int>::iterator j=grp.groupes.begin(); j!=grp.groupes.end(); ++j)
+ INFOS(" in sub-group "<< *j << " <" << groupes[*j-1].nom << "> "
+ << groupes[*j-1].mailles.size() << " mailles of type "
+ << groupes[*j-1].mailles[0]->geometricType);
+ }
+ }
+ else {
+ _groupe::mailleIter maIt=grp.mailles.begin();
+ for(; maIt!=grp.mailles.end(); ++maIt)
+ mailleSet.insert( *maIt );
+ if ( grp.mailles.size() != mailleSet.size() )
+ INFOS( "Self intersecting group: " << i+1 << " <" << grp.nom << ">"
+ << ", mailleSet.size = " << mailleSet.size() << ", nb elems = " << grp.mailles.size());
+ }
+
+ // 1. Build a map _maille* -> index in MEDMEM::GROUP.getNumber(MED_ALL_ELEMENTS).
+ // It is used while fields building.
+ // 2. make mailles know the groups they belong to, that is used in getFamilies()
+ TMailleSet::iterator maIt = mailleSet.begin();
+ int iMa;
+ for ( iMa = 0; maIt != mailleSet.end(); maIt++ ) {
+ grp.relocMap.insert( make_pair( &(**maIt), ++iMa ));
+ (*maIt)->groupes.push_back( i );
+ }
+ ASSERT( iMa == grp.relocMap.size() );
+
+ int nb_geometric_types=1;
+ TMailleSet::iterator j=mailleSet.begin();
+ // initialise groupe_entity a l'entite de la premiere maille du groupe
+ medEntityMesh groupe_entity = (**mailleSet.rbegin()).getEntity(dimension_maillage);
+ if ( hasMixedCells )
+ groupe_entity = MED_CELL;
+ medGeometryElement geometrictype=(**j).geometricType;
+
+ //Parcours des mailles (a partir de la deuxieme) pour compter les types geometriques
+ for ( ++j ; j!=mailleSet.end(); ++j )
+ {
+ //Compte nombre de types geometriques
+ if ( (**j).geometricType != geometrictype ) // si on change de type geometrique
+ {
+ nb_geometric_types++;
+ geometrictype=(**j).geometricType;
+ }
+ }
- int dimension_maillage=maillage.rbegin()->dimension();
+ MED_EN::medGeometryElement * tab_types_geometriques = new MED_EN::medGeometryElement[nb_geometric_types];
+ int * tab_index_types_geometriques = new int[nb_geometric_types+1];
+ int * tab_numeros_elements = new int[mailleSet.size()];
+ int * tab_nombres_elements = new int[nb_geometric_types];
+
+ //Remplit tableaux entree des methodes set
+ int indice_mailles=0/*, maxOrdre = -1*/;
+ j=mailleSet.begin();
+ geometrictype=(**j).geometricType;
+ tab_index_types_geometriques[0]=1;
+ int indice_types_geometriques=1;
+ tab_types_geometriques[0]=geometrictype;
+ //parcours des mailles du groupe
+ for ( ; j!=mailleSet.end(); ++j , ++indice_mailles)
+ {
+ const _maille& ma = **j;
+ tab_numeros_elements[indice_mailles]= ma.ordre;
+// if ( maxOrdre < tab_numeros_elements[indice_mailles] )
+// maxOrdre = tab_numeros_elements[indice_mailles];
+ if (ma.geometricType != geometrictype)
+ {
+ tab_index_types_geometriques[indice_types_geometriques]=indice_mailles+1;
+ geometrictype=ma.geometricType;
+ tab_types_geometriques[indice_types_geometriques]=geometrictype;
+ ++indice_types_geometriques;
+ }
+ }
+ tab_index_types_geometriques[indice_types_geometriques]=indice_mailles+1;
+ for (int k=0; k != nb_geometric_types; ++k)
+ {
+ tab_nombres_elements[k] = tab_index_types_geometriques[k+1]-tab_index_types_geometriques[k];
+ }
+ //INFOS( "MAX ORDRE in grp " << grp.nom << " entity " << groupe_entity << " : " << maxOrdre);
- numerotationMaillage(); // Renumerotation des mailles par entite
+ //Determination type entite du groupe
+ vector <GROUP *> * vect_group;
+ switch ( groupe_entity )
+ {
+ case MED_CELL :
+ vect_group= & _groupCell;
+ break;
+ case MED_FACE :
+ vect_group= & _groupFace;
+ break;
+ case MED_EDGE :
+ vect_group= & _groupEdge;
+ break;
+ case MED_NODE :
+ vect_group= & _groupNode;
+ break;
+ }
+ //Creation nouveau groupe MED
+ GROUP * new_group = new GROUP();
+ //Appel methodes set
+ new_group->setTotalNumberOfElements(mailleSet.size());
+ new_group->setName(grp.nom);
+ new_group->setMesh(_ptrMesh);
+ new_group->setNumberOfGeometricType(nb_geometric_types);
+ new_group->setGeometricType(tab_types_geometriques);
+ new_group->setNumberOfElements(tab_nombres_elements);
+ new_group->setNumber(tab_index_types_geometriques,tab_numeros_elements);
+ new_group->setEntity(groupe_entity);
+ new_group->setAll(mailleSet.size() == maillage.size());
+
+ vector<int> nbGaussPnt( nb_geometric_types, 1 );
+ new_group->setNumberOfGaussPoint( &nbGaussPnt[0] );
+
+ vect_group->push_back(new_group);
+ medGroupes.push_back( new_group );
+
+ delete [] tab_types_geometriques;
+ delete [] tab_index_types_geometriques;
+ delete [] tab_numeros_elements;
+ delete [] tab_nombres_elements;
+ }
+ SCRUTE( medGroupes.size() );
+
+ END_OF(LOC);
+}
- for (unsigned int i=0; i!=this->groupes.size(); ++i)
+//=======================================================================
+//function : getFamilies
+//purpose : create families like MESH::createFamilies() but preserves
+// the order of elements in GROUPs defined by constituent families
+// order. Call it after getGroups()
+//=======================================================================
+
+void _intermediateMED::getFamilies(std::vector<FAMILY *> & _famCell,
+ std::vector<FAMILY *> & _famFace,
+ std::vector<FAMILY *> & _famEdge,
+ std::vector<FAMILY *> & _famNode, MESH * _ptrMesh)
+{
+ const char * LOC = "_intermediateMED::getFamilies() : ";
+ BEGIN_OF(LOC);
+
+ int nbElemFam = 0, nbNodeFam = 0;
+ std::map< GROUP*, vector< FAMILY * > > grpFamsMap;
+ int dimension_maillage=maillage.rbegin()->dimension();
+
+ std::set<_maille>::const_iterator i=maillage.begin(); // iterateurs sur les mailles
+ std::set<_maille>::const_iterator j=maillage.begin();
+
+ do
+ {
+ // make a family containing mailles shared by the same set of groups
+ std::list<unsigned>& grList = i->groupes; // to define the family end
+ int dimension = i->dimension(); // to define the entity end
+ medGeometryElement type = i->geometricType;
+ medEntityMesh entity = i->getEntity( dimension_maillage );
+
+ std::vector<medGeometryElement> tab_types_geometriques;
+ std::vector<int> tab_index_types_geometriques;
+ std::vector<int> tab_nombres_elements;
+ std::vector<int> tab_numeros_elements;
+
+ int iMa = 1, nbtype = 0;
+ tab_types_geometriques.push_back( type );
+ tab_index_types_geometriques.push_back( iMa );
+
+ // scan family cells and fill the tab that are needed by the create a MED FAMILY
+ while (i != maillage.end() &&
+ i->groupes == grList &&
+ i->dimension() == dimension)
{
- // si le groupe est vide, ou si le groupe n'est pas nommé : on passe au suivant
- if (groupes[i].mailles.empty() || groupes[i].nom.empty())
- continue;
-
- int nb_geometric_types=1;
- std::set< std::set< _maille, std::less< _maille >,
- std::allocator< _maille > >::iterator,
- _mailleIteratorCompare,
- std::allocator< std::set< _maille, std::less<_maille >,
- std::allocator< _maille > >::iterator > >::iterator j ;
- j=groupes[i].mailles.begin();
- // initialise groupe_entity a l'entite de la premiere maille du groupe
- medEntityMesh groupe_entity = (**j).getEntity(dimension_maillage);
- medGeometryElement geometrictype=(**j).geometricType;
-
- //Parcours des mailles (a partir de la deuxieme) pour compter les types geometriques
- for ( ++j ; j!=groupes[i].mailles.end(); ++j )
- {
- //Compte nombre de types geometriques
- if ( (**j).geometricType != geometrictype ) // si on change de type geometrique
- {
- nb_geometric_types++;
- geometrictype=(**j).geometricType;
- }
+ if (type != i->geometricType) // si changement de type geometrique
+ {
+ tab_index_types_geometriques.push_back(iMa);
+ tab_nombres_elements.push_back(nbtype);
+ nbtype=0;
+ type=i->geometricType;
+ tab_types_geometriques.push_back(type); // stocke le nouveau type geometrique rencontre
+ }
+ ++nbtype;
+ ++iMa;
+ ++i;
+ }
+ tab_index_types_geometriques.push_back(iMa);
+ tab_nombres_elements.push_back(nbtype); // n'a pas été stocké dans la boucle
+
+ tab_numeros_elements.resize( iMa - 1 );
+ for ( iMa = 0; j != i; j++, iMa++ )
+ tab_numeros_elements[ iMa ] = j->ordre;
+
+ int id = ( entity == MED_NODE ? ++nbNodeFam : -(++nbElemFam) );
+
+ ostringstream name;
+ name << "FAM_" << id;
+
+ // create a empty MED FAMILY and fill it with the tabs we constructed
+ FAMILY* newFam = new FAMILY();
+ newFam->setTotalNumberOfElements( iMa );
+ newFam->setName( name.str() );
+ newFam->setMesh( _ptrMesh );
+ newFam->setNumberOfGeometricType( tab_types_geometriques.size() );
+ newFam->setGeometricType( &tab_types_geometriques[0] ); // we know the tab is not empy
+ newFam->setNumberOfElements( &tab_nombres_elements[0] );
+ newFam->setNumber( &tab_index_types_geometriques[0], &tab_numeros_elements[0] );
+ newFam->setEntity( entity );
+ newFam->setAll( false );
+ newFam->setIdentifier( id );
+ newFam->setNumberOfGroups( grList.size() );
+
+ // Update links between families and groups
+ if ( ! grList.empty() )
+ {
+ std::string * groupNames = new string[ grList.size() ];
+ std::list<unsigned>::iterator g = grList.begin();
+ for ( int i = 0; g != grList.end(); ++g, ++i ) {
+ GROUP * medGROUP = getGroup( *g );
+ groupNames[ i ] = medGROUP->getName();
+ grpFamsMap[ medGROUP ].push_back( newFam );
+ }
+ newFam->setGroupsNames(groupNames);
+ }
+ // store newFam
+ std::vector<FAMILY*>* families = 0;
+ switch ( entity )
+ {
+ case MED_CELL :
+ families = & _famCell; break;
+ case MED_FACE :
+ families = & _famFace; break;
+ case MED_EDGE :
+ families = & _famEdge; break;
+ case MED_NODE :
+ families = & _famNode; break;
+ }
+ if ( families )
+ families->push_back( newFam );
+
+ } while ( i != maillage.end() );
+
+ // update references in groups
+ std::map< GROUP*, vector< FAMILY * > >::iterator gf = grpFamsMap.begin();
+ for ( ; gf != grpFamsMap.end(); ++gf )
+ {
+ gf->first->setNumberOfFamilies( gf->second.size() );
+ gf->first->setFamilies( gf->second );
+ }
+}
- //Test si groupe valide : le groupe doit pointer vers des entites de meme dimension
- if ((**j).dimension() != dimension_maillage)
- continue;
- }
+//=======================================================================
+//function : getGroup
+//purpose :
+//=======================================================================
- // le groupe est valide -> on le traite
- MED_EN::medGeometryElement * tab_types_geometriques = new MED_EN::medGeometryElement[nb_geometric_types];
- int * tab_index_types_geometriques = new int[nb_geometric_types+1];
- int * tab_numeros_elements = new int[groupes[i].mailles.size()];
- int * tab_nombres_elements = new int[nb_geometric_types];
-
- //Remplit tableaux entree des methodes set
- int indice_mailles=0;
- j=groupes[i].mailles.begin();
- geometrictype=(**j).geometricType;
- tab_index_types_geometriques[0]=1;
- int indice_types_geometriques=1;
- tab_types_geometriques[0]=geometrictype;
- //parcours des mailles du groupe
- for ( ; j!=groupes[i].mailles.end(); ++j , ++indice_mailles)
- {
- tab_numeros_elements[indice_mailles]=((**j).ordre);
- if ((**j).geometricType != geometrictype)
- {
- tab_index_types_geometriques[indice_types_geometriques]=indice_mailles+1;
- geometrictype=(**j).geometricType;
- tab_types_geometriques[indice_types_geometriques]=geometrictype;
- ++indice_types_geometriques;
- }
- }
- tab_index_types_geometriques[indice_types_geometriques]=indice_mailles+1;
- for (int k=0; k != nb_geometric_types; ++k)
- {
- tab_nombres_elements[k] = tab_index_types_geometriques[k+1]-tab_index_types_geometriques[k];
- }
+GROUP * _intermediateMED::getGroup( int i )
+{
+ if ( i < medGroupes.size() )
+ return medGroupes[ i ];
+ throw MEDEXCEPTION
+ (LOCALIZED(STRING("_intermediateMED::getGroup(): WRONG GROUP INDEX: ")
+ << medGroupes.size() << " <= " << i ));
+}
- //Determination type entite du groupe
- vector <GROUP *> * vect_group;
- switch ( groupe_entity )
- {
- case MED_CELL :
- vect_group= & _groupCell;
- break;
- case MED_FACE :
- vect_group= & _groupFace;
- break;
- case MED_EDGE :
- vect_group= & _groupEdge;
- break;
- case MED_NODE :
- vect_group= & _groupNode;
- break;
- }
- //Creation nouveau groupe MED
- GROUP * new_group = new GROUP();
- //Appel methodes set
- new_group->setTotalNumberOfElements(groupes[i].mailles.size());
- new_group->setName(groupes[i].nom);
- new_group->setMesh(_ptrMesh);
- new_group->setNumberOfGeometricType(nb_geometric_types);
- new_group->setGeometricType(tab_types_geometriques);
- new_group->setNumberOfElements(tab_nombres_elements);
- new_group->setNumber(tab_index_types_geometriques,tab_numeros_elements);
- new_group->setEntity(groupe_entity);
- new_group->setAll(groupes[i].mailles.size() == maillage.size());
- vect_group->push_back(new_group);
- delete [] tab_types_geometriques;
- delete [] tab_index_types_geometriques;
- delete [] tab_numeros_elements;
- delete [] tab_nombres_elements;
+//=======================================================================
+//function : getFields
+//purpose :
+//=======================================================================
+
+void _intermediateMED::getFields(std::list< FIELD_* >& theFields)
+{
+ const char * LOC = "_intermediateMED::getFields() : ";
+ BEGIN_OF(LOC);
+ std::list< _fieldBase* >::const_iterator fIt = fields.begin();
+ for ( ; fIt != fields.end(); fIt++ )
+ {
+ const _fieldBase* fb = *fIt;
+ SUPPORT* sup = getGroup( fb->group_id );
+ if ( !sup )
+ throw MEDEXCEPTION
+ (LOCALIZED(STRING(LOC) <<"_intermediateMED::getFields(), NULL field support: "
+ << " group index: " << fb->group_id));
+ int nb_elems = sup->getNumberOfElements( MED_ALL_ELEMENTS );
+
+ std::list< FIELD_* > ff = fb->getField(groupes);
+ std::list< FIELD_* >::iterator it = ff.begin();
+ for (int j = 1 ; it != ff.end(); it++, ++j )
+ {
+ FIELD_* f = *it;
+ if ( nb_elems != f->getNumberOfValues() )
+ throw MEDEXCEPTION
+ (LOCALIZED(STRING("_intermediateMED::getFields(), field support size (")
+ << nb_elems << ") != NumberOfValues (" << f->getNumberOfValues()));
+ theFields.push_back( f );
+ f->setSupport( sup );
+ //f->setIterationNumber( j );
+ f->setOrderNumber( j );
}
+ }
+ END_OF(LOC);
+}
- END_OF(LOC);
+_intermediateMED::~_intermediateMED()
+{
+ MESSAGE( "~_intermediateMED()");
+ std::list< _fieldBase* >::const_iterator fIt = fields.begin();
+ for ( ; fIt != fields.end(); fIt++ )
+ delete *fIt;
}
+
/////
#include "MEDMEM_define.hxx"
#include "MEDMEM_Exception.hxx"
+#include "MEDMEM_Field.hxx"
#include <string>
#include <vector>
#include <set>
#include <list>
#include <map>
#include <iostream>
+#include <iomanip>
namespace MEDMEM {
class MESH;
class CONNECTIVITY;
class COORDINATE;
class GROUP;
+class FAMILY;
struct _noeud
{
mutable int number;
std::vector<double> coord;
};
+typedef pair<int,int> _link; // a pair of node numbers
+
struct _maille
{
typedef std::map<int,_noeud>::iterator iter;
MED_EN::medGeometryElement geometricType;
std::vector< iter > sommets;
mutable unsigned ordre; // l'ordre est fixé après insertion dans le set, et ne change ni l'état, ni l'ordre -> mutable
+ mutable bool reverse; // to reverse sommets of a face
+ mutable list<unsigned> groupes; // the GROUPs maille belongs to, used to create families
- _maille() : geometricType(MED_EN::MED_NONE),ordre(0)
+ _maille() : geometricType(MED_EN::MED_NONE),ordre(0),reverse(false)
{
};
- _maille(MED_EN::medGeometryElement _geometricType, size_t nelem) : geometricType(_geometricType),ordre(0)
+ _maille(MED_EN::medGeometryElement _geometricType, size_t nelem) : geometricType(_geometricType),ordre(0),reverse(false)
{
sommets.reserve(nelem);
};
};
bool operator < (const _maille& ma) const;
MED_EN::medEntityMesh getEntity(const int meshDimension) const throw (MEDEXCEPTION);
+ _link link(int i) const;
};
struct _mailleIteratorCompare // pour ordonner le set d'iterateurs sur mailles
struct _groupe
{
- typedef std::set< std::set<_maille>::iterator>::const_iterator mailleIter;
+ typedef std::vector< std::set<_maille>::iterator>::const_iterator mailleIter;
std::string nom;
- std::set< std::set<_maille>::iterator, _mailleIteratorCompare > mailles; // iterateurs sur les mailles composant le groupe
+ std::vector< std::set<_maille>::iterator > mailles; // iterateurs sur les mailles composant le groupe
+// std::set< std::set<_maille>::iterator, _mailleIteratorCompare > mailles; // iterateurs sur les mailles composant le groupe
std::vector<int> groupes; // indices des sous-groupes composant le groupe
+ std::map<const _maille*,int> relocMap; // map _maille* -> index in MEDMEM::GROUP.getNumber(MED_ALL_ELEMENTS). It is built by _intermediateMED::getGroups()
+ bool empty() const { return mailles.empty() && groupes.empty(); }
+};
+
+class _fieldBase {
+ public:
+ int nb_subcomponents;
+ int nb_components;
+ int group_id;
+ MED_EN::med_type_champ type;
+ string name;
+ std::vector<std::string> comp_names;
+ _fieldBase( MED_EN::med_type_champ theType )
+ : nb_subcomponents(0), nb_components(0),group_id(-1),type(theType) {}
+ virtual std::list<FIELD_*> getField(std::vector<_groupe>& groupes) const = 0;
+ virtual void dump(std::ostream&) const;
+ virtual ~_fieldBase() {}
+};
+
+template< class T > class _field: public _fieldBase
+{
+ std::vector< std::vector< T > > comp_values;
+ std::vector< int > comp_supp_ids;
+ public:
+ _field< T > ( MED_EN::med_type_champ theType ): _fieldBase( theType ) {}
+ std::vector< T >& addComponent( int support_id, int nb_values );
+ std::list<FIELD_*> getField(std::vector<_groupe>& groupes) const;
+ virtual void dump(std::ostream&) const;
};
/*!
{
std::set<_maille> maillage;
std::vector<_groupe> groupes;
+ std::vector<GROUP *> medGroupes;
std::map< int, _noeud > points;
+ std::list< _fieldBase* > fields;
+ bool hasMixedCells; // true if there are groups with mixed entity types
CONNECTIVITY * getConnectivity(); // set MED connectivity from the intermediate structure
COORDINATE * getCoordinate(const string & coordinateSystem="CARTESIAN"); // set MED coordinate from the
// intermediate structure
+ void getFamilies(std::vector<FAMILY *> & _famCell, std::vector<FAMILY *> & _famFace,
+ std::vector<FAMILY *> & _famEdge, std::vector<FAMILY *> & _famNode, MESH * _ptrMesh);
void getGroups(std::vector<GROUP *> & _groupCell, std::vector<GROUP *> & _groupFace,
std::vector<GROUP *> & _groupEdge, std::vector<GROUP *> & _groupNode, MESH * _ptrMesh);
+ GROUP * getGroup( int i );
+
+ void getFields(std::list< FIELD_* >& fields);
// used by previous functions to renumber points & mesh.
+ void treatGroupes(); // detect groupes of mixed dimention
void numerotationMaillage();
void numerotationPoints();
+ ~_intermediateMED();
};
std::ostream& operator << (std::ostream& , const _maille& );
std::ostream& operator << (std::ostream& , const _groupe& );
std::ostream& operator << (std::ostream& , const _noeud& );
std::ostream& operator << (std::ostream& , const _intermediateMED& );
+std::ostream& operator << (std::ostream& , const _fieldBase* );
};
+
+template <class T>
+ std::vector< T >& MEDMEM::_field< T >::addComponent( int support_id, int nb_values )
+{
+ if ( comp_supp_ids.empty() ) {
+ comp_supp_ids.reserve( nb_subcomponents * nb_components );
+ comp_values.reserve( nb_subcomponents * nb_components );
+ }
+ comp_supp_ids.push_back( support_id );
+ comp_values.push_back( std::vector< T >() );
+ std::vector< T >& res = comp_values.back();
+ res.resize( nb_values );
+ return res;
+}
+
+
+template <class T>
+std::list<MEDMEM::FIELD_*> MEDMEM::_field< T >::getField(std::vector<_groupe> & groupes) const
+{
+ std::list<FIELD_*> res;
+ int i, j, i_comp, last_comp = 0;
+ while ( last_comp < comp_values.size() )
+ {
+ // find the first array of the next field - last_comp
+ int first_comp = last_comp;
+ std::set<int> id_set;
+ for ( i = first_comp + nb_components - 1; i < comp_values.size(); i += nb_components )
+ if ( id_set.insert( comp_supp_ids[ i ] ).second ) // unique support
+ last_comp = i + 1;
+
+ _groupe& grp = groupes[ group_id ];
+ if ( grp.empty () )
+ continue;
+ int nb_val = grp.relocMap.size();
+ ASSERT ( nb_val );
+
+ //create a filed
+ FIELD< T > * f = new FIELD< T >;
+ f->setNumberOfComponents( nb_components );
+ f->setComponentsNames( &comp_names[0] );
+ f->setNumberOfValues ( nb_val );
+ f->setName( name );
+ f->setValueType( type );
+ vector<string> str( nb_components );
+ f->setComponentsDescriptions( &str[0] );
+ f->setMEDComponentsUnits( &str[0] );
+ res.push_back( f );
+
+ MESSAGE(" make field <" << name << "> on group_id " << group_id <<
+ " relocMap.size: " << nb_val << " nb mailles: " << grp.mailles.size());
+ // set values
+ MEDARRAY< T > * medarray = new MEDARRAY< T >( nb_components, nb_val, MED_EN::MED_NO_INTERLACE );
+ f->setValue( medarray );
+ for ( j = 1; j <= nb_components; ++j ) {
+ // loop on arrays of j-th component
+ for ( i_comp = first_comp++; i_comp < last_comp; i_comp += nb_components )
+ {
+ // get nb elements in a group
+ int gr_id = comp_supp_ids[ i_comp ] - 1;
+ if ( gr_id < 0 || gr_id >= groupes.size() )
+ throw MEDEXCEPTION
+ (LOCALIZED(STRING("_field< T >::getField(), invalid group id: ")
+ << gr_id << ", nb groups: " << groupes.size()));
+ _groupe & sub_grp = groupes[ gr_id ];
+ int nb_supp_elems = sub_grp.mailles.size();
+ MESSAGE(" comp_group_id " << gr_id << " nb values " << comp_values[ i_comp ].size() <<
+ " relocMap.size: " << sub_grp.relocMap.size() << " nb mailles: " << nb_supp_elems);
+
+ // store values
+ const std::vector< T > & values = comp_values[ i_comp ];
+ bool oneValue = ( values.size() == 1 );
+ ASSERT( oneValue || values.size() == nb_supp_elems );
+ for ( int k = 0; k < nb_supp_elems; ++k )
+ {
+ const T& val = oneValue ? values[ 0 ] : values[ k ];
+ const _maille* ma = &(*sub_grp.mailles[ k ]);
+ std::map<const _maille*,int>::const_iterator ma_i = grp.relocMap.find( ma );
+ if ( ma_i == grp.relocMap.end() )
+ throw MEDEXCEPTION
+ (LOCALIZED(STRING("_field< T >::getField(), cant find elem index. ")
+ << k << "-th elem: " << ma));
+ if ( ma_i->second > nb_val )
+ throw MEDEXCEPTION
+ (LOCALIZED(STRING("_field< T >::getField(), wrong elem position. ")
+ << k << "-th elem: " << ma
+ << ", pos (" << ma_i->second << ") must be <= " << nb_val));
+ medarray->setIJ( ma_i->second, j, val );
+ }
+ }
+ }
+ }
+ return res;
+}
+
+
+template <class T> void MEDMEM::_field< T >::dump(std::ostream& os) const
+{
+ _fieldBase::dump(os);
+ os << endl;
+ for ( int i = 0 ; i < comp_values.size(); ++i )
+ {
+ os << " group: " << setw(3) << comp_supp_ids[ i ] <<
+ " nb values: " << comp_values[ i ].size() << endl;
+ }
+}
#endif /* DRIVERTOOLS_HXX */
using namespace MEDMEM;
using namespace MED_EN;
+/*
+ Those defines are from the med File V2.1 and for this class they are fixed.
+*/
+
+#define MED_TAILLE_DESC 200
+#define MED_TAILLE_LNOM 80
+
FAMILY::FAMILY():_identifier(0), _numberOfAttribute(0),
_attributeIdentifier((int*)NULL),_attributeValue((int*)NULL), _attributeDescription((string*)NULL),
_numberOfGroup(0), _groupName((string*)NULL)
MESSAGE("FAMILY::build(medEntityMesh Entity,int **FamilyNumber /* from MED file */)");
bool Find = false ;
// Get types information from <_mesh>
- int numberOfTypes = _mesh->getNumberOfTypes(Entity) ;
- const medGeometryElement * types = _mesh->getTypes(Entity) ;
+ int numberOfTypes = _mesh->getNumberOfTypesWithPoly(Entity) ;
+ medGeometryElement * types = _mesh->getTypesWithPoly(Entity) ;
int * numberOfElementsInFamily = new int[numberOfTypes] ;
int numberOfElementTypesInFamily = 0 ;
// we search for all elements in this family
for (int TypeNumber=0; TypeNumber < numberOfTypes; TypeNumber++) {
- int NumberOfElements = _mesh->getNumberOfElements(Entity,types[TypeNumber]) ;
+ int NumberOfElements = _mesh->getNumberOfElementsWithPoly(Entity,types[TypeNumber]) ;
int NumberOfElementsInThisFamily = 0 ;
int * ElementsOfThisFamilyNumber = FamilyNumber[TypeNumber];
int * tmp_ElementsList = new int[NumberOfElements];
// delete[] GeometricTypeNumber;
// family on all ELEMENT ?
- if (_totalNumberOfElements == _mesh->getNumberOfElements(Entity,MED_ALL_ELEMENTS)) {
+ if (_totalNumberOfElements == _mesh->getNumberOfElementsWithPoly(Entity,MED_ALL_ELEMENTS) && Entity==MED_EN::MED_CELL) {
_isOnAllElts = true ;
// all others attributs are rights !
for (int i=0; i<_numberOfGeometricType; i++)
}
}
delete[] tmp_Types;
+ delete[] types;
delete[] numberOfElementsInFamily;
delete[] tmp_ElementsLists;
_support = m._support;
_numberOfComponents = m._numberOfComponents;
_numberOfValues = m._numberOfValues;
-
- if (m._componentsTypes != NULL)
- {
- _componentsTypes = new int[m._numberOfComponents] ;
- memcpy(_componentsTypes,m._componentsTypes,sizeof(int)*m._numberOfComponents);
- /*
- _componentsTypes = new int[m._numberOfComponents] ;
- for(int i=0;i<m._numberOfComponents;i++) {
- _componentsTypes[i] = m._componentsTypes[i] ;
- }
- */
- }
- else _componentsTypes = (int *) NULL;
-
- _componentsNames = new string[m._numberOfComponents];
- for (int i=0; i<m._numberOfComponents; i++)
- {_componentsNames[i]=m._componentsNames[i];}
- _componentsDescriptions = new string[m._numberOfComponents];
- for (int i=0; i<m._numberOfComponents; i++)
- {_componentsDescriptions[i]=m._componentsDescriptions[i];}
- _componentsUnits = new UNIT[m._numberOfComponents];
- for (int i=0; i<m._numberOfComponents; i++)
- {_componentsUnits[i] = m._componentsUnits[i];}
- // L'operateur '=' est defini dans la classe UNIT
- _MEDComponentsUnits = new string[m._numberOfComponents];
- for (int i=0; i<m._numberOfComponents; i++)
- {_MEDComponentsUnits[i] = m._MEDComponentsUnits[i];}
- _iterationNumber = m._iterationNumber;
- _time = m._time;
- _orderNumber = m._orderNumber;
+ copyGlobalInfo(m);
_valueType = m._valueType;
//_drivers = m._drivers ; // PG : Well, same driver, what about m destructor !
-
}
FIELD_::~FIELD_()
Check up the compatibility of fields before performing an arithmetic operation
\endif
*/
-void FIELD_::_checkFieldCompatibility(const FIELD_& m, const FIELD_& n ) throw (MEDEXCEPTION)
+void FIELD_::_checkFieldCompatibility(const FIELD_& m, const FIELD_& n, bool checkUnit) throw (MEDEXCEPTION)
{
string diagnosis;
diagnosis+="They don't have the same number of values!";
else
{
- for(int i=0; i<m._numberOfComponents; i++)
- {
-// Not yet implemented
-// if(m._componentsTypes[i] != n._componentsTypes[i])
-// {
-// diagnosis+="Components don't have the same types!";
-// break;
-// }
- if(m._MEDComponentsUnits[i] != n._MEDComponentsUnits[i])
- {
- diagnosis+="Components don't have the same units!";
- break;
- }
- }
+ if(checkUnit)
+ {
+ for(int i=0; i<m._numberOfComponents; i++)
+ {
+ // Not yet implemented
+ // if(m._componentsTypes[i] != n._componentsTypes[i])
+ // {
+ // diagnosis+="Components don't have the same types!";
+ // break;
+ // }
+ if(m._MEDComponentsUnits[i] != n._MEDComponentsUnits[i])
+ {
+ diagnosis+="Components don't have the same units!";
+ break;
+ }
+ }
+ }
}
if(diagnosis.size()) // if fields are not compatible : complete diagnosis and throw exception
}
-// void FIELD_::setIterationNumber (int IterationNumber) {};
-// void FIELD_::setOrderNumber (int OrderNumber) {};
-// void FIELD_::setFieldName (string& fieldName) {};
+void FIELD_::_deepCheckFieldCompatibility(const FIELD_& m, const FIELD_& n , bool checkUnit ) throw (MEDEXCEPTION)
+{
+ string diagnosis;
+
+ // check-up, fill diagnosis if some incompatibility is found.
+ if(m._support != n._support)
+ {
+ if(!(m._support->deepCompare(*n._support)))
+ diagnosis+="They don't have the same support!";
+ }
+ else if(m._numberOfComponents != n._numberOfComponents)
+ diagnosis+="They don't have the same number of components!";
+ else if(m._numberOfValues != n._numberOfValues)
+ diagnosis+="They don't have the same number of values!";
+ else
+ {
+ if(checkUnit)
+ {
+ for(int i=0; i<m._numberOfComponents; i++)
+ {
+ if(m._MEDComponentsUnits[i] != n._MEDComponentsUnits[i])
+ {
+ diagnosis+="Components don't have the same units!";
+ break;
+ }
+ }
+ }
+ }
+
+ if(diagnosis.size()) // if fields are not compatible : complete diagnosis and throw exception
+ {
+ diagnosis="Field's operation not allowed!\nThe fields " + m._name + " and "
+ + n._name + " are not compatible.\n" + diagnosis;
+ throw MEDEXCEPTION(diagnosis.c_str());
+ }
+
+ if( m.getNumberOfValues()<=0 || m.getNumberOfComponents()<=0) // check up the size is strictly positive
+ {
+ diagnosis="Field's operation not allowed!\nThe fields " + m._name + " and "
+ + n._name + " are empty! (size<=0).\n";
+ throw MEDEXCEPTION(diagnosis.c_str());
+ }
+}
void FIELD_::rmDriver (int index)
{
void FIELD_::write (int , const string & ) {};
void FIELD_::writeAppend (int , const string & ) {};
void FIELD_::read (int ) {};
+void FIELD_::copyGlobalInfo(const FIELD_& m)
+{
+ if (m._componentsTypes != NULL)
+ {
+ _componentsTypes = new int[m._numberOfComponents] ;
+ memcpy(_componentsTypes,m._componentsTypes,sizeof(int)*m._numberOfComponents);
+ }
+ else
+ _componentsTypes = (int *) NULL;
+
+ _componentsNames = new string[m._numberOfComponents];
+ for (int i=0; i<m._numberOfComponents; i++)
+ _componentsNames[i]=m._componentsNames[i];
+ _componentsDescriptions = new string[m._numberOfComponents];
+ for (int i=0; i<m._numberOfComponents; i++)
+ _componentsDescriptions[i]=m._componentsDescriptions[i];
-// void FIELD_::setValueType(med_type_champ ValueType) {};
-// med_type_champ FIELD_::getValueType() {};
+ if (m._componentsUnits != NULL)
+ {
+ _componentsUnits = new UNIT[m._numberOfComponents];
+ for (int i=0; i<m._numberOfComponents; i++)
+ _componentsUnits[i] = m._componentsUnits[i];
+ }
+ else
+ _componentsUnits=(UNIT*)NULL;
+
+ // L'operateur '=' est defini dans la classe UNIT
+ _MEDComponentsUnits = new string[m._numberOfComponents];
+ for (int i=0; i<m._numberOfComponents; i++)
+ {_MEDComponentsUnits[i] = m._MEDComponentsUnits[i];}
+ _iterationNumber = m._iterationNumber;
+ _time = m._time;
+ _orderNumber = m._orderNumber;
+}
#include "utilities.h"
#include "MEDMEM_Exception.hxx"
#include "MEDMEM_define.hxx"
-
#include "MEDMEM_Support.hxx"
#include "MEDMEM_Unit.hxx"
#include "MEDMEM_Array.hxx"
#include "MEDMEM_GenDriver.hxx"
-#include "MEDMEM_DriverFactory.hxx"
/*!
MED_EN::med_type_champ _valueType ;
vector<GENDRIVER *> _drivers; // Storage of the drivers currently in use
- static void _checkFieldCompatibility(const FIELD_& m, const FIELD_& n ) throw (MEDEXCEPTION);
+ static void _checkFieldCompatibility(const FIELD_& m, const FIELD_& n, bool checkUnit=true) throw (MEDEXCEPTION);
+ static void _deepCheckFieldCompatibility(const FIELD_& m, const FIELD_& n, bool checkUnit=true ) throw (MEDEXCEPTION);
void _checkNormCompatibility(const FIELD<double>* p_field_volume=NULL) const throw (MEDEXCEPTION);
FIELD<double>* _getFieldSize() const;
public:
- friend class MED_MED_RDONLY_DRIVER;
- friend class MED_MED_WRONLY_DRIVER;
- friend class MED_MED_RDWR_DRIVER;
+ friend class MED_MED_RDONLY_DRIVER21;
+ friend class MED_MED_WRONLY_DRIVER21;
+ friend class MED_MED_RDWR_DRIVER21;
+ friend class MED_MED_RDONLY_DRIVER22;
+ friend class MED_MED_WRONLY_DRIVER22;
+ friend class MED_MED_RDWR_DRIVER22;
friend class VTK_MED_DRIVER;
// virtual void setOrderNumber (int OrderNumber);
// virtual void setFieldName (string& fieldName);
- virtual void rmDriver(int index);
+ virtual void rmDriver(int index=0);
virtual int addDriver(driverTypes driverType,
const string & fileName="Default File Name.med",
const string & driverFieldName="Default Field Nam",
inline void setValueType (const MED_EN::med_type_champ ValueType) ;
inline MED_EN::med_type_champ getValueType () const;
-
+protected:
+ void copyGlobalInfo(const FIELD_& m);
};
// ---------------------------------
namespace MEDMEM {
- template<class T2> class MED_FIELD_RDONLY_DRIVER;
- template<class T2> class MED_FIELD_WRONLY_DRIVER;
+ template<class T2> class MED_FIELD_RDONLY_DRIVER21;
+ template<class T2> class MED_FIELD_WRONLY_DRIVER21;
+ template<class T2> class MED_FIELD_RDONLY_DRIVER22;
+ template<class T2> class MED_FIELD_WRONLY_DRIVER22;
template<class T2> class VTK_FIELD_DRIVER;
template <class T> class FIELD : public FIELD_
// array of value of type T
MEDARRAY<T> *_value ;
-
+ static T _scalarForPow;
+ static T pow(T x);
private:
void _operation(const FIELD& m,const FIELD& n, const MED_EN::medModeSwitch mode, char* Op);
void _operationInitialize(const FIELD& m,const FIELD& n, char* Op);
FIELD& operator*=(const FIELD& m);
FIELD& operator/=(const FIELD& m);
static FIELD* add(const FIELD& m, const FIELD& n);
+ static FIELD* addDeep(const FIELD& m, const FIELD& n);
static FIELD* sub(const FIELD& m, const FIELD& n);
+ static FIELD* subDeep(const FIELD& m, const FIELD& n);
static FIELD* mul(const FIELD& m, const FIELD& n);
+ static FIELD* mulDeep(const FIELD& m, const FIELD& n);
static FIELD* div(const FIELD& m, const FIELD& n);
+ static FIELD* divDeep(const FIELD& m, const FIELD& n);
double normMax() const throw (MEDEXCEPTION);
double norm2() const throw (MEDEXCEPTION);
void applyLin(T a, T b);
template <T T_function(T)> void applyFunc();
- static FIELD* scalarProduct(const FIELD& m, const FIELD& n);
+ void applyPow(T scalar);
+ static FIELD* scalarProduct(const FIELD& m, const FIELD& n, bool deepCheck=false);
double normL2(int component, const FIELD<double> * p_field_volume=NULL) const;
double normL2(const FIELD<double> * p_field_volume=NULL) const;
double normL1(int component, const FIELD<double> * p_field_volume=NULL) const;
double normL1(const FIELD<double> * p_field_volume=NULL) const;
+ FIELD* extract(const SUPPORT *subSupport) const throw (MEDEXCEPTION);
- friend class MED_FIELD_RDONLY_DRIVER<T>;
- friend class MED_FIELD_WRONLY_DRIVER<T>;
+ friend class MED_FIELD_RDONLY_DRIVER21<T>;
+ friend class MED_FIELD_WRONLY_DRIVER21<T>;
+ friend class MED_FIELD_RDONLY_DRIVER22<T>;
+ friend class MED_FIELD_WRONLY_DRIVER22<T>;
friend class VTK_FIELD_DRIVER<T>;
//friend class MED_FIELD_RDWR_DRIVER <T>;
inline const T* getValue(MED_EN::medModeSwitch Mode) const;
inline const T* getValueI(MED_EN::medModeSwitch Mode,int i) const;
inline T getValueIJ(int i,int j) const;
+ bool getValueOnElement(int eltIdInSup,T* retValues) const;
inline void setValue(MED_EN::medModeSwitch mode, T* value);
inline void setValueI(MED_EN::medModeSwitch mode, int i, T* value);
setValueType(MED_REEL64) call.
*/
void getBarycenter() const throw (MEDEXCEPTION) ;
+ template<void T_Analytic(const double *,T*)>
+ void fillFromAnalytic();
};
+}
+
+#include "MEDMEM_DriverFactory.hxx"
+
+namespace MEDMEM {
+
+template <class T> T FIELD<T>::_scalarForPow=1;
// --------------------
// Implemented Methods
SCRUTE(this);
try {
- _numberOfValues = Support->getNumberOfElements(MED_ALL_ELEMENTS);
+ _numberOfValues = Support->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS);
}
catch (MEDEXCEPTION &ex) {
MESSAGE("No value defined ! ("<<ex.what()<<")");
return result;
}
+/*! Same as add method except that field check is deeper.
+ */
+template <class T>
+FIELD<T>* FIELD<T>::addDeep(const FIELD& m, const FIELD& n)
+{
+ BEGIN_OF("FIELD<T>::addDeep(const FIELD & m, const FIELD& n)");
+ FIELD_::_deepCheckFieldCompatibility(m, n); // may throw exception
+
+ // Select mode : avoid if possible any calculation of other mode for fields m or *this
+ MED_EN::medModeSwitch mode;
+ if(m.getvalue()->getMode()==n.getvalue()->getMode() || n.getvalue()->isOtherCalculated())
+ mode=m.getvalue()->getMode();
+ else
+ mode=n.getvalue()->getMode();
+
+ // Creation of a new field
+ FIELD<T>* result = new FIELD<T>(m.getSupport(),m.getNumberOfComponents(),mode);
+ result->_operationInitialize(m,n,"+"); // perform Atribute's initialization
+ result->_add_in_place(m,n,mode); // perform addition
+
+ END_OF("FIELD<T>::addDeep(const FIELD & m, const FIELD& n)");
+ return result;
+}
+
/*!
Overload substraction operator.
This operation is authorized only for compatible fields that have the same support.
return result;
}
+/*! Same as sub method except that field check is deeper.
+ */
+template <class T>
+FIELD<T>* FIELD<T>::subDeep(const FIELD& m, const FIELD& n)
+{
+ BEGIN_OF("FIELD<T>::subDeep(const FIELD & m, const FIELD& n)");
+ FIELD_::_deepCheckFieldCompatibility(m, n); // may throw exception
+
+ // Select mode : avoid if possible any calculation of other mode for fields m or *this
+ MED_EN::medModeSwitch mode;
+ if(m.getvalue()->getMode()==n.getvalue()->getMode() || n.getvalue()->isOtherCalculated())
+ mode=m.getvalue()->getMode();
+ else
+ mode=n.getvalue()->getMode();
+
+ // Creation of a new field
+ FIELD<T>* result = new FIELD<T>(m.getSupport(),m.getNumberOfComponents(),mode);
+ result->_operationInitialize(m,n,"-"); // perform Atribute's initialization
+ result->_sub_in_place(m,n,mode); // perform substraction
+
+ END_OF("FIELD<T>::subDeep(const FIELD & m, const FIELD& n)");
+ return result;
+}
+
/*!
Overload multiplication operator.
This operation is authorized only for compatible fields that have the same support.
const FIELD<T> FIELD<T>::operator*(const FIELD & m) const
{
BEGIN_OF("FIELD<T>::operator*(const FIELD & m)");
- FIELD_::_checkFieldCompatibility(*this, m); // may throw exception
+ FIELD_::_checkFieldCompatibility(*this, m, false); // may throw exception
// Select mode : avoid if possible any calculation of other mode for fields m or *this
MED_EN::medModeSwitch mode;
FIELD<T>& FIELD<T>::operator*=(const FIELD & m)
{
BEGIN_OF("FIELD<T>::operator*=(const FIELD & m)");
- FIELD_::_checkFieldCompatibility(*this, m); // may throw exception
+ FIELD_::_checkFieldCompatibility(*this, m, false); // may throw exception
// We choose to keep *this mode, even if it may cost a re-calculation for m
MED_EN::medModeSwitch mode=this->getvalue()->getMode();
FIELD<T>* FIELD<T>::mul(const FIELD& m, const FIELD& n)
{
BEGIN_OF("FIELD<T>::mul(const FIELD & m, const FIELD& n)");
- FIELD_::_checkFieldCompatibility(m, n); // may throw exception
+ FIELD_::_checkFieldCompatibility(m, n, false); // may throw exception
// Select mode : avoid if possible any calculation of other mode for fields m or *this
MED_EN::medModeSwitch mode;
return result;
}
+/*! Same as mul method except that field check is deeper.
+ */
+template <class T>
+FIELD<T>* FIELD<T>::mulDeep(const FIELD& m, const FIELD& n)
+{
+ BEGIN_OF("FIELD<T>::mulDeep(const FIELD & m, const FIELD& n)");
+ FIELD_::_deepCheckFieldCompatibility(m, n, false); // may throw exception
+
+ // Select mode : avoid if possible any calculation of other mode for fields m or *this
+ MED_EN::medModeSwitch mode;
+ if(m.getvalue()->getMode()==n.getvalue()->getMode() || n.getvalue()->isOtherCalculated())
+ mode=m.getvalue()->getMode();
+ else
+ mode=n.getvalue()->getMode();
+
+ // Creation of a new field
+ FIELD<T>* result = new FIELD<T>(m.getSupport(),m.getNumberOfComponents(),mode);
+ result->_operationInitialize(m,n,"*"); // perform Atribute's initialization
+ result->_mul_in_place(m,n,mode); // perform multiplication
+
+ END_OF("FIELD<T>::mulDeep(const FIELD & m, const FIELD& n)");
+ return result;
+}
/*!
Overload division operator.
const FIELD<T> FIELD<T>::operator/(const FIELD & m) const
{
BEGIN_OF("FIELD<T>::operator/(const FIELD & m)");
- FIELD_::_checkFieldCompatibility(*this, m); // may throw exception
+ FIELD_::_checkFieldCompatibility(*this, m, false); // may throw exception
// Select mode : avoid if possible any calculation of other mode for fields m or *this
MED_EN::medModeSwitch mode;
FIELD<T>& FIELD<T>::operator/=(const FIELD & m)
{
BEGIN_OF("FIELD<T>::operator/=(const FIELD & m)");
- FIELD_::_checkFieldCompatibility(*this, m); // may throw exception
+ FIELD_::_checkFieldCompatibility(*this, m, false); // may throw exception
// We choose to keep *this mode, even if it may cost a re-calculation for m
MED_EN::medModeSwitch mode=this->getvalue()->getMode();
FIELD<T>* FIELD<T>::div(const FIELD& m, const FIELD& n)
{
BEGIN_OF("FIELD<T>::div(const FIELD & m, const FIELD& n)");
- FIELD_::_checkFieldCompatibility(m, n); // may throw exception
+ FIELD_::_checkFieldCompatibility(m, n, false); // may throw exception
// Select mode : avoid if possible any calculation of other mode for fields m or *this
MED_EN::medModeSwitch mode;
return result;
}
+/*! Same as div method except that field check is deeper.
+ */
+template <class T>
+FIELD<T>* FIELD<T>::divDeep(const FIELD& m, const FIELD& n)
+{
+ BEGIN_OF("FIELD<T>::divDeep(const FIELD & m, const FIELD& n)");
+ FIELD_::_deepCheckFieldCompatibility(m, n, false); // may throw exception
+
+ // Select mode : avoid if possible any calculation of other mode for fields m or *this
+ MED_EN::medModeSwitch mode;
+ if(m.getvalue()->getMode()==n.getvalue()->getMode() || n.getvalue()->isOtherCalculated())
+ mode=m.getvalue()->getMode();
+ else
+ mode=n.getvalue()->getMode();
+
+ // Creation of a new field
+ FIELD<T>* result = new FIELD<T>(m.getSupport(),m.getNumberOfComponents(),mode);
+ result->_operationInitialize(m,n,"/"); // perform Atribute's initialization
+ result->_div_in_place(m,n,mode); // perform division
+
+ END_OF("FIELD<T>::divDeep(const FIELD & m, const FIELD& n)");
+ return result;
+}
/*!
\if developper
getvalue()->clearOtherMode();
}
}
-
+
+template <class T> T FIELD<T>::pow(T x)
+{
+ return (T)::pow(x,FIELD<T>::_scalarForPow);
+}
+
+/*! Apply to each (scalar) field component the math function pow.
+ * calculation is done "in place".
+ * Use examples :
+ *
+ * \code myField.applyFunc<std::sqrt>(); // apply sqare root function \endcode
+ * \code myField.applyFunc<myFunction>(); // apply your own created function \endcode
+ */
+template <class T> void FIELD<T>::applyPow(T scalar)
+{
+ FIELD<T>::_scalarForPow=scalar;
+ applyFunc<FIELD<T>::pow>();
+}
/*! Apply to each (scalar) field component the linear function x -> ax+b.
* calculation is done "in place".
* Each value of it is the scalar product of the two argument's fields.
* The user is in charge of memory deallocation.
*/
-template <class T> FIELD<T>* FIELD<T>::scalarProduct(const FIELD & m, const FIELD & n)
+template <class T> FIELD<T>* FIELD<T>::scalarProduct(const FIELD & m, const FIELD & n, bool deepCheck)
{
- FIELD_::_checkFieldCompatibility( m, n); // may throw exception
- // we need a MED_FULL_INTERLACE representation of m & n to compute the scalar product
+ if(!deepCheck)
+ FIELD_::_checkFieldCompatibility( m, n, false); // may throw exception
+ else
+ FIELD_::_deepCheckFieldCompatibility(m, n, false);
+ // we need a MED_FULL_INTERLACE representation of m & n to compute the scalar product
const MED_EN::medModeSwitch mode=MED_EN::MED_FULL_INTERLACE;
const int numberOfElements=m.getNumberOfValues(); // strictly positive
p_field_size=_getFieldSize(); // we calculate the volume [PROVISOIRE, en attendant l'implémentation dans mesh]
// get pointer to the element's volumes. MED_FULL_INTERLACE is the default mode for p_field_size
- const double* vol=p_field_size->getValue(MED_FULL_INTERLACE);
- const T* value=getValueI( MED_NO_INTERLACE, component); // get pointer to the component's values
+ const double* vol=p_field_size->getValue(MED_EN::MED_FULL_INTERLACE);
+ const T* value=getValueI( MED_EN::MED_NO_INTERLACE, component); // get pointer to the component's values
const T* lastvalue=value+getNumberOfValues(); // pointing just after the end of column
double integrale=0.0;
p_field_size=_getFieldSize(); // we calculate the volume [PROVISOIRE, en attendant l'implémentation dans mesh]
// get pointer to the element's volumes. MED_FULL_INTERLACE is the default mode for p_field_size
- const double* vol=p_field_size->getValue(MED_FULL_INTERLACE);
+ const double* vol=p_field_size->getValue(MED_EN::MED_FULL_INTERLACE);
const double* lastvol=vol+getNumberOfValues(); // pointing just after the end of vol
- const T* value=getValue( MED_NO_INTERLACE); // get pointer to the field's values
+ const T* value=getValue( MED_EN::MED_NO_INTERLACE); // get pointer to the field's values
double totVol=0.0;
const double* p_vol=vol;
p_field_size=_getFieldSize(); // we calculate the volume [PROVISOIRE, en attendant l'implémentation dans mesh]
// get pointer to the element's volumes. MED_FULL_INTERLACE is the default mode for p_field_size
- const double* vol=p_field_size->getValue(MED_FULL_INTERLACE);
- const T* value=getValueI( MED_NO_INTERLACE, component); // get pointer to the component's values
+ const double* vol=p_field_size->getValue(MED_EN::MED_FULL_INTERLACE);
+ const T* value=getValueI( MED_EN::MED_NO_INTERLACE, component); // get pointer to the component's values
const T* lastvalue=value+getNumberOfValues(); // pointing just after the end of column
double integrale=0.0;
p_field_size=_getFieldSize(); // we calculate the volume [PROVISOIRE, en attendant l'implémentation dans mesh]
// get pointer to the element's volumes. MED_FULL_INTERLACE is the default mode for p_field_size
- const double* vol=p_field_size->getValue(MED_FULL_INTERLACE);
+ const double* vol=p_field_size->getValue(MED_EN::MED_FULL_INTERLACE);
const double* lastvol=vol+getNumberOfValues(); // pointing just after the end of vol
- const T* value=getValue( MED_NO_INTERLACE); // get pointer to the field's values
+ const T* value=getValue( MED_EN::MED_NO_INTERLACE); // get pointer to the field's values
double totVol=0.0;
const double* p_vol=vol;
return integrale/totVol;
}
-
-
+/*! Return a new field (to deallocate with delete) lying on subSupport that is included by
+ * this->_support with corresponding values extracting from this->_value.
+ */
+template <class T> FIELD<T>* FIELD<T>::extract(const SUPPORT *subSupport) const throw (MEDEXCEPTION)
+{
+ if(!subSupport->belongsTo(*_support))
+ throw MEDEXCEPTION("FIELD<T>::extract : subSupport not included in this->_support !");
+ if(_support->isOnAllElements() && subSupport->isOnAllElements())
+ return new FIELD<T>(*this);
+ FIELD<T> *ret=new FIELD<T>(subSupport,_numberOfComponents,MED_EN::MED_FULL_INTERLACE);
+ if(!ret->_value)
+ throw MEDEXCEPTION("FIELD<T>::extract : unvalid support detected !");
+ T* valuesToSet=(T*)ret->_value->get(MED_EN::MED_FULL_INTERLACE);
+ int nbOfEltsSub=subSupport->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS);
+ const int *eltsSub=subSupport->getNumber(MED_EN::MED_ALL_ELEMENTS);
+ T* tempVals=new T[_numberOfComponents];
+ for(int i=0;i<nbOfEltsSub;i++)
+ {
+ if(!getValueOnElement(eltsSub[i],tempVals))
+ throw MEDEXCEPTION("Problem in belongsTo function !!!");
+ for(int j=0;j<_numberOfComponents;j++)
+ valuesToSet[i*_numberOfComponents+j]=tempVals[j];
+ }
+ delete [] tempVals;
+ ret->setValueType(_valueType);
+ ret->copyGlobalInfo(*this);
+ return ret;
+}
/*!
Constructor with parameters; the object is set via a file and its associated
_time = 0.0;
_orderNumber = orderNumber;
- current = addDriver(driverType,fileName,fieldDriverName,MED_LECT);
+ current = addDriver(driverType,fileName,fieldDriverName,MED_EN::MED_LECT);
// switch(driverType)
// {
}
try {
- _numberOfValues = _support->getNumberOfElements(MED_ALL_ELEMENTS);
+ _numberOfValues = _support->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS);
MESSAGE(LOC <<" : "<<_numberOfValues <<" et "<< NumberOfComponents);
_value = new MEDARRAY<T>(_numberOfComponents,_numberOfValues);
const string & driverName/*="Default Field Name"*/,
MED_EN::med_mode_acces access)
{
- const char * LOC = "FIELD<T>::addDriver(driverTypes driverType, const string & fileName=\"Default File Name.med\",const string & driverName=\"Default Field Name\,MED_EN::med_mode_acces access) : ";
+ const char * LOC = "FIELD<T>::addDriver(driverTypes driverType, const string & fileName=\"Default File Name.med\",const string & driverName=\"Default Field Name,MED_EN::med_mode_acces access) : ";
GENDRIVER * driver;
}
+/*!
+ Fills in already allocated retValues array the values related to eltIdInSup.
+ If the element does not exist in this->_support false is returned, true otherwise.
+ */
+template <class T> bool FIELD<T>::getValueOnElement(int eltIdInSup,T* retValues) const
+{
+ if(eltIdInSup<1)
+ return false;
+ if(_support->isOnAllElements())
+ {
+ int nbOfEltsThis=_support->getMesh()->getNumberOfElements(_support->getEntity(),MED_EN::MED_ALL_ELEMENTS);
+ if(eltIdInSup>nbOfEltsThis)
+ return false;
+ const T* valsThis=getValue(MED_EN::MED_FULL_INTERLACE);
+ for(int j=0;j<_numberOfComponents;j++)
+ retValues[j]=valsThis[(eltIdInSup-1)*_numberOfComponents+j];
+ return true;
+ }
+ else
+ {
+ int nbOfEltsThis=_support->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS);
+ const int *eltsThis=_support->getNumber(MED_EN::MED_ALL_ELEMENTS);
+ int iThis;
+ bool found=false;
+ for(iThis=0;iThis<nbOfEltsThis && !found;)
+ if(eltsThis[iThis]==eltIdInSup)
+ found=true;
+ else
+ iThis++;
+ if(!found)
+ return false;
+ const T* valsThis=getValue(MED_EN::MED_FULL_INTERLACE);
+ for(int j=0;j<_numberOfComponents;j++)
+ retValues[j]=valsThis[iThis*_numberOfComponents+j];
+ return true;
+ }
+}
+
/*!
\if developper
Destroy the MEDARRAY<T> in FIELD and put the new one without copy.
// 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))
+ if ((_support == (SUPPORT *) NULL) || (_numberOfComponents != 1) || (_valueType != MED_EN::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);
// 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))
+ if ((_support == (SUPPORT *) NULL) || (_numberOfComponents != 1) || (_valueType != MED_EN::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);
// 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))
+ if ((_support == (SUPPORT *) NULL) || (_numberOfComponents != 1) || (_valueType != MED_EN::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);
int dim_space = _support->getMesh()->getSpaceDimension();
- if ((_numberOfComponents != dim_space) || (_valueType != MED_REEL64))
+ if ((_numberOfComponents != dim_space) || (_valueType != MED_EN::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);
int dim_space = _support->getMesh()->getSpaceDimension();
- if ((_numberOfComponents != dim_space) || (_valueType != MED_REEL64))
+ if ((_numberOfComponents != dim_space) || (_valueType != MED_EN::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 array by using T_Analytic.
+ WARNING : "this" must have allocated its array by setting this->_support and this->_numberOfComponents properly.
+ Typically you should use it on a field built with constructor FIELD<T>::FIELD<T>(SUPPORT *,int nbOfComponents)
+ */
+template <class T>
+template<void T_Analytic(const double *,T*)>
+void FIELD<T>::fillFromAnalytic()
+{
+ int i,j;
+ MESH * mesh = _support->getMesh();
+ int spaceDim = mesh->getSpaceDimension();
+ const double * coord;
+ FIELD<double> * barycenterField=0;
+ double ** xyz=new double* [spaceDim];
+ bool deallocateXyz=false;
+ if(_support->getEntity()==MED_EN::MED_NODE)
+ {
+ if (_support->isOnAllElements())
+ {
+ coord=mesh->getCoordinates(MED_EN::MED_NO_INTERLACE);
+ for(i=0; i<spaceDim; i++)
+ xyz[i]=(double *)coord+i*_numberOfValues;
+ }
+ else
+ {
+ coord = mesh->getCoordinates(MED_EN::MED_FULL_INTERLACE);
+ const int * nodesNumber=_support->getNumber(MED_EN::MED_ALL_ELEMENTS);
+ for(i=0; i<spaceDim; i++)
+ xyz[i]=new double[_numberOfValues];
+ deallocateXyz=true;
+ for(i=0;i<_numberOfValues;i++)
+ {
+ for(j=0;j<spaceDim;j++)
+ xyz[j][i]=coord[(nodesNumber[i]-1)*spaceDim+j];
+ }
+ }
+ }
+ else
+ {
+ barycenterField = mesh->getBarycenter(_support);
+ coord=barycenterField->getValue(MED_EN::MED_NO_INTERLACE);
+ for(i=0; i<spaceDim; i++)
+ xyz[i]=(double *)(coord+i*_numberOfValues);
+ }
+ T* valsToSet=(T*)getValue(MED_EN::MED_FULL_INTERLACE);
+ double *temp=new double[spaceDim];
+ for(i=0;i<_numberOfValues;i++)
+ {
+ for(j=0;j<spaceDim;j++)
+ temp[j]=xyz[j][i];
+ T_Analytic(temp,valsToSet+i*_numberOfComponents);
+ }
+ delete [] temp;
+ if(barycenterField)
+ delete barycenterField;
+ if(deallocateXyz)
+ for(j=0;j<spaceDim;j++)
+ delete [] xyz[j];
+ delete [] xyz;
+}
+
}//End namespace MEDMEM
#endif /* FIELD_HXX */
--- /dev/null
+#ifndef MEDMEM_FORMULAE
+#define MEDMEM_FORMULAE
+
+#include <math.h>
+
+inline void CalculateBarycenterDyn(const double **pts, int nbPts, int dim, double *bary);
+
+inline double CalculateAreaForPolyg(const double **coords, int nbOfPtsInPolygs, int spaceDim);
+
+inline double CalculateAreaForTria(const double *p1, const double *p2, const double *p3,int spaceDim)
+{
+ if (spaceDim==2)
+ return (-((p2[0]-p1[0])*(p3[1]-p1[1]) - (p3[0]-p1[0])*(p2[1]-p1[1]))/2.0);
+ else
+ return (sqrt(((p2[1]-p1[1])*(p3[2]-p1[2]) - (p3[1]-p1[1])*(p2[2]-p1[2]))*
+ ((p2[1]-p1[1])*(p3[2]-p1[2]) - (p3[1]-p1[1])*(p2[2]-p1[2])) +
+ ((p3[0]-p1[0])*(p2[2]-p1[2]) - (p2[0]-p1[0])*(p3[2]-p1[2]))*
+ ((p3[0]-p1[0])*(p2[2]-p1[2]) - (p2[0]-p1[0])*(p3[2]-p1[2])) +
+ ((p2[0]-p1[0])*(p3[1]-p1[1]) - (p3[0]-p1[0])*(p2[1]-p1[1]))*
+ ((p2[0]-p1[0])*(p3[1]-p1[1]) - (p3[0]-p1[0])*(p2[1]-p1[1])))/2.0);
+}
+
+inline double CalculateAreaForQuad(const double *p1, const double *p2, const double *p3, const double *p4, int spaceDim)
+{
+ if (spaceDim==2)
+ {
+ double a1 = (p2[0]-p1[0])/4.0, a2 = (p2[1]-p1[1])/4.0;
+ double b1 = (p3[0]-p4[0])/4.0, b2 = (p3[1]-p4[1])/4.0;
+ double c1 = (p3[0]-p2[0])/4.0, c2 = (p3[1]-p2[1])/4.0;
+ double d1 = (p4[0]-p1[0])/4.0, d2 = (p4[1]-p1[1])/4.0;
+
+ return (- 4.0*(b1*c2 - c1*b2 + a1*c2 - c1*a2 + b1*d2 -
+ d1*b2 + a1*d2 - d1*a2));
+ }
+ else
+ {
+ return ((sqrt(((p2[1]-p1[1])*(p4[2]-p1[2]) - (p4[1]-p1[1])*(p2[2]-p1[2]))*
+ ((p2[1]-p1[1])*(p4[2]-p1[2]) - (p4[1]-p1[1])*(p2[2]-p1[2])) +
+ ((p4[0]-p1[0])*(p2[2]-p1[2]) - (p2[0]-p1[0])*(p4[2]-p1[2]))*
+ ((p4[0]-p1[0])*(p2[2]-p1[2]) - (p2[0]-p1[0])*(p4[2]-p1[2])) +
+ ((p2[0]-p1[0])*(p4[1]-p1[1]) - (p4[0]-p1[0])*(p2[1]-p1[1]))*
+ ((p2[0]-p1[0])*(p4[1]-p1[1]) - (p4[0]-p1[0])*(p2[1]-p1[1]))) +
+ sqrt(((p4[1]-p3[1])*(p2[2]-p3[2]) - (p2[1]-p3[1])*(p4[2]-p3[2]))*
+ ((p4[1]-p3[1])*(p2[2]-p3[2]) - (p2[1]-p3[1])*(p4[2]-p3[2])) +
+ ((p2[0]-p3[0])*(p4[2]-p3[2]) - (p4[0]-p3[0])*(p2[2]-p3[2]))*
+ ((p2[0]-p3[0])*(p4[2]-p3[2]) - (p4[0]-p3[0])*(p2[2]-p3[2])) +
+ ((p4[0]-p3[0])*(p2[1]-p3[1]) - (p2[0]-p3[0])*(p4[1]-p3[1]))*
+ ((p4[0]-p3[0])*(p2[1]-p3[1]) - (p2[0]-p3[0])*(p4[1]-p3[1]))))/2.0);
+ }
+}
+
+inline void CalculateNormalForTria(const double *p1, const double *p2, const double *p3, double *normal)
+{
+ normal[0] = ((p2[1]-p1[1])*(p3[2]-p1[2]) - (p3[1]-p1[1])*(p2[2]-p1[2]))/2.0;
+ normal[1] = ((p3[0]-p1[0])*(p2[2]-p1[2]) - (p2[0]-p1[0])*(p3[2]-p1[2]))/2.0;
+ normal[2] = ((p2[0]-p1[0])*(p3[1]-p1[1]) - (p3[0]-p1[0])*(p2[1]-p1[1]))/2.0;
+}
+
+inline void CalculateNormalForQuad(const double *p1, const double *p2, const double *p3, const double *p4, double *normal)
+{
+ double xnormal1 = (p2[1]-p1[1])*(p4[2]-p1[2]) - (p4[1]-p1[1])*(p2[2]-p1[2]);
+ double xnormal2 = (p4[0]-p1[0])*(p2[2]-p1[2]) - (p2[0]-p1[0])*(p4[2]-p1[2]);
+ double xnormal3 = (p2[0]-p1[0])*(p4[1]-p1[1]) - (p4[0]-p1[0])*(p2[1]-p1[1]);
+ double xarea = sqrt(xnormal1*xnormal1 + xnormal2*xnormal2 + xnormal3*xnormal3);
+ xnormal1 = xnormal1/xarea;
+ xnormal2 = xnormal2/xarea;
+ xnormal3 = xnormal3/xarea;
+ xarea = CalculateAreaForQuad(p1,p2,p3,p4,3);
+ normal[0] = xnormal1*xarea ;
+ normal[1] = xnormal2*xarea ;
+ normal[2] = xnormal3*xarea ;
+}
+
+inline void CalculateNormalForPolyg(const double **coords, int nbOfPtsInPolygs, double *normal)
+{
+ double coordOfBary[3];
+ CalculateBarycenterDyn(coords,nbOfPtsInPolygs,3,coordOfBary);
+ double xnormal1 = (coords[0][1]-coords[1][1])*(coordOfBary[2]-coords[1][2])-(coords[0][2]-coords[1][2])*(coordOfBary[1]-coords[1][1]);
+ double xnormal2 = (coords[0][2]-coords[1][2])*(coordOfBary[0]-coords[1][0])-(coords[0][0]-coords[1][0])*(coordOfBary[2]-coords[1][2]);
+ double xnormal3 = (coords[0][0]-coords[1][0])*(coordOfBary[1]-coords[1][1])-(coords[0][1]-coords[1][1])*(coordOfBary[0]-coords[1][0]);
+ double xarea = sqrt(xnormal1*xnormal1 + xnormal2*xnormal2 + xnormal3*xnormal3);
+ xnormal1 = xnormal1/xarea;
+ xnormal2 = xnormal2/xarea;
+ xnormal3 = xnormal3/xarea;
+ xarea = CalculateAreaForPolyg(coords,nbOfPtsInPolygs,3);
+ normal[0] = xnormal1*xarea ;
+ normal[1] = xnormal2*xarea ;
+ normal[2] = xnormal3*xarea ;
+}
+
+inline double CalculateAreaForPolyg(const double **coords, int nbOfPtsInPolygs, int spaceDim)
+{
+ double coordOfBary[3];
+ CalculateBarycenterDyn(coords,nbOfPtsInPolygs,spaceDim,coordOfBary);
+ double ret=0.;
+ for(int i=0;i<nbOfPtsInPolygs;i++)
+ {
+ double tmp=CalculateAreaForTria(coords[i],coords[(i+1)%nbOfPtsInPolygs],coordOfBary,spaceDim);
+ ret+=tmp;
+ }
+ return ret;
+}
+
+inline double CalculateVolumeForTetra(const double *p1, const double *p2, const double *p3, const double *p4)
+{
+ return ((p3[0]-p1[0])*((p2[1]-p1[1])*(p4[2]-p1[2]) - (p2[2]-p1[2])*(p4[1]-p1[1])) -
+ (p2[0]-p1[0])*((p3[1]-p1[1])*(p4[2]-p1[2]) - (p3[2]-p1[2])*(p4[1]-p1[1])) +
+ (p4[0]-p1[0])*((p3[1]-p1[1])*(p2[2]-p1[2]) - (p3[2]-p1[2])*(p2[1]-p1[1])))/6.0;
+}
+
+inline double CalculateVolumeForPyra(const double *p1, const double *p2, const double *p3, const double *p4, const double *p5)
+{
+ return (((p3[0]-p1[0])*((p2[1]-p1[1])*(p5[2]-p1[2]) - (p2[2]-p1[2])*(p5[1]-p1[1])) -
+ (p2[0]-p1[0])*((p3[1]-p1[1])*(p5[2]-p1[2]) - (p3[2]-p1[2])*(p5[1]-p1[1])) +
+ (p5[0]-p1[0])*((p3[1]-p1[1])*(p2[2]-p1[2]) - (p3[2]-p1[2])*(p2[1]-p1[1]))) +
+ ((p4[0]-p1[0])*((p3[1]-p1[1])*(p5[2]-p1[2]) - (p3[2]-p1[2])*(p5[1]-p1[1])) -
+ (p3[0]-p1[0])*((p4[1]-p1[1])*(p5[2]-p1[2]) - (p4[2]-p1[2])*(p5[1]-p1[1])) +
+ (p5[0]-p1[0])*((p4[1]-p1[1])*(p3[2]-p1[2]) - (p4[2]-p1[2])*(p3[1]-p1[1])))
+ )/6.0;
+}
+
+inline double CalculateVolumeForPenta(const double *p1, const double *p2, const double *p3, const double *p4, const double *p5, const double *p6)
+{
+ double a1 = (p2[0]-p3[0])/2.0, a2 = (p2[1]-p3[1])/2.0, a3 = (p2[2]-p3[2])/2.0;
+ double b1 = (p5[0]-p6[0])/2.0, b2 = (p5[1]-p6[1])/2.0, b3 = (p5[2]-p6[2])/2.0;
+ double c1 = (p4[0]-p1[0])/2.0, c2 = (p4[1]-p1[1])/2.0, c3 = (p4[2]-p1[2])/2.0;
+ double d1 = (p5[0]-p2[0])/2.0, d2 = (p5[1]-p2[1])/2.0, d3 = (p5[2]-p2[2])/2.0;
+ double e1 = (p6[0]-p3[0])/2.0, e2 = (p6[1]-p3[1])/2.0, e3 = (p6[2]-p3[2])/2.0;
+ double f1 = (p1[0]-p3[0])/2.0, f2 = (p1[1]-p3[1])/2.0, f3 = (p1[2]-p3[2])/2.0;
+ double h1 = (p4[0]-p6[0])/2.0, h2 = (p4[1]-p6[1])/2.0, h3 = (p4[2]-p6[2])/2.0;
+
+ double A = a1*c2*f3 - a1*c3*f2 - a2*c1*f3 + a2*c3*f1 +
+ a3*c1*f2 - a3*c2*f1;
+ double B = b1*c2*h3 - b1*c3*h2 - b2*c1*h3 + b2*c3*h1 +
+ b3*c1*h2 - b3*c2*h1;
+ double C = (a1*c2*h3 + b1*c2*f3) - (a1*c3*h2 + b1*c3*f2) -
+ (a2*c1*h3 + b2*c1*f3) + (a2*c3*h1 + b2*c3*f1) +
+ (a3*c1*h2 + b3*c1*f2) - (a3*c2*h1 + b3*c2*f1);
+ double D = a1*d2*f3 - a1*d3*f2 - a2*d1*f3 + a2*d3*f1 +
+ a3*d1*f2 - a3*d2*f1;
+ double E = b1*d2*h3 - b1*d3*h2 - b2*d1*h3 + b2*d3*h1 +
+ b3*d1*h2 - b3*d2*h1;
+ double F = (a1*d2*h3 + b1*d2*f3) - (a1*d3*h2 + b1*d3*f2) -
+ (a2*d1*h3 + b2*d1*f3) + (a2*d3*h1 + b2*d3*f1) +
+ (a3*d1*h2 + b3*d1*f2) - (a3*d2*h1 + b3*d2*f1);
+ double G = a1*e2*f3 - a1*e3*f2 - a2*e1*f3 + a2*e3*f1 +
+ a3*e1*f2 - a3*e2*f1;
+ double H = b1*e2*h3 - b1*e3*h2 - b2*e1*h3 + b2*e3*h1 +
+ b3*e1*h2 - b3*e2*h1;
+ double P = (a1*e2*h3 + b1*e2*f3) - (a1*e3*h2 + b1*e3*f2) -
+ (a2*e1*h3 + b2*e1*f3) + (a2*e3*h1 + b2*e3*f1) +
+ (a3*e1*h2 + b3*e1*f2) - (a3*e2*h1 + b3*e2*f1);
+
+ return (-2.0*(2.0*(A + B + D + E + G + H) + C + F + P)/9.0);
+}
+
+inline double CalculateVolumeForHexa(const double *pt1, const double *pt2, const double *pt3, const double *pt4, const double *pt5, const double *pt6, const double *pt7, const double *pt8)
+{
+ double a1 = (pt3[0]-pt4[0])/8.0, a2 = (pt3[1]-pt4[1])/8.0, a3 = (pt3[2]-pt4[2])/8.0;
+ double b1 = (pt2[0]-pt1[0])/8.0, b2 = (pt2[1]-pt1[1])/8.0, b3 = (pt2[2]-pt1[2])/8.0;
+ double c1 = (pt7[0]-pt8[0])/8.0, c2 = (pt7[1]-pt8[1])/8.0, c3 = (pt7[2]-pt8[2])/8.0;
+ double d1 = (pt6[0]-pt5[0])/8.0, d2 = (pt6[1]-pt5[1])/8.0, d3 = (pt6[2]-pt5[2])/8.0;
+ double e1 = (pt3[0]-pt2[0])/8.0, e2 = (pt3[1]-pt2[1])/8.0, e3 = (pt3[2]-pt2[2])/8.0;
+ double f1 = (pt4[0]-pt1[0])/8.0, f2 = (pt4[1]-pt1[1])/8.0, f3 = (pt4[2]-pt1[2])/8.0;
+ double h1 = (pt7[0]-pt6[0])/8.0, h2 = (pt7[1]-pt6[1])/8.0, h3 = (pt7[2]-pt6[2])/8.0;
+ double p1 = (pt8[0]-pt5[0])/8.0, p2 = (pt8[1]-pt5[1])/8.0, p3 = (pt8[2]-pt5[2])/8.0;
+ double q1 = (pt3[0]-pt7[0])/8.0, q2 = (pt3[1]-pt7[1])/8.0, q3 = (pt3[2]-pt7[2])/8.0;
+ double r1 = (pt4[0]-pt8[0])/8.0, r2 = (pt4[1]-pt8[1])/8.0, r3 = (pt4[2]-pt8[2])/8.0;
+ double s1 = (pt2[0]-pt6[0])/8.0, s2 = (pt2[1]-pt6[1])/8.0, s3 = (pt2[2]-pt6[2])/8.0;
+ double t1 = (pt1[0]-pt5[0])/8.0, t2 = (pt1[1]-pt5[1])/8.0, t3 = (pt1[2]-pt5[2])/8.0;
+
+ double A = a1*e2*q3 - a1*e3*q2 - a2*e1*q3 + a2*e3*q1 +
+ a3*e1*q2 - a3*e2*q1;
+ double B = c1*h2*q3 - c1*h3*q2 - c2*h1*q3 + c2*h3*q1 +
+ c3*h1*q2 - c3*h2*q1;
+ double C = (a1*h2 + c1*e2)*q3 - (a1*h3 + c1*e3)*q2 -
+ (a2*h1 + c2*e1)*q3 + (a2*h3 + c2*e3)*q1 +
+ (a3*h1 + c3*e1)*q2 - (a3*h2 + c3*e2)*q1;
+ double D = b1*e2*s3 - b1*e3*s2 - b2*e1*s3 + b2*e3*s1 +
+ b3*e1*s2 - b3*e2*s1;
+ double E = d1*h2*s3 - d1*h3*s2 - d2*h1*s3 + d2*h3*s1 +
+ d3*h1*s2 - d3*h2*s1;
+ double F = (b1*h2 + d1*e2)*s3 - (b1*h3 + d1*e3)*s2 -
+ (b2*h1 + d2*e1)*s3 + (b2*h3 + d2*e3)*s1 +
+ (b3*h1 + d3*e1)*s2 - (b3*h2 + d3*e2)*s1;
+ double G = (a1*e2*s3 + b1*e2*q3) - (a1*e3*s2 + b1*e3*q2) -
+ (a2*e1*s3 + b2*e1*q3) + (a2*e3*s1 + b2*e3*q1) +
+ (a3*e1*s2 + b3*e1*q2) - (a3*e2*s1 + b3*e2*q1);
+ double H = (c1*h2*s3 + d1*h2*q3) - (c1*h3*s2 + d1*h3*q2) -
+ (c2*h1*s3 + d2*h1*q3) + (c2*h3*s1 + d2*h3*q1) +
+ (c3*h1*s2 + d3*h1*q2) - (c3*h2*s1 + d3*h2*q1);
+ double I = ((a1*h2 + c1*e2)*s3 + (b1*h2 + d1*e2)*q3) -
+ ((a1*h3 + c1*e3)*s2 + (b1*h3 + d1*e3)*q2) -
+ ((a2*h1 + c2*e1)*s3 + (b2*h1 + d2*e1)*q3) +
+ ((a2*h3 + c2*e3)*s1 + (b2*h3 + d2*e3)*q1) +
+ ((a3*h1 + c3*e1)*s2 + (b3*h1 + d3*e1)*q2) -
+ ((a3*h2 + c3*e2)*s1 + (b3*h2 + d3*e2)*q1);
+ double J = a1*f2*r3 - a1*f3*r2 - a2*f1*r3 + a2*f3*r1 +
+ a3*f1*r2 - a3*f2*r1;
+ double K = c1*p2*r3 - c1*p3*r2 - c2*p1*r3 + c2*p3*r1 +
+ c3*p1*r2 - c3*p2*r1;
+ double L = (a1*p2 + c1*f2)*r3 - (a1*p3 + c1*f3)*r2 -
+ (a2*p1 + c2*f1)*r3 + (a2*p3 + c2*f3)*r1 +
+ (a3*p1 + c3*f1)*r2 - (a3*p2 + c3*f2)*r1;
+ double M = b1*f2*t3 - b1*f3*t2 - b2*f1*t3 + b2*f3*t1 +
+ b3*f1*t2 - b3*f2*t1;
+ double N = d1*p2*t3 - d1*p3*t2 - d2*p1*t3 + d2*p3*t1 +
+ d3*p1*t2 - d3*p2*t1;
+ double O = (b1*p2 + d1*f2)*t3 - (b1*p3 + d1*f3)*t2 -
+ (b2*p1 + d2*f1)*t3 + (b2*p3 + d2*f3)*t1 +
+ (b3*p1 + d3*f1)*t2 - (b3*p2 + d3*f2)*t1;
+ double P = (a1*f2*t3 + b1*f2*r3) - (a1*f3*t2 + b1*f3*r2) -
+ (a2*f1*t3 + b2*f1*r3) + (a2*f3*t1 + b2*f3*r1) +
+ (a3*f1*t2 + b3*f1*r2) - (a3*f2*t1 + b3*f2*r1);
+ double Q = (c1*p2*t3 + d1*p2*r3) - (c1*p3*t2 + d1*p3*r2) -
+ (c2*p1*t3 + d2*p1*r3) + (c2*p3*t1 + d2*p3*r1) +
+ (c3*p1*t2 + d3*p1*r2) - (c3*p2*t1 + d3*p2*r1);
+ double R = ((a1*p2 + c1*f2)*t3 + (b1*p2 + d1*f2)*r3) -
+ ((a1*p3 + c1*f3)*t2 + (b1*p3 + d1*f3)*r2) -
+ ((a2*p1 + c2*f1)*t3 + (b2*p1 + d2*f1)*r3) +
+ ((a2*p3 + c2*f3)*t1 + (b2*p3 + d2*f3)*r1) +
+ ((a3*p1 + c3*f1)*t2 + (b3*p1 + d3*f1)*r2) -
+ ((a3*p2 + c3*f2)*t1 + (b3*p2 + d3*f2)*r1);
+ double S = (a1*e2*r3 + a1*f2*q3) - (a1*e3*r2 + a1*f3*q2) -
+ (a2*e1*r3 + a2*f1*q3) + (a2*e3*r1 + a2*f3*q1) +
+ (a3*e1*r2 + a3*f1*q2) - (a3*e2*r1 + a3*f2*q1);
+ double T = (c1*h2*r3 + c1*p2*q3) - (c1*h3*r2 + c1*p3*q2) -
+ (c2*h1*r3 + c2*p1*q3) + (c2*h3*r1 + c2*p3*q1) +
+ (c3*h1*r2 + c3*p1*q2) - (c3*h2*r1 + c3*p2*q1);
+ double U = ((a1*h2 + c1*e2)*r3 + (a1*p2 + c1*f2)*q3) -
+ ((a1*h3 + c1*e3)*r2 + (a1*p3 + c1*f3)*q2) -
+ ((a2*h1 + c2*e1)*r3 + (a2*p1 + c2*f1)*q3) +
+ ((a2*h3 + c2*e3)*r1 + (a2*p3 + c2*f3)*q1) +
+ ((a3*h1 + c3*e1)*r2 + (a3*p1 + c3*f1)*q2) -
+ ((a3*h2 + c3*e2)*r1 + (a3*p2 + c3*f2)*q1);
+ double V = (b1*e2*t3 + b1*f2*s3) - (b1*e3*t2 + b1*f3*s2) -
+ (b2*e1*t3 + b2*f1*s3) + (b2*e3*t1 + b2*f3*s1) +
+ (b3*e1*t2 + b3*f1*s2) - (b3*e2*t1 + b3*f2*s1);
+ double W = (d1*h2*t3 + d1*p2*s3) - (d1*h3*t2 + d1*p3*s2) -
+ (d2*h1*t3 + d2*p1*s3) + (d2*h3*t1 + d2*p3*s1) +
+ (d3*h1*t2 + d3*p1*s2) - (d3*h2*t1 + d3*p2*s1);
+ double X = ((b1*h2 + d1*e2)*t3 + (b1*p2 + d1*f2)*s3) -
+ ((b1*h3 + d1*e3)*t2 + (b1*p3 + d1*f3)*s2) -
+ ((b2*h1 + d2*e1)*t3 + (b2*p1 + d2*f1)*s3) +
+ ((b2*h3 + d2*e3)*t1 + (b2*p3 + d2*f3)*s1) +
+ ((b3*h1 + d3*e1)*t2 + (b3*p1 + d3*f1)*s2) -
+ ((b3*h2 + d3*e2)*t1 + (b3*p2 + d3*f2)*s1);
+ double Y = (a1*e2*t3 + a1*f2*s3 + b1*e2*r3 + b1*f2*q3) -
+ (a1*e3*t2 + a1*f3*s2 + b1*e3*r2 + b1*f3*q2) -
+ (a2*e1*t3 + a2*f1*s3 + b2*e1*r3 + b2*f1*q3) +
+ (a2*e3*t1 + a2*f3*s1 + b2*e3*r1 + b2*f3*q1) +
+ (a3*e1*t2 + a3*f1*s2 + b3*e1*r2 + b3*f1*q2) -
+ (a3*e2*t1 + a3*f2*s1 + b3*e2*r1 + b3*f2*q1);
+ double Z = (c1*h2*t3 + c1*p2*s3 + d1*h2*r3 + d1*p2*q3) -
+ (c1*h3*t2 + c1*p3*s2 + d1*h3*r2 + d1*p3*q2) -
+ (c2*h1*t3 + c2*p1*s3 + d2*h1*r3 + d2*p1*q3) +
+ (c2*h3*t1 + c2*p3*s1 + d2*h3*r1 + d2*p3*q1) +
+ (c3*h1*t2 + c3*p1*s2 + d3*h1*r2 + d3*p1*q2) -
+ (c3*h2*t1 + c3*p2*s1 + d3*h2*r1 + d3*p2*q1);
+ double AA = ((a1*h2 + c1*e2)*t3 + (a1*p2 + c1*f2)*s3 +
+ (b1*h2 + d1*e2)*r3 + (b1*p2 + d1*f2)*q3) -
+ ((a1*h3 + c1*e3)*t2 + (a1*p3 + c1*f3)*s2 +
+ (b1*h3 + d1*e3)*r2 + (b1*p3 + d1*f3)*q2) -
+ ((a2*h1 + c2*e1)*t3 + (a2*p1 + c2*f1)*s3 +
+ (b2*h1 + d2*e1)*r3 + (b2*p1 + d2*f1)*q3) +
+ ((a2*h3 + c2*e3)*t1 + (a2*p3 + c2*f3)*s1 +
+ (b2*h3 + d2*e3)*r1 + (b2*p3 + d2*f3)*q1) +
+ ((a3*h1 + c3*e1)*t2 + (a3*p1 + c3*f1)*s2 +
+ (b3*h1 + d3*e1)*r2 + (b3*p1 + d3*f1)*q2) -
+ ((a3*h2 + c3*e2)*t1 + (a3*p2 + c3*f2)*s1 +
+ (b3*h2 + d3*e2)*r1 + (b3*p2 + d3*f2)*q1);
+
+ return 64.0*(8.0*(A + B + D + E + J + K + M + N) +
+ 4.0*(C + F + G + H + L + O + P + Q + S + T +
+ V + W) + 2.0*(I + R + U + X + Y + Z) +
+ AA)/27.0;
+}
+
+inline double CalculateVolumeForPolyh(const double ***pts, const int *nbOfNodesPerFaces, int nbOfFaces, const double *bary)
+{
+ double volume=0.;
+ for(int i=0;i<nbOfFaces;i++)
+ {
+ double normal[3];
+ CalculateNormalForPolyg(pts[i],nbOfNodesPerFaces[i],normal);
+ double vecForAlt[3];
+ vecForAlt[0]=bary[0]-pts[i][0][0];
+ vecForAlt[1]=bary[1]-pts[i][0][1];
+ vecForAlt[2]=bary[2]-pts[i][0][2];
+ volume+=fabs(vecForAlt[0]*normal[0]+vecForAlt[1]*normal[1]+vecForAlt[2]*normal[2]);
+ }
+ return volume/3.;
+}
+
+template<int N>
+inline double addComponentsOfVec(const double **pts, int rk)
+{
+ return pts[N-1][rk]+addComponentsOfVec<N-1>(pts,rk);
+}
+
+template<>
+inline double addComponentsOfVec<1>(const double **pts, int rk)
+{
+ return pts[0][rk];
+}
+
+template<int N, int DIM>
+inline void CalculateBarycenter(const double **pts, double *bary)
+{
+ bary[DIM-1]=addComponentsOfVec<N>(pts,DIM-1)/N;
+ CalculateBarycenter<N,DIM-1>(pts,bary);
+}
+
+template<>
+inline void CalculateBarycenter<2,0>(const double **pts, double *bary) { }
+
+template<>
+inline void CalculateBarycenter<3,0>(const double **pts, double *bary) { }
+
+template<>
+inline void CalculateBarycenter<4,0>(const double **pts, double *bary) { }
+
+template<>
+inline void CalculateBarycenter<5,0>(const double **pts, double *bary) { }
+
+template<>
+inline void CalculateBarycenter<6,0>(const double **pts, double *bary) { }
+
+template<>
+inline void CalculateBarycenter<7,0>(const double **pts, double *bary) { }
+
+template<>
+inline void CalculateBarycenter<8,0>(const double **pts, double *bary) { }
+
+inline void CalculateBarycenterDyn(const double **pts, int nbPts, int dim, double *bary)
+{
+ for(int i=0;i<dim;i++)
+ {
+ double temp=0.;
+ for(int j=0;j<nbPts;j++)
+ {
+ temp+=pts[j][i];
+ }
+ bary[i]=temp/nbPts;
+ }
+}
+
+#endif
namespace MEDMEM {
/* Modify the following line to add a new driver type (step 1) */
-typedef enum { MED_DRIVER = 0, GIBI_DRIVER = 1, PORFLOW_DRIVER = 2, VTK_DRIVER = 254, NO_DRIVER = 255 } driverTypes;
+typedef enum { MED_DRIVER = 0, GIBI_DRIVER = 1, PORFLOW_DRIVER = 2, VTK_DRIVER = 254, ASCII_DRIVER = 3, NO_DRIVER = 255 } driverTypes;
class GENDRIVER {
protected :
#include <algorithm>
+#include <queue>
#include "MEDMEM_GibiMeshDriver.hxx"
#include "MEDMEM_DriversDef.hxx"
+#include "MEDMEM_Med.hxx"
#include "MEDMEM_Family.hxx"
+#include "MEDMEM_Field.hxx"
#include "MEDMEM_Group.hxx"
#include "MEDMEM_Coordinate.hxx"
#include "MEDMEM_Connectivity.hxx"
#include "MEDMEM_define.hxx"
#include "MEDMEM_DriverTools.hxx"
+#include <stdio.h>
+#include <fcntl.h>
+#ifdef WNT
+#include <io.h>
+#else
+#include <unistd.h>
+#endif
+
+#include <float.h>
+
/////
using namespace std;
using namespace MED_EN;
/////
+// Every memory allocation made in the MedDriver members function are desallocated in the Mesh destructor
+
/////
const size_t GIBI_MESH_DRIVER::nb_geometrie_gibi;
/*36*/ MED_NONE ,/*37*/ MED_NONE ,/*38*/ MED_NONE ,/*39*/ MED_NONE ,/*40*/ MED_NONE ,
/*41*/ MED_NONE ,/*42*/ MED_NONE ,/*43*/ MED_NONE ,/*44*/ MED_NONE ,/*45*/ MED_NONE ,
/*46*/ MED_NONE ,/*47*/ MED_NONE };
-/////
-// Every memory allocation made in the MedDriver members function are desallocated in the Mesh destructor
+//=======================================================================
+//function : gibi2medGeom
+//purpose :
+//=======================================================================
+
+medGeometryElement GIBI_MESH_DRIVER::gibi2medGeom( size_t gibiTypeNb )
+{
+ if ( gibiTypeNb < 1 || gibiTypeNb > 47 )
+ return MED_NONE;
+
+ return geomGIBItoMED[ gibiTypeNb - 1 ];
+}
+
+//=======================================================================
+//function : med2gibiGeom
+//purpose :
+//=======================================================================
+
+int GIBI_MESH_DRIVER::med2gibiGeom( medGeometryElement medGeomType )
+{
+ for ( int i = 0; i < nb_geometrie_gibi; i++ )
+ if ( geomGIBItoMED[ i ] == medGeomType )
+ return i + 1;
+
+ return -1;
+}
+
+//=======================================================================
+//function : getGroupId
+//purpose :
+//=======================================================================
+
+static int getGroupId(const vector<int>& support_ids, _intermediateMED* medi)
+{
+ int group_id = 0;
+ vector<int>::const_iterator sb = support_ids.begin(), se = support_ids.end();
+ if (support_ids.size() == 1 || // one or equal support ids
+ *std::max_element( sb, se ) == *std::min_element( sb, se ))
+ group_id = support_ids[0] - 1;
+ else {
+ // try to find an existing group with the same sub-groups
+ set<int> sup_set;
+ for ( ; sb != se; sb++ )
+ sup_set.insert( *sb );
+ for ( group_id = 0; group_id < medi->groupes.size(); ++group_id ) {
+ if (sup_set.size() == medi->groupes[ group_id ].groupes.size() &&
+ std::equal (sup_set.begin(), sup_set.end(),
+ medi->groupes[ group_id ].groupes.begin()))
+ break;
+ }
+ if ( group_id == medi->groupes.size() )
+ {
+ // no such a group, add a new one
+ medi->groupes.push_back( _groupe() );
+ _groupe& new_grp = medi->groupes.back();
+ //new_grp.nom = string( group_id % 10 + 1, 'G' );
+ new_grp.groupes.reserve( sup_set.size() );
+ for ( set<int>::iterator it = sup_set.begin(); it != sup_set.end(); it++ ) {
+ new_grp.groupes.push_back( *it );
+ //new_grp.nom += "_" + medi->groupes[ *it - 1 ].nom;
+ }
+ }
+ }
+ return group_id;
+}
+
+//=======================================================================
+//function : read
+//purpose :
+//=======================================================================
+
+#define GIBI_EQUAL(var_str, stat_str) \
+ (strncmp (var_str, stat_str, sizeof(stat_str)-1) == 0)
+#define DUMP_LINE_NB " on line " << _lineNb
+
+bool GIBI_MESH_RDONLY_DRIVER::readFile (_intermediateMED* medi, bool readFields )
+{
+ const char * LOC = "GIBI_MESH_RDONLY_DRIVER::readFile() : " ;
+ BEGIN_OF(LOC);
+
+ // LECTURE DES DONNEES DS FICHIER GIBI
+
+ enum Readable_Piles {
+ PILE_SOUS_MAILLAGE=1,
+ PILE_NODES_FIELD =2,
+ PILE_NOEUDS =32,
+ PILE_COORDONNEES =33,
+ PILE_FIELD =39,
+ PILE_LAST_READABLE=39
+ };
+ Readable_Piles readable_Piles [] = {
+ PILE_SOUS_MAILLAGE,
+ PILE_NODES_FIELD,
+ PILE_NOEUDS,
+ PILE_COORDONNEES,
+ PILE_FIELD,
+ PILE_LAST_READABLE
+ };
+ char* ligne; // pour lire une ligne
+ const char* enregistrement_type=" ENREGISTREMENT DE TYPE";
+ vector<int> numero_noeuds; // tableau de travail (indices)
+ set<int> donePiles; // already read piles
+ unsigned space_dimension = 0;
+
+ while ( getNextLine(ligne, false)) // boucle externe de recherche de "ENREGISTREMENT DE TYPE"
+ {
+ if ( !GIBI_EQUAL( ligne, enregistrement_type ))
+ continue; // "ENREGISTREMENT DE TYPE" non trouvé -> on lit la ligne suivante
+
+ // lecture du numéro d'enregistrement
+ int numero_enregistrement = atoi( ligne + strlen(enregistrement_type) + 1 );
+
+ enum { ENREG_TYPE_2=2, ENREG_TYPE_4=4}; // énumération des types d'enregistrement traités
+ int numero_pile, nb_objets_nommes, nb_objets, nb_indices;
+ vector<int> indices_objets_nommes;
+ vector<string> objets_nommes;
+
+ if (numero_enregistrement == ENREG_TYPE_4)
+ {
+ getNextLine(ligne);
+ const char* s = " NIVEAU 15 NIVEAU ERREUR 0 DIMENSION";
+ space_dimension = atoi( ligne + strlen( s ) + 1 );
+ if ( !GIBI_EQUAL( ligne, " NIVEAU" ) || space_dimension < 1 ) {
+ INFOS( " Could not read file: syntax error in type 4 record");
+ return false;
+ }
+ }
+ else if (numero_enregistrement == ENREG_TYPE_2 )
+ {
+ if ( space_dimension == 0 ) {
+ INFOS( "Missing ENREGISTREMENT DE TYPE 4");
+ return false;
+ }
+ // FORMAT(' PILE NUMERO',I4,'NBRE OBJETS NOMMES',I8,'NBRE OBJETS',I8)
+ getNextLine(ligne);
+ const char *s1 = " PILE NUMERO", *s2 = "NBRE OBJETS NOMMES", *s3 = "NBRE OBJETS";
+ if ( ! GIBI_EQUAL( ligne, s1 ) ) {
+ INFOS( " Could not read file: error in type 2 record. " << ligne);
+ return false;
+ }
+ ligne = ligne + strlen(s1);
+ numero_pile = atoi( ligne );
+ ligne = ligne + 4 + strlen(s2);
+ nb_objets_nommes = atoi( ligne );
+ ligne = ligne + 8 + strlen(s3);
+ nb_objets = atoi( ligne );
+ if ( nb_objets_nommes<0 || nb_objets<0 ) {
+ INFOS(" Could not read file: " << nb_objets << " " <<nb_objets_nommes);
+ return false;
+ }
+ if ( !donePiles.insert( numero_pile ).second ) // piles may repeat
+ continue;
+
+ if ( numero_pile > PILE_LAST_READABLE )
+ break; // stop file reading
+
+ // skip not readable piles
+ int i = -1;
+ while ( readable_Piles[ ++i ] != PILE_LAST_READABLE )
+ if ( readable_Piles[ i ] == numero_pile )
+ break;
+ if ( readable_Piles[ i ] != numero_pile )
+ continue;
+
+ // lecture des objets nommés et de leurs indices
+ objets_nommes.resize(nb_objets_nommes);
+ indices_objets_nommes.resize(nb_objets_nommes);
+ for ( initNameReading( nb_objets_nommes ); more(); next() ) {
+ objets_nommes[ index() ] = getName();
+ }
+ for ( initIntReading( nb_objets_nommes ); more(); next() )
+ indices_objets_nommes[ index() ] = getInt();
+
+ // boucle interne : lecture de la pile
+
+ MESSAGE(LOC << "---- Traitement pile " << numero_pile);
+
+ // -----------------------------------
+ // MESH GROUPS
+ // -----------------------------------
+
+ if (numero_pile == PILE_SOUS_MAILLAGE )
+ {
+ map<int,int> strangeGroupType;
+ medi->groupes.reserve(nb_objets*2); // fields may add some groups
+ for (int objet=0; objet!=nb_objets; ++objet) // pour chaque groupe
+ {
+ initIntReading( 5 );
+ unsigned type_geom_castem = getInt(); next();
+ unsigned nb_sous_maillage = getInt(); next();
+ unsigned nb_reference = getInt(); next();
+ unsigned nb_noeud = getInt(); next();
+ unsigned nb_elements = getInt();
+
+ // le cas type_geom_castem=0 correspond aux maillages composites
+ if (type_geom_castem<0) {
+ INFOS(" Error while reading file, bad geometric type:" << type_geom_castem);
+ return false;
+ }
+
+ medi->groupes.push_back(_groupe());
+ _groupe & groupe = medi->groupes.back();
+
+ // si le groupe se compose de sous-maillages (ie groupe composite)
+ if (type_geom_castem==0 && nb_sous_maillage>0)
+ {
+ // lecture des indices des sous-maillages, stockage.
+ // les mailles correspondant a ces sous_maillages seront inserees a la fin du case
+ groupe.groupes.resize( nb_sous_maillage );
+ for ( initIntReading( nb_sous_maillage ); more(); next() ) {
+ groupe.groupes[ index() ] = getInt();
+ }
+ if ( readFields )
+ std::sort( groupe.groupes.begin(), groupe.groupes.end() );
+ }
+ // lecture des references (non utilisé pour MED)
+ for ( i = 0; i < nb_reference; i += 10 ) {// FORMAT(10I8)
+ getNextLine(ligne);
+ }
+ // lecture des couleurs (non utilisé pour MED)
+ for ( i = 0; i < nb_elements; i += 10 ) {
+ getNextLine(ligne);
+ }
+ // not a composit group
+ if (type_geom_castem>0 && nb_sous_maillage==0)
+ {
+ medGeometryElement medType = gibi2medGeom(type_geom_castem);
+ bool goodType = ( medType!=MED_NONE );
+ if ( !goodType )
+ strangeGroupType.insert( make_pair( objet, type_geom_castem ));
+
+ pair<set<_maille>::iterator,bool> p;
+ pair<map<int,_noeud>::iterator,bool> p_no;
+ _noeud no;
+ no.coord.resize(space_dimension);
+ _maille ma( medType, nb_noeud );
+ ma.sommets.resize(nb_noeud);
+ if ( goodType )
+ groupe.mailles.resize( nb_elements );
+
+ // lecture pour chaque maille des sommets et insertions
+ initIntReading( nb_elements * nb_noeud );
+ if ( !goodType ) {
+ while ( more() )
+ next();
+ }
+ else {
+ for ( i = 0; i < nb_elements; ++i )
+ {
+ for (unsigned n = 0; n < nb_noeud; ++n, next() )
+ {
+ if ( !more() ) {
+ INFOS( " Error while reading elem nodes ");
+ return false;
+ }
+ no.number = getInt();
+ p_no=medi->points.insert(make_pair(no.number, no));
+ ma.sommets[n]=p_no.first;
+ }
+ p=medi->maillage.insert(ma);
+ groupe.mailles[i] = p.first; // on stocke dans le groupe un iterateur sur la maille
+ }
+ }
+ }
+ } // loop on groups
+
+ // set group names
+ for (i=0; i!=nb_objets_nommes; ++i) {
+ int grpID = indices_objets_nommes[i];
+ _groupe & grp = medi->groupes[ grpID-1 ];
+ if ( !grp.nom.empty() ) // a group has several names
+ { // create a group with subgroup grp and named grp.nom
+ medi->groupes.push_back(_groupe());
+ medi->groupes.back().groupes.push_back( grpID );
+ medi->groupes.back().nom = grp.nom;
+ }
+ grp.nom=objets_nommes[i];
+ map<int,int>::iterator it = strangeGroupType.find( grpID - 1 );
+ if ( it != strangeGroupType.end() ) {
+ //INFOS( "Skip " << grp.nom << " of not supported CASTEM type: " << it->second );
+ }
+ }
+
+ }// Fin case PILE_SOUS_MAILLAGE
+
+ // ---------------------------------
+ // NODES
+ // ---------------------------------
+
+ else if ( numero_pile == PILE_NOEUDS )
+ {
+ getNextLine( ligne );
+ std::vector<int> place_noeuds;
+ nb_indices = atoi ( ligne );
+ if (nb_indices != nb_objets)
+ {
+ INFOS("Erreur de lecture dans enregistrement de pile " << PILE_NOEUDS);
+ return false;
+ }
+
+ place_noeuds.resize(nb_objets);
+ for ( initIntReading( nb_objets ); more(); next() )
+ place_noeuds[ index() ] = getInt();
+ int max=(* std::max_element(place_noeuds.begin(),place_noeuds.end()));
+
+ // numero_noeuds contient pour chacun des max noeuds qu'on va lire dans le case PILE_COORDONNEES
+ // son indice dans la connectivite du maillage. Cet indice correspond egalement a la cle du map
+ // medi->points ou l'on stocke les noeuds.
+ numero_noeuds.resize(max,-1);
+ for (unsigned i=0; i!=place_noeuds.size(); ++i)
+ numero_noeuds[place_noeuds[i]-1]=i+1;
+ }
+
+ // ---------------------------------------
+ // COORDINATES
+ // ---------------------------------------
+
+ else if ( numero_pile == PILE_COORDONNEES )
+ {
+ getNextLine( ligne );
+ unsigned nb_reels = atoi( ligne );
+ // PROVISOIRE : certains fichier gibi n`ont
+ if (nb_reels < numero_noeuds.size()*(space_dimension)) {
+ INFOS("Erreur de lecture dans enregistrement de pile " << PILE_COORDONNEES);
+ return false;
+ }
+ initDoubleReading( nb_reels );
+ map< int, _noeud >::iterator pIt;
+ for (unsigned i=0; i!=numero_noeuds.size(); ++i)
+ {
+ // si le noeud est utilisé dans le maillage,
+ //on lit ses coordonnées et on les stocke dans la structure
+ if (( numero_noeuds[i] != -1 ) &&
+ (( pIt = medi->points.find(numero_noeuds[i])) != medi->points.end()))
+ {
+ for (unsigned j=0; j!=space_dimension; ++j, next())
+ pIt->second.coord[j] = getDouble();
+ next(); // on ne conserve pas la densite
+ }
+ else // sinon, on passe au noeud suivant
+ {
+ for (unsigned j=0; j!=space_dimension+1; ++j)
+ next();
+ }
+ }
+ }
+
+ // ---------------------------------------
+ // NODE FIELDS
+ // ---------------------------------------
+
+ else if ( numero_pile == PILE_NODES_FIELD && readFields )
+ {
+ vector< _fieldBase* > fields( nb_objets );
+ for (int objet=0; objet!=nb_objets; ++objet) // pour chaque field
+ {
+ initIntReading( 4 ); // nb subcomponents, nb components, IFOUR, nb attributes
+ int i_sub, nb_sub = getInt(); next();
+ int i_comp, nb_comp = getInt(); next(); next();
+ int nb_attr = getInt();
+ if ( nb_sub < 0 || nb_comp < 0 ) {
+ INFOS("Error of field reading: wrong nb of components "
+ << nb_sub << " " << nb_comp << DUMP_LINE_NB);
+ return false;
+ }
+ _field<double>* fdouble = 0;
+ if ( nb_sub > 0 && nb_comp > 0 ) {
+ fdouble = new _field<double>(MED_REEL64);
+ medi->fields.push_back( fdouble );
+ fdouble->nb_subcomponents = nb_sub;
+ fdouble->nb_components = nb_comp;
+ fdouble->comp_names.resize( nb_comp );
+ }
+ fields[ objet ] = fdouble;
+
+ // loop on subcomponents of a field, each of which refers to
+ // a certain support and has the same number of components
+ vector<int> support_ids( nb_sub );
+ vector<int> nb_values( nb_sub );
+ vector<string> comp_names( nb_comp );
+ initIntReading( nb_sub * 3 );
+ for ( i_sub = 0; i_sub < nb_sub; ++i_sub )
+ {
+ support_ids[ i_sub ] = -getInt(); next(); // reference to support
+ if ( support_ids[ i_sub ] < 1 || support_ids[ i_sub ] > medi->groupes.size() ) {
+ INFOS("Error of field reading: wrong mesh reference "<< support_ids[ i_sub ]);
+ return false;
+ }
+ nb_values[ i_sub ] = getInt(); next(); // nb points
+ if ( nb_values[ i_sub ] < 0 ) {
+ INFOS(" Wrong nb of points: " << nb_values[ i_sub ] );
+ return false;
+ }
+ next(); // skip nb of comp names equal to nb_comp
+ }
+ initNameReading( nb_sub * nb_comp, 4 );
+ for ( i_sub = 0; i_sub < nb_sub; ++i_sub )
+ {
+ for ( i_comp = 0; i_comp < nb_comp; ++i_comp, next() ) {
+ ASSERT( more() );
+ fdouble->comp_names[ i_comp ] = getName();// component names
+ }
+ }
+
+ for ( initIntReading( nb_sub ); more(); next() )// nb harmonics ( ignored )
+ ;
+
+ getNextLine( ligne ); // TYPE ( ignored )
+ getNextLine( ligne ); // TITRE ( ignored )
+ for ( initIntReading( nb_attr ); more(); next() ) // attributes ( ignored )
+ ;
+
+ for ( i_sub = 0; i_sub < nb_sub; ++i_sub )
+ {
+ // loop on components: read values
+ initDoubleReading( nb_values[ i_sub ] * nb_comp );
+ for ( i_comp = 0; i_comp < nb_comp; ++i_comp ) {
+ vector<double> & vals =
+ fdouble->addComponent( support_ids[ i_sub ], nb_values[ i_sub ] );
+ for ( int i = 0; more() && i < nb_values[ i_sub ]; next(), ++i ) {
+ vals[ i ] = getDouble();
+ }
+ }
+ } // loop on subcomponents of a field
+
+ // supporting group id
+ if ( fdouble )
+ fdouble->group_id = getGroupId( support_ids, medi );
+
+ } // end loop on field objects
+
+ // set field names
+ for ( i = 0; i < nb_objets_nommes; ++i ) {
+ int fieldIndex = indices_objets_nommes[ i ];
+ if ( fields[ fieldIndex - 1 ] )
+ fields[ fieldIndex - 1 ]->name = objets_nommes[ i ];
+ }
+
+ } // Fin numero_pile == PILE_NODES_FIELD
+
+ // -------------------------------------------------
+ // FIELDS
+ // -------------------------------------------------
+
+ else if ( numero_pile == PILE_FIELD && readFields )
+ {
+ vector< _fieldBase* > fields( nb_objets, (_fieldBase*)NULL );
+ for (int objet=0; objet!=nb_objets; ++objet) // pour chaque field
+ {
+ initIntReading( 1 );
+ int i_sub, nb_sub = getInt(); // <nb_sub> -1 6 <title length>
+ if ( nb_sub < 1 ) {
+ INFOS("Error of field reading: wrong nb of subcomponents " << nb_sub);
+ return false;
+ }
+ getNextLine( ligne ); // title
+ // look for a line starting with '-' : <reference to support>
+ do {
+ initIntReading( nb_sub * 9 );
+ } while ( getInt() >= 0 );
+
+ int i_comp, nb_comp = 0;
+ vector<int> support_ids( nb_sub );
+ for ( i_sub = 0; i_sub < nb_sub; ++i_sub )
+ {
+ support_ids[ i_sub ] = -getInt(); next(); // <reference to support>
+ next(); // skip <address>
+ nb_comp = getInt(); next(); // <nb of components in the field>
+ for ( i = 0; i < 6; ++i ) // 0 0 0 -1 0 2
+ next();
+ if ( support_ids[ i_sub ] < 1 || support_ids[ i_sub ] > medi->groupes.size() ) {
+ INFOS("Error of field reading: wrong mesh reference "<< support_ids[ i_sub ]);
+ return false;
+ }
+ if ( nb_comp < 1 ) {
+ INFOS("Error of field reading: wrong nb of components " << nb_comp);
+ return false;
+ }
+ }
+ for ( initNameReading( nb_sub, 17 ); more(); next() )
+ ; // dummy strings
+ for ( initNameReading( nb_sub ); more(); next() )
+ ; // dummy strings
+
+ // loop on subcomponents of a field, each of which refers to
+ // a certain support and has the same number of components
+ _field<double>* fdouble = 0;
+ _field<int>* fint = 0;
+ vector<string> comp_names( nb_comp ), comp_type( nb_comp );
+ for ( i_sub = 0; i_sub < nb_sub; ++ i_sub )
+ {
+ getNextLine( ligne ); // skip nb_comp addresses of MELVAL structure
+
+ // component names
+ for ( initNameReading( nb_comp ); more(); next() )
+ comp_names[ index() ] = getName();
+
+ // component type
+ for ( initNameReading( nb_comp, 17 ); more(); next() ) { // 17 is name width
+ comp_type[ index() ] = getName();
+ // component types must be the same
+ if ( index() > 0 && comp_type[ index() ] != comp_type[ index() - 1] ) {
+ INFOS( "Error of field reading: diff component types <"
+ << comp_type[ index() ] << "> != <" << comp_type[ index() - 1 ] << ">");
+ return false;
+ }
+ }
+ // now type is known, create a field
+ bool isReal = ( comp_type[0] == "REAL*8" );
+ if ( !fdouble && !fint ) {
+ _fieldBase * fbase;
+ if ( !isReal ) {
+ fbase = fint = new _field<int>(MED_INT32);
+ INFOS( "Warning: read NOT REAL field, type <" << comp_type[0] << ">"
+ << DUMP_LINE_NB);
+ }
+ else
+ fbase = fdouble = new _field<double>(MED_REEL64);
+ medi->fields.push_back( fbase ); // medi->fields is a std::list
+ fields[ objet ] = fbase;
+ fbase->nb_subcomponents = nb_sub;
+ fbase->nb_components = nb_comp;
+ fbase->comp_names = comp_names;
+ fbase->group_id = getGroupId( support_ids, medi );
+ }
+
+ // loop on components: read values
+ for ( i_comp = 0; i_comp < nb_comp; ++i_comp ) {
+ // nb of values
+ initIntReading( 2 );
+ int nb_val_by_elem = getInt(); next();
+ int nb_values = getInt();
+ if ( nb_val_by_elem != 1 ) {
+ INFOS("Error of field reading: nb of values by element "
+ << " != 1 : " << nb_val_by_elem << DUMP_LINE_NB );
+ return false;
+ }
+ if ( isReal ) {
+ vector<double> & vals =
+ fdouble->addComponent( support_ids[ i_sub ], nb_values );
+ for ( initDoubleReading( nb_values ); more(); next()) {
+ vals[ index() ] = getDouble();
+ }
+ }
+ else {
+ vector<int> & vals =
+ fint->addComponent( support_ids[ i_sub ], nb_values );
+ for ( initIntReading( nb_values ); more(); next() ) {
+ vals[ index() ] = getInt();
+ }
+ }
+ }
+ } // loop on subcomponents of a field
+
+ } // end loop on field objects
+
+ // set field names
+ for ( i = 0; i < nb_objets_nommes; ++i ) {
+ int fieldIndex = indices_objets_nommes[ i ];
+ fields[ fieldIndex - 1 ]->name = objets_nommes[ i ];
+ }
+
+ } // numero_pile == PILE_FIELD && readFields
+
+ else if ( numero_pile >= PILE_LAST_READABLE )
+ break; // stop file reading
+
+ } // Fin case ENREG_TYPE_2
+ } // fin de la boucle while de lecture externe
+
+ // check if all needed piles present
+ if ( donePiles.find( PILE_SOUS_MAILLAGE ) != donePiles.end() )
+ {
+ if (donePiles.find( PILE_NOEUDS ) == donePiles.end() ) {
+ INFOS( " Missing pile " << PILE_NOEUDS );
+ return false;
+ }
+ if (donePiles.find( PILE_COORDONNEES ) == donePiles.end()) {
+ INFOS( " Missing pile " << PILE_COORDONNEES );
+ return false;
+ }
+ }
+
+ END_OF(LOC);
+ return true;
+}
GIBI_MESH_DRIVER::GIBI_MESH_DRIVER():
- GENDRIVER(),
- _ptrMesh(( MESH *)MED_NULL),
- // A VOIR _medIdt(MED_INVALID),
- _meshName("")
+ GENDRIVER(),
+ _ptrMesh(( MESH *)MED_NULL),
+ // A VOIR _medIdt(MED_INVALID),
+ _meshName("")
{
+ MESSAGE("GIBI_MESH_DRIVER()");
}
GIBI_MESH_DRIVER::GIBI_MESH_DRIVER(const string & fileName,
_ptrMesh(ptrMesh)
// A VOIR _medIdt(MED_INVALID),
{
+ MESSAGE( "GIBI_MESH_DRIVER(" << fileName <<","<<accessMode );
// _meshName=fileName.substr(0,fileName.rfind("."));
// mesh name construction from fileName
const string ext=".sauve"; // expected extension
// A VOIR _medIdt(MED_INVALID),
_meshName(driver._meshName)
{
+ MESSAGE("GIBI_MESH_DRIVER(const GIBI_MESH_DRIVER & driver)");
}
GIBI_MESH_DRIVER::~GIBI_MESH_DRIVER()
{
+ MESSAGE("~GIBI_MESH_DRIVER()");
}
+void GIBI_MESH_DRIVER::setMeshName(const string & meshName) { _meshName = meshName; };
+string GIBI_MESH_DRIVER::getMeshName() const { return _meshName; };
-void GIBI_MESH_DRIVER::open()
- throw (MEDEXCEPTION)
+
+//---------------------------------- RDONLY PART -------------------------------------------------------------
+
+GIBI_MESH_RDONLY_DRIVER::GIBI_MESH_RDONLY_DRIVER():
+ GIBI_MESH_DRIVER(),
+ _File (-1),_start(0L),_ptr (0L),_eptr (0L)
{
- const char * LOC = "GIBI_MESH_DRIVER::open()" ;
- BEGIN_OF(LOC);
+}
+GIBI_MESH_RDONLY_DRIVER::GIBI_MESH_RDONLY_DRIVER(const string & fileName,MESH * ptrMesh):
+ GIBI_MESH_DRIVER(fileName,ptrMesh,MED_RDONLY),
+ _File (-1),_start(0L),_ptr (0L),_eptr (0L)
+{
+ MESSAGE("GIBI_MESH_RDONLY_DRIVER::GIBI_MESH_RDONLY_DRIVER"
+ "(const string & fileName, MESH * ptrMesh) has been created, "
+ << fileName << ", " << MED_RDONLY);
+}
+GIBI_MESH_RDONLY_DRIVER::GIBI_MESH_RDONLY_DRIVER(const GIBI_MESH_RDONLY_DRIVER & driver):
+GIBI_MESH_DRIVER(driver)
+{
+}
+GIBI_MESH_RDONLY_DRIVER::~GIBI_MESH_RDONLY_DRIVER()
+{
+ BEGIN_OF( "~GIBI_MESH_RDONLY_DRIVER()");
+ if (_File >= 0)
+ {
+ ::close (_File);
+ if (_start != 0L)
+ delete [] _start;
+ }
+ MESSAGE("GIBI_MESH_RDONLY_DRIVER::~GIBI_MESH_RDONLY_DRIVER() has been destroyed");
+}
+GENDRIVER * GIBI_MESH_RDONLY_DRIVER::copy(void) const
+{
+ return new GIBI_MESH_RDONLY_DRIVER(*this);
+}
- _gibi.open(_fileName.c_str(), ios::in);
- if(_gibi)
- _status = MED_OPENED;
- else
- {
- _status = MED_CLOSED;
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Could not open file "<<_fileName<<" in mode ios::in"));
- }
+//=======================================================================
+//function : open
+//purpose :
+//=======================================================================
+
+const int GIBI_MaxOutputLen = 150;
+const int GIBI_BufferSize = 16184; // for non-stream input
+
+void GIBI_MESH_RDONLY_DRIVER::open()
+ // throw (MEDEXCEPTION)
+{
+ const char * LOC = "GIBI_MESH_RDONLY_DRIVER::open()" ;
+ BEGIN_OF(LOC);
+
+// MED_EN::med_mode_acces aMode = getAccessMode();
+// if ( aMode != MED_EN::MED_LECT && aMode != MED_EN::MED_REMP )
+// throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << " Bad file mode access ! " << aMode));
+
+#ifdef WNT
+ _File = ::_open (_fileName.c_str(), _O_RDONLY|_O_BINARY);
+#else
+ _File = ::open (_fileName.c_str(), O_RDONLY);
+#endif
+ if (_File >= 0)
+ {
+ _start = new char [GIBI_BufferSize];
+ _ptr = _start;
+ _eptr = _start;
+ _status = MED_OPENED;
+ _lineNb = 0;
+ }
+ else
+ {
+ _status = MED_CLOSED;
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Could not open file "<<_fileName
+ << " fd: " << _File));
+ }
END_OF(LOC);
}
-
-void GIBI_MESH_DRIVER::close()
- throw (MEDEXCEPTION)
+
+//=======================================================================
+//function : close
+//purpose :
+//=======================================================================
+
+void GIBI_MESH_RDONLY_DRIVER::close()
{
const char * LOC = "GIBI_MESH_DRIVER::close() " ;
BEGIN_OF(LOC);
if ( _status == MED_OPENED)
{
- _gibi.close();
- _status = MED_CLOSED;
+ if (_File >= 0)
+ {
+ ::close (_File);
+ if (_start != 0L)
+ delete [] _start;
+ _File = -1;
+ }
+ _status = MED_CLOSED;
}
END_OF(LOC);
}
-void GIBI_MESH_DRIVER::setMeshName(const string & meshName) { _meshName = meshName; };
-string GIBI_MESH_DRIVER::getMeshName() const { return _meshName; };
+//=======================================================================
+//function : getLine
+//purpose :
+//=======================================================================
-
-//---------------------------------- RDONLY PART -------------------------------------------------------------
-
-GIBI_MESH_RDONLY_DRIVER::GIBI_MESH_RDONLY_DRIVER(): GIBI_MESH_DRIVER()
+bool GIBI_MESH_RDONLY_DRIVER::getLine(char* & aLine)
{
+ bool aResult = true;
+ // Check the state of the buffer;
+ // if there is too little left, read the next portion of data
+ int nBytesRest = _eptr - _ptr;
+ if (nBytesRest < GIBI_MaxOutputLen)
+ {
+ if (nBytesRest > 0) {
+ memcpy (_start, _ptr, nBytesRest);
+ } else
+ nBytesRest = 0;
+ _ptr = _start;
+ const int nBytesRead = ::read (_File,
+ &_start [nBytesRest],
+ GIBI_BufferSize - nBytesRest);
+ nBytesRest += nBytesRead;
+ _eptr = &_start [nBytesRest];
+ }
+ // Check the buffer for the end-of-line
+ char * ptr = _ptr;
+ while (~0)
+ {
+ // Check for end-of-the-buffer, the ultimate criterion for termination
+ if (ptr >= _eptr)
+ {
+ if (nBytesRest <= 0)
+ aResult = false;
+ else
+ _eptr[-1] = '\0';
+ break;
+ }
+ // seek the line-feed character
+ if (ptr[0] == '\n')
+ {
+ if (ptr[-1] == '\r')
+ ptr[-1] = '\0';
+ ptr[0] = '\0';
+ ++ptr;
+ break;
+ }
+ ++ptr;
+ }
+ // Output the result
+ aLine = _ptr;
+ _ptr = ptr;
+ _lineNb++;
+
+ return aResult;
}
-GIBI_MESH_RDONLY_DRIVER::GIBI_MESH_RDONLY_DRIVER(const string & fileName,
- MESH * ptrMesh):
-GIBI_MESH_DRIVER(fileName,ptrMesh,MED_RDONLY)
-{
- MESSAGE("GIBI_MESH_RDONLY_DRIVER::GIBI_MESH_RDONLY_DRIVER(const string & fileName, MESH * ptrMesh) has been created");
-}
+//=======================================================================
+//function : init
+//purpose :
+//=======================================================================
- GIBI_MESH_RDONLY_DRIVER::GIBI_MESH_RDONLY_DRIVER(const GIBI_MESH_RDONLY_DRIVER & driver):
-GIBI_MESH_DRIVER(driver)
+void GIBI_MESH_RDONLY_DRIVER::init( int nbToRead, int nbPosInLine, int width, int shift )
{
+ _nbToRead = nbToRead;
+ _nbPosInLine = nbPosInLine;
+ _width = width;
+ _shift = shift;
+ _iPos = _iRead = 0;
+ if ( _nbToRead ) {
+ getNextLine( _curPos );
+ _curPos = _curPos + _shift;
+ }
+ else
+ _curPos = 0;
}
-GIBI_MESH_RDONLY_DRIVER::~GIBI_MESH_RDONLY_DRIVER()
+//=======================================================================
+//function : next
+//purpose : line getting
+//=======================================================================
+
+void GIBI_MESH_RDONLY_DRIVER::next()
{
- //MESSAGE("GIBI_MESH_RDONLY_DRIVER::~GIBI_MESH_RDONLY_DRIVER() has been destroyed");
+ if ( !more() ) throw MEDEXCEPTION(LOCALIZED("!more()"));
+ ++_iRead;
+ ++_iPos;
+ if ( _iRead < _nbToRead ) {
+ if ( _iPos >= _nbPosInLine ) {
+ getNextLine( _curPos );
+ _curPos = _curPos + _shift;
+ _iPos = 0;
+ }
+ else
+ _curPos = _curPos + _width + _shift;
+ }
+ else
+ _curPos = 0;
}
-
-GENDRIVER * GIBI_MESH_RDONLY_DRIVER::copy(void) const
+
+//=======================================================================
+//function : getName
+//purpose : names reading
+//=======================================================================
+
+string GIBI_MESH_RDONLY_DRIVER::getName() const
{
- return new GIBI_MESH_RDONLY_DRIVER(*this);
+ int len = _width;
+ while (( _curPos[len-1] == ' ' || _curPos[len-1] == 0) && len > 0 )
+ len--;
+ return string( _curPos, len );
}
+//=======================================================================
+//function : read
+//purpose :
+//=======================================================================
+
void GIBI_MESH_RDONLY_DRIVER::read(void) throw (MEDEXCEPTION)
{
- const char * LOC = "GIBI_MESH_RDONLY_DRIVER::read() : " ;
- BEGIN_OF(LOC);
-
- if (_status!=MED_OPENED)
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "The _idt of file " << _fileName << " is : "
- << " (the file is not opened)." )) ;
+ const char * LOC = "_GIBI_RDONLY_DRIVER::read() : " ;
+
+ if (_status!=MED_OPENED)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "The _idt of file " << _fileName << " is : "
+ << " (the file is not opened)." )) ;
+ if ( ! _ptrMesh->isEmpty() )
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Mesh object not empty : can't fill it!"));
+
+ _intermediateMED medi;
+ try {
+ if ( readFile( &medi, false )) {
+ // impression résultats
+ MESSAGE(LOC << "GIBI_MESH_RDONLY_DRIVER::read : RESULTATS STRUCTURE INTERMEDIAIRES : ");
+ MESSAGE(LOC << medi );
+
+ fillMesh( &medi );
+ }
+ }
+ catch (MEDEXCEPTION &ex)
+ {
+ INFOS( ex.what() );
+ }
- // LECTURE DES DONNEES DS FICHIER GIBI
+}
- _intermediateMED medi; // structure de données intermédiaire pour conversion gibi->med
- string buf_ligne; // pour lire une ligne
- const char* enregistrement_type="ENREGISTREMENT DE TYPE";
- std::vector<int> numero_noeuds; // tableau de travail (indices)
+//=======================================================================
+//function : getReverseVector
+//purpose :
+//=======================================================================
+static void getReverseVector (const medGeometryElement type,
+ vector<pair<int,int> > & swapVec )
+{
+ BEGIN_OF("void getReverseVector()");
+ swapVec.clear();
+
+ switch ( type ) {
+ case MED_TETRA4:
+ swapVec.resize(1);
+ swapVec[0] = make_pair( 1, 2 );
+ break;
+ case MED_PYRA5:
+ swapVec.resize(1);
+ swapVec[0] = make_pair( 1, 3 );
+ break;
+ case MED_PENTA6:
+ swapVec.resize(2);
+ swapVec[0] = make_pair( 1, 2 );
+ swapVec[1] = make_pair( 4, 5 );
+ break;
+ case MED_HEXA8:
+ swapVec.resize(2);
+ swapVec[0] = make_pair( 1, 3 );
+ swapVec[1] = make_pair( 5, 7 );
+ break;
+ case MED_TETRA10:
+ swapVec.resize(3);
+ swapVec[0] = make_pair( 1, 2 );
+ swapVec[1] = make_pair( 4, 5 );
+ swapVec[2] = make_pair( 8, 9 );
+ break;
+ case MED_PYRA13:
+ swapVec.resize(4);
+ swapVec[0] = make_pair( 1, 3 );
+ swapVec[1] = make_pair( 5, 8 );
+ swapVec[2] = make_pair( 6, 7 );
+ swapVec[3] = make_pair( 10, 12 );
+ break;
+ case MED_PENTA15:
+ swapVec.resize(4);
+ swapVec[0] = make_pair( 1, 2 );
+ swapVec[1] = make_pair( 4, 5 );
+ swapVec[2] = make_pair( 6, 8 );
+ swapVec[3] = make_pair( 9, 11 );
+ break;
+ case MED_HEXA20:
+ swapVec.resize(7);
+ swapVec[0] = make_pair( 1, 3 );
+ swapVec[1] = make_pair( 5, 7 );
+ swapVec[2] = make_pair( 8, 11 );
+ swapVec[3] = make_pair( 9, 10 );
+ swapVec[4] = make_pair( 12, 15 );
+ swapVec[5] = make_pair( 13, 14 );
+ swapVec[6] = make_pair( 17, 19 );
+ default:;
+ }
+ END_OF("void getReverseVector()");
+}
- while ( getline(_gibi, buf_ligne) ) // boucle externe de recherche de "ENREGISTREMENT DE TYPE"
- {
- string::size_type pos = buf_ligne.find(enregistrement_type);
- if ( pos==string::npos ){
- continue; // "ENREGISTREMENT DE TYPE" non trouvé -> on lit la ligne suivante
- }
- // lecture du numéro d'enregistrement
- int numero_enregistrement;
- istringstream buf(buf_ligne.c_str()+strlen(enregistrement_type)+1);
- buf >> numero_enregistrement;
-
- enum { ENREG_TYPE_2=2, ENREG_TYPE_4=4}; // énumération des types d'enregistrement traités
- int niveau, niveau_erreur;
- unsigned space_dimension,nb_reels;
- int numero_pile, nb_objets_nommes, nb_objets, nb_indices;
- string s1,s2,s3,s4,s5,s6,s7; // temporary strings
- int i1; //temporary int
- double d1; //temporary double
- vector<int> indices_objets_nommes;
- vector<string> objets_nommes;
-
- switch (numero_enregistrement)
- {
- case ENREG_TYPE_4:
- MESSAGE(LOC << "---- Traitement enregistrement de type 4");
- _gibi >> s1 >> niveau >> s2 >> s3 >> niveau_erreur >> s4 >> space_dimension;
- if ( !_gibi || s1!="NIVEAU" || s3!="ERREUR" || s4!="DIMENSION" ) // verification mots -cles
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << " Could not read file " << _fileName
- << " : syntax error in type 4 record"));
- break;
-
- case ENREG_TYPE_2:
- {
- MESSAGE(LOC << "---- Traitement enregistrement de type 2");
- _gibi >> s1 >> s2 >> numero_pile >> s3 >> s4 >> s5 >> nb_objets_nommes >> s6 >> s7 >> nb_objets;
- if ( !_gibi || s1!="PILE" || s2!="NUMERO" || s3!="NBRE" // verification mots -cles
- || s4!="OBJETS" || s5!="NOMMES" || s6!="NBRE"
- || s7!="OBJETS" || nb_objets_nommes<0 || nb_objets<0 )
- {
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << " Could not read file " << _fileName
- << " : error in type 2 record"));
- }
-
- // lecture des objets nommés et de leurs indices
- objets_nommes.resize(nb_objets_nommes);
- indices_objets_nommes.resize(nb_objets_nommes);
- for (int i=0; i!=nb_objets_nommes; ++i)
- _gibi >> objets_nommes[i];
-
- for (int i=0; i!=nb_objets_nommes; ++i)
- _gibi >> indices_objets_nommes[i];
-
- // boucle interne : lecture de la pile
- enum {PILE_SOUS_MAILLAGE=1, PILE_NOEUDS=32, PILE_COORDONNEES=33};
- switch(numero_pile)
- {
- case PILE_SOUS_MAILLAGE:
- {
- medi.groupes.reserve(nb_objets);
- for (int objet=0; objet!=nb_objets; ++objet) // pour chaque groupe
- {
- unsigned type_geom_castem, nb_reference,nb_noeud,nb_elements, nb_sous_maillage;
- _gibi >> type_geom_castem >> nb_sous_maillage >> nb_reference >> nb_noeud >> nb_elements;
-
- // le cas type_geom_castem=0 correspond aux maillages composites
- if (type_geom_castem<0 || (type_geom_castem>0 && geomGIBItoMED[type_geom_castem-1]==MED_NONE) )
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << " Error while reading file " << _fileName
- << "\nCastem geometric type " << type_geom_castem
- << " does not have a correspondant MED geometric type!" ));
-
- // lecture des references (non utilisé pour MED)
- for( unsigned i=0; i!=nb_reference; ++i)
- _gibi >> i1;
-
- // lecture des couleurs (non utilisé pour MED)
- for( unsigned i=0; i!=nb_elements; ++i)
- _gibi >> i1;
-
- _groupe groupe;
- // si le groupe se compose de sous-maillages (ie groupe composite)
- if (type_geom_castem==0 && nb_sous_maillage>0)
- {
- // lecture des indices des sous-maillages, stockage.
- // les mailles correspondant a ces sous_maillages seront inserees a la fin du case
- for (unsigned i=0; i!=nb_sous_maillage; ++i)
- {
- _gibi >> i1;
- groupe.groupes.push_back(i1);
- }
- }
- else
- {
- pair<set<_maille>::iterator,bool> p;
- pair<map<int,_noeud>::iterator,bool> p_no;
- _noeud no;
- no.coord.reserve(space_dimension);
- no.coord.resize(space_dimension);
- _maille ma(geomGIBItoMED[type_geom_castem-1], nb_noeud);
- ma.sommets.resize(nb_noeud);
-
- // lecture pour chaque maille des sommets et insertions
- for( unsigned i=0; i!=nb_elements; ++i)
- {
- for (unsigned n=0; n!=nb_noeud; ++n)
- {
- _gibi >> i1;
- no.number=i1;
- p_no=medi.points.insert(make_pair(i1, no));
- ma.sommets[n]=p_no.first;
- }
-
- p=medi.maillage.insert(ma);
- groupe.mailles.insert(p.first); // on stocke dans le groupe un iterateur sur la maille
-
-// cout << " " << p.second << ": ";
-// for (unsigned n=0; n!=nb_noeud; ++n)
-// cout << ma.sommets[n]->second.number << " ";
-// cout << endl;
-
- }
- }
- medi.groupes.push_back(groupe);
- }
-
- for (int i=0; i!=nb_objets_nommes; ++i)
- medi.groupes[indices_objets_nommes[i]-1].nom=objets_nommes[i];
-
- // scanne les groupes à la recherche de groupes composites
- for( std::vector<_groupe>::iterator i=medi.groupes.begin(); i!=medi.groupes.end(); ++i)
- {
- if( i->groupes.size() ) // le groupe i contient des sous-maillages
- {
- for( std::vector<int>::iterator j=i->groupes.begin(); j!=i->groupes.end(); ++j)
- {
- // pour chacun des sous-maillages j, on recupere les iterateurs *k sur les maille
- // contenues et on les insere dans le groupe i
- std::set< std::set<_maille, std::less<_maille>,
- std::allocator<_maille> >::iterator,
- _mailleIteratorCompare,
- std::allocator< std::set<_maille, std::less<_maille>,
- std::allocator<_maille> >::iterator> >::iterator k=medi.groupes[*j-1].mailles.begin();
- for( ; k!=medi.groupes[*j-1].mailles.end(); ++k)
- i->mailles.insert(*k);
- }
- i->groupes.clear(); // après avoir inséré leur mailles, on efface les groupes composites
- }
- }
-
- break;
- }// Fin case PILE_SOUS_MAILLAGE
-
- case PILE_NOEUDS:
- {
- std::vector<int> place_noeuds;
- _gibi >> nb_indices;
- if (nb_indices != nb_objets)
- {
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << " Could not read file " << _fileName
- << "Erreur de lecture dans enregistrement de type " << (int)ENREG_TYPE_2
- << " (pile " << (int)PILE_NOEUDS << ")" ));
- }
-
- place_noeuds.resize(nb_objets);
- for (unsigned i=0; i!=place_noeuds.size(); ++i)
- _gibi >> place_noeuds[i];
- int max=(* std::max_element(place_noeuds.begin(),place_noeuds.end()));
-
- // numero_noeuds contient pour chacun des max noeuds qu'on va lire dans le case PILE_COORDONNEES
- // son indice dans la connectivite du maillage. Cet indice correspond egalement a la cle du map
- // medi.points ou l'on stocke les noeuds.
- numero_noeuds.resize(max,-1);
- for (unsigned i=0; i!=place_noeuds.size(); ++i)
- numero_noeuds[place_noeuds[i]-1]=i+1;
- break;
- }
-
- case PILE_COORDONNEES:
- _gibi >> nb_reels;
- // PROVISOIRE : certains fichier gibi n'ont
- if (nb_reels < numero_noeuds.size()*(space_dimension))
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << " Could not read file " << _fileName
- << "Erreur de lecture dans enregistrement de type " << (int)ENREG_TYPE_2
- << " (pile " << (int)PILE_COORDONNEES << ")" ));
-
- for (unsigned i=0; i!=numero_noeuds.size(); ++i)
- {
- // si le noeud est utilisé dans le maillage, on lit ses coordonnées et on les stocke dans la structure
- if ( (numero_noeuds[i] != -1) && (medi.points.find(numero_noeuds[i])!=medi.points.end()) )
- {
- for (unsigned j=0; j!=space_dimension; ++j)
- _gibi >> medi.points[numero_noeuds[i]].coord[j];
- _gibi >> d1; // on ne conserve pas la densite
- }
- else // sinon, on passe au noeud suivant
- {
- for (unsigned j=0; j!=space_dimension+1; ++j)
- _gibi >> d1;
- }
- }
- break;
-
- } // Fin switch numero_pile
- break;
- } // Fin case ENREG_TYPE_2
- }
-
- } // fin de la boucle while de lecture externe
-
- // impression résultats
- MESSAGE(LOC << "GIBI_MESH_RDONLY_DRIVER::read : RESULTATS STRUCTURE INTERMEDIAIRES : ");
- MESSAGE(LOC << medi );
+//=======================================================================
+//function : orientElements
+//purpose :
+//=======================================================================
- // TRANSFORMATION EN STRUCTURES MED
- if ( ! _ptrMesh->isEmpty() )
- {
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Mesh object not empty : can't fill it!"));
- }
- else if ( medi.maillage.size()==0 || medi.groupes.size()==0 || medi.points.size()==0)
+static void orientElements( _intermediateMED& medi )
+{
+ MESSAGE("orientElements()");
+ set<_maille>::iterator elemIt = medi.maillage.begin();
+
+ if ( elemIt->sommets[0]->second.coord.size() == 2 ) { // space dimension
+
+ // --------------------------
+ // Orient 2D faces clockwise
+ // --------------------------
+
+ for ( ; elemIt != medi.maillage.end(); elemIt++ )
+ if ( elemIt->dimension() == 2 )
+ {
+ // look for index of the most left node
+ int iLeft = 0, iNode, nbNodes = elemIt->sommets.size();
+ double minX = elemIt->sommets[0]->second.coord[0];
+ for ( iNode = 1; iNode < nbNodes; ++iNode )
+ {
+ if ( minX > elemIt->sommets[ iNode ]->second.coord[ 0 ]) {
+ minX = elemIt->sommets[ iNode ]->second.coord[ 0 ];
+ iLeft = iNode;
+ }
+ }
+ // indeces of the nodes neighboring the most left one
+ int iPrev = ( iLeft - 1 < 0 ) ? nbNodes - 1 : iLeft - 1;
+ int iNext = ( iLeft + 1 == nbNodes ) ? 0 : iLeft + 1;
+ // find components of prev-left and left-next vectors
+ double xP = elemIt->sommets[ iPrev ]->second.coord[ 0 ];
+ double yP = elemIt->sommets[ iPrev ]->second.coord[ 1 ];
+ double xN = elemIt->sommets[ iNext ]->second.coord[ 0 ];
+ double yN = elemIt->sommets[ iNext ]->second.coord[ 1 ];
+ double xL = elemIt->sommets[ iLeft ]->second.coord[ 0 ];
+ double yL = elemIt->sommets[ iLeft ]->second.coord[ 1 ];
+ double xPL = xL - xP, yPL = yL - yP; // components of prev-left vector
+ double xLN = xN - xL, yLN = yN - yL; // components of left-next vector
+ // normalise y of the vectors
+ double modPL = sqrt ( xPL * xPL + yPL * yPL );
+ double modLN = sqrt ( xLN * xLN + yLN * yLN );
+ if ( modLN > DBL_MIN && modPL > DBL_MIN )
+ {
+ yPL /= modPL;
+ yLN /= modLN;
+ // summury direction of neighboring links must be positive
+ bool clockwise = ( yPL + yLN > 0 );
+ elemIt->reverse = ( !clockwise );
+ }
+ }
+ }
+ else {
+
+ int type = -100;
+ vector< pair<int,int> > swapVec;
+ for ( ; elemIt != medi.maillage.end(); elemIt++ ) {
+ if ( elemIt->dimension() == 3 )
+ {
+ // ---------------------------------------------------
+ // Orient volumes according to MED conventions:
+ // normal of a bottom (first) face should be downward
+ // ---------------------------------------------------
+
+ int nbBottomNodes = 0;
+ switch ( elemIt->geometricType ) {
+ case MED_TETRA4:
+ case MED_TETRA10:
+ case MED_PENTA6:
+ case MED_PENTA15:
+ nbBottomNodes = 3; break;
+ case MED_PYRA5:
+ case MED_PYRA13:
+ case MED_HEXA8:
+ case MED_HEXA20:
+ nbBottomNodes = 4; break;
+ default: continue;
+ }
+ // find a normal to the bottom face
+ const _noeud* n[4] = {
+ &elemIt->sommets[0]->second, // 3 bottom nodes
+ &elemIt->sommets[1]->second,
+ &elemIt->sommets[2]->second,
+ &elemIt->sommets[nbBottomNodes]->second };// a top node
+ double vec01 [3] = { // vector n[0]-n[1]
+ n[1]->coord[0] - n[0]->coord[0],
+ n[1]->coord[1] - n[0]->coord[1],
+ n[1]->coord[2] - n[0]->coord[2], };
+ double vec02 [3] = { // vector n[0]-n[2]
+ n[2]->coord[0] - n[0]->coord[0],
+ n[2]->coord[1] - n[0]->coord[1],
+ n[2]->coord[2] - n[0]->coord[2] };
+ double normal [3] = { // vec01 ^ vec02
+ vec01[1] * vec02[2] - vec01[2] * vec02[1],
+ vec01[2] * vec02[0] - vec01[0] * vec02[2],
+ vec01[0] * vec02[1] - vec01[1] * vec02[0] };
+ // check if the 102 angle is convex
+ if ( nbBottomNodes > 3 ) {
+ const _noeud* n3 = &elemIt->sommets[nbBottomNodes-1]->second;// last bottom node
+ double vec03 [3] = { // vector n[0]-n3
+ n3->coord[0] - n[0]->coord[0],
+ n3->coord[1] - n[0]->coord[1],
+ n3->coord[2] - n[0]->coord[2], };
+ if ( fabs( normal[0]+normal[1]+normal[2] ) <= DBL_MIN ) { // vec01 || vec02
+ normal[0] = vec01[1] * vec03[2] - vec01[2] * vec03[1]; // vec01 ^ vec03
+ normal[1] = vec01[2] * vec03[0] - vec01[0] * vec03[2];
+ normal[2] = vec01[0] * vec03[1] - vec01[1] * vec03[0];
+ }
+ else {
+ double vec [3] = { // normal ^ vec01
+ normal[1] * vec01[2] - normal[2] * vec01[1],
+ normal[2] * vec01[0] - normal[0] * vec01[2],
+ normal[0] * vec01[1] - normal[1] * vec01[0] };
+ double dot2 = vec[0]*vec03[0] + vec[1]*vec03[1] + vec[2]*vec03[2]; // vec*vec03
+ if ( dot2 < 0 ) { // concave -> reverse normal
+ normal[0] *= -1;
+ normal[1] *= -1;
+ normal[2] *= -1;
+ }
+ }
+ }
+ // direction from top to bottom
+ vector<double> tbDir(3);
+ tbDir[0] = n[0]->coord[0] - n[3]->coord[0];
+ tbDir[1] = n[0]->coord[1] - n[3]->coord[1];
+ tbDir[2] = n[0]->coord[2] - n[3]->coord[2];
+ // compare 2 directions: normal and top-bottom
+ double dot = normal[0]*tbDir[0] + normal[1]*tbDir[1] + normal[2]*tbDir[2];
+ bool reverse = ( dot < 0. );
+ if ( reverse ) {
+ if ( elemIt->geometricType != type ) {
+ type = elemIt->geometricType;
+ getReverseVector( type, swapVec );
+// INFOS("vec01: " <<vec01[0] << " " <<vec01[1] << " " << vec01[2]);
+// INFOS("vec02: " <<vec02[0] << " " <<vec02[1] << " " << vec02[2]);
+// INFOS("normal: " <<normal[0] << " " <<normal[1] << " " << normal[2]);
+// INFOS("tb: " << tbDir[0] << " " <<tbDir[1] << " " << tbDir[2]);
+// INFOS( *elemIt );
+// for ( vector< _maille::iter >::const_iterator si = elemIt->sommets.begin();
+// si != elemIt->sommets.end(); si++ )
+// INFOS( (*si)->second );
+ }
+ _maille* ma = (_maille*) & (*elemIt);
+ for ( int i = 0; i < swapVec.size(); ++i ) {
+ _maille::iter tmp = ma->sommets[ swapVec[i].first ];
+ ma->sommets[ swapVec[i].first ] = ma->sommets[ swapVec[i].second ];
+ ma->sommets[ swapVec[i].second ] = tmp;
+ }
+ }
+ } // dimension() == 3
+ } // loop on maillage
+
+ // --------------------------------------
+ // orient equally all connected 3D faces
+ // --------------------------------------
+
+ // fill map of links and their faces
+ set<const _maille*> faces;
+ map<const _maille*, _groupe*> fgm;
+ map<_link, list<const _maille*> > linkFacesMap;
+ map<_link, list<const _maille*> >::iterator lfIt, lfIt2;
+
+ medi.treatGroupes(); // erase groupes that wont be converted
+ for (unsigned int i=0; i!=medi.groupes.size(); ++i)
{
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << " Error while reading file " << _fileName
- << " The data read are not completed " ) ) ;
+ _groupe& grp = medi.groupes[i];
+ _groupe::mailleIter maIt=grp.mailles.begin();
+ if ( maIt==grp.mailles.end() || (*maIt)->dimension() != 2 )
+ continue;
+ for(; maIt!=grp.mailles.end(); ++maIt) {
+ if ( faces.insert( &(**maIt )).second ) {
+ for ( int j = 0; j < (*maIt)->sommets.size(); ++j )
+ linkFacesMap[ (*maIt)->link( j ) ].push_back( &(**maIt) );
+ fgm.insert( make_pair( &(**maIt), &grp ));
+ }
+ }
}
- else
+ // dump linkFacesMap
+// for ( lfIt = linkFacesMap.begin(); lfIt!=linkFacesMap.end(); lfIt++) {
+// cout<< "LINK: " << lfIt->first.first << "-" << lfIt->first.second << endl;
+// list<const _maille*> & fList = lfIt->second;
+// list<const _maille*>::iterator fIt = fList.begin();
+// for ( ; fIt != fList.end(); fIt++ )
+// cout << "\t" << **fIt << fgm[*fIt]->nom << endl;
+// }
+
+ // Each oriented link must appear in one face only, else a face is reversed.
+
+ queue<const _maille*> faceQueue; // the queue contains well oriented faces
+ // whose neighbors orientation is to be checked
+
+ bool manifold = true;
+ while ( !linkFacesMap.empty() )
{
- _ptrMesh->_name = _meshName;
- _ptrMesh->_spaceDimension = medi.points.begin()->second.coord.size();
- _ptrMesh->_meshDimension = medi.maillage.rbegin()->dimension();
- _ptrMesh->_numberOfNodes = medi.points.size();
- _ptrMesh->_isAGrid = 0;
- _ptrMesh->_coordinate = medi.getCoordinate();
-
- //Construction des groupes
- vector<GROUP *> groupCell, groupFace, groupEdge, groupNode;
- medi.getGroups(groupCell, groupFace, groupEdge, groupNode, _ptrMesh);
- _ptrMesh->_groupCell = groupCell;
- _ptrMesh->_groupFace = groupFace;
- _ptrMesh->_groupEdge = groupEdge;
- _ptrMesh->_groupNode = groupNode;
-
- // appele en dernier car cette fonction detruit le maillage intermediaire!
- _ptrMesh->_connectivity = medi.getConnectivity();
-
- // calcul de la connectivite d-1 complete, avec renumerotation des groupes
- //if (_ptrMesh->_spaceDimension==3)
- // _ptrMesh->_connectivity->updateGroup(_ptrMesh->_groupFace) ;
- //else if (_ptrMesh->_spaceDimension==2)
- // _ptrMesh->_connectivity->updateGroup(_ptrMesh->_groupEdge) ;
-
- // Creation des familles à partir des groupes
- // NC : Cet appel pourra être différé quand la gestion de la cohérence famille/groupes sera assurée
- _ptrMesh->createFamilies();
- }
+ if ( faceQueue.empty() ) {
+ ASSERT( !linkFacesMap.begin()->second.empty() );
+ faceQueue.push( linkFacesMap.begin()->second.front() );
+ }
+ while ( !faceQueue.empty() )
+ {
+ const _maille* face = faceQueue.front();
+ faceQueue.pop();
+
+ // loop on links of <face>
+ for ( int i = 0; i < face->sommets.size(); ++i ) {
+ _link link = face->link( i );
+ // find the neighbor faces
+ lfIt = linkFacesMap.find( link );
+ int nbFaceByLink = 0;
+ list< const _maille* > ml;
+ if ( lfIt != linkFacesMap.end() )
+ {
+ list<const _maille*> & fList = lfIt->second;
+ list<const _maille*>::iterator fIt = fList.begin();
+ ASSERT( fIt != fList.end() );
+ for ( ; fIt != fList.end(); fIt++, nbFaceByLink++ ) {
+ ml.push_back( *fIt );
+ if ( *fIt != face ) // wrongly oriented neighbor face
+ {
+ const _maille* badFace = *fIt;
+ // reverse and remove badFace from linkFacesMap
+ for ( int j = 0; j < badFace->sommets.size(); ++j ) {
+ _link badlink = badFace->link( j );
+ if ( badlink == link ) continue;
+ lfIt2 = linkFacesMap.find( badlink );
+ if ( lfIt2 != linkFacesMap.end() ) {
+ list<const _maille*> & ff = lfIt2->second;
+ ff.erase( find( ff.begin(), ff.end(), badFace ));
+ if ( ff.empty() )
+ linkFacesMap.erase( lfIt2 );
+ }
+ }
+ badFace->reverse = true; // reverse
+ //INFOS( "REVERSE " << *badFace );
+ faceQueue.push( badFace );
+ }
+ }
+ linkFacesMap.erase( lfIt );
+ }
+ // add good neighbors to the queue
+ _link revLink( link.second, link.first );
+ lfIt = linkFacesMap.find( revLink );
+ if ( lfIt != linkFacesMap.end() )
+ {
+ list<const _maille*> & fList = lfIt->second;
+ list<const _maille*>::iterator fIt = fList.begin();
+ for ( ; fIt != fList.end(); fIt++, nbFaceByLink++ ) {
+ ml.push_back( *fIt );
+ if ( *fIt != face )
+ faceQueue.push( *fIt );
+ }
+ linkFacesMap.erase( lfIt );
+ }
+ if ( nbFaceByLink > 2 ) {
+ if ( manifold ) {
+ list<const _maille*>::iterator i = ml.begin();
+ INFOS(nbFaceByLink << " faces by 1 link:");
+ for( ; i!= ml.end(); i++ ) {
+ INFOS("in object " << fgm[ *i ]->nom);
+ INFOS( **i );
+ }
+ }
+ manifold = false;
+ }
+ } // loop on links of the being checked face
+ } // loop on the face queue
+ } // while ( !linkFacesMap.empty() )
+
+ if ( !manifold )
+ INFOS(" -> Non manifold mesh, faces orientation may be incorrect");
+
+ } // space dimension == 3
+}
+//=======================================================================
+//function : fillMesh
+//purpose : load data from medi to mesh
+//=======================================================================
+void GIBI_MESH_RDONLY_DRIVER::fillMesh(_intermediateMED* _ptrMedi)
+{
+ const char * LOC = "GIBI_MESH_RDONLY_DRIVER::fillMesh(_intermediateMED* _ptrMedi) : " ;
+ BEGIN_OF(LOC);
- END_OF(LOC);
+ _ptrMesh->_name = _meshName;
+
+ if (_ptrMedi)
+ {
+ if (_ptrMedi->maillage.size()==0 ||
+ _ptrMedi->groupes.size()==0 ||
+ _ptrMedi->points.size()==0) {
+ INFOS(" Error while reading file: the data read are not completed " ) ;
+ return;
+ }
+ // fix element orientation
+ orientElements( *_ptrMedi );
+
+ _ptrMesh->_spaceDimension = _ptrMedi->points.begin()->second.coord.size();
+ _ptrMesh->_meshDimension = _ptrMedi->maillage.rbegin()->dimension();
+ _ptrMesh->_numberOfNodes = _ptrMedi->points.size();
+ _ptrMesh->_isAGrid = 0;
+ _ptrMesh->_coordinate = _ptrMedi->getCoordinate();
+
+ //Construction des groupes
+ _ptrMedi->getGroups(_ptrMesh->_groupCell,
+ _ptrMesh->_groupFace,
+ _ptrMesh->_groupEdge,
+ _ptrMesh->_groupNode, _ptrMesh);
+
+ _ptrMesh->_connectivity = _ptrMedi->getConnectivity();
+
+ // calcul de la connectivite d-1 complete, avec renumerotation des groupes
+ //if (_ptrMesh->_spaceDimension==3)
+ // _ptrMesh->_connectivity->updateGroup(_ptrMesh->_groupFace) ;
+ //else if (_ptrMesh->_spaceDimension==2)
+ // _ptrMesh->_connectivity->updateGroup(_ptrMesh->_groupEdge) ;
+
+ // Creation des familles à partir des groupes
+ // NC : Cet appel pourra être différé quand la gestion de la cohérence famille/groupes sera assurée
+ _ptrMesh->createFamilies();
+ // TAKE CARE OF ELEMENTS ORDER IN GROUPS AFTER THEIR SPLITING INTO FAMILIES !!!!
+ // _ptrMesh->createFamilies() breaks the order
+// _ptrMedi->getFamilies(_ptrMesh->_familyCell,
+// _ptrMesh->_familyFace,
+// _ptrMesh->_familyEdge,
+// _ptrMesh->_familyNode, _ptrMesh);
+
+ // add attributes to families
+ set<string> famNames;
+ for (medEntityMesh entity=MED_CELL; entity<MED_ALL_ENTITIES; ++entity)
+ {
+ int i, nb = _ptrMesh->getNumberOfFamilies(entity);
+ for ( i = 1; i <= nb; ++i ) {
+ FAMILY* f = const_cast<FAMILY*>( _ptrMesh->getFamily( entity, i ));
+ f->setNumberOfAttributes( 1 );
+ int* attIDs = new int[1];
+ attIDs[0] = 1;
+ f->setAttributesIdentifiers( attIDs );
+ int* attVals = new int[1];
+ attVals[0] = 1;
+ f->setAttributesValues( attVals );
+ string* attDescr = new string[1];
+ attDescr[0] = "med_family";
+ f->setAttributesDescriptions( attDescr );
+ // limit a name length
+ if ( f->getName().length() > 31 ) {
+ ostringstream name;
+ name << "FAM" << f->getIdentifier();
+ f->setName( name.str());
+ }
+ // check if family is on the whole mesh entity
+ if (_ptrMesh->getNumberOfElements( entity, MED_ALL_ELEMENTS ) ==
+ f->getNumberOfElements( MED_ALL_ELEMENTS ))
+ f->setAll( true );
+ }
+ // setAll() for groups
+ nb = _ptrMesh->getNumberOfGroups(entity);
+ for ( i = 1; i <= nb; ++i ) {
+ GROUP * g = const_cast<GROUP*>( _ptrMesh->getGroup( entity, i ));
+ if (_ptrMesh->getNumberOfElements( entity, MED_ALL_ELEMENTS ) ==
+ g->getNumberOfElements( MED_ALL_ELEMENTS ))
+ g->setAll( true );
+ }
+ }
+ }
+ END_OF(LOC);
}
void GIBI_MESH_RDONLY_DRIVER::write( void ) const
GIBI_MESH_WRONLY_DRIVER::GIBI_MESH_WRONLY_DRIVER():GIBI_MESH_DRIVER()
{
}
-
GIBI_MESH_WRONLY_DRIVER::GIBI_MESH_WRONLY_DRIVER(const string & fileName,
MESH * ptrMesh):
GIBI_MESH_DRIVER(fileName,ptrMesh,MED_WRONLY)
{
MESSAGE("GIBI_MESH_WRONLY_DRIVER::GIBI_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh) has been created");
}
-
GIBI_MESH_WRONLY_DRIVER::GIBI_MESH_WRONLY_DRIVER(const GIBI_MESH_WRONLY_DRIVER & driver):
GIBI_MESH_DRIVER(driver)
{
}
-
GIBI_MESH_WRONLY_DRIVER::~GIBI_MESH_WRONLY_DRIVER()
{
//MESSAGE("GIBI_MESH_WRONLY_DRIVER::GIBI_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh) has been destroyed");
}
-
GENDRIVER * GIBI_MESH_WRONLY_DRIVER::copy(void) const
{
return new GIBI_MESH_WRONLY_DRIVER(*this);
}
-
void GIBI_MESH_WRONLY_DRIVER::read (void)
throw (MEDEXCEPTION)
{
throw MEDEXCEPTION("GIBI_MESH_WRONLY_DRIVER::read : Can't read with a WRONLY driver !");
}
+//=======================================================================
+//function : open
+//purpose :
+//=======================================================================
+
+void GIBI_MESH_WRONLY_DRIVER::open()
+ // throw (MEDEXCEPTION)
+{
+ const char * LOC = "GIBI_MESH_DRIVER::open()" ;
+ BEGIN_OF(LOC);
+
+ MED_EN::med_mode_acces aMode = getAccessMode();
+ switch (aMode) {
+ case MED_EN::MED_REMP:
+ case MED_EN::MED_ECRI: // should never append !!
+ _gibi.open(_fileName.c_str(), ios::out);
+ break;
+ default:
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Bad file mode access ! " << aMode));
+ }
+ if (_gibi &&
+#ifdef WNT
+ _gibi.is_open()
+#else
+ _gibi.rdbuf()->is_open()
+#endif
+ )
+ _status = MED_OPENED;
+ else
+ {
+ _status = MED_CLOSED;
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Could not open file "<<_fileName));
+ }
+ END_OF(LOC);
+}
+
+//=======================================================================
+//function : close
+//purpose :
+//=======================================================================
+
+void GIBI_MESH_WRONLY_DRIVER::close()
+ // throw (MEDEXCEPTION)
+{
+ const char * LOC = "GIBI_MESH_DRIVER::close() " ;
+ BEGIN_OF(LOC);
+ if ( _status == MED_OPENED)
+ {
+ _gibi.close();
+ _status = MED_CLOSED;
+ }
+ END_OF(LOC);
+}
+
+//=======================================================================
+//function : write
+//purpose :
+//=======================================================================
+
void GIBI_MESH_WRONLY_DRIVER::write(void) const
throw (MEDEXCEPTION)
{
const char * LOC = "void GIBI_MESH_WRONLY_DRIVER::write(void) const : ";
BEGIN_OF(LOC);
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<< "Write Driver isn\'t implemented"));
+ // we are going to modify the _gibi field
+ GIBI_MESH_WRONLY_DRIVER * me = const_cast<GIBI_MESH_WRONLY_DRIVER *>(this);
+// try {
+ me->writeSupportsAndMesh();
+ me->writeLastRecord();
+// }
+// catch (MEDEXCEPTION &ex)
+// {
+// INFOS( ex.what() );
+// }
END_OF(LOC);
-}
+}
+
+//=======================================================================
+//function : getName
+//purpose : return cleaned up support name
+//=======================================================================
+
+static string cleanName( const string& theName )
+{
+ string name = theName;
+ if ( !name.empty() ) {
+ // find a name string end
+ int i, len = name.length();
+ for ( i = 0; i < len; ++i ) {
+ if ( name[i] == 0 )
+ break;
+ }
+ // cut off trailing white spaces
+ while ( i > 0 && name[i-1] == ' ' )
+ i--;
+ if ( i != len ) {
+ name = name.substr( 0, i );
+ len = i;
+ }
+ }
+ return name;
+}
+
+//=======================================================================
+//function : addSupport
+//purpose :
+//=======================================================================
+
+bool GIBI_MESH_WRONLY_DRIVER::addSupport( const SUPPORT * support )
+{
+ if ( !support )
+ return false;
+ map<const SUPPORT*,supportData>::iterator su = _supports.find( support );
+ if ( su != _supports.end() )
+ return ( su->second.getNumberOfTypes() > 0 );
+
+ if ( support->getMesh() != _ptrMesh )
+ throw MEDEXCEPTION(LOCALIZED(STRING("cant write support of other mesh" )));
+
+ // get sub-supports and define a support type name
+ string supType;
+ list<const SUPPORT*> sList;
+ const GROUP* group = dynamic_cast< const GROUP* >(support);
+ if ( group )
+ {
+ if ( group->getNumberOfTypes() > 0 || group->isOnAllElements() )
+ sList.push_back( group );
+ else {
+ int iFam, nbFam = group->getNumberOfFamilies();
+ for ( iFam = 1; iFam <= nbFam; ++iFam )
+ sList.push_back( group->getFamily( iFam ));
+ }
+ supType = "group";
+ }
+ else
+ {
+ sList.push_back( support );
+ supType = dynamic_cast< const FAMILY* >(support) ? "family" : "support";
+ }
+
+ supportData & data = _supports[ support ];
+ data._cleanName = cleanName( support->getName() );
+
+ // check if it is a writtable support, i.e.
+ // nodal connectivity for a support entity exists
+ medEntityMesh entity = support->getEntity();
+ if ( entity != MED_NODE && !_ptrMesh->existConnectivity( MED_NODAL, entity )) {
+ INFOS("Do not save " << supType << " of entity " << entity
+ << " named <" << data._cleanName << "> nodal connectivity not defined");
+ return false;
+ }
+
+ // fill supportData
+ list<const SUPPORT*>::iterator sIt = sList.begin();
+ for ( ; sIt != sList.end(); sIt++ )
+ {
+ bool onAll = (*sIt)->isOnAllElements();
+ int nbTypes = 0;
+ if ( !onAll )
+ nbTypes = (*sIt)->getNumberOfTypes();
+ else
+ nbTypes = _ptrMesh->getNumberOfTypes( entity );
+ if ( nbTypes == 0 )
+ continue;
+ const medGeometryElement* types = 0;
+ if ( !onAll )
+ types = (*sIt)->getTypes();
+ else if ( entity != MED_NODE )
+ types = _ptrMesh->getTypes( entity );
+ for ( int iType = 0; iType < nbTypes; ++iType )
+ {
+ medGeometryElement geomType = types ? types[ iType ] : MED_ALL_ELEMENTS;
+ const int * ptrElemIDs = 0;
+ int elemID1 = 0, nbElems = 0;
+ if ( onAll ) {
+ nbElems = _ptrMesh->getNumberOfElements( entity, geomType );
+ elemID1 = (entity == MED_NODE) ? 1 : _ptrMesh->getGlobalNumberingIndex (entity)[ iType ];
+ }
+ else {
+ nbElems = (*sIt)->getNumberOfElements( geomType );
+ ptrElemIDs = (*sIt)->getNumber( geomType );
+ }
+ if ( geomType == 0 )
+ geomType = MED_POINT1;
+
+ data.addTypeData( geomType, nbElems, ptrElemIDs, elemID1 );
+ }
+ }
+
+ if ( data.getNumberOfTypes() == 0 ) {
+ INFOS("Do not save " << supType << " of entity " << entity
+ << " named <" << data._cleanName << "> no geometric types");
+ return false;
+ }
+
+ return true;
+}
+
+//=======================================================================
+//function : getSupportIndex
+//purpose :
+//=======================================================================
+
+int GIBI_MESH_WRONLY_DRIVER::getSubMeshIdAndSize(const SUPPORT * support,
+ list<pair<int,int> > & idsAndSizes) const
+{
+ idsAndSizes.clear();
+ map<const SUPPORT*,supportData>::const_iterator su = _supports.find( support );
+ if ( su == _supports.end() )
+ return 0;
+
+ supportData * data = const_cast<supportData *>( & su->second );
+ int id = data->_id;
+ if ( data->getNumberObjects() > data->getNumberOfTypes() )
+ id++;
+ supportData::typeIterator tIt = data->_types.begin();
+ for ( ; tIt != data->_types.end(); ++tIt )
+ {
+ int size = 0;
+ list< typeData >& td = tIt->second;
+ list< typeData >::iterator tdIt = td.begin();
+ for ( ; tdIt != td.end(); ++tdIt )
+ size += tdIt->_nbElems;
+ idsAndSizes.push_back( make_pair( id++, size ));
+ }
+ return idsAndSizes.size();
+}
+
+// ============================================================
+// the class writes endl to the file as soon as <limit> fields
+// have been written after the last endl
+// ============================================================
+
+class TFieldCounter
+{
+ fstream& _file;
+ int _count, _limit;
+ public:
+ TFieldCounter(fstream& f, int limit=0): _file(f), _limit(limit) { init(); }
+ void init(int limit=0) // init, is done by stop() as well
+ { if (limit) _limit = limit; _count = 0; }
+ void operator++(int) // next
+ { if ( ++_count == _limit ) { _file << endl; init(); }}
+ void stop() // init() and write endl if there was no endl after the last written field
+ { if ( _count ) _file << endl; init(); }
+};
+
+//=======================================================================
+//function : writeElements
+//purpose : ptrElemIDs and elemID1 provide two alternative ways of giving
+// elements to write.
+// If elemSet != 0 then an element is
+// ( addElemInSet ? <written and added to elemSet> : <ignored if id is in elemSet>)
+//=======================================================================
+
+void GIBI_MESH_WRONLY_DRIVER::writeElements (medGeometryElement geomType,
+ list< typeData >& typeDataList,
+ const int * nodalConnect,
+ const int * nodalConnectIndex)
+{
+ // ITYPEL : type de l'鬩ment 1=point, 2=segment ?eux noeuds...
+ // NBSOUS : nombre de sous parties dans cet objet,
+ // une sous partie par type d'鬩ments le composant.
+ // NBREF : nombre de sous r馩rences. Une r馩rence est par exemple le contour
+ // NBNOEL : nombre de noeuds par 鬩ment
+ // NBEL : nombre d'鬩ments
+
+ int castemType = GIBI_MESH_DRIVER::med2gibiGeom( geomType );
+ char* zeroI8 = " 0"; // FORMAT(I8)
+ int nbElemNodes = geomType % 100;
+
+ // count total nb of elements
+ int nbElements = 0;
+ list< typeData >::iterator td = typeDataList.begin();
+ for ( ; td != typeDataList.end(); td++ )
+ nbElements += td->_nbElems;
+
+ _gibi << setw(8) << castemType << // ITYPE
+ zeroI8 << // NBSOUS
+ zeroI8 << // NBREF
+ setw(8) << nbElemNodes << // NBNOEL
+ setw(8) << nbElements << // NBEL
+ endl;
+
+ MESSAGE("writeElements(): geomType=" << geomType << " nbElements= " << nbElements)
+
+ // L 'enregistrement donnant le num? de la couleur des 鬩ments.
+ // * 8000 FORMAT(10I8)
+ TFieldCounter fcount( _gibi, 10 );
+ int iElem = 0;
+ for ( ; iElem < nbElements; ++iElem, fcount++ )
+ _gibi << zeroI8;
+ fcount.stop();
+
+ // Tableau des connectivit鳮 Description du premier 鬩ment puis du deuxi譥...
+ // ATTENTION il ne s'agit pas de la num?tation vraie,
+ // il faut la faire passer par le filtre du dernier tableau de la pile num? 32.
+ //int nbSkipped = 0;
+
+ for ( td = typeDataList.begin(); td != typeDataList.end(); td++ )
+ {
+ for ( int i = 0; i < td->_nbElems; i++ )
+ {
+ iElem = td->_ptrElemIDs ? td->_ptrElemIDs[ i ] : td->_elemID1 + i;
+ if ( geomType == MED_POINT1 )
+ {
+ _gibi << setw(8) << iElem;
+ fcount++;
+ }
+ else
+ {
+ int nodeId = nodalConnectIndex[ iElem - 1 ] - 1;
+ for ( int iNode = 0; iNode < nbElemNodes; ++iNode, fcount++ ) {
+ _gibi << setw(8) << nodalConnect[ nodeId++ ];
+ }
+ }
+ }
+ }
+
+ fcount.stop();
+}
+
+//=======================================================================
+//function : addName
+//purpose : make name uppercase and shorter than 9, add it to nameNbMap,
+// raise if not unique
+//=======================================================================
+
+void GIBI_MESH_WRONLY_DRIVER::addName(map<string,int>& nameMap,
+ string& theName,
+ int index,
+ string prefix)
+{
+ string name = cleanName( theName );
+ if ( !name.empty() ) {
+ int len = name.length();
+ if ( len > 8 )
+ throw MEDEXCEPTION(STRING("Can't write too long name: ") << name );
+
+ for ( int i = 0; i < len; ++i )
+ name[i] = toupper( name[i] );
+ if ( ! nameMap.insert( make_pair( name, index )).second )
+ throw MEDEXCEPTION(STRING("Can't write not unique name: ") << name );
+// bool ok = ( len <= 8 && len > 0 );
+// if ( ok ) {
+// for ( int i = 0; i < len; ++i )
+// name[i] = toupper( name[i] );
+// ok = nameMap.insert( make_pair( name, index )).second;
+// }
+// if ( !ok ) {
+// char *str=new char[ prefix.size() + 13 ];
+// int j = 1;
+// do {
+// sprintf( str, "%s_%d", prefix.c_str(), nameMap.size()+j );
+// ok = nameMap.insert( make_pair( str, index )).second;
+// j++;
+// } while ( !ok );
+// INFOS( "Save <" << name << "> as <" << str << ">");
+// delete [] str;
+// }
+ }
+}
+
+//=======================================================================
+//function : writeNames
+//purpose :
+//=======================================================================
+
+void GIBI_MESH_WRONLY_DRIVER::writeNames( map<string,int>& nameNbMap )
+{
+ // La pile num? 1 est celle des objets de type maillage.
+ // La ligne suivante donne le nom des objets maillages sauv鳮
+ // * 8001 FORMAT(8(1X,A8))
+ if ( !nameNbMap.empty() )
+ {
+ TFieldCounter fcount( _gibi, 8 );
+ _gibi << left;
+ map<string,int>::iterator nameNbIt = nameNbMap.begin();
+ for ( ; nameNbIt != nameNbMap.end(); nameNbIt++, fcount++ ) {
+ _gibi << " " << setw(8) << nameNbIt->first;
+ }
+ fcount.stop();
+ _gibi << right;
+ // La ligne suivante donne les num?s d'ordre, dans la pile,
+ // des objets nomm?cit?pr飩demment.
+ // * 8000 FORMAT(10I8)
+ nameNbIt = nameNbMap.begin();
+ for ( fcount.init(10); nameNbIt != nameNbMap.end(); nameNbIt++, fcount++ )
+ _gibi << setw(8) << nameNbIt->second;
+ fcount.stop();
+ }
+}
+
+//=======================================================================
+//function : writeSupportsAndMesh
+//purpose :
+//=======================================================================
+
+void GIBI_MESH_WRONLY_DRIVER::writeSupportsAndMesh()
+{
+ const char * LOC = "void GIBI_MESH_WRONLY_DRIVER::writeSupportsAndMesh() ";
+ BEGIN_OF(LOC);
+
+ if (_status!=MED_OPENED)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "file " << _fileName<< " is not opened." ));
+ if (!_ptrMesh)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "can't write a NULL mesh" ));
+ if (!_ptrMesh->getConnectivityptr())
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "can't write a mesh with NULL connectivity" ));
+
+ // fill _supports with families and groups
+ medEntityMesh entity;
+ for (entity=MED_CELL; entity<MED_ALL_ENTITIES; ++entity)
+ {
+ int i, nb = _ptrMesh->getNumberOfGroups(entity);
+ for ( i = 1; i <= nb; ++i )
+ addSupport( _ptrMesh->getGroup( entity, i ));
+// nb = _ptrMesh->getNumberOfFamilies(entity);
+// for ( i = 1; i <= nb; ++i )
+// addSupport( _ptrMesh->getFamily( entity, i ));
+ }
+
+ // --------------------------------------------------------------------
+ // Count total nb of objects: an object per an element type in support
+ // plus an object per an element type not used in _supports.
+ // Collect object names
+ // --------------------------------------------------------------------
+
+ vector<int> nbSuppElemsByType(MED_HEXA20,0);
+ map<string,int> nameNbMap;
+ map<const SUPPORT*,supportData>::iterator supIt = _supports.begin();
+ int i, nb_objects = 0;
+ for ( ; supIt != _supports.end(); supIt++ )
+ {
+ supportData & data = supIt->second;
+ int nbSupObj = data.getNumberObjects();
+ if ( nbSupObj == 0 )
+ continue;
+ data._id = nb_objects + 1;
+ nb_objects += nbSupObj;
+
+ addName( nameNbMap, data._cleanName, data._id, "C" );
+ MESSAGE( "obj " << data._id << " " << data._cleanName);
+
+ // count elements: take into account supports on all elements and families only
+ const SUPPORT* support = supIt->first;
+ if ( support->isOnAllElements() || dynamic_cast< const FAMILY* >( support ))
+ {
+ supportData::typeIterator tIt = data._types.begin();
+ for ( ; tIt != data._types.end(); ++tIt )
+ if ( support->isOnAllElements() )
+ {
+ nbSuppElemsByType[ tIt->first ] = INT_MAX / 100;
+ }
+ else
+ {
+ list< typeData >& td = tIt->second;
+ list< typeData >::iterator tdIt = td.begin();
+ for ( ; tdIt != td.end(); ++tdIt )
+ nbSuppElemsByType[ tIt->first] += tdIt->_nbElems;
+ }
+ }
+ }
+
+ // count types of mesh elements that are not all in _supports
+ int iType, nbTypes;
+ entity = _ptrMesh->getConnectivityptr()->getEntity();
+ for ( ; entity < MED_NODE; entity++ )
+ {
+ nbTypes = _ptrMesh->getNumberOfTypes( entity );
+ if ( nbTypes == 0 || !_ptrMesh->existConnectivity( MED_NODAL, entity ))
+ continue;
+ const medGeometryElement* types = _ptrMesh->getTypes( entity );
+ for ( iType = 0; iType < nbTypes; ++iType )
+ {
+ int nbElemInSups = nbSuppElemsByType[ types[ iType ]];
+ int nbElemInMesh = _ptrMesh->getNumberOfElements(entity, types[ iType ]);
+ if ( nbElemInSups < nbElemInMesh ) {
+ nb_objects++;
+ nbSuppElemsByType[ types[ iType ]] = -1; // to keep written elements of _supports
+ }
+ }
+ }
+
+ // ------------
+ // Write file
+ // ------------
+
+ // Premier paquet dont le nombre de lignes ne varie pas.
+ // On y trouve des indications g鮩rales.
+ const int dim = _ptrMesh->getSpaceDimension();
+ _gibi << " ENREGISTREMENT DE TYPE 4" << endl;
+ _gibi << " NIVEAU 15 NIVEAU ERREUR 0 DIMENSION " << dim <<endl;
+ _gibi << " DENSITE .00000E+00" << endl;
+ _gibi << " ENREGISTREMENT DE TYPE 7" << endl;
+ _gibi << " NOMBRE INFO CASTEM2000 8" <<endl;
+ _gibi << " IFOUR -1 NIFOUR 0 IFOMOD -1 IECHO 1 IIMPI 0 IOSPI 0 ISOTYP 1" << endl;
+ _gibi << " NSDPGE 0" << endl;
+
+ // Deuxi譥 paquet qui d馩nit toutes les piles
+ // (une pile par type d'objet et certaines piles en plus).
+ // Un enregistrement de type 2 pr鶩ent de l'飲iture d'une nouvelle pile,
+ // celui de type 5 pr鶩ent de la fin.
+ // * 800 FORMAT (' ENREGISTREMENT DE TYPE', I4)
+ _gibi << " ENREGISTREMENT DE TYPE 2" << endl;
+ // * 801 FORMAT(' PILE NUMERO',I4,'NBRE OBJETS NOMMES',I8,'NBRE OBJETS',I8)
+ _gibi << " PILE NUMERO 1NBRE OBJETS NOMMES" << setw(8) << nameNbMap.size() <<
+ "NBRE OBJETS" << setw(8) << nb_objects <<endl;
+
+ writeNames( nameNbMap );
+
+ // Passage ?a description des objets les uns apr賠les autres.
+ // Le premier enregistrement de chaque objet est compos頤e 5 nombres repr鳥ntant :
+ // ITYPEL : type de l'鬩ment 1=point, 2=segment ?eux noeuds...
+ // NBSOUS : nombre de sous parties dans cet objet,
+ // une sous partie par type d'鬩ments le composant.
+ // NBREF : nombre de sous r馩rences. Une r馩rence est par exemple le contour
+ // NBNOEL : nombre de noeuds par 鬩ment
+ // NBEL : nombre d'鬩ments
+ // Si ITYPEL=0 alors NBSOUS diff鲥nt de z?. Dans ce cas on lira la liste des positions,
+ // dans la pile des objets, des sous parties le composant.
+ // Si NBSOUS=0, NBNOEL et NBEL sont diff鲥nts de z?, on trouve, au besoin,
+ // la liste des r馩rences , les num?s des couleurs puis les connectivit鳮
+
+ TFieldCounter fcount( _gibi, 10 );
+ char* zeroI8 = " 0"; // FORMAT(I8)
+ for ( supIt = _supports.begin(); supIt != _supports.end(); supIt++ )
+ {
+ supportData & data = supIt->second;
+ int nbSupObj = data.getNumberObjects();
+ if ( nbSupObj == 0 )
+ continue;
+ MESSAGE("support " << data._id << "<" << data._cleanName << ">");
+
+ // write a compound object
+ int nbTypes = data.getNumberOfTypes();
+ if ( nbSupObj > nbTypes )
+ {
+ _gibi << zeroI8 << setw(8) << nbTypes << zeroI8 << zeroI8 << zeroI8 << endl;
+ for ( int i_sub = 1; i_sub <= nbTypes; ++i_sub, fcount++ )
+ _gibi << setw(8) << ( data._id + i_sub );
+ fcount.stop();
+ }
+ // write components
+ entity = supIt->first->getEntity();
+ const int * nodalConnect = 0, * nodalConnectIndex = 0;
+ if ( entity != MED_NODE ) {
+ nodalConnect = _ptrMesh->getConnectivity (MED_FULL_INTERLACE,
+ MED_NODAL,
+ entity,
+ MED_ALL_ELEMENTS);
+ nodalConnectIndex = _ptrMesh->getConnectivityIndex (MED_NODAL,entity);
+ }
+ supportData::typeIterator tIt = data._types.begin();
+ for ( ; tIt != data._types.end(); ++tIt )
+ {
+ writeElements (tIt->first,
+ tIt->second,
+ nodalConnect,
+ nodalConnectIndex);
+ }
+ } // loop on _supports
+
+ // Write elements that are not in _supports
+
+ supportData data;
+ entity = _ptrMesh->getConnectivityptr()->getEntity();
+ for ( ; entity < MED_NODE; entity++ )
+ {
+ int nbTypes = _ptrMesh->getNumberOfTypes( entity );
+ if ( nbTypes == 0 || !_ptrMesh->existConnectivity( MED_NODAL, entity ))
+ continue;
+ const medGeometryElement* types = _ptrMesh->getTypes( entity );
+ const int * nbIndex = _ptrMesh->getGlobalNumberingIndex (entity);
+ const int * nodalConnect = 0, * nodalConnectIndex = 0;
+ nodalConnect = _ptrMesh->getConnectivity (MED_FULL_INTERLACE,
+ MED_NODAL,
+ entity,
+ MED_ALL_ELEMENTS);
+ nodalConnectIndex = _ptrMesh->getConnectivityIndex (MED_NODAL,entity);
+
+ for ( int iType = 1; iType <= nbTypes; ++iType )
+ {
+ int nbElements = nbIndex[ iType ] - nbIndex[ iType - 1 ];
+ medGeometryElement geomType = types[ iType - 1 ];
+ if ( nbSuppElemsByType[ geomType ] >= nbElements )
+ continue; // all elements are written with _supports
+
+ int elemId1 = nbIndex[ iType - 1 ];
+ data.addTypeData( geomType, nbElements, 0, elemId1 );
+
+ writeElements (geomType,
+ data._types[ geomType ],
+ nodalConnect,
+ nodalConnectIndex);
+ }
+ }
+
+ // D颵t de la pile 32 (celle des points)
+
+ int nbNodes = _ptrMesh->getNumberOfNodes();
+ _gibi << " ENREGISTREMENT DE TYPE 2" << endl;
+ _gibi << " PILE NUMERO 32NBRE OBJETS NOMMES 0" <<
+ "NBRE OBJETS" << setw(8) << nbNodes << endl;
+ // Liste des noms de points
+ // * 8001 FORMAT(8(1X,A8))
+ // No named nodes
+ // suit le nombre de noeuds
+ _gibi << setw(8) << nbNodes << endl;
+ // Le tableau suivant donne le filtre pour avoir le vrai num? des noeuds
+ // appartenant aux 鬩ments d飲its. Par exemple, si un 鬩ment, d飲it
+ // dans la pile 1, fait r馩rence ?n num? de noeud 駡l ? il faut le
+ // mettre 駡l ?2
+ // * 8000 FORMAT(10I8)
+ for ( i = 0; i < nbNodes; ++i, fcount++ )
+ _gibi << setw(8) << i + 1;
+ fcount.stop();
+
+ // D颵t de pile 33 (celle des configurations (coordonn?))
+ _gibi << " ENREGISTREMENT DE TYPE 2" << endl;
+ _gibi << " PILE NUMERO 33NBRE OBJETS NOMMES 0NBRE OBJETS 1" << endl;
+ // Suit le nombre de points dont on donne les coordonn?
+ int nbValues = nbNodes * ( dim + 1 );
+ _gibi << setw(8) << nbValues << endl;
+ // Les coordonn? sont donn? par noeuds. D'abord le premier puis le deuxi譥...
+ // Pour chaque noeuds, on donne les 2 ou 3 coordonn? plus la densit頣ourante
+ // au moment de sa cr顴ion.
+ // * 8003 FORMAT(1P,3E22.14)
+ _gibi.precision(14);
+ _gibi.setf( ios_base::scientific, ios_base::floatfield );
+ _gibi.setf( ios_base::uppercase );
+ const double * coords = _ptrMesh->getCoordinates(MED_FULL_INTERLACE);
+ int j = 0;
+ for ( fcount.init(3),i = 0; i < nbNodes; ++i, j += dim )
+ {
+ for ( int iCoord = 0; iCoord < dim; ++iCoord, fcount++ )
+ _gibi << setw(22) << coords[ j + iCoord ];
+ _gibi << setw(22) << 0.0; // densite
+ fcount++;
+ }
+ fcount.stop();
+ END_OF(LOC);
+}
+
+//=======================================================================
+//function : writeLastRecord
+//purpose :
+//=======================================================================
+
+void GIBI_MESH_WRONLY_DRIVER::writeLastRecord()
+{
+ _gibi << " ENREGISTREMENT DE TYPE 5" << endl;
+ _gibi << "LABEL AUTOMATIQUE : 1" << endl;
+}
/*--------------------- RDWR PART -------------------------------*/
GIBI_MESH_RDWR_DRIVER::GIBI_MESH_RDWR_DRIVER():GIBI_MESH_DRIVER()
{
}
-
GIBI_MESH_RDWR_DRIVER::GIBI_MESH_RDWR_DRIVER(const string & fileName,
- MESH * ptrMesh):
- GIBI_MESH_DRIVER(fileName,ptrMesh,MED_RDWR)
+ MESH * ptrMesh):
+ GIBI_MESH_DRIVER(fileName,ptrMesh,MED_RDWR)
{
MESSAGE("GIBI_MESH_RDWR_DRIVER::GIBI_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh) has been created");
}
-
GIBI_MESH_RDWR_DRIVER::GIBI_MESH_RDWR_DRIVER(const GIBI_MESH_RDWR_DRIVER & driver):
GIBI_MESH_RDONLY_DRIVER::GIBI_MESH_DRIVER(driver)
{
+ MESSAGE("GIBI_MESH_RDWR_DRIVER::GIBI_MESH_RDWR_DRIVER(driver) has been created");
}
-
GIBI_MESH_RDWR_DRIVER::~GIBI_MESH_RDWR_DRIVER() {
- //MESSAGE("GIBI_MESH_RDWR_DRIVER::GIBI_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh) has been destroyed");
+ MESSAGE("GIBI_MESH_RDWR_DRIVER::GIBI_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh) has been destroyed");
}
-
GENDRIVER * GIBI_MESH_RDWR_DRIVER::copy(void) const
{
- return new GIBI_MESH_RDWR_DRIVER(*this);
+ BEGIN_OF( "GIBI_MESH_RDWR_DRIVER::copy()");
+ GENDRIVER * driver = new GIBI_MESH_RDWR_DRIVER(*this);
+ END_OF( "GIBI_MESH_RDWR_DRIVER::copy()");
+ return driver;
}
-
void GIBI_MESH_RDWR_DRIVER::write(void) const
throw (MEDEXCEPTION)
{
- GIBI_MESH_WRONLY_DRIVER::write();
+ GIBI_MESH_RDWR_DRIVER * me = const_cast<GIBI_MESH_RDWR_DRIVER *>(this);
+ me->GIBI_MESH_WRONLY_DRIVER::open();
+ me->GIBI_MESH_WRONLY_DRIVER::write();
+ me->GIBI_MESH_WRONLY_DRIVER::close();
}
void GIBI_MESH_RDWR_DRIVER::read (void)
throw (MEDEXCEPTION)
{
+ BEGIN_OF( "GIBI_MESH_RDWR_DRIVER::read()");
+ GIBI_MESH_RDONLY_DRIVER::open();
GIBI_MESH_RDONLY_DRIVER::read();
+ GIBI_MESH_RDONLY_DRIVER::close();
+ END_OF( "GIBI_MESH_RDWR_DRIVER::read()");
+}
+void GIBI_MESH_RDWR_DRIVER::open()
+ // throw (MEDEXCEPTION)
+{
+}
+void GIBI_MESH_RDWR_DRIVER::close()
+ // throw (MEDEXCEPTION)
+{
+}
+
+//============================== ====================================================
+//============================== FIELD Reading Driver ==============================
+//============================== ====================================================
+
+GIBI_MED_RDONLY_DRIVER::GIBI_MED_RDONLY_DRIVER():GIBI_MESH_RDONLY_DRIVER()
+{
+}
+GIBI_MED_RDONLY_DRIVER::GIBI_MED_RDONLY_DRIVER(const string & fileName, MED * ptrMed):
+ GIBI_MESH_RDONLY_DRIVER(fileName,NULL), _med( ptrMed )
+{
+ MESSAGE("GIBI_MED_RDONLY_DRIVER(const string & fileName, MED * ptrMed) has been created");
+ _fileName = fileName;
+ _accessMode = MED_RDONLY;
+}
+GIBI_MED_RDONLY_DRIVER::GIBI_MED_RDONLY_DRIVER(const GIBI_MED_RDONLY_DRIVER & driver)
+{
+}
+ GIBI_MED_RDONLY_DRIVER::~GIBI_MED_RDONLY_DRIVER()
+{
+}
+GENDRIVER * GIBI_MED_RDONLY_DRIVER::copy ( void ) const
+{
+ return new GIBI_MED_RDONLY_DRIVER(*this);
+}
+
+//=======================================================================
+//function : read
+//purpose :
+//=======================================================================
+
+void GIBI_MED_RDONLY_DRIVER::read ( void ) throw (MEDEXCEPTION)
+{
+ const char * LOC = "GIBI_MED_RDONLY_DRIVER::read() : " ;
+ BEGIN_OF(LOC);
+
+ if (_status!=MED_OPENED)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "file " << _fileName<<" is not opened." ));
+
+ _ptrMesh = new MESH();
+
+ _intermediateMED medi;
+ try {
+ if ( !readFile( &medi, true ) )
+ return;
+
+ // set name of field and its support if it is empty
+ set<string> fnames;
+ list< _fieldBase* >::iterator fIt = medi.fields.begin();
+ for ( ; fIt != medi.fields.end(); fIt++ )
+ fnames.insert( (*fIt)->name );
+ int i = 0;
+ for (fIt = medi.fields.begin(); fIt != medi.fields.end(); fIt++ ) {
+ _fieldBase* f = *fIt;
+ if ( f->name.empty() ) {
+ do {
+ ostringstream name;
+ name << "F_" << ++i;
+ f->name = name.str();
+ } while ( !fnames.insert( f->name ).second );
+ }
+ _groupe& g = medi.groupes[ f->group_id ];
+ if ( g.nom.empty() )
+ g.nom = "GRP_" + f->name;
+ }
+ //MESSAGE(LOC << medi );
+ fillMesh( &medi );
+ MESSAGE(LOC << "GIBI_MED_RDONLY_DRIVER::read : RESULTATS STRUCTURE INTERMEDIAIRES : ");
+ MESSAGE(LOC << medi );
+
+ list< FIELD_* > fields;
+ medi.getFields( fields );
+ MESSAGE( "nb fields: " << fields.size() );
+
+ if ( _ptrMesh->getName().empty() )
+ _ptrMesh->setName( "MESH" );
+
+ _med->addMesh( _ptrMesh );
+
+ list< FIELD_* >::iterator it = fields.begin();
+ for ( ; it != fields.end(); it++ )
+ _med->addField( *it );
+ }
+ catch (MEDEXCEPTION &ex)
+ {
+ INFOS( ex.what() );
+ }
+
+ END_OF(LOC);
+}
+
+//============================== ====================================================
+//============================== FIELD Writting Driver ==============================
+//============================== ====================================================
+
+GIBI_MED_WRONLY_DRIVER::GIBI_MED_WRONLY_DRIVER():GIBI_MESH_WRONLY_DRIVER()
+{
+}
+GIBI_MED_WRONLY_DRIVER::GIBI_MED_WRONLY_DRIVER(const string & fileName,
+ MED * ptrMed,
+ MESH * ptrMesh)
+ :GIBI_MESH_WRONLY_DRIVER(fileName,ptrMesh), _med( ptrMed )
+{
+ const char * LOC =
+ "GIBI_MED_WRONLY_DRIVER(const string & fileName, MED * ptrMed, MESH * ptrMesh)" ;
+ BEGIN_OF(LOC);
+
+ _fileName = fileName;
+ _accessMode = MED_WRONLY;
+ _ptrMesh = ptrMesh;
+ if ( !_med || !_ptrMesh )
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << " Bad params " << ptrMed << " " << ptrMesh ));
+}
+GIBI_MED_WRONLY_DRIVER::GIBI_MED_WRONLY_DRIVER(const GIBI_MED_WRONLY_DRIVER & driver)
+{
+}
+GIBI_MED_WRONLY_DRIVER::~GIBI_MED_WRONLY_DRIVER()
+{
+}
+GENDRIVER * GIBI_MED_WRONLY_DRIVER::copy ( void ) const
+{
+ return new GIBI_MED_WRONLY_DRIVER(*this);
+}
+
+//=======================================================================
+//function : writeDataSection
+//purpose :
+//=======================================================================
+
+template< class T >
+ static void writeDataSection (fstream& file,
+ FIELD_* field,
+ int id1,
+ int id2)
+{
+ FIELD<T>* f = dynamic_cast<FIELD<T>*>( field );
+ if (!f) return;
+ MEDARRAY<T>* array = f->getvalue();
+ int ld = array->getLeadingValue();
+ //SCRUTE( array->getLengthValue() );
+ for ( int iComp = 0; iComp < ld; ++iComp )
+ {
+ file << setw(8) << 1 // nb scalar values by element
+ << setw(8) << ( id2 - id1 ) // total nb of scalar values
+ << setw(8) << 0
+ << setw(8) << 0 << endl;
+ // * 8003 FORMAT(1P,3E22.14)
+ int id = id1;
+ while ( id < id2 )
+ {
+ for ( int i = 0; id < id2 && i < 3; ++i )
+ file << setw(22) << array->getIJ( id++, iComp + 1);
+ file << endl;
+ }
+ }
+}
+
+//=======================================================================
+//function : getSupports
+//purpose :
+//=======================================================================
+
+// int GIBI_MED_WRONLY_DRIVER::getSupports(const FIELD_* field,
+// list<const SUPPORT*>& supList) const
+// {
+// int nbSup = 0;
+// const SUPPORT* sup = field->getSupport();
+// const GROUP* group = dynamic_cast<const GROUP*>( sup );
+// if ( group ) {
+// int nbFam = group->getNumberOfFamilies();
+// for ( int iFam = 1; iFam <= nbFam; ++iFam ) {
+// const FAMILY* fam = group->getFamily( iFam );
+// if ( getSupportIndex( fam ) >= 0 ) {
+// supList.push_back( fam );
+// nbSup++;
+// }
+// }
+// }
+// else {
+// supList.push_back( sup );
+// nbSup++;
+// }
+// return nbSup;
+// }
+
+//=======================================================================
+//function : write
+//purpose :
+//=======================================================================
+
+void GIBI_MED_WRONLY_DRIVER::write( void ) const throw (MEDEXCEPTION)
+{
+ const char * LOC = "void GIBI_MED_WRONLY_DRIVER::write(void) const : ";
+ BEGIN_OF(LOC);
+
+ // we are going to modify the _gibi field
+ GIBI_MED_WRONLY_DRIVER * me = const_cast<GIBI_MED_WRONLY_DRIVER *>(this);
+
+ // get all fields on _ptrMesh and add their support to be written
+ list<FIELD_*> fields;
+ int iField, nbFileds = _med->getNumberOfFields();
+ int nb_obj = 0;
+ list<int> nb_sub_list;
+ map<string,int> nameNbMap;
+
+ list<pair<int,int> > subIdSizeList; // pair( <submesh id>, <submesh size> );
+ list<pair<int,int> >::iterator idsize;
+
+ string *names=new string[ nbFileds ];
+ _med->getFieldNames( names );
+ for ( iField = 0; iField < nbFileds; ++iField )
+ {
+ int nb_sub = 0;
+ deque<DT_IT_> dtit = _med->getFieldIteration( names[ iField ]);
+ deque<DT_IT_>::iterator fIt = dtit.begin();
+ for ( ; fIt != dtit.end(); fIt++ )
+ {
+ FIELD_ * f = _med->getField( names[ iField ], fIt->dt, fIt->it );
+ if ( !dynamic_cast< FIELD<double >* >( f ))
+ {
+ MESSAGE("GIBI_MED_WRONLY_DRIVER::write( FIELD< int > ) not implemented");
+ continue;
+ }
+ const SUPPORT * sup = f->getSupport();
+ if ( me->addSupport( sup ) ) {
+ fields.push_back( f );
+ nb_sub += getSubMeshIdAndSize( sup, subIdSizeList );
+ }
+ }
+ if ( nb_sub ) {
+ addName( nameNbMap, names[ iField ], ++nb_obj, "F" );
+ nb_sub_list.push_back( nb_sub );
+ }
+ }
+
+ // write mesh
+
+ //try {
+ me->writeSupportsAndMesh();
+// }
+// catch (MEDEXCEPTION &ex)
+// {
+// INFOS( ex.what() );
+// return;
+// }
+
+ // write fields
+
+ if ( !fields.empty() ) {
+
+ fstream & gibi = me->_gibi;
+
+ TFieldCounter fcount( gibi, 10 );
+
+ gibi << " ENREGISTREMENT DE TYPE 2" << endl;
+ gibi << " PILE NUMERO 39NBRE OBJETS NOMMES" << setw(8) << nameNbMap.size()
+ << "NBRE OBJETS" << setw(8) << nb_obj << endl;
+
+ me->writeNames( nameNbMap );
+
+ list<FIELD_*>::iterator itF = fields.begin();
+ list<int>::iterator itNbSub = nb_sub_list.begin();
+ int nb_sub = 0, cur_nb_sub = 0;
+ for ( ; itF != fields.end(); itF++ )
+ {
+ if ( cur_nb_sub == nb_sub && itNbSub != nb_sub_list.end() ) {
+ // start the next field writting
+ nb_sub = *(itNbSub++);
+ gibi << setw(8) << nb_sub << " -1 6 72" << endl;
+ gibi << left;
+ gibi << setw(72) << " Field" << endl;
+ gibi << right;
+ gibi << setw(72) << " " << endl;
+
+ // Sub Components section
+ list<FIELD_*>::iterator itF2 = itF;
+ vector<int> vals( 9, 0 );
+ vals[8] = 2;
+ fcount.init(10);
+ cur_nb_sub = 0;
+ while ( itF2 != fields.end() && cur_nb_sub < nb_sub )
+ {
+ FIELD_* f = *itF2++;
+ vals[2] = f->getNumberOfComponents();
+ getSubMeshIdAndSize( f->getSupport(), subIdSizeList );
+ for ( idsize = subIdSizeList.begin(); idsize != subIdSizeList.end(); idsize++ )
+ {
+ ++cur_nb_sub;
+ vals[0] = -idsize->first; // support id
+ for ( int i = 0; i < vals.size(); ++i, fcount++ )
+ gibi << setw(8) << vals[ i ];
+ }
+ }
+ fcount.stop();
+ cur_nb_sub = 0;
+ // dummy strings
+ int i_sub;
+ for ( fcount.init(4), i_sub = 0; i_sub < nb_sub; ++i_sub, fcount++ )
+ gibi << " ";
+ fcount.stop();
+ for ( fcount.init(8), i_sub = 0; i_sub < nb_sub; ++i_sub, fcount++ )
+ gibi << " ";
+ fcount.stop();
+ }
+
+ FIELD_* f = *itF;
+ int id1 = 1;
+ int iComp, nbComp = f->getNumberOfComponents();
+ // loop on sub-components
+ getSubMeshIdAndSize( f->getSupport(), subIdSizeList );
+ for ( idsize = subIdSizeList.begin(); idsize != subIdSizeList.end(); idsize++ )
+ {
+ cur_nb_sub++;
+ // component addresses
+ for ( fcount.init(10), iComp = 0; iComp < nbComp; ++iComp, fcount++ )
+ gibi << setw(8) << 777; // a good number
+ fcount.stop();
+ // component names
+ gibi << left;
+ for ( fcount.init(8), iComp = 0; iComp < nbComp; ++iComp, fcount++ )
+ gibi << " " << setw(8) << f->getComponentName( iComp + 1 );
+ fcount.stop();
+ // component types
+ for ( fcount.init(4), iComp = 0; iComp < nbComp; ++iComp, fcount++ )
+ gibi << " " << setw(17) << "REAL*8";
+ fcount.stop();
+ gibi << right;
+
+ // Data section
+ int id2 = id1 + idsize->second;
+ writeDataSection<double>( gibi, f, id1, id2 );
+ id1 = id2;
+ }
+ } // loop on fields
+ }
+ me->writeLastRecord();
+ delete [] names;
+ END_OF(LOC);
}
#include <string>
#include <vector>
+#include <map>
#include <fstream>
+#include <list>
#include "MEDMEM_define.hxx"
#include "MEDMEM_GenDriver.hxx"
*/
namespace MEDMEM {
+class MED;
class MESH;
+class FIELD_;
class FAMILY;
class GROUP;
+class SUPPORT;
class CONNECTIVITY;
+class _intermediateMED;
class GIBI_MESH_DRIVER : public GENDRIVER
{
protected:
// A VOIR FILE DESCRIPTEUR ? MED_FR::med_idt _medIdt;
string _meshName;
/////
- ifstream _gibi;
-
+
// tableau de correspondance des types géométriques de CASTEM -> MED
static const size_t nb_geometrie_gibi=47;
static const MED_EN::medGeometryElement geomGIBItoMED[nb_geometrie_gibi];
*/
virtual ~GIBI_MESH_DRIVER() ;
- void open() throw (MEDEXCEPTION);
- void close() throw (MEDEXCEPTION);
-
virtual void write( void ) const = 0 ;
virtual void read ( void ) = 0 ;
*/
string getMeshName() const ;
-private:
+ static MED_EN::medGeometryElement gibi2medGeom( size_t gibiTypeNb );
+ static int med2gibiGeom( MED_EN::medGeometryElement medGeomType );
+
+ private:
virtual GENDRIVER * copy ( void ) const = 0 ;
};
class GIBI_MESH_RDONLY_DRIVER : public virtual GIBI_MESH_DRIVER
{
-
public :
/*!
*/
void read ( void ) throw (MEDEXCEPTION);
+ void open();
+ void close();
+
+protected:
+
+ bool readFile(_intermediateMED* medi, bool readFields );
+
+ void fillMesh(_intermediateMED* medi);
+
private:
GENDRIVER * copy ( void ) const ;
+ // fields and methods for file reading
+
+ bool getLine(char* & line);
+ bool getNextLine (char* & line, bool raiseIfNot = true ) throw (MEDEXCEPTION)
+ {
+ if ( getLine( line )) return true;
+ if ( raiseIfNot ) throw MEDEXCEPTION(LOCALIZED(STRING("Unexpected EOF on ln ")<<_lineNb));
+ return false;
+ }
+ void initNameReading(int nbValues, int width = 8) // FORMAT(8(1X,A8))
+ { init( nbValues, 72 / ( width + 1 ), width, 1 ); }
+ void initIntReading(int nbValues) // FORMAT(10I8)
+ { init( nbValues, 10, 8 ); }
+ void initDoubleReading(int nbValues) // FORMAT(1P,3E22.14)
+ { init( nbValues, 3, 22 ); }
+ void init( int nbToRead, int nbPosInLine, int width, int shift = 0 );
+ bool more() const { return ( _iRead < _nbToRead && _curPos ); }
+ void next();
+ char* str() const { return _curPos; }
+ int index() const { return _iRead; }
+ int getInt() const { return atoi( str() ); }
+ double getDouble() const { return atof( str() ); }
+ string getName() const;
+
+ // line getting
+ int _File;
+ char* _start;
+ char* _ptr;
+ char* _eptr;
+ int _lineNb;
+
+ // string reading
+ int _iPos, _nbPosInLine, _width, _shift;
+ int _iRead, _nbToRead;
+ char* _curPos;
};
/*!
*/
void read ( void ) throw (MEDEXCEPTION);
-private:
+ void open();
+ void close();
+
+ protected:
+
+ fstream _gibi;
+
+ /*!
+ Add a support to write. Return true if a support will be written
+ */
+ bool addSupport( const SUPPORT * support );
+ /*!
+ return submesh id and size for a support. Call it after writeSupportsAndMesh()
+ */
+ int getSubMeshIdAndSize(const SUPPORT * support,
+ list<pair<int,int> > & idsAndSizes ) const;
+ /*!
+ Write MESH and _supports.
+ */
+ void writeSupportsAndMesh();
+ /*!
+ Write the record closing file
+ */
+ void writeLastRecord();
+
+ static void addName( map<string,int>& nameMap, string& name, int index, string prefix );
+
+ void writeNames( map<string,int>& nameMap );
+
+ private:
+
+ struct typeData
+ {
+ int _nbElems;
+ const int * _ptrElemIDs; // elem ids or
+ int _elemID1; // first elem id if isOnAllElements()
+ typeData(): _nbElems(0), _ptrElemIDs(NULL), _elemID1(0) {}
+ typeData( int nbElems, const int * ptrElemIDs, int elemID1 )
+ : _nbElems(nbElems), _ptrElemIDs(ptrElemIDs), _elemID1(elemID1) {}
+ };
+ struct supportData
+ {
+ typedef map< MED_EN::medGeometryElement, list< typeData > >::iterator typeIterator;
+ int _id;
+ string _cleanName;
+ map< MED_EN::medGeometryElement, list< typeData > > _types;
+ supportData(): _id(0) {}
+ int getNumberOfTypes() const { return _types.size(); }
+ int getNumberObjects() const
+ { return _types.size() < 2 ? _types.size() : _types.size() + !_cleanName.empty(); }
+ void addTypeData(MED_EN::medGeometryElement type, int nbElems,
+ const int * ptrElemIDs, int elemID1 )
+ { _types[type].push_back( typeData( nbElems, ptrElemIDs, elemID1 )); }
+ };
+
+ void writeElements (MED_EN::medGeometryElement geomType,
+ list< typeData >& typeDataList,
+ const int * nodalConnect,
+ const int * nodalConnectIndex);
+
+ map<const SUPPORT*, supportData> _supports;
GENDRIVER * copy ( void ) const ;
};
*/
void read (void) throw (MEDEXCEPTION);
-private:
+ void open();
+ void close();
+
+ private:
GENDRIVER * copy(void) const ;
};
+
+class GIBI_MED_RDONLY_DRIVER : public GIBI_MESH_RDONLY_DRIVER {
+
+ MED * _med;
+
+public:
+
+ /*!
+ Constructor.
+ */
+ GIBI_MED_RDONLY_DRIVER() ;
+ /*!
+ Constructor.
+ */
+ GIBI_MED_RDONLY_DRIVER(const string & fileName, MED * ptrMed) ;
+ /*!
+ Copy constructor.
+ */
+ GIBI_MED_RDONLY_DRIVER(const GIBI_MED_RDONLY_DRIVER & driver) ;
+
+ /*!
+ Destructor.
+ */
+ virtual ~GIBI_MED_RDONLY_DRIVER() ;
+
+ /*!
+ Read MESH in the specified file.
+ */
+ void read ( void ) throw (MEDEXCEPTION);
+
+private:
+
+ GENDRIVER * copy ( void ) const ;
+
+};
+
+/*!
+
+ Driver Med for MESH : Write only.
+
+ Implement write method.
+
+*/
+
+class GIBI_MED_WRONLY_DRIVER : public GIBI_MESH_WRONLY_DRIVER {
+
+ MED * _med;
+
+public :
+
+ /*!
+ Constructor.
+ */
+ GIBI_MED_WRONLY_DRIVER() ;
+ /*!
+ Constructor. To write a mesh and all fields on it
+ */
+ GIBI_MED_WRONLY_DRIVER(const string & fileName, MED * ptrMed, MESH * ptrMesh) ;
+ /*!
+ Copy constructor.
+ */
+ GIBI_MED_WRONLY_DRIVER(const GIBI_MED_WRONLY_DRIVER & driver) ;
+
+ /*!
+ Destructor.
+ */
+ virtual ~GIBI_MED_WRONLY_DRIVER() ;
+
+ /*!
+ Write MESH in the specified file.
+ */
+ void write( void ) const throw (MEDEXCEPTION);
+
+ //int getSupports(const FIELD_* field, list<const SUPPORT*>& supList) const;
+
+private:
+
+ GENDRIVER * copy ( void ) const ;
+};
+
+
+/*!
+
+ Driver GIBI for MESH : Read write.
+ - Use read method from GIBI_MED_RDONLY_DRIVER
+ - Use write method from GIBI_MED_WRONLY_DRIVER
+
+*/
+
+// class GIBI_MED_RDWR_DRIVER : public GIBI_MED_RDONLY_DRIVER, public GIBI_MED_WRONLY_DRIVER {
+
+// public :
+
+// /*!
+// Constructor.
+// */
+// GIBI_MED_RDWR_DRIVER() ;
+// /*!
+// Constructor.
+// */
+// GIBI_MED_RDWR_DRIVER(const string & fileName, MESH * ptrMesh) ;
+// /*!
+// Copy constructor.
+// */
+// GIBI_MED_RDWR_DRIVER(const GIBI_MED_RDWR_DRIVER & driver) ;
+
+// /*!
+// Destructor.
+// */
+// ~GIBI_MED_RDWR_DRIVER() ;
+
+// /*!
+// 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 ;
+
+// };
};
return &_gridGeometry[i];
}
+MED_EN::medGeometryElement * GRID::getTypesWithPoly(MED_EN::medEntityMesh Entity) const
+{
+ int size=getNumberOfTypesWithPoly(Entity);
+ MED_EN::medGeometryElement *ret=new MED_EN::medGeometryElement[size];
+ memcpy(ret,getTypes(Entity),size*sizeof(MED_EN::medGeometryElement));
+ return ret;
+}
+
//=======================================================================
//function : fillMeshAfterRead
//purpose :
inline int getNumberOfTypes(MED_EN::medEntityMesh Entity) const;
+ inline int getNumberOfTypesWithPoly(MED_EN::medEntityMesh Entity) const;
+
inline const MED_EN::medGeometryElement * getTypes(MED_EN::medEntityMesh Entity) const;
+ MED_EN::medGeometryElement * getTypesWithPoly(MED_EN::medEntityMesh Entity) const;
+
inline const CELLMODEL * getCellsTypes(MED_EN::medEntityMesh Entity) const;
const int * getGlobalNumberingIndex(MED_EN::medEntityMesh Entity) const;
inline int getNumberOfElements(MED_EN::medEntityMesh Entity,
MED_EN::medGeometryElement Type) const;
+ inline int getNumberOfElementsWithPoly(MED_EN::medEntityMesh Entity,
+ MED_EN::medGeometryElement Type) const;
+
inline bool existConnectivity(MED_EN::medConnectivity ConnectivityType,
MED_EN::medEntityMesh Entity) const;
inline MED_EN::medGeometryElement getElementType(MED_EN::medEntityMesh Entity,
int Number) const;
+ inline MED_EN::medGeometryElement getElementTypeWithPoly(MED_EN::medEntityMesh Entity,
+ int Number) const;
+
inline void calculateConnectivity(MED_EN::medModeSwitch Mode,
MED_EN::medConnectivity ConnectivityType,
MED_EN::medEntityMesh Entity) const ;
inline void setGridType(MED_EN::med_grid_type gridType);
- friend class MED_MESH_RDONLY_DRIVER;
- friend class MED_MESH_WRONLY_DRIVER;
-
+ friend class IMED_MESH_RDONLY_DRIVER;
+ friend class IMED_MESH_WRONLY_DRIVER;
+ friend class MED_MESH_RDONLY_DRIVER21;
+ friend class MED_MESH_WRONLY_DRIVER21;
+ friend class MED_MESH_RDONLY_DRIVER22;
+ friend class MED_MESH_WRONLY_DRIVER22;
};
return 1; // a grid has one type
}
+
+inline int GRID::getNumberOfTypesWithPoly(MED_EN::medEntityMesh entity) const
+{
+ MESSAGE("GRID::getNumberOfTypes(medEntityMesh entity) : "<<entity);
+ return 1; // a grid has one type
+}
+
/*!
Get the whole list of CELLMODEL used by cells of given type (medEntityMesh).
return numberOfElements;
}
+int GRID::getNumberOfElementsWithPoly(MED_EN::medEntityMesh entity, MED_EN::medGeometryElement Type) const
+{
+ return getNumberOfElements(entity,Type);
+}
+
/*!
Return true if the wanted connectivity exist, else return false
return _connectivity->getElementType(Entity,Number);
}
+inline MED_EN::medGeometryElement GRID::getElementTypeWithPoly(MED_EN::medEntityMesh Entity,int Number) const
+{
+ return getElementType(Entity,Number);
+}
+
/*!
Calculate the ask connectivity. Return an exception if this could not be
done. Do nothing if connectivity already exist.
using namespace MEDMEM;
using namespace MED_EN;
+#define MED_NOPDT -1
+
/*!
Constructor.
*/
};
+/*!
+ Return a reference to the FIELD object named fieldName with
+ time and iteration nb it.
+*/
+FIELD_ *MED::getField2(const string & fieldName, double time, int it) const throw (MEDEXCEPTION)
+{
+ const char * LOC = "MED::getField2 ( const string &, const int, const int ) const : ";
+ const double eps=1e-9;
+ map<FIELD_NAME_,MAP_DT_IT_>::const_iterator itFields=_fields.find(fieldName);
+ if ( itFields == _fields.end() )
+ throw MED_EXCEPTION (LOCALIZED( STRING(LOC) << "There is no known field named |" << fieldName << "|"));
+ MAP_DT_IT_::const_iterator iters=(*itFields).second.begin();
+ bool found=false;
+ FIELD_ *ret;
+ for(;iters!=(*itFields).second.end() && !found;iters++)
+ if(fabs((*iters).second->getTime()-time)<eps)
+ //if(it==(*iters).first.it)
+ {
+ ret=(*iters).second;
+ found=true;
+ }
+ if(!found)
+ throw MED_EXCEPTION(LOCALIZED( STRING(LOC) << "There is no known field existing at specified time and iteration !!! "));
+ return ret;
+ END_OF(LOC);
+}
// fiend ostream & MED::operator<<(ostream &os,const MED & med) const {
// return os;
{
bool operator() (const DT_IT_ &p1, const DT_IT_ &p2) const
{
- if ( bool test = p1.dt == p2.dt)
+ if ( p1.dt == p2.dt)
return p1.it < p2.it ;
else
return p1.dt < p2.dt ;
class MED
{
// 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;
+ friend class MED_MED_RDONLY_DRIVER21;
+ friend class MED_MED_WRONLY_DRIVER21;
+ friend class MED_MED_RDWR_DRIVER21;
+ friend class MED_MED_RDONLY_DRIVER22;
+ friend class MED_MED_WRONLY_DRIVER22;
+ friend class MED_MED_RDWR_DRIVER22;
private:
deque<DT_IT_> getFieldIteration (const string & fieldName) const throw (MEDEXCEPTION) ;
FIELD_ * getField ( const string & fieldName,
const int dt, const int it) const throw (MEDEXCEPTION) ;
+ FIELD_ * getField2 ( const string & fieldName,
+ double time, int it=0) const throw (MEDEXCEPTION) ;
const map<MED_EN::medEntityMesh,SUPPORT *> & getSupports(const string & meshName) const throw (MEDEXCEPTION) ;
#include "MEDMEM_Unit.hxx"
#include "MEDMEM_Array.hxx"
#include "MEDMEM_Support.hxx"
-//#include "MEDMEM_Field.hxx"
#include "MEDMEM_Mesh.hxx"
+#include "MEDMEM_Compatibility21_22.hxx"
namespace MEDMEM {
template <class T> class FIELD;
-
-// A QD LA CLASSE MED_ALL_ELEMENTS_DRIVER.... :) pour mutualiser le open ..... avec led _medIdt...
-
-/*!
-
- Driver Med for FIELD.
-
- Generic part : implement open and close methods.
-
-*/
+template <class T> class MED_FIELD_RDWR_DRIVER;
+template <class T> class MED_FIELD_RDONLY_DRIVER;
+template <class T> class MED_FIELD_WRONLY_DRIVER;
template <class T> class MED_FIELD_DRIVER : public GENDRIVER
{
protected:
-
FIELD<T> * _ptrField;
- med_2_1::med_idt _medIdt;
string _fieldName;
int _fieldNum;
-
void search_field() ;
public :
/*!
Constructor.
*/
- MED_FIELD_DRIVER():GENDRIVER(),
- _ptrField((FIELD<T> *)MED_NULL),_medIdt(MED_INVALID),
- _fieldName(""),_fieldNum(MED_INVALID) {}
+ MED_FIELD_DRIVER():_ptrField((FIELD<T> *) NULL),
+ _fieldName(""),_fieldNum(MED_INVALID)
+ {}
/*!
Constructor.
*/
MED_FIELD_DRIVER(const string & fileName, FIELD<T> * ptrField,
MED_EN::med_mode_acces accessMode)
: GENDRIVER(fileName,accessMode),
- _ptrField((FIELD<T> *) ptrField),_medIdt(MED_INVALID),
- _fieldName(fileName),_fieldNum(MED_INVALID)
+ _ptrField((FIELD<T> *) ptrField),
+ _fieldName(fileName),_fieldNum(MED_INVALID)
{
}
MED_FIELD_DRIVER(const MED_FIELD_DRIVER & fieldDriver):
GENDRIVER(fieldDriver),
_ptrField(fieldDriver._ptrField),
- _medIdt(MED_INVALID),
_fieldName(fieldDriver._fieldName),
- _fieldNum(fieldDriver._fieldNum)
+ _fieldNum(fieldDriver._fieldNum)
{
}
/*!
Destructor.
*/
- virtual ~MED_FIELD_DRIVER() {
- }
-
- void open() throw (MEDEXCEPTION)
- {
- const char * LOC = "MED_FIELD_DRIVER::open() ";
- BEGIN_OF(LOC);
-
- // we must set fieldname before open, because we must find field number in file (if it exist !!!)
- if ( _fileName == "" )
- throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
- << "_fileName is |\"\"|, please set a correct fileName before calling open()"
- )
- );
-
- MESSAGE(LOC<<"_fileName.c_str : "<< _fileName.c_str()<<",mode : "<< _accessMode);
- _medIdt = med_2_1::MEDouvrir( (const_cast <char *> (_fileName.c_str())),(med_2_1::med_mode_acces) _accessMode);
- MESSAGE(LOC<<"_medIdt : "<< _medIdt );
- if (_medIdt > 0)
- _status=MED_OPENED;
- else {
- _status = MED_INVALID;
- _medIdt = MED_INVALID;
- throw MED_EXCEPTION (LOCALIZED( STRING(LOC)
- << "Can't open |" << _fileName
- << "|, _medIdt : " << _medIdt
- )
- );
- }
-
- END_OF(LOC);
- }
-
- void close() {
- BEGIN_OF("MED_FIELD_DRIVER::close()");
- med_2_1::med_int err = 0;
- if (_status == MED_OPENED) {
- err=med_2_1::MEDfermer(_medIdt);
- //H5close(); // If we call H5close() all the files are closed.
- _status = MED_CLOSED;
- _medIdt = MED_INVALID;
- MESSAGE(" MED_FIELD_DRIVER::close() : MEDfermer : _medIdt= " << _medIdt );
- MESSAGE(" MED_FIELD_DRIVER::close() : MEDfermer : err = " << err );
- }
- END_OF("MED_FIELD_DRIVER::close()");
+ virtual ~MED_FIELD_DRIVER()
+ {
+ MESSAGE("MED_FIELD_DRIVER::~MED_FIELD_DRIVER() has been destroyed");
}
+ virtual void open() throw (MEDEXCEPTION) = 0;
+ virtual void close() =0;
virtual void write( void ) const = 0 ;
virtual void read ( void ) = 0 ;
-
/*!
Set the name of the FIELD asked in file.
It could be different than the name of the FIELD object.
*/
- void setFieldName(const string & fieldName) ;
+ virtual void setFieldName(const string & fieldName) { _fieldName = fieldName; }
/*!
Get the name of the FIELD asked in file.
*/
- string getFieldName() const ;
-
-private:
+ virtual string getFieldName() const { return _fieldName; }
+protected:
virtual GENDRIVER * copy ( void ) const = 0 ;
-
+ friend class MED_FIELD_RDWR_DRIVER<T>;
+ friend class MED_FIELD_RDONLY_DRIVER<T>;
+ friend class MED_FIELD_WRONLY_DRIVER<T>;
};
/*!
*/
-template <class T> class MED_FIELD_RDONLY_DRIVER : public virtual MED_FIELD_DRIVER<T>
+template <class T> class IMED_FIELD_RDONLY_DRIVER : public virtual MED_FIELD_DRIVER<T>
{
public :
/*!
Constructor.
*/
- MED_FIELD_RDONLY_DRIVER():MED_FIELD_DRIVER<T>() {};
+ IMED_FIELD_RDONLY_DRIVER() {}
/*!
Constructor.
*/
- MED_FIELD_RDONLY_DRIVER(const string & fileName, FIELD<T> * ptrField):
+ IMED_FIELD_RDONLY_DRIVER(const string & fileName, FIELD<T> * ptrField):
MED_FIELD_DRIVER<T>(fileName,ptrField,MED_EN::MED_RDONLY) {
- BEGIN_OF("MED_FIELD_RDONLY_DRIVER::MED_FIELD_RDONLY_DRIVER(const string & fileName, const FIELD<T> * ptrField)");
- END_OF("MED_FIELD_RDONLY_DRIVER::MED_FIELD_RDONLY_DRIVER(const string & fileName, const FIELD<T> * ptrField)");
+ BEGIN_OF("IMED_FIELD_RDONLY_DRIVER::IMED_FIELD_RDONLY_DRIVER(const string & fileName, const FIELD<T> * ptrField)");
+ END_OF("IMED_FIELD_RDONLY_DRIVER::IMED_FIELD_RDONLY_DRIVER(const string & fileName, const FIELD<T> * ptrField)");
}
/*!
Copy constructor.
*/
- MED_FIELD_RDONLY_DRIVER(const MED_FIELD_RDONLY_DRIVER & fieldDriver):
- MED_FIELD_DRIVER<T>(fieldDriver) {};
+ IMED_FIELD_RDONLY_DRIVER(const IMED_FIELD_RDONLY_DRIVER & fieldDriver):
+ MED_FIELD_DRIVER<T>(fieldDriver) {}
/*!
Destructor.
*/
- virtual ~MED_FIELD_RDONLY_DRIVER() {};
+ virtual ~IMED_FIELD_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 FIELD in the specified file.
- */
- void read ( void ) throw (MEDEXCEPTION) ;
-
-private:
- GENDRIVER * copy( void ) const ;
+ friend class MED_FIELD_RDONLY_DRIVER<T>;
};
/*!
*/
-template <class T> class MED_FIELD_WRONLY_DRIVER : public virtual MED_FIELD_DRIVER<T> {
+template <class T> class IMED_FIELD_WRONLY_DRIVER : public virtual MED_FIELD_DRIVER<T> {
public :
/*!
Constructor.
*/
- MED_FIELD_WRONLY_DRIVER():MED_FIELD_DRIVER<T>() {}
+ IMED_FIELD_WRONLY_DRIVER() {}
/*!
Constructor.
*/
- MED_FIELD_WRONLY_DRIVER(const string & fileName, FIELD<T> * ptrField):
+ IMED_FIELD_WRONLY_DRIVER(const string & fileName, FIELD<T> * ptrField):
MED_FIELD_DRIVER<T>(fileName,ptrField,MED_EN::MED_WRONLY)
{
BEGIN_OF("MED_FIELD_WRONLY_DRIVER::MED_FIELD_WRONLY_DRIVER(const string & fileName, const FIELD<T> * ptrField)");
END_OF("MED_FIELD_WRONLY_DRIVER::MED_FIELD_WRONLY_DRIVER(const string & fileName, const FIELD<T> * ptrField)");
- };
+ }
/*!
Copy constructor.
*/
- MED_FIELD_WRONLY_DRIVER(const MED_FIELD_WRONLY_DRIVER & fieldDriver):
- MED_FIELD_DRIVER<T>(fieldDriver) {};
+ IMED_FIELD_WRONLY_DRIVER(const IMED_FIELD_WRONLY_DRIVER & fieldDriver):
+ MED_FIELD_DRIVER<T>(fieldDriver) {}
/*!
Destructor.
*/
- virtual ~MED_FIELD_WRONLY_DRIVER() {};
-
- /*!
- Write FIELD in the specified file.
- */
- void write( void ) const throw (MEDEXCEPTION) ;
+ virtual ~IMED_FIELD_WRONLY_DRIVER() {};
/*!
Return a MEDEXCEPTION : it is the write-only driver.
*/
void read ( void ) throw (MEDEXCEPTION) ;
-private:
- GENDRIVER * copy( void ) const ;
-
+ friend class MED_FIELD_WRONLY_DRIVER<T>;
};
*/
-template <class T> class MED_FIELD_RDWR_DRIVER : public MED_FIELD_RDONLY_DRIVER<T>, public MED_FIELD_WRONLY_DRIVER<T> {
+template <class T> class IMED_FIELD_RDWR_DRIVER : public virtual IMED_FIELD_RDONLY_DRIVER<T>, public virtual IMED_FIELD_WRONLY_DRIVER<T> {
public :
/*!
Constructor.
*/
- MED_FIELD_RDWR_DRIVER():MED_FIELD_DRIVER<T>() {}
+ IMED_FIELD_RDWR_DRIVER() {}
/*!
Constructor.
*/
- MED_FIELD_RDWR_DRIVER(const string & fileName, FIELD<T> * ptrField):
- MED_FIELD_DRIVER<T>(fileName,ptrField,MED_EN::MED_RDWR)
+ IMED_FIELD_RDWR_DRIVER(const string & fileName, FIELD<T> * ptrField):
+ IMED_FIELD_RDONLY_DRIVER<T>(fileName,ptrField),IMED_FIELD_WRONLY_DRIVER<T>(fileName,ptrField),MED_FIELD_DRIVER<T>(fileName,ptrField,MED_EN::MED_RDWR)
{
BEGIN_OF("MED_FIELD_RDWR_DRIVER::MED_FIELD_RDWR_DRIVER(const string & fileName, const FIELD<T> * ptrField)");
//_accessMode = MED_RDWR ;
END_OF("MED_FIELD_RDWR_DRIVER::MED_FIELD_RDWR_DRIVER(const string & fileName, const FIELD<T> * ptrField)");
- };
+ }
/*!
Copy constructor.
*/
- MED_FIELD_RDWR_DRIVER(const MED_FIELD_RDWR_DRIVER & fieldDriver):
- MED_FIELD_DRIVER<T>(fieldDriver) {};
+ IMED_FIELD_RDWR_DRIVER(const IMED_FIELD_RDWR_DRIVER & fieldDriver):
+ IMED_FIELD_RDONLY_DRIVER<T>(fieldDriver),IMED_FIELD_WRONLY_DRIVER<T>(fieldDriver),MED_FIELD_DRIVER<T>(fieldDriver) {}
/*!
Destructor.
*/
- ~MED_FIELD_RDWR_DRIVER() {};
+ ~IMED_FIELD_RDWR_DRIVER() {}
- /*!
- Write FIELD in the specified file.
- */
- void write(void) const throw (MEDEXCEPTION) ;
- /*!
- Read FIELD in the specified file.
- */
- void read (void) throw (MEDEXCEPTION) ;
+ friend class MED_FIELD_RDWR_DRIVER<T>;
+};
+}
+
+namespace MEDMEM {
+
+template <class T> class MED_FIELD_RDONLY_DRIVER : public virtual IMED_FIELD_RDONLY_DRIVER<T>
+{
+
+public :
+ MED_FIELD_RDONLY_DRIVER();
+ MED_FIELD_RDONLY_DRIVER(const string & fileName, FIELD<T> * ptrField);
+
+ MED_FIELD_RDONLY_DRIVER(const MED_FIELD_RDONLY_DRIVER & fieldDriver):IMED_FIELD_RDONLY_DRIVER<T>(fieldDriver) { _concreteFieldDrv = fieldDriver._concreteFieldDrv->copy(); }
+ virtual ~MED_FIELD_RDONLY_DRIVER() { if (_concreteFieldDrv) delete _concreteFieldDrv; }
+ virtual void read ( void ) throw (MEDEXCEPTION) { _concreteFieldDrv->read(); }
+ virtual void write( void ) const throw (MEDEXCEPTION) { _concreteFieldDrv->write(); }
+ virtual void open() throw (MEDEXCEPTION) { _concreteFieldDrv->open(); }
+ virtual void close() { _concreteFieldDrv->close(); }
+ virtual void setFieldName(const string & fieldName) { _concreteFieldDrv->setFieldName(fieldName); }
+ virtual string getFieldName() const { return MED_FIELD_DRIVER<T>::getFieldName(); }
private:
- GENDRIVER * copy( void ) const ;
+ virtual GENDRIVER * copy ( void ) const { return new MED_FIELD_RDONLY_DRIVER<T>(*this); }
+protected:
+ GENDRIVER * _concreteFieldDrv;
+};
+template <class T> class MED_FIELD_WRONLY_DRIVER : public virtual IMED_FIELD_WRONLY_DRIVER<T> {
+public :
+ MED_FIELD_WRONLY_DRIVER();
+ MED_FIELD_WRONLY_DRIVER(const string & fileName, FIELD<T> * ptrField);
+
+ MED_FIELD_WRONLY_DRIVER(const MED_FIELD_WRONLY_DRIVER & fieldDriver):IMED_FIELD_WRONLY_DRIVER<T>(fieldDriver) { _concreteFieldDrv = fieldDriver._concreteFieldDrv->copy(); }
+ virtual ~MED_FIELD_WRONLY_DRIVER() { if (_concreteFieldDrv) delete _concreteFieldDrv;}
+ virtual void read ( void ) throw (MEDEXCEPTION) { _concreteFieldDrv->read(); }
+ virtual void write( void ) const throw (MEDEXCEPTION) { _concreteFieldDrv->write(); }
+ virtual void open() throw (MEDEXCEPTION) { _concreteFieldDrv->open(); }
+ virtual void close() { _concreteFieldDrv->close(); }
+ virtual void setFieldName(const string & fieldName) { _concreteFieldDrv->setFieldName(fieldName); }
+ virtual string getFieldName() const { return MED_FIELD_DRIVER<T>::getFieldName(); }
+private:
+ virtual GENDRIVER * copy ( void ) const { return new MED_FIELD_WRONLY_DRIVER<T>(*this); }
+protected:
+ GENDRIVER * _concreteFieldDrv;
};
+template <class T> class MED_FIELD_RDWR_DRIVER : public virtual IMED_FIELD_RDWR_DRIVER<T> {
+public:
+ MED_FIELD_RDWR_DRIVER();
+ /*!
+ Constructor.
+ */
+ MED_FIELD_RDWR_DRIVER(const string & fileName, FIELD<T> * ptrField);
+
+ MED_FIELD_RDWR_DRIVER(const MED_FIELD_RDWR_DRIVER & fieldDriver):
+ IMED_FIELD_RDWR_DRIVER<T>(fieldDriver)
+ { _concreteFieldDrv = fieldDriver._concreteFieldDrv->copy(); }
+ ~MED_FIELD_RDWR_DRIVER() { if (_concreteFieldDrv) delete _concreteFieldDrv;}
+ virtual void read ( void ) throw (MEDEXCEPTION) { _concreteFieldDrv->read(); }
+ virtual void write( void ) const throw (MEDEXCEPTION) { _concreteFieldDrv->write(); }
+ virtual void open() throw (MEDEXCEPTION) { _concreteFieldDrv->open(); }
+ virtual void close() { _concreteFieldDrv->close(); }
+ virtual void setFieldName(const string & fieldName) { _concreteFieldDrv->setFieldName(fieldName); }
+ virtual string getFieldName() const { return MED_FIELD_DRIVER<T>::getFieldName(); }
+private:
+ virtual GENDRIVER * copy ( void ) const { return new MED_FIELD_RDWR_DRIVER<T>(*this); }
+protected:
+ GENDRIVER * _concreteFieldDrv;
+};
+}
/*-------------------------*/
/* template implementation */
/*-------------------------*/
/*--------------------- DRIVER PART -------------------------------*/
-template <class T> void MED_FIELD_DRIVER<T>::setFieldName(const string & fieldName)
-{
- _fieldName = fieldName;
-}
+// template <class T> void MED_FIELD_DRIVER<T>::setFieldName(const string & fieldName)
+// {
+// _fieldName = fieldName;
+// }
-template <class T> string MED_FIELD_DRIVER<T>::getFieldName() const
-{
- return _fieldName;
-}
-
-// template <class T> void MED_FIELD_DRIVER<T>::search_field() {
-// const char * LOC = "template <class T> class MED_FIELD_DRIVER::search_field() :";
-
-// // we search the field number !!!!
-// if (_status==MED_OPENED)
-// if (_fieldNum==MED_INVALID) {
-// int err ;
-// int numberOfFields = 0; //MED_INVALID
-// // char fieldName[MED_TAILLE_NOM+1] = "";
-// char fieldName[MED_TAILLE_NOM+1] ;
-// int numberOfComponents = 0;
-// char * componentName = (char *) MED_NULL;
-// char * unitName = (char *) MED_NULL;
-// med_2_1::med_type_champ type ;
-// numberOfFields = med_2_1::MEDnChamp(_medIdt,0) ;
-// if ( numberOfFields <= 0 )
-// throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<": No Field found !"));
-// for (int i=1;i<=numberOfFields;i++) {
-
-// numberOfComponents = med_2_1::MEDnChamp(_medIdt,i) ;
-// if ( numberOfComponents <= 0 )
-// throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
-// << "Be careful there is no compound for field n°"
-// << i << "in file |"<<_fileName<<"| !"));
-
-// componentName = new char[numberOfComponents*MED_TAILLE_PNOM+1] ;
-// unitName = new char[numberOfComponents*MED_TAILLE_PNOM+1] ;
-
-// err = med_2_1::MEDchampInfo(_medIdt, i, fieldName, &type, componentName,
-// unitName, numberOfComponents) ;
-
-// delete[] componentName ;
-// delete[] unitName ;
-// MESSAGE("Champ "<<i<<" : #" << fieldName <<"# et recherche #"<<_fieldName.c_str()<<"#");
-// if ( !strcmp(fieldName,_fieldName.c_str()) ) {
-// MESSAGE("FOUND FIELD "<< fieldName <<" : "<<i);
-// _fieldNum = i ;
-// break ;
-// }
-// }
-// }
-// }
+// template <class T> string MED_FIELD_DRIVER<T>::getFieldName() const
+// {
+// return _fieldName;
+// }
-/*--------------------- RDONLY PART -------------------------------*/
+#include "MEDMEM_DriverFactory.hxx"
+#include "MEDMEM_MedFieldDriver21.hxx"
+#include "MEDMEM_MedFieldDriver22.hxx"
-template <class T> GENDRIVER * MED_FIELD_RDONLY_DRIVER<T>::copy(void) const
-{
- MED_FIELD_RDONLY_DRIVER<T> * myDriver =
- new MED_FIELD_RDONLY_DRIVER<T>(*this);
- return myDriver ;
-}
-template <class T> void MED_FIELD_RDONLY_DRIVER<T>::read(void)
- throw (MEDEXCEPTION)
-{
- const char * LOC = " MED_FIELD_RDONLY_DRIVER::read() " ;
- BEGIN_OF(LOC);
-
- if (MED_FIELD_DRIVER<T>::_ptrField->_name=="")
- MED_FIELD_DRIVER<T>::_ptrField->_name = MED_FIELD_DRIVER<T>::_fieldName ;
- else
- MED_FIELD_DRIVER<T>::_fieldName = MED_FIELD_DRIVER<T>::_ptrField->_name; // bug indetermine ! apres avoir fait readfilestruct, lorsque je recupere le champ, tout est bon sauf le nom du champ dans le driver !!!!!
-
- MESSAGE("###### "<<LOC<<" fieldNameDRIVER : "<<MED_FIELD_DRIVER<T>::_fieldName<<" fieldName : "<<MED_FIELD_DRIVER<T>::_ptrField->_name);
-
- string MeshName = MED_FIELD_DRIVER<T>::_ptrField->getSupport()->getMesh()->getName() ;
-
- if (MED_FIELD_DRIVER<T>::_status==MED_OPENED)
- {
-
- // search_field() ;
-
- char * fieldName ;
- fieldName = new char[MED_TAILLE_NOM+1] ;
- int err ;
- int numberOfComponents = 0;
- char * componentName = (char *) MED_NULL;
- char * unitName = (char *) MED_NULL;
- med_2_1::med_type_champ type ;
-
- // we search the field number !!!!
- if (MED_FIELD_DRIVER<T>::_fieldNum==MED_INVALID) {
- int numberOfFields = 0; //MED_INVALID
- numberOfFields = med_2_1::MEDnChamp(MED_FIELD_DRIVER<T>::_medIdt,0) ;
- if ( numberOfFields <= 0 )
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<": No Field found !"));
- for (int i=1;i<=numberOfFields;i++) {
-
- numberOfComponents = med_2_1::MEDnChamp(MED_FIELD_DRIVER<T>::_medIdt,i) ;
- if ( numberOfComponents <= 0 )
- // throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
- // << "Be careful there is no compound for field n°"
- // << i << "in file |"<<_fileName<<"| !"));
- MESSAGE(LOC<<"Be careful there is no compound for field n°"<<i<<"in file |"<<_fileName<<"| !");
-
- componentName = new char[numberOfComponents*MED_TAILLE_PNOM+1] ;
- unitName = new char[numberOfComponents*MED_TAILLE_PNOM+1] ;
-
- err = med_2_1::MEDchampInfo(MED_FIELD_DRIVER<T>::_medIdt, i, fieldName, &type, componentName,
- unitName, numberOfComponents) ;
-
- MESSAGE("Champ "<<i<<" : #" << fieldName <<"# et recherche #"<<MED_FIELD_DRIVER<T>::_fieldName.c_str()<<"#");
- if ( !strcmp(fieldName,MED_FIELD_DRIVER<T>::_fieldName.c_str()) ) {
- MESSAGE("FOUND FIELD "<< fieldName <<" : "<<i);
- MED_FIELD_DRIVER<T>::_fieldNum = i ;
- break ;
- }
- // not found : release memory and search next field !
- delete[] componentName ;
- delete[] unitName ;
- }
- }
-
- delete[] fieldName ;
-
- if (MED_FIELD_DRIVER<T>::_fieldNum==MED_INVALID)
- throw MEDEXCEPTION(LOCALIZED( STRING(LOC) << ": Field "<<MED_FIELD_DRIVER<T>::_fieldName << " not found in file " << MED_FIELD_DRIVER<T>::_fileName ) );
- MESSAGE ("FieldNum : "<<MED_FIELD_DRIVER<T>::_fieldNum);
-
- // int err ;
- // int NumberOfComponents = med_2_1::MEDnChamp(MED_FIELD_DRIVER<T>::_medIdt,MED_FIELD_DRIVER<T>::_fieldNum) ;
- if (numberOfComponents < 1)
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"no component")) ; // use iostring !
- // test type to check if it is rigth !!!???
- MED_FIELD_DRIVER<T>::_ptrField->_numberOfComponents = numberOfComponents ;
- MED_FIELD_DRIVER<T>::_ptrField->_componentsTypes = new int[numberOfComponents] ;
- MED_FIELD_DRIVER<T>::_ptrField->_componentsNames = new string[numberOfComponents] ;
- MED_FIELD_DRIVER<T>::_ptrField->_componentsUnits = new UNIT[numberOfComponents] ;
- MED_FIELD_DRIVER<T>::_ptrField->_componentsDescriptions = new string[numberOfComponents] ;
- MED_FIELD_DRIVER<T>::_ptrField->_MEDComponentsUnits = new string[numberOfComponents] ;
- for (int i=0; i<numberOfComponents; i++) {
- MED_FIELD_DRIVER<T>::_ptrField->_componentsTypes[i] = 1 ;
-
- // PG : what about space !!!
- MED_FIELD_DRIVER<T>::_ptrField->_componentsNames[i] = string(componentName,i*MED_TAILLE_PNOM,MED_TAILLE_PNOM) ;
- SCRUTE(MED_FIELD_DRIVER<T>::_ptrField->_componentsNames[i]);
- MED_FIELD_DRIVER<T>::_ptrField->_MEDComponentsUnits[i] = string(unitName,i*MED_TAILLE_PNOM,MED_TAILLE_PNOM) ;
- SCRUTE(MED_FIELD_DRIVER<T>::_ptrField->_MEDComponentsUnits[i]);
- }
- delete[] componentName;
- delete[] unitName;
-
- // read values for each geometric type in _support
- int NumberOfTypes = MED_FIELD_DRIVER<T>::_ptrField->_support->getNumberOfTypes() ;
- const MED_EN::medGeometryElement *Types = MED_FIELD_DRIVER<T>::_ptrField->_support->getTypes() ;
- T ** myValues = new T*[NumberOfTypes] ;
- int * NumberOfValues = new int[NumberOfTypes] ;
- int TotalNumberOfValues = 0 ;
- MESSAGE ("NumberOfTypes :"<< NumberOfTypes);
- _ptrField->_numberOfValues=0 ;
- for (int i=0; i<NumberOfTypes; i++) {
- MESSAGE ("Type["<<i+1<<"] :"<< Types[i]);
- MESSAGE ("Entity :"<<MED_FIELD_DRIVER<T>::_ptrField->_support->getEntity());
- NumberOfValues[i] =
- MEDnVal(MED_FIELD_DRIVER<T>::_medIdt,
- const_cast <char*> (MED_FIELD_DRIVER<T>::_fieldName.c_str()),
- (med_2_1::med_entite_maillage)MED_FIELD_DRIVER<T>::_ptrField->_support->getEntity(),
- (med_2_1::med_geometrie_element)Types[i],
- MED_FIELD_DRIVER<T>::_ptrField->_iterationNumber,
- MED_FIELD_DRIVER<T>::_ptrField->_orderNumber) ; // no time step ! prend en compte le nbre de pt de gauss
- // test if NumberOfValues is the same in _support !!! TODO that !!
- // we suppose it is
- // we could allocate array
- myValues[i] = new T[ NumberOfValues[i]*numberOfComponents ] ;
- TotalNumberOfValues+=NumberOfValues[i] ;// diviser par le nombre de point de gauss
- char * ProfilName = new char[MED_TAILLE_NOM+1];
- MESSAGE ("NumberOfValues :"<< NumberOfValues[i]);
- MESSAGE ("NumberOfComponents :"<< numberOfComponents);
- MESSAGE ("MESH_NAME :"<< MeshName.c_str());
- MESSAGE ("FIELD_NAME :"<< MED_FIELD_DRIVER<T>::_fieldName.c_str());
- MESSAGE ("MED_ENTITE :"<< (med_2_1::med_entite_maillage) MED_FIELD_DRIVER<T>::_ptrField->_support->getEntity());
- MESSAGE("MED_GEOM :"<<(med_2_1::med_geometrie_element)Types[i]);
- MESSAGE("Iteration :"<<MED_FIELD_DRIVER<T>::_ptrField->getIterationNumber());
- MESSAGE("Order :"<<MED_FIELD_DRIVER<T>::_ptrField->getOrderNumber());
- MED_FIELD_DRIVER<T>::_ptrField->_numberOfValues+=NumberOfValues[i]; // problem with gauss point : _numberOfValues != TotalNumberOfValues !!!!!!!
- med_2_1::med_err ret;
-#if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
- int lgth2=NumberOfValues[i]*numberOfComponents;
- if(_ptrField->getValueType()==MED_EN::MED_INT32)
- {
- med_2_1::med_int *temp=new med_2_1::med_int[lgth2];
- ret=med_2_1::MEDchampLire(MED_FIELD_DRIVER<T>::_medIdt,const_cast <char*> (MeshName.c_str()),
- const_cast <char*> (MED_FIELD_DRIVER<T>::_fieldName.c_str()),
- (unsigned char*) temp,
- med_2_1::MED_NO_INTERLACE,
- MED_ALL,
- ProfilName,
- (med_2_1::med_entite_maillage) MED_FIELD_DRIVER<T>::_ptrField->_support->getEntity(),(med_2_1::med_geometrie_element)Types[i],
- MED_FIELD_DRIVER<T>::_ptrField->getIterationNumber(),
- MED_FIELD_DRIVER<T>::_ptrField->getOrderNumber()
- );
- for(int i2=0;i2<lgth2;i2++)
- myValues[i][i2]=(int)(temp[i2]);
- delete [] temp;
- }
- else
-#endif
- ret=med_2_1::MEDchampLire(MED_FIELD_DRIVER<T>::_medIdt,const_cast <char*> (MeshName.c_str()),
- const_cast <char*> (MED_FIELD_DRIVER<T>::_fieldName.c_str()),
- (unsigned char*) myValues[i],
- med_2_1::MED_NO_INTERLACE,
- MED_ALL,
- ProfilName,
- (med_2_1::med_entite_maillage) MED_FIELD_DRIVER<T>::_ptrField->_support->getEntity(),(med_2_1::med_geometrie_element)Types[i],
- MED_FIELD_DRIVER<T>::_ptrField->getIterationNumber(),
- MED_FIELD_DRIVER<T>::_ptrField->getOrderNumber()
- );
- if (ret < 0) {
- // we must do some delete !!!
- for(int j=0; j<=i;j++)
- delete[] myValues[j];
- delete[] myValues;
- delete[] NumberOfValues ;
- delete[] ProfilName;
- delete[] MED_FIELD_DRIVER<T>::_ptrField->_componentsTypes ;
- delete[] MED_FIELD_DRIVER<T>::_ptrField->_componentsNames ;
- delete[] MED_FIELD_DRIVER<T>::_ptrField->_componentsUnits ;
- delete[] MED_FIELD_DRIVER<T>::_ptrField->_componentsDescriptions ;
- delete[] MED_FIELD_DRIVER<T>::_ptrField->_MEDComponentsUnits ;
- MED_FIELD_DRIVER<T>::_ptrField->_componentsTypes = NULL ;
- MED_FIELD_DRIVER<T>::_ptrField->_componentsNames = NULL ;
- MED_FIELD_DRIVER<T>::_ptrField->_componentsUnits = NULL ;
- MED_FIELD_DRIVER<T>::_ptrField->_componentsDescriptions = NULL ;
- MED_FIELD_DRIVER<T>::_ptrField->_MEDComponentsUnits = NULL ;
- MED_FIELD_DRIVER<T>::_fieldNum = MED_INVALID ; // we have not found right field, so reset the field number
- throw MEDEXCEPTION( LOCALIZED( STRING(LOC) <<": ERROR when read value")) ;
- }
-
- delete[] ProfilName ;
- }
- // allocate _value
- // probleme avec les points de gauss : voir lorsqu-il y en a (!= 1)
- // MEDARRAY<T> * Values = new MEDARRAY<T>(MED_FIELD_DRIVER<T>::_ptrField->getNumberOfComponents(),TotalNumberOfValues/MED_FIELD_DRIVER<T>::_ptrField->getNumberOfComponents(),MED_EN::MED_NO_INTERLACE);
-
- if (MED_FIELD_DRIVER<T>::_ptrField->_value==NULL)
- MED_FIELD_DRIVER<T>::_ptrField->_value=new MEDARRAY<T>(numberOfComponents,TotalNumberOfValues,MED_EN::MED_NO_INTERLACE);
-
- MEDARRAY<T> * Values = MED_FIELD_DRIVER<T>::_ptrField->_value ; // create by constructor ???
- // check if dimensions are right : inutile : c'est dans le constructeur !!!
- //if (Values->getLeadingValue() != numberOfComponents)
- // throw MEDEXCEPTION( LOCALIZED( STRING(LOC) <<": leading dimension are false : "<<Values->getLeadingValue()<<" and "<<numberOfComponents) ) ;
- //if (Values->getLengthValue() != TotalNumberOfValues)
- // throw MEDEXCEPTION( LOCALIZED( STRING(LOC) <<": length dimension are false : "<<Values->getLengthValue()<<" and "<<TotalNumberOfValues) ) ;
-
- for (int i=0; i<numberOfComponents; i++) {
- //T * ValuesT = Values->getRow(i+1) ;
- int Count = 1 ;
- for (int j=0; j<NumberOfTypes; j++) {
- T * myValue = myValues[j] ;
- int NumberOf = NumberOfValues[j] ;
-// MED_FIELD_DRIVER<T>::_ptrField->_numberOfValues+=NumberOf; // problem with gauss point : _numberOfValues != TotalNumberOfValues !!!!!!!
- int offset = NumberOf*i ;
- for (int k=0 ; k<NumberOf; k++) {
- //ValuesT[Count]=myValue[k+offset] ;
- Values->setIJ(Count,i+1,myValue[k+offset]);
- SCRUTE(Count);
- SCRUTE(Values->getIJ(Count,i+1));
- Count++;
- }
- }
- }
-
- for (int j=0; j<NumberOfTypes; j++)
- delete[] myValues[j] ;
- delete[] myValues ;
- delete[] NumberOfValues ;
-
- MED_FIELD_DRIVER<T>::_ptrField->_isRead = true ;
- }
-
- END_OF(LOC);
-}
+/*--------------------- RDONLY PART -------------------------------*/
+namespace MEDMEM {
-template <class T> void MED_FIELD_RDONLY_DRIVER<T>::write( void ) const
+template <class T> void IMED_FIELD_RDONLY_DRIVER<T>::write( void ) const
throw (MEDEXCEPTION)
{
throw MEDEXCEPTION("MED_FIELD_RDONLY_DRIVER::write : Can't write with a RDONLY driver !");
}
-/*--------------------- WRONLY PART -------------------------------*/
+template <class T> MED_FIELD_RDONLY_DRIVER<T>::MED_FIELD_RDONLY_DRIVER() {
+ MESSAGE("You are using the default constructor of the Field read only Driver and it is 2.1 one");
+ _concreteFieldDrv=new MED_FIELD_RDONLY_DRIVER21<T>();
+}
-template <class T> GENDRIVER * MED_FIELD_WRONLY_DRIVER<T>::copy(void) const
-{
- MED_FIELD_WRONLY_DRIVER<T> * myDriver =
- new MED_FIELD_WRONLY_DRIVER<T>(*this);
- return myDriver ;
+template <class T> MED_FIELD_RDONLY_DRIVER<T>::MED_FIELD_RDONLY_DRIVER(const string & fileName, FIELD<T> * ptrField)
+ {
+ BEGIN_OF("MED_FIELD_RDONLY_DRIVER::MED_FIELD_RDONLY_DRIVER(const string & fileName, const FIELD<T> * ptrField)");
+
+ _concreteFieldDrv = DRIVERFACTORY::buildFieldDriverFromFile(fileName,ptrField,MED_EN::MED_LECT);
+
+ END_OF("MED_FIELD_RDONLY_DRIVER::MED_FIELD_RDONLY_DRIVER(const string & fileName, const FIELD<T> * ptrField)");
}
-template <class T> void MED_FIELD_WRONLY_DRIVER<T>::read (void)
+/*--------------------- WRONLY PART -------------------------------*/
+
+template <class T> void IMED_FIELD_WRONLY_DRIVER<T>::read (void)
throw (MEDEXCEPTION)
{
throw MEDEXCEPTION("MED_FIELD_WRONLY_DRIVER::read : Can't read with a WRONLY driver !");
}
-template <class T> void MED_FIELD_WRONLY_DRIVER<T>::write(void) const
- throw (MEDEXCEPTION)
-{
- const char * LOC = "MED_FIELD_WRONLY_DRIVER::write(void) const " ;
- BEGIN_OF(LOC);
- if (MED_FIELD_DRIVER<T>::_status==MED_OPENED)
- {
- int err ;
-
- int component_count=MED_FIELD_DRIVER<T>::_ptrField->getNumberOfComponents();
- string component_name(component_count*MED_TAILLE_PNOM,' ') ;
- string component_unit(component_count*MED_TAILLE_PNOM,' ') ;
-
- const string * listcomponent_name=MED_FIELD_DRIVER<T>::_ptrField->getComponentsNames() ;
- const string * listcomponent_unit=MED_FIELD_DRIVER<T>::_ptrField->getMEDComponentsUnits() ;
- int length ;
- for (int i=0; i < component_count ; i++) {
- length = min(MED_TAILLE_PNOM,(int)listcomponent_name[i].size());
- component_name.replace(i*MED_TAILLE_PNOM,length,
- listcomponent_name[i],0,length);
- length = min(MED_TAILLE_PNOM,(int)listcomponent_unit[i].size());
- component_unit.replace(i*MED_TAILLE_PNOM,length,
- listcomponent_unit[i],0,length);
- }
-
- MESSAGE("component_name=|"<<component_name<<"|");
- MESSAGE("component_unit=|"<<component_unit<<"|");
-
- MED_EN::med_type_champ ValueType=MED_FIELD_DRIVER<T>::_ptrField->getValueType() ;
-
- MESSAGE("Template Type =|"<<ValueType<<"|");
-
- // le champ existe deja ???
- char * champName = new char[MED_TAILLE_NOM+1] ;
- med_2_1::med_type_champ type ;
- char * compName ;
- char * compUnit ;
- bool Find = false ;
- int n = med_2_1::MEDnChamp(MED_FIELD_DRIVER<T>::_medIdt,0);
- int nbComp ;
- for (int i=1; i<=n; i++) {
- nbComp = med_2_1::MEDnChamp(MED_FIELD_DRIVER<T>::_medIdt,i);
- compName = new char[MED_TAILLE_PNOM*nbComp+1];
- compUnit = new char[MED_TAILLE_PNOM*nbComp+1];
- err = med_2_1::MEDchampInfo(MED_FIELD_DRIVER<T>::_medIdt,i,champName,&type,compName,compUnit,nbComp);
- if (err == 0)
- if (strcmp(champName,MED_FIELD_DRIVER<T>::_ptrField->getName().c_str())==0) { // Found !
- Find = true ;
- break ;
- }
- delete[] compName ;
- delete[] compUnit ;
- }
- delete[] champName ;
- if (Find) {
- // the same ?
- if (nbComp != component_count)
- throw MEDEXCEPTION( LOCALIZED (STRING(LOC)
- <<": Field exist in file, but number of component are different : "<<nbComp<<" in file and "<<component_count<<" in memory."
- )
- );
- // component name and unit
- MESSAGE(LOC<<" Component name in file : "<<compName);
- MESSAGE(LOC<<" Component name in memory : "<<component_name);
- MESSAGE(LOC<<" Component unit in file : "<<compUnit);
- MESSAGE(LOC<<" Component unit in memory : "<<component_unit);
- delete[] compName ;
- delete[] compUnit ;
-
- } else {
- // Verify the field doesn't exist
-
- string dataGroupName = "/CHA/";
- dataGroupName += MED_FIELD_DRIVER<T>::_ptrField->getName();
- MESSAGE(LOC << "|" << dataGroupName << "|" );
- MED_EN::med_idt gid = H5Gopen(MED_FIELD_DRIVER<T>::_medIdt, dataGroupName.c_str() );
-
- if ( gid < 0 ) {
- // create field :
- err=med_2_1::MEDchampCr(MED_FIELD_DRIVER<T>::_medIdt,
- const_cast <char*> ((MED_FIELD_DRIVER<T>::_ptrField->getName()).c_str()),
- (med_2_1::med_type_champ) ValueType,
- const_cast <char*> ( component_name.c_str() ),
- const_cast <char*> ( component_unit.c_str() ),
- component_count);
- if ( err < 0 )
- throw MEDEXCEPTION( LOCALIZED (STRING(LOC)
- << ": Error MEDchampCr : "<<err
- )
- );
- }
- else H5Gclose(gid);
- }
-
- const SUPPORT * mySupport = MED_FIELD_DRIVER<T>::_ptrField->getSupport() ;
-
- if (! mySupport->isOnAllElements())
- throw MEDEXCEPTION( LOCALIZED (STRING(LOC)
- <<": Field must be on all entity"
- )
- );
-
- MESH * myMesh = mySupport->getMesh() ;
- string MeshName = myMesh->getName() ;
- //MED_EN::medModeSwitch Mode = MED_FIELD_DRIVER<T>::_ptrField->_value->getMode() ;
- // on boucle sur tout les types pour ecrire les tableaux de valeur
- int NumberOfType = mySupport->getNumberOfTypes() ;
- int Index = 1 ;
- const MED_EN::medGeometryElement * Types = mySupport->getTypes() ;
- const int * NumberOfGaussPoint = mySupport->getNumberOfGaussPoint() ;
- for (int i=0;i<NumberOfType;i++) {
- int NumberOfElements = mySupport->getNumberOfElements(Types[i]) ;
-
- const T * value = MED_FIELD_DRIVER<T>::_ptrField->getValueI(MED_EN::MED_FULL_INTERLACE,Index) ;
-
- MESSAGE("MED_FIELD_DRIVER<T>::_medIdt : "<<MED_FIELD_DRIVER<T>::_medIdt);
- MESSAGE("MeshName.c_str() : "<<MeshName.c_str());
- MESSAGE("MED_FIELD_DRIVER<T>::_ptrField->getName() : "<<MED_FIELD_DRIVER<T>::_ptrField->getName());
- MESSAGE("value : "<<value);
- MESSAGE("NumberOfElements : "<<NumberOfElements);
- MESSAGE("NumberOfGaussPoint[i] : "<<NumberOfGaussPoint[i]);
- MESSAGE("mySupport->getEntity() : "<<mySupport->getEntity());
- MESSAGE("Types[i] : "<<Types[i]);
- MESSAGE("MED_FIELD_DRIVER<T>::_ptrField->getIterationNumber() : "<<MED_FIELD_DRIVER<T>::_ptrField->getIterationNumber());
- MESSAGE("MED_FIELD_DRIVER<T>::_ptrField->getTime() : "<<MED_FIELD_DRIVER<T>::_ptrField->getTime());
- MESSAGE("MED_FIELD_DRIVER<T>::_ptrField->getOrderNumber() : "<<MED_FIELD_DRIVER<T>::_ptrField->getOrderNumber());
-
-/* char chanom[MED_TAILLE_NOM+1];
- char chacomp[MED_TAILLE_NOM+1];
- char chaunit[MED_TAILLE_NOM+1];
- med_2_1::med_type_champ chatype;
- med_int chancomp=1;
-
- err=med_2_1::MEDchampInfo(MED_FIELD_DRIVER<T>::_medIdt,1,chanom,&chatype,chacomp,chaunit,chancomp);
-
- if (err<0)
- {
- cout<<"=======================================================================> gros probleme"<<endl;
- exit(-1);
- }
- cout<<"==================> nom lu = "<<chanom<<endl;
- cout<<"==================> type lu = "<<chatype<<endl;
- cout<<"==================> nom composante lu = "<<chacomp<<endl;
- cout<<"==================> nom unit lu = "<<chaunit<<endl;
- cout<<"==================> valeur de med_2_1::MED_REEL64 = "<<med_2_1::MED_REEL64<<endl;
-*/
-#if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
- if(_ptrField->getValueType()==MED_EN::MED_INT32)
- {
- int lgth2=_ptrField->getNumberOfValues();
- med_2_1::med_int *temp=new med_2_1::med_int[lgth2];
- for(int i2=0;i2<lgth2;i2++)
- temp[i2]=(int)(value[i2]);
- err=med_2_1::MEDchampEcr(MED_FIELD_DRIVER<T>::_medIdt,
- const_cast <char*> ( MeshName.c_str()) , //( string(mesh_name).resize(MED_TAILLE_NOM).c_str())
- const_cast <char*> ( (MED_FIELD_DRIVER<T>::_ptrField->getName()).c_str()),
- (unsigned char*)temp,
- med_2_1::MED_FULL_INTERLACE,
- NumberOfElements,
- NumberOfGaussPoint[i],
- MED_ALL,
- MED_NOPFL,
- med_2_1::MED_REMP, // PROFIL NON GERE, mode de remplacement non géré
- (med_2_1::med_entite_maillage)mySupport->getEntity(),
- (med_2_1::med_geometrie_element)Types[i],
- MED_FIELD_DRIVER<T>::_ptrField->getIterationNumber(),
- " ",
- MED_FIELD_DRIVER<T>::_ptrField->getTime(),
- MED_FIELD_DRIVER<T>::_ptrField->getOrderNumber()
- );
- delete [] temp;
- }
- else
-#endif
- err=med_2_1::MEDchampEcr(MED_FIELD_DRIVER<T>::_medIdt,
- const_cast <char*> ( MeshName.c_str()) , //( string(mesh_name).resize(MED_TAILLE_NOM).c_str())
- const_cast <char*> ( (MED_FIELD_DRIVER<T>::_ptrField->getName()).c_str()),
- (unsigned char*)value,
- med_2_1::MED_FULL_INTERLACE,
- NumberOfElements,
- NumberOfGaussPoint[i],
- MED_ALL,
- MED_NOPFL,
- med_2_1::MED_REMP, // PROFIL NON GERE, mode de remplacement non géré
- (med_2_1::med_entite_maillage)mySupport->getEntity(),
- (med_2_1::med_geometrie_element)Types[i],
- MED_FIELD_DRIVER<T>::_ptrField->getIterationNumber(),
- " ",
- MED_FIELD_DRIVER<T>::_ptrField->getTime(),
- MED_FIELD_DRIVER<T>::_ptrField->getOrderNumber()
- );
- if (err < MED_VALID )
- throw MEDEXCEPTION(LOCALIZED( STRING(LOC)
- <<": Error in writing Field "<< MED_FIELD_DRIVER<T>::_ptrField->getName() <<", type "<<Types[i]
- )
- );
-
- Index += NumberOfElements ;
-
- }
- }
-
- END_OF(LOC);
+template <class T> MED_FIELD_WRONLY_DRIVER<T>::MED_FIELD_WRONLY_DRIVER() {
+ MESSAGE("You are using the default constructor of the Field write only Driver and it is 2.1 one");
+
+ _concreteFieldDrv=new MED_FIELD_WRONLY_DRIVER21<T>();
+}
+
+template <class T> MED_FIELD_WRONLY_DRIVER<T>::MED_FIELD_WRONLY_DRIVER(const string & fileName, FIELD<T> * ptrField)
+ {
+ BEGIN_OF("MED_FIELD_WRONLY_DRIVER::MED_FIELD_WRONLY_DRIVER(const string & fileName, const FIELD<T> * ptrField)");
+
+ _concreteFieldDrv = DRIVERFACTORY::buildFieldDriverFromFile(fileName,ptrField,MED_EN::MED_ECRI);
+
+ END_OF("MED_FIELD_RDONLY_DRIVER::MED_FIELD_RDONLY_DRIVER(const string & fileName, const FIELD<T> * ptrField)");
}
/*--------------------- RDWR PART -------------------------------*/
-template <class T> GENDRIVER * MED_FIELD_RDWR_DRIVER<T>::copy(void) const
-{
- MED_FIELD_RDWR_DRIVER<T> * myDriver =
- new MED_FIELD_RDWR_DRIVER<T>(*this);
- return myDriver ;
+template <class T> MED_FIELD_RDWR_DRIVER<T>::MED_FIELD_RDWR_DRIVER() {
+ MESSAGE("You are using the default constructor of the Field read/write Driver and it is 2.1 one");
+
+ _concreteFieldDrv=new MED_FIELD_RDWR_DRIVER21<T>();
}
-template <class T> void MED_FIELD_RDWR_DRIVER<T>::write(void) const
- throw (MEDEXCEPTION)
-{
- BEGIN_OF("MED_FIELD_RDWR_DRIVER::write(void)");
- MED_FIELD_WRONLY_DRIVER<T>::write();
- END_OF("MED_FIELD_RDWR_DRIVER::write(void)");
-}
+template <class T> MED_FIELD_RDWR_DRIVER<T>::MED_FIELD_RDWR_DRIVER(const string & fileName, FIELD<T> * ptrField)
+ {
+ BEGIN_OF("MED_FIELD_RDWR_DRIVER::MED_FIELD_RDWR_DRIVER(const string & fileName, const FIELD<T> * ptrField)");
-template <class T> void MED_FIELD_RDWR_DRIVER<T>::read (void)
- throw (MEDEXCEPTION)
-{
- BEGIN_OF("MED_FIELD_RDWR_DRIVER::read(void)");
- MED_FIELD_RDONLY_DRIVER<T>::read();
- END_OF("MED_FIELD_RDWR_DRIVER::read(void)");
+ _concreteFieldDrv = DRIVERFACTORY::buildFieldDriverFromFile(fileName,ptrField,MED_EN::MED_REMP);
+
+ END_OF("MED_FIELD_RDWR_DRIVER::MED_FIELD_RDWR_DRIVER(const string & fileName, const FIELD<T> * ptrField)");
}
+
+
}//End namespace MEDMEM
/*-----------------------------------------------------------------*/
--- /dev/null
+#ifndef MED_FIELD_DRIVER21_HXX
+#define MED_FIELD_DRIVER21_HXX
+
+#include <string>
+
+#include "MEDMEM_define.hxx"
+
+#include "MEDMEM_GenDriver.hxx"
+#include "utilities.h"
+#include "MEDMEM_MedFieldDriver.hxx"
+#include "MEDMEM_STRING.hxx"
+#include "MEDMEM_Exception.hxx"
+#include "MEDMEM_Unit.hxx"
+#include "MEDMEM_Array.hxx"
+#include "MEDMEM_Support.hxx"
+#include "MEDMEM_Mesh.hxx"
+
+namespace MEDMEM {
+template <class T> class FIELD;
+
+// A QD LA CLASSE MED_ALL_ELEMENTS_DRIVER.... :) pour mutualiser le open ..... avec led _medIdt...
+
+/*!
+
+ Driver Med for FIELD.
+
+ Generic part : implement open and close methods.
+
+*/
+
+template <class T> class MED_FIELD_DRIVER21 : public virtual MED_FIELD_DRIVER<T>
+{
+protected:
+ med_2_1::med_idt _medIdt;
+
+ void search_field() ;
+public :
+
+ // all MED cell type ?? Classe de Définition ??
+ // static const medGeometryElement all_cell_type[MED_NBR_GEOMETRIE_MAILLE];
+
+ // static const char * const all_cell_type_tab [MED_NBR_GEOMETRIE_MAILLE];
+
+ /*!
+ Constructor.
+ */
+ MED_FIELD_DRIVER21():MED_FIELD_DRIVER<T>(),_medIdt(MED_INVALID)
+ {}
+ /*!
+ Constructor.
+ */
+ MED_FIELD_DRIVER21(const string & fileName, FIELD<T> * ptrField,
+ MED_EN::med_mode_acces accessMode)
+ : MED_FIELD_DRIVER<T>(fileName,ptrField,accessMode),_medIdt(MED_INVALID)
+ {
+ }
+
+ /*!
+ Copy constructor.
+ */
+ MED_FIELD_DRIVER21(const MED_FIELD_DRIVER21 & fieldDriver):
+ MED_FIELD_DRIVER<T>(fieldDriver), _medIdt(fieldDriver._medIdt)
+ {
+ }
+
+ /*!
+ Destructor.
+ */
+ virtual ~MED_FIELD_DRIVER21() {
+ }
+
+ void open() throw (MEDEXCEPTION)
+ {
+ const char * LOC = "MED_FIELD_DRIVER21::open() ";
+ BEGIN_OF(LOC);
+
+ // we must set fieldname before open, because we must find field number in file (if it exist !!!)
+ if ( MED_FIELD_DRIVER<T>::_fileName == "" )
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+ << "_fileName is |\"\"|, please set a correct fileName before calling open()"
+ )
+ );
+
+ MESSAGE(LOC<<"_fileName.c_str : "<< MED_FIELD_DRIVER<T>::_fileName.c_str()<<",mode : "<< MED_FIELD_DRIVER<T>::_accessMode);
+ _medIdt = med_2_1::MEDouvrir( (const_cast <char *> (MED_FIELD_DRIVER<T>::_fileName.c_str())),(med_2_1::med_mode_acces) MED_FIELD_DRIVER<T>::_accessMode);
+ MESSAGE(LOC<<"_medIdt : "<< _medIdt );
+ if (_medIdt > 0)
+ MED_FIELD_DRIVER<T>::_status=MED_OPENED;
+ else {
+ MED_FIELD_DRIVER<T>::_status = MED_INVALID;
+ MED_FIELD_DRIVER21<T>::_medIdt = MED_INVALID;
+ throw MED_EXCEPTION (LOCALIZED( STRING(LOC)
+ << "Can't open |" << MED_FIELD_DRIVER<T>::_fileName
+ << "|, _medIdt : " << MED_FIELD_DRIVER21<T>::_medIdt
+ )
+ );
+ }
+
+ END_OF(LOC);
+ }
+
+ void close() {
+ BEGIN_OF("MED_FIELD_DRIVER21::close()");
+ med_2_1::med_int err = 0;
+ if (MED_FIELD_DRIVER<T>::_status == MED_OPENED) {
+ err=med_2_1::MEDfermer(MED_FIELD_DRIVER21<T>::_medIdt);
+ //H5close(); // If we call H5close() all the files are closed.
+ MED_FIELD_DRIVER<T>::_status = MED_CLOSED;
+ MED_FIELD_DRIVER21<T>::_medIdt = MED_INVALID;
+ MESSAGE(" MED_FIELD_DRIVER21::close() : MEDfermer : MED_FIELD_DRIVER<T>::_medIdt= " << _medIdt );
+ MESSAGE(" MED_FIELD_DRIVER21::close() : MEDfermer : err = " << err );
+ }
+ END_OF("MED_FIELD_DRIVER21::close()");
+ }
+
+
+};
+
+/*!
+
+ Driver Med for FIELD : Read only.
+
+ Implement read method.
+
+*/
+
+ template <class T> class MED_FIELD_RDONLY_DRIVER21 : public virtual MED_FIELD_DRIVER21<T>, public virtual IMED_FIELD_RDONLY_DRIVER<T>
+{
+
+public :
+
+ /*!
+ Constructor.
+ */
+ MED_FIELD_RDONLY_DRIVER21():MED_FIELD_DRIVER<T>() {};
+
+ /*!
+ Constructor.
+ */
+ MED_FIELD_RDONLY_DRIVER21(const string & fileName, FIELD<T> * ptrField):
+ IMED_FIELD_RDONLY_DRIVER<T>(fileName,ptrField),
+ MED_FIELD_DRIVER21<T>(fileName,ptrField,MED_EN::MED_RDONLY),
+ MED_FIELD_DRIVER<T>(fileName,ptrField,MED_EN::MED_RDONLY)
+ {
+ BEGIN_OF("MED_FIELD_RDONLY_DRIVER21::MED_FIELD_RDONLY_DRIVER21(const string & fileName, const FIELD<T> * ptrField)");
+ END_OF("MED_FIELD_RDONLY_DRIVER21::MED_FIELD_RDONLY_DRIVER21(const string & fileName, const FIELD<T> * ptrField)");
+ }
+
+ /*!
+ Copy constructor.
+ */
+ MED_FIELD_RDONLY_DRIVER21(const MED_FIELD_RDONLY_DRIVER21 & fieldDriver):
+ IMED_FIELD_RDONLY_DRIVER<T>(fieldDriver),
+ MED_FIELD_DRIVER21<T>(fieldDriver),
+ MED_FIELD_DRIVER<T>(fieldDriver)
+ {};
+
+ /*!
+ Destructor.
+ */
+ virtual ~MED_FIELD_RDONLY_DRIVER21() {};
+
+ // 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 FIELD in the specified file.
+ */
+ void read ( void ) throw (MEDEXCEPTION) ;
+
+private:
+ GENDRIVER * copy( void ) const ;
+
+};
+
+/*!
+
+ Driver Med for FIELD : Write only.
+
+ Implement write method.
+
+*/
+
+template <class T> class MED_FIELD_WRONLY_DRIVER21 : public virtual MED_FIELD_DRIVER21<T>, public virtual IMED_FIELD_WRONLY_DRIVER<T> {
+
+public :
+
+ /*!
+ Constructor.
+ */
+ MED_FIELD_WRONLY_DRIVER21():MED_FIELD_DRIVER<T>() {}
+
+ /*!
+ Constructor.
+ */
+ MED_FIELD_WRONLY_DRIVER21(const string & fileName, FIELD<T> * ptrField):
+ IMED_FIELD_WRONLY_DRIVER<T>(fileName,ptrField),
+ MED_FIELD_DRIVER21<T>(fileName,ptrField,MED_EN::MED_WRONLY),
+ MED_FIELD_DRIVER<T>(fileName,ptrField,MED_EN::MED_WRONLY)
+ {
+ BEGIN_OF("MED_FIELD_WRONLY_DRIVER21::MED_FIELD_WRONLY_DRIVER21(const string & fileName, const FIELD<T> * ptrField)");
+ END_OF("MED_FIELD_WRONLY_DRIVER21::MED_FIELD_WRONLY_DRIVER21(const string & fileName, const FIELD<T> * ptrField)");
+ }
+
+ /*!
+ Copy constructor.
+ */
+ MED_FIELD_WRONLY_DRIVER21(const MED_FIELD_WRONLY_DRIVER21 & fieldDriver):
+ IMED_FIELD_WRONLY_DRIVER<T>(fieldDriver),
+ MED_FIELD_DRIVER21<T>(fieldDriver),
+ MED_FIELD_DRIVER<T>(fieldDriver)
+ {}
+
+ /*!
+ Destructor.
+ */
+ virtual ~MED_FIELD_WRONLY_DRIVER21() {};
+
+ /*!
+ Write FIELD 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:
+ GENDRIVER * copy( void ) const ;
+
+};
+
+
+/*!
+
+ Driver Med for FIELD : Read write.
+ - Use read method from MED_FIELD_RDONLY_DRIVER
+ - Use write method from MED_FIELD_WDONLY_DRIVER
+
+*/
+
+template <class T> class MED_FIELD_RDWR_DRIVER21 : public MED_FIELD_RDONLY_DRIVER21<T>, public MED_FIELD_WRONLY_DRIVER21<T>, public IMED_FIELD_RDWR_DRIVER<T> {
+
+public :
+
+ /*!
+ Constructor.
+ */
+ MED_FIELD_RDWR_DRIVER21():MED_FIELD_DRIVER21<T>() {}
+
+ /*!
+ Constructor.
+ */
+ MED_FIELD_RDWR_DRIVER21(const string & fileName, FIELD<T> * ptrField):
+ MED_FIELD_WRONLY_DRIVER21<T>(fileName,ptrField),
+ MED_FIELD_RDONLY_DRIVER21<T>(fileName,ptrField),
+ IMED_FIELD_RDONLY_DRIVER<T>(fileName,ptrField),
+ IMED_FIELD_WRONLY_DRIVER<T>(fileName,ptrField),
+ MED_FIELD_DRIVER<T>(fileName,ptrField,MED_EN::MED_RDWR),
+ IMED_FIELD_RDWR_DRIVER<T>(fileName,ptrField)
+ {
+ BEGIN_OF("MED_FIELD_RDWR_DRIVER21::MED_FIELD_RDWR_DRIVER21(const string & fileName, const FIELD<T> * ptrField)");
+ //_accessMode = MED_RDWR ;
+ END_OF("MED_FIELD_RDWR_DRIVER21::MED_FIELD_RDWR_DRIVER21(const string & fileName, const FIELD<T> * ptrField)");
+ };
+
+ /*!
+ Copy constructor.
+ */
+ MED_FIELD_RDWR_DRIVER21(const MED_FIELD_RDWR_DRIVER21 & fieldDriver):
+ MED_FIELD_WRONLY_DRIVER21<T>(fieldDriver),
+ MED_FIELD_RDONLY_DRIVER21<T>(fieldDriver),
+ IMED_FIELD_RDWR_DRIVER<T>(fieldDriver),
+ IMED_FIELD_RDONLY_DRIVER<T>(fieldDriver),
+ IMED_FIELD_WRONLY_DRIVER<T>(fieldDriver),
+ MED_FIELD_DRIVER<T>(fieldDriver)
+ {};
+
+ /*!
+ Destructor.
+ */
+ ~MED_FIELD_RDWR_DRIVER21() {};
+
+ /*!
+ Write FIELD in the specified file.
+ */
+ void write(void) const throw (MEDEXCEPTION) ;
+ /*!
+ Read FIELD in the specified file.
+ */
+ void read (void) throw (MEDEXCEPTION) ;
+
+private:
+ GENDRIVER * copy( void ) const ;
+
+};
+
+/*--------------------- DRIVER PART -------------------------------*/
+
+// template <class T> void MED_FIELD_DRIVER<T>::search_field() {
+// const char * LOC = "template <class T> class MED_FIELD_DRIVER::search_field() :";
+
+// // we search the field number !!!!
+// if (_status==MED_OPENED)
+// if (_fieldNum==MED_INVALID) {
+// int err ;
+// int numberOfFields = 0; //MED_INVALID
+// // char fieldName[MED_TAILLE_NOM+1] = "";
+// char fieldName[MED_TAILLE_NOM+1] ;
+// int numberOfComponents = 0;
+// char * componentName = (char *) MED_NULL;
+// char * unitName = (char *) MED_NULL;
+// med_2_1::med_type_champ type ;
+// numberOfFields = med_2_1::MEDnChamp(_medIdt,0) ;
+// if ( numberOfFields <= 0 )
+// throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<": No Field found !"));
+// for (int i=1;i<=numberOfFields;i++) {
+
+// numberOfComponents = med_2_1::MEDnChamp(_medIdt,i) ;
+// if ( numberOfComponents <= 0 )
+// throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+// << "Be careful there is no compound for field n°"
+// << i << "in file |"<<_fileName<<"| !"));
+
+// componentName = new char[numberOfComponents*MED_TAILLE_PNOM+1] ;
+// unitName = new char[numberOfComponents*MED_TAILLE_PNOM+1] ;
+
+// err = med_2_1::MEDchampInfo(_medIdt, i, fieldName, &type, componentName,
+// unitName, numberOfComponents) ;
+
+// delete[] componentName ;
+// delete[] unitName ;
+// MESSAGE("Champ "<<i<<" : #" << fieldName <<"# et recherche #"<<_fieldName.c_str()<<"#");
+// if ( !strcmp(fieldName,_fieldName.c_str()) ) {
+// MESSAGE("FOUND FIELD "<< fieldName <<" : "<<i);
+// _fieldNum = i ;
+// break ;
+// }
+// }
+// }Srdwr
+// }
+
+/*--------------------- RDONLY PART -------------------------------*/
+
+template <class T> GENDRIVER * MED_FIELD_RDONLY_DRIVER21<T>::copy(void) const
+{
+ return new MED_FIELD_RDONLY_DRIVER21<T>(*this);
+}
+
+template <class T> void MED_FIELD_RDONLY_DRIVER21<T>::read(void)
+ throw (MEDEXCEPTION)
+{
+ const char * LOC = " MED_FIELD_RDONLY_DRIVER21::read() " ;
+ BEGIN_OF(LOC);
+
+ if (MED_FIELD_DRIVER<T>::_ptrField->_name=="")
+ MED_FIELD_DRIVER<T>::_ptrField->_name = MED_FIELD_DRIVER<T>::_fieldName ;
+ else
+ MED_FIELD_DRIVER<T>::_fieldName = MED_FIELD_DRIVER<T>::_ptrField->_name; // bug indetermine ! apres avoir fait readfilestruct, lorsque je recupere le champ, tout est bon sauf le nom du champ dans le driver !!!!!
+
+ MESSAGE("###### "<<LOC<<" fieldNameDRIVER : "<<MED_FIELD_DRIVER<T>::_fieldName<<" fieldName : "<<MED_FIELD_DRIVER<T>::_ptrField->_name);
+
+ string MeshName = MED_FIELD_DRIVER<T>::_ptrField->getSupport()->getMesh()->getName() ;
+
+ if (MED_FIELD_DRIVER<T>::_status==MED_OPENED)
+ {
+
+ // search_field() ;
+
+ char * fieldName ;
+ fieldName = new char[MED_TAILLE_NOM+1] ;
+ int err ;
+ int numberOfComponents = 0;
+ char * componentName = (char *) MED_NULL;
+ char * unitName = (char *) MED_NULL;
+ med_2_1::med_type_champ type ;
+
+ // we search the field number !!!!
+ if (MED_FIELD_DRIVER<T>::_fieldNum==MED_INVALID) {
+ int numberOfFields = 0; //MED_INVALID
+ numberOfFields = med_2_1::MEDnChamp(MED_FIELD_DRIVER21<T>::_medIdt,0) ;
+ if ( numberOfFields <= 0 )
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<": No Field found !"));
+ for (int i=1;i<=numberOfFields;i++) {
+
+ numberOfComponents = med_2_1::MEDnChamp(MED_FIELD_DRIVER21<T>::_medIdt,i) ;
+ if ( numberOfComponents <= 0 )
+ // throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+ // << "Be careful there is no compound for field n°"
+ // << i << "in file |"<<_fileName<<"| !"));
+ MESSAGE(LOC<<"Be careful there is no compound for field n°"<<i<<"in file |"<<MED_FIELD_DRIVER<T>::_fileName<<"| !");
+
+ componentName = new char[numberOfComponents*MED_TAILLE_PNOM21+1] ;
+ unitName = new char[numberOfComponents*MED_TAILLE_PNOM21+1] ;
+
+ err = med_2_1::MEDchampInfo(MED_FIELD_DRIVER21<T>::_medIdt, i, fieldName, &type, componentName,
+ unitName, numberOfComponents) ;
+
+ MESSAGE("Champ "<<i<<" : #" << fieldName <<"# et recherche #"<<MED_FIELD_DRIVER<T>::_fieldName.c_str()<<"#");
+ if ( !strcmp(fieldName,MED_FIELD_DRIVER<T>::_fieldName.c_str()) ) {
+ MESSAGE("FOUND FIELD "<< fieldName <<" : "<<i);
+ MED_FIELD_DRIVER<T>::_fieldNum = i ;
+ break ;
+ }
+ // not found : release memory and search next field !
+ delete[] componentName ;
+ delete[] unitName ;
+ }
+ }
+
+ delete[] fieldName ;
+
+ if (MED_FIELD_DRIVER<T>::_fieldNum==MED_INVALID)
+ throw MEDEXCEPTION(LOCALIZED( STRING(LOC) << ": Field "<<MED_FIELD_DRIVER<T>::_fieldName << " not found in file " << MED_FIELD_DRIVER<T>::_fileName ) );
+ MESSAGE ("FieldNum : "<<MED_FIELD_DRIVER<T>::_fieldNum);
+
+ // int err ;
+ // int NumberOfComponents = med_2_1::MEDnChamp(MED_FIELD_DRIVER21<T>::_medIdt,MED_FIELD_DRIVER<T>::_fieldNum) ;
+ if (numberOfComponents < 1)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"no component")) ; // use iostring !
+ // test type to check if it is rigth !!!???
+ MED_FIELD_DRIVER<T>::_ptrField->_numberOfComponents = numberOfComponents ;
+ MED_FIELD_DRIVER<T>::_ptrField->_componentsTypes = new int[numberOfComponents] ;
+ MED_FIELD_DRIVER<T>::_ptrField->_componentsNames = new string[numberOfComponents] ;
+ MED_FIELD_DRIVER<T>::_ptrField->_componentsUnits = new UNIT[numberOfComponents] ;
+ MED_FIELD_DRIVER<T>::_ptrField->_componentsDescriptions = new string[numberOfComponents] ;
+ MED_FIELD_DRIVER<T>::_ptrField->_MEDComponentsUnits = new string[numberOfComponents] ;
+ for (int i=0; i<numberOfComponents; i++) {
+ MED_FIELD_DRIVER<T>::_ptrField->_componentsTypes[i] = 1 ;
+
+ // PG : what about space !!!
+ MED_FIELD_DRIVER<T>::_ptrField->_componentsNames[i] = string(componentName,i*MED_TAILLE_PNOM21,MED_TAILLE_PNOM21) ;
+ SCRUTE(MED_FIELD_DRIVER<T>::_ptrField->_componentsNames[i]);
+ MED_FIELD_DRIVER<T>::_ptrField->_MEDComponentsUnits[i] = string(unitName,i*MED_TAILLE_PNOM21,MED_TAILLE_PNOM21) ;
+ SCRUTE(MED_FIELD_DRIVER<T>::_ptrField->_MEDComponentsUnits[i]);
+ }
+ delete[] componentName;
+ delete[] unitName;
+
+ // read values for each geometric type in _support
+ int NumberOfTypes = MED_FIELD_DRIVER<T>::_ptrField->_support->getNumberOfTypes() ;
+ const MED_EN::medGeometryElement *Types = MED_FIELD_DRIVER<T>::_ptrField->_support->getTypes() ;
+ T ** myValues = new T*[NumberOfTypes] ;
+ int * NumberOfValues = new int[NumberOfTypes] ;
+ int TotalNumberOfValues = 0 ;
+ MESSAGE ("NumberOfTypes :"<< NumberOfTypes);
+ MED_FIELD_DRIVER<T>::_ptrField->_numberOfValues=0 ;
+ for (int i=0; i<NumberOfTypes; i++) {
+ MESSAGE ("Type["<<i+1<<"] :"<< Types[i]);
+ MESSAGE ("Entity :"<<MED_FIELD_DRIVER<T>::_ptrField->_support->getEntity());
+ NumberOfValues[i] =
+ MEDnVal(MED_FIELD_DRIVER21<T>::_medIdt,
+ const_cast <char*> (MED_FIELD_DRIVER<T>::_fieldName.c_str()),
+ (med_2_1::med_entite_maillage)MED_FIELD_DRIVER<T>::_ptrField->_support->getEntity(),
+ (med_2_1::med_geometrie_element)Types[i],
+ MED_FIELD_DRIVER<T>::_ptrField->_iterationNumber,
+ MED_FIELD_DRIVER<T>::_ptrField->_orderNumber) ; // no time step ! prend en compte le nbre de pt de gauss
+ // test if NumberOfValues is the same in _support !!! TODO that !!
+ // we suppose it is
+ // we could allocate array
+ myValues[i] = new T[ NumberOfValues[i]*numberOfComponents ] ;
+ TotalNumberOfValues+=NumberOfValues[i] ;// diviser par le nombre de point de gauss
+ char * ProfilName = new char[MED_TAILLE_NOM+1];
+ MESSAGE ("NumberOfValues :"<< NumberOfValues[i]);
+ MESSAGE ("NumberOfComponents :"<< numberOfComponents);
+ MESSAGE ("MESH_NAME :"<< MeshName.c_str());
+ MESSAGE ("FIELD_NAME :"<< MED_FIELD_DRIVER<T>::_fieldName.c_str());
+ MESSAGE ("MED_ENTITE :"<< (med_2_1::med_entite_maillage) MED_FIELD_DRIVER<T>::_ptrField->_support->getEntity());
+ MESSAGE("MED_GEOM :"<<(med_2_1::med_geometrie_element)Types[i]);
+ MESSAGE("Iteration :"<<MED_FIELD_DRIVER<T>::_ptrField->getIterationNumber());
+ MESSAGE("Order :"<<MED_FIELD_DRIVER<T>::_ptrField->getOrderNumber());
+ MED_FIELD_DRIVER<T>::_ptrField->_numberOfValues+=NumberOfValues[i]; // problem with gauss point : _numberOfValues != TotalNumberOfValues !!!!!!!
+ med_2_1::med_err ret;
+#if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
+ int lgth2=NumberOfValues[i]*numberOfComponents;
+ if(_ptrField->getValueType()==MED_EN::MED_INT32)
+ {
+ med_2_1::med_int *temp=new med_2_1::med_int[lgth2];
+ ret=med_2_1::MEDchampLire(MED_FIELD_DRIVER21<T>::_medIdt,const_cast <char*> (MeshName.c_str()),
+ const_cast <char*> (MED_FIELD_DRIVER<T>::_fieldName.c_str()),
+ (unsigned char*) temp,
+ med_2_1::MED_NO_INTERLACE,
+ MED_ALL,
+ ProfilName,
+ (med_2_1::med_entite_maillage) MED_FIELD_DRIVER<T>::_ptrField->_support->getEntity(),(med_2_1::med_geometrie_element)Types[i],
+ MED_FIELD_DRIVER<T>::_ptrField->getIterationNumber(),
+ MED_FIELD_DRIVER<T>::_ptrField->getOrderNumber()
+ );
+ for(int i2=0;i2<lgth2;i2++)
+ myValues[i][i2]=(int)(temp[i2]);
+ delete [] temp;
+ }
+ else
+#endif
+ ret=med_2_1::MEDchampLire(MED_FIELD_DRIVER21<T>::_medIdt,const_cast <char*> (MeshName.c_str()),
+ const_cast <char*> (MED_FIELD_DRIVER<T>::_fieldName.c_str()),
+ (unsigned char*) myValues[i],
+ med_2_1::MED_NO_INTERLACE,
+ MED_ALL,
+ ProfilName,
+ (med_2_1::med_entite_maillage) MED_FIELD_DRIVER<T>::_ptrField->_support->getEntity(),(med_2_1::med_geometrie_element)Types[i],
+ MED_FIELD_DRIVER<T>::_ptrField->getIterationNumber(),
+ MED_FIELD_DRIVER<T>::_ptrField->getOrderNumber()
+ );
+ if (ret < 0) {
+ // we must do some delete !!!
+ for(int j=0; j<=i;j++)
+ delete[] myValues[j];
+ delete[] myValues;
+ delete[] NumberOfValues ;
+ delete[] ProfilName;
+ delete[] MED_FIELD_DRIVER<T>::_ptrField->_componentsTypes ;
+ delete[] MED_FIELD_DRIVER<T>::_ptrField->_componentsNames ;
+ delete[] MED_FIELD_DRIVER<T>::_ptrField->_componentsUnits ;
+ delete[] MED_FIELD_DRIVER<T>::_ptrField->_componentsDescriptions ;
+ delete[] MED_FIELD_DRIVER<T>::_ptrField->_MEDComponentsUnits ;
+ MED_FIELD_DRIVER<T>::_ptrField->_componentsTypes = NULL ;
+ MED_FIELD_DRIVER<T>::_ptrField->_componentsNames = NULL ;
+ MED_FIELD_DRIVER<T>::_ptrField->_componentsUnits = NULL ;
+ MED_FIELD_DRIVER<T>::_ptrField->_componentsDescriptions = NULL ;
+ MED_FIELD_DRIVER<T>::_ptrField->_MEDComponentsUnits = NULL ;
+ MED_FIELD_DRIVER<T>::_fieldNum = MED_INVALID ; // we have not found right field, so reset the field number
+ throw MEDEXCEPTION( LOCALIZED( STRING(LOC) <<": ERROR when read value")) ;
+ }
+
+ delete[] ProfilName ;
+ }
+ // allocate _value
+ // probleme avec les points de gauss : voir lorsqu-il y en a (!= 1)
+ // MEDARRAY<T> * Values = new MEDARRAY<T>(MED_FIELD_DRIVER<T>::_ptrField->getNumberOfComponents(),TotalNumberOfValues/MED_FIELD_DRIVER<T>::_ptrField->getNumberOfComponents(),MED_EN::MED_NO_INTERLACE);
+
+ if (MED_FIELD_DRIVER<T>::_ptrField->_value==NULL)
+ MED_FIELD_DRIVER<T>::_ptrField->_value=new MEDARRAY<T>(numberOfComponents,TotalNumberOfValues,MED_EN::MED_NO_INTERLACE);
+
+ MEDARRAY<T> * Values = MED_FIELD_DRIVER<T>::_ptrField->_value ; // create by constructor ???
+ // check if dimensions are right : inutile : c'est dans le constructeur !!!
+ //if (Values->getLeadingValue() != numberOfComponents)
+ // throw MEDEXCEPTION( LOCALIZED( STRING(LOC) <<": leading dimension are false : "<<Values->getLeadingValue()<<" and "<<numberOfComponents) ) ;
+ //if (Values->getLengthValue() != TotalNumberOfValues)
+ // throw MEDEXCEPTION( LOCALIZED( STRING(LOC) <<": length dimension are false : "<<Values->getLengthValue()<<" and "<<TotalNumberOfValues) ) ;
+
+ for (int i=0; i<numberOfComponents; i++) {
+ //T * ValuesT = Values->getRow(i+1) ;
+ int Count = 1 ;
+ for (int j=0; j<NumberOfTypes; j++) {
+ T * myValue = myValues[j] ;
+ int NumberOf = NumberOfValues[j] ;
+// MED_FIELD_DRIVER<T>::_ptrField->_numberOfValues+=NumberOf; // problem with gauss point : _numberOfValues != TotalNumberOfValues !!!!!!!
+ int offset = NumberOf*i ;
+ for (int k=0 ; k<NumberOf; k++) {
+ //ValuesT[Count]=myValue[k+offset] ;
+ Values->setIJ(Count,i+1,myValue[k+offset]);
+ SCRUTE(Count);
+ SCRUTE(Values->getIJ(Count,i+1));
+ Count++;
+ }
+ }
+ }
+
+ for (int j=0; j<NumberOfTypes; j++)
+ delete[] myValues[j] ;
+ delete[] myValues ;
+ delete[] NumberOfValues ;
+
+ MED_FIELD_DRIVER<T>::_ptrField->_isRead = true ;
+ }
+
+ END_OF(LOC);
+}
+
+template <class T> void MED_FIELD_RDONLY_DRIVER21<T>::write( void ) const
+ throw (MEDEXCEPTION)
+{
+ throw MEDEXCEPTION("MED_FIELD_RDONLY_DRIVER21::write : Can't write with a RDONLY driver !");
+}
+
+/*--------------------- WRONLY PART -------------------------------*/
+
+template <class T> GENDRIVER * MED_FIELD_WRONLY_DRIVER21<T>::copy(void) const
+{
+ return new MED_FIELD_WRONLY_DRIVER21<T>(*this);
+}
+
+template <class T> void MED_FIELD_WRONLY_DRIVER21<T>::read (void)
+ throw (MEDEXCEPTION)
+{
+ throw MEDEXCEPTION("MED_FIELD_WRONLY_DRIVER21::read : Can't read with a WRONLY driver !");
+}
+
+template <class T> void MED_FIELD_WRONLY_DRIVER21<T>::write(void) const
+ throw (MEDEXCEPTION)
+{
+ const char * LOC = "MED_FIELD_WRONLY_DRIVER21::write(void) const " ;
+ BEGIN_OF(LOC);
+ if (MED_FIELD_DRIVER<T>::_status==MED_OPENED)
+ {
+ int err ;
+
+ int component_count=MED_FIELD_DRIVER<T>::_ptrField->getNumberOfComponents();
+ string component_name(component_count*MED_TAILLE_PNOM21,' ') ;
+ string component_unit(component_count*MED_TAILLE_PNOM21,' ') ;
+
+ const string * listcomponent_name=MED_FIELD_DRIVER<T>::_ptrField->getComponentsNames() ;
+ const string * listcomponent_unit=MED_FIELD_DRIVER<T>::_ptrField->getMEDComponentsUnits() ;
+ int length ;
+ for (int i=0; i < component_count ; i++) {
+ length = min(MED_TAILLE_PNOM21,(int)listcomponent_name[i].size());
+ component_name.replace(i*MED_TAILLE_PNOM21,length,
+ listcomponent_name[i],0,length);
+ length = min(MED_TAILLE_PNOM21,(int)listcomponent_unit[i].size());
+ component_unit.replace(i*MED_TAILLE_PNOM21,length,
+ listcomponent_unit[i],0,length);
+ }
+
+ MESSAGE("component_name=|"<<component_name<<"|");
+ MESSAGE("component_unit=|"<<component_unit<<"|");
+
+ MED_EN::med_type_champ ValueType=MED_FIELD_DRIVER<T>::_ptrField->getValueType() ;
+
+ MESSAGE("Template Type =|"<<ValueType<<"|");
+
+ // le champ existe deja ???
+ char * champName = new char[MED_TAILLE_NOM+1] ;
+ med_2_1::med_type_champ type ;
+ char * compName ;
+ char * compUnit ;
+ bool Find = false ;
+ int n = med_2_1::MEDnChamp(MED_FIELD_DRIVER21<T>::_medIdt,0);
+ int nbComp ;
+ for (int i=1; i<=n; i++) {
+ nbComp = med_2_1::MEDnChamp(MED_FIELD_DRIVER21<T>::_medIdt,i);
+ compName = new char[MED_TAILLE_PNOM21*nbComp+1];
+ compUnit = new char[MED_TAILLE_PNOM21*nbComp+1];
+ err = med_2_1::MEDchampInfo(MED_FIELD_DRIVER21<T>::_medIdt,i,champName,&type,compName,compUnit,nbComp);
+ if (err == 0)
+ if (strcmp(champName,MED_FIELD_DRIVER<T>::_ptrField->getName().c_str())==0) { // Found !
+ Find = true ;
+ break ;
+ }
+ delete[] compName ;
+ delete[] compUnit ;
+ }
+ delete[] champName ;
+ if (Find) {
+ // the same ?
+ if (nbComp != component_count)
+ throw MEDEXCEPTION( LOCALIZED (STRING(LOC)
+ <<": Field exist in file, but number of component are different : "<<nbComp<<" in file and "<<component_count<<" in memory."
+ )
+ );
+ // component name and unit
+ MESSAGE(LOC<<" Component name in file : "<<compName);
+ MESSAGE(LOC<<" Component name in memory : "<<component_name);
+ MESSAGE(LOC<<" Component unit in file : "<<compUnit);
+ MESSAGE(LOC<<" Component unit in memory : "<<component_unit);
+ delete[] compName ;
+ delete[] compUnit ;
+
+ } else {
+ // Verify the field doesn't exist
+
+ string dataGroupName = "/CHA/";
+ dataGroupName += MED_FIELD_DRIVER<T>::_ptrField->getName();
+ MESSAGE(LOC << "|" << dataGroupName << "|" );
+ med_2_1::med_idt gid = H5Gopen(MED_FIELD_DRIVER21<T>::_medIdt, dataGroupName.c_str() );
+
+ if ( gid < 0 ) {
+ // create field :
+ err=med_2_1::MEDchampCr(MED_FIELD_DRIVER21<T>::_medIdt,
+ const_cast <char*> ((MED_FIELD_DRIVER<T>::_ptrField->getName()).c_str()),
+ (med_2_1::med_type_champ) ValueType,
+ const_cast <char*> ( component_name.c_str() ),
+ const_cast <char*> ( component_unit.c_str() ),
+ component_count);
+ if ( err < 0 )
+ throw MEDEXCEPTION( LOCALIZED (STRING(LOC)
+ << ": Error MEDchampCr : "<<err
+ )
+ );
+ }
+ else H5Gclose(gid);
+ }
+
+ const SUPPORT * mySupport = MED_FIELD_DRIVER<T>::_ptrField->getSupport() ;
+
+ if (! mySupport->isOnAllElements())
+ throw MEDEXCEPTION( LOCALIZED (STRING(LOC)
+ <<": Field must be on all entity"
+ )
+ );
+
+ MESH * myMesh = mySupport->getMesh() ;
+ string MeshName = myMesh->getName() ;
+ //MED_EN::medModeSwitch Mode = MED_FIELD_DRIVER<T>::_ptrField->_value->getMode() ;
+ // on boucle sur tout les types pour ecrire les tableaux de valeur
+ int NumberOfType = mySupport->getNumberOfTypes() ;
+ int Index = 1 ;
+ const MED_EN::medGeometryElement * Types = mySupport->getTypes() ;
+ const int * NumberOfGaussPoint = mySupport->getNumberOfGaussPoint() ;
+ for (int i=0;i<NumberOfType;i++) {
+ int NumberOfElements = mySupport->getNumberOfElements(Types[i]) ;
+
+ const T * value = MED_FIELD_DRIVER<T>::_ptrField->getValueI(MED_EN::MED_FULL_INTERLACE,Index) ;
+
+ MESSAGE("MED_FIELD_DRIVER21<T>::_medIdt : "<<MED_FIELD_DRIVER21<T>::_medIdt);
+ MESSAGE("MeshName.c_str() : "<<MeshName.c_str());
+ MESSAGE("MED_FIELD_DRIVER<T>::_ptrField->getName() : "<<MED_FIELD_DRIVER<T>::_ptrField->getName());
+ MESSAGE("value : "<<value);
+ MESSAGE("NumberOfElements : "<<NumberOfElements);
+ MESSAGE("NumberOfGaussPoint[i] : "<<NumberOfGaussPoint[i]);
+ MESSAGE("mySupport->getEntity() : "<<mySupport->getEntity());
+ MESSAGE("Types[i] : "<<Types[i]);
+ MESSAGE("MED_FIELD_DRIVER<T>::_ptrField->getIterationNumber() : "<<MED_FIELD_DRIVER<T>::_ptrField->getIterationNumber());
+ MESSAGE("MED_FIELD_DRIVER<T>::_ptrField->getTime() : "<<MED_FIELD_DRIVER<T>::_ptrField->getTime());
+ MESSAGE("MED_FIELD_DRIVER<T>::_ptrField->getOrderNumber() : "<<MED_FIELD_DRIVER<T>::_ptrField->getOrderNumber());
+
+/* char chanom[MED_TAILLE_NOM+1];
+ char chacomp[MED_TAILLE_NOM+1];
+ char chaunit[MED_TAILLE_NOM+1];
+ med_2_1::med_type_champ chatype;
+ med_int chancomp=1;
+
+ err=med_2_1::MEDchampInfo(MED_FIELD_DRIVER<T>::_medIdt,1,chanom,&chatype,chacomp,chaunit,chancomp);
+
+ if (err<0)
+ {
+ cout<<"=======================================================================> gros probleme"<<endl;
+ exit(-1);
+ }
+ cout<<"==================> nom lu = "<<chanom<<endl;
+ cout<<"==================> type lu = "<<chatype<<endl;
+ cout<<"==================> nom composante lu = "<<chacomp<<endl;
+ cout<<"==================> nom unit lu = "<<chaunit<<endl;
+ cout<<"==================> valeur de med_2_1::MED_REEL64 = "<<med_2_1::MED_REEL64<<endl;
+*/
+#if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
+ if(_ptrField->getValueType()==MED_EN::MED_INT32)
+ {
+ int lgth2=_ptrField->getNumberOfValues();
+ med_2_1::med_int *temp=new med_2_1::med_int[lgth2];
+ for(int i2=0;i2<lgth2;i2++)
+ temp[i2]=(int)(value[i2]);
+ err=med_2_1::MEDchampEcr(MED_FIELD_DRIVER21<T>::_medIdt,
+ const_cast <char*> ( MeshName.c_str()) , //( string(mesh_name).resize(MED_TAILLE_NOM).c_str())
+ const_cast <char*> ( (MED_FIELD_DRIVER<T>::_ptrField->getName()).c_str()),
+ (unsigned char*)temp,
+ med_2_1::MED_FULL_INTERLACE,
+ NumberOfElements,
+ NumberOfGaussPoint[i],
+ MED_ALL,
+ MED_NOPFL,
+ med_2_1::MED_REMP, // PROFIL NON GERE, mode de remplacement non géré
+ (med_2_1::med_entite_maillage)mySupport->getEntity(),
+ (med_2_1::med_geometrie_element)Types[i],
+ MED_FIELD_DRIVER<T>::_ptrField->getIterationNumber(),
+ " ",
+ MED_FIELD_DRIVER<T>::_ptrField->getTime(),
+ MED_FIELD_DRIVER<T>::_ptrField->getOrderNumber()
+ );
+ delete [] temp;
+ }
+ else
+#endif
+ err=med_2_1::MEDchampEcr(MED_FIELD_DRIVER21<T>::_medIdt,
+ const_cast <char*> ( MeshName.c_str()) , //( string(mesh_name).resize(MED_TAILLE_NOM).c_str())
+ const_cast <char*> ( (MED_FIELD_DRIVER<T>::_ptrField->getName()).c_str()),
+ (unsigned char*)value,
+ med_2_1::MED_FULL_INTERLACE,
+ NumberOfElements,
+ NumberOfGaussPoint[i],
+ MED_ALL,
+ MED_NOPFL,
+ med_2_1::MED_REMP, // PROFIL NON GERE, mode de remplacement non géré
+ (med_2_1::med_entite_maillage)mySupport->getEntity(),
+ (med_2_1::med_geometrie_element)Types[i],
+ MED_FIELD_DRIVER<T>::_ptrField->getIterationNumber(),
+ " ",
+ MED_FIELD_DRIVER<T>::_ptrField->getTime(),
+ MED_FIELD_DRIVER<T>::_ptrField->getOrderNumber()
+ );
+ if (err < MED_VALID )
+ throw MEDEXCEPTION(LOCALIZED( STRING(LOC)
+ <<": Error in writing Field "<< MED_FIELD_DRIVER<T>::_ptrField->getName() <<", type "<<Types[i]
+ )
+ );
+
+ Index += NumberOfElements ;
+
+ }
+ }
+
+ END_OF(LOC);
+}
+
+/*--------------------- RDWR PART -------------------------------*/
+
+template <class T> GENDRIVER * MED_FIELD_RDWR_DRIVER21<T>::copy(void) const
+{
+ return new MED_FIELD_RDWR_DRIVER21<T>(*this);
+}
+
+template <class T> void MED_FIELD_RDWR_DRIVER21<T>::write(void) const
+ throw (MEDEXCEPTION)
+{
+ BEGIN_OF("MED_FIELD_RDWR_DRIVER21::write(void)");
+ MED_FIELD_WRONLY_DRIVER21<T>::write();
+ END_OF("MED_FIELD_RDWR_DRIVER21::write(void)");
+}
+
+template <class T> void MED_FIELD_RDWR_DRIVER21<T>::read (void)
+ throw (MEDEXCEPTION)
+{
+ BEGIN_OF("MED_FIELD_RDWR_DRIVER21::read(void)");
+ MED_FIELD_RDONLY_DRIVER21<T>::read();
+ END_OF("MED_FIELD_RDWR_DRIVER21::read(void)");
+}
+}//End namespace MEDMEM
+/*-----------------------------------------------------------------*/
+
+#endif /* MED_FIELD_DRIVER_HXX */
+
--- /dev/null
+#ifndef MED_FIELD_DRIVER22_HXX
+#define MED_FIELD_DRIVER22_HXX
+
+#include <string>
+
+#include "MEDMEM_define.hxx"
+
+#include "MEDMEM_GenDriver.hxx"
+#include "utilities.h"
+#include "MEDMEM_MedFieldDriver.hxx"
+#include "MEDMEM_STRING.hxx"
+#include "MEDMEM_Exception.hxx"
+#include "MEDMEM_Unit.hxx"
+#include "MEDMEM_Array.hxx"
+#include "MEDMEM_Support.hxx"
+#include "MEDMEM_Mesh.hxx"
+
+namespace MEDMEM {
+template <class T> class FIELD;
+
+// A QD LA CLASSE MED_ALL_ELEMENTS_DRIVER.... :) pour mutualiser le open ..... avec led _medIdt...
+
+/*!
+
+ Driver Med for FIELD.
+
+ Generic part : implement open and close methods.
+
+*/
+
+template <class T> class MED_FIELD_DRIVER22 : public virtual MED_FIELD_DRIVER<T>
+{
+protected:
+
+ med_2_2::med_idt _medIdt;
+
+ void search_field() ;
+
+public :
+
+ // all MED cell type ?? Classe de Définition ??
+ // static const medGeometryElement all_cell_type[MED_NBR_GEOMETRIE_MAILLE];
+
+ // static const char * const all_cell_type_tab [MED_NBR_GEOMETRIE_MAILLE];
+
+ /*!
+ Constructor.
+ */
+ MED_FIELD_DRIVER22():MED_FIELD_DRIVER<T>(),_medIdt(MED_INVALID)
+ {}
+ /*!
+ Constructor.
+ */
+ MED_FIELD_DRIVER22(const string & fileName, FIELD<T> * ptrField,
+ MED_EN::med_mode_acces accessMode)
+ : MED_FIELD_DRIVER<T>(fileName,ptrField,accessMode),_medIdt(MED_INVALID)
+ {
+ }
+
+ /*!
+ Copy constructor.
+ */
+ MED_FIELD_DRIVER22(const MED_FIELD_DRIVER22 & fieldDriver):
+ MED_FIELD_DRIVER<T>(fieldDriver),
+ _medIdt(fieldDriver._medIdt)
+ {
+ }
+
+ /*!
+ Destructor.
+ */
+ virtual ~MED_FIELD_DRIVER22() {
+ }
+
+ void open() throw (MEDEXCEPTION)
+ {
+ const char * LOC = "MED_FIELD_DRIVER22::open() ";
+ BEGIN_OF(LOC);
+
+ // we must set fieldname before open, because we must find field number in file (if it exist !!!)
+ if ( MED_FIELD_DRIVER<T>::_fileName == "" )
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+ << "_fileName is |\"\"|, please set a correct fileName before calling open()"
+ )
+ );
+
+ MESSAGE(LOC<<"_fileName.c_str : "<< MED_FIELD_DRIVER<T>::_fileName.c_str()<<",mode : "<< MED_FIELD_DRIVER<T>::_accessMode);
+ _medIdt = med_2_2::MEDouvrir( (const_cast <char *> (MED_FIELD_DRIVER<T>::_fileName.c_str())),(med_2_2::med_mode_acces) MED_FIELD_DRIVER<T>::_accessMode);
+ MESSAGE(LOC<<"_medIdt : "<< _medIdt );
+ if (_medIdt > 0)
+ MED_FIELD_DRIVER<T>::_status=MED_OPENED;
+ else {
+ MED_FIELD_DRIVER<T>::_status = MED_INVALID;
+ _medIdt = MED_INVALID;
+ throw MED_EXCEPTION (LOCALIZED( STRING(LOC)
+ << "Can't open |" << MED_FIELD_DRIVER<T>::_fileName
+ << "|, _medIdt : " << _medIdt
+ )
+ );
+ }
+
+ END_OF(LOC);
+ }
+
+ void close() {
+ BEGIN_OF("MED_FIELD_DRIVER22::close()");
+ med_2_2::med_int err = 0;
+ if (MED_FIELD_DRIVER<T>::_status == MED_OPENED) {
+ err=med_2_2::MEDfermer(_medIdt);
+ //H5close(); // If we call H5close() all the files are closed.
+ MED_FIELD_DRIVER<T>::_status = MED_CLOSED;
+ _medIdt = MED_INVALID;
+ MESSAGE(" MED_FIELD_DRIVER22::close() : MEDfermer : _medIdt= " << _medIdt );
+ MESSAGE(" MED_FIELD_DRIVER22::close() : MEDfermer : err = " << err );
+ }
+ END_OF("MED_FIELD_DRIVER22::close()");
+ }
+
+};
+
+/*!
+
+ Driver Med for FIELD : Read only.
+
+ Implement read method.
+
+*/
+
+ template <class T> class MED_FIELD_RDONLY_DRIVER22 : public virtual MED_FIELD_DRIVER22<T>, public virtual IMED_FIELD_RDONLY_DRIVER<T>
+{
+
+public :
+
+ /*!
+ Constructor.
+ */
+ MED_FIELD_RDONLY_DRIVER22():MED_FIELD_DRIVER<T>() {};
+
+ /*!
+ Constructor.
+ */
+ MED_FIELD_RDONLY_DRIVER22(const string & fileName, FIELD<T> * ptrField):
+ IMED_FIELD_RDONLY_DRIVER<T>(fileName,ptrField),
+ MED_FIELD_DRIVER22<T>(fileName,ptrField,MED_EN::MED_RDONLY),
+ MED_FIELD_DRIVER<T>(fileName,ptrField,MED_EN::MED_RDONLY)
+ {
+ BEGIN_OF("MED_FIELD_RDONLY_DRIVER22::MED_FIELD_RDONLY_DRIVER22(const string & fileName, const FIELD<T> * ptrField)");
+ END_OF("MED_FIELD_RDONLY_DRIVER22::MED_FIELD_RDONLY_DRIVER22(const string & fileName, const FIELD<T> * ptrField)");
+ }
+
+ /*!
+ Copy constructor.
+ */
+ MED_FIELD_RDONLY_DRIVER22(const MED_FIELD_RDONLY_DRIVER22 & fieldDriver):
+ IMED_FIELD_RDONLY_DRIVER<T>(fieldDriver),
+ MED_FIELD_DRIVER22<T>(fieldDriver),
+ MED_FIELD_DRIVER<T>(fieldDriver)
+ {};
+
+ /*!
+ Destructor.
+ */
+ virtual ~MED_FIELD_RDONLY_DRIVER22() {};
+
+ // 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 FIELD in the specified file.
+ */
+ void read ( void ) throw (MEDEXCEPTION) ;
+
+private:
+ GENDRIVER * copy( void ) const ;
+
+};
+
+/*!
+
+ Driver Med for FIELD : Write only.
+
+ Implement write method.
+
+*/
+
+template <class T> class MED_FIELD_WRONLY_DRIVER22 : public virtual MED_FIELD_DRIVER22<T>, public virtual IMED_FIELD_WRONLY_DRIVER<T> {
+
+public :
+
+ /*!
+ Constructor.
+ */
+ MED_FIELD_WRONLY_DRIVER22():MED_FIELD_DRIVER<T>() {}
+
+ /*!
+ Constructor.
+ */
+ MED_FIELD_WRONLY_DRIVER22(const string & fileName, FIELD<T> * ptrField):
+ IMED_FIELD_WRONLY_DRIVER<T>(fileName,ptrField),
+ MED_FIELD_DRIVER22<T>(fileName,ptrField,MED_EN::MED_WRONLY),
+ MED_FIELD_DRIVER<T>(fileName,ptrField,MED_EN::MED_WRONLY)
+ {
+ BEGIN_OF("MED_FIELD_WRONLY_DRIVER22::MED_FIELD_WRONLY_DRIVER22(const string & fileName, const FIELD<T> * ptrField)");
+ END_OF("MED_FIELD_WRONLY_DRIVER22::MED_FIELD_WRONLY_DRIVER22(const string & fileName, const FIELD<T> * ptrField)");
+ };
+
+ /*!
+ Copy constructor.
+ */
+ MED_FIELD_WRONLY_DRIVER22(const MED_FIELD_WRONLY_DRIVER22 & fieldDriver):
+ IMED_FIELD_WRONLY_DRIVER<T>(fieldDriver),
+ MED_FIELD_DRIVER22<T>(fieldDriver),
+ MED_FIELD_DRIVER<T>(fieldDriver)
+ {};
+
+ /*!
+ Destructor.
+ */
+ virtual ~MED_FIELD_WRONLY_DRIVER22() {};
+
+ /*!
+ Write FIELD 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:
+ GENDRIVER * copy( void ) const ;
+
+};
+
+
+/*!
+
+ Driver Med for FIELD : Read write.
+ - Use read method from MED_FIELD_RDONLY_DRIVER
+ - Use write method from MED_FIELD_WDONLY_DRIVER
+
+*/
+
+template <class T> class MED_FIELD_RDWR_DRIVER22 : public MED_FIELD_RDONLY_DRIVER22<T>, public MED_FIELD_WRONLY_DRIVER22<T>, public IMED_FIELD_RDWR_DRIVER<T> {
+
+public :
+
+ /*!
+ Constructor.
+ */
+ MED_FIELD_RDWR_DRIVER22():MED_FIELD_DRIVER22<T>() {}
+
+ /*!
+ Constructor.
+ */
+ MED_FIELD_RDWR_DRIVER22(const string & fileName, FIELD<T> * ptrField):
+ MED_FIELD_WRONLY_DRIVER22<T>(fileName,ptrField),
+ MED_FIELD_RDONLY_DRIVER22<T>(fileName,ptrField),
+ IMED_FIELD_RDONLY_DRIVER<T>(fileName,ptrField),
+ IMED_FIELD_WRONLY_DRIVER<T>(fileName,ptrField),
+ MED_FIELD_DRIVER<T>(fileName,ptrField,MED_EN::MED_RDWR),
+ IMED_FIELD_RDWR_DRIVER<T>(fileName,ptrField)
+ {
+ BEGIN_OF("MED_FIELD_RDWR_DRIVER22::MED_FIELD_RDWR_DRIVER22(const string & fileName, const FIELD<T> * ptrField)");
+ //_accessMode = MED_RDWR ;
+ END_OF("MED_FIELD_RDWR_DRIVER22::MED_FIELD_RDWR_DRIVER22(const string & fileName, const FIELD<T> * ptrField)");
+ };
+
+ /*!
+ Copy constructor.
+ */
+ MED_FIELD_RDWR_DRIVER22(const MED_FIELD_RDWR_DRIVER22 & fieldDriver):
+ MED_FIELD_WRONLY_DRIVER22<T>(fieldDriver),
+ MED_FIELD_RDONLY_DRIVER22<T>(fieldDriver),
+ IMED_FIELD_RDWR_DRIVER<T>(fieldDriver),
+ IMED_FIELD_RDONLY_DRIVER<T>(fieldDriver),
+ IMED_FIELD_WRONLY_DRIVER<T>(fieldDriver),
+ MED_FIELD_DRIVER<T>(fieldDriver)
+ {};
+
+ /*!
+ Destructor.
+ */
+ ~MED_FIELD_RDWR_DRIVER22() {};
+
+ /*!
+ Write FIELD in the specified file.
+ */
+ void write(void) const throw (MEDEXCEPTION) ;
+ /*!
+ Read FIELD in the specified file.
+ */
+ void read (void) throw (MEDEXCEPTION) ;
+
+private:
+ GENDRIVER * copy( void ) const ;
+
+};
+
+
+/*-------------------------*/
+/* template implementation */
+/*-------------------------*/
+
+/*--------------------- DRIVER PART -------------------------------*/
+
+// template <class T> void MED_FIELD_DRIVER<T>::search_field() {
+// const char * LOC = "template <class T> class MED_FIELD_DRIVER::search_field() :";
+
+// // we search the field number !!!!
+// if (_status==MED_OPENED)
+// if (_fieldNum==MED_INVALID) {
+// int err ;
+// int numberOfFields = 0; //MED_INVALID
+// // char fieldName[MED_TAILLE_NOM+1] = "";
+// char fieldName[MED_TAILLE_NOM+1] ;
+// int numberOfComponents = 0;
+// char * componentName = (char *) MED_NULL;
+// char * unitName = (char *) MED_NULL;
+// med_2_2::med_type_champ type ;
+// numberOfFields = med_2_2::MEDnChamp(_medIdt,0) ;
+// if ( numberOfFields <= 0 )
+// throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<": No Field found !"));
+// for (int i=1;i<=numberOfFields;i++) {
+
+// numberOfComponents = med_2_2::MEDnChamp(_medIdt,i) ;
+// if ( numberOfComponents <= 0 )
+// throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+// << "Be careful there is no compound for field n°"
+// << i << "in file |"<<_fileName<<"| !"));
+
+// componentName = new char[numberOfComponents*MED_TAILLE_PNOM+1] ;
+// unitName = new char[numberOfComponents*MED_TAILLE_PNOM+1] ;
+
+// err = med_2_2::MEDchampInfo(_medIdt, i, fieldName, &type, componentName,
+// unitName, numberOfComponents) ;
+
+// delete[] componentName ;
+// delete[] unitName ;
+// MESSAGE("Champ "<<i<<" : #" << fieldName <<"# et recherche #"<<_fieldName.c_str()<<"#");
+// if ( !strcmp(fieldName,_fieldName.c_str()) ) {
+// MESSAGE("FOUND FIELD "<< fieldName <<" : "<<i);
+// _fieldNum = i ;
+// break ;
+// }
+// }
+// }
+// }
+
+/*--------------------- RDONLY PART -------------------------------*/
+
+template <class T> GENDRIVER * MED_FIELD_RDONLY_DRIVER22<T>::copy(void) const
+{
+ return new MED_FIELD_RDONLY_DRIVER22<T>(*this);
+}
+
+template <class T> void MED_FIELD_RDONLY_DRIVER22<T>::read(void)
+ throw (MEDEXCEPTION)
+{
+ const char * LOC = " MED_FIELD_RDONLY_DRIVER22::read() " ;
+ BEGIN_OF(LOC);
+
+ if (MED_FIELD_DRIVER<T>::_ptrField->_name=="")
+ MED_FIELD_DRIVER<T>::_ptrField->_name = MED_FIELD_DRIVER<T>::_fieldName ;
+ else
+ MED_FIELD_DRIVER<T>::_fieldName = MED_FIELD_DRIVER<T>::_ptrField->_name; // bug indetermine ! apres avoir fait readfilestruct, lorsque je recupere le champ, tout est bon sauf le nom du champ dans le driver !!!!!
+
+ MESSAGE("###### "<<LOC<<" fieldNameDRIVER : "<<MED_FIELD_DRIVER<T>::_fieldName<<" fieldName : "<<MED_FIELD_DRIVER<T>::_ptrField->_name);
+
+ string MeshName = MED_FIELD_DRIVER<T>::_ptrField->getSupport()->getMesh()->getName() ;
+
+ if (MED_FIELD_DRIVER<T>::_status==MED_OPENED)
+ {
+
+ // search_field() ;
+
+ char * fieldName ;
+ fieldName = new char[MED_TAILLE_NOM+1] ;
+ int err ;
+ int numberOfComponents = 0;
+ char * componentName = (char *) MED_NULL;
+ char * unitName = (char *) MED_NULL;
+ med_2_2::med_type_champ type ;
+
+ // we search the field number !!!!
+ if (MED_FIELD_DRIVER<T>::_fieldNum==MED_INVALID) {
+ int numberOfFields = 0; //MED_INVALID
+ numberOfFields = med_2_2::MEDnChamp(MED_FIELD_DRIVER22<T>::_medIdt,0) ;
+ if ( numberOfFields <= 0 )
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<": No Field found !"));
+ for (int i=1;i<=numberOfFields;i++) {
+
+ numberOfComponents = med_2_2::MEDnChamp(MED_FIELD_DRIVER22<T>::_medIdt,i) ;
+ if ( numberOfComponents <= 0 )
+ // throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+ // << "Be careful there is no compound for field n°"
+ // << i << "in file |"<<_fileName<<"| !"));
+ MESSAGE(LOC<<"Be careful there is no compound for field n°"<<i<<"in file |"<<MED_FIELD_DRIVER<T>::_fileName<<"| !");
+
+ componentName = new char[numberOfComponents*MED_TAILLE_PNOM22+1] ;
+ unitName = new char[numberOfComponents*MED_TAILLE_PNOM22+1] ;
+
+ err = med_2_2::MEDchampInfo(MED_FIELD_DRIVER22<T>::_medIdt, i, fieldName, &type, componentName,
+ unitName, numberOfComponents) ;
+
+ MESSAGE("Champ "<<i<<" : #" << fieldName <<"# et recherche #"<<MED_FIELD_DRIVER<T>::_fieldName.c_str()<<"#");
+ if ( !strcmp(fieldName,MED_FIELD_DRIVER<T>::_fieldName.c_str()) ) {
+ MESSAGE("FOUND FIELD "<< fieldName <<" : "<<i);
+ MED_FIELD_DRIVER<T>::_fieldNum = i ;
+ break ;
+ }
+ // not found : release memory and search next field !
+ delete[] componentName ;
+ delete[] unitName ;
+ }
+ }
+
+ delete[] fieldName ;
+
+ if (MED_FIELD_DRIVER<T>::_fieldNum==MED_INVALID)
+ throw MEDEXCEPTION(LOCALIZED( STRING(LOC) << ": Field "<<MED_FIELD_DRIVER<T>::_fieldName << " not found in file " << MED_FIELD_DRIVER<T>::_fileName ) );
+ MESSAGE ("FieldNum : "<<MED_FIELD_DRIVER<T>::_fieldNum);
+
+ // int err ;
+ // int NumberOfComponents = med_2_2::MEDnChamp(MED_FIELD_DRIVER<T>::_medIdt,MED_FIELD_DRIVER<T>::_fieldNum) ;
+ if (numberOfComponents < 1)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"no component")) ; // use iostring !
+ // test type to check if it is rigth !!!???
+ MED_FIELD_DRIVER<T>::_ptrField->_numberOfComponents = numberOfComponents ;
+ MED_FIELD_DRIVER<T>::_ptrField->_componentsTypes = new int[numberOfComponents] ;
+ MED_FIELD_DRIVER<T>::_ptrField->_componentsNames = new string[numberOfComponents] ;
+ MED_FIELD_DRIVER<T>::_ptrField->_componentsUnits = new UNIT[numberOfComponents] ;
+ MED_FIELD_DRIVER<T>::_ptrField->_componentsDescriptions = new string[numberOfComponents] ;
+ MED_FIELD_DRIVER<T>::_ptrField->_MEDComponentsUnits = new string[numberOfComponents] ;
+ for (int i=0; i<numberOfComponents; i++) {
+ MED_FIELD_DRIVER<T>::_ptrField->_componentsTypes[i] = 1 ;
+
+ // PG : what about space !!!
+ MED_FIELD_DRIVER<T>::_ptrField->_componentsNames[i] = string(componentName,i*MED_TAILLE_PNOM22,MED_TAILLE_PNOM22) ;
+ SCRUTE(MED_FIELD_DRIVER<T>::_ptrField->_componentsNames[i]);
+ MED_FIELD_DRIVER<T>::_ptrField->_MEDComponentsUnits[i] = string(unitName,i*MED_TAILLE_PNOM22,MED_TAILLE_PNOM22) ;
+ SCRUTE(MED_FIELD_DRIVER<T>::_ptrField->_MEDComponentsUnits[i]);
+ }
+ delete[] componentName;
+ delete[] unitName;
+
+ // read values for each geometric type in _support
+ int NumberOfTypes = MED_FIELD_DRIVER<T>::_ptrField->_support->getNumberOfTypes() ;
+ const MED_EN::medGeometryElement *Types = MED_FIELD_DRIVER<T>::_ptrField->_support->getTypes() ;
+ T ** myValues = new T*[NumberOfTypes] ;
+ int * NumberOfValues = new int[NumberOfTypes] ;
+ int TotalNumberOfValues = 0 ;
+ MESSAGE ("NumberOfTypes :"<< NumberOfTypes);
+ MED_FIELD_DRIVER<T>::_ptrField->_numberOfValues=0 ;
+ for (int i=0; i<NumberOfTypes; i++) {
+ MESSAGE ("Type["<<i+1<<"] :"<< Types[i]);
+ MESSAGE ("Entity :"<<MED_FIELD_DRIVER<T>::_ptrField->_support->getEntity());
+// NumberOfValues[i] =
+// MEDnVal(_medIdt,
+// const_cast <char*> (MED_FIELD_DRIVER<T>::_fieldName.c_str()),
+// (med_2_2::med_entite_maillage)_ptrField->_support->getEntity(),
+// (med_2_2::med_geometrie_element)Types[i],
+// _ptrField->_iterationNumber,
+// _ptrField->_orderNumber) ; // no time step ! prend en compte le nbre de pt de gauss
+ // test if NumberOfValues is the same in _support !!! TODO that !!
+ // we suppose it is
+ // we could allocate array
+ // Be really carefull about the profil; especially the last arg of
+ // MEDnVal
+
+ NumberOfValues[i] =
+ MEDnVal(MED_FIELD_DRIVER22<T>::_medIdt,
+ const_cast <char*> (MED_FIELD_DRIVER<T>::_fieldName.c_str()),
+ (med_2_2::med_entite_maillage)MED_FIELD_DRIVER<T>::_ptrField->_support->getEntity(),
+ (med_2_2::med_geometrie_element) Types[i],
+ MED_FIELD_DRIVER<T>::_ptrField->_iterationNumber, MED_FIELD_DRIVER<T>::_ptrField->_orderNumber,
+ const_cast <char*> (MED_FIELD_DRIVER<T>::_ptrField->_support->getMesh()->getName().c_str()),
+ med_2_2::MED_COMPACT) ;
+
+ myValues[i] = new T[ NumberOfValues[i]*numberOfComponents ] ;
+ TotalNumberOfValues+=NumberOfValues[i] ;// diviser par le nombre de point de gauss
+ char * ProfilName = new char[MED_TAILLE_NOM+1];
+ char * LocalGaussName = new char[MED_TAILLE_NOM+1];
+ MESSAGE ("NumberOfValues :"<< NumberOfValues[i]);
+ MESSAGE ("NumberOfComponents :"<< numberOfComponents);
+ MESSAGE ("MESH_NAME :"<< MeshName.c_str());
+ MESSAGE ("FIELD_NAME :"<< MED_FIELD_DRIVER<T>::_fieldName.c_str());
+ MESSAGE ("MED_ENTITE :"<< (med_2_2::med_entite_maillage) MED_FIELD_DRIVER<T>::_ptrField->_support->getEntity());
+ MESSAGE("MED_GEOM :"<<(med_2_2::med_geometrie_element)Types[i]);
+ MESSAGE("Iteration :"<<MED_FIELD_DRIVER<T>::_ptrField->getIterationNumber());
+ MESSAGE("Order :"<<MED_FIELD_DRIVER<T>::_ptrField->getOrderNumber());
+ MED_FIELD_DRIVER<T>::_ptrField->_numberOfValues+=NumberOfValues[i]; // problem with gauss point : _numberOfValues != TotalNumberOfValues !!!!!!!
+
+ err = MEDchampLire(MED_FIELD_DRIVER22<T>::_medIdt,const_cast <char*> (MeshName.c_str()),
+ const_cast <char*> (MED_FIELD_DRIVER<T>::_fieldName.c_str()),
+ (unsigned char*) myValues[i],
+ med_2_2::MED_NO_INTERLACE,MED_ALL,
+ LocalGaussName,ProfilName,
+ med_2_2::MED_NO_PFLMOD,
+ (med_2_2::med_entite_maillage) MED_FIELD_DRIVER<T>::_ptrField->_support->getEntity(),(med_2_2::med_geometrie_element)Types[i],
+ MED_FIELD_DRIVER<T>::_ptrField->getIterationNumber(),
+ MED_FIELD_DRIVER<T>::_ptrField->getOrderNumber());
+
+ if ( err < 0) {
+ // we must do some delete !!!
+ for(int j=0; j<=i;j++)
+ delete[] myValues[j];
+ delete[] myValues;
+ delete[] NumberOfValues ;
+ delete[] ProfilName;
+ delete[] LocalGaussName;
+ delete[] MED_FIELD_DRIVER<T>::_ptrField->_componentsTypes ;
+ delete[] MED_FIELD_DRIVER<T>::_ptrField->_componentsNames ;
+ delete[] MED_FIELD_DRIVER<T>::_ptrField->_componentsUnits ;
+ delete[] MED_FIELD_DRIVER<T>::_ptrField->_componentsDescriptions ;
+ delete[] MED_FIELD_DRIVER<T>::_ptrField->_MEDComponentsUnits ;
+ MED_FIELD_DRIVER<T>::_ptrField->_componentsTypes = NULL ;
+ MED_FIELD_DRIVER<T>::_ptrField->_componentsNames = NULL ;
+ MED_FIELD_DRIVER<T>::_ptrField->_componentsUnits = NULL ;
+ MED_FIELD_DRIVER<T>::_ptrField->_componentsDescriptions = NULL ;
+ MED_FIELD_DRIVER<T>::_ptrField->_MEDComponentsUnits = NULL ;
+ MED_FIELD_DRIVER<T>::_fieldNum = MED_INVALID ; // we have not found right field, so reset the field number
+ throw MEDEXCEPTION( LOCALIZED( STRING(LOC) <<": ERROR when read value")) ;
+ }
+
+ // At this time ProfilName should be med_2_2::MED_NOPFL and
+ // LocalGaussName should be med_2_2::MED_NOGAUSS
+ delete[] ProfilName ;
+ delete[] LocalGaussName ;
+ }
+ // allocate _value
+ // probleme avec les points de gauss : voir lorsqu-il y en a (!= 1)
+ // MEDARRAY<T> * Values = new MEDARRAY<T>(MED_FIELD_DRIVER<T>::_ptrField->getNumberOfComponents(),TotalNumberOfValues/MED_FIELD_DRIVER<T>::_ptrField->getNumberOfComponents(),MED_EN::MED_NO_INTERLACE);
+
+ if (MED_FIELD_DRIVER<T>::_ptrField->_value==NULL)
+ MED_FIELD_DRIVER<T>::_ptrField->_value=new MEDARRAY<T>(numberOfComponents,TotalNumberOfValues,MED_EN::MED_NO_INTERLACE);
+
+ MEDARRAY<T> * Values = MED_FIELD_DRIVER<T>::_ptrField->_value ; // create by constructor ???
+ // check if dimensions are right : inutile : c'est dans le constructeur !!!
+ //if (Values->getLeadingValue() != numberOfComponents)
+ // throw MEDEXCEPTION( LOCALIZED( STRING(LOC) <<": leading dimension are false : "<<Values->getLeadingValue()<<" and "<<numberOfComponents) ) ;
+ //if (Values->getLengthValue() != TotalNumberOfValues)
+ // throw MEDEXCEPTION( LOCALIZED( STRING(LOC) <<": length dimension are false : "<<Values->getLengthValue()<<" and "<<TotalNumberOfValues) ) ;
+
+ for (int i=0; i<numberOfComponents; i++) {
+ //T * ValuesT = Values->getRow(i+1) ;
+ int Count = 1 ;
+ for (int j=0; j<NumberOfTypes; j++) {
+ T * myValue = myValues[j] ;
+ int NumberOf = NumberOfValues[j] ;
+// MED_FIELD_DRIVER<T>::_ptrField->_numberOfValues+=NumberOf; // problem with gauss point : _numberOfValues != TotalNumberOfValues !!!!!!!
+ int offset = NumberOf*i ;
+ for (int k=0 ; k<NumberOf; k++) {
+ //ValuesT[Count]=myValue[k+offset] ;
+ Values->setIJ(Count,i+1,myValue[k+offset]);
+ SCRUTE(Count);
+ SCRUTE(Values->getIJ(Count,i+1));
+ Count++;
+ }
+ }
+ }
+
+ for (int j=0; j<NumberOfTypes; j++)
+ delete[] myValues[j] ;
+ delete[] myValues ;
+ delete[] NumberOfValues ;
+
+ MED_FIELD_DRIVER<T>::_ptrField->_isRead = true ;
+ }
+
+ END_OF(LOC);
+}
+
+template <class T> void MED_FIELD_RDONLY_DRIVER22<T>::write( void ) const
+ throw (MEDEXCEPTION)
+{
+ throw MEDEXCEPTION("MED_FIELD_RDONLY_DRIVER22::write : Can't write with a RDONLY driver !");
+}
+
+/*--------------------- WRONLY PART -------------------------------*/
+
+template <class T> GENDRIVER * MED_FIELD_WRONLY_DRIVER22<T>::copy(void) const
+{
+ return new MED_FIELD_WRONLY_DRIVER22<T>(*this);
+}
+
+template <class T> void MED_FIELD_WRONLY_DRIVER22<T>::read (void)
+ throw (MEDEXCEPTION)
+{
+ throw MEDEXCEPTION("MED_FIELD_WRONLY_DRIVER22::read : Can't read with a WRONLY driver !");
+}
+
+template <class T> void MED_FIELD_WRONLY_DRIVER22<T>::write(void) const
+ throw (MEDEXCEPTION)
+{
+ const char * LOC = "MED_FIELD_WRONLY_DRIVER22::write(void) const " ;
+ BEGIN_OF(LOC);
+ if (MED_FIELD_DRIVER<T>::_status==MED_OPENED)
+ {
+ int err ;
+
+ int component_count=MED_FIELD_DRIVER<T>::_ptrField->getNumberOfComponents();
+ string component_name(component_count*MED_TAILLE_PNOM22,' ') ;
+ string component_unit(component_count*MED_TAILLE_PNOM22,' ') ;
+
+ const string * listcomponent_name=MED_FIELD_DRIVER<T>::_ptrField->getComponentsNames() ;
+ const string * listcomponent_unit=MED_FIELD_DRIVER<T>::_ptrField->getMEDComponentsUnits() ;
+ int length ;
+ for (int i=0; i < component_count ; i++) {
+ length = min(MED_TAILLE_PNOM22,(int)listcomponent_name[i].size());
+ component_name.replace(i*MED_TAILLE_PNOM22,length,
+ listcomponent_name[i],0,length);
+ length = min(MED_TAILLE_PNOM22,(int)listcomponent_unit[i].size());
+ component_unit.replace(i*MED_TAILLE_PNOM22,length,
+ listcomponent_unit[i],0,length);
+ }
+
+ MESSAGE("component_name=|"<<component_name<<"|");
+ MESSAGE("component_unit=|"<<component_unit<<"|");
+
+ MED_EN::med_type_champ ValueType=MED_FIELD_DRIVER<T>::_ptrField->getValueType() ;
+
+ MESSAGE("Template Type =|"<<ValueType<<"|");
+
+ // le champ existe deja ???
+ char * champName = new char[MED_TAILLE_NOM+1] ;
+ med_2_2::med_type_champ type ;
+ char * compName ;
+ char * compUnit ;
+ bool Find = false ;
+ int n = med_2_2::MEDnChamp(MED_FIELD_DRIVER22<T>::_medIdt,0);
+ int nbComp ;
+ for (int i=1; i<=n; i++) {
+ nbComp = med_2_2::MEDnChamp(MED_FIELD_DRIVER22<T>::_medIdt,i);
+ compName = new char[MED_TAILLE_PNOM22*nbComp+1];
+ compUnit = new char[MED_TAILLE_PNOM22*nbComp+1];
+ err = med_2_2::MEDchampInfo(MED_FIELD_DRIVER22<T>::_medIdt,i,champName,&type,compName,compUnit,nbComp);
+ if (err == 0)
+ if (strcmp(champName,MED_FIELD_DRIVER<T>::_ptrField->getName().c_str())==0) { // Found !
+ Find = true ;
+ break ;
+ }
+ delete[] compName ;
+ delete[] compUnit ;
+ }
+ delete[] champName ;
+ if (Find) {
+ // the same ?
+ if (nbComp != component_count)
+ throw MEDEXCEPTION( LOCALIZED (STRING(LOC)
+ <<": Field exist in file, but number of component are different : "<<nbComp<<" in file and "<<component_count<<" in memory."
+ )
+ );
+ // component name and unit
+ MESSAGE(LOC<<" Component name in file : "<<compName);
+ MESSAGE(LOC<<" Component name in memory : "<<component_name);
+ MESSAGE(LOC<<" Component unit in file : "<<compUnit);
+ MESSAGE(LOC<<" Component unit in memory : "<<component_unit);
+ delete[] compName ;
+ delete[] compUnit ;
+
+ } else {
+ // Verify the field doesn't exist
+
+ string dataGroupName = "/CHA/";
+ dataGroupName += MED_FIELD_DRIVER<T>::_ptrField->getName();
+ MESSAGE(LOC << "|" << dataGroupName << "|" );
+ med_2_2::med_idt gid = H5Gopen(MED_FIELD_DRIVER22<T>::_medIdt, dataGroupName.c_str() );
+
+ if ( gid < 0 ) {
+ // create field :
+ err=med_2_2::MEDchampCr(MED_FIELD_DRIVER22<T>::_medIdt,
+ const_cast <char*> ((MED_FIELD_DRIVER<T>::_ptrField->getName()).c_str()),
+ (med_2_2::med_type_champ) ValueType,
+ const_cast <char*> ( component_name.c_str() ),
+ const_cast <char*> ( component_unit.c_str() ),
+ component_count);
+ if ( err < 0 )
+ throw MEDEXCEPTION( LOCALIZED (STRING(LOC)
+ << ": Error MEDchampCr : "<<err
+ )
+ );
+ }
+ else H5Gclose(gid);
+ }
+
+ const SUPPORT * mySupport = MED_FIELD_DRIVER<T>::_ptrField->getSupport() ;
+
+ if (! mySupport->isOnAllElements())
+ throw MEDEXCEPTION( LOCALIZED (STRING(LOC)
+ <<": Field must be on all entity"
+ )
+ );
+
+ MESH * myMesh = mySupport->getMesh() ;
+ string MeshName = myMesh->getName() ;
+ //MED_EN::medModeSwitch Mode = MED_FIELD_DRIVER<T>::_ptrField->_value->getMode() ;
+ // on boucle sur tout les types pour ecrire les tableaux de valeur
+ int NumberOfType = mySupport->getNumberOfTypes() ;
+ int Index = 1 ;
+ const MED_EN::medGeometryElement * Types = mySupport->getTypes() ;
+ const int * NumberOfGaussPoint = mySupport->getNumberOfGaussPoint() ;
+ for (int i=0;i<NumberOfType;i++) {
+ int NumberOfElements = mySupport->getNumberOfElements(Types[i]) ;
+
+ const T * value = MED_FIELD_DRIVER<T>::_ptrField->getValueI(MED_EN::MED_FULL_INTERLACE,Index) ;
+
+ MESSAGE("MED_FIELD_DRIVER<T>22::_medIdt : "<<MED_FIELD_DRIVER22<T>::_medIdt);
+ MESSAGE("MeshName.c_str() : "<<MeshName.c_str());
+ MESSAGE("MED_FIELD_DRIVER<T>::_ptrField->getName() : "<<MED_FIELD_DRIVER<T>::_ptrField->getName());
+ MESSAGE("value : "<<value);
+ MESSAGE("NumberOfElements : "<<NumberOfElements);
+ MESSAGE("NumberOfGaussPoint[i] : "<<NumberOfGaussPoint[i]);
+ MESSAGE("mySupport->getEntity() : "<<mySupport->getEntity());
+ MESSAGE("Types[i] : "<<Types[i]);
+ MESSAGE("MED_FIELD_DRIVER<T>::_ptrField->getIterationNumber() : "<<MED_FIELD_DRIVER<T>::_ptrField->getIterationNumber());
+ MESSAGE("MED_FIELD_DRIVER<T>::_ptrField->getTime() : "<<MED_FIELD_DRIVER<T>::_ptrField->getTime());
+ MESSAGE("MED_FIELD_DRIVER<T>::_ptrField->getOrderNumber() : "<<MED_FIELD_DRIVER<T>::_ptrField->getOrderNumber());
+
+/* char chanom[MED_TAILLE_NOM+1];
+ char chacomp[MED_TAILLE_NOM+1];
+ char chaunit[MED_TAILLE_NOM+1];
+ med_2_2::med_type_champ chatype;
+ med_int chancomp=1;
+
+ err=med_2_2::MEDchampInfo(MED_FIELD_DRIVER<T>::_medIdt,1,chanom,&chatype,chacomp,chaunit,chancomp);
+
+ if (err<0)
+ {
+ cout<<"=======================================================================> gros probleme"<<endl;
+ exit(-1);
+ }
+ cout<<"==================> nom lu = "<<chanom<<endl;
+ cout<<"==================> type lu = "<<chatype<<endl;
+ cout<<"==================> nom composante lu = "<<chacomp<<endl;
+ cout<<"==================> nom unit lu = "<<chaunit<<endl;
+ cout<<"==================> valeur de med_2_2::MED_REEL64 = "<<med_2_2::MED_REEL64<<endl;
+*/
+
+// err=med_2_2::MEDchampEcr(_medIdt,
+// const_cast <char*> ( MeshName.c_str()) , //( string(mesh_name).resize(MED_TAILLE_NOM).c_str())
+// const_cast <char*> ( (_ptrField->getName()).c_str()),
+// (unsigned char*)value,
+// med_2_2::MED_FULL_INTERLACE,
+// NumberOfElements,
+// NumberOfGaussPoint[i],
+// MED_ALL,
+// MED_NOPFL,
+// med_2_2::MED_REMP, // PROFIL NON GERE, mode de remplacement non géré
+// (med_2_2::med_entite_maillage)mySupport->getEntity(),
+// (med_2_2::med_geometrie_element)Types[i],
+// _ptrField->getIterationNumber(),
+// " ",
+// _ptrField->getTime(),
+// _ptrField->getOrderNumber()
+// );
+
+ err=med_2_2::MEDchampEcr(MED_FIELD_DRIVER22<T>::_medIdt,
+ const_cast <char*> ( MeshName.c_str()) , //( string(mesh_name).resize(MED_TAILLE_NOM).c_str())
+ const_cast <char*> ( (MED_FIELD_DRIVER<T>::_ptrField->getName()).c_str()),
+ (unsigned char*)value,
+ med_2_2::MED_FULL_INTERLACE,
+ NumberOfElements*NumberOfGaussPoint[i],
+ MED_NOGAUSS, MED_ALL, MED_NOPFL,
+ med_2_2::MED_NO_PFLMOD, // PROFIL NON GERE, mode de remplacement non géré
+ (med_2_2::med_entite_maillage)mySupport->getEntity(),
+ (med_2_2::med_geometrie_element)Types[i],
+ MED_FIELD_DRIVER<T>::_ptrField->getIterationNumber(),
+ " ",
+ MED_FIELD_DRIVER<T>::_ptrField->getTime(),
+ MED_FIELD_DRIVER<T>::_ptrField->getOrderNumber()
+ );
+
+ if (err < MED_VALID )
+ throw MEDEXCEPTION(LOCALIZED( STRING(LOC)
+ <<": Error in writing Field "<< MED_FIELD_DRIVER<T>::_ptrField->getName() <<", type "<<Types[i]
+ )
+ );
+
+ Index += NumberOfElements ;
+
+ }
+ }
+
+ END_OF(LOC);
+}
+
+/*--------------------- RDWR PART -------------------------------*/
+
+template <class T> GENDRIVER * MED_FIELD_RDWR_DRIVER22<T>::copy(void) const
+{
+ return new MED_FIELD_RDWR_DRIVER22<T>(*this);
+}
+
+template <class T> void MED_FIELD_RDWR_DRIVER22<T>::write(void) const
+ throw (MEDEXCEPTION)
+{
+ BEGIN_OF("MED_FIELD_RDWR_DRIVER22::write(void)");
+ MED_FIELD_WRONLY_DRIVER22<T>::write();
+ END_OF("MED_FIELD_RDWR_DRIVER22::write(void)");
+}
+
+template <class T> void MED_FIELD_RDWR_DRIVER22<T>::read (void)
+ throw (MEDEXCEPTION)
+{
+ BEGIN_OF("MED_FIELD_RDWR_DRIVER22::read(void)");
+ MED_FIELD_RDONLY_DRIVER22<T>::read();
+ END_OF("MED_FIELD_RDWR_DRIVER22::read(void)");
+}
+
+}
+/*-----------------------------------------------------------------*/
+
+#endif /* MED_FIELD_DRIVER_HXX */
+
-# include <string>
-
-# include "MEDMEM_MedMedDriver.hxx"
-# include "MEDMEM_MedMeshDriver.hxx"
-# include "MEDMEM_DriversDef.hxx"
-
-# include "MEDMEM_Mesh.hxx"
-# include "MEDMEM_Grid.hxx"
-# include "MEDMEM_Field.hxx"
-// EN ATTENDANT L'utilisation de MedFieldDriver.hxx ds Field.hxx
-# include "MEDMEM_MedFieldDriver.hxx"
-# include "MEDMEM_Med.hxx"
-
-# include "MEDMEM_define.hxx"
+#include "MEDMEM_MedMedDriver.hxx"
+#include "MEDMEM_Compatibility21_22.hxx"
+#include "MEDMEM_MedMedDriver21.hxx"
+#include "MEDMEM_MedMedDriver22.hxx"
+#include "MEDMEM_DriverFactory.hxx"
+#include "MEDMEM_define.hxx"
using namespace std;
using namespace MED_EN;
using namespace MEDMEM;
MED_MED_DRIVER::MED_MED_DRIVER(): GENDRIVER(),
- _ptrMed((MED * const)MED_NULL),_medIdt(MED_INVALID)
+ _ptrMed((MED * const)MED_NULL),
+ _concreteMedDrv((GENDRIVER *) MED_NULL)
{}
MED_MED_DRIVER::MED_MED_DRIVER(const string & fileName, MED * const ptrMed):
- GENDRIVER(fileName,MED_EN::MED_RDWR), _ptrMed(ptrMed), _medIdt(MED_INVALID)
+ GENDRIVER(fileName,MED_EN::MED_RDWR), _ptrMed(ptrMed),
+ _concreteMedDrv((GENDRIVER *) MED_NULL)
{
//_ptrMed->addDriver(*this); // The specific MED driver id is set within the addDriver method.
}
MED_MED_DRIVER::MED_MED_DRIVER(const string & fileName,
MED * const ptrMed,
MED_EN::med_mode_acces accessMode):
- GENDRIVER(fileName,accessMode), _ptrMed(ptrMed), _medIdt(MED_INVALID)
+ GENDRIVER(fileName,accessMode), _ptrMed(ptrMed),
+ _concreteMedDrv((GENDRIVER *) MED_NULL)
{
}
//REM : As t'on besoin du champ _status : _medIdt <-> _status ? Oui
MED_MED_DRIVER::MED_MED_DRIVER(const MED_MED_DRIVER & driver):
GENDRIVER(driver),
_ptrMed(driver._ptrMed),
- _medIdt(MED_INVALID)
+ _concreteMedDrv(driver._concreteMedDrv->copy())
{
}
MED_MED_DRIVER::~MED_MED_DRIVER()
{
MESSAGE("MED_MED_DRIVER::~MED_MED_DRIVER() has been destroyed");
+ if (_concreteMedDrv) delete _concreteMedDrv;
}
-// GENDRIVER * MED_MED_DRIVER::copy(void) const
-// {
-// return new MED_MED_DRIVER(*this) ;
-// }
-void MED_MED_DRIVER::read()
-{
-}
-void MED_MED_DRIVER::readFileStruct()
-{
-}
-void MED_MED_DRIVER::write() const
-{
-}
-GENDRIVER * MED_MED_DRIVER::copy(void) const
-{
- return new MED_MED_DRIVER(*this) ;
-}
-void MED_MED_DRIVER::writeFrom() const
-{
-}
-
-
-
-void MED_MED_DRIVER::open()
- throw (MEDEXCEPTION)
-{
-
- const char * LOC ="MED_MED_DRIVER::open() : ";
- BEGIN_OF(LOC);
-
- // REFLECHIR SUR CE TEST PAR RAPPORT A L'OUVERTURE/FERMETURE
-// if ( _medIdt != MED_INVALID )
-// throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
-// << "_medIdt is already in use, please close the file |"
-// << _fileName << "| before calling open()"
-// )
-// );
-
-// if ( _status != MED_CLOSED )
-// throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
-// << "_status is 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()"
- )
- );
-
- MESSAGE(LOC<<"_fileName.c_str : "<< _fileName.c_str()<<",mode : "<< _accessMode);
- _medIdt = MEDouvrir( (const_cast <char *> (_fileName.c_str())), (med_2_1::med_mode_acces) _accessMode);
- MESSAGE(LOC<<" _medIdt = "<<_medIdt);
-
- if (_medIdt > 0)
- _status=MED_OPENED;
- else {
- _status = MED_CLOSED;
- _medIdt = MED_INVALID;
- throw MED_EXCEPTION (LOCALIZED( STRING(LOC)
- << "Can't open |" << _fileName
- << "|, _medIdt : " << _medIdt
- )
- );
- }
-
- END_OF(LOC);
-}
-
-
-void MED_MED_DRIVER::close()
-{
- med_2_1::med_int err = 0;
- const char * LOC = "MED_MED_DRIVER::close() : ";
-
-
-// if ( _status == MED_CLOSED)
-// throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << ": the file |"
-// << _fileName << "| is already closed"
-// )
-// );
-
-// if ( _medIdt == MED_INVALID )
-// throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "_medIdt invalid, but the file |"
-// << _fileName << "| seems to be openned !"
-// )
-// );
-
- if ( _medIdt != MED_INVALID )
- err=med_2_1::MEDfermer(_medIdt);
-
-// if (err != MED_VALID)
-// throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "the file |"
-// << _fileName << "| couldn't be closed"
-// )
-// );
-
- _status = MED_CLOSED;
- _medIdt = MED_INVALID;
-
- END_OF(LOC);
-}
-
-
// ------------- Read Only Part --------------
-MED_MED_RDONLY_DRIVER::MED_MED_RDONLY_DRIVER():MED_MED_DRIVER()
+IMED_MED_RDONLY_DRIVER::IMED_MED_RDONLY_DRIVER():MED_MED_DRIVER()
{
}
-MED_MED_RDONLY_DRIVER::MED_MED_RDONLY_DRIVER(const string & fileName, MED * const ptrMed):
+IMED_MED_RDONLY_DRIVER::IMED_MED_RDONLY_DRIVER(const string & fileName, MED * const ptrMed):
MED_MED_DRIVER(fileName,ptrMed,MED_EN::MED_RDONLY)
{
MESSAGE("MED_MED_RDONLY_DRIVER::MED_MED_RDONLY_DRIVER(const string & fileName, MED * const ptrMed) Constructeur read only");
}
-MED_MED_RDONLY_DRIVER::MED_MED_RDONLY_DRIVER(const MED_MED_RDONLY_DRIVER & driver):
+IMED_MED_RDONLY_DRIVER::IMED_MED_RDONLY_DRIVER(const IMED_MED_RDONLY_DRIVER & driver):
MED_MED_DRIVER(driver)
{
}
-MED_MED_RDONLY_DRIVER::~MED_MED_RDONLY_DRIVER()
+IMED_MED_RDONLY_DRIVER::~IMED_MED_RDONLY_DRIVER()
{
MESSAGE("MED_MED_RDONLY_DRIVER::~MED_MED_RDONLY_DRIVER() has been destroyed");
}
-GENDRIVER * MED_MED_RDONLY_DRIVER::copy(void) const
-{
- return new MED_MED_RDONLY_DRIVER(*this) ;
-}
-
-void MED_MED_RDONLY_DRIVER::readFileStruct( void )
- throw (MEDEXCEPTION)
-{
- const char * LOC = "MED_MED_DRIVER::readFileStruct() : ";
- int err,i,j;
-
- BEGIN_OF(LOC);
-
- if ( _medIdt == MED_INVALID )
- throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
- << "_medIdt is invalid, please open the file |"
- << _fileName << "| before calling readFileStruct()"
- )
- );
- // Read number of meshes and their associated name
- {
- int numberOfMeshes;
- char meshName[MED_TAILLE_NOM+1]="";
- med_2_1::med_int meshDim;
- MESH * ptrMesh;
- // MED_MESH_RDWR_DRIVER * ptrDriver; !! UNUSED VARIABLE !!
-
- numberOfMeshes = med_2_1::MEDnMaa(_medIdt) ;
- if ( numberOfMeshes <= 0 )
- MESSAGE(LOC << "Be careful there is no mesh in file |"<<_fileName<<"| !");
-
- MESH_ENTITIES::const_iterator currentEntity;
- for (i=1;i<=numberOfMeshes;i++) {
-
- // find out if the mesh is a Grid
-
- med_2_1::med_int isAGrid = false;
- med_2_1::med_grid_type type;
-
- err = MEDgridInfo (_medIdt, i, &isAGrid, &type);
- if (err != MED_VALID)
- throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "error in MEDgridInfo()") );
-
- err = med_2_1::MEDmaaInfo(_medIdt, i ,meshName, &meshDim) ;
- if (err != MED_VALID)
- throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << ": can't get information about the mesh n°"
- << i <<" of the file |" << _fileName << "| !"
- )
- );
- MESSAGE(LOC<<": Mesh n°"<<i<<" nammed "<<meshName);
-
- if (isAGrid)
- ptrMesh = new GRID((MED_EN::med_grid_type) type);
- else
- ptrMesh = new MESH();
-
- //MED_MESH_RDWR_DRIVER * _ptrDriver = new MED_MESH_RDWR_DRIVER(_fileName, ptrMesh);
- MED_EN::med_mode_acces myMode = getAccessMode();
- MED_MESH_DRIVER * ptrDriver ;
- switch (myMode) {
- case MED_EN::MED_LECT:
- ptrDriver = new MED_MESH_RDONLY_DRIVER(_fileName, ptrMesh);
- break ;
- case MED_EN::MED_REMP:
- ptrDriver = new MED_MESH_RDWR_DRIVER(_fileName, ptrMesh);
- break ;
- case MED_EN::MED_ECRI: // should never append !!
- ptrDriver = new MED_MESH_RDONLY_DRIVER(_fileName, ptrMesh);
- break;
- default:
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Bad file mode access !"));
- }
- ptrDriver->setId ( getId() );
- ptrDriver->setMeshName ( meshName );
- ptrMesh->addDriver(*ptrDriver);
- delete ptrDriver ;
-
- if (isAGrid)
- _ptrMed->_meshes[meshName] = (MESH *) ptrMesh;
- else
- _ptrMed->_meshes[meshName] = ptrMesh;
-
- ptrMesh->setName(meshName);
-
- SCRUTE(ptrMesh);
-
- MESSAGE(LOC<<"is" << (isAGrid ? "" : " NOT") << " a GRID and its name is "<<ptrMesh->getName());
-
- // we create all global support (for each entity type :
- int index = 0;
- for (currentEntity=meshEntities.begin();currentEntity != meshEntities.end(); currentEntity++) {
- string supportName="SupportOnAll_" ;
- supportName+=entNames[(*currentEntity).first] ;
- //(_ptrMed->_support)[meshName][(MED_EN::medEntityMesh)(*currentEntity).first]=new SUPPORT(ptrMesh,supportName,(MED_EN::medEntityMesh) (*currentEntity).first) ;
- SUPPORT* mySupport = new SUPPORT() ;
- mySupport->setName(supportName);
- mySupport->setMesh(ptrMesh);
- mySupport->setEntity((MED_EN::medEntityMesh) (*currentEntity).first);
- mySupport->setAll(true);
- (_ptrMed->_support)[meshName][(MED_EN::medEntityMesh)(*currentEntity).first] = mySupport ;
- MESSAGE(LOC<< "The support " << supportName.c_str() << " on entity " << (*currentEntity).first << " is built");
- index++;
- }
- MESSAGE(LOC <<"The mesh " <<ptrMesh->getName() << " has " << index << " support(s)");
- }
-
- map<MESH_NAME_, map<MED_EN::medEntityMesh,SUPPORT *> >::const_iterator const_itSupportOnMesh ;
-
- int index = 0;
-
- vector<SUPPORT *> vectSupp;
- for (const_itSupportOnMesh=_ptrMed->_support.begin(); const_itSupportOnMesh != _ptrMed->_support.end();
- const_itSupportOnMesh++ )
- {
- map<MED_EN::medEntityMesh,SUPPORT *>::const_iterator const_itSupport ;
- for (const_itSupport=(*const_itSupportOnMesh).second.begin();
- const_itSupport!=(*const_itSupportOnMesh).second.end();const_itSupport++) index++;
- }
-
- MESSAGE(LOC << "In this MED object there is(are) " << index << " support(s):");
-
- vectSupp.resize(index);
-
- index = 0;
- for (const_itSupportOnMesh=_ptrMed->_support.begin(); const_itSupportOnMesh != _ptrMed->_support.end();
- const_itSupportOnMesh++ )
- {
- map<MED_EN::medEntityMesh,SUPPORT *>::const_iterator const_itSupport ;
- for (const_itSupport=(*const_itSupportOnMesh).second.begin();
- const_itSupport!=(*const_itSupportOnMesh).second.end();const_itSupport++)
- {
- vectSupp[index] = (*const_itSupport).second;
- SCRUTE(vectSupp[index]);
- MESSAGE(LOC << "Support number " << index << " is "<< *vectSupp[index]);
- index++;
- }
- }
-
- }
-
-
- // Read number of fields, their associated name and their list of (timeStepNumber,iterationNumber)
- {
- int numberOfFields = 0; //MED_INVALID
- // char fieldName[MED_TAILLE_NOM+1] = "";
- char fieldName[MED_TAILLE_NOM+1] ;
- int numberOfComponents = 0;
- char * componentName = (char *) MED_NULL;
- char * unitName = (char *) MED_NULL;
- // char meshName[MED_TAILLE_NOM+1] = "";
- char meshName[MED_TAILLE_NOM+1] ;
- med_2_1::med_type_champ type;
- MESH * ptrMesh = (MESH *) MED_NULL;
- FIELD_ * ptrField = (FIELD_ *) MED_NULL;
- //MED_FIELD_RDWR_DRIVER * ptrDriver = (MED_FIELD_RDWR_DRIVER * ) MED_NULL;
- GENDRIVER * ptrDriver = (GENDRIVER * ) MED_NULL;
- SUPPORT * ptrSupport = (SUPPORT * ) MED_NULL;
- MESH_ENTITIES::const_iterator currentEntity;
- list<MED_EN::medGeometryElement>::const_iterator currentGeometry;
- med_2_1::med_int NbOfGaussPts = 0;
- int numberOfTimeSteps = -1;
- med_2_1::med_int timeStepNumber = -1;
- // char timeStepUnit[MED_TAILLE_PNOM]= "";
- char timeStepUnit[MED_TAILLE_PNOM+1] ;
- double timeStep = 0.0;
- med_2_1::med_int orderNumber = -1; //???init?????
- map<MESH_NAME_,MESH*> & _meshes = _ptrMed->_meshes;
- map<FIELD_NAME_,MAP_DT_IT_> & _fields = _ptrMed->_fields;
- map<FIELD_ *, MESH_NAME_> & _meshName = _ptrMed->_meshName;
- map<MESH_NAME_, map<MED_EN::medEntityMesh,SUPPORT *> > & _support = _ptrMed->_support;
-
-
- numberOfFields = med_2_1::MEDnChamp(_medIdt,0) ;
- if ( numberOfFields <= 0 )
- MESSAGE(LOC << "Be careful there is no field in file |"<<_fileName<<"| !");
-
- for (i=1;i<=numberOfFields;i++) {
-
- numberOfComponents = med_2_1::MEDnChamp(_medIdt,i) ;
- if ( numberOfComponents <= 0 )
- if (err != MED_VALID)
- throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "Be careful there is no compound for field n°"
- << i << "in file |"<<_fileName<<"| !"));
-
- componentName = new char[numberOfComponents*MED_TAILLE_PNOM+1] ;
- unitName = new char[numberOfComponents*MED_TAILLE_PNOM+1] ;
-
- err = MEDchampInfo(_medIdt, i, fieldName, &type, componentName,
- unitName, numberOfComponents) ;
-
- if (err != MED_VALID)
- throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
- << ": can't get information about the field n°"
- << i <<" of the file |" << _fileName << "| !"));
-
- MESSAGE(LOC << "Field n°"<<i<<" nammed "<< fieldName
- << " ,component(s) : " << componentName
- <<" ,unit(s) : " << unitName);
-
-
- // Loop on all (entity type,geometry type) until you find an existing one then
- // get the (n°dt,n°it) pairs list for the current (field,entity type,geometry type)
- // We suppose there is the same list whatever the existing (entity type,geometry type) pair
- // support map :
- for (currentEntity=meshEntities.begin();currentEntity != meshEntities.end(); currentEntity++) {
- // numberOfTimeSteps MUST be given by MEDchampInfo !!!!!
- for (currentGeometry = (*currentEntity).second.begin();currentGeometry != (*currentEntity).second.end(); currentGeometry++) {
- MESSAGE("Field information with Entity,Geom = "<<(*currentEntity).first<<","<<(*currentGeometry));
- numberOfTimeSteps = MEDnPasdetemps(_medIdt, fieldName,
- (med_2_1::med_entite_maillage)(*currentEntity).first,
- (med_2_1::med_geometrie_element) (*currentGeometry) );
- MESSAGE("Field information 2 : NumberOfTimeStep :"<<numberOfTimeSteps);
- if ( numberOfTimeSteps > MED_VALID )
- break ; // There are value for some med_geometrie_element of this med_entite_maillage.
- }
- if (numberOfTimeSteps>0) // we have at least one
-
- for (currentGeometry = (*currentEntity).second.begin();currentGeometry != (*currentEntity).second.end(); currentGeometry++) {
-
- MESSAGE("Field information 3 : Geom : "<<(*currentGeometry));
- for (j=1;j <= numberOfTimeSteps; j++) {
-
- MESSAGE("Field information 4 : time step j = "<<j);
- err = MEDpasdetempsInfo( _medIdt, fieldName,
- (med_2_1::med_entite_maillage) (*currentEntity).first,
- (med_2_1::med_geometrie_element) (*currentGeometry),j,
- meshName, &NbOfGaussPts,
- &timeStepNumber, timeStepUnit, &timeStep,
- &orderNumber);
- if (err == MED_VALID) { // we have found for (*currentEntity).first and (*currentGeometry)
-
- MESSAGE("Field information 5 ;: NumberOfGaussPoint : "<<NbOfGaussPts<<", timeStepNumber : "<<timeStepNumber);
- // CORRECT a bug in MEDpasdetempsInfo :
- // we get a value n'importe quoi in NbOfGaussPts !!!!
-
- if (NbOfGaussPts>100)
- NbOfGaussPts=1 ;
- if (timeStepNumber<0)
- timeStepNumber=-1 ;
-
-
- // ATTENTION TRAITER L'EXCEPTION !!!!!!!!!!!!
-
- // Il faudra traiter le cas d'un champ qui utilise +sieurs (entity,geom) voir le travail de patrick
- // Il faudra traiter le cas des profils...
- // ptrField = new FIELD();
- // _ptrDriver = new MED_FIELD_RDWR_DRIVER(_fileName, ptrField);
- // ptrField->addDriver(_ptrDriver);
- // _fields[fieldName]=ptrField;
-
- // Verify meshName is already known
-
- map<MESH_NAME_,MESH*>::iterator _meshesIt = _meshes.find(meshName);
- if ( _meshesIt == _meshes.end() ) {
- MESSAGE(LOC << "There is no mesh |"
- << meshName <<"| in the file |"
- << _fileName <<"|, but |" << meshName <<"| is referenced by field |"
- << fieldName <<"|, entity : |"
- << entNames [(*currentEntity).first] <<"|, geometric element of type |"
- << geoNames [(*currentGeometry)] <<"|"
- );
- } // POURQUOI SI JE NE MET PAS DE BLOCK J'AI UN PARSE ERROR : PG : c'est la macro MESSAGE qui fait ca !
- else
- ptrMesh = _meshes[meshName];
-
- ptrSupport = _support[meshName][(med_2_1::med_entite_maillage) (*currentEntity).first];
- if (NbOfGaussPts != 1)
- throw MEDEXCEPTION(LOCALIZED( STRING(LOC) <<"Number of Gauss Point must be equal to 1 for instance")) ;
-
- // init to null to prevent some error if not correctly allocated !
- ptrField = (FIELD_*)NULL ;
- ptrDriver = (GENDRIVER*)NULL ;
-
- switch ( type) {
- case med_2_1::MED_INT64 :
- if ( sizeof(med_2_1::med_int) != 8 )
- throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) <<
- " The Field type of |"
- << fieldName <<"|, entity : |"
- << entNames [(*currentEntity).first] <<"|, geometric element of type |"
- << geoNames [(*currentGeometry) ] <<
- "| is MED_INT64 but size of med_int is not equal to 8 bytes !"
- )
- );
- break;
- case med_2_1::MED_INT32 : {
-// throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) <<
-// "NOT IMPLEMENTED : BUG IN STL !")
-// ) ;
- // ptrField = new FIELD<med_2_1::med_int> ( ptrSupport,numberOfComponents ); // Les valeurs du champ ne doivent pas être lue pour l'instant
-
- ptrField = new FIELD<int> ( ); // Les valeurs du champ ne doivent pas être lue pour l'instant
- ((FIELD<int>*) ptrField)->setSupport(ptrSupport);
- ((FIELD<int>*) ptrField)->setNumberOfComponents(numberOfComponents);
- ((FIELD<int>*) ptrField)->setName(fieldName) ; //provisoire, pour debug
- MESSAGE("#### SET NAME in FIELD : "<<fieldName);
-
- MED_EN::med_mode_acces myMode = getAccessMode();
- switch (myMode) {
- case MED_EN::MED_LECT:
- ptrDriver = new MED_FIELD_RDONLY_DRIVER<int>(_fileName, (FIELD<int> *)ptrField);
- break ;
- case MED_EN::MED_REMP:
- ptrDriver = new MED_FIELD_RDWR_DRIVER<int>(_fileName, (FIELD<int> *)ptrField);
- break ;
- case MED_EN::MED_ECRI: // should never append !!
- ptrDriver = new MED_FIELD_RDONLY_DRIVER<int>(_fileName, (FIELD<int> *)ptrField);
- break;
- default:
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Bad file mode access !"));
- }
- break;
- }
- case med_2_1::MED_REEL64 : {
- // ptrField = new FIELD<med_2_1::med_float> ( ptrSupport,numberOfComponents ); // Les valeurs du champ ne doivent pas être lue pour l'instant
- ptrField = new FIELD<med_2_1::med_float> ( ); // Les valeurs du champ ne doivent pas être lue pour l'instant
- ((FIELD<med_2_1::med_float>*) ptrField)->setSupport(ptrSupport);
- ((FIELD<med_2_1::med_float>*) ptrField)->setNumberOfComponents(numberOfComponents);
- ((FIELD<med_2_1::med_float>*) ptrField)->setName(fieldName) ; //provisoire, pour debug
- MESSAGE("#### SET NAME in FIELD : "<<fieldName);
-
- MED_EN::med_mode_acces myMode = getAccessMode();
- switch (myMode) {
- case MED_EN::MED_LECT:
- ptrDriver = new MED_FIELD_RDONLY_DRIVER<med_2_1::med_float>(_fileName, (FIELD<med_2_1::med_float> *)ptrField);
- break ;
- case MED_EN::MED_REMP:
- ptrDriver = new MED_FIELD_RDWR_DRIVER<med_2_1::med_float>(_fileName, (FIELD<med_2_1::med_float> *)ptrField);
- break ;
- case MED_EN::MED_ECRI: // should never append !!
- ptrDriver = new MED_FIELD_RDONLY_DRIVER<med_2_1::med_float>(_fileName, (FIELD<med_2_1::med_float> *)ptrField);
- break;
- default:
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Bad file mode access !"));
- }
- break;
- }
- default : {
- if ( numberOfTimeSteps > 1)
- throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) <<
- " The Field type of |"
- << fieldName <<"|, entity : |"
- << entNames [(*currentEntity).first]
- <<"|, geometric element of type |"
- << geoNames [(*currentGeometry)]
- <<"| is neither MED_INT, MED_INT32, MED_INT64 nor MED_REEL64 !"
- )
- );
- break ;
- }
- }
- ptrField->setValueType((MED_EN::med_type_champ) type) ; // need to write field !
-
- MESSAGE("timeStepNumber :"<<timeStepNumber<<",orderNumber :"<<orderNumber);
- ptrField->setIterationNumber ( timeStepNumber); // A ajouter dans la classe FIELD
- ptrField->setOrderNumber ( orderNumber);
- ptrField->setTime ( timeStep);
-
- // Create a driver for this (field n°dt,n°it)
- ptrDriver->setId ( getId() );
- MESSAGE("###### ptrDriver->setFieldName : #"<<fieldName<<"#");
- ptrDriver->setFieldName(fieldName);
- ptrField->addDriver(*ptrDriver);
- // driver is duplicated : remove it
- delete ptrDriver;
-
- DT_IT_ dtIt;
- dtIt.dt = timeStepNumber;
- dtIt.it = orderNumber;
-
- (_fields [fieldName])[dtIt] = ptrField;
- _meshName[ptrField ] = meshName;
- }
- }
- }
- }
- delete[] componentName ;
- delete[] unitName ;
- }
- }
-
- // read profil count and their names
- // int support_count_= 0 ; !! UNUSED VARIABLE !!
- // il faut lire les champs pour avoir les profils stockes !!!
- // il faudrait implémenter la lecture des profils dans med !!!
-
- END_OF(LOC);
-
-}
-
-// This method ask the drivers of all MESH/FIELD objects created from this MED driver
-// to read themselves
-void MED_MED_RDONLY_DRIVER::read( void )
- throw (MEDEXCEPTION) // from objects method read !
-{
- const char * LOC = "MED_MED_DRIVER::read() : ";
-
- BEGIN_OF(LOC);
-
- const map<MESH_NAME_, MESH*> & _meshes = const_cast<const map<MESH_NAME_, MESH*>& > (_ptrMed->_meshes);
- map<MESH_NAME_,MESH*>::const_iterator currentMesh;
-
- const map<FIELD_ *, MESH_NAME_> & _meshName = const_cast<const map<FIELD_ *, MESH_NAME_>& > (_ptrMed->_meshName);
- map<FIELD_ *, MESH_NAME_>::const_iterator currentField;
-
- for ( currentMesh=_meshes.begin();currentMesh != _meshes.end(); currentMesh++ )
- (*currentMesh).second->read(*this);
- //(*currentMesh).second->read(); // default reader, from readFileStruct
-
- // PROVISOIRE
- _ptrMed->updateSupport() ;
-
- for ( currentField =_meshName.begin(); currentField != _meshName.end(); currentField++ )
- (*currentField).first->read(*this);
- //(*currentField).first->read(); // default reader, from readFileStruct
-
- END_OF(LOC);
-}
-
-void MED_MED_RDONLY_DRIVER::write(void) const
+void IMED_MED_RDONLY_DRIVER::write(void) const
throw (MEDEXCEPTION)
{
throw MEDEXCEPTION("MED_MED_RDONLY_DRIVER::write : Can't write with a RDONLY driver !");
}
-void MED_MED_RDONLY_DRIVER::writeFrom(void) const
+void IMED_MED_RDONLY_DRIVER::writeFrom(void) const
throw (MEDEXCEPTION)
{
throw MEDEXCEPTION("MED_MED_RDONLY_DRIVER::writeFrom : Can't write with a RDONLY driver !");
// ------------- Write Only Part --------------
-MED_MED_WRONLY_DRIVER::MED_MED_WRONLY_DRIVER():MED_MED_DRIVER()
+IMED_MED_WRONLY_DRIVER::IMED_MED_WRONLY_DRIVER()
{
}
-MED_MED_WRONLY_DRIVER::MED_MED_WRONLY_DRIVER(const string & fileName, MED * const ptrMed):
- MED_MED_DRIVER(fileName,ptrMed)
+IMED_MED_WRONLY_DRIVER::IMED_MED_WRONLY_DRIVER(const string & fileName, MED * const ptrMed):
+ MED_MED_DRIVER(fileName,ptrMed,MED_EN::MED_ECRI)
{}
-MED_MED_WRONLY_DRIVER::MED_MED_WRONLY_DRIVER(const MED_MED_WRONLY_DRIVER & driver):
+IMED_MED_WRONLY_DRIVER::IMED_MED_WRONLY_DRIVER(const IMED_MED_WRONLY_DRIVER & driver):
MED_MED_DRIVER(driver)
{}
-MED_MED_WRONLY_DRIVER::~MED_MED_WRONLY_DRIVER()
+IMED_MED_WRONLY_DRIVER::~IMED_MED_WRONLY_DRIVER()
{
MESSAGE("MED_MED_WRONLY_DRIVER::~MED_MED_WRONLY_DRIVER() has been destroyed");
}
-GENDRIVER * MED_MED_WRONLY_DRIVER::copy(void) const
+void IMED_MED_WRONLY_DRIVER::read(void)
+ throw (MEDEXCEPTION)
{
- return new MED_MED_WRONLY_DRIVER(*this) ;
+ throw MEDEXCEPTION("MED_MED_WRONLY_DRIVER::read : Can't read with a WRONLY driver !");
}
-void MED_MED_WRONLY_DRIVER::read(void)
+void IMED_MED_WRONLY_DRIVER::readFileStruct(void)
throw (MEDEXCEPTION)
{
throw MEDEXCEPTION("MED_MED_WRONLY_DRIVER::read : Can't read with a WRONLY driver !");
}
-void MED_MED_WRONLY_DRIVER::readFileStruct(void)
- throw (MEDEXCEPTION)
+// ------------- Read Write Part --------------
+
+IMED_MED_RDWR_DRIVER::IMED_MED_RDWR_DRIVER()
+{}
+
+IMED_MED_RDWR_DRIVER::IMED_MED_RDWR_DRIVER(const string & fileName, MED * const ptrMed):
+ IMED_MED_RDONLY_DRIVER(fileName,ptrMed),IMED_MED_WRONLY_DRIVER(fileName,ptrMed),MED_MED_DRIVER(fileName,ptrMed,MED_REMP)
+{}
+
+IMED_MED_RDWR_DRIVER::IMED_MED_RDWR_DRIVER(const IMED_MED_RDWR_DRIVER & driver):
+ IMED_MED_RDONLY_DRIVER(driver),IMED_MED_WRONLY_DRIVER(driver),MED_MED_DRIVER(driver)
+{}
+
+IMED_MED_RDWR_DRIVER::~IMED_MED_RDWR_DRIVER() {
+ MESSAGE("MED_MED_RDWR_DRIVER::~MED_MED_RDWR_DRIVER() has been destroyed");
+}
+
+MED_MED_RDONLY_DRIVER::MED_MED_RDONLY_DRIVER()
{
- throw MEDEXCEPTION("MED_MED_WRONLY_DRIVER::read : Can't read with a WRONLY driver !");
+ MESSAGE("You are using the default constructor of the Med read only Driver and it is 2.1 one");
+ _concreteMedDrv = new MED_MED_RDONLY_DRIVER21();
}
-// This method ask the drivers of all MESH/FIELD objects created from this MED driver
-// to write themselves
-void MED_MED_WRONLY_DRIVER::writeFrom( void) const
- throw (MEDEXCEPTION) //from object method write !
+MED_MED_RDONLY_DRIVER::MED_MED_RDONLY_DRIVER(const string & fileName, MED * const ptrMed)
{
- const char * LOC = "MED_MED_DRIVER::writeFrom() : ";
+ _concreteMedDrv = DRIVERFACTORY::buildMedDriverFromFile(fileName,ptrMed,MED_LECT);
+}
- BEGIN_OF(LOC);
+MED_MED_RDONLY_DRIVER::MED_MED_RDONLY_DRIVER(const MED_MED_RDONLY_DRIVER & driver):MED_MED_DRIVER(driver)
+{
+}
- const map<MESH_NAME_, MESH*> & _meshes = const_cast<const map<MESH_NAME_, MESH*>& > (_ptrMed->_meshes);
- map<MESH_NAME_,MESH*>::const_iterator currentMesh;
+MED_MED_RDONLY_DRIVER::~MED_MED_RDONLY_DRIVER()
+{
+}
- const map<FIELD_ *, MESH_NAME_> & _meshName = const_cast<const map<FIELD_ *, MESH_NAME_>& > (_ptrMed->_meshName);
- map<FIELD_ *, MESH_NAME_>::const_iterator currentField;
-
- for ( currentMesh=_meshes.begin();currentMesh != _meshes.end(); currentMesh++ ) {
- try {
- (*currentMesh).second->write(*this);
- // On utilise pour les objects MESH ET FIELD le write(GENDRIVER *) et le == ds GENDRIVER avec eventuellement 1 id
- }
- catch ( const MED_DRIVER_NOT_FOUND_EXCEPTION & ex ) {
- continue;
- }
- }
+void MED_MED_RDONLY_DRIVER::write ( void ) const throw (MEDEXCEPTION)
+{
+ _concreteMedDrv->write();
+}
- for ( currentField=_meshName.begin();currentField != _meshName.end(); currentField++ ) {
- try {
- (*currentField).first->write(*this);
- }
- catch ( const MED_DRIVER_NOT_FOUND_EXCEPTION & ex ) {
- continue;
- }
- }
+void MED_MED_RDONLY_DRIVER::writeFrom ( void ) const throw (MEDEXCEPTION)
+{
+ _concreteMedDrv->writeFrom();
+}
- END_OF(LOC);
+void MED_MED_RDONLY_DRIVER::open() throw (MEDEXCEPTION)
+{
+ _concreteMedDrv->open();
+}
+void MED_MED_RDONLY_DRIVER::close()
+{
+ _concreteMedDrv->close();
+}
+void MED_MED_RDONLY_DRIVER::read ( void )
+{
+ _concreteMedDrv->read();
}
-void MED_MED_WRONLY_DRIVER::write(void ) const
- throw (MEDEXCEPTION) // from object method write !
+void MED_MED_RDONLY_DRIVER::readFileStruct ( void )
{
- const char * LOC = "MED_MED_DRIVER::write() : ";
- int current;
+ _concreteMedDrv->readFileStruct();
+}
- BEGIN_OF(LOC);
+GENDRIVER * MED_MED_RDONLY_DRIVER::copy ( void ) const
+{
+ return new MED_MED_RDONLY_DRIVER(*this);
+}
- // BCLE SUR LES OBJETS AVEC AJOUT DE DRIVER ET APPELS write
+MED_MED_WRONLY_DRIVER::MED_MED_WRONLY_DRIVER()
+{
+ MESSAGE("You are using the default constructor of the Med write only Driver and it is 2.1 one");
- const map<MESH_NAME_, MESH*> & _meshes = const_cast<const map<MESH_NAME_, MESH*>& > (_ptrMed->_meshes);
- map<MESH_NAME_,MESH*>::const_iterator currentMesh;
+ _concreteMedDrv = new MED_MED_WRONLY_DRIVER21();
+}
- const map<FIELD_ *, MESH_NAME_> & _meshName = const_cast<const map<FIELD_ *, MESH_NAME_>& > (_ptrMed->_meshName);
- map<FIELD_ *, MESH_NAME_>::const_iterator currentField;
-
- for ( currentMesh=_meshes.begin();currentMesh != _meshes.end(); currentMesh++ ) {
- //current = (*currentMesh).second->addDriver(MED_DRIVER,_fileName);
- current = (*currentMesh).second->addDriver(MED_DRIVER,_fileName,(*currentMesh).second->getName());
- // put right _id in Mesh driver (same as this._id)
- (*currentMesh).second->_drivers[current]->setId( getId() );
- //(*currentMesh).second->write(current) ;
- }
+MED_MED_WRONLY_DRIVER::MED_MED_WRONLY_DRIVER(const string & fileName, MED * const ptrMed)
+{
+ _concreteMedDrv = DRIVERFACTORY::buildMedDriverFromFile(fileName,ptrMed,MED_ECRI);
+}
- for ( currentField=_meshName.begin();currentField != _meshName.end(); currentField++ ) {
- //current = (*currentField).first->addDriver(MED_DRIVER,_fileName);
- current = (*currentField).first->addDriver(MED_DRIVER,_fileName,(*currentField).first->getName());
- // put right _id in Field driver (same as this._id)
- (*currentField).first->_drivers[current]->setId( getId() );
- //(*currentField).first->write(current) ;
- }
+MED_MED_WRONLY_DRIVER::MED_MED_WRONLY_DRIVER(const MED_MED_WRONLY_DRIVER & driver):MED_MED_DRIVER(driver)
+{
+}
- // that's work, but it is more efficenty to write directly when we had driver, no ?
- writeFrom();
-
- END_OF(LOC);
+MED_MED_WRONLY_DRIVER::~MED_MED_WRONLY_DRIVER()
+{
+}
+void MED_MED_WRONLY_DRIVER::write ( void ) const throw (MEDEXCEPTION)
+{
+ _concreteMedDrv->write();
}
-// ------------- Read Write Part --------------
+void MED_MED_WRONLY_DRIVER::writeFrom ( void ) const throw (MEDEXCEPTION)
+{
+ _concreteMedDrv->writeFrom();
+}
+
+void MED_MED_WRONLY_DRIVER::open() throw (MEDEXCEPTION)
+{
+ _concreteMedDrv->open();
+}
+
+void MED_MED_WRONLY_DRIVER::close()
+{
+ _concreteMedDrv->close();
+}
+
+void MED_MED_WRONLY_DRIVER::read ( void ) throw (MEDEXCEPTION)
+{
+ _concreteMedDrv->read();
+}
+
+void MED_MED_WRONLY_DRIVER::readFileStruct ( void ) throw (MEDEXCEPTION)
+{
+ _concreteMedDrv->readFileStruct();
+}
+
+GENDRIVER * MED_MED_WRONLY_DRIVER::copy ( void ) const
+{
+ return _concreteMedDrv->copy();
+}
MED_MED_RDWR_DRIVER::MED_MED_RDWR_DRIVER()
-{}
+{
+ MESSAGE("You are using the default constructor of the Med read write Driver and it is 2.1 one");
+ _concreteMedDrv = new MED_MED_RDWR_DRIVER21();
+}
-MED_MED_RDWR_DRIVER::MED_MED_RDWR_DRIVER(const string & fileName, MED * const ptrMed):
- MED_MED_DRIVER(fileName,ptrMed)
-{}
+MED_MED_RDWR_DRIVER::MED_MED_RDWR_DRIVER(const string & fileName, MED * const ptrMed)
+{
+ _concreteMedDrv = DRIVERFACTORY::buildMedDriverFromFile(fileName,ptrMed,MED_REMP);
+}
MED_MED_RDWR_DRIVER::MED_MED_RDWR_DRIVER(const MED_MED_RDWR_DRIVER & driver):
MED_MED_DRIVER(driver)
-{}
+{
+}
-MED_MED_RDWR_DRIVER::~MED_MED_RDWR_DRIVER() {
- MESSAGE("MED_MED_RDWR_DRIVER::~MED_MED_RDWR_DRIVER() has been destroyed");
+MED_MED_RDWR_DRIVER::~MED_MED_RDWR_DRIVER()
+{
+}
+
+void MED_MED_RDWR_DRIVER::write ( void ) const throw (MEDEXCEPTION)
+{
+ _concreteMedDrv->write();
+}
+
+void MED_MED_RDWR_DRIVER::writeFrom ( void ) const throw (MEDEXCEPTION)
+{
+ _concreteMedDrv->writeFrom();
}
-GENDRIVER * MED_MED_RDWR_DRIVER::copy(void) const
+void MED_MED_RDWR_DRIVER::open() throw (MEDEXCEPTION)
{
- return new MED_MED_RDWR_DRIVER(*this) ;
+ _concreteMedDrv->open();
}
-void MED_MED_RDWR_DRIVER::read(void)
- throw (MEDEXCEPTION) // from MED_MED_RDONLY_DRIVER::read()
+void MED_MED_RDWR_DRIVER::close()
{
- BEGIN_OF("MED_MED_RDWR_DRIVER::read(void)");
- MED_MED_RDONLY_DRIVER::read();
- END_OF("MED_MED_RDWR_DRIVER::read(void)");
+ _concreteMedDrv->close();
}
-void MED_MED_RDWR_DRIVER::readFileStruct(void)
- throw (MEDEXCEPTION) // from MED_MED_RDONLY_DRIVER::readFileStruct()
+void MED_MED_RDWR_DRIVER::read ( void ) throw (MEDEXCEPTION)
{
- BEGIN_OF("MED_MED_RDWR_DRIVER::readFileStruct(void)");
- MED_MED_RDONLY_DRIVER::readFileStruct();
- END_OF("MED_MED_RDWR_DRIVER::readFileStruct(void)");
+ _concreteMedDrv->read();
}
-void MED_MED_RDWR_DRIVER::write(void) const
- throw (MEDEXCEPTION) // from MED_MED_WRONLY_DRIVER::write()
+void MED_MED_RDWR_DRIVER::readFileStruct ( void ) throw (MEDEXCEPTION)
{
- BEGIN_OF("MED_MED_RDWR_DRIVER::write(void) const");
- MED_MED_WRONLY_DRIVER::write();
- END_OF("MED_MED_RDWR_DRIVER::write(void) const");
+ _concreteMedDrv->readFileStruct();
}
-void MED_MED_RDWR_DRIVER::writeFrom(void) const
- throw (MEDEXCEPTION) // from MED_MED_WRONLY_DRIVER::writeFrom();
+GENDRIVER * MED_MED_RDWR_DRIVER::copy ( void ) const
{
- BEGIN_OF("MED_MED_RDWR_DRIVER::writeFrom(void) const");
- MED_MED_WRONLY_DRIVER::writeFrom();
- END_OF("MED_MED_RDWR_DRIVER::writeFrom(void) const");
+ return _concreteMedDrv->copy();
}
protected:
MED * const _ptrMed; // Store 'MED_DRIVER (0..n)----(1) MED' associations
- MED_EN::med_idt _medIdt; // The _medIdt used to write/read Meshes to ::_filename
-
- //private:
- // MED_MED_DRIVER();
+ GENDRIVER * _concreteMedDrv;
public :
/*!
*/
virtual ~MED_MED_DRIVER() ;
- void open() throw (MEDEXCEPTION) ;
- void close();
+ virtual void open() throw (MEDEXCEPTION) = 0 ;
+ virtual void close() = 0 ;
+ virtual void write ( void ) const = 0 ;
+ virtual void writeFrom ( void ) const = 0 ;
+ virtual void read ( void ) = 0 ;
+ virtual void readFileStruct ( void ) = 0 ;
- //virtual void write ( void ) const = 0 ;
- virtual void write ( void ) const ;
- //virtual void writeFrom ( void ) const = 0 ;
- virtual void writeFrom ( void ) const ;
- //virtual void read ( void ) = 0 ;
- virtual void read ( void ) ;
- //virtual void readFileStruct ( void ) = 0 ;
- virtual void readFileStruct ( void ) ;
-
-private:
- //virtual GENDRIVER * copy ( void ) const = 0 ;
- virtual GENDRIVER * copy ( void ) const ;
+protected:
+ virtual GENDRIVER * copy ( void ) const = 0 ;
+ friend class MED_MED_RDONLY_DRIVER;
+ friend class MED_MED_WRONLY_DRIVER;
+ friend class MED_MED_RDWR_DRIVER;
};
/*!
*/
-class MED_MED_RDONLY_DRIVER : public virtual MED_MED_DRIVER
+class IMED_MED_RDONLY_DRIVER : public virtual MED_MED_DRIVER
{
public :
/*!
Constructor.
*/
- MED_MED_RDONLY_DRIVER();
+ IMED_MED_RDONLY_DRIVER();
/*!
Constructor.
*/
- MED_MED_RDONLY_DRIVER(const string & fileName, MED * const ptrMed);
+ IMED_MED_RDONLY_DRIVER(const string & fileName, MED * const ptrMed);
/*!
Copy constructor.
*/
- MED_MED_RDONLY_DRIVER(const MED_MED_RDONLY_DRIVER & driver);
+ IMED_MED_RDONLY_DRIVER(const IMED_MED_RDONLY_DRIVER & driver);
/*!
Destructor.
*/
- virtual ~MED_MED_RDONLY_DRIVER();
+ virtual ~IMED_MED_RDONLY_DRIVER();
/*!
Return a MEDEXCEPTION : it is the read-only driver.
Return a MEDEXCEPTION : it is the read-only driver.
*/
void writeFrom ( void ) const throw (MEDEXCEPTION) ;
- /*!
- Read all from the file.
- */
- void read ( void ) throw (MEDEXCEPTION);
- /*!
- Read only table of contents of the file.
-
- All objects are created but there values are not read.
- */
- void readFileStruct ( void ) throw (MEDEXCEPTION) ;
-
-private:
- virtual GENDRIVER * copy ( void ) const ;
-
};
/*!
*/
-class MED_MED_WRONLY_DRIVER : public virtual MED_MED_DRIVER
+class IMED_MED_WRONLY_DRIVER : public virtual MED_MED_DRIVER
{
public :
/*!
Constructor.
*/
- MED_MED_WRONLY_DRIVER();
+ IMED_MED_WRONLY_DRIVER();
/*!
Constructor.
*/
- MED_MED_WRONLY_DRIVER(const string & fileName, MED * const ptrMed);
+ IMED_MED_WRONLY_DRIVER(const string & fileName, MED * const ptrMed);
/*!
Copy constructor.
*/
- MED_MED_WRONLY_DRIVER(const MED_MED_WRONLY_DRIVER & driver);
+ IMED_MED_WRONLY_DRIVER(const IMED_MED_WRONLY_DRIVER & driver);
/*!
Destructor.
*/
- virtual ~MED_MED_WRONLY_DRIVER();
+ virtual ~IMED_MED_WRONLY_DRIVER();
- /*!
- Write all in file.
- */
- void write ( void ) const throw (MEDEXCEPTION);
- /*!
- Write only objects created from this MED driver in file.
- */
- void writeFrom ( void ) const throw (MEDEXCEPTION);
/*!
Return a MEDEXCEPTION : it is the write-only driver.
*/
*/
void readFileStruct ( void ) throw (MEDEXCEPTION) ;
-private:
- virtual GENDRIVER * copy ( void ) const ;
-
};
/*!
*/
-class MED_MED_RDWR_DRIVER : public virtual MED_MED_RDONLY_DRIVER,
- public virtual MED_MED_WRONLY_DRIVER
+class IMED_MED_RDWR_DRIVER : public virtual IMED_MED_RDONLY_DRIVER,
+ public virtual IMED_MED_WRONLY_DRIVER
{
public :
/*!
Constructor.
*/
- MED_MED_RDWR_DRIVER();
+ IMED_MED_RDWR_DRIVER();
/*!
Constructor.
*/
- MED_MED_RDWR_DRIVER(const string & fileName, MED * const ptrMed);
+ IMED_MED_RDWR_DRIVER(const string & fileName, MED * const ptrMed);
/*!
Copy constructor.
*/
- MED_MED_RDWR_DRIVER(const MED_MED_RDWR_DRIVER & driver);
+ IMED_MED_RDWR_DRIVER(const IMED_MED_RDWR_DRIVER & driver);
/*!
Destructor.
*/
- ~MED_MED_RDWR_DRIVER();
-
- /*!
- Write all in file.
- */
- void write ( void ) const throw (MEDEXCEPTION);
- /*!
- Write only objects created from this MED driver in file.
- */
- void writeFrom ( void ) const throw (MEDEXCEPTION);
- /*!
- Read all from the file.
- */
- void read ( void ) throw (MEDEXCEPTION);
- /*!
- Read only table of contents of the file.
+ ~IMED_MED_RDWR_DRIVER();
- All objects are created but there values are not read.
- */
- void readFileStruct ( void ) throw (MEDEXCEPTION);
+};
+class MED_MED_RDONLY_DRIVER : public virtual IMED_MED_RDONLY_DRIVER
+{
+public :
+ MED_MED_RDONLY_DRIVER();
+ MED_MED_RDONLY_DRIVER(const string & fileName, MED * const ptrMed);
+ MED_MED_RDONLY_DRIVER(const MED_MED_RDONLY_DRIVER & driver);
+ virtual ~MED_MED_RDONLY_DRIVER();
+ void write ( void ) const throw (MEDEXCEPTION) ;
+ void writeFrom ( void ) const throw (MEDEXCEPTION) ;
+ virtual void open() throw (MEDEXCEPTION) ;
+ virtual void close() ;
+ virtual void read ( void ) ;
+ virtual void readFileStruct ( void ) ;
private:
- virtual GENDRIVER * copy ( void ) const ;
+ GENDRIVER * copy ( void ) const;
+};
+
+class MED_MED_WRONLY_DRIVER : public virtual IMED_MED_WRONLY_DRIVER
+{
+public :
+ MED_MED_WRONLY_DRIVER();
+ MED_MED_WRONLY_DRIVER(const string & fileName, MED * const ptrMed);
+ MED_MED_WRONLY_DRIVER(const MED_MED_WRONLY_DRIVER & driver);
+ virtual ~MED_MED_WRONLY_DRIVER();
+ void write ( void ) const throw (MEDEXCEPTION) ;
+ void writeFrom ( void ) const throw (MEDEXCEPTION) ;
+ virtual void open() throw (MEDEXCEPTION) ;
+ virtual void close() ;
+ virtual void read ( void ) throw (MEDEXCEPTION) ;
+ virtual void readFileStruct ( void ) throw (MEDEXCEPTION) ;
+private:
+ GENDRIVER * copy ( void ) const;
};
+
+class MED_MED_RDWR_DRIVER : public IMED_MED_RDWR_DRIVER
+{
+
+public :
+ MED_MED_RDWR_DRIVER();
+ MED_MED_RDWR_DRIVER(const string & fileName, MED * const ptrMed);
+ MED_MED_RDWR_DRIVER(const MED_MED_RDWR_DRIVER & driver);
+ ~MED_MED_RDWR_DRIVER();
+ void write ( void ) const throw (MEDEXCEPTION) ;
+ void writeFrom ( void ) const throw (MEDEXCEPTION) ;
+ virtual void open() throw (MEDEXCEPTION) ;
+ virtual void close() ;
+ virtual void read ( void ) throw (MEDEXCEPTION) ;
+ virtual void readFileStruct ( void ) throw (MEDEXCEPTION) ;
+private:
+ GENDRIVER * copy ( void ) const;
};
+}
#endif /* MED_MED_DRIVER_HXX */
--- /dev/null
+#include "MEDMEM_Compatibility21_22.hxx"
+#include "MEDMEM_MedMedDriver21.hxx"
+#include "MEDMEM_MedMeshDriver.hxx"
+#include "MEDMEM_DriversDef.hxx"
+
+#include "MEDMEM_Mesh.hxx"
+#include "MEDMEM_Grid.hxx"
+#include "MEDMEM_Field.hxx"
+// EN ATTENDANT L'utilisation de MedFieldDriver.hxx ds Field.hxx
+#include "MEDMEM_MedFieldDriver.hxx"
+#include "MEDMEM_Med.hxx"
+#include "MEDMEM_define.hxx"
+
+#include <string>
+
+using namespace std;
+using namespace MED_EN;
+using namespace MEDMEM;
+
+MED_MED_DRIVER21::MED_MED_DRIVER21(): _medIdt(MED_INVALID)
+{}
+
+MED_MED_DRIVER21::MED_MED_DRIVER21(const string & fileName, MED * const ptrMed):
+ MED_MED_DRIVER(fileName,ptrMed), _medIdt(MED_INVALID)
+{
+ //_ptrMed->addDriver(*this); // The specific MED driver id is set within the addDriver method.
+}
+
+MED_MED_DRIVER21::MED_MED_DRIVER21(const string & fileName,
+ MED * const ptrMed,
+ MED_EN::med_mode_acces accessMode):
+ MED_MED_DRIVER(fileName,ptrMed,accessMode), _medIdt(MED_INVALID)
+{
+}
+//REM : As t'on besoin du champ _status : _medIdt <-> _status ? Oui
+
+MED_MED_DRIVER21::MED_MED_DRIVER21(const MED_MED_DRIVER21 & driver):
+ MED_MED_DRIVER(driver),_medIdt(driver._medIdt)
+{
+}
+
+MED_MED_DRIVER21::~MED_MED_DRIVER21()
+{
+ MESSAGE("MED_MED_DRIVER21::~MED_MED_DRIVER21() has been destroyed");
+}
+
+void MED_MED_DRIVER21::read()
+{
+}
+void MED_MED_DRIVER21::readFileStruct()
+{
+}
+void MED_MED_DRIVER21::write() const
+{
+}
+GENDRIVER * MED_MED_DRIVER21::copy(void) const
+{
+ return new MED_MED_DRIVER21(*this) ;
+}
+void MED_MED_DRIVER21::writeFrom() const
+{
+}
+
+void MED_MED_DRIVER21::open()
+ throw (MEDEXCEPTION)
+{
+
+ const char * LOC ="MED_MED_DRIVER21::open() : ";
+ BEGIN_OF(LOC);
+
+ // REFLECHIR SUR CE TEST PAR RAPPORT A L'OUVERTURE/FERMETURE
+// if ( _medIdt != MED_INVALID )
+// throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+// << "_medIdt is already in use, please close the file |"
+// << _fileName << "| before calling open()"
+// )
+// );
+
+// if ( _status != MED_CLOSED )
+// throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+// << "_status is 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()"
+ )
+ );
+
+ MESSAGE(LOC<<"_fileName.c_str : "<< _fileName.c_str()<<",mode : "<< _accessMode);
+ _medIdt = med_2_1::MEDouvrir( (const_cast <char *> (_fileName.c_str())), (med_2_1::med_mode_acces) _accessMode);
+ MESSAGE(LOC<<" _medIdt = "<<_medIdt);
+
+ if (_medIdt > 0)
+ _status=MED_OPENED;
+ else {
+ _status = MED_CLOSED;
+ _medIdt = MED_INVALID;
+ throw MED_EXCEPTION (LOCALIZED( STRING(LOC)
+ << "Can't open |" << _fileName
+ << "|, _medIdt : " << _medIdt
+ )
+ );
+ }
+
+ END_OF(LOC);
+}
+
+
+void MED_MED_DRIVER21::close()
+{
+ med_2_1::med_int err = 0;
+ const char * LOC = "MED_MED_DRIVER21::close() : ";
+
+
+// if ( _status == MED_CLOSED)
+// throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << ": the file |"
+// << _fileName << "| is already closed"
+// )
+// );
+
+// if ( _medIdt == MED_INVALID )
+// throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "_medIdt invalid, but the file |"
+// << _fileName << "| seems to be openned !"
+// )
+// );
+
+ if ( _medIdt != MED_INVALID )
+ err=med_2_1::MEDfermer(_medIdt);
+
+// if (err != MED_VALID)
+// throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "the file |"
+// << _fileName << "| couldn't be closed"
+// )
+// );
+
+ _status = MED_CLOSED;
+ _medIdt = MED_INVALID;
+
+ END_OF(LOC);
+}
+
+
+// ------------- Read Only Part --------------
+
+MED_MED_RDONLY_DRIVER21::MED_MED_RDONLY_DRIVER21()
+{
+}
+
+MED_MED_RDONLY_DRIVER21::MED_MED_RDONLY_DRIVER21(const string & fileName, MED * const ptrMed):
+ IMED_MED_RDONLY_DRIVER(fileName,ptrMed),MED_MED_DRIVER21(fileName,ptrMed,MED_EN::MED_RDONLY),MED_MED_DRIVER(fileName,ptrMed,MED_EN::MED_RDONLY)
+{
+ MESSAGE("MED_MED_RDONLY_DRIVER21::MED_MED_RDONLY_DRIVER21(const string & fileName, MED * const ptrMed) Constructeur read only");
+}
+
+MED_MED_RDONLY_DRIVER21::MED_MED_RDONLY_DRIVER21(const MED_MED_RDONLY_DRIVER21 & driver):
+ IMED_MED_RDONLY_DRIVER(driver) ,MED_MED_DRIVER21(driver),MED_MED_DRIVER(driver)
+{
+}
+
+MED_MED_RDONLY_DRIVER21::~MED_MED_RDONLY_DRIVER21()
+{
+ MESSAGE("MED_MED_RDONLY_DRIVER21::~MED_MED_RDONLY_DRIVER21() has been destroyed");
+}
+
+GENDRIVER * MED_MED_RDONLY_DRIVER21::copy(void) const
+{
+ return new MED_MED_RDONLY_DRIVER21(*this) ;
+}
+
+void MED_MED_RDONLY_DRIVER21::write ( void ) const throw (MEDEXCEPTION)
+{
+ IMED_MED_RDONLY_DRIVER::write();
+}
+
+void MED_MED_RDONLY_DRIVER21::writeFrom ( void ) const throw (MEDEXCEPTION)
+{
+ IMED_MED_RDONLY_DRIVER::writeFrom();
+}
+
+void MED_MED_RDONLY_DRIVER21::readFileStruct( void )
+ throw (MEDEXCEPTION)
+{
+ const char * LOC = "MED_MED_DRIVER21::readFileStruct() : ";
+ int err,i,j;
+
+ BEGIN_OF(LOC);
+
+ if ( _medIdt == MED_INVALID )
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+ << "_medIdt is invalid, please open the file |"
+ << _fileName << "| before calling readFileStruct()"
+ )
+ );
+ // Read number of meshes and their associated name
+ {
+ int numberOfMeshes;
+ char meshName[MED_TAILLE_NOM+1]="";
+ char meshDescription[MED_TAILLE_DESC+1]="";
+ med_2_1::med_int meshDim;
+ MESH * ptrMesh;
+ // MED_MESH_RDWR_DRIVER * ptrDriver; !! UNUSED VARIABLE !!
+
+ numberOfMeshes = med_2_1::MEDnMaa(_medIdt) ;
+ if ( numberOfMeshes <= 0 )
+ MESSAGE(LOC << "Be careful there is no mesh in file |"<<_fileName<<"| !");
+
+ MESH_ENTITIES::const_iterator currentEntity;
+ for (i=1;i<=numberOfMeshes;i++) {
+
+ // find out if the mesh is a Grid
+
+ med_2_1::med_int isAGrid = false;
+ med_2_1::med_grid_type type;
+
+ err = MEDgridInfo (_medIdt, i, &isAGrid, &type);
+ if (err != MED_VALID)
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "error in MEDgridInfo()") );
+
+ err = med_2_1::MEDmaaInfo(_medIdt, i ,meshName, &meshDim) ;
+
+ strcpy(meshDescription,"Mesh from Med 2.2 format");
+
+ if (err != MED_VALID)
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << ": can't get information about the mesh n°"
+ << i <<" of the file |" << _fileName << "| !"
+ )
+ );
+ MESSAGE(LOC<<": Mesh n°"<<i<<" nammed "<<meshName);
+
+ if (isAGrid)
+ ptrMesh = new GRID((MED_EN::med_grid_type) type);
+ else
+ ptrMesh = new MESH();
+
+ //MED_MESH_RDWR_DRIVER * _ptrDriver = new MED_MESH_RDWR_DRIVER(_fileName, ptrMesh);
+ MED_EN::med_mode_acces myMode = getAccessMode();
+// MED_MESH_DRIVER * ptrDriver ;
+// switch (myMode) {
+// case MED_EN::MED_LECT:
+// ptrDriver = new MED_MESH_RDONLY_DRIVER(_fileName, ptrMesh);
+// break ;
+// case MED_EN::MED_REMP:
+// ptrDriver = new MED_MESH_RDWR_DRIVER(_fileName, ptrMesh);
+// break ;
+// case MED_EN::MED_ECRI: // should never append !!
+// ptrDriver = new MED_MESH_RDONLY_DRIVER(_fileName, ptrMesh);
+// break;
+// default:
+// throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Bad file mode access !"));
+// }
+
+ GENDRIVER * ptrDriver =
+ DRIVERFACTORY::buildConcreteMedDriverForMesh(_fileName, ptrMesh,
+ meshName, myMode, V21);
+
+ ptrDriver->setId ( getId() );
+ ptrDriver->setMeshName ( meshName );
+ ptrMesh->setDescription(meshDescription);
+
+ SCRUTE(ptrDriver);
+
+ ptrMesh->addDriver(*ptrDriver);
+ delete ptrDriver ;
+
+ if (isAGrid)
+ _ptrMed->_meshes[meshName] = (MESH *) ptrMesh;
+ else
+ _ptrMed->_meshes[meshName] = ptrMesh;
+
+ ptrMesh->setName(meshName);
+
+ SCRUTE(ptrMesh);
+
+ MESSAGE(LOC<<"is" << (isAGrid ? "" : " NOT") << " a GRID and its name is "<<ptrMesh->getName());
+
+ // we create all global support (for each entity type :
+ int index = 0;
+ for (currentEntity=meshEntities.begin();currentEntity != meshEntities.end(); currentEntity++) {
+ string supportName="SupportOnAll_" ;
+ supportName+=entNames[(*currentEntity).first] ;
+ //(_ptrMed->_support)[meshName][(MED_EN::medEntityMesh)(*currentEntity).first]=new SUPPORT(ptrMesh,supportName,(MED_EN::medEntityMesh) (*currentEntity).first) ;
+ SUPPORT* mySupport = new SUPPORT() ;
+ mySupport->setName(supportName);
+ mySupport->setMesh(ptrMesh);
+ mySupport->setEntity((MED_EN::medEntityMesh) (*currentEntity).first);
+ mySupport->setAll(true);
+ (_ptrMed->_support)[meshName][(MED_EN::medEntityMesh)(*currentEntity).first] = mySupport ;
+ MESSAGE(LOC<< "The support " << supportName.c_str() << " on entity " << (*currentEntity).first << " is built");
+ index++;
+ }
+ MESSAGE(LOC <<"The mesh " <<ptrMesh->getName() << " has " << index << " support(s)");
+ }
+
+ map<MESH_NAME_, map<MED_EN::medEntityMesh,SUPPORT *> >::const_iterator const_itSupportOnMesh ;
+
+ int index = 0;
+
+ vector<SUPPORT *> vectSupp;
+ for (const_itSupportOnMesh=_ptrMed->_support.begin(); const_itSupportOnMesh != _ptrMed->_support.end();
+ const_itSupportOnMesh++ )
+ {
+ map<MED_EN::medEntityMesh,SUPPORT *>::const_iterator const_itSupport ;
+ for (const_itSupport=(*const_itSupportOnMesh).second.begin();
+ const_itSupport!=(*const_itSupportOnMesh).second.end();const_itSupport++) index++;
+ }
+
+ MESSAGE(LOC << "In this MED object there is(are) " << index << " support(s):");
+
+ vectSupp.resize(index);
+
+ index = 0;
+ for (const_itSupportOnMesh=_ptrMed->_support.begin(); const_itSupportOnMesh != _ptrMed->_support.end();
+ const_itSupportOnMesh++ )
+ {
+ map<MED_EN::medEntityMesh,SUPPORT *>::const_iterator const_itSupport ;
+ for (const_itSupport=(*const_itSupportOnMesh).second.begin();
+ const_itSupport!=(*const_itSupportOnMesh).second.end();const_itSupport++)
+ {
+ vectSupp[index] = (*const_itSupport).second;
+ SCRUTE(vectSupp[index]);
+ MESSAGE(LOC << "Support number " << index << " is "<< *vectSupp[index]);
+ index++;
+ }
+ }
+
+ }
+
+
+ // Read number of fields, their associated name and their list of (timeStepNumber,iterationNumber)
+ {
+ int numberOfFields = 0; //MED_INVALID
+ // char fieldName[MED_TAILLE_NOM+1] = "";
+ char fieldName[MED_TAILLE_NOM+1] ;
+ int numberOfComponents = 0;
+ char * componentName = (char *) MED_NULL;
+ char * unitName = (char *) MED_NULL;
+ // char meshName[MED_TAILLE_NOM+1] = "";
+ char meshName[MED_TAILLE_NOM+1] ;
+ med_2_1::med_type_champ type;
+ MESH * ptrMesh = (MESH *) MED_NULL;
+ FIELD_ * ptrField = (FIELD_ *) MED_NULL;
+ //MED_FIELD_RDWR_DRIVER * ptrDriver = (MED_FIELD_RDWR_DRIVER * ) MED_NULL;
+ GENDRIVER * ptrDriver = (GENDRIVER * ) MED_NULL;
+ SUPPORT * ptrSupport = (SUPPORT * ) MED_NULL;
+ MESH_ENTITIES::const_iterator currentEntity;
+ list<MED_EN::medGeometryElement>::const_iterator currentGeometry;
+ med_2_1::med_int NbOfGaussPts = 0;
+ int numberOfTimeSteps = -1;
+ med_2_1::med_int timeStepNumber = -1;
+ // char timeStepUnit[MED_TAILLE_PNOM]= "";
+ char timeStepUnit[MED_TAILLE_PNOM21+1] ;
+ double timeStep = 0.0;
+ med_2_1::med_int orderNumber = -1; //???init?????
+ map<MESH_NAME_,MESH*> & _meshes = _ptrMed->_meshes;
+ map<FIELD_NAME_,MAP_DT_IT_> & _fields = _ptrMed->_fields;
+ map<FIELD_ *, MESH_NAME_> & _meshName = _ptrMed->_meshName;
+ map<MESH_NAME_, map<MED_EN::medEntityMesh,SUPPORT *> > & support = _ptrMed->_support;
+
+
+ numberOfFields = med_2_1::MEDnChamp(_medIdt,0) ;
+ if ( numberOfFields <= 0 )
+ MESSAGE(LOC << "Be careful there is no field in file |"<<_fileName<<"| !");
+
+ for (i=1;i<=numberOfFields;i++) {
+
+ numberOfComponents = med_2_1::MEDnChamp(_medIdt,i) ;
+ if ( numberOfComponents <= 0 )
+ if (err != MED_VALID)
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "Be careful there is no compound for field n°"
+ << i << "in file |"<<_fileName<<"| !"));
+
+ componentName = new char[numberOfComponents*MED_TAILLE_PNOM21+1] ;
+ unitName = new char[numberOfComponents*MED_TAILLE_PNOM21+1] ;
+
+ err = MEDchampInfo(_medIdt, i, fieldName, &type, componentName,
+ unitName, numberOfComponents) ;
+
+ if (err != MED_VALID)
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+ << ": can't get information about the field n°"
+ << i <<" of the file |" << _fileName << "| !"));
+
+ MESSAGE(LOC << "Field n°"<<i<<" nammed "<< fieldName
+ << " ,component(s) : " << componentName
+ <<" ,unit(s) : " << unitName);
+
+
+ // Loop on all (entity type,geometry type) until you find an existing one then
+ // get the (n°dt,n°it) pairs list for the current (field,entity type,geometry type)
+ // We suppose there is the same list whatever the existing (entity type,geometry type) pair
+ // support map :
+ for (currentEntity=meshEntities.begin();currentEntity != meshEntities.end(); currentEntity++) {
+ // numberOfTimeSteps MUST be given by MEDchampInfo !!!!!
+ for (currentGeometry = (*currentEntity).second.begin();currentGeometry != (*currentEntity).second.end(); currentGeometry++) {
+ MESSAGE("Field information with Entity,Geom = "<<(*currentEntity).first<<","<<(*currentGeometry));
+ numberOfTimeSteps = MEDnPasdetemps(_medIdt, fieldName,
+ (med_2_1::med_entite_maillage)(*currentEntity).first,
+ (med_2_1::med_geometrie_element) (*currentGeometry) );
+ MESSAGE("Field information 2 : NumberOfTimeStep :"<<numberOfTimeSteps);
+ if ( numberOfTimeSteps > MED_VALID )
+ break ; // There are value for some med_geometrie_element of this med_entite_maillage.
+ }
+ if (numberOfTimeSteps>0) // we have at least one
+
+ for (currentGeometry = (*currentEntity).second.begin();currentGeometry != (*currentEntity).second.end(); currentGeometry++) {
+
+ MESSAGE("Field information 3 : Geom : "<<(*currentGeometry));
+ for (j=1;j <= numberOfTimeSteps; j++) {
+
+ MESSAGE("Field information 4 : time step j = "<<j);
+ err = MEDpasdetempsInfo( _medIdt, fieldName,
+ (med_2_1::med_entite_maillage) (*currentEntity).first,
+ (med_2_1::med_geometrie_element) (*currentGeometry),j,
+ meshName, &NbOfGaussPts,
+ &timeStepNumber, timeStepUnit, &timeStep,
+ &orderNumber);
+ if (err == MED_VALID) { // we have found for (*currentEntity).first and (*currentGeometry)
+
+ MESSAGE("Field information 5 ;: NumberOfGaussPoint : "<<NbOfGaussPts<<", timeStepNumber : "<<timeStepNumber);
+ // CORRECT a bug in MEDpasdetempsInfo :
+ // we get a value n'importe quoi in NbOfGaussPts !!!!
+
+ if (NbOfGaussPts>100)
+ NbOfGaussPts=1 ;
+ if (timeStepNumber<0)
+ timeStepNumber=-1 ;
+
+
+ // ATTENTION TRAITER L'EXCEPTION !!!!!!!!!!!!
+
+ // Il faudra traiter le cas d'un champ qui utilise +sieurs (entity,geom) voir le travail de patrick
+ // Il faudra traiter le cas des profils...
+ // ptrField = new FIELD();
+ // _ptrDriver = new MED_FIELD_RDWR_DRIVER(_fileName, ptrField);
+ // ptrField->addDriver(_ptrDriver);
+ // _fields[fieldName]=ptrField;
+
+ // Verify meshName is already known
+
+ map<MESH_NAME_,MESH*>::iterator _meshesIt = _meshes.find(meshName);
+ if ( _meshesIt == _meshes.end() ) {
+ MESSAGE(LOC << "There is no mesh |"
+ << meshName <<"| in the file |"
+ << _fileName <<"|, but |" << meshName <<"| is referenced by field |"
+ << fieldName <<"|, entity : |"
+ << entNames [(*currentEntity).first] <<"|, geometric element of type |"
+ << geoNames [(*currentGeometry)] <<"|"
+ );
+ } // POURQUOI SI JE NE MET PAS DE BLOCK J'AI UN PARSE ERROR : PG : c'est la macro MESSAGE qui fait ca !
+ else
+ ptrMesh = _meshes[meshName];
+
+ ptrSupport = support[meshName][(MED_EN::medEntityMesh) (*currentEntity).first];
+ if (NbOfGaussPts != 1)
+ throw MEDEXCEPTION(LOCALIZED( STRING(LOC) <<"Number of Gauss Point must be equal to 1 for instance")) ;
+
+ // init to null to prevent some error if not correctly allocated !
+ ptrField = (FIELD_*)NULL ;
+// ptrDriver = (GENDRIVER*)NULL ;
+
+ switch ( type) {
+ case med_2_1::MED_INT64 :
+ if ( sizeof(med_2_1::med_int) != 8 )
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) <<
+ " The Field type of |"
+ << fieldName <<"|, entity : |"
+ << entNames [(*currentEntity).first] <<"|, geometric element of type |"
+ << geoNames [(*currentGeometry) ] <<
+ "| is MED_INT64 but size of med_int is not equal to 8 bytes !"
+ )
+ );
+ break;
+ case med_2_1::MED_INT32 : {
+// throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) <<
+// "NOT IMPLEMENTED : BUG IN STL !")
+// ) ;
+ // ptrField = new FIELD<med_2_1::med_int> ( ptrSupport,numberOfComponents ); // Les valeurs du champ ne doivent pas être lue pour l'instant
+
+ ptrField = new FIELD<int> ( ); // Les valeurs du champ ne doivent pas être lue pour l'instant
+ ((FIELD<int>*) ptrField)->setSupport(ptrSupport);
+ ((FIELD<int>*) ptrField)->setNumberOfComponents(numberOfComponents);
+ ((FIELD<int>*) ptrField)->setName(fieldName) ; //provisoire, pour debug
+ MESSAGE("#### SET NAME in FIELD : "<<fieldName);
+
+ MED_EN::med_mode_acces myMode = getAccessMode();
+// switch (myMode) {
+// case MED_EN::MED_LECT:
+// ptrDriver = new MED_FIELD_RDONLY_DRIVER<int>(_fileName, (FIELD<int> *)ptrField);
+// break ;
+// case MED_EN::MED_REMP:
+// ptrDriver = new MED_FIELD_RDWR_DRIVER<int>(_fileName, (FIELD<int> *)ptrField);
+// break ;
+// case MED_EN::MED_ECRI: // should never append !!
+// ptrDriver = new MED_FIELD_RDONLY_DRIVER<int>(_fileName, (FIELD<int> *)ptrField);
+// break;
+// default:
+// throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Bad file mode access !"));
+// }
+
+ ptrDriver = DRIVERFACTORY::buildConcreteMedDriverForField<int>(_fileName, (FIELD<int> *)ptrField, myMode, V21);
+
+ SCRUTE(ptrDriver);
+
+ break;
+ }
+ case med_2_1::MED_REEL64 : {
+ // ptrField = new FIELD<med_2_1::med_float> ( ptrSupport,numberOfComponents ); // Les valeurs du champ ne doivent pas être lue pour l'instant
+ ptrField = new FIELD<double> ( ); // Les valeurs du champ ne doivent pas être lue pour l'instant
+ ((FIELD<med_2_1::med_float>*) ptrField)->setSupport(ptrSupport);
+ ((FIELD<med_2_1::med_float>*) ptrField)->setNumberOfComponents(numberOfComponents);
+ ((FIELD<med_2_1::med_float>*) ptrField)->setName(fieldName) ; //provisoire, pour debug
+ MESSAGE("#### SET NAME in FIELD : "<<fieldName);
+
+ MED_EN::med_mode_acces myMode = getAccessMode();
+// switch (myMode) {
+// case MED_EN::MED_LECT:
+// ptrDriver = new MED_FIELD_RDONLY_DRIVER<med_2_1::med_float>(_fileName, (FIELD<med_2_1::med_float> *)ptrField);
+// break ;
+// case MED_EN::MED_REMP:
+// ptrDriver = new MED_FIELD_RDWR_DRIVER<med_2_1::med_float>(_fileName, (FIELD<med_2_1::med_float> *)ptrField);
+// break ;
+// case MED_EN::MED_ECRI: // should never append !!
+// ptrDriver = new MED_FIELD_RDONLY_DRIVER<med_2_1::med_float>(_fileName, (FIELD<med_2_1::med_float> *)ptrField);
+// break;
+// default:
+// throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Bad file mode access !"));
+// }
+
+ ptrDriver = DRIVERFACTORY::buildConcreteMedDriverForField<med_2_1::med_float>(_fileName, (FIELD<med_2_1::med_float> *)ptrField, myMode, V21);
+ SCRUTE(ptrDriver);
+
+ break;
+ }
+ default : {
+ if ( numberOfTimeSteps > 1)
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) <<
+ " The Field type of |"
+ << fieldName <<"|, entity : |"
+ << entNames [(*currentEntity).first]
+ <<"|, geometric element of type |"
+ << geoNames [(*currentGeometry)]
+ <<"| is neither MED_INT, MED_INT32, MED_INT64 nor MED_REEL64 !"
+ )
+ );
+ break ;
+ }
+ }
+ ptrField->setValueType((MED_EN::med_type_champ) type) ; // need to write field !
+
+ MESSAGE("timeStepNumber :"<<timeStepNumber<<",orderNumber :"<<orderNumber);
+ ptrField->setIterationNumber ( timeStepNumber); // A ajouter dans la classe FIELD
+ ptrField->setOrderNumber ( orderNumber);
+ ptrField->setTime ( timeStep);
+
+ // Create a driver for this (field n°dt,n°it)
+ ptrDriver->setId ( getId() );
+ MESSAGE("###### ptrDriver->setFieldName : #"<<fieldName<<"#");
+ ptrDriver->setFieldName(fieldName);
+ ptrField->addDriver(*ptrDriver);
+ // driver is duplicated : remove it
+ delete ptrDriver;
+
+ DT_IT_ dtIt;
+ dtIt.dt = timeStepNumber;
+ dtIt.it = orderNumber;
+
+ (_fields [fieldName])[dtIt] = ptrField;
+ _meshName[ptrField ] = meshName;
+ }
+ }
+ }
+ }
+ delete[] componentName ;
+ delete[] unitName ;
+ }
+ }
+
+ // read profil count and their names
+ // int support_count_= 0 ; !! UNUSED VARIABLE !!
+ // il faut lire les champs pour avoir les profils stockes !!!
+ // il faudrait implémenter la lecture des profils dans med !!!
+
+ END_OF(LOC);
+
+}
+
+// This method ask the drivers of all MESH/FIELD objects created from this MED driver
+// to read themselves
+void MED_MED_RDONLY_DRIVER21::read( void )
+ throw (MEDEXCEPTION) // from objects method read !
+{
+ const char * LOC = "MED_MED_DRIVER21::read() : ";
+
+ BEGIN_OF(LOC);
+
+ const map<MESH_NAME_, MESH*> & _meshes = const_cast<const map<MESH_NAME_, MESH*>& > (_ptrMed->_meshes);
+ map<MESH_NAME_,MESH*>::const_iterator currentMesh;
+
+ const map<FIELD_ *, MESH_NAME_> & _meshName = const_cast<const map<FIELD_ *, MESH_NAME_>& > (_ptrMed->_meshName);
+ map<FIELD_ *, MESH_NAME_>::const_iterator currentField;
+
+ for ( currentMesh=_meshes.begin();currentMesh != _meshes.end(); currentMesh++ )
+ (*currentMesh).second->read(*this);
+ //(*currentMesh).second->read(); // default reader, from readFileStruct
+
+ // PROVISOIRE
+ _ptrMed->updateSupport() ;
+
+ for ( currentField =_meshName.begin(); currentField != _meshName.end(); currentField++ )
+ (*currentField).first->read(*this);
+ //(*currentField).first->read(); // default reader, from readFileStruct
+
+ END_OF(LOC);
+}
+
+// ------------- Write Only Part --------------
+
+MED_MED_WRONLY_DRIVER21::MED_MED_WRONLY_DRIVER21()
+{
+}
+
+MED_MED_WRONLY_DRIVER21::MED_MED_WRONLY_DRIVER21(const string & fileName, MED * const ptrMed):
+ IMED_MED_WRONLY_DRIVER(fileName,ptrMed),MED_MED_DRIVER21(fileName,ptrMed),MED_MED_DRIVER(fileName,ptrMed,MED_EN::MED_WRONLY)
+{}
+
+MED_MED_WRONLY_DRIVER21::MED_MED_WRONLY_DRIVER21(const MED_MED_WRONLY_DRIVER21 & driver):
+ IMED_MED_WRONLY_DRIVER(driver),MED_MED_DRIVER(driver),MED_MED_DRIVER21(driver)
+{}
+
+MED_MED_WRONLY_DRIVER21::~MED_MED_WRONLY_DRIVER21()
+{
+ MESSAGE("MED_MED_WRONLY_DRIVER21::~MED_MED_WRONLY_DRIVER21() has been destroyed");
+}
+
+GENDRIVER * MED_MED_WRONLY_DRIVER21::copy(void) const
+{
+ return new MED_MED_WRONLY_DRIVER21(*this) ;
+}
+
+void MED_MED_WRONLY_DRIVER21::read ( void ) throw (MEDEXCEPTION)
+{
+ IMED_MED_WRONLY_DRIVER::read();
+}
+
+void MED_MED_WRONLY_DRIVER21::readFileStruct ( void ) throw (MEDEXCEPTION)
+{
+ IMED_MED_WRONLY_DRIVER::readFileStruct();
+}
+
+// This method ask the drivers of all MESH/FIELD objects created from this MED driver
+// to write themselves
+void MED_MED_WRONLY_DRIVER21::writeFrom( void) const
+ throw (MEDEXCEPTION) //from object method write !
+{
+ const char * LOC = "MED_MED_DRIVER21::writeFrom() : ";
+
+ BEGIN_OF(LOC);
+
+ const map<MESH_NAME_, MESH*> & _meshes = const_cast<const map<MESH_NAME_, MESH*>& > (_ptrMed->_meshes);
+ map<MESH_NAME_,MESH*>::const_iterator currentMesh;
+
+ const map<FIELD_ *, MESH_NAME_> & _meshName = const_cast<const map<FIELD_ *, MESH_NAME_>& > (_ptrMed->_meshName);
+ map<FIELD_ *, MESH_NAME_>::const_iterator currentField;
+
+ for ( currentMesh=_meshes.begin();currentMesh != _meshes.end(); currentMesh++ ) {
+ try {
+ (*currentMesh).second->write(*this);
+ // On utilise pour les objects MESH ET FIELD le write(GENDRIVER *) et le == ds GENDRIVER avec eventuellement 1 id
+ }
+ catch ( const MED_DRIVER_NOT_FOUND_EXCEPTION & ex ) {
+ continue;
+ }
+ }
+
+ for ( currentField=_meshName.begin();currentField != _meshName.end(); currentField++ ) {
+ try {
+ (*currentField).first->write(*this);
+ }
+ catch ( const MED_DRIVER_NOT_FOUND_EXCEPTION & ex ) {
+ continue;
+ }
+ }
+
+ END_OF(LOC);
+
+}
+
+void MED_MED_WRONLY_DRIVER21::write(void ) const
+ throw (MEDEXCEPTION) // from object method write !
+{
+ const char * LOC = "MED_MED_DRIVER21::write() : ";
+ int current;
+
+ BEGIN_OF(LOC);
+
+ // BCLE SUR LES OBJETS AVEC AJOUT DE DRIVER ET APPELS write
+
+ const map<MESH_NAME_, MESH*> & _meshes = const_cast<const map<MESH_NAME_, MESH*>& > (_ptrMed->_meshes);
+ map<MESH_NAME_,MESH*>::const_iterator currentMesh;
+
+ const map<FIELD_ *, MESH_NAME_> & _meshName = const_cast<const map<FIELD_ *, MESH_NAME_>& > (_ptrMed->_meshName);
+ map<FIELD_ *, MESH_NAME_>::const_iterator currentField;
+
+ for ( currentMesh=_meshes.begin();currentMesh != _meshes.end(); currentMesh++ ) {
+ //current = (*currentMesh).second->addDriver(MED_DRIVER,_fileName);
+ current = (*currentMesh).second->addDriver(MED_DRIVER,_fileName,(*currentMesh).second->getName());
+ // put right _id in Mesh driver (same as this._id)
+ (*currentMesh).second->_drivers[current]->setId( getId() );
+ //(*currentMesh).second->write(current) ;
+ }
+
+ for ( currentField=_meshName.begin();currentField != _meshName.end(); currentField++ ) {
+ //current = (*currentField).first->addDriver(MED_DRIVER,_fileName);
+ current = (*currentField).first->addDriver(MED_DRIVER,_fileName,(*currentField).first->getName());
+ // put right _id in Field driver (same as this._id)
+ (*currentField).first->_drivers[current]->setId( getId() );
+ //(*currentField).first->write(current) ;
+ }
+
+ // that's work, but it is more efficenty to write directly when we had driver, no ?
+ writeFrom();
+
+ END_OF(LOC);
+
+}
+
+// ------------- Read Write Part --------------
+
+MED_MED_RDWR_DRIVER21::MED_MED_RDWR_DRIVER21()
+{}
+
+MED_MED_RDWR_DRIVER21::MED_MED_RDWR_DRIVER21(const string & fileName, MED * const ptrMed):
+ MED_MED_RDONLY_DRIVER21(fileName,ptrMed),
+ MED_MED_WRONLY_DRIVER21(fileName,ptrMed),
+ IMED_MED_RDWR_DRIVER(fileName,ptrMed),
+ MED_MED_DRIVER21(fileName,ptrMed,MED_REMP),
+ IMED_MED_WRONLY_DRIVER(fileName,ptrMed),
+ IMED_MED_RDONLY_DRIVER(fileName,ptrMed),
+ MED_MED_DRIVER(fileName,ptrMed,MED_REMP)
+{}
+
+MED_MED_RDWR_DRIVER21::MED_MED_RDWR_DRIVER21(const MED_MED_RDWR_DRIVER21 & driver):
+ MED_MED_RDONLY_DRIVER21(driver),
+ MED_MED_WRONLY_DRIVER21(driver),
+ IMED_MED_RDWR_DRIVER(driver),
+ MED_MED_DRIVER21(driver),
+ IMED_MED_WRONLY_DRIVER(driver),
+ IMED_MED_RDONLY_DRIVER(driver),
+ MED_MED_DRIVER(driver)
+{}
+
+MED_MED_RDWR_DRIVER21::~MED_MED_RDWR_DRIVER21() {
+ MESSAGE("MED_MED_RDWR_DRIVER21::~MED_MED_RDWR_DRIVER21() has been destroyed");
+}
+
+GENDRIVER * MED_MED_RDWR_DRIVER21::copy(void) const
+{
+ return new MED_MED_RDWR_DRIVER21(*this) ;
+}
+
+void MED_MED_RDWR_DRIVER21::read(void)
+ throw (MEDEXCEPTION) // from MED_MED_RDONLY_DRIVER::read()
+{
+ BEGIN_OF("MED_MED_RDWR_DRIVER21::read(void)");
+ MED_MED_RDONLY_DRIVER21::read();
+ END_OF("MED_MED_RDWR_DRIVER21::read(void)");
+}
+
+void MED_MED_RDWR_DRIVER21::readFileStruct(void)
+ throw (MEDEXCEPTION) // from MED_MED_RDONLY_DRIVER::readFileStruct()
+{
+ BEGIN_OF("MED_MED_RDWR_DRIVER21::readFileStruct(void)");
+ MED_MED_RDONLY_DRIVER21::readFileStruct();
+ END_OF("MED_MED_RDWR_DRIVER21::readFileStruct(void)");
+}
+
+void MED_MED_RDWR_DRIVER21::write(void) const
+ throw (MEDEXCEPTION) // from MED_MED_WRONLY_DRIVER::write()
+{
+ BEGIN_OF("MED_MED_RDWR_DRIVER21::write(void) const");
+ MED_MED_WRONLY_DRIVER21::write();
+ END_OF("MED_MED_RDWR_DRIVER21::write(void) const");
+}
+
+void MED_MED_RDWR_DRIVER21::writeFrom(void) const
+ throw (MEDEXCEPTION) // from MED_MED_WRONLY_DRIVER::writeFrom();
+{
+ BEGIN_OF("MED_MED_RDWR_DRIVER21::writeFrom(void) const");
+ MED_MED_WRONLY_DRIVER21::writeFrom();
+ END_OF("MED_MED_RDWR_DRIVER21::writeFrom(void) const");
+}
--- /dev/null
+#ifndef MED_MED_DRIVER21_HXX
+#define MED_MED_DRIVER21_HXX
+
+#include "MEDMEM_MedMedDriver.hxx"
+#include <string>
+#include "utilities.h"
+#include "MEDMEM_Exception.hxx"
+#include "MEDMEM_GenDriver.hxx"
+#include "MEDMEM_define.hxx"
+
+/*!
+
+ Driver Med for MED.
+
+ Generic part : implement open and close methods.
+
+*/
+
+// This driver pilots within a MED class read/write accesses of fields/meshes
+namespace MEDMEM {
+class MESH;
+class FIELD_;
+class MED;
+
+class MED_MED_DRIVER21 : public virtual MED_MED_DRIVER
+{
+protected:
+
+ med_2_1::med_idt _medIdt; // The _medIdt used to write/read Meshes to ::_filename
+
+public :
+ MED_MED_DRIVER21();
+ MED_MED_DRIVER21(const string & fileName, MED * const ptrMed);
+ MED_MED_DRIVER21(const string & fileName, MED * const ptrMed,
+ MED_EN::med_mode_acces accessMode);
+ MED_MED_DRIVER21(const MED_MED_DRIVER21 & driver);
+ virtual ~MED_MED_DRIVER21();
+ void open() throw (MEDEXCEPTION) ;
+ void close();
+ virtual void write ( void ) const ;
+ virtual void writeFrom ( void ) const ;
+ virtual void read ( void ) ;
+ virtual void readFileStruct ( void ) ;
+private:
+ virtual GENDRIVER * copy ( void ) const ;
+};
+
+/*!
+
+ Driver Med for MED : Read only.
+
+ Implement read method.
+
+*/
+
+ class MED_MED_RDONLY_DRIVER21 : public virtual IMED_MED_RDONLY_DRIVER, public virtual MED_MED_DRIVER21
+{
+public :
+ MED_MED_RDONLY_DRIVER21();
+ MED_MED_RDONLY_DRIVER21(const string & fileName, MED * const ptrMed);
+ MED_MED_RDONLY_DRIVER21(const MED_MED_RDONLY_DRIVER21 & driver);
+ virtual ~MED_MED_RDONLY_DRIVER21();
+ void write ( void ) const throw (MEDEXCEPTION) ;
+ void writeFrom ( void ) const throw (MEDEXCEPTION) ;
+ void read ( void ) throw (MEDEXCEPTION);
+ void readFileStruct ( void ) throw (MEDEXCEPTION) ;
+private:
+ virtual GENDRIVER * copy ( void ) const ;
+};
+
+class MED_MED_WRONLY_DRIVER21 : public virtual IMED_MED_WRONLY_DRIVER, public virtual MED_MED_DRIVER21
+{
+
+public :
+ MED_MED_WRONLY_DRIVER21();
+ MED_MED_WRONLY_DRIVER21(const string & fileName, MED * const ptrMed);
+ MED_MED_WRONLY_DRIVER21(const MED_MED_WRONLY_DRIVER21 & driver);
+ virtual ~MED_MED_WRONLY_DRIVER21();
+ void write ( void ) const throw (MEDEXCEPTION);
+ void writeFrom ( void ) const throw (MEDEXCEPTION);
+ void read ( void ) throw (MEDEXCEPTION) ;
+ void readFileStruct ( void ) throw (MEDEXCEPTION) ;
+private:
+ virtual GENDRIVER * copy ( void ) const ;
+};
+
+class MED_MED_RDWR_DRIVER21 : public MED_MED_RDONLY_DRIVER21,
+ public MED_MED_WRONLY_DRIVER21,
+ public IMED_MED_RDWR_DRIVER
+{
+public :
+ MED_MED_RDWR_DRIVER21();
+ MED_MED_RDWR_DRIVER21(const string & fileName, MED * const ptrMed);
+ MED_MED_RDWR_DRIVER21(const MED_MED_RDWR_DRIVER21 & driver);
+ ~MED_MED_RDWR_DRIVER21();
+ void write ( void ) const throw (MEDEXCEPTION);
+ void writeFrom ( void ) const throw (MEDEXCEPTION);
+ void read ( void ) throw (MEDEXCEPTION);
+ void readFileStruct ( void ) throw (MEDEXCEPTION);
+private:
+ virtual GENDRIVER * copy ( void ) const ;
+};
+
+}
+
+#endif /* MED_MED_DRIVER21_HXX */
--- /dev/null
+#include "MEDMEM_Compatibility21_22.hxx"
+# include "MEDMEM_MedMedDriver22.hxx"
+# include "MEDMEM_MedMeshDriver.hxx"
+# include "MEDMEM_DriversDef.hxx"
+
+# include "MEDMEM_Mesh.hxx"
+# include "MEDMEM_Grid.hxx"
+# include "MEDMEM_Field.hxx"
+// EN ATTENDANT L'utilisation de MedFieldDriver.hxx ds Field.hxx
+# include "MEDMEM_MedFieldDriver.hxx"
+# include "MEDMEM_Med.hxx"
+# include "MEDMEM_define.hxx"
+
+using namespace std;
+using namespace MED_EN;
+using namespace MEDMEM;
+
+MED_MED_DRIVER22::MED_MED_DRIVER22(): _medIdt(MED_INVALID)
+{}
+
+MED_MED_DRIVER22::MED_MED_DRIVER22(const string & fileName, MED * const ptrMed):
+ MED_MED_DRIVER(fileName,ptrMed), _medIdt(MED_INVALID)
+{
+ //_ptrMed->addDriver(*this); // The specific MED driver id is set within the addDriver method.
+}
+
+MED_MED_DRIVER22::MED_MED_DRIVER22(const string & fileName,
+ MED * const ptrMed,
+ MED_EN::med_mode_acces accessMode):
+ MED_MED_DRIVER(fileName,ptrMed,accessMode), _medIdt(MED_INVALID)
+{
+}
+//REM : As t'on besoin du champ _status : _medIdt <-> _status ? Oui
+
+MED_MED_DRIVER22::MED_MED_DRIVER22(const MED_MED_DRIVER22 & driver):
+ MED_MED_DRIVER(driver), _medIdt(MED_INVALID)
+{
+}
+
+MED_MED_DRIVER22::~MED_MED_DRIVER22()
+{
+ MESSAGE("MED_MED_DRIVER22::~MED_MED_DRIVER22() has been destroyed");
+}
+
+// GENDRIVER * MED_MED_DRIVER::copy(void) const
+// {
+// return new MED_MED_DRIVER(*this) ;
+// }
+void MED_MED_DRIVER22::read()
+{
+}
+void MED_MED_DRIVER22::readFileStruct()
+{
+}
+void MED_MED_DRIVER22::write() const
+{
+}
+GENDRIVER * MED_MED_DRIVER22::copy(void) const
+{
+ return new MED_MED_DRIVER22(*this) ;
+}
+void MED_MED_DRIVER22::writeFrom() const
+{
+}
+
+
+
+void MED_MED_DRIVER22::open()
+ throw (MEDEXCEPTION)
+{
+
+ const char * LOC ="MED_MED_DRIVER22::open() : ";
+ BEGIN_OF(LOC);
+
+ // REFLECHIR SUR CE TEST PAR RAPPORT A L'OUVERTURE/FERMETURE
+// if ( _medIdt != MED_INVALID )
+// throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+// << "_medIdt is already in use, please close the file |"
+// << _fileName << "| before calling open()"
+// )
+// );
+
+// if ( _status != MED_CLOSED )
+// throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+// << "_status is 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()"
+ )
+ );
+
+ MESSAGE(LOC<<"_fileName.c_str : "<< _fileName.c_str()<<",mode : "<< _accessMode);
+
+ _medIdt = med_2_2::MEDouvrir( (const_cast <char *> (_fileName.c_str())), (med_2_2::med_mode_acces) _accessMode);
+ MESSAGE(LOC<<" _medIdt = "<<_medIdt);
+
+ if (_medIdt > 0)
+ _status=MED_OPENED;
+ else {
+ _status = MED_CLOSED;
+ _medIdt = MED_INVALID;
+ throw MED_EXCEPTION (LOCALIZED( STRING(LOC)
+ << "Can't open |" << _fileName
+ << "|, _medIdt : " << _medIdt
+ )
+ );
+ }
+
+ END_OF(LOC);
+}
+
+
+void MED_MED_DRIVER22::close()
+{
+ med_2_2::med_int err = 0;
+ const char * LOC = "MED_MED_DRIVER22::close() : ";
+
+
+// if ( _status == MED_CLOSED)
+// throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << ": the file |"
+// << _fileName << "| is already closed"
+// )
+// );
+
+// if ( _medIdt == MED_INVALID )
+// throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "_medIdt invalid, but the file |"
+// << _fileName << "| seems to be openned !"
+// )
+// );
+
+ if ( _medIdt != MED_INVALID )
+ err=med_2_2::MEDfermer(_medIdt);
+
+// if (err != MED_VALID)
+// throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "the file |"
+// << _fileName << "| couldn't be closed"
+// )
+// );
+
+ _status = MED_CLOSED;
+ _medIdt = MED_INVALID;
+
+ END_OF(LOC);
+}
+
+
+// ------------- Read Only Part --------------
+
+MED_MED_RDONLY_DRIVER22::MED_MED_RDONLY_DRIVER22()
+{
+}
+
+MED_MED_RDONLY_DRIVER22::MED_MED_RDONLY_DRIVER22(const string & fileName, MED * const ptrMed):
+ IMED_MED_RDONLY_DRIVER(fileName,ptrMed),MED_MED_DRIVER22(fileName,ptrMed,MED_EN::MED_RDONLY),MED_MED_DRIVER(fileName,ptrMed,MED_EN::MED_RDONLY)
+{
+ MESSAGE("MED_MED_RDONLY_DRIVER22::MED_MED_RDONLY_DRIVER22(const string & fileName, MED * const ptrMed) Constructeur read only");
+}
+
+MED_MED_RDONLY_DRIVER22::MED_MED_RDONLY_DRIVER22(const MED_MED_RDONLY_DRIVER22 & driver):
+ IMED_MED_RDONLY_DRIVER(driver) ,MED_MED_DRIVER22(driver),MED_MED_DRIVER(driver)
+{
+}
+
+MED_MED_RDONLY_DRIVER22::~MED_MED_RDONLY_DRIVER22()
+{
+ MESSAGE("MED_MED_RDONLY_DRIVER22::~MED_MED_RDONLY_DRIVER22() has been destroyed");
+}
+
+GENDRIVER * MED_MED_RDONLY_DRIVER22::copy(void) const
+{
+ return new MED_MED_RDONLY_DRIVER22(*this) ;
+}
+
+void MED_MED_RDONLY_DRIVER22::write ( void ) const throw (MEDEXCEPTION)
+{
+ IMED_MED_RDONLY_DRIVER::write();
+}
+
+void MED_MED_RDONLY_DRIVER22::writeFrom ( void ) const throw (MEDEXCEPTION)
+{
+ IMED_MED_RDONLY_DRIVER::writeFrom();
+}
+
+void MED_MED_RDONLY_DRIVER22::readFileStruct( void )
+ throw (MEDEXCEPTION)
+{
+ const char * LOC = "MED_MED_DRIVER22::readFileStruct() : ";
+ int err,i,j;
+
+ BEGIN_OF(LOC);
+
+ if ( _medIdt == MED_INVALID )
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+ << "_medIdt is invalid, please open the file |"
+ << _fileName << "| before calling readFileStruct()"
+ )
+ );
+ // Read number of meshes and their associated name
+ {
+ int numberOfMeshes;
+ char meshName[MED_TAILLE_NOM+1]="";
+ char meshDescription[MED_TAILLE_DESC+1]="";
+ int meshDim;
+ med_2_2::med_maillage meshType;
+
+ MESH * ptrMesh;
+ // MED_MESH_RDWR_DRIVER * ptrDriver; !! UNUSED VARIABLE !!
+
+ numberOfMeshes = med_2_2::MEDnMaa(_medIdt) ;
+ if ( numberOfMeshes <= 0 )
+ MESSAGE(LOC << "Be careful there is no mesh in file |"<<_fileName<<"| !");
+
+ MESH_ENTITIES::const_iterator currentEntity;
+ for (i=1;i<=numberOfMeshes;i++)
+ {
+ //get infoamation on the i^th mesh
+
+ err = MEDmaaInfo(_medIdt, i ,meshName, &meshDim, &meshType,
+ meshDescription) ;
+
+ if (err != MED_VALID)
+ throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << ": can't get information about the mesh n°" << i << " of the file |" << _fileName << "| !"));
+
+ switch (meshType)
+ {
+ case med_2_2::MED_STRUCTURE:
+ MESSAGE(LOC<<": Mesh n°"<< i <<" nammed "<< meshName << " with the description " << meshDescription << " is structured");
+
+ med_2_2::med_type_grille type;
+
+ err = MEDnatureGrilleLire(_medIdt, meshName, &type);
+
+ if (err != MED_VALID)
+ throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << ": can't get the nature of the grid which is the mesh n°" << i << " of the file |" << _fileName << "| !"));
+
+ ptrMesh = new GRID((MED_EN::med_grid_type) type);
+ break;
+ case med_2_2::MED_NON_STRUCTURE:
+ MESSAGE(LOC<<": Mesh n°"<< i <<" nammed "<< meshName << " with the description " << meshDescription << " is not structured");
+
+ ptrMesh = new MESH();
+ break;
+ default:
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Bad file mesh type !"));
+ }
+
+ bool isAGrid = ptrMesh->getIsAGrid();
+
+
+ MED_EN::med_mode_acces myMode = getAccessMode();
+// MED_MESH_DRIVER * ptrDriver ;
+// switch (myMode) {
+// case MED_EN::MED_LECT: // V2_1->V2_2
+// ptrDriver = new MED_MESH_RDONLY_DRIVER(_fileName, ptrMesh);
+// break ;
+// case MED_EN::MED_REMP: // V2_1->V2_2
+// ptrDriver = new MED_MESH_RDWR_DRIVER(_fileName, ptrMesh);
+// break ;
+// case MED_EN::MED_ECRI: // should never append !! V2_1->V2_2
+// ptrDriver = new MED_MESH_WRONLY_DRIVER(_fileName, ptrMesh);
+// break;
+// default:
+// throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Bad file mode access !"));
+// }
+
+ GENDRIVER * ptrDriver =
+ DRIVERFACTORY::buildConcreteMedDriverForMesh(_fileName, ptrMesh,
+ meshName, myMode, V22);
+
+ ptrDriver->setId ( getId() );
+ ptrDriver->setMeshName ( meshName );
+ ptrMesh->addDriver(*ptrDriver);
+ delete ptrDriver ;
+
+ if (isAGrid)
+ _ptrMed->_meshes[meshName] = (MESH *) ptrMesh;
+ else
+ _ptrMed->_meshes[meshName] = ptrMesh;
+
+ // _ptrMed->_meshes[meshName] = ptrMesh;
+
+ ptrMesh->setName(meshName);
+
+ ptrMesh->setDescription(meshDescription);
+
+ SCRUTE(ptrMesh);
+
+ MESSAGE(LOC<<"is" << (isAGrid ? "" : " NOT") << " a GRID and its name is "<<ptrMesh->getName());
+
+ // we create all global support (for each entity type :
+ int index = 0;
+ for (currentEntity=meshEntities.begin();currentEntity != meshEntities.end(); currentEntity++) {
+ string supportName="SupportOnAll_" ;
+ supportName+=entNames[(MED_EN::medEntityMesh)(*currentEntity).first] ;
+ SUPPORT* mySupport = new SUPPORT() ;
+ mySupport->setName(supportName);
+ mySupport->setMesh(ptrMesh);
+ mySupport->setEntity((MED_EN::medEntityMesh) (*currentEntity).first);
+ mySupport->setAll(true);
+ (_ptrMed->_support)[meshName][(MED_EN::medEntityMesh)(*currentEntity).first] = mySupport ;
+ MESSAGE(LOC<< "The support " << supportName.c_str() << " on entity " << (*currentEntity).first << " is built");
+ index++;
+ }
+ MESSAGE(LOC <<"The mesh " <<ptrMesh->getName() << " has " << index << " support(s)");
+ }
+
+ map<MESH_NAME_, map<MED_EN::medEntityMesh,SUPPORT *> >::iterator itSupportOnMesh ;
+
+ int index = 0;
+
+ vector<SUPPORT *> vectSupp;
+ for (itSupportOnMesh=_ptrMed->_support.begin();
+ itSupportOnMesh != _ptrMed->_support.end();
+ itSupportOnMesh++ )
+ {
+ map<MED_EN::medEntityMesh,SUPPORT *>::iterator itSupport ;
+ for (itSupport=(*itSupportOnMesh).second.begin();
+ itSupport!=(*itSupportOnMesh).second.end();
+ itSupport++)
+ {
+ index++;
+ }
+ }
+
+ MESSAGE(LOC << "In this MED object there is(are) " << index << " support(s):");
+
+ vectSupp.resize(index);
+
+ map<MESH_NAME_, map<MED_EN::medEntityMesh,SUPPORT *> >::const_iterator const_itSupportOnMesh ;
+
+ index = 0;
+ for (const_itSupportOnMesh=_ptrMed->_support.begin(); const_itSupportOnMesh != _ptrMed->_support.end();
+ const_itSupportOnMesh++ )
+ {
+ map<MED_EN::medEntityMesh,SUPPORT *>::const_iterator const_itSupport ;
+ for (const_itSupport=(*const_itSupportOnMesh).second.begin();
+ const_itSupport!=(*const_itSupportOnMesh).second.end();const_itSupport++)
+ {
+ vectSupp[index] = (*const_itSupport).second;
+ SCRUTE(vectSupp[index]);
+ MESSAGE(LOC << "Support number " << index << " is "<< *vectSupp[index]);
+ index++;
+ }
+ }
+
+ }
+
+
+ // Read number of fields, their associated name and their list of (timeStepNumber,iterationNumber)
+ {
+ int numberOfFields = 0; //MED_INVALID
+ // char fieldName[MED_TAILLE_NOM+1] = "";
+ char fieldName[MED_TAILLE_NOM+1] ;
+ int numberOfComponents = 0;
+ char * componentName = (char *) MED_NULL;
+ char * unitName = (char *) MED_NULL;
+ // char meshName[MED_TAILLE_NOM+1] = "";
+ char meshName[MED_TAILLE_NOM+1] ;
+ med_2_2::med_type_champ type;
+ MESH * ptrMesh = (MESH *) MED_NULL;
+ FIELD_ * ptrField = (FIELD_ *) MED_NULL;
+ //MED_FIELD_RDWR_DRIVER * ptrDriver = (MED_FIELD_RDWR_DRIVER * ) MED_NULL;
+ GENDRIVER * ptrDriver = (GENDRIVER * ) MED_NULL;
+ SUPPORT * ptrSupport = (SUPPORT * ) MED_NULL;
+ MESH_ENTITIES::const_iterator currentEntity;
+ list<MED_EN::medGeometryElement>::const_iterator currentGeometry;
+ med_2_2::med_int NbOfGaussPts = 0;
+ int numberOfTimeSteps = -1;
+ med_2_2::med_int timeStepNumber = -1;
+ // char timeStepUnit[MED_TAILLE_PNOM]= "";
+ char timeStepUnit[MED_TAILLE_PNOM22+1] ;
+ double timeStep = 0.0;
+ int orderNumber = -1; //???init?????
+ int numberOfRefMesh = 0;
+ med_2_2::med_booleen meshLink;
+ map<MESH_NAME_,MESH*> & _meshes = _ptrMed->_meshes;
+ map<FIELD_NAME_,MAP_DT_IT_> & _fields = _ptrMed->_fields;
+ map<FIELD_ *, MESH_NAME_> & _meshName = _ptrMed->_meshName;
+ map<MESH_NAME_, map<MED_EN::medEntityMesh,SUPPORT *> > & support = _ptrMed->_support;
+
+ numberOfFields = med_2_2::MEDnChamp(_medIdt,0) ;
+ if ( numberOfFields <= 0 )
+ MESSAGE(LOC << "Be careful there is no field in file |"<<
+ _fileName<<"| !");
+
+ for (i=1;i<=numberOfFields;i++)
+ {
+ numberOfComponents = med_2_2::MEDnChamp(_medIdt,i) ;
+
+ if ( numberOfComponents <= 0 )
+ if (err != MED_VALID)
+ throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << "Be careful there is no compound for field n°" << i << "in file |"<<_fileName<<"| !"));
+
+ componentName = new char[numberOfComponents*MED_TAILLE_PNOM22+1] ;
+ unitName = new char[numberOfComponents*MED_TAILLE_PNOM22+1] ;
+
+ err = MEDchampInfo(_medIdt, i, fieldName, &type, componentName,
+ unitName, numberOfComponents) ;
+
+ if (err != MED_VALID)
+ throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << ": can't get information about the field n°" << i <<" of the file |" << _fileName << "| !"));
+
+ MESSAGE(LOC << "Field n°"<<i<<" nammed "<< fieldName
+ << " ,component(s) : " << componentName
+ <<" ,unit(s) : " << unitName);
+
+ // Loop on all (entity type,geometry type) until you find an existing
+ // one then get the (n°dt,n°it) pairs list for the current
+ // (field,entity type,geometry type) We suppose there is the same list
+ // whatever the existing (entity type,geometry type) pair
+
+ // support map :
+
+ for (currentEntity=meshEntities.begin();currentEntity != meshEntities.end(); currentEntity++)
+ {
+ // numberOfTimeSteps MUST be given by MEDchampInfo !!!!!
+ for (currentGeometry = (*currentEntity).second.begin();
+ currentGeometry != (*currentEntity).second.end();
+ currentGeometry++)
+ {
+ MESSAGE("Field information with Entity,Geom = "<<
+ (*currentEntity).first<<","<<(*currentGeometry));
+
+ numberOfTimeSteps =
+ MEDnPasdetemps(_medIdt, fieldName,
+ (med_2_2::med_entite_maillage)(*currentEntity).first,
+ (med_2_2::med_geometrie_element) (*currentGeometry) );
+
+ MESSAGE("Field information 2 : NumberOfTimeStep :"<<
+ numberOfTimeSteps);
+
+ if ( numberOfTimeSteps > MED_VALID )
+ break ;
+ // There are value for some med_geometrie_element of this
+ // med_entite_maillage.
+ }
+ if (numberOfTimeSteps>0) // we have at least one
+
+ for (currentGeometry = (*currentEntity).second.begin();
+ currentGeometry != (*currentEntity).second.end();
+ currentGeometry++)
+ {
+ MESSAGE("Field information 3 : Geom : "<<(*currentGeometry));
+
+ for (j=1;j <= numberOfTimeSteps; j++)
+ {
+ MESSAGE("Field information 4 : time step j = "<<j);
+
+ // err = MEDpasdetempsInfo( _medIdt, fieldName,
+ // (med_2_2::med_entite_maillage) (*currentEntity).first,
+ // (*currentGeometry),j, meshName,
+ // &NbOfGaussPts, &timeStepNumber,
+ // timeStepUnit, &timeStep, &orderNumber);
+
+ err = MEDpasdetempsInfo(_medIdt, fieldName,
+ (med_2_2::med_entite_maillage)
+ (*currentEntity).first,
+ (med_2_2::med_geometrie_element)
+ (*currentGeometry),j,
+ &NbOfGaussPts, &timeStepNumber,
+ &orderNumber, timeStepUnit,
+ &timeStep, meshName, &meshLink,
+ &numberOfRefMesh);
+
+ if (err == MED_VALID)
+ { // we have found for (*currentEntity).first and
+ // (*currentGeometry)
+ MESSAGE("Field information 5 ;: NumberOfGaussPoint : " << NbOfGaussPts << ", timeStepNumber : " << timeStepNumber << ", orderNumber : " << orderNumber);
+ // CORRECT a bug in MEDpasdetempsInfo :
+ // we get a value n'importe quoi in NbOfGaussPts !!!!
+
+ if (timeStepNumber<0) timeStepNumber=-1 ;
+ if ((numberOfRefMesh != 1) ||
+ (meshLink != med_2_2::MED_VRAI) ||
+ (NbOfGaussPts != 1))
+ {
+ NbOfGaussPts = 1;
+ numberOfRefMesh=1;
+ MESSAGE("This field is Med Memory compliant because NumberOfGaussPoint : " << NbOfGaussPts << ", or numberOfRefMesh : " << numberOfRefMesh << ", or meshLink : " << meshLink);
+ }
+
+ // ATTENTION TRAITER L'EXCEPTION CI DESSUS !!!!!!!!
+
+ // Il faudra traiter le cas d'un champ qui utilise
+ // +sieurs (entity,geom) voir le travail de patrick
+ // Il faudra traiter le cas des profils...
+ // ptrField = new FIELD();
+ // _ptrDriver = new MED_FIELD_RDWR_DRIVER(_fileName,
+ // ptrField);
+ // ptrField->addDriver(_ptrDriver);
+ // _fields[fieldName]=ptrField;
+
+ map<MESH_NAME_,MESH*>::iterator _meshesIt =
+ _meshes.find(meshName);
+
+ if ( _meshesIt == _meshes.end() ) {
+ MESSAGE(LOC << "There is no mesh |" << meshName <<
+ "| in the file |" << _fileName <<
+ "|, but |" << meshName <<
+ "| is referenced by field |" <<
+ fieldName <<"|, entity : |" <<
+ entNames[ (med_2_2::med_entite_maillage)
+ (*currentEntity).first] <<
+ "|, geometric element of type |" <<
+ geoNames [(*currentGeometry)] <<"|");
+ }
+ // POURQUOI SI JE NE MET PAS DE BLOCK J'AI UN PARSE
+ // ERROR : PG : c'est la macro MESSAGE qui fait ca !
+ else
+ ptrMesh = _meshes[meshName];
+
+ ptrSupport = support[meshName][(MED_EN::medEntityMesh) (*currentEntity).first];
+ if (NbOfGaussPts != 1)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Number of Gauss Point must be equal to 1 for instance")) ;
+
+ // init to null to prevent some error if not
+ // correctly allocated !
+
+ ptrField = (FIELD_*)NULL ;
+ ptrDriver = (GENDRIVER*)NULL ;
+
+ switch ( type) {
+ case med_2_2::MED_INT64 :
+ if ( sizeof(med_2_2::med_int) != 8 )
+ throw MED_EXCEPTION(LOCALIZED(STRING(LOC) <<" The Field type of |" << fieldName <<"|, entity : |" << entNames[(med_2_2::med_entite_maillage) (*currentEntity).first] <<"|, geometric element of type |" << geoNames [(*currentGeometry)] << "| is MED_INT64 but size of med_int is not equal to 8 bytes !"));
+ break;
+ case med_2_2::MED_INT32 : {
+ ptrField = new FIELD<int> ( );
+ // Les valeurs du champ ne doivent pas être lue
+ // pour l'instant
+ ((FIELD<int>*)
+ ptrField)->setSupport(ptrSupport);
+ ((FIELD<int>*)
+ ptrField)->setNumberOfComponents(numberOfComponents);
+ ((FIELD<int>*)
+ ptrField)->setName(fieldName) ;
+ //provisoire, pour debug
+ MESSAGE("#### SET NAME in FIELD : "<<fieldName);
+
+ MED_EN::med_mode_acces myMode = getAccessMode();
+// switch (myMode) {
+// case MED_EN::MED_LECT: // V2_1->V2_2
+// ptrDriver = new
+// MED_FIELD_RDONLY_DRIVER<int>
+// (_fileName, (FIELD<int> *)
+// ptrField);
+// break ;
+// case MED_EN::MED_REMP: // V2_1->V2_2
+// ptrDriver = new
+// MED_FIELD_RDWR_DRIVER<int>
+// (_fileName, (FIELD<int> *)
+// ptrField);
+// break ;
+// case MED_EN::MED_ECRI: // should never append !! V2_1->V2_2
+// ptrDriver = new
+// MED_FIELD_WRONLY_DRIVER<int>
+// (_fileName, (FIELD<int> *)
+// ptrField);
+// break;
+// default:
+// throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Bad file mode access !"));
+// }
+
+ ptrDriver = DRIVERFACTORY::buildConcreteMedDriverForField<int>(_fileName, (FIELD<int> *)ptrField, myMode, V22);
+
+ SCRUTE(ptrDriver);
+
+
+ break;
+ }
+ case MED_EN::MED_REEL64 : {
+ ptrField = new FIELD<double> ( );
+ // Les valeurs du champ ne doivent pas être lue
+ // pour l'instant
+ ((FIELD<double>*)
+ ptrField)->setSupport(ptrSupport);
+ ((FIELD<double>*)
+ ptrField)->setNumberOfComponents(numberOfComponents);
+ ((FIELD<double>*)
+ ptrField)->setName(fieldName) ;
+ //provisoire, pour debug
+ MESSAGE("#### SET NAME in FIELD : "<<fieldName);
+
+ MED_EN::med_mode_acces myMode = getAccessMode();
+// switch (myMode) {
+// case MED_EN::MED_LECT: // V2_1->V2_2
+// ptrDriver = new
+// MED_FIELD_RDONLY_DRIVER<double>
+// (_fileName, (FIELD<double> *)
+// ptrField);
+// break ;
+// case MED_EN::MED_REMP: // V2_1->V2_2
+// ptrDriver = new
+// MED_FIELD_RDWR_DRIVER<double>
+// (_fileName, (FIELD<double> *)
+// ptrField);
+// break ;
+// case MED_EN::MED_ECRI: // should never append !! V2_1->V2_2
+// ptrDriver = new
+// MED_FIELD_WRONLY_DRIVER<double>
+// (_fileName, (FIELD<double> *)
+// ptrField);
+// break;
+// default:
+// throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Bad file mode access !"));
+// }
+
+ ptrDriver = DRIVERFACTORY::buildConcreteMedDriverForField<double>(_fileName, (FIELD<double> *)ptrField, myMode, V22);
+ SCRUTE(ptrDriver);
+
+ break;
+ }
+ default : {
+ if ( numberOfTimeSteps > 1)
+ throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << " The Field type of |" << fieldName <<"|, entity : |" << entNames[(med_2_2::med_entite_maillage) (*currentEntity).first] <<"|, geometric element of type |" << geoNames [(*currentGeometry)] <<"| is neither MED_INT, MED_INT32, MED_INT64 nor MED_REEL64 !"));
+ break ;
+ }
+ }
+ ptrField->setValueType((MED_EN::med_type_champ)
+ type) ;
+ // need to write field !
+
+ MESSAGE("timeStepNumber :"<<timeStepNumber<<
+ ",orderNumber :"<<orderNumber);
+ ptrField->setIterationNumber ( timeStepNumber);
+ // A ajouter dans la classe FIELD
+ ptrField->setOrderNumber ( orderNumber);
+ ptrField->setTime ( timeStep);
+
+ // Create a driver for this (field n°dt,n°it)
+ ptrDriver->setId ( getId() );
+ MESSAGE("###### ptrDriver->setFieldName : #"<<
+ fieldName<<"#");
+ ptrDriver->setFieldName(fieldName);
+ ptrField->addDriver(*ptrDriver);
+ // driver is duplicated : remove it
+ delete ptrDriver;
+
+ DT_IT_ dtIt;
+ dtIt.dt = timeStepNumber;
+ dtIt.it = orderNumber;
+
+ (_fields [fieldName])[dtIt] = ptrField;
+ _meshName[ptrField ] = meshName;
+ }
+ }
+ }
+ }
+ delete[] componentName ;
+ delete[] unitName ;
+ }
+ }
+
+ // read profil count and their names
+ // int support_count_= 0 ; !! UNUSED VARIABLE !!
+ // il faut lire les champs pour avoir les profils stockes !!!
+ // il faudrait implémenter la lecture des profils dans med !!!
+
+ END_OF(LOC);
+
+}
+
+// This method ask the drivers of all MESH/FIELD objects created from this MED driver
+// to read themselves
+void MED_MED_RDONLY_DRIVER22::read( void )
+ throw (MEDEXCEPTION) // from objects method read !
+{
+ const char * LOC = "MED_MED_DRIVER22::read() : ";
+
+ BEGIN_OF(LOC);
+
+ const map<MESH_NAME_, MESH*> & _meshes = const_cast<const map<MESH_NAME_, MESH*>& > (_ptrMed->_meshes);
+ map<MESH_NAME_,MESH*>::const_iterator currentMesh;
+
+ const map<FIELD_ *, MESH_NAME_> & _meshName = const_cast<const map<FIELD_ *, MESH_NAME_>& > (_ptrMed->_meshName);
+ map<FIELD_ *, MESH_NAME_>::const_iterator currentField;
+
+ for ( currentMesh=_meshes.begin();currentMesh != _meshes.end(); currentMesh++ )
+ (*currentMesh).second->read(*this);
+ //(*currentMesh).second->read(); // default reader, from readFileStruct
+
+ // PROVISOIRE
+ _ptrMed->updateSupport() ;
+
+ for ( currentField =_meshName.begin(); currentField != _meshName.end(); currentField++ )
+ (*currentField).first->read(*this);
+ //(*currentField).first->read(); // default reader, from readFileStruct
+
+ END_OF(LOC);
+}
+
+// ------------- Write Only Part --------------
+
+MED_MED_WRONLY_DRIVER22::MED_MED_WRONLY_DRIVER22()
+{
+}
+
+MED_MED_WRONLY_DRIVER22::MED_MED_WRONLY_DRIVER22(const string & fileName, MED * const ptrMed):
+ IMED_MED_WRONLY_DRIVER(fileName,ptrMed),MED_MED_DRIVER22(fileName,ptrMed),MED_MED_DRIVER(fileName,ptrMed,MED_EN::MED_WRONLY)
+{}
+
+MED_MED_WRONLY_DRIVER22::MED_MED_WRONLY_DRIVER22(const MED_MED_WRONLY_DRIVER22 & driver):
+ IMED_MED_WRONLY_DRIVER(driver),MED_MED_DRIVER(driver),MED_MED_DRIVER22(driver)
+{}
+
+MED_MED_WRONLY_DRIVER22::~MED_MED_WRONLY_DRIVER22()
+{
+ MESSAGE("MED_MED_WRONLY_DRIVER22::~MED_MED_WRONLY_DRIVER22() has been destroyed");
+}
+
+GENDRIVER * MED_MED_WRONLY_DRIVER22::copy(void) const
+{
+ return new MED_MED_WRONLY_DRIVER22(*this) ;
+}
+
+void MED_MED_WRONLY_DRIVER22::read(void)
+ throw (MEDEXCEPTION)
+{
+ IMED_MED_WRONLY_DRIVER::read();
+}
+
+void MED_MED_WRONLY_DRIVER22::readFileStruct(void)
+ throw (MEDEXCEPTION)
+{
+ IMED_MED_WRONLY_DRIVER::readFileStruct();
+}
+
+// This method ask the drivers of all MESH/FIELD objects created from this MED driver
+// to write themselves
+void MED_MED_WRONLY_DRIVER22::writeFrom( void) const
+ throw (MEDEXCEPTION) //from object method write !
+{
+ const char * LOC = "MED_MED_DRIVER22::writeFrom() : ";
+
+ BEGIN_OF(LOC);
+
+ const map<MESH_NAME_, MESH*> & _meshes = const_cast<const map<MESH_NAME_, MESH*>& > (_ptrMed->_meshes);
+ map<MESH_NAME_,MESH*>::const_iterator currentMesh;
+
+ const map<FIELD_ *, MESH_NAME_> & _meshName = const_cast<const map<FIELD_ *, MESH_NAME_>& > (_ptrMed->_meshName);
+ map<FIELD_ *, MESH_NAME_>::const_iterator currentField;
+
+ for ( currentMesh=_meshes.begin();currentMesh != _meshes.end(); currentMesh++ ) {
+ try {
+ (*currentMesh).second->write(*this);
+ // On utilise pour les objects MESH ET FIELD le write(GENDRIVER *) et le == ds GENDRIVER avec eventuellement 1 id
+ }
+ catch ( const MED_DRIVER_NOT_FOUND_EXCEPTION & ex ) {
+ continue;
+ }
+ }
+
+ for ( currentField=_meshName.begin();currentField != _meshName.end(); currentField++ ) {
+ try {
+ (*currentField).first->write(*this);
+ }
+ catch ( const MED_DRIVER_NOT_FOUND_EXCEPTION & ex ) {
+ continue;
+ }
+ }
+
+ END_OF(LOC);
+
+}
+
+void MED_MED_WRONLY_DRIVER22::write(void ) const
+ throw (MEDEXCEPTION) // from object method write !
+{
+ const char * LOC = "MED_MED_DRIVER22::write() : ";
+ int current;
+
+ BEGIN_OF(LOC);
+
+ // BCLE SUR LES OBJETS AVEC AJOUT DE DRIVER ET APPELS write
+
+ const map<MESH_NAME_, MESH*> & _meshes = const_cast<const map<MESH_NAME_, MESH*>& > (_ptrMed->_meshes);
+ map<MESH_NAME_,MESH*>::const_iterator currentMesh;
+
+ const map<FIELD_ *, MESH_NAME_> & _meshName = const_cast<const map<FIELD_ *, MESH_NAME_>& > (_ptrMed->_meshName);
+ map<FIELD_ *, MESH_NAME_>::const_iterator currentField;
+
+ for ( currentMesh=_meshes.begin();currentMesh != _meshes.end(); currentMesh++ ) {
+ //current = (*currentMesh).second->addDriver(MED_DRIVER,_fileName);
+ current = (*currentMesh).second->addDriver(MED_DRIVER,_fileName,(*currentMesh).second->getName());
+ // put right _id in Mesh driver (same as this._id)
+ (*currentMesh).second->_drivers[current]->setId( getId() );
+ //(*currentMesh).second->write(current) ;
+ }
+
+ for ( currentField=_meshName.begin();currentField != _meshName.end(); currentField++ ) {
+ //current = (*currentField).first->addDriver(MED_DRIVER,_fileName);
+ current = (*currentField).first->addDriver(MED_DRIVER,_fileName,(*currentField).first->getName());
+ // put right _id in Field driver (same as this._id)
+ (*currentField).first->_drivers[current]->setId( getId() );
+ //(*currentField).first->write(current) ;
+ }
+
+ // that's work, but it is more efficenty to write directly when we had driver, no ?
+ writeFrom();
+
+ END_OF(LOC);
+
+}
+
+// ------------- Read Write Part --------------
+
+MED_MED_RDWR_DRIVER22::MED_MED_RDWR_DRIVER22()
+{}
+
+MED_MED_RDWR_DRIVER22::MED_MED_RDWR_DRIVER22(const string & fileName, MED * const ptrMed):
+ MED_MED_RDONLY_DRIVER22(fileName,ptrMed),
+ MED_MED_WRONLY_DRIVER22(fileName,ptrMed),
+ IMED_MED_RDWR_DRIVER(fileName,ptrMed),
+ MED_MED_DRIVER22(fileName,ptrMed,MED_REMP),
+ IMED_MED_WRONLY_DRIVER(fileName,ptrMed),
+ IMED_MED_RDONLY_DRIVER(fileName,ptrMed),
+ MED_MED_DRIVER(fileName,ptrMed,MED_REMP)
+{}
+
+MED_MED_RDWR_DRIVER22::MED_MED_RDWR_DRIVER22(const MED_MED_RDWR_DRIVER22 & driver):
+ MED_MED_RDONLY_DRIVER22(driver),
+ MED_MED_WRONLY_DRIVER22(driver),
+ IMED_MED_RDWR_DRIVER(driver),
+ MED_MED_DRIVER22(driver),
+ IMED_MED_WRONLY_DRIVER(driver),
+ IMED_MED_RDONLY_DRIVER(driver),
+ MED_MED_DRIVER(driver)
+{}
+
+MED_MED_RDWR_DRIVER22::~MED_MED_RDWR_DRIVER22() {
+ MESSAGE("MED_MED_RDWR_DRIVER22::~MED_MED_RDWR_DRIVER22() has been destroyed");
+}
+
+GENDRIVER * MED_MED_RDWR_DRIVER22::copy(void) const
+{
+ return new MED_MED_RDWR_DRIVER22(*this) ;
+}
+
+void MED_MED_RDWR_DRIVER22::read(void)
+ throw (MEDEXCEPTION) // from MED_MED_RDONLY_DRIVER::read()
+{
+ BEGIN_OF("MED_MED_RDWR_DRIVER22::read(void)");
+ MED_MED_RDONLY_DRIVER22::read();
+ END_OF("MED_MED_RDWR_DRIVER22::read(void)");
+}
+
+void MED_MED_RDWR_DRIVER22::readFileStruct(void)
+ throw (MEDEXCEPTION) // from MED_MED_RDONLY_DRIVER::readFileStruct()
+{
+ BEGIN_OF("MED_MED_RDWR_DRIVER22::readFileStruct(void)");
+ MED_MED_RDONLY_DRIVER22::readFileStruct();
+ END_OF("MED_MED_RDWR_DRIVER22::readFileStruct(void)");
+}
+
+void MED_MED_RDWR_DRIVER22::write(void) const
+ throw (MEDEXCEPTION) // from MED_MED_WRONLY_DRIVER::write()
+{
+ BEGIN_OF("MED_MED_RDWR_DRIVER22::write(void) const");
+ MED_MED_WRONLY_DRIVER22::write();
+ END_OF("MED_MED_RDWR_DRIVER22::write(void) const");
+}
+
+void MED_MED_RDWR_DRIVER22::writeFrom(void) const
+ throw (MEDEXCEPTION) // from MED_MED_WRONLY_DRIVER::writeFrom();
+{
+ BEGIN_OF("MED_MED_RDWR_DRIVER22::writeFrom(void) const");
+ MED_MED_WRONLY_DRIVER22::writeFrom();
+ END_OF("MED_MED_RDWR_DRIVER22::writeFrom(void) const");
+}
--- /dev/null
+#ifndef MED_MED_DRIVER22_HXX
+#define MED_MED_DRIVER22_HXX
+
+#include "MEDMEM_MedMedDriver.hxx"
+#include <string>
+#include "utilities.h"
+#include "MEDMEM_Exception.hxx"
+#include "MEDMEM_GenDriver.hxx"
+#include "MEDMEM_define.hxx"
+
+/*!
+
+ Driver Med for MED.
+
+ Generic part : implement open and close methods.
+
+*/
+
+// This driver pilots within a MED class read/write accesses of fields/meshes
+namespace MEDMEM {
+class MESH;
+class FIELD_;
+class MED;
+
+class MED_MED_DRIVER22 : public virtual MED_MED_DRIVER
+{
+protected:
+
+ med_2_2::med_idt _medIdt; // The _medIdt used to write/read Meshes to ::_filename
+
+ //private:
+ // MED_MED_DRIVER();
+
+public :
+ /*!
+ Constructor.
+ */
+ MED_MED_DRIVER22();
+ /*!
+ Constructor.
+ */
+ MED_MED_DRIVER22(const string & fileName, MED * const ptrMed);
+ /*!
+ Constructor.
+ */
+ MED_MED_DRIVER22(const string & fileName, MED * const ptrMed,
+ MED_EN::med_mode_acces accessMode);
+
+ // OPERATEUR DE RECOPIE AVEC _medIdt ??
+ /*!
+ Copy constructor.
+ */
+ MED_MED_DRIVER22(const MED_MED_DRIVER22 & driver);
+
+ /*!
+ Destructor.
+ */
+ virtual ~MED_MED_DRIVER22() ;
+
+ void open() throw (MEDEXCEPTION) ;
+ void close();
+
+ //virtual void write ( void ) const = 0 ;
+ virtual void write ( void ) const ;
+ //virtual void writeFrom ( void ) const = 0 ;
+ virtual void writeFrom ( void ) const ;
+ //virtual void read ( void ) = 0 ;
+ virtual void read ( void ) ;
+ //virtual void readFileStruct ( void ) = 0 ;
+ virtual void readFileStruct ( void ) ;
+
+private:
+ //virtual GENDRIVER * copy ( void ) const = 0 ;
+ virtual GENDRIVER * copy ( void ) const ;
+
+};
+
+/*!
+
+ Driver Med for MED : Read only.
+
+ Implement read method.
+
+*/
+
+ class MED_MED_RDONLY_DRIVER22 : public virtual IMED_MED_RDONLY_DRIVER, public virtual MED_MED_DRIVER22
+{
+public :
+ /*!
+ Constructor.
+ */
+ MED_MED_RDONLY_DRIVER22();
+ /*!
+ Constructor.
+ */
+ MED_MED_RDONLY_DRIVER22(const string & fileName, MED * const ptrMed);
+ /*!
+ Copy constructor.
+ */
+ MED_MED_RDONLY_DRIVER22(const MED_MED_RDONLY_DRIVER22 & driver);
+
+ /*!
+ Destructor.
+ */
+ virtual ~MED_MED_RDONLY_DRIVER22();
+
+ /*!
+ Return a MEDEXCEPTION : it is the read-only driver.
+ */
+ void write ( void ) const throw (MEDEXCEPTION) ;
+ /*!
+ Return a MEDEXCEPTION : it is the read-only driver.
+ */
+ void writeFrom ( void ) const throw (MEDEXCEPTION) ;
+ /*!
+ Read all from the file.
+ */
+ void read ( void ) throw (MEDEXCEPTION);
+ /*!
+ Read only table of contents of the file.
+
+ All objects are created but there values are not read.
+ */
+ void readFileStruct ( void ) throw (MEDEXCEPTION) ;
+
+private:
+ virtual GENDRIVER * copy ( void ) const ;
+
+};
+
+/*!
+
+ Driver Med for MED : Write only.
+
+ Implement write method.
+
+*/
+
+class MED_MED_WRONLY_DRIVER22 : public virtual IMED_MED_WRONLY_DRIVER, public virtual MED_MED_DRIVER22
+{
+
+public :
+ /*!
+ Constructor.
+ */
+ MED_MED_WRONLY_DRIVER22();
+ /*!
+ Constructor.
+ */
+ MED_MED_WRONLY_DRIVER22(const string & fileName, MED * const ptrMed);
+ /*!
+ Copy constructor.
+ */
+ MED_MED_WRONLY_DRIVER22(const MED_MED_WRONLY_DRIVER22 & driver);
+
+ /*!
+ Destructor.
+ */
+ virtual ~MED_MED_WRONLY_DRIVER22();
+
+ /*!
+ Write all in file.
+ */
+ void write ( void ) const throw (MEDEXCEPTION);
+ /*!
+ Write only objects created from this MED driver in file.
+ */
+ void writeFrom ( void ) const throw (MEDEXCEPTION);
+ /*!
+ Return a MEDEXCEPTION : it is the write-only driver.
+ */
+ void read ( void ) throw (MEDEXCEPTION) ;
+ /*!
+ Return a MEDEXCEPTION : it is the write-only driver.
+ */
+ void readFileStruct ( void ) throw (MEDEXCEPTION) ;
+
+private:
+ virtual GENDRIVER * copy ( void ) const ;
+
+};
+
+/*!
+
+ Driver Med for MED : Read write.
+ - Use read method from MED_MED_RDONLY_DRIVER
+ - Use write method from MED_MED_WDONLY_DRIVER
+
+*/
+
+class MED_MED_RDWR_DRIVER22 : public virtual MED_MED_RDONLY_DRIVER22,
+ public virtual MED_MED_WRONLY_DRIVER22,
+ public virtual IMED_MED_RDWR_DRIVER
+{
+
+public :
+ /*!
+ Constructor.
+ */
+ MED_MED_RDWR_DRIVER22();
+ /*!
+ Constructor.
+ */
+ MED_MED_RDWR_DRIVER22(const string & fileName, MED * const ptrMed);
+ /*!
+ Copy constructor.
+ */
+ MED_MED_RDWR_DRIVER22(const MED_MED_RDWR_DRIVER22 & driver);
+
+ /*!
+ Destructor.
+ */
+ ~MED_MED_RDWR_DRIVER22();
+
+ /*!
+ Write all in file.
+ */
+ void write ( void ) const throw (MEDEXCEPTION);
+ /*!
+ Write only objects created from this MED driver in file.
+ */
+ void writeFrom ( void ) const throw (MEDEXCEPTION);
+ /*!
+ Read all from the file.
+ */
+ void read ( void ) throw (MEDEXCEPTION);
+ /*!
+ Read only table of contents of the file.
+
+ All objects are created but there values are not read.
+ */
+ void readFileStruct ( void ) throw (MEDEXCEPTION);
+
+private:
+ virtual GENDRIVER * copy ( void ) const ;
+
+};
+};
+
+#endif /* MED_MED_DRIVER22_HXX */
#include "MEDMEM_MedMeshDriver.hxx"
-
+#include "MEDMEM_MedMeshDriver21.hxx"
+#include "MEDMEM_DriverFactory.hxx"
#include "MEDMEM_DriversDef.hxx"
#include "MEDMEM_Family.hxx"
using namespace MEDMEM;
using namespace MED_EN;
-extern "C" {
- extern med_idt _MEDdatagroupOuvrir(med_idt pid, char *nom);
- extern med_err _MEDdatagroupFermer(med_idt id);
-}
-
// Every memory allocation made in the MedDriver members function are desallocated in the Mesh destructor
MED_MESH_DRIVER::MED_MESH_DRIVER():
GENDRIVER(),
_ptrMesh(( MESH *)MED_NULL),
- _medIdt(MED_INVALID),
_meshName(""),
_meshNum(MED_INVALID)
{
MESH * ptrMesh,
MED_EN::med_mode_acces accessMode):
GENDRIVER(fileName,accessMode),
- _ptrMesh(ptrMesh),
- _medIdt(MED_INVALID),
+ _ptrMesh(ptrMesh),
_meshName(""),
- _meshNum(MED_INVALID)
+ _meshNum(MED_INVALID)
{
}
MED_MESH_DRIVER::MED_MESH_DRIVER(const MED_MESH_DRIVER & driver):
GENDRIVER(driver),
_ptrMesh(driver._ptrMesh),
- _medIdt(MED_INVALID),
_meshName(driver._meshName),
- _meshNum(driver._meshNum)
+ _meshNum(driver._meshNum)
{
+
}
MED_MESH_DRIVER::~MED_MESH_DRIVER()
{
-}
+ MESSAGE("MED_MESH_DRIVER::~MED_MESH_DRIVER()has been destroyed");
-void MED_MESH_DRIVER::open()
-{
- const char * LOC = "MED_MESH_DRIVER::open()" ;
- BEGIN_OF(LOC);
- MESSAGE(LOC<<" : _fileName.c_str : "<< _fileName.c_str()<<",mode : "<< _accessMode);
- _medIdt = med_2_1::MEDouvrir( (const_cast <char *> (_fileName.c_str())),(med_2_1::med_mode_acces) _accessMode);
- MESSAGE(LOC<<" _medIdt : "<< _medIdt );
- if (_medIdt > 0)
- _status = MED_OPENED;
- else {
- _medIdt = MED_INVALID;
- _status = MED_CLOSED;
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Could not open file "<<_fileName<<" in mode "<<_accessMode));
- }
-
- END_OF(LOC);
}
-
-void MED_MESH_DRIVER::close()
-{
- const char * LOC = "MED_MESH_DRIVER::close() " ;
- BEGIN_OF(LOC);
- int err = 0;
- if ( _status == MED_OPENED) {
- err=med_2_1::MEDfermer(_medIdt);
- // san -- MED5873 : Calling H5close() here leads to failure of SALOMEDS::StudyManager_i::_SaveAs()
- // method during study saving process. MEDfermer() seems sufficient for closing a file.
- //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);
-}
-
-void MED_MESH_DRIVER::setMeshName(const string & meshName) { _meshName = meshName; };
-string MED_MESH_DRIVER::getMeshName() const { return _meshName; };
-//A FAIRE UTILISER LES MAPS...
-const med_2_1::med_geometrie_element MED_MESH_DRIVER::all_cell_type[MED_NBR_GEOMETRIE_MAILLE]=
- { med_2_1::MED_POINT1,med_2_1::MED_SEG2,med_2_1::MED_SEG3,med_2_1::MED_TRIA3,med_2_1::MED_QUAD4,med_2_1::MED_TRIA6,med_2_1::MED_QUAD8,
- med_2_1::MED_TETRA4,med_2_1::MED_PYRA5,med_2_1::MED_PENTA6,med_2_1::MED_HEXA8,med_2_1::MED_TETRA10,med_2_1::MED_PYRA13,
- med_2_1::MED_PENTA15, med_2_1::MED_HEXA20};
-
-const char * const MED_MESH_DRIVER::all_cell_type_tab [MED_NBR_GEOMETRIE_MAILLE]=
- { "MED_POINT1","MED_SEG2","MED_SEG3","MED_TRIA3","MED_QUAD4","MED_TRIA6","MED_QUAD8",
- "MED_TETRA4","MED_PYRA5","MED_PENTA6","MED_HEXA8","MED_TETRA10","MED_PYRA13",
- "MED_PENTA15","MED_HEXA20"};
+void MED_MESH_DRIVER::setMeshName(const string & meshName)
+{
+ _meshName = meshName;
+}
+string MED_MESH_DRIVER::getMeshName() const
+{
+ return _meshName;
+}
//---------------------------------- RDONLY PART -------------------------------------------------------------
-MED_MESH_RDONLY_DRIVER::MED_MESH_RDONLY_DRIVER(): MED_MESH_DRIVER()
+IMED_MESH_RDONLY_DRIVER::IMED_MESH_RDONLY_DRIVER(): MED_MESH_DRIVER()
{
}
-MED_MESH_RDONLY_DRIVER::MED_MESH_RDONLY_DRIVER(const string & fileName,
- MESH * ptrMesh):
- MED_MESH_DRIVER(fileName,ptrMesh,MED_RDONLY)
+IMED_MESH_RDONLY_DRIVER::IMED_MESH_RDONLY_DRIVER(const string & fileName,
+ MESH * ptrMesh):
+ MED_MESH_DRIVER(fileName, ptrMesh, MED_EN::MED_RDONLY)
{
- MESSAGE("MED_MESH_RDONLY_DRIVER::MED_MESH_RDONLY_DRIVER(const string & fileName, MESH * ptrMesh) has been created");
+ MESSAGE("IMED_MESH_RDONLY_DRIVER::IMED_MESH_RDONLY_DRIVER(const string & fileName, MESH * ptrMesh) has been created");
}
-MED_MESH_RDONLY_DRIVER::MED_MESH_RDONLY_DRIVER(const MED_MESH_RDONLY_DRIVER & driver):
+IMED_MESH_RDONLY_DRIVER::IMED_MESH_RDONLY_DRIVER(const IMED_MESH_RDONLY_DRIVER & driver):
MED_MESH_DRIVER(driver)
{
}
-MED_MESH_RDONLY_DRIVER::~MED_MESH_RDONLY_DRIVER()
-{
- //MESSAGE("MED_MESH_RDONLY_DRIVER::~MED_MESH_RDONLY_DRIVER() has been destroyed");
-}
-
-GENDRIVER * MED_MESH_RDONLY_DRIVER::copy(void) const
-{
- return new MED_MESH_RDONLY_DRIVER(*this);
-}
-
-void MED_MESH_RDONLY_DRIVER::read(void)
-{
- const char * LOC = "MED_MESH_RDONLY_DRIVER::read() : " ;
- BEGIN_OF(LOC);
- if (_status!=MED_OPENED)
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "The _idt of file " << _fileName << " is : " << _medIdt << " (the file is not opened)." )) ;
-
- _ptrMesh->_name = _meshName;
-
- SCRUTE(_ptrMesh->getIsAGrid());
-
- if (_ptrMesh->getIsAGrid())
- {
- getGRID( );
-
- // always call getFAMILY : families are requiered !!!!
-
-// int nbFam = MEDnFam(_medIdt,
-// const_cast <char *> (_meshName.c_str()),
-// 0,
-// med_2_1::MED_FAMILLE);
-// if (nbFam > 0)
- {
-// getFAMILY();
-
- if (getFAMILY()!=MED_VALID)
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERREUR in getFAMILY when the mesh is a grid")) ;
-
- buildAllGroups(_ptrMesh->_groupNode,_ptrMesh->_familyNode) ;
- }
-
- END_OF(LOC);
- return;
- }
-
- if (getCOORDINATE()!=MED_VALID)
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERREUR in getCOORDINATE" )) ;
-
- if (getCONNECTIVITY()!=MED_VALID)
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERREUR in getCOONECTIVITY")) ;
-
- if (getFAMILY()!=MED_VALID)
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERREUR in getFAMILY" )) ;
-
- updateFamily();
-
- // we build all groups
- // on node
- buildAllGroups(_ptrMesh->_groupNode,_ptrMesh->_familyNode) ;
- // on cell
- buildAllGroups(_ptrMesh->_groupCell,_ptrMesh->_familyCell) ;
- // on face
- buildAllGroups(_ptrMesh->_groupFace,_ptrMesh->_familyFace) ;
- // on edge
- buildAllGroups(_ptrMesh->_groupEdge,_ptrMesh->_familyEdge) ;
-
-// MESSAGE(LOC<<"Checking of CellModel !!!!!!!");
-
-// int nbOfTypes = _ptrMesh->_connectivity->_numberOfTypes;
-// for(int i=0;i<nbOfTypes;i++)
-// {
-// MESSAGE(LOC << _ptrMesh->_connectivity->_type[i]) ;
-// }
-
- END_OF(LOC);
-}
-
-//=======================================================================
-//function : getGRID
-//purpose :
-//=======================================================================
-
-void MED_MESH_RDONLY_DRIVER::getGRID()
-{
- const char * LOC = "MED_MESH_RDONLY_DRIVER::getGRID() : " ;
- BEGIN_OF(LOC);
-
- if (_status!=MED_OPENED)
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "med file is not opened"));
-
- GRID * ptrGrid = (GRID *) _ptrMesh;
-
- int err, i;
-
- // Read the dimension of the space for the mesh <_meshName>
- int SpaceDimension = med_2_1::MEDdimLire(_medIdt,const_cast <char *> (_meshName.c_str())) ;
- if ( SpaceDimension <= MED_VALID )
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"The space dimension |" << SpaceDimension <<
- "| seems to be incorrect " << "for the mesh : |" <<
- _meshName << "|")) ;
- _ptrMesh->_spaceDimension = SpaceDimension;
-
- // Read Array length
- int * ArrayLen[] = { & ptrGrid->_iArrayLength,
- & ptrGrid->_jArrayLength,
- & ptrGrid->_kArrayLength };
- int idim;
- for (idim = 0; idim < _ptrMesh->_spaceDimension; ++idim)
- {
- int lenght = med_2_1::MEDnGrid(_medIdt,
- const_cast <char *> (_ptrMesh->_name.c_str()),
- (med_2_1::med_grid)
- idim
- );
- if ( lenght <= MED_VALID )
- throw MEDEXCEPTION(STRING(LOC) <<"The number of nodes |" << lenght <<
- "| seems to be incorrect "
- << "for the mesh : |" << _meshName << "|" ) ;
-
- ArrayLen [idim][0] = lenght;
- }
-
- med_2_1::med_repere rep ;
- string tmp_nom_coord (MED_TAILLE_PNOM*(_ptrMesh->_spaceDimension)+1,' ');
- string tmp_unit_coord(MED_TAILLE_PNOM*(_ptrMesh->_spaceDimension)+1,' ');
- char * tmp_nom = (const_cast <char *> ( tmp_nom_coord.c_str()) ) ;
- char * tmp_unit= (const_cast <char *> ( tmp_unit_coord.c_str()) ) ;
-
- // Read node coordinates for MED_BODY_FITTED grid
-
- SCRUTE(ptrGrid->getGridType());
-
- if (ptrGrid->getGridType() == MED_EN::MED_BODY_FITTED)
- {
- // Read nb of nodes
- int NumberOfNodes = med_2_1::MEDnGrid(_medIdt,
- const_cast <char *> (_meshName.c_str()),
- med_2_1::MED_GRID_NOEUD);
- if ( NumberOfNodes <= MED_VALID )
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"The number of nodes |" << NumberOfNodes <<
- "| seems to be incorrect "
- << "for the mesh : |" << _meshName << "|" )) ;
- _ptrMesh->_numberOfNodes = NumberOfNodes ;
-
- // this array is useless because families numbers are read in getFAMILY
- //CCRT as it is useless replace int by med_int
- med_2_1::med_int * MEDArrayNodeFamily = new med_2_1::med_int[ NumberOfNodes ];
- // create coordinates
- _ptrMesh->_coordinate = new COORDINATE(SpaceDimension,NumberOfNodes,
- MED_EN::MED_FULL_INTERLACE);
-
- // Read coordinates and families
-// double * coo = const_cast <double *>
-// (_ptrMesh->_coordinate->getCoordinates(MED_EN::MED_FULL_INTERLACE));
-
-// err = med_2_1::MEDbodyFittedLire (_medIdt,
-// const_cast <char *> (_ptrMesh->_name.c_str()),
-// _ptrMesh->_spaceDimension,
-// coo,
-// med_2_1::MED_FULL_INTERLACE,
-// & rep,
-// tmp_nom,
-// tmp_unit,
-// MEDArrayNodeFamily,
-// NumberOfNodes);
-
- err = med_2_1::MEDbodyFittedLire (_medIdt,
- const_cast <char *> (_ptrMesh->_name.c_str()),
- _ptrMesh->_spaceDimension,
- const_cast <double *> ( _ptrMesh->_coordinate->_coordinate.get(MED_EN::MED_FULL_INTERLACE) ),
- med_2_1::MED_FULL_INTERLACE,
- & rep,
- tmp_nom,
- tmp_unit,
- MEDArrayNodeFamily,
- NumberOfNodes);
-
- MESSAGE(LOC << " NumberOfNodes = " << NumberOfNodes << " SpaceDimension = " << SpaceDimension);
-
- ptrGrid->_is_coordinates_filled = true;
-
-// for (int icoor = 0 ; icoor<NumberOfNodes ; icoor++)
-// for(int jcoor = 0 ; jcoor<SpaceDimension ; jcoor++)
-// MESSAGE(LOC << " icoor = " << icoor << " jcoor = " << jcoor << " COOR = " << _ptrMesh->getCoordinates(MED_FULL_INTERLACE)[icoor*SpaceDimension+jcoor]);
-
- delete[] MEDArrayNodeFamily;
- if (err != MED_VALID)
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"error in MEDbodyFittedLire()"));
-
- // _ptrMesh->_MEDArrayNodeFamily = fam ;
-
- }
- else
- {
- // Read Arrays and Node families in Cartesian or Polar Grid
-
- int nbNodes = 1;
- double * Array[] = { (double*) 0, (double*) 0, (double*) 0 };
- for (idim = 0; idim < _ptrMesh->_spaceDimension; ++idim)
- {
- int nbNodesDim = * ArrayLen [idim];
- nbNodes *= nbNodesDim;
- Array [idim] = new double [ nbNodesDim ];
- err = med_2_1::MEDgridLire (_medIdt,
- const_cast <char *> (_ptrMesh->_name.c_str()),
- _ptrMesh->_spaceDimension,
- Array [idim],
- idim,
- med_2_1::MED_FULL_INTERLACE,
- & rep,
- tmp_nom,
- tmp_unit);
- if (err != MED_VALID)
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Error in MEDgridLire for dimention" << idim ));
-
- }
- ptrGrid->_iArray = Array[0];
- ptrGrid->_jArray = Array[1];
- ptrGrid->_kArray = Array[2];
-
- _ptrMesh->_numberOfNodes = nbNodes ;
-
- // create coordinates
- _ptrMesh->_coordinate = new COORDINATE(SpaceDimension,nbNodes,
- MED_EN::MED_FULL_INTERLACE);
- // Read node families
-// int nbFamNodes = med_2_1::MEDnGrid(_medIdt,
-// const_cast <char *> (_ptrMesh->_name.c_str()),
-// med_2_1::MED_FAM_NOEUD);
-// if (nbFamNodes > 0)
-// {
-// // int * fam = new int[ nbFamNodes ];
-
-// //_ptrMesh->_MEDArrayNodeFamily = new int[ nbFamNodes ];
-// // this array is useless because families numbers are read in getFAMILY
-// int * MEDArrayNodeFamily = new int[ nbFamNodes ];
-
-// err = med_2_1::MEDfamGridLire (_medIdt,
-// const_cast <char *> (_ptrMesh->_name.c_str()),
-// MEDArrayNodeFamily,
-// nbFamNodes,
-// med_2_1::MED_NOEUD);
-
-// if (err != MED_VALID)
-// throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't read grid nodes families for "
-// << idim << "-th dimention"));
-// else
-// _ptrMesh->_MEDArrayNodeFamily = fam;
-// }
-
- } // end read Cartesian or Polar Grid
-
- // set coordinate names
-
- for (i=0; i<_ptrMesh->_spaceDimension; ++i ) {
- string myStringName(tmp_nom_coord,i*MED_TAILLE_PNOM,MED_TAILLE_PNOM) ;
- string myStringUnit(tmp_unit_coord,i*MED_TAILLE_PNOM,MED_TAILLE_PNOM) ;
- // suppress space at the end
- int j ;
- for(j=MED_TAILLE_PNOM-1;j>=0;j--)
- if (myStringName[j] != ' ') break ;
- _ptrMesh->_coordinate->_coordinateName[i]=string(myStringName,0,j+1);
- for(j=MED_TAILLE_PNOM-1;j>=0;j--)
- if (myStringUnit[j] != ' ') break ;
- _ptrMesh->_coordinate->_coordinateUnit[i]=string(myStringUnit,0,j+1);
- }
-
- string coordinateSystem = "UNDEFINED";
-
- if( rep == med_2_1::MED_CART) coordinateSystem = "CARTESIAN";
- else if ( rep == med_2_1::MED_CYL) coordinateSystem = "CYLINDRICAL";
- else if ( rep == med_2_1::MED_SPHER) coordinateSystem = "SPHERICAL";
-
- _ptrMesh->_coordinate->setCoordinatesSystem(coordinateSystem);
-
-
- END_OF(LOC);
-}
-
-//=======================================================================
-//function : getCOORDINATE
-// A FAIRE : RENVOYER DU VOID
-//=======================================================================
-int MED_MESH_RDONLY_DRIVER::getCOORDINATE()
-{
- const char * LOC = "MED_MESH_RDONLY_DRIVER::getCOORDINATE() : " ;
- BEGIN_OF(LOC);
-
- if (_status==MED_OPENED)
- {
- int err ;
-
- // Read the dimension of the space for the mesh <_meshName>
- // to be able to create a COORDINATE object
- int SpaceDimension = med_2_1::MEDdimLire(_medIdt,const_cast <char *> (_meshName.c_str())) ;
- if ( SpaceDimension <= MED_VALID )
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"The space dimension |" << SpaceDimension << "| seems to be incorrect "
- << "for the mesh : |" << _meshName << "|")) ;
- _ptrMesh->_spaceDimension = SpaceDimension ;
-
-
-
- // Read the number of nodes used in the mesh <_meshName>
- // to be able to create a COORDINATE object
- int NumberOfNodes=MEDnEntMaa(_medIdt,
- const_cast <char *> (_meshName.c_str()),
- med_2_1::MED_COOR,
- med_2_1::MED_NOEUD,
- (med_2_1::med_geometrie_element) MED_NONE,
- (med_2_1::med_connectivite) MED_NONE);
- if ( NumberOfNodes <= MED_VALID )
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"The number of nodes |" << NumberOfNodes << "| seems to be incorrect "
- << "for the mesh : |" << _meshName << "|" )) ;
- _ptrMesh->_numberOfNodes = NumberOfNodes ;
-
-
-
- // create a COORDINATE object
- _ptrMesh->_coordinate = new COORDINATE(SpaceDimension, NumberOfNodes, MED_EN::MED_FULL_INTERLACE);
-
- med_2_1::med_repere rep ; // ATTENTION ---> DOIT ETRE INTEGRE DS MESH EF: FAIT NON?
- string tmp_nom_coord (MED_TAILLE_PNOM*(_ptrMesh->_spaceDimension)+1,'\0');
- string tmp_unit_coord(MED_TAILLE_PNOM*(_ptrMesh->_spaceDimension)+1,'\0');
- char * tmp_nom = (const_cast <char *> ( tmp_nom_coord.c_str()) ) ;
- char * tmp_unit= (const_cast <char *> ( tmp_unit_coord.c_str()) ) ;
-
- err=MEDcoordLire(_medIdt,
- const_cast <char *> (_ptrMesh->_name.c_str()),
- _ptrMesh->_spaceDimension,
- //const_cast <double *> ( _ptrMesh->_coordinate->_coordinate->get(MED_EN::MED_FULL_INTERLACE) ),
- const_cast <double *> ( _ptrMesh->_coordinate->_coordinate.get(MED_EN::MED_FULL_INTERLACE) ),
- med_2_1::MED_FULL_INTERLACE,
- MED_ALL, // we read all the coordinates
- NULL, // we don't use a profile
- 0, // so the profile's size is 0
- &rep,tmp_nom,tmp_unit);
- if (err != MED_VALID)
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't read coordinates of the |" << NumberOfNodes << "| nodes "
- << "for the mesh : |" << _meshName
- << "| of space dimension |" << SpaceDimension
- << "| with units names |" << tmp_nom
- << "| and units |" << tmp_unit
- << " |")) ;
-
-
- for (int i=0;i<_ptrMesh->_spaceDimension;i++) {
- string myStringName(tmp_nom_coord,i*MED_TAILLE_PNOM,MED_TAILLE_PNOM) ;
- string myStringUnit(tmp_unit_coord,i*MED_TAILLE_PNOM,MED_TAILLE_PNOM) ;
- // suppress space at the end
- int j ;
- for(j=MED_TAILLE_PNOM-1;j>=0;j--)
- if (myStringName[j] != ' ') break ;
- _ptrMesh->_coordinate->_coordinateName[i]=string(myStringName,0,j+1);
- for(j=MED_TAILLE_PNOM-1;j>=0;j--)
- if (myStringUnit[j] != ' ') break ;
- _ptrMesh->_coordinate->_coordinateUnit[i]=string(myStringUnit,0,j+1);
- }
-
- // Pourquoi le stocker sous forme de chaîne ?
- switch (rep)
- {
- case med_2_1::MED_CART :
- {
- _ptrMesh->_coordinate->_coordinateSystem = "CARTESIAN";
- break ;
- }
- case med_2_1::MED_CYL :
- {
- _ptrMesh->_coordinate->_coordinateSystem = "CYLINDRICAL";
- break ;
- }
- case med_2_1::MED_SPHER :
- {
- _ptrMesh->_coordinate->_coordinateSystem = "SPHERICAL";
- break ;
- }
- default :
- {
- _ptrMesh->_coordinate->_coordinateSystem = "UNDEFINED"; // ?Erreur ?
- break ;
- }
- }
-
- // Read the unused optional node Names
- char * tmp_node_name = new char[NumberOfNodes*MED_TAILLE_PNOM+1];
- tmp_node_name[NumberOfNodes]='\0' ;
- err=MEDnomLire(_medIdt,const_cast <char*> (_ptrMesh->_name.c_str()),
- tmp_node_name,NumberOfNodes*MED_TAILLE_PNOM,med_2_1::MED_NOEUD,
- (med_2_1::med_geometrie_element) MED_NONE);
- if (err == MED_VALID)
- MESSAGE(LOC<<"MED_MESH_RDONLY_DRIVER::getNoeuds() : WARNING : Nodes have names but we do not read them !");
- delete[] tmp_node_name ;
-
-
- // ??? Read the unused optional node Numbers ???
- med_2_1::med_int * tmp_node_number = new med_2_1::med_int[NumberOfNodes] ;
- err=MEDnumLire(_medIdt,const_cast <char*> (_ptrMesh->_name.c_str()),
- tmp_node_number,NumberOfNodes,med_2_1::MED_NOEUD,(med_2_1::med_geometrie_element)0);
- if (err == MED_VALID) {
- // INFOS(LOC<<"WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING");
- // INFOS(LOC<<"MED_MESH_RDONLY_DRIVER::getNoeuds() : WARNING : Nodes have numbers but we do not take care of them !");
- // INFOS(LOC<<"WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING");
- MESSAGE(LOC<<"MED_MESH_RDONLY_DRIVER::getNoeuds() : Nodes have numbers, we DO TAKE care of them !");
- _ptrMesh->_coordinate->_nodeNumber.set(NumberOfNodes) ;
-#if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
- for(med_2_1::med_int i2=0;i2<NumberOfNodes;i2++)
- _ptrMesh->_coordinate->_nodeNumber[i2]=(int)(tmp_node_number[i2]);
-#else
- memcpy((int*)_ptrMesh->_coordinate->_nodeNumber,tmp_node_number,sizeof(int)*NumberOfNodes) ;
-#endif
-
- //////////////////////////////////////////////////////////////////////////////////////
- /// Modification pour prise en compte de la numérotation optionnelle des noeuds ///
- //////////////////////////////////////////////////////////////////////////////////////
- ///
- /// Calcule _optionnalToCanonicNodesNumbers de telle sorte que _optionnalToCanonicNodesNumbers[OptionnalNumber]==CanonicNumber
-
-// _ptrMesh->_arePresentOptionnalNodesNumbers=1;
-// for (int canonicNumber=1;canonicNumber<=NumberOfNodes;canonicNumber++) _ptrMesh->_optionnalToCanonicNodesNumbers[tmp_node_number[canonicNumber-1]]=canonicNumber;
-// ICI RETOUR A LA NORMALE::: AUCUNE PRISE EN COMPTE D'UN NUMEROTATION OPTIONNEL
- _ptrMesh->_arePresentOptionnalNodesNumbers=0;
- }
- else _ptrMesh->_arePresentOptionnalNodesNumbers=0;
-
- //////////////////////////////////////////////////////////////////////////////////////
-
- delete[] tmp_node_number ;
-
- END_OF(LOC);
- return MED_VALID;
- }
- return MED_ERROR;
-}
-
-
-int MED_MESH_RDONLY_DRIVER::getCONNECTIVITY()
-{
- const char * LOC = "MED_MESH_RDONLY_DRIVER::getCONNECTIVITY : " ;
- BEGIN_OF(LOC);
-
- if (_status==MED_OPENED)
- {
-
- int err = 0 ;
- // read MED_CELL connectivity
- CONNECTIVITY * Connectivity = new CONNECTIVITY(MED_CELL) ;
- Connectivity->_numberOfNodes = _ptrMesh->_numberOfNodes ; // EF : Pourquoi cet attribut est-il dans MESH et non dans COORDINATE ?
-
- // Try to read nodal connectivity of the cells <Connectivity->_nodal>
- // then try to read descending connectivity <Connectivity->_descending>
- // if neither nodal nor descending connectivity exists
- // throw an exception.
- err = getNodalConnectivity(Connectivity) ;
- if (err!=MED_VALID)
- {
- Connectivity->_typeConnectivity = MED_DESCENDING ;
- err = getDescendingConnectivity(Connectivity) ;
- }
- else
- getDescendingConnectivity(Connectivity) ; // we read it if there is one
-
- if (err!=MED_VALID)
- {
- delete Connectivity ;
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "We could not read " <<
- "any Connectivity")) ;
- }
-
- _ptrMesh->_meshDimension = Connectivity->_entityDimension ;
-
- // At this point Connectivity->_typeConnectivity is either NODAL or DESCENDING
- // If both connectivities are found Connectivity->_typeConnectivity is NODAL
- // If space dimension is 3
- // try to read the nodal connectivity of the faces <ConnectivityFace->_nodal> then
- // try to read the descending connectivity <ConnectivityFace->_descending>
- // if there is no descending connectivity and the CELLS are
- // defined in descending mode then throw an exception
-
- // PROVISOIRE : if we have some face or edge in MED_MAILLE, we don't read more. There could not be have face or edge !!!!
-
- if(Connectivity->_constituent==NULL)
- {
- SCRUTE(_ptrMesh->_meshDimension);
- if (_ptrMesh->_meshDimension == 3)
- {
- MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE DES FACES..." );
- CONNECTIVITY * ConnectivityFace = new CONNECTIVITY(MED_EN::MED_FACE) ;
- ConnectivityFace->_typeConnectivity = Connectivity->_typeConnectivity ;
- // NODAL or DESCENDING
- SCRUTE(ConnectivityFace->_typeConnectivity);
- if (Connectivity->_typeConnectivity == MED_DESCENDING)
- {
- MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE DESCENDANTE DES FACES" );
- err = getDescendingConnectivity(ConnectivityFace) ;
- if (err!=MED_VALID)
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<
- "No FACE in descending connectivity")) ;
- getNodalConnectivity(ConnectivityFace) ; // if any !
- }
- else
- {
- MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE NODALE DES FACES" );
- err = getNodalConnectivity(ConnectivityFace) ;
- if (err!=MED_VALID)
- { // or error ????? we are in NODAL mode.
- err = getDescendingConnectivity(ConnectivityFace) ;
- }
- else
- getDescendingConnectivity(ConnectivityFace); // if any !
- }
-
- if (err!=MED_VALID)
- {
- delete ConnectivityFace ;
- MESSAGE(LOC<<"No FACE defined.") ;
- }
- else
- {
- MESSAGE(LOC<<" SAUVEGARDE DE LA CONNECTIVITE DES " <<
- "FACES DANS L'OBJET CONNECTIVITY" );
- Connectivity->_constituent=ConnectivityFace ;
- }
- }
-
- // read MED_EDGE connectivity
- if (_ptrMesh->_meshDimension > 1)
- { // we are in 3 or 2D
- MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE DES ARRETES...." );
- CONNECTIVITY * ConnectivityEdge = new CONNECTIVITY(MED_EDGE) ;
- ConnectivityEdge->_typeConnectivity = Connectivity->_typeConnectivity ;
- if (Connectivity->_typeConnectivity == MED_DESCENDING)
- {
- MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE DESCENDANTE " <<
- "DES ARRETES" );
- err = getDescendingConnectivity(ConnectivityEdge) ;
- if (err!=MED_VALID)
- throw MEDEXCEPTION ( LOCALIZED(STRING(LOC) <<
- "No EDGE in descending connectivity")) ;
- getNodalConnectivity(ConnectivityEdge) ; // if any !
- }
- else
- {
- MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE NODALE DES ARRETES" );
- err = getNodalConnectivity(ConnectivityEdge) ;
- if (err!=MED_VALID)
- { // or error ????? we are in NODAL mode.
- err = getDescendingConnectivity(ConnectivityEdge) ;
- }
- else
- getDescendingConnectivity(ConnectivityEdge) ; // if any !
- }
-
- if (err!=MED_VALID)
- {
- delete ConnectivityEdge ;
- MESSAGE(LOC<<"No EDGE defined.") ;
- }
- else
- {
- if (_ptrMesh->_meshDimension == 3)
- if (Connectivity->_constituent != NULL)
- Connectivity->_constituent->_constituent=ConnectivityEdge ;
- else
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<< "EDGE defined but there are no FACE !")) ;
- else
- { // IN 2D
- MESSAGE(LOC<<" SAUVEGARDE DE LA CONNECTIVITE DES " <<
- "ARETES DANS L'OBJET CONNECTIVITY" );
- Connectivity->_constituent=ConnectivityEdge ;
- }
- }
- }
- }
- _ptrMesh->_connectivity = Connectivity ;
-
- // all right !
-
- // we have read all connectivity in file, now we must build descending connectivity if necessary !
-
- // If connectivity descending is defined, we have nothing to do, all constituent are defined !
- // If connectivity is only nodal, we must rebuild descending if we have some contituent !
-
- //A FAIRE !!!!
-// if (Connectivity->_descending == NULL)
-// if (Connectivity->_constituent != NULL){
-// // update Connectivity->_constituent
-// CONNECTIVITY * myConstituentOld = Connectivity->_constituent ;
-// Connectivity->_constituent = (CONNECTIVITY *)NULL ;
-// Connectivity->calculateDescendingConnectivity() ;
-
-// }
-
- END_OF(LOC);
- return MED_VALID;
- }
- return MED_ERROR;
-}
-
-int MED_MESH_RDONLY_DRIVER::getNodalConnectivity(CONNECTIVITY * Connectivity)
-{
- const char * LOC = "MED_MESH_RDONLY_DRIVER::getNodalConnectivity : " ;
- BEGIN_OF(LOC);
-
- int spaceDimension = _ptrMesh->_spaceDimension;
-
- if (_status==MED_OPENED)
- {
- // Get the type of entity to work on (previously set in the Connectivity Object)
- med_2_1::med_entite_maillage Entity = (med_2_1::med_entite_maillage) Connectivity->getEntity();
-
- // Get the number of cells of each type & store it in <tmp_cells_count>.
- int * tmp_cells_count = new int[MED_NBR_GEOMETRIE_MAILLE] ;
- int i;
- for (i=1;i<MED_NBR_GEOMETRIE_MAILLE;i++)
- { // EF :ON SCANNE DES GEOMETRIES INUTILES, UTILISER LES MAPS
-
- tmp_cells_count[i]=MEDnEntMaa(_medIdt,(const_cast <char *> (_ptrMesh->_name.c_str())),
- med_2_1::MED_CONN,(med_2_1::med_entite_maillage) Entity,
- all_cell_type[i],med_2_1::MED_NOD);
-
- // Get the greatest dimension of the cells : Connectivity->_entityDimension
- // We suppose there is no cells used as faces in MED 2.2.x , this is forbidden !!!
- // In version prior to 2.2.x, it is possible
- if (tmp_cells_count[i]>0)
- {
- Connectivity->_entityDimension=all_cell_type[i]/100;
- Connectivity->_numberOfTypes++;
- }
- }
-
-
- // If there is no nodal connectivity, we quit !
- if ( Connectivity->_numberOfTypes == 0 )
- {
- delete[] tmp_cells_count ;
- return MED_ERROR ;
- }
-
- // if MED version < 2.2.x, we read only entity with dimention = Connectivity->_entityDimension. Lesser dimension are face or edge !
-
- char version_med[10] ;
- if ( MEDfichEntete(_medIdt,med_2_1::MED_VERSION,version_med) != 0 )
- {
- // error : we suppose we have not a good med file !
- delete[] tmp_cells_count ;
- return MED_ERROR ;
- }
-
- // we get MED version number
- // If MED version is < 2.2 then the cells which dimension
- // is lesser than the main dimension ( Connectivity->_entityDimension )
- // are either faces or edges
-
- // string medVersion(version_med);
- // int firstNumber =
- int * tmpEdgeCount = new int[MED_NBR_GEOMETRIE_MAILLE] ;
- tmpEdgeCount[0] = 0 ;
- int numberOfEdgesTypes = 0;
- int * tmpFaceCount = new int[MED_NBR_GEOMETRIE_MAILLE] ;
- tmpFaceCount[0] = 0 ;
- int numberOfFacesTypes = 0;
-
-// if ((version_med != "2.2")&(Entity==med_2_1::MED_MAILLE))
-// {
-// Connectivity->_numberOfTypes=0;
-
-// for ( i=1;i<MED_NBR_GEOMETRIE_MAILLE;i++)
-// {
-// tmpFaceCount[i]=0;
-// tmpEdgeCount[i]=0;
-// if (tmp_cells_count[i]!=0)
-// {
-// int dimension = all_cell_type[i]/100 ;
-// if (Connectivity->_entityDimension==dimension)
-// Connectivity->_numberOfTypes++ ;
-
-// if (dimension == 2)
-// if (Connectivity->_entityDimension==3)
-// {
-// tmpFaceCount[i]=tmp_cells_count[i] ;
-// tmp_cells_count[i]=0 ;
-// numberOfFacesTypes++;
-// }
-// if (dimension == 1)
-// if (Connectivity->_entityDimension>dimension)
-// {
-// tmpEdgeCount[i]=tmp_cells_count[i] ;
-// tmp_cells_count[i]=0;
-// numberOfEdgesTypes++ ;
-// }
-// }
-// }
-// }
-
- if (Entity==med_2_1::MED_MAILLE)
- {
- Connectivity->_numberOfTypes=0;
-
- for ( i=1;i<MED_NBR_GEOMETRIE_MAILLE;i++)
- {
- tmpFaceCount[i]=0;
- tmpEdgeCount[i]=0;
- if (tmp_cells_count[i]!=0)
- {
- int dimension = all_cell_type[i]/100 ;
- if (Connectivity->_entityDimension==dimension)
- Connectivity->_numberOfTypes++ ;
-
- if (dimension == 2)
- if (Connectivity->_entityDimension==3)
- {
- tmpFaceCount[i]=tmp_cells_count[i] ;
- //tmp_cells_count[i]=0 ;
- //Connectivity->_numberOfTypes++ ;
- numberOfFacesTypes++;
- }
- if (dimension == 1)
- if (Connectivity->_entityDimension>dimension)
- {
- tmpEdgeCount[i]=tmp_cells_count[i] ;
- //tmp_cells_count[i]=0;
- //Connectivity->_numberOfTypes++ ;
- numberOfEdgesTypes++ ;
- }
- }
- }
- }
-
- // bloc to read CELL :
- {
- // Prepare an array of indexes on the different cell types to create a MEDSKYLINEARRAY
- // We use <tmp_cells_count> to calculate <Connectivity->_count> then we release it
- Connectivity->_geometricTypes = new MED_EN::medGeometryElement [Connectivity->_numberOfTypes] ; // Double emploi pour des raisons pratiques
- Connectivity->_type = new CELLMODEL [Connectivity->_numberOfTypes] ; //
- Connectivity->_count = new int [Connectivity->_numberOfTypes+1] ;
- Connectivity->_count[0] = 1;
-
- int size = 0 ;
- int typeNumber=1 ;
- int i;
- for ( i=1;i<MED_NBR_GEOMETRIE_MAILLE;i++)
- { // no point1 cell type (?)
- int dimension = all_cell_type[i]/100 ;
- if ((tmp_cells_count[i]>0) && (Connectivity->_entityDimension == dimension))
- {
- Connectivity->_count[typeNumber]=Connectivity->_count[typeNumber-1]+tmp_cells_count[i];
-
- CELLMODEL t( (MED_EN::medGeometryElement) MED_MESH_DRIVER::all_cell_type[i]) ;
-
- Connectivity->_type[typeNumber-1] = t ;
-
- Connectivity->_geometricTypes[typeNumber-1]=( MED_EN::medGeometryElement) MED_MESH_DRIVER::all_cell_type[i] ;
-
- // probleme avec les mailles de dimension < a dimension du maillage :
- // Il faut oter le zero a la lecture est le remettre a l'ecriture : ce n'est pas fait !!!!! On interdit ce cas pour l'instant !!!
-
-
- size+=tmp_cells_count[i]*((MED_MESH_DRIVER::all_cell_type[i])%100) ;
-
- MESSAGE(LOC
- << Connectivity->_count[typeNumber]-1 << " cells of type "
- << all_cell_type_tab[i] );
-
- typeNumber++;
- }
- }
-
- // Creation of the MEDSKYLINEARRAY
- //Connectivity->_nodal = new MEDSKYLINEARRAY(Connectivity->_count[Connectivity->_numberOfTypes]-1,size) ;
- //int * NodalIndex = Connectivity->_nodal->getIndex() ;
- int * NodalValue = new int[size] ;
- int * NodalIndex = new int[Connectivity->_count[Connectivity->_numberOfTypes]] ;
- NodalIndex[0]=1 ;
-
- // Fill the MEDSKYLINEARRAY by reading the MED file.
- int j=0;
- for ( i=0;i<Connectivity->_numberOfTypes;i++)
- {
- int multi = 0 ;
- med_2_1::med_geometrie_element med_type = (med_2_1::med_geometrie_element) Connectivity->_type[i].getType() ;
- //if ( Connectivity->_type[i].getDimension() < Connectivity->_entityDimension)
- if (Connectivity->_entity == MED_CELL)
- if ( Connectivity->_type[i].getDimension() < _ptrMesh->_spaceDimension)
- multi=1;
-
- // int NumberOfCell = Connectivity->_count[i+1]-Connectivity->_count[i] ;
- int NumberOfNodeByCell = Connectivity->_type[i].getNumberOfNodes() ;
-
- // initialise index
- for ( j=Connectivity->_count[i]; j<Connectivity->_count[i+1];j++)
- NodalIndex[j]=NodalIndex[j-1]+NumberOfNodeByCell ;
-
- int tmp_numberOfCells = Connectivity->_count[i+1]-Connectivity->_count[i] ;
- med_2_1::med_int * tmp_ConnectivityArray = new med_2_1::med_int[(NumberOfNodeByCell+multi)*tmp_numberOfCells];
-
- //int err=MEDconnLire(_medIdt,const_cast <char *> (_ptrMesh->_name.c_str()),
- // Connectivity->_entityDimension,tmp_ConnectivityArray,
- //med_2_1::MED_FULL_INTERLACE,NULL,0,Entity,med_type,med_2_1::MED_NOD);
-
- int err=MEDconnLire(_medIdt,const_cast <char *> (_ptrMesh->_name.c_str()),
- _ptrMesh->_spaceDimension,tmp_ConnectivityArray,
- med_2_1::MED_FULL_INTERLACE,NULL,0,Entity,med_type,
- med_2_1::MED_NOD);
-
- if ( err != MED_VALID)
- {
- delete[] tmp_ConnectivityArray;
- delete[] tmp_cells_count;
- delete[] tmpFaceCount;
- delete[] tmpEdgeCount;
- MESSAGE(LOC<<": MEDconnLire returns "<<err) ;
- return MED_ERROR ;
- }
-
- int * ConnectivityArray = NodalValue + NodalIndex[Connectivity->_count[i]-1]-1 ;
-
- // version originale sans prise en compte des numéros optionnels
- //
- for ( j=0; j<tmp_numberOfCells; j++) for (int k=0; k<NumberOfNodeByCell; k++)
- ConnectivityArray[j*NumberOfNodeByCell+k]=(int)(tmp_ConnectivityArray[j*(NumberOfNodeByCell+multi)+k]) ;
-
- //////////////////////////////////////////////////////////////////////////////
- // Modification pour prise en compte de la numérotation optionnelle des noeuds ///
- //////////////////////////////////////////////////////////////////////////////
- //
- // Rénumérote le tableau temporaire tmp_ConnectivityArray en utilisant _optionnalToCanonicNodesNumbers
- // Le traitement est identique à la version originelle s'il n'y a pas de numérotation optionnelle
-
- // if (_ptrMesh->_arePresentOptionnalNodesNumbers==1)
- // {
- // for ( j=0; j<tmp_numberOfCells; j++) for (int k=0; k<NumberOfNodeByCell; k++)
- // ConnectivityArray[j*NumberOfNodeByCell+k]=_ptrMesh->_optionnalToCanonicNodesNumbers[tmp_ConnectivityArray[j*(NumberOfNodeByCell+multi)+k]] ;
- // }
- // else
- // {
- // for ( j=0; j<tmp_numberOfCells; j++) for (int k=0; k<NumberOfNodeByCell; k++)
- // ConnectivityArray[j*NumberOfNodeByCell+k]=tmp_ConnectivityArray[j*(NumberOfNodeByCell+multi)+k] ;
- // }
- ////////////////////////////////////////////////////////////////////////////
-
- delete[] tmp_ConnectivityArray;
- }
-
- Connectivity->_nodal = new MEDSKYLINEARRAY(Connectivity->_count[Connectivity->_numberOfTypes]-1,
- size,
- NodalIndex,
- NodalValue) ;
-
- delete[] NodalIndex;
- delete[] NodalValue;
- } // end of bloc to read CELL
-
- delete[] tmp_cells_count;
-
-
-
- // Get Face if any
- // ===============
-
- if (numberOfFacesTypes!=0) {
-
- // Create a CONNECTIVITY constituent to put in the top level CONNECTIVITY recursive class
- CONNECTIVITY * constituent = new CONNECTIVITY(numberOfFacesTypes,MED_EN::MED_FACE) ;
- constituent->_entityDimension = 2 ;
- constituent->_count[0]=1 ;
-
- // In order to create the MEDSKYLINEARRAY of the constituent object we need :
- // 1:
- // To initialize the _count array of the constituent object (containning cumulated face count by geometric type)
- // _count[0]=1 and _count[_numberOfTypes] give the size of NodalIndex
- // 2:
- // To calculate the total number of face nodes whatever the geometric type is.
- // The result is the size of the array containning all the nodes : NodalValue
- // 3 :
- // To calculate the starting indexes of the different face types in NodalValue,
- // this is the NodalIndex array.
-
- int size = 0 ;
- int typeNumber = 1 ;
- int i;
- for ( i=1; i < MED_NBR_GEOMETRIE_MAILLE; i++) { // no point1 cell type (?)
- if (tmpFaceCount[i]>0) {
-
- constituent->_count[typeNumber] = constituent->_count[typeNumber-1] + tmpFaceCount[i];
- CELLMODEL t( (MED_EN::medGeometryElement) MED_MESH_DRIVER::all_cell_type[i]) ;
- constituent->_type[typeNumber-1]=t ;
-
- constituent->_geometricTypes[typeNumber-1]=( MED_EN::medGeometryElement) MED_MESH_DRIVER::all_cell_type[i] ;
-
- size+=tmpFaceCount[i]*((MED_MESH_DRIVER::all_cell_type[i])%100) ;
- typeNumber++;
- }
- }
-
- // Creation of the MEDSKYLINEARRAY
- //constituent->_nodal = new MEDSKYLINEARRAY(constituent->_count[constituent->_numberOfTypes]-1,size) ;
- //int * NodalIndex = constituent->_nodal->getIndex() ;
- int * NodalValue = new int[size] ;
- int * NodalIndex = new int[constituent->_count[constituent->_numberOfTypes]] ;
- NodalIndex[0]=1 ;
-
- // Fill the MEDSKYLINEARRAY by reading the MED file.
- for ( i=0; i<constituent->_numberOfTypes; i++) {
- med_2_1::med_geometrie_element med_type = (med_2_1::med_geometrie_element) constituent->_type[i].getType() ;
-
- int NumberOfNodeByFace = constituent->_type[i].getNumberOfNodes() ;
-
- // initialise NodalIndex
- for (int j=constituent->_count[i]; j<constituent->_count[i+1];j++)
- NodalIndex[j]=NodalIndex[j-1]+NumberOfNodeByFace ;
-
- int tmp_numberOfFaces = constituent->_count[i+1]-constituent->_count[i] ;
- // Il faut ajouter 1 pour le zero a la lecture !!!
- // ATTENTION UNIQUEMENT POUR MED < 2.2.x
- med_2_1::med_int * tmp_constituentArray = NULL;
- if (version_med != "2.2")
- tmp_constituentArray = new med_2_1::med_int[(NumberOfNodeByFace+1)*tmp_numberOfFaces] ;
- else {
- tmp_constituentArray = new med_2_1::med_int[NumberOfNodeByFace*tmp_numberOfFaces] ;
- MESSAGE(LOC<<": WE ARE USING MED2.2 so there is no +1 for calculating the size of tmp_constituentArray !") ;
- }
-
- int err=MEDconnLire(_medIdt,const_cast <char *> (_ptrMesh->_name.c_str()),
- Connectivity->_entityDimension,tmp_constituentArray,
- med_2_1::MED_FULL_INTERLACE,NULL,0,med_2_1::MED_MAILLE,med_type,med_2_1::MED_NOD);
-
- if ( err != MED_VALID) {
- MESSAGE(LOC<<": MEDconnLire returns "<<err) ;
- delete constituent ;
- delete[] tmp_constituentArray;
- delete[] tmpFaceCount;
- delete[] tmpEdgeCount;
- return MED_ERROR ;
- }
-
- int * constituentArray = NodalValue + NodalIndex[constituent->_count[i]-1]-1 ;
-
- // version originale sans prise en compte des numéros optionnels
- //
- for (int j=0; j<tmp_numberOfFaces; j++)
- for (int k=0; k<NumberOfNodeByFace; k++)
- constituentArray[j*NumberOfNodeByFace+k]=(int)(tmp_constituentArray[j*(NumberOfNodeByFace+1)+k]) ;
-
- //////////////////////////////////////////////////////////////////////////////////////
- /// Modification pour prise en compte de la numérotation optionnelle des noeuds ///
- //////////////////////////////////////////////////////////////////////////////////////
- ///
- /// Rénumérote le tableau temporaire tmp_constituentArray en utilisant _optionnalToCanonicNodesNumbers
- /// Le traitement est identique à la version originelle s'il n'y a pas de numérotation optionnelle
-
-// if (_ptrMesh->_arePresentOptionnalNodesNumbers)
-// {
-// for (int j=0; j<tmp_numberOfFaces; j++) for (int k=0; k<NumberOfNodeByFace; k++)
-// constituentArray[j*NumberOfNodeByFace+k]=_ptrMesh->_optionnalToCanonicNodesNumbers[tmp_constituentArray[j*(NumberOfNodeByFace+1)+k]] ;
-// }
-// else
-// {
-// for (int j=0; j<tmp_numberOfFaces; j++) for (int k=0; k<NumberOfNodeByFace; k++)
-// constituentArray[j*NumberOfNodeByFace+k]=tmp_constituentArray[j*(NumberOfNodeByFace+1)+k] ;
-// }
-
- //////////////////////////////////////////////////////////////////////////////////////
-
- delete[] tmp_constituentArray;
- }
-
- constituent->_nodal = new MEDSKYLINEARRAY(constituent->_count[constituent->_numberOfTypes]-1,
- size,
- NodalIndex,
- NodalValue) ;
- delete[] NodalIndex ;
- delete[] NodalValue ;
-
- Connectivity->_constituent = constituent ;
- }
-
- delete[] tmpFaceCount;
-
- // get Edge if any
- // ===============
- if (numberOfEdgesTypes!=0) {
- CONNECTIVITY * constituent = new CONNECTIVITY(numberOfEdgesTypes,MED_EDGE) ;
- constituent->_entityDimension = 1 ;
- constituent->_count[0]=1 ;
-
- int size = 0 ;
- int typeNumber=1 ;
- // if you declare a variable <i> in two <for> initialization statement,
- // compiler gcc2.95.3 says nothing but there are two <i> variables in the same block
- //and the value you get in the common block seems to be the value of the first variable !
- int i;
-
- for ( i=1; i<MED_NBR_GEOMETRIE_MAILLE; i++) { // no point1 cell type (?)
- if (tmpEdgeCount[i]>0) {
-
- constituent->_count[typeNumber]=constituent->_count[typeNumber-1]+tmpEdgeCount[i];
- CELLMODEL t( (MED_EN::medGeometryElement) MED_MESH_DRIVER::all_cell_type[i]) ;
- constituent->_type[typeNumber-1]=t ;
-
- constituent->_geometricTypes[typeNumber-1]=( MED_EN::medGeometryElement) MED_MESH_DRIVER::all_cell_type[i] ;
-
- size+=tmpEdgeCount[i]*((MED_MESH_DRIVER::all_cell_type[i])%100) ;
- typeNumber++;
- }
- }
-
- // Creation of the MEDSKYLINEARRAY
- //constituent->_nodal = new MEDSKYLINEARRAY(constituent->_count[constituent->_numberOfTypes]-1,size) ;
- //int * NodalIndex = constituent->_nodal->getIndex() ;
- int * NodalValue = new int[size] ;
- int * NodalIndex = new int[constituent->_count[constituent->_numberOfTypes]] ;
- NodalIndex[0]=1 ;
-
- // Fill the MEDSKYLINEARRAY by reading the MED file.
- for ( i=0; i<constituent->_numberOfTypes; i++) {
- med_2_1::med_geometrie_element med_type = (med_2_1::med_geometrie_element) constituent->_type[i].getType() ;
-
- int NumberOfNodeByEdge = constituent->_type[i].getNumberOfNodes() ;
-
- // initialise index
- for (int j=constituent->_count[i]; j<constituent->_count[i+1];j++)
- NodalIndex[j]=NodalIndex[j-1]+NumberOfNodeByEdge ;
-
- int tmp_numberOfEdges = constituent->_count[i+1]-constituent->_count[i] ;
- // Il faut ajouter 1 pour le zero a la lecture !!!
-
- // ATTENTION UNIQUEMENT POUR MED < 2.2.x
- med_2_1::med_int * tmp_constituentArray = NULL;
- if (version_med != "2.2")
- tmp_constituentArray = new med_2_1::med_int[(NumberOfNodeByEdge+1)*tmp_numberOfEdges] ;
- else {
- tmp_constituentArray = new med_2_1::med_int[NumberOfNodeByEdge*tmp_numberOfEdges] ;
- MESSAGE(LOC<<": WE ARE USING MED2.2 so there is no +1 for calculating the size of tmp_constituentArray !") ;
- }
-
- int err=MEDconnLire(_medIdt,const_cast <char *> (_ptrMesh->_name.c_str()),
- _ptrMesh->_spaceDimension,tmp_constituentArray,
- med_2_1::MED_FULL_INTERLACE,NULL,0,med_2_1::MED_MAILLE,med_type,med_2_1::MED_NOD);
- if ( err != MED_VALID) {
- MESSAGE(LOC<<": MEDconnLire returns "<<err) ;
- delete constituent ;
- delete[] tmp_constituentArray;
- delete[] tmpEdgeCount;
- return MED_ERROR ;
- }
-
- int * constituentArray = NodalValue + NodalIndex[constituent->_count[i]-1]-1 ;
-
- // version originale sans prise en compte des numéros optionnels
- //
- for (int j=0; j<tmp_numberOfEdges; j++)
- for (int k=0; k<NumberOfNodeByEdge; k++)
- constituentArray[j*NumberOfNodeByEdge+k]=(int)(tmp_constituentArray[j*(NumberOfNodeByEdge+1)+k]) ;
-
- //////////////////////////////////////////////////////////////////////////////////////
- /// Modification pour prise en compte de la numérotation optionnelle des noeuds ///
- //////////////////////////////////////////////////////////////////////////////////////
- ///
- /// Rénumérote le tableau temporaire tmp_constituentArray en utilisant _optionnalToCanonicNodesNumbers
- /// Le traitement est identique à la version originelle s'il n'y a pas de numérotation optionnelle
-
-// if (_ptrMesh->_arePresentOptionnalNodesNumbers)
-// {
-// for (int j=0; j<tmp_numberOfEdges; j++) for (int k=0; k<NumberOfNodeByEdge; k++)
-// constituentArray[j*NumberOfNodeByEdge+k]=_ptrMesh->_optionnalToCanonicNodesNumbers[tmp_constituentArray[j*(NumberOfNodeByEdge+1)+k]] ;
-// }
-// else
-// {
-// for (int j=0; j<tmp_numberOfEdges; j++) for (int k=0; k<NumberOfNodeByEdge; k++)
-// constituentArray[j*NumberOfNodeByEdge+k]=tmp_constituentArray[j*(NumberOfNodeByEdge+1)+k] ;
-// }
-
- //////////////////////////////////////////////////////////////////////////////////////
-
- delete[] tmp_constituentArray;
- }
-
- constituent->_nodal = new MEDSKYLINEARRAY(constituent->_count[constituent->_numberOfTypes]-1,
- size,
- NodalIndex,
- NodalValue) ;
-
- delete[] NodalIndex ;
- delete[] NodalValue ;
-
- if (Connectivity->_entityDimension == 3) {
- if (Connectivity->_constituent==NULL)
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Edges are defined but there are no Faces !"));
- Connectivity->_constituent->_constituent = constituent ;
- } else
- Connectivity->_constituent = constituent ;
- }
-
- delete[] tmpEdgeCount;
-
- return MED_VALID;
- }
-
- return MED_ERROR;
-}
-
-int MED_MESH_RDONLY_DRIVER::getDescendingConnectivity(CONNECTIVITY * Connectivity)
+int IMED_MESH_RDONLY_DRIVER::getDescendingConnectivity(CONNECTIVITY * Connectivity)
{
const char * LOC = "MED_MESH_RDONLY_DRIVER::getDescendingConnectivity : " ;
if (_status==MED_OPENED)
return MED_ERROR;
}
-// int MED_MESH_RDONLY_DRIVER::getElementFamilies(CONNECTIVITY * Connectivity)
-// {
-// int err = 0 ;
-// int NumberOfTypes = Connectivity->_numberOfTypes ;
-// int * Count = Connectivity->_count ;
-// medGeometryElement * GeometricTypes= Connectivity->_geometricTypes ;
-// int ** tmp_array = new int*[NumberOfTypes] ;
-// for (int i=0; i<NumberOfTypes; i++)
-// tmp_array[i]=NULL ;
-// for (int i=0; i<NumberOfTypes; i++) {
-// int NumberOfElements = Count[i+1]-Count[i] ;
-// int * tmp_families_number = new int[NumberOfElements] ;
-// err = MEDfamLire(_medIdt,const_cast <char*> (_ptrMesh->_name.c_str()),
-// tmp_families_number,NumberOfElements,
-// Connectivity->_entity,GeometricTypes[i]);
-// tmp_array[i]=tmp_families_number ;
-// if (err != MED_VALID) {
-// for (int j=0; j<NumberOfTypes; j++)
-// if (tmp_array[j] != NULL)
-// delete[] tmp_array[j] ;
-// delete[] tmp_array ;
-// throw MEDEXCEPTION("MED_MESH_RDONLY_DRIVER::getElementFamilies : No Family in element GeometricTypes[i]");
-// }
-// }
-
-// if (Connectivity->_entity == MED_CELL)
-// _ptrMesh->_MEDArrayCellFamily = tmp_array ;
-// else if (Connectivity->_entity == MED_FACE)
-// _ptrMesh->_MEDArrayFaceFamily = tmp_array ;
-// else if (Connectivity->_entity == MED_EDGE)
-// _ptrMesh->_MEDArrayEdgeFamily = tmp_array ;
-
-// return MED_VALID ;
-// }
-
-int MED_MESH_RDONLY_DRIVER::getFAMILY()
-{
- const char * LOC = "MED_MESH_RDONLY_DRIVER::getFAMILY() : " ;
- BEGIN_OF(LOC);
-
- if (_status==MED_OPENED) {
- int err = 0 ;
-
- int * MEDArrayNodeFamily = NULL ;
- int ** MEDArrayCellFamily = NULL ;
- int ** MEDArrayFaceFamily = NULL ;
- int ** MEDArrayEdgeFamily = NULL ;
-
- if ( !_ptrMesh->getIsAGrid() )
- {
- // read number :
- // NODE :
- MEDArrayNodeFamily = new int[_ptrMesh->getNumberOfNodes()] ;
- err = getNodesFamiliesNumber(MEDArrayNodeFamily) ; // error only if (_status!=MED_OPENED), other case exeception !
- // CELL
-
- MESSAGE(LOC << "error returned from getNodesFamiliesNumber " << err);
-
- MEDArrayCellFamily = new int*[_ptrMesh->getNumberOfTypes(MED_CELL)] ; // ET SI IL N'Y A PAS DE CELLS ?
- const medGeometryElement * myTypes = _ptrMesh->getTypes(MED_CELL);
- for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_CELL);i++)
- MEDArrayCellFamily[i] = new int[_ptrMesh->getNumberOfElements(MED_CELL,myTypes[i])] ;
-
- err = getCellsFamiliesNumber(MEDArrayCellFamily,_ptrMesh->_connectivity,MED_CELL) ;
-
- MESSAGE(LOC << "error returned from getCellsFamiliesNumber for Cells " << err);
-
- if (_ptrMesh->_connectivity->_constituent != NULL) {
- if (_ptrMesh->_connectivity->_constituent->_entity == MED_EN::MED_FACE) {
- // FACE
- MEDArrayFaceFamily = new int*[_ptrMesh->getNumberOfTypes(MED_FACE)] ;
- myTypes = _ptrMesh->getTypes(MED_FACE);
- for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_FACE);i++)
- MEDArrayFaceFamily[i] = new int[_ptrMesh->getNumberOfElements(MED_FACE,myTypes[i])] ;
-
- err = getCellsFamiliesNumber(MEDArrayFaceFamily,_ptrMesh->_connectivity->_constituent,MED_FACE) ;
-
- MESSAGE(LOC << "error returned from getCellsFamiliesNumber for Faces " << err);
-
- } else {
- // EDGE in 2D
- MEDArrayEdgeFamily = new int*[_ptrMesh->getNumberOfTypes(MED_EDGE)] ;
- myTypes = _ptrMesh->getTypes(MED_EDGE);
- for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_EDGE);i++)
- MEDArrayEdgeFamily[i] = new int[_ptrMesh->getNumberOfElements(MED_EDGE,myTypes[i])] ;
- err = getCellsFamiliesNumber(MEDArrayEdgeFamily,_ptrMesh->_connectivity->_constituent,MED_EDGE) ;
-
- MESSAGE(LOC << "error returned from getCellsFamiliesNumber for Edges in 2D " << err);
-
- }
- // EDGE in 3D
- if (_ptrMesh->_connectivity->_constituent->_constituent != NULL) {
- MEDArrayEdgeFamily = new int*[_ptrMesh->getNumberOfTypes(MED_EDGE)] ;
- myTypes = _ptrMesh->getTypes(MED_EDGE);
- for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_EDGE);i++)
- MEDArrayEdgeFamily[i] = new int[_ptrMesh->getNumberOfElements(MED_EDGE,myTypes[i])] ;
- err = getCellsFamiliesNumber(MEDArrayEdgeFamily,_ptrMesh->_connectivity->_constituent->_constituent,MED_EDGE) ; // we are in 3D !
-
- MESSAGE(LOC << "error returned from getCellsFamiliesNumber for Edges in 3D " << err);
-
- }
- }
- }
- else
- {
- // node
- int NumberOfNodes = _ptrMesh->getNumberOfNodes() ;
- MEDArrayNodeFamily = new int[ NumberOfNodes ];
-#if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
- med_2_1::med_int* MEDArrayNodeFamily2 = new med_2_1::med_int[ NumberOfNodes ];
- err = med_2_1::MEDfamGridLire (_medIdt,
- const_cast <char *> (_ptrMesh->_name.c_str()),
- MEDArrayNodeFamily2,
- NumberOfNodes,
- med_2_1::MED_NOEUD);
- for(int i=0;i<NumberOfNodes;i++)
- MEDArrayNodeFamily[i]=(int) MEDArrayNodeFamily2[i];
- delete [] MEDArrayNodeFamily2;
-#else
- err = med_2_1::MEDfamGridLire (_medIdt,
- const_cast <char *> (_ptrMesh->_name.c_str()),
- MEDArrayNodeFamily,
- NumberOfNodes,
- med_2_1::MED_NOEUD);
-#endif
- // what about cell face and edge ?
- }
-
- // Creation of the families
- int NumberOfFamilies = MEDnFam(_medIdt,const_cast <char *> (_meshName.c_str()),0,med_2_1::MED_FAMILLE) ;
- if ( NumberOfFamilies < 1 ) // at least family 0 must exist
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"There is no FAMILY, FAMILY 0 must exists" ));
-
- SCRUTE(NumberOfFamilies);
-
- vector<FAMILY*> &NodeFamilyVector = _ptrMesh->_familyNode ;
- vector<FAMILY*> &CellFamilyVector = _ptrMesh->_familyCell ;
- vector<FAMILY*> &FaceFamilyVector = _ptrMesh->_familyFace ;
- vector<FAMILY*> &EdgeFamilyVector = _ptrMesh->_familyEdge ;
-
- int numberOfNodesFamilies = 0 ;
- int numberOfCellsFamilies = 0 ;
- int numberOfFacesFamilies = 0 ;
- int numberOfEdgesFamilies = 0 ;
-
- for (int i=0;i<NumberOfFamilies;i++) {
-
- med_2_1::med_int NumberOfAttributes = MEDnFam(_medIdt,const_cast <char *> (_meshName.c_str()),i+1,med_2_1::MED_ATTR) ;
- if (NumberOfAttributes < 0)
- throw MEDEXCEPTION("MED_MESH_RDONLY_DRIVER::getFAMILY() : NumberOfAttributes" );
-
- med_2_1::med_int NumberOfGroups = MEDnFam(_medIdt,const_cast <char *> (_meshName.c_str()),i+1,med_2_1::MED_GROUPE) ;
- if (NumberOfGroups < 0)
- throw MEDEXCEPTION("MED_MESH_RDONLY_DRIVER::getFAMILY() : NumberOfGroups" );
-
- med_2_1::med_int FamilyIdentifier ;
- string FamilyName(MED_TAILLE_NOM,'\0');
- int * AttributesIdentifier = new int[NumberOfAttributes] ;
- int * AttributesValues = new int[NumberOfAttributes] ;
- string AttributesDescription(MED_TAILLE_DESC*NumberOfAttributes,' ') ;
- string GroupsNames(MED_TAILLE_LNOM*NumberOfGroups+1,'\0') ;
-#if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
- med_2_1::med_int tmp_NumberOfAttributes=NumberOfAttributes;
- med_2_1::med_int * AttributesIdentifier2 = new med_2_1::med_int[NumberOfAttributes] ;
- med_2_1::med_int * AttributesValues2 = new med_2_1::med_int[NumberOfAttributes] ;
- err = med_2_1::MEDfamInfo(_medIdt,const_cast <char *> (_meshName.c_str()),
- i+1,const_cast <char *> (FamilyName.c_str()),
- &FamilyIdentifier,AttributesIdentifier2,AttributesValues2,
- const_cast <char *> (AttributesDescription.c_str()),
- &NumberOfAttributes,
- const_cast <char *> (GroupsNames.c_str()),&NumberOfGroups
- );
- for(med_2_1::med_int i2=0;i2<tmp_NumberOfAttributes;i2++)
- {
- AttributesIdentifier[i2]=(int)(AttributesIdentifier2[i2]);
- AttributesValues[i2]=(int)(AttributesValues2[i2]);
- }
- delete [] AttributesIdentifier2;
- delete [] AttributesValues2;
-#else
- err = med_2_1::MEDfamInfo(_medIdt,const_cast <char *> (_meshName.c_str()),
- i+1,const_cast <char *> (FamilyName.c_str()),
- &FamilyIdentifier,AttributesIdentifier,AttributesValues,
- const_cast <char *> (AttributesDescription.c_str()),
- &NumberOfAttributes,
- const_cast <char *> (GroupsNames.c_str()),&NumberOfGroups
- );
-#endif
-
- SCRUTE(GroupsNames);
- SCRUTE(FamilyName);
- SCRUTE(err);
- SCRUTE(i);
-
- if (err != MED_VALID)
- throw MEDEXCEPTION("MED_MESH_RDONLY_DRIVER::getFAMILY() : ERROR when get FAMILY informations" );
- if (FamilyIdentifier != 0 ) {
- FAMILY * Family = new FAMILY(_ptrMesh,(int)FamilyIdentifier,FamilyName,
- (int)NumberOfAttributes,AttributesIdentifier,
- AttributesValues,AttributesDescription,
- (int)NumberOfGroups,GroupsNames,
- MEDArrayNodeFamily,
- MEDArrayCellFamily,
- MEDArrayFaceFamily,
- MEDArrayEdgeFamily
- ) ;
- // All good ?
- // if nothing found, delete Family
-
-
- //MESSAGE(LOC << " Well is that OK now ?? " << (*Family));
-
-
-
- if (Family->getNumberOfTypes() == 0) {
- MESSAGE(LOC<<"Nothing found for family "<<FamilyName<< " : skip");
- delete Family;
- } else
- switch (Family->getEntity()) {
- case MED_EN::MED_NODE :
- NodeFamilyVector.push_back(Family) ;
- numberOfNodesFamilies++ ;
- break ;
- case MED_EN::MED_CELL :
- CellFamilyVector.push_back(Family) ;
- numberOfCellsFamilies++ ;
- break ;
- case MED_EN::MED_FACE :
- FaceFamilyVector.push_back(Family) ;
- numberOfFacesFamilies++ ;
- break ;
- case MED_EN::MED_EDGE :
- EdgeFamilyVector.push_back(Family) ;
- numberOfEdgesFamilies++ ;
- break ;
- }
-
- // MESSAGE(LOC << (*Family));
-
-
-
-
- }
-
- delete [] AttributesIdentifier ;
- delete [] AttributesValues ;
- }
-
- if (MEDArrayNodeFamily != NULL)
- delete[] MEDArrayNodeFamily ;
- if (MEDArrayCellFamily != NULL) {
- for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_CELL);i++)
- delete[] MEDArrayCellFamily[i] ;
- delete[] MEDArrayCellFamily ;
- }
- if (MEDArrayFaceFamily != NULL) {
- for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_FACE);i++)
- delete[] MEDArrayFaceFamily[i] ;
- delete[] MEDArrayFaceFamily ;
- }
- if (MEDArrayEdgeFamily != NULL) {
- for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_EDGE);i++)
- delete[] MEDArrayEdgeFamily[i] ;
- delete[] MEDArrayEdgeFamily ;
- }
-
- END_OF(LOC);
- return MED_VALID ;
- }
- return MED_ERROR;
-}
-
-int MED_MESH_RDONLY_DRIVER::getNodesFamiliesNumber(int * MEDArrayNodeFamily)
-{
- const char * LOC = "MED_MESH_RDONLY_DRIVER::getNodesFamiliesNumber() : " ;
- BEGIN_OF(LOC);
- if (_status==MED_OPENED) {
- int err = 0 ;
-#if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
- int lgth=_ptrMesh->getNumberOfNodes();
- med_2_1::med_int *temp=new med_2_1::med_int[lgth];
- err = MEDfamLire(_medIdt,(const_cast <char *> (_ptrMesh->_name.c_str())),
- temp,
- _ptrMesh->getNumberOfNodes(),
- med_2_1::MED_NOEUD,(med_2_1::med_geometrie_element) MED_NONE);
- for(int i2=0;i2<lgth;i2++)
- MEDArrayNodeFamily[i2]=(int)(temp[i2]);
- delete [] temp;
-#else
- err = MEDfamLire(_medIdt,(const_cast <char *> (_ptrMesh->_name.c_str())),
- MEDArrayNodeFamily,
- _ptrMesh->getNumberOfNodes(),
- med_2_1::MED_NOEUD,(med_2_1::med_geometrie_element) MED_NONE);
-#endif
- if ( err != MED_VALID) {
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "There is no family for the |"<< _ptrMesh->getNumberOfNodes()
- << "| nodes in mesh |"
- << _ptrMesh->_name.c_str() << "|" ));
- }
- END_OF(LOC);
- return MED_VALID;
- }
- return MED_ERROR;
-}
-
-int MED_MESH_RDONLY_DRIVER::getCellsFamiliesNumber(int **MEDArrayFamily,CONNECTIVITY *Connectivity, MED_EN::medEntityMesh entity)
-{
- const char * LOC = "MED_MESH_RDONLY_DRIVER::getCellsFamiliesNumber " ;
- BEGIN_OF(LOC);
-
- if (_status==MED_OPENED) {
- int i, err = 0 ;
- for (i=0;i<Connectivity->_numberOfTypes;i++) {
- int NumberOfCell = Connectivity->_count[i+1]-Connectivity->_count[i] ;
-#if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
- const medGeometryElement * myTypes = _ptrMesh->getTypes(entity);
- int lgthI=_ptrMesh->getNumberOfElements(entity,myTypes[i]);
- med_2_1::med_int *temp=new med_2_1::med_int[lgthI];
- err=MEDfamLire(_medIdt,const_cast <char *> (_ptrMesh->_name.c_str()),
- temp,NumberOfCell,
- (med_2_1::med_entite_maillage) Connectivity->_entity,
- (med_2_1::med_geometrie_element) Connectivity->_geometricTypes[i]);
- for(int i2=0;i2<lgthI;i2++)
- MEDArrayFamily[i][i2]=(int)(temp[i2]);
- delete [] temp;
-#else
- err=MEDfamLire(_medIdt,const_cast <char *> (_ptrMesh->_name.c_str()),
- MEDArrayFamily[i],NumberOfCell,
- (med_2_1::med_entite_maillage) Connectivity->_entity,
- (med_2_1::med_geometrie_element) Connectivity->_geometricTypes[i]);
-#endif
-
- // provisoire : si les faces ou les aretes sont des mailles !!!
- if (err != MED_VALID) {
- MESSAGE(LOC<<"search face/edge family on cell !!!");
-#if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
- int lgthI=_ptrMesh->getNumberOfElements(entity,myTypes[i]);
- med_2_1::med_int *temp=new med_2_1::med_int[lgthI];
- err=MEDfamLire(_medIdt,const_cast <char *> (_ptrMesh->_name.c_str()),
- temp,NumberOfCell,
- med_2_1::MED_MAILLE,
- (med_2_1::med_geometrie_element) Connectivity->_geometricTypes[i]);
- for(int i2=0;i2<lgthI;i2++)
- MEDArrayFamily[i][i2]=(int)(temp[i2]);
- delete [] temp;
-#else
- err=MEDfamLire(_medIdt,const_cast <char *> (_ptrMesh->_name.c_str()),
- MEDArrayFamily[i],NumberOfCell,
- med_2_1::MED_MAILLE,
- (med_2_1::med_geometrie_element) Connectivity->_geometricTypes[i]);
-#endif
- }
-
- if (err != MED_VALID)
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Family not found for entity "<<Connectivity->_entity<<" and geometric type "<<Connectivity->_geometricTypes[i]));
-
- }
- return MED_VALID;
- }
- return MED_ERROR;
-}
-
-void MED_MESH_RDONLY_DRIVER::buildAllGroups(vector<GROUP*> & Groups, vector<FAMILY*> & Families)
+void IMED_MESH_RDONLY_DRIVER::buildAllGroups(vector<GROUP*> & Groups, vector<FAMILY*> & Families)
{
const char * LOC = "MED_MESH_RDONLY_DRIVER::buildAllGroups " ;
BEGIN_OF(LOC);
END_OF(LOC);
}
-void MED_MESH_RDONLY_DRIVER::updateFamily()
+void IMED_MESH_RDONLY_DRIVER::updateFamily()
{
const char * LOC = "MED_MESH_RDONLY_DRIVER::updateFamily() " ;
BEGIN_OF(LOC);
}
-void MED_MESH_RDONLY_DRIVER::write( void ) const
+void IMED_MESH_RDONLY_DRIVER::write( void ) const
{
throw MEDEXCEPTION("MED_MESH_RDONLY_DRIVER::write : Can't write with a RDONLY driver !");
}
/*--------------------- WRONLY PART -------------------------------*/
-MED_MESH_WRONLY_DRIVER::MED_MESH_WRONLY_DRIVER():MED_MESH_DRIVER()
+IMED_MESH_WRONLY_DRIVER::IMED_MESH_WRONLY_DRIVER():MED_MESH_DRIVER()
{
}
-MED_MESH_WRONLY_DRIVER::MED_MESH_WRONLY_DRIVER(const string & fileName,
+IMED_MESH_WRONLY_DRIVER::IMED_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::MED_MESH_WRONLY_DRIVER(const MED_MESH_WRONLY_DRIVER & driver):
+IMED_MESH_WRONLY_DRIVER::IMED_MESH_WRONLY_DRIVER(const IMED_MESH_WRONLY_DRIVER & driver):
MED_MESH_DRIVER(driver)
{
}
-MED_MESH_WRONLY_DRIVER::~MED_MESH_WRONLY_DRIVER()
+IMED_MESH_WRONLY_DRIVER::~IMED_MESH_WRONLY_DRIVER()
{
//MESSAGE("MED_MESH_WRONLY_DRIVER::MED_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh) has been destroyed");
}
-GENDRIVER * MED_MESH_WRONLY_DRIVER::copy(void) const
+void IMED_MESH_WRONLY_DRIVER::read (void)
{
- return new MED_MESH_WRONLY_DRIVER(*this);
+ throw MEDEXCEPTION("MED_MESH_WRONLY_DRIVER::read : Can't read with a WRONLY driver !");
}
-void MED_MESH_WRONLY_DRIVER::read (void)
+/*--------------------- RDWR PART -------------------------------*/
+
+IMED_MESH_RDWR_DRIVER::IMED_MESH_RDWR_DRIVER()
{
- throw MEDEXCEPTION("MED_MESH_WRONLY_DRIVER::read : Can't read with a WRONLY driver !");
}
-void MED_MESH_WRONLY_DRIVER::write(void) const
-{
- const char * LOC = "void MED_MESH_WRONLY_DRIVER::write(void) const : ";
- BEGIN_OF(LOC);
+IMED_MESH_RDWR_DRIVER::IMED_MESH_RDWR_DRIVER(const string & fileName,
+ MESH * ptrMesh):
+ IMED_MESH_RDONLY_DRIVER(fileName,ptrMesh),IMED_MESH_WRONLY_DRIVER(fileName,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");
+}
- // we must first create mesh !!
- MESSAGE(LOC << "MeshName : |" << _meshName << "| FileName : |"<<_fileName<<"| MedIdt : | "<< _medIdt << "|");
+IMED_MESH_RDWR_DRIVER::IMED_MESH_RDWR_DRIVER(const IMED_MESH_RDWR_DRIVER & driver):
+ IMED_MESH_RDONLY_DRIVER(driver),IMED_MESH_WRONLY_DRIVER(driver),MED_MESH_DRIVER(driver)
+{
+}
- if (_status!=MED_OPENED)
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "File "<<_fileName<<" is not open. Open it before write !"));
+IMED_MESH_RDWR_DRIVER::~IMED_MESH_RDWR_DRIVER() {
+ //MESSAGE("MED_MESH_RDWR_DRIVER::MED_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh) has been destroyed");
+}
- if (_ptrMesh->getIsAGrid())
- {
- if ( writeGRID() != MED_VALID )
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeGRID()" )) ;
- }
- else
- {
- if (writeCoordinates()!=MED_VALID)
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeCoordinates()" )) ;
-
- if (writeConnectivities(MED_EN::MED_CELL)!=MED_VALID)
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeConnectivities(MED_CELL)" )) ;
- if (writeConnectivities(MED_EN::MED_FACE)!=MED_VALID)
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeConnectivities(MED_FACE)" )) ;
- if (writeConnectivities(MED_EN::MED_EDGE)!=MED_VALID)
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeConnectivities(MED_EDGE)" )) ;
- }
+/////////// Concrete MED_MESH_DRIVERS implementations
- if (writeFamilyNumbers() !=MED_VALID)
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeFamilyNumbers()" )) ;
-
+MED_MESH_RDONLY_DRIVER::MED_MESH_RDONLY_DRIVER()
+{
+ MESSAGE("You are using the default constructor of the Mesh read only Driver and it is 2.1 one");
+ _concreteMeshDrv = new MED_MESH_RDONLY_DRIVER21();
+}
- // well we must first write zero family :
- if (_status==MED_OPENED) {
- int err ;
- // test if the family already exists (HDF trick waiting a MED evolution to be replaced)
- string dataGroupFam = "/ENS_MAA/"+_meshName+"/FAS/FAMILLE_0/";
- MESSAGE("|"<<dataGroupFam<<"|");
- err =_MEDdatagroupOuvrir(_medIdt,const_cast <char *> (dataGroupFam.c_str()) );
- if ( err < MED_VALID ) {
- SCRUTE(err);
-
- err = med_2_1::MEDfamCr( _medIdt,
- const_cast <char *> ( _meshName.c_str() ),
- "FAMILLE_0", 0,
- (med_2_1::med_int*)NULL, (med_2_1::med_int*)NULL, (char*)NULL, 0,
- (char*)NULL, 0);
-
- if ( err != MED_VALID)
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't create family |FAMILLE_0| with identifier |0| groups names || and attributes descriptions ||")) ;
- }
- else
- _MEDdatagroupFermer(_medIdt);
-
- }
+MED_MESH_RDONLY_DRIVER::MED_MESH_RDONLY_DRIVER(const string & fileName, MESH * ptrMesh)
+{
+ _concreteMeshDrv = DRIVERFACTORY::buildMeshDriverFromFile(fileName,ptrMesh,MED_LECT);
+}
- MESSAGE(LOC<<"writeFamilies(_ptrMesh->_familyNode)");
- if (writeFamilies(_ptrMesh->_familyNode) !=MED_VALID)
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeFamilies(_ptrMesh->_familyNode)" )) ;
+MED_MESH_RDONLY_DRIVER::MED_MESH_RDONLY_DRIVER(const MED_MESH_RDONLY_DRIVER & driver):MED_MESH_DRIVER(driver)
+{
+ _concreteMeshDrv = driver._concreteMeshDrv->copy();
+}
- MESSAGE(LOC<<"writeFamilies(_ptrMesh->_familyCell)");
- if (writeFamilies(_ptrMesh->_familyCell) !=MED_VALID)
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeFamilies(_ptrMesh->_familyCell)" )) ;
+MED_MESH_RDONLY_DRIVER::~MED_MESH_RDONLY_DRIVER()
+{
+ if (_concreteMeshDrv) delete _concreteMeshDrv;
+}
- MESSAGE(LOC<<"writeFamilies(_ptrMesh->_familyFace)");
- if (writeFamilies(_ptrMesh->_familyFace) !=MED_VALID)
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeFamilies(_ptrMesh->_familyFace)" )) ;
+void MED_MESH_RDONLY_DRIVER::write( void ) const
+{
+ _concreteMeshDrv->write();
+}
- MESSAGE(LOC<<"writeFamilies(_ptrMesh->_familyEdge)");
- if (writeFamilies(_ptrMesh->_familyEdge) !=MED_VALID)
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeFamilies(_ptrMesh->_familyEdge)" )) ;
+void MED_MESH_RDONLY_DRIVER::read ( void )
+{
+ _concreteMeshDrv->read();
+}
- END_OF(LOC);
-}
+void MED_MESH_RDONLY_DRIVER::open()
+{
+ _concreteMeshDrv->open();
+}
-//=======================================================================
-//function : writeGRID
-//purpose :
-//=======================================================================
+void MED_MESH_RDONLY_DRIVER::close()
+{
+ _concreteMeshDrv->close();
+}
-int MED_MESH_WRONLY_DRIVER::writeGRID() const
+void MED_MESH_RDONLY_DRIVER::setMeshName(const string & meshName)
{
- const char * LOC = "MED_MESH_WRONLY_DRIVER::writeGRID() : " ;
- BEGIN_OF(LOC);
-
- if (_status!=MED_OPENED)
- {
- MESSAGE (LOC<<" Not open !!!");
- return MED_ERROR;
- }
- GRID * ptrGrid = (GRID*) _ptrMesh;
-
- med_2_1::med_err err = MED_ERROR;
- med_2_1::med_repere rep;
- string tmp_name(_ptrMesh->_spaceDimension*MED_TAILLE_PNOM,' ');
- string tmp_unit(_ptrMesh->_spaceDimension*MED_TAILLE_PNOM,' ');
-
- // Test if the mesh <_meshName> already exists
- // If it doesn't exists create it
- // If it already exists verify if its dimension is the same as <_ptrMesh->_spaceDimension>
- // rem : <_meshName> is the driver meshName not <ptrMesh->_meshName>
- int dim = med_2_1::MEDdimLire(_medIdt, const_cast <char *> (_meshName.c_str()) );
- if (dim < MED_VALID)
- {
- err = med_2_1::MEDgridCr(_medIdt,
- const_cast <char *> (_meshName.c_str()),
- _ptrMesh->_spaceDimension,
- (med_2_1::med_grid_type) ptrGrid->getGridType());
- if (err != MED_VALID)
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Unable to create Grid"));
- else
- MESSAGE(LOC<<"Grid "<<_meshName<<" created in file "<<_fileName<<" !");
- }
- else if (dim != _ptrMesh->_spaceDimension)
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Grid |" << _meshName.c_str() <<
- "| already exists in file |" << _fileName <<
- "| with dimension |" << dim <<
- "| but the dimension of the mesh we want to write is |"
- << _ptrMesh->_spaceDimension <<"|" )) ;
-
- // Recompose the <_spaceDimension> strings in 1 string
- int lengthString ;
- string valueString ;
- for (int i=0;i<_ptrMesh->_spaceDimension;i++) {
- SCRUTE(i);
- valueString = _ptrMesh->_coordinate->_coordinateName[i] ;
- lengthString = (MED_TAILLE_PNOM<valueString.size())?MED_TAILLE_PNOM:valueString.size() ;
- tmp_name.replace(i*MED_TAILLE_PNOM,i*MED_TAILLE_PNOM+lengthString,valueString,0,lengthString);
- valueString = _ptrMesh->_coordinate->_coordinateUnit[i];
- lengthString = (MED_TAILLE_PNOM<valueString.size())?MED_TAILLE_PNOM:valueString.size() ;
- tmp_unit.replace(i*MED_TAILLE_PNOM,i*MED_TAILLE_PNOM+lengthString,valueString,0,lengthString);
- }
+ _concreteMeshDrv->setMeshName(meshName);
+}
- // Pourquoi le stocker sous forme de chaîne ?
- const string & coordinateSystem = _ptrMesh->_coordinate->_coordinateSystem;
- if (coordinateSystem == "CARTESIAN")
- rep = med_2_1::MED_CART;
- else if ( coordinateSystem == "CYLINDRICAL")
- rep = med_2_1::MED_CYL;
- else if ( coordinateSystem == "SPHERICAL" )
- rep = med_2_1::MED_SPHER;
- else
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Grid |" << _meshName.c_str() <<
- "| doesn't have a valid coordinate system : |"
- << _ptrMesh->_coordinate->_coordinateSystem
- << "|" )) ;
-
- med_2_1::med_int ArrayLen[] = { (med_2_1::med_int) ptrGrid->_iArrayLength,
- (med_2_1::med_int) ptrGrid->_jArrayLength,
- (med_2_1::med_int) ptrGrid->_kArrayLength };
-
- // Write node coordinates for MED_BODY_FITTED grid
- if (ptrGrid->getGridType() == MED_EN::MED_BODY_FITTED)
- {
-
- // Write Coordinates and families
- double * coo = const_cast <double *>
- (_ptrMesh->_coordinate->getCoordinates(MED_EN::MED_FULL_INTERLACE));
-
- // Write unused families
- //CCRT unused => med_2_1::med_int
- med_2_1::med_int * MEDArrayNodeFamily = new med_2_1::med_int[_ptrMesh->_numberOfNodes] ;
-
- err = MEDbodyFittedEcr (_medIdt,
- const_cast <char *> (_ptrMesh->_name.c_str()),
- _ptrMesh->_spaceDimension,
- coo,
- ArrayLen,
- med_2_1::MED_FULL_INTERLACE,
- rep,
- const_cast <char *> (tmp_name.c_str()),
- const_cast <char *> (tmp_unit.c_str()),
- MEDArrayNodeFamily,
- _ptrMesh->_numberOfNodes,
- med_2_1::MED_REMP);
- delete[] MEDArrayNodeFamily;
-
- if (err != MED_VALID)
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"error in MEDbodyFittedEcr()"));
+string MED_MESH_RDONLY_DRIVER::getMeshName() const
+{
+ return MED_MESH_DRIVER::getMeshName();
+}
- }
- else
- {
- // Write Arrays of Cartesian or Polar Grid
-
- double * Array[] = { ptrGrid->_iArray,
- ptrGrid->_jArray,
- ptrGrid->_kArray };
- int idim;
- for (idim = 0; idim < _ptrMesh->_spaceDimension; ++idim)
- {
- err = med_2_1::MEDgridEcr (_medIdt,
- const_cast <char *> (_ptrMesh->_name.c_str()),
- _ptrMesh->_spaceDimension,
- Array [idim],
- ArrayLen [idim],
- idim,
- med_2_1::MED_FULL_INTERLACE,
- rep,
- const_cast <char *> (tmp_name.c_str()),
- const_cast <char *> (tmp_unit.c_str()),
- med_2_1::MED_REMP);
- if (err != MED_VALID)
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't read grid coordinates for "
- << idim << "-th dimention"));
- }
+GENDRIVER * MED_MESH_RDONLY_DRIVER::copy ( void ) const
+{
+ return new MED_MESH_RDONLY_DRIVER(*this);
+}
-// err = MEDfamGridEcr(_medIdt,
-// const_cast <char *> (_ptrMesh->_name.c_str()),
-// _ptrMesh->_MEDArrayNodeFamily,
-// _ptrMesh->_numberOfNodes,
-// med_2_1::MED_REMP,
-// med_2_1::MED_NOEUD);
- if (err != MED_VALID)
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"error in MEDfamGridEcr()"));
+// int MED_MESH_RDONLY_DRIVER::getCOORDINATE()
+// {
+// return _concreteMeshDrv->getCOORDINATE();
+// }
- } // end Write Cartesian or Polar Grid
+// int MED_MESH_RDONLY_DRIVER::getCONNECTIVITY()
+// {
+// return _concreteMeshDrv->getCONNECTIVITY();
+// }
- END_OF(LOC);
- return MED_VALID;
-}
+// int MED_MESH_RDONLY_DRIVER::getFAMILY()
+// {
+// return _concreteMeshDrv->getFAMILY();
+// }
-//=======================================================================
-//function : writeCoordinates
-//purpose :
-//=======================================================================
+// int MED_MESH_RDONLY_DRIVER::getNodalConnectivity(CONNECTIVITY * Connectivity)
+// {
+// return _concreteMeshDrv->getNodalConnectivity(Connectivity);
+// }
-int MED_MESH_WRONLY_DRIVER::writeCoordinates() const {
-
- const char * LOC = "int MED_MESH_WRONLY_DRIVER::writeCoordinates() const : ";
- BEGIN_OF(LOC);
+// int MED_MESH_RDONLY_DRIVER::getDescendingConnectivity(CONNECTIVITY * Connectivity)
+// {
+// return _concreteMeshDrv->getDescendingConnectivity(Connectivity);
+// }
- med_2_1::med_err err = MED_ERROR;
- med_2_1::med_repere rep;
- string tmp_name(_ptrMesh->_spaceDimension*MED_TAILLE_PNOM,' ');
- string tmp_unit(_ptrMesh->_spaceDimension*MED_TAILLE_PNOM,' ');
-
- // Recompose the <_spaceDimension> strings in 1 string
- int lengthString ;
- string valueString ;
- for (int i=0;i<_ptrMesh->_spaceDimension;i++) {
- valueString = _ptrMesh->_coordinate->_coordinateName[i] ;
- lengthString = (MED_TAILLE_PNOM<valueString.size())?MED_TAILLE_PNOM:valueString.size() ;
- tmp_name.replace(i*MED_TAILLE_PNOM,i*MED_TAILLE_PNOM+lengthString,valueString,0,lengthString);
- valueString = _ptrMesh->_coordinate->_coordinateUnit[i];
- lengthString = (MED_TAILLE_PNOM<valueString.size())?MED_TAILLE_PNOM:valueString.size() ;
- tmp_unit.replace(i*MED_TAILLE_PNOM,i*MED_TAILLE_PNOM+lengthString,valueString,0,lengthString);
- }
+// int MED_MESH_RDONLY_DRIVER::getNodesFamiliesNumber(int * MEDArrayNodeFamily)
+// {
+// return _concreteMeshDrv->getNodesFamiliesNumber(MEDArrayNodeFamily);
+// }
- // Test if the mesh <_meshName> already exists
- // If it doesn't exists create it
- // If it already exists verify if its dimension is the same as <_ptrMesh->_spaceDimension>
- // rem : <_meshName> is the driver meshName not <ptrMesh->_meshName>
- int dim = med_2_1::MEDdimLire(_medIdt, const_cast <char *> (_meshName.c_str()) );
- if (dim < MED_VALID)
- if (med_2_1::MEDmaaCr(_medIdt,const_cast <char *> (_meshName.c_str()),_ptrMesh->_spaceDimension) != 0 )
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Unable to create Mesh : |" << _meshName << "|"));
- else
- {
- MESSAGE(LOC<<"Mesh "<<_meshName<<" created in file "<<_fileName<<" !");
- }
- else if (dim != _ptrMesh->_spaceDimension)
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Mesh |" << _meshName.c_str() << "| already exists in file |" << _fileName
- << "| with dimension |" << dim << "| but the dimension of the mesh we want to write is |"
- << _ptrMesh->_spaceDimension <<"|" )) ;
-
- // Pourquoi le stocker sous forme de chaîne ?
- const string & coordinateSystem = _ptrMesh->_coordinate->_coordinateSystem;
- if (coordinateSystem == "CARTESIAN")
- rep = med_2_1::MED_CART;
- else if ( coordinateSystem == "CYLINDRICAL")
- rep = med_2_1::MED_CYL;
- else if ( coordinateSystem == "SPHERICAL" )
- rep = med_2_1::MED_SPHER;
- else
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Mesh |" << _meshName.c_str() << "| doesn't have a valid coordinate system : |"
- << _ptrMesh->_coordinate->_coordinateSystem
- << "|" )) ;
-
- err = MEDcoordEcr(_medIdt, const_cast <char *> (_meshName.c_str()),
- _ptrMesh->_spaceDimension,
- //const_cast <double *> ( _ptrMesh->_coordinate->_coordinate->get(MED_EN::MED_FULL_INTERLACE) ),
- const_cast <double *> ( _ptrMesh->_coordinate->_coordinate.get(MED_EN::MED_FULL_INTERLACE) ),
- med_2_1::MED_FULL_INTERLACE,
- _ptrMesh->_numberOfNodes, // _ptrMesh->_coordinate->_numberOfNodes
- med_2_1::MED_REMP,
- rep,
- const_cast <char *> (tmp_name.c_str()),
- const_cast <char *> (tmp_unit.c_str())
- );
-
- if (err<0)
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write coordinates of mesh |" << _meshName.c_str() << "| in file |" << _fileName
- << "| with dimension |" << _ptrMesh->_spaceDimension <<"| and"
- << " with units names |" << tmp_name
- << "| and units |" << tmp_unit
- << " |")) ;
-
-
- //////////////////////////////////////////////////////////////////////////////////////
- /// Modification pour prise en compte de la numérotation optionnelle des noeuds ///
- //////////////////////////////////////////////////////////////////////////////////////
- ///
- /// Ecrit les numéros optionnels des noeuds
- /// Le traitement est identique à la version originelle s'il n'y a pas de numérotation optionnelle
-
-
- if (_ptrMesh->_arePresentOptionnalNodesNumbers==1) {
-#if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
- int lgth=_ptrMesh->_coordinate->getNumberOfNodes();
- med_2_1::med_int *temp=new med_2_1::med_int[lgth];
- for(int i2=0;i2<lgth;i2++)
- temp[i2]=(med_2_1::med_int)(_ptrMesh->_coordinate->getNodesNumbers()[i2]);
- err = MEDnumEcr(_medIdt,const_cast <char *> (_meshName.c_str()),
- temp,
- _ptrMesh->_numberOfNodes, med_2_1::MED_REMP,
- med_2_1::MED_NOEUD, med_2_1::med_geometrie_element(0) );
- delete [] temp;
-#else
- err = MEDnumEcr(_medIdt,const_cast <char *> (_meshName.c_str()),
- const_cast <int *> (_ptrMesh->_coordinate->getNodesNumbers() ),
- _ptrMesh->_numberOfNodes, med_2_1::MED_REMP,
- med_2_1::MED_NOEUD, med_2_1::med_geometrie_element(0) );
-#endif
-
- if (err<0)
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write optionnal numbers of mesh |" << _meshName.c_str()
- << "| in file |" << _fileName << " |")) ;
- }
- //////////////////////////////////////////////////////////////////////////////////////
+// int MED_MESH_RDONLY_DRIVER::getCellsFamiliesNumber(int** Arrays, CONNECTIVITY* Connectivity, MED_EN::medEntityMesh entity)
+// {
+// return _concreteMeshDrv->getCellsFamiliesNumber(Arrays,Connectivity,entity);
+// }
- END_OF(LOC);
-
- return MED_VALID;
+// void MED_MESH_RDONLY_DRIVER::getGRID()
+// {
+// _concreteMeshDrv->getGRID();
+// }
+
+MED_MESH_WRONLY_DRIVER::MED_MESH_WRONLY_DRIVER()
+{
+ MESSAGE("You are using the default constructor of the Mesh write only Driver and it is 2.1 one");
+ _concreteMeshDrv = new MED_MESH_WRONLY_DRIVER21();
}
+MED_MESH_WRONLY_DRIVER::MED_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh)
+{
+ _concreteMeshDrv = DRIVERFACTORY::buildMeshDriverFromFile(fileName,ptrMesh,MED_ECRI);
+}
+MED_MESH_WRONLY_DRIVER::MED_MESH_WRONLY_DRIVER(const MED_MESH_WRONLY_DRIVER & driver):MED_MESH_DRIVER(driver)
+{
+ _concreteMeshDrv = driver._concreteMeshDrv->copy();
+}
+MED_MESH_WRONLY_DRIVER::~MED_MESH_WRONLY_DRIVER()
+{
+ if (_concreteMeshDrv) delete _concreteMeshDrv;
+}
-int MED_MESH_WRONLY_DRIVER::writeConnectivities(medEntityMesh entity) const {
-
- const char * LOC="int MED_MESH_WRONLY_DRIVER::writeConnectivities() const : ";
- BEGIN_OF(LOC);
+void MED_MESH_WRONLY_DRIVER::open()
+{
+ _concreteMeshDrv->open();
+}
- med_2_1::med_err err;
-
- // REM SI LA METHODE EST APPELEE DIRECTEMENT ET QUE LE MAILLAGE N'EST PAS CREE IL Y A PB !
- // PG : IMPOSSIBLE : LA METHODE EST PRIVEE !
-
- // A FAIRE : A tester surtout dans les methodes de MESH.
- // if ( _ptrMesh->_connectivity == (CONNECTIVITY *) MED_INVALID )
- if ( _ptrMesh->_connectivity == (CONNECTIVITY *) NULL )
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "The connectivity is not defined in the MESH object ")) ;
-
- if ( _ptrMesh->existConnectivity(MED_NODAL,entity) ) {
-
- int numberOfTypes = _ptrMesh->getNumberOfTypes (entity) ;
- const medGeometryElement * types = _ptrMesh->getTypes (entity) ;
-
- for (int i=0; i<numberOfTypes; i++) {
-
- int numberOfElements = _ptrMesh->getNumberOfElements (entity,types[i]);
- const int * connectivity = _ptrMesh->getConnectivity (MED_EN::MED_FULL_INTERLACE,
- MED_NODAL, entity, types[i]); // ?? et SI MED_NODAL n'existe pas, recalcul auto ??
-
- // Pour l'instant la class utilise le multi.....
- int multi = 0 ;
- if (entity==MED_EN::MED_CELL)
- if ( (types[i]/ 100) < _ptrMesh->_spaceDimension)
- multi=1 ;
- int numberOfNodes = types[i]%100 ;
- int * connectivityArray = new int[numberOfElements*(numberOfNodes+multi)];
-
- // version originale sans prise en compte des numéros optionnels
- //
- for (int j=0 ; j<numberOfElements; j++)
- {
- for (int k=0; k<numberOfNodes; k++)
- connectivityArray[j*(numberOfNodes+multi)+k]=connectivity[j*numberOfNodes+k] ;
-
- if (multi>0) connectivityArray[j*(numberOfNodes+multi)+numberOfNodes]=0;
- }
-
- //////////////////////////////////////////////////////////////////////////////////////
- /// Modification pour prise en compte de la numérotation optionnelle des noeuds ///
- //////////////////////////////////////////////////////////////////////////////////////
- ///
- /// Dénumérote les sommets des mailles pour leur rendre leurs numéros optionnels
- /// Le traitement est identique à la version originelle s'il n'y a pas de numérotation optionnelle
-
-// if (_ptrMesh->_arePresentOptionnalNodesNumbers==1)
-// {
-// const int * nodesNumbers = _ptrMesh->_coordinate->getNodesNumbers();
-// for (int j=0 ; j<numberOfElements; j++)
-// {
-// for (int k=0; k<numberOfNodes; k++) connectivityArray[j*(numberOfNodes+multi)+k]=nodesNumbers[connectivity[j*numberOfNodes+k]-1] ;
-// if (multi>0) connectivityArray[j*(numberOfNodes+multi)+numberOfNodes]=0;
-// }
-// }
-// else
-// {
-// for (int j=0 ; j<numberOfElements; j++)
-// {
-// for (int k=0; k<numberOfNodes; k++) connectivityArray[j*(numberOfNodes+multi)+k]=connectivity[j*numberOfNodes+k] ;
-// if (multi>0) connectivityArray[j*(numberOfNodes+multi)+numberOfNodes]=0;
-// }
-// }
-
- //////////////////////////////////////////////////////////////////////////////////////
-#if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
- int lgth=numberOfElements*(numberOfNodes+multi);
- med_2_1::med_int *temp=new med_2_1::med_int[lgth];
- for(int i2=0;i2<lgth;i2++)
- temp[i2]=(med_2_1::med_int)(connectivityArray[i2]);
- err = MEDconnEcr( _medIdt, const_cast <char *> ( _meshName.c_str()), _ptrMesh->_spaceDimension,
- temp, med_2_1::MED_FULL_INTERLACE , numberOfElements,
- med_2_1::MED_REMP,
- (med_2_1::med_entite_maillage ) entity,
- (med_2_1::med_geometrie_element) types[i], med_2_1::MED_NOD );
- delete [] temp;
-#else
- err = MEDconnEcr( _medIdt, const_cast <char *> ( _meshName.c_str()), _ptrMesh->_spaceDimension,
- connectivityArray, med_2_1::MED_FULL_INTERLACE , numberOfElements,
- med_2_1::MED_REMP,
- (med_2_1::med_entite_maillage ) entity,
- (med_2_1::med_geometrie_element) types[i], med_2_1::MED_NOD );
-#endif
- delete[] connectivityArray ;
- if (err<0) // ETENDRE LES EXPLICATIONS
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write connectivities of mesh |" << _meshName.c_str() << "| in file |" << _fileName
- << "| with dimension |" << _ptrMesh->_spaceDimension <<"| and"
- )) ;
- }
- }
- // Connctivity descending :
- if ( _ptrMesh->existConnectivity(MED_DESCENDING,entity) ) {
-
- int numberOfTypes = _ptrMesh->getNumberOfTypes (entity) ;
- const medGeometryElement * types = _ptrMesh->getTypes (entity) ;
-
- for (int i=0; i<numberOfTypes; i++) {
-
- int numberOfElements = _ptrMesh->getNumberOfElements (entity,types[i]);
- const int * connectivity = _ptrMesh->getConnectivity(MED_EN::MED_FULL_INTERLACE, MED_DESCENDING, entity, types[i]);
-
- // Pour l'instant la class utilise le multi.....
-#if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
- int lgth=_ptrMesh->getConnectivityLength(MED_EN::MED_FULL_INTERLACE, MED_DESCENDING, entity, types[i]);
- med_2_1::med_int *temp=new med_2_1::med_int[lgth];
- for(int i2=0;i2<lgth;i2++)
- temp[i2]=(med_2_1::med_int)(connectivity[i2]);
- err = med_2_1::MEDconnEcr( _medIdt,
- const_cast <char *> ( _meshName.c_str()),
- _ptrMesh->_spaceDimension,
- temp,
- med_2_1::MED_FULL_INTERLACE,
- numberOfElements,
- med_2_1::MED_REMP,
- (med_2_1::med_entite_maillage ) entity,
- (med_2_1::med_geometrie_element) types[i],
- med_2_1::MED_DESC );
- delete [] temp;
-#else
- err = med_2_1::MEDconnEcr( _medIdt,
- const_cast <char *> ( _meshName.c_str()),
- _ptrMesh->_spaceDimension,
- const_cast <int *> (connectivity),
- med_2_1::MED_FULL_INTERLACE,
- numberOfElements,
- med_2_1::MED_REMP,
- (med_2_1::med_entite_maillage ) entity,
- (med_2_1::med_geometrie_element) types[i],
- med_2_1::MED_DESC );
-#endif
-
- if (err<0) // ETENDRE LES EXPLICATIONS
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write connectivities of mesh |" << _meshName.c_str() << "| in file |" << _fileName
- << "| with dimension |" << _ptrMesh->_spaceDimension <<"| and"
- )) ;
-
- }
- }
- END_OF(LOC);
- return MED_VALID;
+void MED_MESH_WRONLY_DRIVER::close()
+{
+ _concreteMeshDrv->close();
}
-int MED_MESH_WRONLY_DRIVER::writeFamilyNumbers() const {
-
- const char * LOC="int MED_MESH_WRONLY_DRIVER::writeFamilyNumbers() const : ";
- BEGIN_OF(LOC);
+void MED_MESH_WRONLY_DRIVER::setMeshName(const string & meshName)
+{
+ _concreteMeshDrv->setMeshName(meshName);
+}
- med_2_1::med_err err;
-
- // SOLUTION TEMPORAIRE CAR _ptrMesh->_MEDArrayNodeFamily DOIT ETRE ENLEVER DE LA CLASSE MESH
-
- { // Node related block
-
- // We build the array from the families list objects :
- int NumberOfNodes = _ptrMesh->getNumberOfNodes() ;
- int * MEDArrayNodeFamily = new int[NumberOfNodes] ;
- // family 0 by default
- for (int i=0; i<NumberOfNodes; i++)
- MEDArrayNodeFamily[i]=0;
- //vector<FAMILY*> myFamilies = _ptrMesh->getFamilies(MED_NODE);
- vector<FAMILY*> * myFamilies = &_ptrMesh->_familyNode;
- int NumberOfNodesFamilies = myFamilies->size() ;
- //bool ToDestroy = false;
- if (0 == NumberOfNodesFamilies) {
- //ToDestroy = true ;
- vector<GROUP*> myGroups = _ptrMesh->getGroups(MED_NODE);
- int NumberOfGroups = myGroups.size() ;
- // build families from groups
- for (int i=0; i<NumberOfGroups; i++) {
- SUPPORT * mySupport = myGroups[i] ;
- FAMILY* myFamily = new FAMILY(*mySupport);
- myFamily->setIdentifier(i+1);
- myFamilies->push_back(myFamily);
- }
- NumberOfNodesFamilies=myFamilies->size() ;
- }
- for (int i=0 ; i<NumberOfNodesFamilies; i++) {
- //SCRUTE(i);
- //SCRUTE(myFamilies[i]->getName());
- int FamilyIdentifier = (*myFamilies)[i]->getIdentifier() ;
- int TotalNumber = (*myFamilies)[i]->getNumberOfElements(MED_ALL_ELEMENTS) ;
- if ((*myFamilies)[i]->isOnAllElements())
- for (int j=0; j<TotalNumber; j++)
- MEDArrayNodeFamily[j]=FamilyIdentifier;
- else {
- const int * Number = (*myFamilies)[i]->getNumber(MED_ALL_ELEMENTS) ;
- for (int j=0; j<TotalNumber; j++)
- MEDArrayNodeFamily[Number[j]-1]=FamilyIdentifier ;
- }
- }
- for(int j=0; j<NumberOfNodes; j++) {
- SCRUTE(MEDArrayNodeFamily[j]);
- }
- if ( !_ptrMesh->getIsAGrid() ){
-#if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
- int lgth=NumberOfNodes;
- med_2_1::med_int *temp=new med_2_1::med_int[lgth];
- for(int i2=0;i2<lgth;i2++)
- temp[i2]=(med_2_1::med_int)(MEDArrayNodeFamily[i2]);
- err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
- temp, NumberOfNodes,med_2_1::MED_REMP ,
- med_2_1::MED_NOEUD,
- (med_2_1::med_geometrie_element) MED_NONE);
- delete [] temp;
-#else
- err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
- MEDArrayNodeFamily, NumberOfNodes,med_2_1::MED_REMP ,
- med_2_1::MED_NOEUD,
- (med_2_1::med_geometrie_element) MED_NONE);
-#endif
- }
- else{
-#if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
- int lgth=NumberOfNodes;
- med_2_1::med_int *temp=new med_2_1::med_int[lgth];
- for(int i2=0;i2<lgth;i2++)
- temp[i2]=(med_2_1::med_int)(MEDArrayNodeFamily[i2]);
- err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
- temp, NumberOfNodes,med_2_1::MED_REMP ,
- med_2_1::MED_NOEUD,
- (med_2_1::med_geometrie_element) MED_NONE);
- delete [] temp;
-#else
- err = MEDfamGridEcr(_medIdt,
- const_cast <char *> (_ptrMesh->_name.c_str()),
- MEDArrayNodeFamily,
- NumberOfNodes,
- med_2_1::MED_REMP,
- med_2_1::MED_NOEUD);
-#endif
- }
+string MED_MESH_WRONLY_DRIVER::getMeshName() const
+{
+ return MED_MESH_DRIVER::getMeshName();
+}
- if ( err != MED_VALID)
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't write node family for the |"<< NumberOfNodes
- << "| nodes in mesh |"
- << _ptrMesh->_name.c_str() << "|" ));
- delete[] MEDArrayNodeFamily;
- //if (true == ToDestroy)
- // for (int i=0; i<NumberOfNodesFamilies; i++)
- // delete myFamilies[i];
- }
-
- { // CELLS RELATED BLOCK
- medEntityMesh entity=MED_EN::MED_CELL;
- // SOLUTION TEMPORAIRE CAR _ptrMesh->_MEDArray____Family DOIT ETRE ENLEVER DE LA CLASSE MESH
- if ( ( _ptrMesh->existConnectivity(MED_NODAL,entity) )|( _ptrMesh->existConnectivity(MED_DESCENDING,entity) ) ) {
-
- int numberOfTypes = _ptrMesh->getNumberOfTypes (entity) ;
- const medGeometryElement * types = _ptrMesh->getTypes (entity) ;
-
- // We build the array from the families list objects :
- int NumberOfElements = _ptrMesh->getNumberOfElements(entity, MED_ALL_ELEMENTS);
- int * MEDArrayFamily = new int[NumberOfElements] ;
- // family 0 by default
- for (int i=0; i<NumberOfElements; i++)
- MEDArrayFamily[i]=0;
- //vector<FAMILY*> myFamilies = _ptrMesh->getFamilies(entity);
- vector<FAMILY*> * myFamilies = &_ptrMesh->_familyCell ;
- int NumberOfFamilies = myFamilies->size() ;
- //bool ToDestroy = false;
- if (0 == NumberOfFamilies) {
- //ToDestroy = true ;
- vector<GROUP*> myGroups = _ptrMesh->getGroups(entity);
- int NumberOfGroups = myGroups.size() ;
- // build families from groups
- for (int i=0; i<NumberOfGroups; i++) {
- SCRUTE( myGroups[i]->getName() );
- SUPPORT * mySupport = myGroups[i] ;
- FAMILY* myFamily = new FAMILY(*mySupport);
- myFamily->setIdentifier(-i-1);
- myFamilies->push_back(myFamily);
- }
- NumberOfFamilies=myFamilies->size() ;
- }
- for (int i=0 ; i<NumberOfFamilies; i++) {
- int FamilyIdentifier = (*myFamilies)[i]->getIdentifier() ;
- int TotalNumber = (*myFamilies)[i]->getNumberOfElements(MED_ALL_ELEMENTS) ;
- if ((*myFamilies)[i]->isOnAllElements())
- for (int ii=0; ii<TotalNumber; ii++)
- MEDArrayFamily[ii]=FamilyIdentifier;
- else {
- const int * Number = (*myFamilies)[i]->getNumber(MED_ALL_ELEMENTS) ;
- for (int ii=0; ii<TotalNumber; ii++)
- MEDArrayFamily[Number[ii]-1]=FamilyIdentifier ;
- }
- }
-
- const int * typeCount = _ptrMesh->getGlobalNumberingIndex(entity) ;
-#if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
- int lgth=NumberOfElements;
- med_2_1::med_int *temp=new med_2_1::med_int[lgth];
- for(int i2=0;i2<lgth;i2++)
- temp[i2]=(med_2_1::med_int) (MEDArrayFamily[i2]);
-#endif
- for (int i=0; i<numberOfTypes; i++) {
-#if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
- err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
- temp+typeCount[i]-1,typeCount[i+1]-typeCount[i],
- med_2_1::MED_REMP ,
- (med_2_1::med_entite_maillage) entity,
- (med_2_1::med_geometrie_element) types[i]
-);
-#else
- err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
- MEDArrayFamily+typeCount[i]-1,typeCount[i+1]-typeCount[i],
- med_2_1::MED_REMP ,
- (med_2_1::med_entite_maillage) entity,
- (med_2_1::med_geometrie_element) types[i]
-);
-#endif
- MESSAGE("OK "<<i);
- if ( err != MED_VALID)
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't write family for the |"<< _ptrMesh->getNumberOfElements(entity, types[i])
- << "| cells of geometric type |" << geoNames[ types[i]] <<"|in mesh |"
- << _ptrMesh->_name.c_str() << "|" ));
- }
-#if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
- delete [] temp;
-#endif
- delete[] MEDArrayFamily ;
- //if (true == ToDestroy) {
- // int NumberOfFamilies = myFamilies->size();
- // for (int i=0; i<NumberOfFamilies; i++)
- // delete myFamilies[i];
- //}
- }
- }
+GENDRIVER * MED_MESH_WRONLY_DRIVER::copy ( void ) const
+{
+ return new MED_MESH_WRONLY_DRIVER(*this);
+}
- { // FACE RELATED BLOCK
- medEntityMesh entity=MED_EN::MED_FACE;
- // SOLUTION TEMPORAIRE CAR _ptrMesh->_MEDArray____Family DOIT ETRE ENLEVER DE LA CLASSE MESH
- if ( ( _ptrMesh->existConnectivity(MED_NODAL,entity) )|( _ptrMesh->existConnectivity(MED_DESCENDING,entity) ) ) {
-
- int numberOfTypes = _ptrMesh->getNumberOfTypes (entity) ;
- const medGeometryElement * types = _ptrMesh->getTypes (entity) ;
- SCRUTE(numberOfTypes);
-
- int numberOfElements = _ptrMesh->getNumberOfElements(entity, MED_ALL_ELEMENTS) ;
- int * familyArray = new int[numberOfElements] ;
- for (int i=0;i<numberOfElements;i++)
- familyArray[i]=0;
-
- int numberOfFamilies = _ptrMesh->getNumberOfFamilies(entity) ;
- //vector<FAMILY*> myFamilies = _ptrMesh->getFamilies(entity) ;
- vector<FAMILY*> * myFamilies = &_ptrMesh->_familyFace ;
- //bool ToDestroy = false;
- if (0 == numberOfFamilies) {
- //ToDestroy = true ;
- vector<GROUP*> myGroups = _ptrMesh->getGroups(entity);
- int NumberOfGroups = myGroups.size() ;
- // build families from groups
- for (int i=0; i<NumberOfGroups; i++) {
- SCRUTE( myGroups[i]->getName() );
- SUPPORT * mySupport = myGroups[i] ;
- FAMILY* myFamily = new FAMILY(*mySupport);
- myFamily->setIdentifier(-i-1000);
- myFamilies->push_back(myFamily);
- }
- numberOfFamilies=myFamilies->size() ;
- }
- for (int i=0;i<numberOfFamilies;i++) {
- int familyNumber = (*myFamilies)[i]->getIdentifier() ;
- int numberOfFamilyElements = (*myFamilies)[i]->getNumberOfElements(MED_ALL_ELEMENTS) ;
- if ((*myFamilies)[i]->isOnAllElements())
- for (int ii=0; ii<numberOfFamilyElements; ii++)
- familyArray[ii]=familyNumber;
- else {
- const int * myFamilyElements = (*myFamilies)[i]->getNumber(MED_ALL_ELEMENTS) ;
- for (int ii=0;ii<numberOfFamilyElements;ii++)
- familyArray[myFamilyElements[ii]-1]=familyNumber;
- }
- }
-
- const int * typeCount = _ptrMesh->getGlobalNumberingIndex(entity) ;
-#if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
- int lgth=numberOfElements;
- med_2_1::med_int *temp=new med_2_1::med_int[lgth];
- for(int i2=0;i2<lgth;i2++)
- temp[i2]=(med_2_1::med_int) (familyArray[i2]);
-#endif
- for (int i=0; i<numberOfTypes; i++) {
-
- int typeNumberOfElements = typeCount[i+1] - typeCount[i] ;
-#if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
- err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
- temp+typeCount[i]-1, typeNumberOfElements,
- med_2_1::MED_REMP ,
- (med_2_1::med_entite_maillage) entity,
- (med_2_1::med_geometrie_element) types[i]);
-#else
- err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
- familyArray+typeCount[i]-1, typeNumberOfElements,
- med_2_1::MED_REMP ,
- (med_2_1::med_entite_maillage) entity,
- (med_2_1::med_geometrie_element) types[i]);
-#endif
- if ( err != MED_VALID)
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't write family for the |"<< _ptrMesh->getNumberOfElements(entity, types[i])
- << "| faces of geometric type |" << geoNames[types[i]] <<"|in mesh |"
- << _ptrMesh->_name.c_str() << "|" ));
- }
-#if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
- delete [] temp;
-#endif
- delete[] familyArray ;
- //if (true == ToDestroy) {
- // int NumberOfFamilies = myFamilies->size();
- // for (int i=0; i<NumberOfFamilies; i++)
- // delete myFamilies[i];
- //}
- }
- }
+void MED_MESH_WRONLY_DRIVER::MED_MESH_WRONLY_DRIVER::read ( void )
+{
+ _concreteMeshDrv->read();
+}
- { // EDGE RELATED BLOCK
- //medEntityMesh entity=MED_EN::MED_FACE;
- medEntityMesh entity=MED_EN::MED_EDGE;
- // SOLUTION TEMPORAIRE CAR _ptrMesh->_MEDArray____Family DOIT ETRE ENLEVER DE LA CLASSE MESH
- if ( ( _ptrMesh->existConnectivity(MED_NODAL,entity) )|( _ptrMesh->existConnectivity(MED_DESCENDING,entity) ) ) {
-
- int numberOfTypes = _ptrMesh->getNumberOfTypes (entity) ;
- const medGeometryElement * types = _ptrMesh->getTypes (entity) ;
-
- int numberOfElements = _ptrMesh->getNumberOfElements(entity, MED_ALL_ELEMENTS) ;
- int * familyArray = new int[numberOfElements] ;
- for (int i=0;i<numberOfElements;i++)
- familyArray[i]=0;
-
- int numberOfFamilies = _ptrMesh->getNumberOfFamilies(entity) ;
- //vector<FAMILY*> myFamilies = _ptrMesh->getFamilies(entity) ;
- vector<FAMILY*> * myFamilies = &_ptrMesh->_familyEdge ;
- //bool ToDestroy = false;
- if (0 == numberOfFamilies) {
- //ToDestroy = true ;
- vector<GROUP*> myGroups = _ptrMesh->getGroups(entity);
- int NumberOfGroups = myGroups.size() ;
- // build families from groups
- for (int i=0; i<NumberOfGroups; i++) {
- SCRUTE( myGroups[i]->getName() );
- SUPPORT * mySupport = myGroups[i] ;
- FAMILY* myFamily = new FAMILY(*mySupport);
- myFamily->setIdentifier(-i-2000);
- myFamilies->push_back(myFamily);
- }
- numberOfFamilies=myFamilies->size() ;
- }
- for (int i=0;i<numberOfFamilies;i++) {
- int familyNumber = (*myFamilies)[i]->getIdentifier() ;
- int numberOfFamilyElements = (*myFamilies)[i]->getNumberOfElements(MED_ALL_ELEMENTS) ;
- if ((*myFamilies)[i]->isOnAllElements())
- for (int ii=0; ii<numberOfFamilyElements; ii++)
- familyArray[ii]=familyNumber;
- else {
- const int * myFamilyElements = (*myFamilies)[i]->getNumber(MED_ALL_ELEMENTS) ;
- for (int ii=0;ii<numberOfFamilyElements;ii++)
- familyArray[myFamilyElements[ii]-1]=familyNumber;
- }
- }
-
- const int * typeCount = _ptrMesh->getGlobalNumberingIndex(entity) ;
-#if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
- int lgth=numberOfElements;
- med_2_1::med_int *temp=new med_2_1::med_int[lgth];
- for(int i2=0;i2<lgth;i2++)
- temp[i2]=(med_2_1::med_int) (familyArray[i2]);
-#endif
- for (int i=0; i<numberOfTypes; i++) {
-
- int typeNumberOfElements = typeCount[i+1] - typeCount[i] ;
-#if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
- err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
- temp+typeCount[i]-1, typeNumberOfElements,
- med_2_1::MED_REMP ,
- (med_2_1::med_entite_maillage) entity,
- (med_2_1::med_geometrie_element) types[i]);
-#else
- err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
- familyArray+typeCount[i]-1, typeNumberOfElements,
- med_2_1::MED_REMP ,
- (med_2_1::med_entite_maillage) entity,
- (med_2_1::med_geometrie_element) types[i]);
-#endif
- if ( err != MED_VALID)
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't write family for the |"<< _ptrMesh->getNumberOfElements(entity, types[i])
- << "| edges of geometric type |" << geoNames[types[i]] <<"|in mesh |"
- << _ptrMesh->_name.c_str() << "|" ));
- }
-#if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
- delete [] temp;
-#endif
- delete[] familyArray ;
- //if (true == ToDestroy) {
- // int NumberOfFamilies = myFamilies->size();
- // for (int i=0; i<NumberOfFamilies; i++)
- // delete myFamilies[i];
- //}
- }
- }
-
- END_OF(LOC);
- return MED_VALID;
+void MED_MESH_WRONLY_DRIVER::MED_MESH_WRONLY_DRIVER::write( void ) const
+{
+ _concreteMeshDrv->write();
}
-int MED_MESH_WRONLY_DRIVER::writeFamilies(vector<FAMILY*> & families ) const {
-
- const char * LOC="int MED_MESH_WRONLY_DRIVER::writeFamilies(vector<FAMILY*> families) const : ";
- BEGIN_OF(LOC);
+// int MED_MESH_WRONLY_DRIVER::MED_MESH_WRONLY_DRIVER::writeCoordinates () const
+// {
+// return _concreteMeshDrv->writeCoordinates();
+// }
- med_2_1::med_err err;
-
- MESSAGE(LOC<<" families.size() :"<<families.size());
-
- for (unsigned int i=0; i< families.size(); i++) {
-
- int numberOfAttributes = families[i]->getNumberOfAttributes ();
- string attributesDescriptions = "";
-
- // Recompose the attributes descriptions arg for MED
- for (int j=0; j < numberOfAttributes; j++) {
-
- string attributeDescription = families[i]->getAttributeDescription(j+1);
-
- if ( attributeDescription.size() > MED_TAILLE_DESC )
- throw MEDEXCEPTION( LOCALIZED(STRING(LOC) << "The size of the attribute description n° |" << j+1 << "| of the family |" << families[i]->getName()
- << "| with identifier |" << families[i]->getIdentifier() << "| is |"
- << attributeDescription.size() <<"| and is more than |" << MED_TAILLE_DESC << "|")) ;
-
- attributesDescriptions += attributeDescription;
- }
-
-
- int numberOfGroups = families[i]->getNumberOfGroups();
- string groupsNames(numberOfGroups*MED_TAILLE_LNOM,'\0') ;
- // Recompose the groups names arg for MED
- for (int j=0; j < numberOfGroups; j++) {
-
- string groupName = families[i]->getGroupName(j+1);
-
- if ( groupName.size() > MED_TAILLE_LNOM )
- throw MEDEXCEPTION( LOCALIZED(STRING(LOC) << "The size of the group name n° |" << j+1 << "| of the family |" << families[i]->getName()
- << "| with identifier |" << families[i]->getIdentifier() << "| is |"
- << groupName.size() <<"| and is more than |" << MED_TAILLE_LNOM << "|")) ;
-
-
- int length = min(MED_TAILLE_LNOM,(int)groupName.size());
- groupsNames.replace(j*MED_TAILLE_LNOM,length, groupName,0,length);
-
- }
+// int MED_MESH_WRONLY_DRIVER::MED_MESH_WRONLY_DRIVER::writeConnectivities (MED_EN::medEntityMesh entity) const
+// {
+// return _concreteMeshDrv->writeConnectivities(entity);
+// }
- // test if the family already exists (HDF trick waiting a MED evolution to be replaced)
- string dataGroupFam = "/ENS_MAA/"+_meshName+"/FAS/"+families[i]->getName()+"/";
- SCRUTE("|"<<dataGroupFam<<"|");
- err =_MEDdatagroupOuvrir(_medIdt,const_cast <char *> (dataGroupFam.c_str()) ) ;
- if ( err < MED_VALID ) {
- SCRUTE(err);
-
- MESSAGE(LOC<<"families[i]->getName().c_str() : "<<families[i]->getName().c_str());
- MESSAGE(LOC<<"_meshName.c_str() : "<<_meshName.c_str());
- MESSAGE(LOC<<"families[i]->getIdentifier() : "<<families[i]->getIdentifier());
- MESSAGE(LOC<<"numberOfAttributes : "<<numberOfAttributes);
-
- //MESSAGE(LOC<<"families[i]->getAttributesIdentifiers() : "<<families[i]->getAttributesIdentifiers()[0]);
- //MESSAGE(LOC<<"families[i]->getAttributesValues() : "<<families[i]->getAttributesValues()[0]);
- MESSAGE(LOC<<"attributesDescriptions.c_str() : "<<attributesDescriptions.c_str());
- MESSAGE(LOC<<"numberOfGroups : "<<numberOfGroups);
- MESSAGE(LOC<<"groupsNames.c_str() : "<<groupsNames.c_str());
-#if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
- int lgth=families[i]->getNumberOfAttributes();
- med_2_1::med_int * AttributesIdentifier2 = new med_2_1::med_int[lgth] ;
- med_2_1::med_int * AttributesValues2 = new med_2_1::med_int[lgth] ;
- for(med_2_1::med_int i2=0;i2<lgth;i2++)
- {
- AttributesIdentifier2[i2]=(med_2_1::med_int)(families[i]->getAttributesIdentifiers()[i2]);
- AttributesValues2[i2]=(med_2_1::med_int)(families[i]->getAttributesValues()[i2]);
- }
- err = med_2_1::MEDfamCr( _medIdt,
- const_cast <char *> ( _meshName.c_str() ),
- const_cast <char *> ( families[i]->getName().c_str() ),
- families[i]->getIdentifier(),
- AttributesIdentifier2,
- AttributesValues2,
- const_cast <char *> (attributesDescriptions.c_str()),
- numberOfAttributes,
- const_cast <char *> (groupsNames.c_str()),
- numberOfGroups);
- delete [] AttributesIdentifier2;
- delete [] AttributesValues2;
-#else
- err = med_2_1::MEDfamCr( _medIdt,
- const_cast <char *> ( _meshName.c_str() ),
- const_cast <char *> ( families[i]->getName().c_str() ),
- families[i]->getIdentifier(),
- families[i]->getAttributesIdentifiers(),
- families[i]->getAttributesValues(),
- const_cast <char *> (attributesDescriptions.c_str()),
- numberOfAttributes,
- const_cast <char *> (groupsNames.c_str()),
- numberOfGroups);
-#endif
- SCRUTE(err);
- if ( err != MED_VALID)
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't create family |" << families[i]->getName()
- << "| with identifier |" << families[i]->getIdentifier() << "| groups names |"
- << groupsNames <<"| and attributes descriptions |" << attributesDescriptions << "|")) ;
- }
- else
- _MEDdatagroupFermer(_medIdt);
+// int MED_MESH_WRONLY_DRIVER::MED_MESH_WRONLY_DRIVER::writeFamilyNumbers () const
+// {
+// return _concreteMeshDrv->writeFamilyNumbers();
+// }
+// int MED_MESH_WRONLY_DRIVER::MED_MESH_WRONLY_DRIVER::writeFamilies (vector<FAMILY*> & families) const
+// {
+// return _concreteMeshDrv->writeFamilies(families);
+// }
- }
+// int MED_MESH_WRONLY_DRIVER::MED_MESH_WRONLY_DRIVER::writeGRID() const
+// {
+// return _concreteMeshDrv->writeGRID();
+// }
- END_OF(LOC);
-
- return MED_VALID;
+MED_MESH_RDWR_DRIVER::MED_MESH_RDWR_DRIVER()
+{
+ _concreteMeshDrv=new MED_MESH_RDWR_DRIVER21();
}
+MED_MESH_RDWR_DRIVER::MED_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh)
+{
+ _concreteMeshDrv = DRIVERFACTORY::buildMeshDriverFromFile(fileName,ptrMesh,MED_REMP);
+}
-// A FAIRE POUR LES NOEUDS ET LES ELEMENTS ret = MEDfamEcr(
-
-
-
-/*--------------------- RDWR PART -------------------------------*/
+MED_MESH_RDWR_DRIVER::MED_MESH_RDWR_DRIVER(const MED_MESH_RDWR_DRIVER & driver): MED_MESH_DRIVER(driver)
+{
+ _concreteMeshDrv = driver._concreteMeshDrv->copy();
+}
-MED_MESH_RDWR_DRIVER::MED_MESH_RDWR_DRIVER():MED_MESH_DRIVER()
+MED_MESH_RDWR_DRIVER::~MED_MESH_RDWR_DRIVER()
{
+ if (_concreteMeshDrv) delete _concreteMeshDrv;
}
-MED_MESH_RDWR_DRIVER::MED_MESH_RDWR_DRIVER(const string & fileName,
- MESH * ptrMesh):
- MED_MESH_DRIVER(fileName,ptrMesh,MED_RDWR)
+void MED_MESH_RDWR_DRIVER::read ( void )
{
- MESSAGE("MED_MESH_RDWR_DRIVER::MED_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh) has been created");
+ _concreteMeshDrv->read();
}
-MED_MESH_RDWR_DRIVER::MED_MESH_RDWR_DRIVER(const MED_MESH_RDWR_DRIVER & driver):
- MED_MESH_RDONLY_DRIVER::MED_MESH_DRIVER(driver)
+void MED_MESH_RDWR_DRIVER::write( void ) const
{
+ _concreteMeshDrv->write();
+}
+
+void MED_MESH_RDWR_DRIVER::open()
+{
+ _concreteMeshDrv->open();
}
-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");
-}
-
-GENDRIVER * MED_MESH_RDWR_DRIVER::copy(void) const
+void MED_MESH_RDWR_DRIVER::close()
{
- return new MED_MESH_RDWR_DRIVER(*this);
+ _concreteMeshDrv->close();
}
-void MED_MESH_RDWR_DRIVER::write(void) const
+// int MED_MESH_RDWR_DRIVER::getCOORDINATE()
+// {
+// return _concreteMeshDrv->getCOORDINATE();
+// }
+
+// int MED_MESH_RDWR_DRIVER::getCONNECTIVITY()
+// {
+// return _concreteMeshDrv->getCONNECTIVITY();
+// }
+
+// int MED_MESH_RDWR_DRIVER::getFAMILY()
+// {
+// return _concreteMeshDrv->getFAMILY();
+// }
+
+// int MED_MESH_RDWR_DRIVER::getNodalConnectivity(CONNECTIVITY * Connectivity)
+// {
+// return _concreteMeshDrv->getNodalConnectivity(Connectivity);
+// }
+
+// int MED_MESH_RDWR_DRIVER::getDescendingConnectivity(CONNECTIVITY * Connectivity)
+// {
+// return _concreteMeshDrv->getDescendingConnectivity(Connectivity);
+// }
+
+// int MED_MESH_RDWR_DRIVER::getNodesFamiliesNumber(int * MEDArrayNodeFamily)
+// {
+// return _concreteMeshDrv->getNodesFamiliesNumber(MEDArrayNodeFamily);
+// }
+
+// int MED_MESH_RDWR_DRIVER::getCellsFamiliesNumber(int** Arrays, CONNECTIVITY* Connectivity, MED_EN::medEntityMesh entity)
+// {
+// return _concreteMeshDrv->getCellsFamiliesNumber(Arrays,Connectivity,entity);
+// }
+
+// void MED_MESH_RDWR_DRIVER::getGRID ()
+// {
+// _concreteMeshDrv->getGRID();
+// }
+
+// int MED_MESH_RDWR_DRIVER::writeCoordinates () const
+// {
+// _concreteMeshDrv->writeCoordinates();
+// }
+
+// int MED_MESH_RDWR_DRIVER::writeConnectivities (MED_EN::medEntityMesh entity) const
+// {
+// return _concreteMeshDrv->writeConnectivities (entity);
+// }
+
+// int MED_MESH_RDWR_DRIVER::writeFamilyNumbers () const
+// {
+// return _concreteMeshDrv->writeFamilyNumbers();
+// }
+
+// int MED_MESH_RDWR_DRIVER::writeFamilies (vector<FAMILY*> & families) const
+// {
+// return _concreteMeshDrv->writeFamilies(families);
+// }
+
+// int MED_MESH_RDWR_DRIVER::writeGRID() const
+// {
+// return _concreteMeshDrv->writeGRID();
+// }
+
+void MED_MESH_RDWR_DRIVER::setMeshName(const string & meshName)
{
- MED_MESH_WRONLY_DRIVER::write();
+ _concreteMeshDrv->setMeshName(meshName);
}
-void MED_MESH_RDWR_DRIVER::read (void)
+
+string MED_MESH_RDWR_DRIVER::getMeshName() const
{
- MED_MESH_RDONLY_DRIVER::read();
+ return MED_MESH_DRIVER::getMeshName();
}
+GENDRIVER * MED_MESH_RDWR_DRIVER::copy ( void ) const
+{
+ return new MED_MESH_RDWR_DRIVER(*this);
+}
protected:
MESH * _ptrMesh;
- med_2_1::med_idt _medIdt;
string _meshName; // const ?
int _meshNum; // INUTILE ?
-
-public :
- // all MED cell type
- static const med_2_1::med_geometrie_element all_cell_type[MED_NBR_GEOMETRIE_MAILLE];
-
- static const char * const all_cell_type_tab [MED_NBR_GEOMETRIE_MAILLE];
+
+public :
/*!
Constructor.
*/
virtual ~MED_MESH_DRIVER() ;
- void open();
- void close();
+ virtual void open() = 0;
+ virtual void close() = 0;
virtual void write( void ) const = 0 ;
virtual void read ( void ) = 0 ;
It could be different than the name of the MESH object.
*/
- void setMeshName(const string & meshName) ;
+ virtual void setMeshName(const string & meshName) ;
/*!
Get the name of the MESH asked in file.
*/
- string getMeshName() const ;
+ virtual string getMeshName() const ;
-private:
+public:
virtual GENDRIVER * copy ( void ) const = 0 ;
};
*/
-class MED_MESH_RDONLY_DRIVER : public virtual MED_MESH_DRIVER
+ class IMED_MESH_RDONLY_DRIVER : public virtual MED_MESH_DRIVER
{
public :
/*!
Constructor.
*/
- MED_MESH_RDONLY_DRIVER() ;
+ IMED_MESH_RDONLY_DRIVER() ;
/*!
Constructor.
*/
- MED_MESH_RDONLY_DRIVER(const string & fileName, MESH * ptrMesh) ;
+ IMED_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() ;
+ IMED_MESH_RDONLY_DRIVER(const IMED_MESH_RDONLY_DRIVER & driver) ;
// CREER UNE METHODE POUR LIRE LA LISTE DES MAILLAGES .....
-
/*!
Return a MEDEXCEPTION : it is the read-only driver.
*/
void write( void ) const;
- /*!
- Read MESH in the specified file.
- */
- void read ( void );
-private:
- int getCOORDINATE();
- int getCONNECTIVITY();
- int getFAMILY();
- int getNodalConnectivity(CONNECTIVITY * Connectivity) ;
- int getDescendingConnectivity(CONNECTIVITY * Connectivity) ;
- int getNodesFamiliesNumber(int * MEDArrayNodeFamily) ;
- int getCellsFamiliesNumber(int** Arrays, CONNECTIVITY* Connectivity, MED_EN::medEntityMesh entity) ;
+protected:
+// virtual int getCOORDINATE() = 0 ;
+// virtual int getCONNECTIVITY() = 0 ;
+// virtual int getFAMILY() = 0 ;
+// virtual int getNodalConnectivity(CONNECTIVITY * Connectivity) = 0 ;
+ int getDescendingConnectivity(CONNECTIVITY * Connectivity);
+// virtual int getNodesFamiliesNumber(int * MEDArrayNodeFamily) = 0 ;
+// virtual int getCellsFamiliesNumber(int** Arrays, CONNECTIVITY* Connectivity, MED_EN::medEntityMesh entity) = 0 ;
void updateFamily() ;
void buildAllGroups(vector<GROUP*> & Groups, vector<FAMILY*> & Families) ;
- void getGRID ();
+// virtual void getGRID () = 0 ;
- GENDRIVER * copy ( void ) const ;
+ friend class MED_MESH_RDONLY_DRIVER;
};
*/
-class MED_MESH_WRONLY_DRIVER : public virtual MED_MESH_DRIVER {
+class IMED_MESH_WRONLY_DRIVER : public virtual MED_MESH_DRIVER {
public :
/*!
Constructor.
*/
- MED_MESH_WRONLY_DRIVER() ;
+ IMED_MESH_WRONLY_DRIVER() ;
/*!
Constructor.
*/
- MED_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh) ;
+ IMED_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh) ;
/*!
Copy constructor.
*/
- MED_MESH_WRONLY_DRIVER(const MED_MESH_WRONLY_DRIVER & driver) ;
+ IMED_MESH_WRONLY_DRIVER(const IMED_MESH_WRONLY_DRIVER & driver) ;
/*!
Destructor.
*/
- virtual ~MED_MESH_WRONLY_DRIVER() ;
+ virtual ~IMED_MESH_WRONLY_DRIVER() ;
- /*!
- Write MESH in the specified file.
- */
- void write( void ) const;
/*!
Return a MEDEXCEPTION : it is the write-only driver.
*/
void read ( void );
-private:
- int writeCoordinates () const;
- int writeConnectivities (MED_EN::medEntityMesh entity) const;
- int writeFamilyNumbers () const;
- int writeFamilies (vector<FAMILY*> & families) const;
- int writeGRID() const;
+// protected:
+// virtual int writeCoordinates () const = 0 ;
+// virtual int writeConnectivities (MED_EN::medEntityMesh entity) const = 0 ;
+// virtual int writeFamilyNumbers () const = 0 ;
+// virtual int writeFamilies (vector<FAMILY*> & families) const = 0 ;
+// virtual int writeGRID() const = 0 ;
- GENDRIVER * copy ( void ) const ;
+ friend class MED_MESH_WRONLY_DRIVER;
};
*/
-class MED_MESH_RDWR_DRIVER : public MED_MESH_RDONLY_DRIVER, public MED_MESH_WRONLY_DRIVER {
+class IMED_MESH_RDWR_DRIVER : public virtual IMED_MESH_RDONLY_DRIVER, public virtual IMED_MESH_WRONLY_DRIVER {
public :
/*!
Constructor.
*/
- MED_MESH_RDWR_DRIVER() ;
+ IMED_MESH_RDWR_DRIVER() ;
/*!
Constructor.
*/
- MED_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh) ;
+ IMED_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh) ;
/*!
Copy constructor.
*/
- MED_MESH_RDWR_DRIVER(const MED_MESH_RDWR_DRIVER & driver) ;
+ IMED_MESH_RDWR_DRIVER(const IMED_MESH_RDWR_DRIVER & driver) ;
/*!
Destructor.
*/
- ~MED_MESH_RDWR_DRIVER() ;
+ ~IMED_MESH_RDWR_DRIVER() ;
- /*!
- Write MESH in the specified file.
- */
- void write(void) const;
- /*!
- Read MESH in the specified file.
- */
- void read (void);
+ friend class MED_MESH_RDWR_DRIVER;
-private:
- GENDRIVER * copy(void) const ;
+};
+class MED_MESH_RDONLY_DRIVER : public virtual IMED_MESH_RDONLY_DRIVER
+{
+public:
+ MED_MESH_RDONLY_DRIVER();
+ MED_MESH_RDONLY_DRIVER(const string & fileName, MESH * ptrMesh);
+ MED_MESH_RDONLY_DRIVER(const MED_MESH_RDONLY_DRIVER & driver);
+ ~MED_MESH_RDONLY_DRIVER();
+ void setMeshName(const string & meshName);
+ string getMeshName() const;
+ void write( void ) const;
+ void read ( void );
+ void open();
+ void close();
+protected:
+ GENDRIVER * _concreteMeshDrv;
+// int getCOORDINATE();
+// int getCONNECTIVITY();
+// int getFAMILY();
+// int getNodalConnectivity(CONNECTIVITY * Connectivity);
+// int getDescendingConnectivity(CONNECTIVITY * Connectivity);
+// int getNodesFamiliesNumber(int * MEDArrayNodeFamily);
+// int getCellsFamiliesNumber(int** Arrays, CONNECTIVITY* Connectivity, MED_EN::medEntityMesh entity);
+// void getGRID ();
+ GENDRIVER * copy ( void ) const;
};
+
+class MED_MESH_WRONLY_DRIVER : public virtual IMED_MESH_WRONLY_DRIVER {
+public :
+ MED_MESH_WRONLY_DRIVER();
+ MED_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh);
+ MED_MESH_WRONLY_DRIVER(const MED_MESH_WRONLY_DRIVER & driver);
+ ~MED_MESH_WRONLY_DRIVER();
+ void setMeshName(const string & meshName);
+ string getMeshName() const;
+ void read ( void );
+ void write( void ) const;
+ void open();
+ void close();
+protected:
+ GENDRIVER * _concreteMeshDrv;
+// int writeCoordinates () const;
+// int writeConnectivities (MED_EN::medEntityMesh entity) const;
+// int writeFamilyNumbers () const;
+// int writeFamilies (vector<FAMILY*> & families) const;
+// int writeGRID() const;
+ GENDRIVER * copy ( void ) const;
+};
+
+class MED_MESH_RDWR_DRIVER : public IMED_MESH_RDWR_DRIVER {
+public :
+ MED_MESH_RDWR_DRIVER();
+ MED_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh);
+ MED_MESH_RDWR_DRIVER(const MED_MESH_RDWR_DRIVER & driver);
+ ~MED_MESH_RDWR_DRIVER();
+ void setMeshName(const string & meshName);
+ string getMeshName() const;
+ void read ( void );
+ void write( void ) const;
+ void open();
+ void close();
+protected:
+ GENDRIVER * _concreteMeshDrv;
+// int getCOORDINATE();
+// int getCONNECTIVITY();
+// int getFAMILY();
+// int getNodalConnectivity(CONNECTIVITY * Connectivity);
+// int getDescendingConnectivity(CONNECTIVITY * Connectivity);
+// int getNodesFamiliesNumber(int * MEDArrayNodeFamily);
+// int getCellsFamiliesNumber(int** Arrays, CONNECTIVITY* Connectivity, MED_EN::medEntityMesh entity);
+// void getGRID ();
+// int writeCoordinates () const;
+// int writeConnectivities (MED_EN::medEntityMesh entity) const;
+// int writeFamilyNumbers () const;
+// int writeFamilies (vector<FAMILY*> & families) const;
+// int writeGRID() const;
+ GENDRIVER * copy ( void ) const;
+};
+
};
#endif /* MED_MESH_DRIVER_HXX */
--- /dev/null
+#include "MEDMEM_MedMeshDriver21.hxx"
+
+#include "MEDMEM_DriversDef.hxx"
+
+#include "MEDMEM_Family.hxx"
+#include "MEDMEM_Group.hxx"
+#include "MEDMEM_Coordinate.hxx"
+#include "MEDMEM_Connectivity.hxx"
+#include "MEDMEM_Mesh.hxx"
+#include "MEDMEM_CellModel.hxx"
+#include "MEDMEM_Grid.hxx"
+
+
+using namespace std;
+using namespace MEDMEM;
+using namespace MED_EN;
+
+namespace med_2_1 {
+ extern "C" {
+ extern med_idt _MEDdatagroupOuvrir(med_idt pid, char *nom);
+ extern med_err _MEDdatagroupFermer(med_idt id);
+ }
+}
+
+// Every memory allocation made in the MedDriver members function are desallocated in the Mesh destructor
+
+MED_MESH_DRIVER21::MED_MESH_DRIVER21():_medIdt(MED_INVALID)
+{
+}
+
+MED_MESH_DRIVER21::MED_MESH_DRIVER21(const string & fileName,
+ MESH * ptrMesh,
+ MED_EN::med_mode_acces accessMode):
+ _medIdt(MED_INVALID),MED_MESH_DRIVER(fileName,ptrMesh,accessMode)
+{
+}
+
+MED_MESH_DRIVER21::MED_MESH_DRIVER21(const MED_MESH_DRIVER21 & driver):
+ MED_MESH_DRIVER(driver),_medIdt(driver._medIdt)
+{
+}
+
+MED_MESH_DRIVER21::~MED_MESH_DRIVER21()
+{
+}
+
+void MED_MESH_DRIVER21::open()
+{
+ const char * LOC = "MED_MESH_DRIVER21::open()" ;
+ BEGIN_OF(LOC);
+ MESSAGE(LOC<<" : _fileName.c_str : "<< _fileName.c_str()<<",mode : "<< _accessMode);
+ _medIdt = med_2_1::MEDouvrir( (const_cast <char *> (_fileName.c_str())),(med_2_1::med_mode_acces) _accessMode);
+ MESSAGE(LOC<<" _medIdt : "<< _medIdt );
+ if (_medIdt > 0)
+ _status = MED_OPENED;
+ else {
+ _medIdt = MED_INVALID;
+ _status = MED_CLOSED;
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Could not open file "<<_fileName<<" in mode "<<_accessMode));
+ }
+
+ END_OF(LOC);
+}
+
+void MED_MESH_DRIVER21::close()
+{
+ const char * LOC = "MED_MESH_DRIVER21::close() " ;
+ BEGIN_OF(LOC);
+ int err = 0;
+ if ( _status == MED_OPENED) {
+ err=med_2_1::MEDfermer(_medIdt);
+ // san -- MED5873 : Calling H5close() here leads to failure of SALOMEDS::StudyManager_i::_SaveAs()
+ // method during study saving process. MEDfermer() seems sufficient for closing a file.
+ //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);
+}
+
+//A FAIRE UTILISER LES MAPS...
+const med_2_1::med_geometrie_element MED_MESH_DRIVER21::all_cell_type[MED_NBR_GEOMETRIE_MAILLE]=
+ { med_2_1::MED_POINT1,med_2_1::MED_SEG2,med_2_1::MED_SEG3,med_2_1::MED_TRIA3,med_2_1::MED_QUAD4,med_2_1::MED_TRIA6,med_2_1::MED_QUAD8,
+ med_2_1::MED_TETRA4,med_2_1::MED_PYRA5,med_2_1::MED_PENTA6,med_2_1::MED_HEXA8,med_2_1::MED_TETRA10,med_2_1::MED_PYRA13,
+ med_2_1::MED_PENTA15, med_2_1::MED_HEXA20};
+
+const char * const MED_MESH_DRIVER21::all_cell_type_tab [MED_NBR_GEOMETRIE_MAILLE]=
+ { "MED_POINT1","MED_SEG2","MED_SEG3","MED_TRIA3","MED_QUAD4","MED_TRIA6","MED_QUAD8",
+ "MED_TETRA4","MED_PYRA5","MED_PENTA6","MED_HEXA8","MED_TETRA10","MED_PYRA13",
+ "MED_PENTA15","MED_HEXA20"};
+
+//---------------------------------- RDONLY PART -------------------------------------------------------------
+
+MED_MESH_RDONLY_DRIVER21::MED_MESH_RDONLY_DRIVER21()
+{
+}
+
+MED_MESH_RDONLY_DRIVER21::MED_MESH_RDONLY_DRIVER21(const string & fileName,
+ MESH * ptrMesh):
+ IMED_MESH_RDONLY_DRIVER(fileName,ptrMesh),MED_MESH_DRIVER21(fileName,ptrMesh,MED_RDONLY),MED_MESH_DRIVER(fileName,ptrMesh,MED_RDONLY)
+{
+ MESSAGE("MED_MESH_RDONLY_DRIVER21::MED_MESH_RDONLY_DRIVER21(const string & fileName, MESH * ptrMesh) has been created");
+}
+
+MED_MESH_RDONLY_DRIVER21::MED_MESH_RDONLY_DRIVER21(const MED_MESH_RDONLY_DRIVER21 & driver):
+ IMED_MESH_RDONLY_DRIVER(driver),MED_MESH_DRIVER21(driver),MED_MESH_DRIVER(driver)
+{
+}
+
+MED_MESH_RDONLY_DRIVER21::~MED_MESH_RDONLY_DRIVER21()
+{
+ //MESSAGE("MED_MESH_RDONLY_DRIVER21::~MED_MESH_RDONLY_DRIVER21() has been destroyed");
+}
+
+GENDRIVER * MED_MESH_RDONLY_DRIVER21::copy(void) const
+{
+ return new MED_MESH_RDONLY_DRIVER21(*this);
+}
+
+void MED_MESH_RDONLY_DRIVER21::read(void)
+{
+ const char * LOC = "MED_MESH_RDONLY_DRIVER21::read() : " ;
+ BEGIN_OF(LOC);
+ if (_status!=MED_OPENED)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "The _idt of file " << _fileName << " is : " << _medIdt << " (the file is not opened)." )) ;
+
+ _ptrMesh->_name = _meshName;
+
+ SCRUTE(_ptrMesh->getIsAGrid());
+
+ if (_ptrMesh->getIsAGrid())
+ {
+ getGRID( );
+
+ // always call getFAMILY : families are requiered !!!!
+
+// int nbFam = MEDnFam(_medIdt,
+// const_cast <char *> (_meshName.c_str()),
+// 0,
+// med_2_1::MED_FAMILLE);
+// if (nbFam > 0)
+ {
+// getFAMILY();
+
+ if (getFAMILY()!=MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERREUR in getFAMILY when the mesh is a grid")) ;
+
+ buildAllGroups(_ptrMesh->_groupNode,_ptrMesh->_familyNode) ;
+ }
+
+ END_OF(LOC);
+ return;
+ }
+
+ if (getCOORDINATE()!=MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERREUR in getCOORDINATE" )) ;
+
+ if (getCONNECTIVITY()!=MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERREUR in getCOONECTIVITY")) ;
+
+ if (getFAMILY()!=MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERREUR in getFAMILY" )) ;
+
+ updateFamily();
+
+ // we build all groups
+ // on node
+ buildAllGroups(_ptrMesh->_groupNode,_ptrMesh->_familyNode) ;
+ // on cell
+ buildAllGroups(_ptrMesh->_groupCell,_ptrMesh->_familyCell) ;
+ // on face
+ buildAllGroups(_ptrMesh->_groupFace,_ptrMesh->_familyFace) ;
+ // on edge
+ buildAllGroups(_ptrMesh->_groupEdge,_ptrMesh->_familyEdge) ;
+
+// MESSAGE(LOC<<"Checking of CellModel !!!!!!!");
+
+// int nbOfTypes = _ptrMesh->_connectivity->_numberOfTypes;
+// for(int i=0;i<nbOfTypes;i++)
+// {
+// MESSAGE(LOC << _ptrMesh->_connectivity->_type[i]) ;
+// }
+
+ END_OF(LOC);
+}
+
+//=======================================================================
+//function : getGRID
+//purpose :
+//=======================================================================
+
+void MED_MESH_RDONLY_DRIVER21::getGRID()
+{
+ const char * LOC = "MED_MESH_RDONLY_DRIVER21::getGRID() : " ;
+ BEGIN_OF(LOC);
+
+ if (_status!=MED_OPENED)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "med file is not opened"));
+
+ GRID * ptrGrid = (GRID *) _ptrMesh;
+
+ int err, i;
+
+ // Read the dimension of the space for the mesh <_meshName>
+ int SpaceDimension = med_2_1::MEDdimLire(_medIdt,const_cast <char *> (_meshName.c_str())) ;
+ if ( SpaceDimension <= MED_VALID )
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"The space dimension |" << SpaceDimension <<
+ "| seems to be incorrect " << "for the mesh : |" <<
+ _meshName << "|")) ;
+ _ptrMesh->_spaceDimension = SpaceDimension;
+
+ _ptrMesh->_meshDimension = SpaceDimension;
+
+ // Read Array length
+ int * ArrayLen[] = { & ptrGrid->_iArrayLength,
+ & ptrGrid->_jArrayLength,
+ & ptrGrid->_kArrayLength };
+ int idim;
+ for (idim = 0; idim < _ptrMesh->_spaceDimension; ++idim)
+ {
+ int lenght = med_2_1::MEDnGrid(_medIdt,
+ const_cast <char *> (_ptrMesh->_name.c_str()),
+ (med_2_1::med_grid)
+ idim
+ );
+ if ( lenght <= MED_VALID )
+ throw MEDEXCEPTION(STRING(LOC) <<"The number of nodes |" << lenght <<
+ "| seems to be incorrect "
+ << "for the mesh : |" << _meshName << "|" ) ;
+
+ ArrayLen [idim][0] = lenght;
+ }
+
+ med_2_1::med_repere rep ;
+ string tmp_nom_coord (MED_TAILLE_PNOM21*(_ptrMesh->_spaceDimension)+1,' ');
+ string tmp_unit_coord(MED_TAILLE_PNOM21*(_ptrMesh->_spaceDimension)+1,' ');
+ char * tmp_nom = (const_cast <char *> ( tmp_nom_coord.c_str()) ) ;
+ char * tmp_unit= (const_cast <char *> ( tmp_unit_coord.c_str()) ) ;
+
+ // Read node coordinates for MED_BODY_FITTED grid
+
+ SCRUTE(ptrGrid->getGridType());
+
+ if (ptrGrid->getGridType() == MED_EN::MED_BODY_FITTED)
+ {
+ // Read nb of nodes
+ int NumberOfNodes = med_2_1::MEDnGrid(_medIdt,
+ const_cast <char *> (_meshName.c_str()),
+ med_2_1::MED_GRID_NOEUD);
+ if ( NumberOfNodes <= MED_VALID )
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"The number of nodes |" << NumberOfNodes <<
+ "| seems to be incorrect "
+ << "for the mesh : |" << _meshName << "|" )) ;
+ _ptrMesh->_numberOfNodes = NumberOfNodes ;
+
+ // this array is useless because families numbers are read in getFAMILY
+ //CCRT as it is useless replace int by med_int
+ med_2_1::med_int * MEDArrayNodeFamily = new med_2_1::med_int[ NumberOfNodes ];
+ // create coordinates
+ _ptrMesh->_coordinate = new COORDINATE(SpaceDimension,NumberOfNodes,
+ MED_EN::MED_FULL_INTERLACE);
+
+ // Read coordinates and families
+// double * coo = const_cast <double *>
+// (_ptrMesh->_coordinate->getCoordinates(MED_EN::MED_FULL_INTERLACE));
+
+// err = med_2_1::MEDbodyFittedLire (_medIdt,
+// const_cast <char *> (_ptrMesh->_name.c_str()),
+// _ptrMesh->_spaceDimension,
+// coo,
+// med_2_1::MED_FULL_INTERLACE,
+// & rep,
+// tmp_nom,
+// tmp_unit,
+// MEDArrayNodeFamily,
+// NumberOfNodes);
+
+ err = med_2_1::MEDbodyFittedLire (_medIdt,
+ const_cast <char *> (_ptrMesh->_name.c_str()),
+ _ptrMesh->_spaceDimension,
+ const_cast <double *> ( _ptrMesh->_coordinate->_coordinate.get(MED_EN::MED_FULL_INTERLACE) ),
+ med_2_1::MED_FULL_INTERLACE,
+ & rep,
+ tmp_nom,
+ tmp_unit,
+ MEDArrayNodeFamily,
+ NumberOfNodes);
+
+ MESSAGE(LOC << " NumberOfNodes = " << NumberOfNodes << " SpaceDimension = " << SpaceDimension);
+
+ ptrGrid->_is_coordinates_filled = true;
+
+// for (int icoor = 0 ; icoor<NumberOfNodes ; icoor++)
+// for(int jcoor = 0 ; jcoor<SpaceDimension ; jcoor++)
+// MESSAGE(LOC << " icoor = " << icoor << " jcoor = " << jcoor << " COOR = " << _ptrMesh->getCoordinates(MED_FULL_INTERLACE)[icoor*SpaceDimension+jcoor]);
+
+ delete[] MEDArrayNodeFamily;
+ if (err != MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"error in MEDbodyFittedLire()"));
+
+ // _ptrMesh->_MEDArrayNodeFamily = fam ;
+
+ }
+ else
+ {
+ // Read Arrays and Node families in Cartesian or Polar Grid
+
+ int nbNodes = 1;
+ double * Array[] = { (double*) 0, (double*) 0, (double*) 0 };
+ for (idim = 0; idim < _ptrMesh->_spaceDimension; ++idim)
+ {
+ int nbNodesDim = * ArrayLen [idim];
+ nbNodes *= nbNodesDim;
+ Array [idim] = new double [ nbNodesDim ];
+ err = med_2_1::MEDgridLire (_medIdt,
+ const_cast <char *> (_ptrMesh->_name.c_str()),
+ _ptrMesh->_spaceDimension,
+ Array [idim],
+ idim,
+ med_2_1::MED_FULL_INTERLACE,
+ & rep,
+ tmp_nom,
+ tmp_unit);
+ if (err != MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Error in MEDgridLire for dimention" << idim ));
+
+ }
+ ptrGrid->_iArray = Array[0];
+ ptrGrid->_jArray = Array[1];
+ ptrGrid->_kArray = Array[2];
+
+ _ptrMesh->_numberOfNodes = nbNodes ;
+
+ // create coordinates
+ _ptrMesh->_coordinate = new COORDINATE(SpaceDimension,nbNodes,
+ MED_EN::MED_FULL_INTERLACE);
+ } // end read Cartesian or Polar Grid
+
+ // set coordinate names
+
+ for (i=0; i<_ptrMesh->_spaceDimension; ++i ) {
+ string myStringName(tmp_nom_coord,i*MED_TAILLE_PNOM21,MED_TAILLE_PNOM21) ;
+ string myStringUnit(tmp_unit_coord,i*MED_TAILLE_PNOM21,MED_TAILLE_PNOM21) ;
+ // suppress space at the end
+ int j ;
+ for(j=MED_TAILLE_PNOM21-1;j>=0;j--)
+ if (myStringName[j] != ' ') break ;
+ _ptrMesh->_coordinate->_coordinateName[i]=string(myStringName,0,j+1);
+ for(j=MED_TAILLE_PNOM21-1;j>=0;j--)
+ if (myStringUnit[j] != ' ') break ;
+ _ptrMesh->_coordinate->_coordinateUnit[i]=string(myStringUnit,0,j+1);
+ }
+
+ string coordinateSystem = "UNDEFINED";
+
+ if( rep == med_2_1::MED_CART) coordinateSystem = "CARTESIAN";
+ else if ( rep == med_2_1::MED_CYL) coordinateSystem = "CYLINDRICAL";
+ else if ( rep == med_2_1::MED_SPHER) coordinateSystem = "SPHERICAL";
+
+ _ptrMesh->_coordinate->setCoordinatesSystem(coordinateSystem);
+
+
+ END_OF(LOC);
+}
+
+//=======================================================================
+//function : getCOORDINATE
+// A FAIRE : RENVOYER DU VOID
+//=======================================================================
+int MED_MESH_RDONLY_DRIVER21::getCOORDINATE()
+{
+ const char * LOC = "MED_MESH_RDONLY_DRIVER21::getCOORDINATE() : " ;
+ BEGIN_OF(LOC);
+
+ if (_status==MED_OPENED)
+ {
+ int err ;
+
+ // Read the dimension of the space for the mesh <_meshName>
+ // to be able to create a COORDINATE object
+ int SpaceDimension = med_2_1::MEDdimLire(_medIdt,const_cast <char *> (_meshName.c_str())) ;
+ if ( SpaceDimension <= MED_VALID )
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"The space dimension |" << SpaceDimension << "| seems to be incorrect "
+ << "for the mesh : |" << _meshName << "|")) ;
+ _ptrMesh->_spaceDimension = SpaceDimension ;
+
+
+
+ // Read the number of nodes used in the mesh <_meshName>
+ // to be able to create a COORDINATE object
+ int NumberOfNodes=MEDnEntMaa(_medIdt,
+ const_cast <char *> (_meshName.c_str()),
+ med_2_1::MED_COOR,
+ med_2_1::MED_NOEUD,
+ (med_2_1::med_geometrie_element) MED_NONE,
+ (med_2_1::med_connectivite) MED_NONE);
+ if ( NumberOfNodes <= MED_VALID )
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"The number of nodes |" << NumberOfNodes << "| seems to be incorrect "
+ << "for the mesh : |" << _meshName << "|" )) ;
+ _ptrMesh->_numberOfNodes = NumberOfNodes ;
+
+
+
+ // create a COORDINATE object
+ _ptrMesh->_coordinate = new COORDINATE(SpaceDimension, NumberOfNodes, MED_EN::MED_FULL_INTERLACE);
+
+ med_2_1::med_repere rep ; // ATTENTION ---> DOIT ETRE INTEGRE DS MESH EF: FAIT NON?
+ string tmp_nom_coord (MED_TAILLE_PNOM21*(_ptrMesh->_spaceDimension)+1,'\0');
+ string tmp_unit_coord(MED_TAILLE_PNOM21*(_ptrMesh->_spaceDimension)+1,'\0');
+ char * tmp_nom = (const_cast <char *> ( tmp_nom_coord.c_str()) ) ;
+ char * tmp_unit= (const_cast <char *> ( tmp_unit_coord.c_str()) ) ;
+
+ err=MEDcoordLire(_medIdt,
+ const_cast <char *> (_ptrMesh->_name.c_str()),
+ _ptrMesh->_spaceDimension,
+ //const_cast <double *> ( _ptrMesh->_coordinate->_coordinate->get(MED_EN::MED_FULL_INTERLACE) ),
+ const_cast <double *> ( _ptrMesh->_coordinate->_coordinate.get(MED_EN::MED_FULL_INTERLACE) ),
+ med_2_1::MED_FULL_INTERLACE,
+ MED_ALL, // we read all the coordinates
+ NULL, // we don't use a profile
+ 0, // so the profile's size is 0
+ &rep,tmp_nom,tmp_unit);
+ if (err != MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't read coordinates of the |" << NumberOfNodes << "| nodes "
+ << "for the mesh : |" << _meshName
+ << "| of space dimension |" << SpaceDimension
+ << "| with units names |" << tmp_nom
+ << "| and units |" << tmp_unit
+ << " |")) ;
+
+
+ for (int i=0;i<_ptrMesh->_spaceDimension;i++) {
+ string myStringName(tmp_nom_coord,i*MED_TAILLE_PNOM21,MED_TAILLE_PNOM21) ;
+ string myStringUnit(tmp_unit_coord,i*MED_TAILLE_PNOM21,MED_TAILLE_PNOM21) ;
+ // suppress space at the end
+ int j ;
+ for(j=MED_TAILLE_PNOM21-1;j>=0;j--)
+ if (myStringName[j] != ' ') break ;
+ _ptrMesh->_coordinate->_coordinateName[i]=string(myStringName,0,j+1);
+ for(j=MED_TAILLE_PNOM21-1;j>=0;j--)
+ if (myStringUnit[j] != ' ') break ;
+ _ptrMesh->_coordinate->_coordinateUnit[i]=string(myStringUnit,0,j+1);
+ }
+
+ // Pourquoi le stocker sous forme de chaîne ?
+ switch (rep)
+ {
+ case med_2_1::MED_CART :
+ {
+ _ptrMesh->_coordinate->_coordinateSystem = "CARTESIAN";
+ break ;
+ }
+ case med_2_1::MED_CYL :
+ {
+ _ptrMesh->_coordinate->_coordinateSystem = "CYLINDRICAL";
+ break ;
+ }
+ case med_2_1::MED_SPHER :
+ {
+ _ptrMesh->_coordinate->_coordinateSystem = "SPHERICAL";
+ break ;
+ }
+ default :
+ {
+ _ptrMesh->_coordinate->_coordinateSystem = "UNDEFINED"; // ?Erreur ?
+ break ;
+ }
+ }
+
+ // Read the unused optional node Names
+ char * tmp_node_name = new char[NumberOfNodes*MED_TAILLE_PNOM21+1];
+ tmp_node_name[NumberOfNodes]='\0' ;
+ err=MEDnomLire(_medIdt,const_cast <char*> (_ptrMesh->_name.c_str()),
+ tmp_node_name,NumberOfNodes*MED_TAILLE_PNOM21,med_2_1::MED_NOEUD,
+ (med_2_1::med_geometrie_element) MED_NONE);
+ if (err == MED_VALID)
+ MESSAGE(LOC<<"MED_MESH_RDONLY_DRIVER::getNoeuds() : WARNING : Nodes have names but we do not read them !");
+ delete[] tmp_node_name ;
+
+
+ // ??? Read the unused optional node Numbers ???
+ med_2_1::med_int * tmp_node_number = new med_2_1::med_int[NumberOfNodes] ;
+ err=MEDnumLire(_medIdt,const_cast <char*> (_ptrMesh->_name.c_str()),
+ tmp_node_number,NumberOfNodes,med_2_1::MED_NOEUD,(med_2_1::med_geometrie_element)0);
+ if (err == MED_VALID) {
+ // INFOS(LOC<<"WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING");
+ // INFOS(LOC<<"MED_MESH_RDONLY_DRIVER::getNoeuds() : WARNING : Nodes have numbers but we do not take care of them !");
+ // INFOS(LOC<<"WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING");
+ MESSAGE(LOC<<"MED_MESH_RDONLY_DRIVER::getNoeuds() : Nodes have numbers, we DO TAKE care of them !");
+ _ptrMesh->_coordinate->_nodeNumber.set(NumberOfNodes) ;
+#if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
+ for(med_2_1::med_int i2=0;i2<NumberOfNodes;i2++)
+ _ptrMesh->_coordinate->_nodeNumber[i2]=(int)(tmp_node_number[i2]);
+#else
+ memcpy((int*)_ptrMesh->_coordinate->_nodeNumber,tmp_node_number,sizeof(int)*NumberOfNodes) ;
+#endif
+
+ //////////////////////////////////////////////////////////////////////////////////////
+ /// Modification pour prise en compte de la numérotation optionnelle des noeuds ///
+ //////////////////////////////////////////////////////////////////////////////////////
+ ///
+ /// Calcule _optionnalToCanonicNodesNumbers de telle sorte que _optionnalToCanonicNodesNumbers[OptionnalNumber]==CanonicNumber
+
+// _ptrMesh->_arePresentOptionnalNodesNumbers=1;
+// for (int canonicNumber=1;canonicNumber<=NumberOfNodes;canonicNumber++) _ptrMesh->_optionnalToCanonicNodesNumbers[tmp_node_number[canonicNumber-1]]=canonicNumber;
+// ICI RETOUR A LA NORMALE::: AUCUNE PRISE EN COMPTE D'UN NUMEROTATION OPTIONNEL
+ _ptrMesh->_arePresentOptionnalNodesNumbers=0;
+ }
+ else _ptrMesh->_arePresentOptionnalNodesNumbers=0;
+
+ //////////////////////////////////////////////////////////////////////////////////////
+
+ delete[] tmp_node_number ;
+
+ END_OF(LOC);
+ return MED_VALID;
+ }
+ return MED_ERROR;
+}
+
+
+int MED_MESH_RDONLY_DRIVER21::getCONNECTIVITY()
+{
+ const char * LOC = "MED_MESH_RDONLY_DRIVER21::getCONNECTIVITY : " ;
+ BEGIN_OF(LOC);
+
+ if (_status==MED_OPENED)
+ {
+
+ int err = 0 ;
+ // read MED_CELL connectivity
+ CONNECTIVITY * Connectivity = new CONNECTIVITY(MED_CELL) ;
+ Connectivity->_numberOfNodes = _ptrMesh->_numberOfNodes ; // EF : Pourquoi cet attribut est-il dans MESH et non dans COORDINATE ?
+
+ // Try to read nodal connectivity of the cells <Connectivity->_nodal>
+ // then try to read descending connectivity <Connectivity->_descending>
+ // if neither nodal nor descending connectivity exists
+ // throw an exception.
+ err = getNodalConnectivity(Connectivity) ;
+ if (err!=MED_VALID)
+ {
+ Connectivity->_typeConnectivity = MED_DESCENDING ;
+ err = getDescendingConnectivity(Connectivity) ;
+ }
+ else
+ getDescendingConnectivity(Connectivity) ; // we read it if there is one
+
+ if (err!=MED_VALID)
+ {
+ delete Connectivity ;
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "We could not read " <<
+ "any Connectivity")) ;
+ }
+
+ _ptrMesh->_meshDimension = Connectivity->_entityDimension ;
+
+ // At this point Connectivity->_typeConnectivity is either NODAL or DESCENDING
+ // If both connectivities are found Connectivity->_typeConnectivity is NODAL
+ // If space dimension is 3
+ // try to read the nodal connectivity of the faces <ConnectivityFace->_nodal> then
+ // try to read the descending connectivity <ConnectivityFace->_descending>
+ // if there is no descending connectivity and the CELLS are
+ // defined in descending mode then throw an exception
+
+ // PROVISOIRE : if we have some face or edge in MED_MAILLE, we don't read more. There could not be have face or edge !!!!
+
+ if(Connectivity->_constituent==NULL)
+ {
+ SCRUTE(_ptrMesh->_meshDimension);
+ if (_ptrMesh->_meshDimension == 3)
+ {
+ MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE DES FACES..." );
+ CONNECTIVITY * ConnectivityFace = new CONNECTIVITY(MED_EN::MED_FACE) ;
+ ConnectivityFace->_typeConnectivity = Connectivity->_typeConnectivity ;
+ // NODAL or DESCENDING
+ SCRUTE(ConnectivityFace->_typeConnectivity);
+ if (Connectivity->_typeConnectivity == MED_DESCENDING)
+ {
+ MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE DESCENDANTE DES FACES" );
+ err = getDescendingConnectivity(ConnectivityFace) ;
+ if (err!=MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<
+ "No FACE in descending connectivity")) ;
+ getNodalConnectivity(ConnectivityFace) ; // if any !
+ }
+ else
+ {
+ MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE NODALE DES FACES" );
+ err = getNodalConnectivity(ConnectivityFace) ;
+ if (err!=MED_VALID)
+ { // or error ????? we are in NODAL mode.
+ err = getDescendingConnectivity(ConnectivityFace) ;
+ }
+ else
+ getDescendingConnectivity(ConnectivityFace); // if any !
+ }
+
+ if (err!=MED_VALID)
+ {
+ delete ConnectivityFace ;
+ MESSAGE(LOC<<"No FACE defined.") ;
+ }
+ else
+ {
+ MESSAGE(LOC<<" SAUVEGARDE DE LA CONNECTIVITE DES " <<
+ "FACES DANS L'OBJET CONNECTIVITY" );
+ Connectivity->_constituent=ConnectivityFace ;
+ }
+ }
+
+ // read MED_EDGE connectivity
+ if (_ptrMesh->_meshDimension > 1)
+ { // we are in 3 or 2D
+ MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE DES ARRETES...." );
+ CONNECTIVITY * ConnectivityEdge = new CONNECTIVITY(MED_EDGE) ;
+ ConnectivityEdge->_typeConnectivity = Connectivity->_typeConnectivity ;
+ if (Connectivity->_typeConnectivity == MED_DESCENDING)
+ {
+ MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE DESCENDANTE " <<
+ "DES ARRETES" );
+ err = getDescendingConnectivity(ConnectivityEdge) ;
+ if (err!=MED_VALID)
+ throw MEDEXCEPTION ( LOCALIZED(STRING(LOC) <<
+ "No EDGE in descending connectivity")) ;
+ getNodalConnectivity(ConnectivityEdge) ; // if any !
+ }
+ else
+ {
+ MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE NODALE DES ARRETES" );
+ err = getNodalConnectivity(ConnectivityEdge) ;
+ if (err!=MED_VALID)
+ { // or error ????? we are in NODAL mode.
+ err = getDescendingConnectivity(ConnectivityEdge) ;
+ }
+ else
+ getDescendingConnectivity(ConnectivityEdge) ; // if any !
+ }
+
+ if (err!=MED_VALID)
+ {
+ delete ConnectivityEdge ;
+ MESSAGE(LOC<<"No EDGE defined.") ;
+ }
+ else
+ {
+ if (_ptrMesh->_meshDimension == 3)
+ if (Connectivity->_constituent != NULL)
+ Connectivity->_constituent->_constituent=ConnectivityEdge ;
+ else
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<< "EDGE defined but there are no FACE !")) ;
+ else
+ { // IN 2D
+ MESSAGE(LOC<<" SAUVEGARDE DE LA CONNECTIVITE DES " <<
+ "ARETES DANS L'OBJET CONNECTIVITY" );
+ Connectivity->_constituent=ConnectivityEdge ;
+ }
+ }
+ }
+ }
+ _ptrMesh->_connectivity = Connectivity ;
+
+ // all right !
+
+ // we have read all connectivity in file, now we must build descending connectivity if necessary !
+
+ // If connectivity descending is defined, we have nothing to do, all constituent are defined !
+ // If connectivity is only nodal, we must rebuild descending if we have some contituent !
+
+ //A FAIRE !!!!
+// if (Connectivity->_descending == NULL)
+// if (Connectivity->_constituent != NULL){
+// // update Connectivity->_constituent
+// CONNECTIVITY * myConstituentOld = Connectivity->_constituent ;
+// Connectivity->_constituent = (CONNECTIVITY *)NULL ;
+// Connectivity->calculateDescendingConnectivity() ;
+
+// }
+
+ END_OF(LOC);
+ return MED_VALID;
+ }
+ return MED_ERROR;
+}
+
+int MED_MESH_RDONLY_DRIVER21::getNodalConnectivity(CONNECTIVITY * Connectivity)
+{
+ const char * LOC = "MED_MESH_RDONLY_DRIVER21::getNodalConnectivity : " ;
+ BEGIN_OF(LOC);
+
+ int spaceDimension = _ptrMesh->_spaceDimension;
+
+ if (_status==MED_OPENED)
+ {
+ // Get the type of entity to work on (previously set in the Connectivity Object)
+ med_2_1::med_entite_maillage Entity = (med_2_1::med_entite_maillage) Connectivity->getEntity();
+
+ // Get the number of cells of each type & store it in <tmp_cells_count>.
+ int * tmp_cells_count = new int[MED_NBR_GEOMETRIE_MAILLE] ;
+ int i;
+ for (i=1;i<MED_NBR_GEOMETRIE_MAILLE;i++)
+ { // EF :ON SCANNE DES GEOMETRIES INUTILES, UTILISER LES MAPS
+
+ tmp_cells_count[i]=MEDnEntMaa(_medIdt,(const_cast <char *> (_ptrMesh->_name.c_str())),
+ med_2_1::MED_CONN,(med_2_1::med_entite_maillage) Entity,
+ all_cell_type[i],med_2_1::MED_NOD);
+
+ // Get the greatest dimension of the cells : Connectivity->_entityDimension
+ // We suppose there is no cells used as faces in MED 2.2.x , this is forbidden !!!
+ // In version prior to 2.2.x, it is possible
+ if (tmp_cells_count[i]>0)
+ {
+ Connectivity->_entityDimension=all_cell_type[i]/100;
+ Connectivity->_numberOfTypes++;
+ }
+ }
+
+
+ // If there is no nodal connectivity, we quit !
+ if ( Connectivity->_numberOfTypes == 0 )
+ {
+ delete[] tmp_cells_count ;
+ return MED_ERROR ;
+ }
+
+ // if MED version < 2.2.x, we read only entity with dimention = Connectivity->_entityDimension. Lesser dimension are face or edge !
+
+ char version_med[10] ;
+ if ( MEDfichEntete(_medIdt,med_2_1::MED_VERSION,version_med) != 0 )
+ {
+ // error : we suppose we have not a good med file !
+ delete[] tmp_cells_count ;
+ return MED_ERROR ;
+ }
+
+ // we get MED version number
+ // If MED version is < 2.2 then the cells which dimension
+ // is lesser than the main dimension ( Connectivity->_entityDimension )
+ // are either faces or edges
+
+ // string medVersion(version_med);
+ // int firstNumber =
+ int * tmpEdgeCount = new int[MED_NBR_GEOMETRIE_MAILLE] ;
+ tmpEdgeCount[0] = 0 ;
+ int numberOfEdgesTypes = 0;
+ int * tmpFaceCount = new int[MED_NBR_GEOMETRIE_MAILLE] ;
+ tmpFaceCount[0] = 0 ;
+ int numberOfFacesTypes = 0;
+
+// if ((version_med != "2.2")&(Entity==med_2_1::MED_MAILLE))
+// {
+// Connectivity->_numberOfTypes=0;
+
+// for ( i=1;i<MED_NBR_GEOMETRIE_MAILLE;i++)
+// {
+// tmpFaceCount[i]=0;
+// tmpEdgeCount[i]=0;
+// if (tmp_cells_count[i]!=0)
+// {
+// int dimension = all_cell_type[i]/100 ;
+// if (Connectivity->_entityDimension==dimension)
+// Connectivity->_numberOfTypes++ ;
+
+// if (dimension == 2)
+// if (Connectivity->_entityDimension==3)
+// {
+// tmpFaceCount[i]=tmp_cells_count[i] ;
+// tmp_cells_count[i]=0 ;
+// numberOfFacesTypes++;
+// }
+// if (dimension == 1)
+// if (Connectivity->_entityDimension>dimension)
+// {
+// tmpEdgeCount[i]=tmp_cells_count[i] ;
+// tmp_cells_count[i]=0;
+// numberOfEdgesTypes++ ;
+// }
+// }
+// }
+// }
+
+ if (Entity==med_2_1::MED_MAILLE)
+ {
+ Connectivity->_numberOfTypes=0;
+
+ for ( i=1;i<MED_NBR_GEOMETRIE_MAILLE;i++)
+ {
+ tmpFaceCount[i]=0;
+ tmpEdgeCount[i]=0;
+ if (tmp_cells_count[i]!=0)
+ {
+ int dimension = all_cell_type[i]/100 ;
+ if (Connectivity->_entityDimension==dimension)
+ Connectivity->_numberOfTypes++ ;
+
+ if (dimension == 2)
+ if (Connectivity->_entityDimension==3)
+ {
+ tmpFaceCount[i]=tmp_cells_count[i] ;
+ //tmp_cells_count[i]=0 ;
+ //Connectivity->_numberOfTypes++ ;
+ numberOfFacesTypes++;
+ }
+ if (dimension == 1)
+ if (Connectivity->_entityDimension>dimension)
+ {
+ tmpEdgeCount[i]=tmp_cells_count[i] ;
+ //tmp_cells_count[i]=0;
+ //Connectivity->_numberOfTypes++ ;
+ numberOfEdgesTypes++ ;
+ }
+ }
+ }
+ }
+
+ // bloc to read CELL :
+ {
+ // Prepare an array of indexes on the different cell types to create a MEDSKYLINEARRAY
+ // We use <tmp_cells_count> to calculate <Connectivity->_count> then we release it
+ Connectivity->_geometricTypes = new MED_EN::medGeometryElement [Connectivity->_numberOfTypes] ; // Double emploi pour des raisons pratiques
+ Connectivity->_type = new CELLMODEL [Connectivity->_numberOfTypes] ; //
+ Connectivity->_count = new int [Connectivity->_numberOfTypes+1] ;
+ Connectivity->_count[0] = 1;
+
+ int size = 0 ;
+ int typeNumber=1 ;
+ int i;
+ for ( i=1;i<MED_NBR_GEOMETRIE_MAILLE;i++)
+ { // no point1 cell type (?)
+ int dimension = all_cell_type[i]/100 ;
+ if ((tmp_cells_count[i]>0) && (Connectivity->_entityDimension == dimension))
+ {
+ Connectivity->_count[typeNumber]=Connectivity->_count[typeNumber-1]+tmp_cells_count[i];
+
+ CELLMODEL t( (MED_EN::medGeometryElement) MED_MESH_DRIVER21::all_cell_type[i]) ;
+
+ Connectivity->_type[typeNumber-1] = t ;
+
+ Connectivity->_geometricTypes[typeNumber-1]=( MED_EN::medGeometryElement) MED_MESH_DRIVER21::all_cell_type[i] ;
+
+ // probleme avec les mailles de dimension < a dimension du maillage :
+ // Il faut oter le zero a la lecture est le remettre a l'ecriture : ce n'est pas fait !!!!! On interdit ce cas pour l'instant !!!
+
+
+ size+=tmp_cells_count[i]*((MED_MESH_DRIVER21::all_cell_type[i])%100) ;
+
+ MESSAGE(LOC
+ << Connectivity->_count[typeNumber]-1 << " cells of type "
+ << all_cell_type_tab[i] );
+
+ typeNumber++;
+ }
+ }
+
+ // Creation of the MEDSKYLINEARRAY
+ //Connectivity->_nodal = new MEDSKYLINEARRAY(Connectivity->_count[Connectivity->_numberOfTypes]-1,size) ;
+ //int * NodalIndex = Connectivity->_nodal->getIndex() ;
+ int * NodalValue = new int[size] ;
+ int * NodalIndex = new int[Connectivity->_count[Connectivity->_numberOfTypes]] ;
+ NodalIndex[0]=1 ;
+
+ // Fill the MEDSKYLINEARRAY by reading the MED file.
+ int j=0;
+ for ( i=0;i<Connectivity->_numberOfTypes;i++)
+ {
+ int multi = 0 ;
+ med_2_1::med_geometrie_element med_type = (med_2_1::med_geometrie_element) Connectivity->_type[i].getType() ;
+ //if ( Connectivity->_type[i].getDimension() < Connectivity->_entityDimension)
+ if (Connectivity->_entity == MED_CELL)
+ if ( Connectivity->_type[i].getDimension() < spaceDimension)
+ multi=1;
+
+ // int NumberOfCell = Connectivity->_count[i+1]-Connectivity->_count[i] ;
+ int NumberOfNodeByCell = Connectivity->_type[i].getNumberOfNodes() ;
+
+ // initialise index
+ for ( j=Connectivity->_count[i]; j<Connectivity->_count[i+1];j++)
+ NodalIndex[j]=NodalIndex[j-1]+NumberOfNodeByCell ;
+
+ int tmp_numberOfCells = Connectivity->_count[i+1]-Connectivity->_count[i] ;
+ med_2_1::med_int * tmp_ConnectivityArray = new med_2_1::med_int[(NumberOfNodeByCell+multi)*tmp_numberOfCells];
+
+ //int err=MEDconnLire(_medIdt,const_cast <char *> (_ptrMesh->_name.c_str()),
+ // Connectivity->_entityDimension,tmp_ConnectivityArray,
+ //med_2_1::MED_FULL_INTERLACE,NULL,0,Entity,med_type,med_2_1::MED_NOD);
+
+ int err=MEDconnLire(_medIdt,const_cast <char *> (_ptrMesh->_name.c_str()),
+ spaceDimension,tmp_ConnectivityArray,
+ med_2_1::MED_FULL_INTERLACE,NULL,0,Entity,med_type,
+ med_2_1::MED_NOD);
+
+ if ( err != MED_VALID)
+ {
+ delete[] tmp_ConnectivityArray;
+ delete[] tmp_cells_count;
+ delete[] tmpFaceCount;
+ delete[] tmpEdgeCount;
+ MESSAGE(LOC<<": MEDconnLire returns "<<err) ;
+ return MED_ERROR ;
+ }
+
+ int * ConnectivityArray = NodalValue + NodalIndex[Connectivity->_count[i]-1]-1 ;
+
+ // version originale sans prise en compte des numéros optionnels
+ //
+ for ( j=0; j<tmp_numberOfCells; j++) for (int k=0; k<NumberOfNodeByCell; k++)
+ ConnectivityArray[j*NumberOfNodeByCell+k]=(int)(tmp_ConnectivityArray[j*(NumberOfNodeByCell+multi)+k]) ;
+
+ //////////////////////////////////////////////////////////////////////////////
+ // Modification pour prise en compte de la numérotation optionnelle des noeuds ///
+ //////////////////////////////////////////////////////////////////////////////
+ //
+ // Rénumérote le tableau temporaire tmp_ConnectivityArray en utilisant _optionnalToCanonicNodesNumbers
+ // Le traitement est identique à la version originelle s'il n'y a pas de numérotation optionnelle
+
+ // if (_ptrMesh->_arePresentOptionnalNodesNumbers==1)
+ // {
+ // for ( j=0; j<tmp_numberOfCells; j++) for (int k=0; k<NumberOfNodeByCell; k++)
+ // ConnectivityArray[j*NumberOfNodeByCell+k]=_ptrMesh->_optionnalToCanonicNodesNumbers[tmp_ConnectivityArray[j*(NumberOfNodeByCell+multi)+k]] ;
+ // }
+ // else
+ // {
+ // for ( j=0; j<tmp_numberOfCells; j++) for (int k=0; k<NumberOfNodeByCell; k++)
+ // ConnectivityArray[j*NumberOfNodeByCell+k]=tmp_ConnectivityArray[j*(NumberOfNodeByCell+multi)+k] ;
+ // }
+ ////////////////////////////////////////////////////////////////////////////
+
+ delete[] tmp_ConnectivityArray;
+ }
+
+ Connectivity->_nodal = new MEDSKYLINEARRAY(Connectivity->_count[Connectivity->_numberOfTypes]-1,
+ size,
+ NodalIndex,
+ NodalValue) ;
+
+ delete[] NodalIndex;
+ delete[] NodalValue;
+ } // end of bloc to read CELL
+
+ delete[] tmp_cells_count;
+
+
+
+ // Get Face if any
+ // ===============
+
+ if (numberOfFacesTypes!=0) {
+
+ // Create a CONNECTIVITY constituent to put in the top level CONNECTIVITY recursive class
+ CONNECTIVITY * constituent = new CONNECTIVITY(numberOfFacesTypes,MED_EN::MED_FACE) ;
+ constituent->_entityDimension = 2 ;
+ constituent->_count[0]=1 ;
+
+ // In order to create the MEDSKYLINEARRAY of the constituent object we need :
+ // 1:
+ // To initialize the _count array of the constituent object (containning cumulated face count by geometric type)
+ // _count[0]=1 and _count[_numberOfTypes] give the size of NodalIndex
+ // 2:
+ // To calculate the total number of face nodes whatever the geometric type is.
+ // The result is the size of the array containning all the nodes : NodalValue
+ // 3 :
+ // To calculate the starting indexes of the different face types in NodalValue,
+ // this is the NodalIndex array.
+
+ int size = 0 ;
+ int typeNumber = 1 ;
+ int i;
+ for ( i=1; i < MED_NBR_GEOMETRIE_MAILLE; i++) { // no point1 cell type (?)
+ if (tmpFaceCount[i]>0) {
+
+ constituent->_count[typeNumber] = constituent->_count[typeNumber-1] + tmpFaceCount[i];
+ CELLMODEL t( (MED_EN::medGeometryElement) MED_MESH_DRIVER21::all_cell_type[i]) ;
+ constituent->_type[typeNumber-1]=t ;
+
+ constituent->_geometricTypes[typeNumber-1]=( MED_EN::medGeometryElement) MED_MESH_DRIVER21::all_cell_type[i] ;
+
+ size+=tmpFaceCount[i]*((MED_MESH_DRIVER21::all_cell_type[i])%100) ;
+ typeNumber++;
+ }
+ }
+
+ // Creation of the MEDSKYLINEARRAY
+ //constituent->_nodal = new MEDSKYLINEARRAY(constituent->_count[constituent->_numberOfTypes]-1,size) ;
+ //int * NodalIndex = constituent->_nodal->getIndex() ;
+ int * NodalValue = new int[size] ;
+ int * NodalIndex = new int[constituent->_count[constituent->_numberOfTypes]] ;
+ NodalIndex[0]=1 ;
+
+ // Fill the MEDSKYLINEARRAY by reading the MED file.
+ for ( i=0; i<constituent->_numberOfTypes; i++) {
+ med_2_1::med_geometrie_element med_type = (med_2_1::med_geometrie_element) constituent->_type[i].getType() ;
+
+ int NumberOfNodeByFace = constituent->_type[i].getNumberOfNodes() ;
+
+ // initialise NodalIndex
+ for (int j=constituent->_count[i]; j<constituent->_count[i+1];j++)
+ NodalIndex[j]=NodalIndex[j-1]+NumberOfNodeByFace ;
+
+ int tmp_numberOfFaces = constituent->_count[i+1]-constituent->_count[i] ;
+ // Il faut ajouter 1 pour le zero a la lecture !!!
+ // ATTENTION UNIQUEMENT POUR MED < 2.2.x
+ med_2_1::med_int * tmp_constituentArray = NULL;
+ if (version_med != "2.2")
+ tmp_constituentArray = new med_2_1::med_int[(NumberOfNodeByFace+1)*tmp_numberOfFaces] ;
+ else {
+ tmp_constituentArray = new med_2_1::med_int[NumberOfNodeByFace*tmp_numberOfFaces] ;
+ MESSAGE(LOC<<": WE ARE USING MED2.2 so there is no +1 for calculating the size of tmp_constituentArray !") ;
+ }
+
+ int err=MEDconnLire(_medIdt,const_cast <char *> (_ptrMesh->_name.c_str()),
+ Connectivity->_entityDimension,tmp_constituentArray,
+ med_2_1::MED_FULL_INTERLACE,NULL,0,med_2_1::MED_MAILLE,med_type,med_2_1::MED_NOD);
+
+ if ( err != MED_VALID) {
+ MESSAGE(LOC<<": MEDconnLire returns "<<err) ;
+ delete constituent ;
+ delete[] tmp_constituentArray;
+ delete[] tmpFaceCount;
+ delete[] tmpEdgeCount;
+ return MED_ERROR ;
+ }
+
+ int * constituentArray = NodalValue + NodalIndex[constituent->_count[i]-1]-1 ;
+
+ // version originale sans prise en compte des numéros optionnels
+ //
+ for (int j=0; j<tmp_numberOfFaces; j++)
+ for (int k=0; k<NumberOfNodeByFace; k++)
+ constituentArray[j*NumberOfNodeByFace+k]=(int)(tmp_constituentArray[j*(NumberOfNodeByFace+1)+k]) ;
+
+ //////////////////////////////////////////////////////////////////////////////////////
+ /// Modification pour prise en compte de la numérotation optionnelle des noeuds ///
+ //////////////////////////////////////////////////////////////////////////////////////
+ ///
+ /// Rénumérote le tableau temporaire tmp_constituentArray en utilisant _optionnalToCanonicNodesNumbers
+ /// Le traitement est identique à la version originelle s'il n'y a pas de numérotation optionnelle
+
+// if (_ptrMesh->_arePresentOptionnalNodesNumbers)
+// {
+// for (int j=0; j<tmp_numberOfFaces; j++) for (int k=0; k<NumberOfNodeByFace; k++)
+// constituentArray[j*NumberOfNodeByFace+k]=_ptrMesh->_optionnalToCanonicNodesNumbers[tmp_constituentArray[j*(NumberOfNodeByFace+1)+k]] ;
+// }
+// else
+// {
+// for (int j=0; j<tmp_numberOfFaces; j++) for (int k=0; k<NumberOfNodeByFace; k++)
+// constituentArray[j*NumberOfNodeByFace+k]=tmp_constituentArray[j*(NumberOfNodeByFace+1)+k] ;
+// }
+
+ //////////////////////////////////////////////////////////////////////////////////////
+
+ delete[] tmp_constituentArray;
+ }
+
+ constituent->_nodal = new MEDSKYLINEARRAY(constituent->_count[constituent->_numberOfTypes]-1,
+ size,
+ NodalIndex,
+ NodalValue) ;
+ delete[] NodalIndex ;
+ delete[] NodalValue ;
+
+ Connectivity->_constituent = constituent ;
+ }
+
+ delete[] tmpFaceCount;
+
+ // get Edge if any
+ // ===============
+ if (numberOfEdgesTypes!=0) {
+ CONNECTIVITY * constituent = new CONNECTIVITY(numberOfEdgesTypes,MED_EDGE) ;
+ constituent->_entityDimension = 1 ;
+ constituent->_count[0]=1 ;
+
+ int size = 0 ;
+ int typeNumber=1 ;
+ // if you declare a variable <i> in two <for> initialization statement,
+ // compiler gcc2.95.3 says nothing but there are two <i> variables in the same block
+ //and the value you get in the common block seems to be the value of the first variable !
+ int i;
+
+ for ( i=1; i<MED_NBR_GEOMETRIE_MAILLE; i++) { // no point1 cell type (?)
+ if (tmpEdgeCount[i]>0) {
+
+ constituent->_count[typeNumber]=constituent->_count[typeNumber-1]+tmpEdgeCount[i];
+ CELLMODEL t( (MED_EN::medGeometryElement) MED_MESH_DRIVER21::all_cell_type[i]) ;
+ constituent->_type[typeNumber-1]=t ;
+
+ constituent->_geometricTypes[typeNumber-1]=( MED_EN::medGeometryElement) MED_MESH_DRIVER21::all_cell_type[i] ;
+
+ size+=tmpEdgeCount[i]*((MED_MESH_DRIVER21::all_cell_type[i])%100) ;
+ typeNumber++;
+ }
+ }
+
+ // Creation of the MEDSKYLINEARRAY
+ //constituent->_nodal = new MEDSKYLINEARRAY(constituent->_count[constituent->_numberOfTypes]-1,size) ;
+ //int * NodalIndex = constituent->_nodal->getIndex() ;
+ int * NodalValue = new int[size] ;
+ int * NodalIndex = new int[constituent->_count[constituent->_numberOfTypes]] ;
+ NodalIndex[0]=1 ;
+
+ // Fill the MEDSKYLINEARRAY by reading the MED file.
+ for ( i=0; i<constituent->_numberOfTypes; i++) {
+ med_2_1::med_geometrie_element med_type = (med_2_1::med_geometrie_element) constituent->_type[i].getType() ;
+
+ int NumberOfNodeByEdge = constituent->_type[i].getNumberOfNodes() ;
+
+ // initialise index
+ for (int j=constituent->_count[i]; j<constituent->_count[i+1];j++)
+ NodalIndex[j]=NodalIndex[j-1]+NumberOfNodeByEdge ;
+
+ int tmp_numberOfEdges = constituent->_count[i+1]-constituent->_count[i] ;
+ // Il faut ajouter 1 pour le zero a la lecture !!!
+
+ // ATTENTION UNIQUEMENT POUR MED < 2.2.x
+ med_2_1::med_int * tmp_constituentArray = NULL;
+ if (version_med != "2.2")
+ tmp_constituentArray = new med_2_1::med_int[(NumberOfNodeByEdge+1)*tmp_numberOfEdges] ;
+ else {
+ tmp_constituentArray = new med_2_1::med_int[NumberOfNodeByEdge*tmp_numberOfEdges] ;
+ MESSAGE(LOC<<": WE ARE USING MED2.2 so there is no +1 for calculating the size of tmp_constituentArray !") ;
+ }
+
+ int err=MEDconnLire(_medIdt,const_cast <char *> (_ptrMesh->_name.c_str()),
+ spaceDimension,tmp_constituentArray,
+ med_2_1::MED_FULL_INTERLACE,NULL,0,med_2_1::MED_MAILLE,
+ med_type,med_2_1::MED_NOD);
+ if ( err != MED_VALID) {
+ MESSAGE(LOC<<": MEDconnLire returns "<<err) ;
+ delete constituent ;
+ delete[] tmp_constituentArray;
+ delete[] tmpEdgeCount;
+ return MED_ERROR ;
+ }
+
+ int * constituentArray = NodalValue + NodalIndex[constituent->_count[i]-1]-1 ;
+
+ // version originale sans prise en compte des numéros optionnels
+ //
+ for (int j=0; j<tmp_numberOfEdges; j++)
+ for (int k=0; k<NumberOfNodeByEdge; k++)
+ constituentArray[j*NumberOfNodeByEdge+k]=(int)(tmp_constituentArray[j*(NumberOfNodeByEdge+1)+k]) ;
+
+ //////////////////////////////////////////////////////////////////////////////////////
+ /// Modification pour prise en compte de la numérotation optionnelle des noeuds ///
+ //////////////////////////////////////////////////////////////////////////////////////
+ ///
+ /// Rénumérote le tableau temporaire tmp_constituentArray en utilisant _optionnalToCanonicNodesNumbers
+ /// Le traitement est identique à la version originelle s'il n'y a pas de numérotation optionnelle
+
+// if (_ptrMesh->_arePresentOptionnalNodesNumbers)
+// {
+// for (int j=0; j<tmp_numberOfEdges; j++) for (int k=0; k<NumberOfNodeByEdge; k++)
+// constituentArray[j*NumberOfNodeByEdge+k]=_ptrMesh->_optionnalToCanonicNodesNumbers[tmp_constituentArray[j*(NumberOfNodeByEdge+1)+k]] ;
+// }
+// else
+// {
+// for (int j=0; j<tmp_numberOfEdges; j++) for (int k=0; k<NumberOfNodeByEdge; k++)
+// constituentArray[j*NumberOfNodeByEdge+k]=tmp_constituentArray[j*(NumberOfNodeByEdge+1)+k] ;
+// }
+
+ //////////////////////////////////////////////////////////////////////////////////////
+
+ delete[] tmp_constituentArray;
+ }
+
+ constituent->_nodal = new MEDSKYLINEARRAY(constituent->_count[constituent->_numberOfTypes]-1,
+ size,
+ NodalIndex,
+ NodalValue) ;
+
+ delete[] NodalIndex ;
+ delete[] NodalValue ;
+
+ if (Connectivity->_entityDimension == 3) {
+ if (Connectivity->_constituent==NULL)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Edges are defined but there are no Faces !"));
+ Connectivity->_constituent->_constituent = constituent ;
+ } else
+ Connectivity->_constituent = constituent ;
+ }
+
+ delete[] tmpEdgeCount;
+
+ return MED_VALID;
+ }
+
+ return MED_ERROR;
+}
+
+int MED_MESH_RDONLY_DRIVER21::getFAMILY()
+{
+ const char * LOC = "MED_MESH_RDONLY_DRIVER21::getFAMILY() : " ;
+ BEGIN_OF(LOC);
+
+ if (_status==MED_OPENED) {
+ int err = 0 ;
+
+ int * MEDArrayNodeFamily = NULL ;
+ int ** MEDArrayCellFamily = NULL ;
+ int ** MEDArrayFaceFamily = NULL ;
+ int ** MEDArrayEdgeFamily = NULL ;
+
+ if ( !_ptrMesh->getIsAGrid() )
+ {
+ // read number :
+ // NODE :
+ MEDArrayNodeFamily = new int[_ptrMesh->getNumberOfNodes()] ;
+ err = getNodesFamiliesNumber(MEDArrayNodeFamily) ; // error only if (_status!=MED_OPENED), other case exeception !
+ // CELL
+
+ MESSAGE(LOC << "error returned from getNodesFamiliesNumber " << err);
+
+ MEDArrayCellFamily = new int*[_ptrMesh->getNumberOfTypes(MED_CELL)] ; // ET SI IL N'Y A PAS DE CELLS ?
+ const medGeometryElement * myTypes = _ptrMesh->getTypes(MED_CELL);
+ for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_CELL);i++)
+ MEDArrayCellFamily[i] = new int[_ptrMesh->getNumberOfElements(MED_CELL,myTypes[i])] ;
+
+ err = getCellsFamiliesNumber(MEDArrayCellFamily,_ptrMesh->_connectivity,MED_CELL) ;
+
+ MESSAGE(LOC << "error returned from getCellsFamiliesNumber for Cells " << err);
+
+ if (_ptrMesh->_connectivity->_constituent != NULL) {
+ if (_ptrMesh->_connectivity->_constituent->_entity == MED_EN::MED_FACE) {
+ // FACE
+ MEDArrayFaceFamily = new int*[_ptrMesh->getNumberOfTypes(MED_FACE)] ;
+ myTypes = _ptrMesh->getTypes(MED_FACE);
+ for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_FACE);i++)
+ MEDArrayFaceFamily[i] = new int[_ptrMesh->getNumberOfElements(MED_FACE,myTypes[i])] ;
+
+ err = getCellsFamiliesNumber(MEDArrayFaceFamily,_ptrMesh->_connectivity->_constituent,MED_FACE) ;
+
+ MESSAGE(LOC << "error returned from getCellsFamiliesNumber for Faces " << err);
+
+ } else {
+ // EDGE in 2D
+ MEDArrayEdgeFamily = new int*[_ptrMesh->getNumberOfTypes(MED_EDGE)] ;
+ myTypes = _ptrMesh->getTypes(MED_EDGE);
+ for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_EDGE);i++)
+ MEDArrayEdgeFamily[i] = new int[_ptrMesh->getNumberOfElements(MED_EDGE,myTypes[i])] ;
+ err = getCellsFamiliesNumber(MEDArrayEdgeFamily,_ptrMesh->_connectivity->_constituent,MED_EDGE) ;
+
+ MESSAGE(LOC << "error returned from getCellsFamiliesNumber for Edges in 2D " << err);
+
+ }
+ // EDGE in 3D
+ if (_ptrMesh->_connectivity->_constituent->_constituent != NULL) {
+ MEDArrayEdgeFamily = new int*[_ptrMesh->getNumberOfTypes(MED_EDGE)] ;
+ myTypes = _ptrMesh->getTypes(MED_EDGE);
+ for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_EDGE);i++)
+ MEDArrayEdgeFamily[i] = new int[_ptrMesh->getNumberOfElements(MED_EDGE,myTypes[i])] ;
+ err = getCellsFamiliesNumber(MEDArrayEdgeFamily,_ptrMesh->_connectivity->_constituent->_constituent,MED_EDGE) ; // we are in 3D !
+
+ MESSAGE(LOC << "error returned from getCellsFamiliesNumber for Edges in 3D " << err);
+
+ }
+ }
+ }
+ else
+ {
+ // node
+ int NumberOfNodes = _ptrMesh->getNumberOfNodes() ;
+ MEDArrayNodeFamily = new int[ NumberOfNodes ];
+#if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
+ med_2_1::med_int* MEDArrayNodeFamily2 = new med_2_1::med_int[ NumberOfNodes ];
+ err = med_2_1::MEDfamGridLire (_medIdt,
+ const_cast <char *> (_ptrMesh->_name.c_str()),
+ MEDArrayNodeFamily2,
+ NumberOfNodes,
+ med_2_1::MED_NOEUD);
+ for(int i=0;i<NumberOfNodes;i++)
+ MEDArrayNodeFamily[i]=(int) MEDArrayNodeFamily2[i];
+ delete [] MEDArrayNodeFamily2;
+#else
+ err = med_2_1::MEDfamGridLire (_medIdt,
+ const_cast <char *> (_ptrMesh->_name.c_str()),
+ MEDArrayNodeFamily,
+ NumberOfNodes,
+ med_2_1::MED_NOEUD);
+#endif
+ // what about cell face and edge ?
+ }
+
+ // Creation of the families
+ int NumberOfFamilies = MEDnFam(_medIdt,const_cast <char *> (_meshName.c_str()),0,med_2_1::MED_FAMILLE) ;
+ if ( NumberOfFamilies < 1 ) // at least family 0 must exist
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"There is no FAMILY, FAMILY 0 must exists" ));
+
+ SCRUTE(NumberOfFamilies);
+
+ vector<FAMILY*> &NodeFamilyVector = _ptrMesh->_familyNode ;
+ vector<FAMILY*> &CellFamilyVector = _ptrMesh->_familyCell ;
+ vector<FAMILY*> &FaceFamilyVector = _ptrMesh->_familyFace ;
+ vector<FAMILY*> &EdgeFamilyVector = _ptrMesh->_familyEdge ;
+
+ int numberOfNodesFamilies = 0 ;
+ int numberOfCellsFamilies = 0 ;
+ int numberOfFacesFamilies = 0 ;
+ int numberOfEdgesFamilies = 0 ;
+
+ for (int i=0;i<NumberOfFamilies;i++) {
+
+ med_2_1::med_int NumberOfAttributes = MEDnFam(_medIdt,const_cast <char *> (_meshName.c_str()),i+1,med_2_1::MED_ATTR) ;
+ if (NumberOfAttributes < 0)
+ throw MEDEXCEPTION("MED_MESH_RDONLY_DRIVER21::getFAMILY() : NumberOfAttributes" );
+
+ med_2_1::med_int NumberOfGroups = MEDnFam(_medIdt,const_cast <char *> (_meshName.c_str()),i+1,med_2_1::MED_GROUPE) ;
+ if (NumberOfGroups < 0)
+ throw MEDEXCEPTION("MED_MESH_RDONLY_DRIVER21::getFAMILY() : NumberOfGroups" );
+
+ med_2_1::med_int FamilyIdentifier ;
+ string FamilyName(MED_TAILLE_NOM,'\0');
+ int * AttributesIdentifier = new int[NumberOfAttributes] ;
+ int * AttributesValues = new int[NumberOfAttributes] ;
+ string AttributesDescription(MED_TAILLE_DESC*NumberOfAttributes,' ') ;
+ string GroupsNames(MED_TAILLE_LNOM*NumberOfGroups+1,'\0') ;
+#if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
+ med_2_1::med_int tmp_NumberOfAttributes=NumberOfAttributes;
+ med_2_1::med_int * AttributesIdentifier2 = new med_2_1::med_int[NumberOfAttributes] ;
+ med_2_1::med_int * AttributesValues2 = new med_2_1::med_int[NumberOfAttributes] ;
+ err = med_2_1::MEDfamInfo(_medIdt,const_cast <char *> (_meshName.c_str()),
+ i+1,const_cast <char *> (FamilyName.c_str()),
+ &FamilyIdentifier,AttributesIdentifier2,AttributesValues2,
+ const_cast <char *> (AttributesDescription.c_str()),
+ &NumberOfAttributes,
+ const_cast <char *> (GroupsNames.c_str()),&NumberOfGroups
+ );
+ for(med_2_1::med_int i2=0;i2<tmp_NumberOfAttributes;i2++)
+ {
+ AttributesIdentifier[i2]=(int)(AttributesIdentifier2[i2]);
+ AttributesValues[i2]=(int)(AttributesValues2[i2]);
+ }
+ delete [] AttributesIdentifier2;
+ delete [] AttributesValues2;
+#else
+ err = med_2_1::MEDfamInfo(_medIdt,const_cast <char *> (_meshName.c_str()),
+ i+1,const_cast <char *> (FamilyName.c_str()),
+ &FamilyIdentifier,AttributesIdentifier,AttributesValues,
+ const_cast <char *> (AttributesDescription.c_str()),
+ &NumberOfAttributes,
+ const_cast <char *> (GroupsNames.c_str()),&NumberOfGroups
+ );
+#endif
+
+ SCRUTE(GroupsNames);
+ SCRUTE(FamilyName);
+ SCRUTE(err);
+ SCRUTE(i);
+
+ if (err != MED_VALID)
+ throw MEDEXCEPTION("MED_MESH_RDONLY_DRIVER21::getFAMILY() : ERROR when get FAMILY informations" );
+ if (FamilyIdentifier != 0 ) {
+ FAMILY * Family = new FAMILY(_ptrMesh,(int)FamilyIdentifier,FamilyName,
+ (int)NumberOfAttributes,AttributesIdentifier,
+ AttributesValues,AttributesDescription,
+ (int)NumberOfGroups,GroupsNames,
+ MEDArrayNodeFamily,
+ MEDArrayCellFamily,
+ MEDArrayFaceFamily,
+ MEDArrayEdgeFamily
+ ) ;
+ // All good ?
+ // if nothing found, delete Family
+
+
+ //MESSAGE(LOC << " Well is that OK now ?? " << (*Family));
+
+
+
+ if (Family->getNumberOfTypes() == 0) {
+ MESSAGE(LOC<<"Nothing found for family "<<FamilyName<< " : skip");
+ delete Family;
+ } else
+ switch (Family->getEntity()) {
+ case MED_EN::MED_NODE :
+ NodeFamilyVector.push_back(Family) ;
+ numberOfNodesFamilies++ ;
+ break ;
+ case MED_EN::MED_CELL :
+ CellFamilyVector.push_back(Family) ;
+ numberOfCellsFamilies++ ;
+ break ;
+ case MED_EN::MED_FACE :
+ FaceFamilyVector.push_back(Family) ;
+ numberOfFacesFamilies++ ;
+ break ;
+ case MED_EN::MED_EDGE :
+ EdgeFamilyVector.push_back(Family) ;
+ numberOfEdgesFamilies++ ;
+ break ;
+ }
+
+ // MESSAGE(LOC << (*Family));
+
+
+
+
+ }
+
+ delete [] AttributesIdentifier ;
+ delete [] AttributesValues ;
+ }
+
+ if (MEDArrayNodeFamily != NULL)
+ delete[] MEDArrayNodeFamily ;
+ if (MEDArrayCellFamily != NULL) {
+ for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_CELL);i++)
+ delete[] MEDArrayCellFamily[i] ;
+ delete[] MEDArrayCellFamily ;
+ }
+ if (MEDArrayFaceFamily != NULL) {
+ for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_FACE);i++)
+ delete[] MEDArrayFaceFamily[i] ;
+ delete[] MEDArrayFaceFamily ;
+ }
+ if (MEDArrayEdgeFamily != NULL) {
+ for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_EDGE);i++)
+ delete[] MEDArrayEdgeFamily[i] ;
+ delete[] MEDArrayEdgeFamily ;
+ }
+
+ END_OF(LOC);
+ return MED_VALID ;
+ }
+ return MED_ERROR;
+}
+
+int MED_MESH_RDONLY_DRIVER21::getNodesFamiliesNumber(int * MEDArrayNodeFamily)
+{
+ const char * LOC = "MED_MESH_RDONLY_DRIVER21::getNodesFamiliesNumber() : " ;
+ BEGIN_OF(LOC);
+ if (_status==MED_OPENED) {
+ int err = 0 ;
+#if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
+ int lgth=_ptrMesh->getNumberOfNodes();
+ med_2_1::med_int *temp=new med_2_1::med_int[lgth];
+ err = MEDfamLire(_medIdt,(const_cast <char *> (_ptrMesh->_name.c_str())),
+ temp,
+ _ptrMesh->getNumberOfNodes(),
+ med_2_1::MED_NOEUD,(med_2_1::med_geometrie_element) MED_NONE);
+ for(int i2=0;i2<lgth;i2++)
+ MEDArrayNodeFamily[i2]=(int)(temp[i2]);
+ delete [] temp;
+#else
+ err = MEDfamLire(_medIdt,(const_cast <char *> (_ptrMesh->_name.c_str())),
+ MEDArrayNodeFamily,
+ _ptrMesh->getNumberOfNodes(),
+ med_2_1::MED_NOEUD,(med_2_1::med_geometrie_element) MED_NONE);
+#endif
+ if ( err != MED_VALID) {
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "There is no family for the |"<< _ptrMesh->getNumberOfNodes()
+ << "| nodes in mesh |"
+ << _ptrMesh->_name.c_str() << "|" ));
+ }
+ END_OF(LOC);
+ return MED_VALID;
+ }
+ return MED_ERROR;
+}
+
+int MED_MESH_RDONLY_DRIVER21::getCellsFamiliesNumber(int **MEDArrayFamily,
+ CONNECTIVITY *Connectivity,
+ MED_EN::medEntityMesh entity)
+{
+ const char * LOC = "MED_MESH_RDONLY_DRIVER21::getCellsFamiliesNumber " ;
+ BEGIN_OF(LOC);
+
+ if (_status==MED_OPENED) {
+ int i, err = 0 ;
+ for (i=0;i<Connectivity->_numberOfTypes;i++) {
+ int NumberOfCell = Connectivity->_count[i+1]-Connectivity->_count[i] ;
+#if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
+ const medGeometryElement * myTypes = _ptrMesh->getTypes(entity);
+ int lgthI=_ptrMesh->getNumberOfElements(entity,myTypes[i]);
+ med_2_1::med_int *temp=new med_2_1::med_int[lgthI];
+ err=MEDfamLire(_medIdt,const_cast <char *> (_ptrMesh->_name.c_str()),
+ temp,NumberOfCell,
+ (med_2_1::med_entite_maillage) Connectivity->_entity,
+ (med_2_1::med_geometrie_element) Connectivity->_geometricTypes[i]);
+ for(int i2=0;i2<lgthI;i2++)
+ MEDArrayFamily[i][i2]=(int)(temp[i2]);
+ delete [] temp;
+#else
+ err=MEDfamLire(_medIdt,const_cast <char *> (_ptrMesh->_name.c_str()),
+ MEDArrayFamily[i],NumberOfCell,
+ (med_2_1::med_entite_maillage) Connectivity->_entity,
+ (med_2_1::med_geometrie_element) Connectivity->_geometricTypes[i]);
+#endif
+
+ // provisoire : si les faces ou les aretes sont des mailles !!!
+ if (err != MED_VALID) {
+ MESSAGE(LOC<<"search face/edge family on cell !!!");
+#if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
+ int lgthI=_ptrMesh->getNumberOfElements(entity,myTypes[i]);
+ med_2_1::med_int *temp=new med_2_1::med_int[lgthI];
+ err=MEDfamLire(_medIdt,const_cast <char *> (_ptrMesh->_name.c_str()),
+ temp,NumberOfCell,
+ med_2_1::MED_MAILLE,
+ (med_2_1::med_geometrie_element) Connectivity->_geometricTypes[i]);
+ for(int i2=0;i2<lgthI;i2++)
+ MEDArrayFamily[i][i2]=(int)(temp[i2]);
+ delete [] temp;
+#else
+ err=MEDfamLire(_medIdt,const_cast <char *> (_ptrMesh->_name.c_str()),
+ MEDArrayFamily[i],NumberOfCell,
+ med_2_1::MED_MAILLE,
+ (med_2_1::med_geometrie_element) Connectivity->_geometricTypes[i]);
+#endif
+ }
+
+ if (err != MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Family not found for entity "<<Connectivity->_entity<<" and geometric type "<<Connectivity->_geometricTypes[i]));
+
+ }
+ return MED_VALID;
+ }
+ return MED_ERROR;
+}
+
+/*--------------------- WRONLY PART -------------------------------*/
+
+MED_MESH_WRONLY_DRIVER21::MED_MESH_WRONLY_DRIVER21()
+{
+}
+
+MED_MESH_WRONLY_DRIVER21::MED_MESH_WRONLY_DRIVER21(const string & fileName,
+ MESH * ptrMesh):
+ MED_MESH_DRIVER21(fileName,ptrMesh,MED_WRONLY),IMED_MESH_WRONLY_DRIVER(fileName,ptrMesh),MED_MESH_DRIVER(fileName,ptrMesh,MED_WRONLY)
+{
+ MESSAGE("MED_MESH_WRONLY_DRIVER21::MED_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh) has been created");
+}
+
+MED_MESH_WRONLY_DRIVER21::MED_MESH_WRONLY_DRIVER21(const MED_MESH_WRONLY_DRIVER21 & driver):
+ IMED_MESH_WRONLY_DRIVER(driver),MED_MESH_DRIVER21(driver),MED_MESH_DRIVER(driver)
+{
+}
+
+MED_MESH_WRONLY_DRIVER21::~MED_MESH_WRONLY_DRIVER21()
+{
+ //MESSAGE("MED_MESH_WRONLY_DRIVER21::MED_MESH_WRONLY_DRIVER21(const string & fileName, MESH * ptrMesh) has been destroyed");
+}
+
+GENDRIVER * MED_MESH_WRONLY_DRIVER21::copy(void) const
+{
+ return new MED_MESH_WRONLY_DRIVER21(*this);
+}
+
+void MED_MESH_WRONLY_DRIVER21::write(void) const
+{
+ const char * LOC = "void MED_MESH_WRONLY_DRIVER21::write(void) const : ";
+ BEGIN_OF(LOC);
+
+ // we must first create mesh !!
+ MESSAGE(LOC << "MeshName : |" << _meshName << "| FileName : |"<<_fileName<<"| MedIdt : | "<< _medIdt << "|");
+
+ if (_status!=MED_OPENED)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "File "<<_fileName<<" is not open. Open it before write !"));
+
+ if (_ptrMesh->getIsAGrid())
+ {
+ if ( writeGRID() != MED_VALID )
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeGRID()" )) ;
+ }
+ else
+ {
+ if (writeCoordinates()!=MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeCoordinates()" )) ;
+
+ if (writeConnectivities(MED_EN::MED_CELL)!=MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeConnectivities(MED_CELL)" )) ;
+ if (writeConnectivities(MED_EN::MED_FACE)!=MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeConnectivities(MED_FACE)" )) ;
+ if (writeConnectivities(MED_EN::MED_EDGE)!=MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeConnectivities(MED_EDGE)" )) ;
+ }
+
+ if (writeFamilyNumbers() !=MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeFamilyNumbers()" )) ;
+
+
+ // well we must first write zero family :
+ if (_status==MED_OPENED) {
+ int err ;
+ // test if the family already exists (HDF trick waiting a MED evolution to be replaced)
+ string dataGroupFam = "/ENS_MAA/"+_meshName+"/FAS/FAMILLE_0/";
+ MESSAGE("|"<<dataGroupFam<<"|");
+ err = med_2_1::_MEDdatagroupOuvrir(_medIdt,const_cast <char *> (dataGroupFam.c_str()) );
+ if ( err < MED_VALID ) {
+ SCRUTE(err);
+
+ err = med_2_1::MEDfamCr( _medIdt,
+ const_cast <char *> ( _meshName.c_str() ),
+ "FAMILLE_0", 0,
+ (med_2_1::med_int*)NULL, (med_2_1::med_int*)NULL, (char*)NULL, 0,
+ (char*)NULL, 0);
+
+ if ( err != MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't create family |FAMILLE_0| with identifier |0| groups names || and attributes descriptions ||")) ;
+ }
+ else
+ med_2_1::_MEDdatagroupFermer(_medIdt);
+
+ }
+
+ MESSAGE(LOC<<"writeFamilies(_ptrMesh->_familyNode)");
+ if (writeFamilies(_ptrMesh->_familyNode) !=MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeFamilies(_ptrMesh->_familyNode)" )) ;
+
+ MESSAGE(LOC<<"writeFamilies(_ptrMesh->_familyCell)");
+ if (writeFamilies(_ptrMesh->_familyCell) !=MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeFamilies(_ptrMesh->_familyCell)" )) ;
+
+ MESSAGE(LOC<<"writeFamilies(_ptrMesh->_familyFace)");
+ if (writeFamilies(_ptrMesh->_familyFace) !=MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeFamilies(_ptrMesh->_familyFace)" )) ;
+
+ MESSAGE(LOC<<"writeFamilies(_ptrMesh->_familyEdge)");
+ if (writeFamilies(_ptrMesh->_familyEdge) !=MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeFamilies(_ptrMesh->_familyEdge)" )) ;
+
+ END_OF(LOC);
+}
+
+//=======================================================================
+//function : writeGRID
+//purpose :
+//=======================================================================
+
+int MED_MESH_WRONLY_DRIVER21::writeGRID() const
+{
+ const char * LOC = "MED_MESH_WRONLY_DRIVER21::writeGRID() : " ;
+ BEGIN_OF(LOC);
+
+ if (_status!=MED_OPENED)
+ {
+ MESSAGE (LOC<<" Not open !!!");
+ return MED_ERROR;
+ }
+ GRID * ptrGrid = (GRID*) _ptrMesh;
+
+ med_2_1::med_err err = MED_ERROR;
+ med_2_1::med_repere rep;
+ string tmp_name(_ptrMesh->_spaceDimension*MED_TAILLE_PNOM21,' ');
+ string tmp_unit(_ptrMesh->_spaceDimension*MED_TAILLE_PNOM21,' ');
+
+ // Test if the mesh <_meshName> already exists
+ // If it doesn't exists create it
+ // If it already exists verify if its dimension is the same as <_ptrMesh->_spaceDimension>
+ // rem : <_meshName> is the driver meshName not <ptrMesh->_meshName>
+ int dim = med_2_1::MEDdimLire(_medIdt, const_cast <char *> (_meshName.c_str()) );
+ if (dim < MED_VALID)
+ {
+ err = med_2_1::MEDgridCr(_medIdt,
+ const_cast <char *> (_meshName.c_str()),
+ _ptrMesh->_spaceDimension,
+ (med_2_1::med_grid_type) ptrGrid->getGridType());
+ if (err != MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Unable to create Grid"));
+ else
+ MESSAGE(LOC<<"Grid "<<_meshName<<" created in file "<<_fileName<<" !");
+ }
+ else if (dim != _ptrMesh->_spaceDimension)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Grid |" << _meshName.c_str() <<
+ "| already exists in file |" << _fileName <<
+ "| with dimension |" << dim <<
+ "| but the dimension of the mesh we want to write is |"
+ << _ptrMesh->_spaceDimension <<"|" )) ;
+
+ // Recompose the <_spaceDimension> strings in 1 string
+ int lengthString ;
+ string valueString ;
+ for (int i=0;i<_ptrMesh->_spaceDimension;i++) {
+ SCRUTE(i);
+ valueString = _ptrMesh->_coordinate->_coordinateName[i] ;
+ lengthString = (MED_TAILLE_PNOM21<valueString.size())?MED_TAILLE_PNOM21:valueString.size() ;
+ tmp_name.replace(i*MED_TAILLE_PNOM21,i*MED_TAILLE_PNOM21+lengthString,valueString,0,lengthString);
+ valueString = _ptrMesh->_coordinate->_coordinateUnit[i];
+ lengthString = (MED_TAILLE_PNOM21<valueString.size())?MED_TAILLE_PNOM21:valueString.size() ;
+ tmp_unit.replace(i*MED_TAILLE_PNOM21,i*MED_TAILLE_PNOM21+lengthString,valueString,0,lengthString);
+ }
+
+ // Pourquoi le stocker sous forme de chaîne ?
+ const string & coordinateSystem = _ptrMesh->_coordinate->_coordinateSystem;
+ if (coordinateSystem == "CARTESIAN")
+ rep = med_2_1::MED_CART;
+ else if ( coordinateSystem == "CYLINDRICAL")
+ rep = med_2_1::MED_CYL;
+ else if ( coordinateSystem == "SPHERICAL" )
+ rep = med_2_1::MED_SPHER;
+ else
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Grid |" << _meshName.c_str() <<
+ "| doesn't have a valid coordinate system : |"
+ << _ptrMesh->_coordinate->_coordinateSystem
+ << "|" )) ;
+
+ med_2_1::med_int ArrayLen[] = { (med_2_1::med_int) ptrGrid->_iArrayLength,
+ (med_2_1::med_int) ptrGrid->_jArrayLength,
+ (med_2_1::med_int) ptrGrid->_kArrayLength };
+
+ // Write node coordinates for MED_BODY_FITTED grid
+ if (ptrGrid->getGridType() == MED_EN::MED_BODY_FITTED)
+ {
+
+ // Write Coordinates and families
+ double * coo = const_cast <double *>
+ (_ptrMesh->_coordinate->getCoordinates(MED_EN::MED_FULL_INTERLACE));
+
+ // Write unused families
+ //CCRT unused => med_2_1::med_int
+ med_2_1::med_int * MEDArrayNodeFamily = new med_2_1::med_int[_ptrMesh->_numberOfNodes] ;
+
+ err = MEDbodyFittedEcr (_medIdt,
+ const_cast <char *> (_ptrMesh->_name.c_str()),
+ _ptrMesh->_spaceDimension,
+ coo,
+ ArrayLen,
+ med_2_1::MED_FULL_INTERLACE,
+ rep,
+ const_cast <char *> (tmp_name.c_str()),
+ const_cast <char *> (tmp_unit.c_str()),
+ MEDArrayNodeFamily,
+ _ptrMesh->_numberOfNodes,
+ med_2_1::MED_REMP);
+ delete[] MEDArrayNodeFamily;
+
+ if (err != MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"error in MEDbodyFittedEcr()"));
+
+ }
+ else
+ {
+ // Write Arrays of Cartesian or Polar Grid
+
+ double * Array[] = { ptrGrid->_iArray,
+ ptrGrid->_jArray,
+ ptrGrid->_kArray };
+ int idim;
+ for (idim = 0; idim < _ptrMesh->_spaceDimension; ++idim)
+ {
+ err = med_2_1::MEDgridEcr (_medIdt,
+ const_cast <char *> (_ptrMesh->_name.c_str()),
+ _ptrMesh->_spaceDimension,
+ Array [idim],
+ ArrayLen [idim],
+ idim,
+ med_2_1::MED_FULL_INTERLACE,
+ rep,
+ const_cast <char *> (tmp_name.c_str()),
+ const_cast <char *> (tmp_unit.c_str()),
+ med_2_1::MED_REMP);
+ if (err != MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't read grid coordinates for "
+ << idim << "-th dimention"));
+ }
+
+// err = MEDfamGridEcr(_medIdt,
+// const_cast <char *> (_ptrMesh->_name.c_str()),
+// _ptrMesh->_MEDArrayNodeFamily,
+// _ptrMesh->_numberOfNodes,
+// med_2_1::MED_REMP,
+// med_2_1::MED_NOEUD);
+ if (err != MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"error in MEDfamGridEcr()"));
+
+ } // end Write Cartesian or Polar Grid
+
+ END_OF(LOC);
+ return MED_VALID;
+}
+
+//=======================================================================
+//function : writeCoordinates
+//purpose :
+//=======================================================================
+
+int MED_MESH_WRONLY_DRIVER21::writeCoordinates() const {
+
+ const char * LOC = "int MED_MESH_WRONLY_DRIVER21::writeCoordinates() const : ";
+ BEGIN_OF(LOC);
+
+ med_2_1::med_err err = MED_ERROR;
+ med_2_1::med_repere rep;
+ string tmp_name(_ptrMesh->_spaceDimension*MED_TAILLE_PNOM21,' ');
+ string tmp_unit(_ptrMesh->_spaceDimension*MED_TAILLE_PNOM21,' ');
+
+ // Recompose the <_spaceDimension> strings in 1 string
+ int lengthString ;
+ string valueString ;
+ for (int i=0;i<_ptrMesh->_spaceDimension;i++) {
+ valueString = _ptrMesh->_coordinate->_coordinateName[i] ;
+ lengthString = (MED_TAILLE_PNOM21<valueString.size())?MED_TAILLE_PNOM21:valueString.size() ;
+ tmp_name.replace(i*MED_TAILLE_PNOM21,i*MED_TAILLE_PNOM21+lengthString,valueString,0,lengthString);
+ valueString = _ptrMesh->_coordinate->_coordinateUnit[i];
+ lengthString = (MED_TAILLE_PNOM21<valueString.size())?MED_TAILLE_PNOM21:valueString.size() ;
+ tmp_unit.replace(i*MED_TAILLE_PNOM21,i*MED_TAILLE_PNOM21+lengthString,valueString,0,lengthString);
+ }
+
+ // Test if the mesh <_meshName> already exists
+ // If it doesn't exists create it
+ // If it already exists verify if its dimension is the same as <_ptrMesh->_spaceDimension>
+ // rem : <_meshName> is the driver meshName not <ptrMesh->_meshName>
+ int dim = med_2_1::MEDdimLire(_medIdt, const_cast <char *> (_meshName.c_str()) );
+ if (dim < MED_VALID)
+ if (med_2_1::MEDmaaCr(_medIdt,const_cast <char *> (_meshName.c_str()),_ptrMesh->_spaceDimension) != 0 )
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Unable to create Mesh : |" << _meshName << "|"));
+ else
+ {
+ MESSAGE(LOC<<"Mesh "<<_meshName<<" created in file "<<_fileName<<" !");
+ }
+ else if (dim != _ptrMesh->_spaceDimension)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Mesh |" << _meshName.c_str() << "| already exists in file |" << _fileName
+ << "| with dimension |" << dim << "| but the dimension of the mesh we want to write is |"
+ << _ptrMesh->_spaceDimension <<"|" )) ;
+
+ // Pourquoi le stocker sous forme de chaîne ?
+ const string & coordinateSystem = _ptrMesh->_coordinate->_coordinateSystem;
+ if (coordinateSystem == "CARTESIAN")
+ rep = med_2_1::MED_CART;
+ else if ( coordinateSystem == "CYLINDRICAL")
+ rep = med_2_1::MED_CYL;
+ else if ( coordinateSystem == "SPHERICAL" )
+ rep = med_2_1::MED_SPHER;
+ else
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Mesh |" << _meshName.c_str() << "| doesn't have a valid coordinate system : |"
+ << _ptrMesh->_coordinate->_coordinateSystem
+ << "|" )) ;
+
+ err = MEDcoordEcr(_medIdt, const_cast <char *> (_meshName.c_str()),
+ _ptrMesh->_spaceDimension,
+ //const_cast <double *> ( _ptrMesh->_coordinate->_coordinate->get(MED_EN::MED_FULL_INTERLACE) ),
+ const_cast <double *> ( _ptrMesh->_coordinate->_coordinate.get(MED_EN::MED_FULL_INTERLACE) ),
+ med_2_1::MED_FULL_INTERLACE,
+ _ptrMesh->_numberOfNodes, // _ptrMesh->_coordinate->_numberOfNodes
+ med_2_1::MED_REMP,
+ rep,
+ const_cast <char *> (tmp_name.c_str()),
+ const_cast <char *> (tmp_unit.c_str())
+ );
+
+ if (err<0)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write coordinates of mesh |" << _meshName.c_str() << "| in file |" << _fileName
+ << "| with dimension |" << _ptrMesh->_spaceDimension <<"| and"
+ << " with units names |" << tmp_name
+ << "| and units |" << tmp_unit
+ << " |")) ;
+
+
+ //////////////////////////////////////////////////////////////////////////////////////
+ /// Modification pour prise en compte de la numérotation optionnelle des noeuds ///
+ //////////////////////////////////////////////////////////////////////////////////////
+ ///
+ /// Ecrit les numéros optionnels des noeuds
+ /// Le traitement est identique à la version originelle s'il n'y a pas de numérotation optionnelle
+
+
+ if (_ptrMesh->_arePresentOptionnalNodesNumbers==1) {
+#if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
+ int lgth=_ptrMesh->_coordinate->getNumberOfNodes();
+ med_2_1::med_int *temp=new med_2_1::med_int[lgth];
+ for(int i2=0;i2<lgth;i2++)
+ temp[i2]=(med_2_1::med_int)(_ptrMesh->_coordinate->getNodesNumbers()[i2]);
+ err = MEDnumEcr(_medIdt,const_cast <char *> (_meshName.c_str()),
+ temp,
+ _ptrMesh->_numberOfNodes, med_2_1::MED_REMP,
+ med_2_1::MED_NOEUD, med_2_1::med_geometrie_element(0) );
+ delete [] temp;
+#else
+ err = MEDnumEcr(_medIdt,const_cast <char *> (_meshName.c_str()),
+ const_cast <int *> (_ptrMesh->_coordinate->getNodesNumbers() ),
+ _ptrMesh->_numberOfNodes, med_2_1::MED_REMP,
+ med_2_1::MED_NOEUD, med_2_1::med_geometrie_element(0) );
+#endif
+
+ if (err<0)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write optionnal numbers of mesh |" << _meshName.c_str()
+ << "| in file |" << _fileName << " |")) ;
+ }
+ //////////////////////////////////////////////////////////////////////////////////////
+
+ END_OF(LOC);
+
+ return MED_VALID;
+}
+
+
+
+
+int MED_MESH_WRONLY_DRIVER21::writeConnectivities(medEntityMesh entity) const {
+
+ const char * LOC="int MED_MESH_WRONLY_DRIVER21::writeConnectivities() const : ";
+ BEGIN_OF(LOC);
+
+ med_2_1::med_err err;
+
+ // REM SI LA METHODE EST APPELEE DIRECTEMENT ET QUE LE MAILLAGE N'EST PAS CREE IL Y A PB !
+ // PG : IMPOSSIBLE : LA METHODE EST PRIVEE !
+
+ // A FAIRE : A tester surtout dans les methodes de MESH.
+ // if ( _ptrMesh->_connectivity == (CONNECTIVITY *) MED_INVALID )
+ if ( _ptrMesh->_connectivity == (CONNECTIVITY *) NULL )
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "The connectivity is not defined in the MESH object ")) ;
+
+ if ( _ptrMesh->existConnectivity(MED_NODAL,entity) ) {
+
+ int numberOfTypes = _ptrMesh->getNumberOfTypes (entity) ;
+ const medGeometryElement * types = _ptrMesh->getTypes (entity) ;
+
+ for (int i=0; i<numberOfTypes; i++) {
+
+ int numberOfElements = _ptrMesh->getNumberOfElements (entity,types[i]);
+ const int * connectivity = _ptrMesh->getConnectivity (MED_EN::MED_FULL_INTERLACE,
+ MED_NODAL, entity, types[i]); // ?? et SI MED_NODAL n'existe pas, recalcul auto ??
+
+ // Pour l'instant la class utilise le multi.....
+ int multi = 0 ;
+ if (entity==MED_EN::MED_CELL)
+ if ( (types[i]/ 100) < _ptrMesh->_spaceDimension)
+ multi=1 ;
+ int numberOfNodes = types[i]%100 ;
+ int * connectivityArray = new int[numberOfElements*(numberOfNodes+multi)];
+
+ // version originale sans prise en compte des numéros optionnels
+ //
+ for (int j=0 ; j<numberOfElements; j++)
+ {
+ for (int k=0; k<numberOfNodes; k++)
+ connectivityArray[j*(numberOfNodes+multi)+k]=connectivity[j*numberOfNodes+k] ;
+
+ if (multi>0) connectivityArray[j*(numberOfNodes+multi)+numberOfNodes]=0;
+ }
+
+ //////////////////////////////////////////////////////////////////////////////////////
+ /// Modification pour prise en compte de la numérotation optionnelle des noeuds ///
+ //////////////////////////////////////////////////////////////////////////////////////
+ ///
+ /// Dénumérote les sommets des mailles pour leur rendre leurs numéros optionnels
+ /// Le traitement est identique à la version originelle s'il n'y a pas de numérotation optionnelle
+
+// if (_ptrMesh->_arePresentOptionnalNodesNumbers==1)
+// {
+// const int * nodesNumbers = _ptrMesh->_coordinate->getNodesNumbers();
+// for (int j=0 ; j<numberOfElements; j++)
+// {
+// for (int k=0; k<numberOfNodes; k++) connectivityArray[j*(numberOfNodes+multi)+k]=nodesNumbers[connectivity[j*numberOfNodes+k]-1] ;
+// if (multi>0) connectivityArray[j*(numberOfNodes+multi)+numberOfNodes]=0;
+// }
+// }
+// else
+// {
+// for (int j=0 ; j<numberOfElements; j++)
+// {
+// for (int k=0; k<numberOfNodes; k++) connectivityArray[j*(numberOfNodes+multi)+k]=connectivity[j*numberOfNodes+k] ;
+// if (multi>0) connectivityArray[j*(numberOfNodes+multi)+numberOfNodes]=0;
+// }
+// }
+
+ //////////////////////////////////////////////////////////////////////////////////////
+#if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
+ int lgth=numberOfElements*(numberOfNodes+multi);
+ med_2_1::med_int *temp=new med_2_1::med_int[lgth];
+ for(int i2=0;i2<lgth;i2++)
+ temp[i2]=(med_2_1::med_int)(connectivityArray[i2]);
+ err = MEDconnEcr( _medIdt, const_cast <char *> ( _meshName.c_str()), _ptrMesh->_spaceDimension,
+ temp, med_2_1::MED_FULL_INTERLACE , numberOfElements,
+ med_2_1::MED_REMP,
+ (med_2_1::med_entite_maillage ) entity,
+ (med_2_1::med_geometrie_element) types[i], med_2_1::MED_NOD );
+ delete [] temp;
+#else
+ err = MEDconnEcr( _medIdt, const_cast <char *> ( _meshName.c_str()), _ptrMesh->_spaceDimension,
+ connectivityArray, med_2_1::MED_FULL_INTERLACE , numberOfElements,
+ med_2_1::MED_REMP,
+ (med_2_1::med_entite_maillage ) entity,
+ (med_2_1::med_geometrie_element) types[i], med_2_1::MED_NOD );
+#endif
+ delete[] connectivityArray ;
+ if (err<0) // ETENDRE LES EXPLICATIONS
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write connectivities of mesh |" << _meshName.c_str() << "| in file |" << _fileName
+ << "| with dimension |" << _ptrMesh->_spaceDimension <<"| and"
+ )) ;
+ }
+ }
+ // Connctivity descending :
+ if ( _ptrMesh->existConnectivity(MED_DESCENDING,entity) ) {
+
+ int numberOfTypes = _ptrMesh->getNumberOfTypes (entity) ;
+ const medGeometryElement * types = _ptrMesh->getTypes (entity) ;
+
+ for (int i=0; i<numberOfTypes; i++) {
+
+ int numberOfElements = _ptrMesh->getNumberOfElements (entity,types[i]);
+ const int * connectivity = _ptrMesh->getConnectivity(MED_EN::MED_FULL_INTERLACE, MED_DESCENDING, entity, types[i]);
+
+ // Pour l'instant la class utilise le multi.....
+#if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
+ int lgth=_ptrMesh->getConnectivityLength(MED_EN::MED_FULL_INTERLACE, MED_DESCENDING, entity, types[i]);
+ med_2_1::med_int *temp=new med_2_1::med_int[lgth];
+ for(int i2=0;i2<lgth;i2++)
+ temp[i2]=(med_2_1::med_int)(connectivity[i2]);
+ err = med_2_1::MEDconnEcr( _medIdt,
+ const_cast <char *> ( _meshName.c_str()),
+ _ptrMesh->_spaceDimension,
+ temp,
+ med_2_1::MED_FULL_INTERLACE,
+ numberOfElements,
+ med_2_1::MED_REMP,
+ (med_2_1::med_entite_maillage ) entity,
+ (med_2_1::med_geometrie_element) types[i],
+ med_2_1::MED_DESC );
+ delete [] temp;
+#else
+ err = med_2_1::MEDconnEcr( _medIdt,
+ const_cast <char *> ( _meshName.c_str()),
+ _ptrMesh->_spaceDimension,
+ const_cast <int *> (connectivity),
+ med_2_1::MED_FULL_INTERLACE,
+ numberOfElements,
+ med_2_1::MED_REMP,
+ (med_2_1::med_entite_maillage ) entity,
+ (med_2_1::med_geometrie_element) types[i],
+ med_2_1::MED_DESC );
+#endif
+
+ if (err<0) // ETENDRE LES EXPLICATIONS
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write connectivities of mesh |" << _meshName.c_str() << "| in file |" << _fileName
+ << "| with dimension |" << _ptrMesh->_spaceDimension <<"| and"
+ )) ;
+
+ }
+ }
+ END_OF(LOC);
+ return MED_VALID;
+}
+
+int MED_MESH_WRONLY_DRIVER21::writeFamilyNumbers() const {
+
+ const char * LOC="int MED_MESH_WRONLY_DRIVER21::writeFamilyNumbers() const : ";
+ BEGIN_OF(LOC);
+
+ med_2_1::med_err err;
+
+ // SOLUTION TEMPORAIRE CAR _ptrMesh->_MEDArrayNodeFamily DOIT ETRE ENLEVER DE LA CLASSE MESH
+
+ { // Node related block
+
+ // We build the array from the families list objects :
+ int NumberOfNodes = _ptrMesh->getNumberOfNodes() ;
+ int * MEDArrayNodeFamily = new int[NumberOfNodes] ;
+ // family 0 by default
+ for (int i=0; i<NumberOfNodes; i++)
+ MEDArrayNodeFamily[i]=0;
+ //vector<FAMILY*> myFamilies = _ptrMesh->getFamilies(MED_NODE);
+ vector<FAMILY*> * myFamilies = &_ptrMesh->_familyNode;
+ int NumberOfNodesFamilies = myFamilies->size() ;
+ //bool ToDestroy = false;
+ if (0 == NumberOfNodesFamilies) {
+ //ToDestroy = true ;
+ vector<GROUP*> myGroups = _ptrMesh->getGroups(MED_NODE);
+ int NumberOfGroups = myGroups.size() ;
+ // build families from groups
+ for (int i=0; i<NumberOfGroups; i++) {
+ SUPPORT * mySupport = myGroups[i] ;
+ FAMILY* myFamily = new FAMILY(*mySupport);
+ myFamily->setIdentifier(i+1);
+ myFamilies->push_back(myFamily);
+ }
+ NumberOfNodesFamilies=myFamilies->size() ;
+ }
+ for (int i=0 ; i<NumberOfNodesFamilies; i++) {
+ //SCRUTE(i);
+ //SCRUTE(myFamilies[i]->getName());
+ int FamilyIdentifier = (*myFamilies)[i]->getIdentifier() ;
+ int TotalNumber = (*myFamilies)[i]->getNumberOfElements(MED_ALL_ELEMENTS) ;
+ if ((*myFamilies)[i]->isOnAllElements())
+ for (int j=0; j<TotalNumber; j++)
+ MEDArrayNodeFamily[j]=FamilyIdentifier;
+ else {
+ const int * Number = (*myFamilies)[i]->getNumber(MED_ALL_ELEMENTS) ;
+ for (int j=0; j<TotalNumber; j++)
+ MEDArrayNodeFamily[Number[j]-1]=FamilyIdentifier ;
+ }
+ }
+ for(int j=0; j<NumberOfNodes; j++) {
+ SCRUTE(MEDArrayNodeFamily[j]);
+ }
+ if ( !_ptrMesh->getIsAGrid() ){
+#if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
+ int lgth=NumberOfNodes;
+ med_2_1::med_int *temp=new med_2_1::med_int[lgth];
+ for(int i2=0;i2<lgth;i2++)
+ temp[i2]=(med_2_1::med_int)(MEDArrayNodeFamily[i2]);
+ err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
+ temp, NumberOfNodes,med_2_1::MED_REMP ,
+ med_2_1::MED_NOEUD,
+ (med_2_1::med_geometrie_element) MED_NONE);
+ delete [] temp;
+#else
+ err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
+ MEDArrayNodeFamily, NumberOfNodes,med_2_1::MED_REMP ,
+ med_2_1::MED_NOEUD,
+ (med_2_1::med_geometrie_element) MED_NONE);
+#endif
+ }
+ else{
+#if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
+ int lgth=NumberOfNodes;
+ med_2_1::med_int *temp=new med_2_1::med_int[lgth];
+ for(int i2=0;i2<lgth;i2++)
+ temp[i2]=(med_2_1::med_int)(MEDArrayNodeFamily[i2]);
+ err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
+ temp, NumberOfNodes,med_2_1::MED_REMP ,
+ med_2_1::MED_NOEUD,
+ (med_2_1::med_geometrie_element) MED_NONE);
+ delete [] temp;
+#else
+ err = MEDfamGridEcr(_medIdt,
+ const_cast <char *> (_ptrMesh->_name.c_str()),
+ MEDArrayNodeFamily,
+ NumberOfNodes,
+ med_2_1::MED_REMP,
+ med_2_1::MED_NOEUD);
+#endif
+ }
+
+ if ( err != MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't write node family for the |"<< NumberOfNodes
+ << "| nodes in mesh |"
+ << _ptrMesh->_name.c_str() << "|" ));
+ delete[] MEDArrayNodeFamily;
+ //if (true == ToDestroy)
+ // for (int i=0; i<NumberOfNodesFamilies; i++)
+ // delete myFamilies[i];
+ }
+
+ { // CELLS RELATED BLOCK
+ medEntityMesh entity=MED_EN::MED_CELL;
+ // SOLUTION TEMPORAIRE CAR _ptrMesh->_MEDArray____Family DOIT ETRE ENLEVER DE LA CLASSE MESH
+ if ( ( _ptrMesh->existConnectivity(MED_NODAL,entity) )|( _ptrMesh->existConnectivity(MED_DESCENDING,entity) ) ) {
+
+ int numberOfTypes = _ptrMesh->getNumberOfTypes (entity) ;
+ const medGeometryElement * types = _ptrMesh->getTypes (entity) ;
+
+ // We build the array from the families list objects :
+ int NumberOfElements = _ptrMesh->getNumberOfElements(entity, MED_ALL_ELEMENTS);
+ int * MEDArrayFamily = new int[NumberOfElements] ;
+ // family 0 by default
+ for (int i=0; i<NumberOfElements; i++)
+ MEDArrayFamily[i]=0;
+ //vector<FAMILY*> myFamilies = _ptrMesh->getFamilies(entity);
+ vector<FAMILY*> * myFamilies = &_ptrMesh->_familyCell ;
+ int NumberOfFamilies = myFamilies->size() ;
+ //bool ToDestroy = false;
+ if (0 == NumberOfFamilies) {
+ //ToDestroy = true ;
+ vector<GROUP*> myGroups = _ptrMesh->getGroups(entity);
+ int NumberOfGroups = myGroups.size() ;
+ // build families from groups
+ for (int i=0; i<NumberOfGroups; i++) {
+ SCRUTE( myGroups[i]->getName() );
+ SUPPORT * mySupport = myGroups[i] ;
+ FAMILY* myFamily = new FAMILY(*mySupport);
+ myFamily->setIdentifier(-i-1);
+ myFamilies->push_back(myFamily);
+ }
+ NumberOfFamilies=myFamilies->size() ;
+ }
+ for (int i=0 ; i<NumberOfFamilies; i++) {
+ int FamilyIdentifier = (*myFamilies)[i]->getIdentifier() ;
+ int TotalNumber = (*myFamilies)[i]->getNumberOfElements(MED_ALL_ELEMENTS) ;
+ if ((*myFamilies)[i]->isOnAllElements())
+ for (int ii=0; ii<TotalNumber; ii++)
+ MEDArrayFamily[ii]=FamilyIdentifier;
+ else {
+ const int * Number = (*myFamilies)[i]->getNumber(MED_ALL_ELEMENTS) ;
+ for (int ii=0; ii<TotalNumber; ii++)
+ MEDArrayFamily[Number[ii]-1]=FamilyIdentifier ;
+ }
+ }
+
+ const int * typeCount = _ptrMesh->getGlobalNumberingIndex(entity) ;
+#if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
+ int lgth=NumberOfElements;
+ med_2_1::med_int *temp=new med_2_1::med_int[lgth];
+ for(int i2=0;i2<lgth;i2++)
+ temp[i2]=(med_2_1::med_int) (MEDArrayFamily[i2]);
+#endif
+ for (int i=0; i<numberOfTypes; i++) {
+#if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
+ err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
+ temp+typeCount[i]-1,typeCount[i+1]-typeCount[i],
+ med_2_1::MED_REMP ,
+ (med_2_1::med_entite_maillage) entity,
+ (med_2_1::med_geometrie_element) types[i]
+);
+#else
+ err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
+ MEDArrayFamily+typeCount[i]-1,typeCount[i+1]-typeCount[i],
+ med_2_1::MED_REMP ,
+ (med_2_1::med_entite_maillage) entity,
+ (med_2_1::med_geometrie_element) types[i]
+);
+#endif
+ MESSAGE("OK "<<i);
+ if ( err != MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't write family for the |"<< _ptrMesh->getNumberOfElements(entity, types[i])
+ << "| cells of geometric type |" << geoNames[ types[i]] <<"|in mesh |"
+ << _ptrMesh->_name.c_str() << "|" ));
+ }
+#if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
+ delete [] temp;
+#endif
+ delete[] MEDArrayFamily ;
+ //if (true == ToDestroy) {
+ // int NumberOfFamilies = myFamilies->size();
+ // for (int i=0; i<NumberOfFamilies; i++)
+ // delete myFamilies[i];
+ //}
+ }
+ }
+
+ { // FACE RELATED BLOCK
+ medEntityMesh entity=MED_EN::MED_FACE;
+ // SOLUTION TEMPORAIRE CAR _ptrMesh->_MEDArray____Family DOIT ETRE ENLEVER DE LA CLASSE MESH
+ if ( ( _ptrMesh->existConnectivity(MED_NODAL,entity) )|( _ptrMesh->existConnectivity(MED_DESCENDING,entity) ) ) {
+
+ int numberOfTypes = _ptrMesh->getNumberOfTypes (entity) ;
+ const medGeometryElement * types = _ptrMesh->getTypes (entity) ;
+ SCRUTE(numberOfTypes);
+
+ int numberOfElements = _ptrMesh->getNumberOfElements(entity, MED_ALL_ELEMENTS) ;
+ int * familyArray = new int[numberOfElements] ;
+ for (int i=0;i<numberOfElements;i++)
+ familyArray[i]=0;
+
+ int numberOfFamilies = _ptrMesh->getNumberOfFamilies(entity) ;
+ //vector<FAMILY*> myFamilies = _ptrMesh->getFamilies(entity) ;
+ vector<FAMILY*> * myFamilies = &_ptrMesh->_familyFace ;
+ //bool ToDestroy = false;
+ if (0 == numberOfFamilies) {
+ //ToDestroy = true ;
+ vector<GROUP*> myGroups = _ptrMesh->getGroups(entity);
+ int NumberOfGroups = myGroups.size() ;
+ // build families from groups
+ for (int i=0; i<NumberOfGroups; i++) {
+ SCRUTE( myGroups[i]->getName() );
+ SUPPORT * mySupport = myGroups[i] ;
+ FAMILY* myFamily = new FAMILY(*mySupport);
+ myFamily->setIdentifier(-i-1000);
+ myFamilies->push_back(myFamily);
+ }
+ numberOfFamilies=myFamilies->size() ;
+ }
+ for (int i=0;i<numberOfFamilies;i++) {
+ int familyNumber = (*myFamilies)[i]->getIdentifier() ;
+ int numberOfFamilyElements = (*myFamilies)[i]->getNumberOfElements(MED_ALL_ELEMENTS) ;
+ if ((*myFamilies)[i]->isOnAllElements())
+ for (int ii=0; ii<numberOfFamilyElements; ii++)
+ familyArray[ii]=familyNumber;
+ else {
+ const int * myFamilyElements = (*myFamilies)[i]->getNumber(MED_ALL_ELEMENTS) ;
+ for (int ii=0;ii<numberOfFamilyElements;ii++)
+ familyArray[myFamilyElements[ii]-1]=familyNumber;
+ }
+ }
+
+ const int * typeCount = _ptrMesh->getGlobalNumberingIndex(entity) ;
+#if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
+ int lgth=numberOfElements;
+ med_2_1::med_int *temp=new med_2_1::med_int[lgth];
+ for(int i2=0;i2<lgth;i2++)
+ temp[i2]=(med_2_1::med_int) (familyArray[i2]);
+#endif
+ for (int i=0; i<numberOfTypes; i++) {
+
+ int typeNumberOfElements = typeCount[i+1] - typeCount[i] ;
+#if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
+ err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
+ temp+typeCount[i]-1, typeNumberOfElements,
+ med_2_1::MED_REMP ,
+ (med_2_1::med_entite_maillage) entity,
+ (med_2_1::med_geometrie_element) types[i]);
+#else
+ err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
+ familyArray+typeCount[i]-1, typeNumberOfElements,
+ med_2_1::MED_REMP ,
+ (med_2_1::med_entite_maillage) entity,
+ (med_2_1::med_geometrie_element) types[i]);
+#endif
+ if ( err != MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't write family for the |"<< _ptrMesh->getNumberOfElements(entity, types[i])
+ << "| faces of geometric type |" << geoNames[types[i]] <<"|in mesh |"
+ << _ptrMesh->_name.c_str() << "|" ));
+ }
+#if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
+ delete [] temp;
+#endif
+ delete[] familyArray ;
+ //if (true == ToDestroy) {
+ // int NumberOfFamilies = myFamilies->size();
+ // for (int i=0; i<NumberOfFamilies; i++)
+ // delete myFamilies[i];
+ //}
+ }
+ }
+
+ { // EDGE RELATED BLOCK
+ //medEntityMesh entity=MED_EN::MED_FACE;
+ medEntityMesh entity=MED_EN::MED_EDGE;
+ // SOLUTION TEMPORAIRE CAR _ptrMesh->_MEDArray____Family DOIT ETRE ENLEVER DE LA CLASSE MESH
+ if ( ( _ptrMesh->existConnectivity(MED_NODAL,entity) )|( _ptrMesh->existConnectivity(MED_DESCENDING,entity) ) ) {
+
+ int numberOfTypes = _ptrMesh->getNumberOfTypes (entity) ;
+ const medGeometryElement * types = _ptrMesh->getTypes (entity) ;
+
+ int numberOfElements = _ptrMesh->getNumberOfElements(entity, MED_ALL_ELEMENTS) ;
+ int * familyArray = new int[numberOfElements] ;
+ for (int i=0;i<numberOfElements;i++)
+ familyArray[i]=0;
+
+ int numberOfFamilies = _ptrMesh->getNumberOfFamilies(entity) ;
+ //vector<FAMILY*> myFamilies = _ptrMesh->getFamilies(entity) ;
+ vector<FAMILY*> * myFamilies = &_ptrMesh->_familyEdge ;
+ //bool ToDestroy = false;
+ if (0 == numberOfFamilies) {
+ //ToDestroy = true ;
+ vector<GROUP*> myGroups = _ptrMesh->getGroups(entity);
+ int NumberOfGroups = myGroups.size() ;
+ // build families from groups
+ for (int i=0; i<NumberOfGroups; i++) {
+ SCRUTE( myGroups[i]->getName() );
+ SUPPORT * mySupport = myGroups[i] ;
+ FAMILY* myFamily = new FAMILY(*mySupport);
+ myFamily->setIdentifier(-i-2000);
+ myFamilies->push_back(myFamily);
+ }
+ numberOfFamilies=myFamilies->size() ;
+ }
+ for (int i=0;i<numberOfFamilies;i++) {
+ int familyNumber = (*myFamilies)[i]->getIdentifier() ;
+ int numberOfFamilyElements = (*myFamilies)[i]->getNumberOfElements(MED_ALL_ELEMENTS) ;
+ if ((*myFamilies)[i]->isOnAllElements())
+ for (int ii=0; ii<numberOfFamilyElements; ii++)
+ familyArray[ii]=familyNumber;
+ else {
+ const int * myFamilyElements = (*myFamilies)[i]->getNumber(MED_ALL_ELEMENTS) ;
+ for (int ii=0;ii<numberOfFamilyElements;ii++)
+ familyArray[myFamilyElements[ii]-1]=familyNumber;
+ }
+ }
+
+ const int * typeCount = _ptrMesh->getGlobalNumberingIndex(entity) ;
+#if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
+ int lgth=numberOfElements;
+ med_2_1::med_int *temp=new med_2_1::med_int[lgth];
+ for(int i2=0;i2<lgth;i2++)
+ temp[i2]=(med_2_1::med_int) (familyArray[i2]);
+#endif
+ for (int i=0; i<numberOfTypes; i++) {
+
+ int typeNumberOfElements = typeCount[i+1] - typeCount[i] ;
+#if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
+ err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
+ temp+typeCount[i]-1, typeNumberOfElements,
+ med_2_1::MED_REMP ,
+ (med_2_1::med_entite_maillage) entity,
+ (med_2_1::med_geometrie_element) types[i]);
+#else
+ err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
+ familyArray+typeCount[i]-1, typeNumberOfElements,
+ med_2_1::MED_REMP ,
+ (med_2_1::med_entite_maillage) entity,
+ (med_2_1::med_geometrie_element) types[i]);
+#endif
+ if ( err != MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't write family for the |"<< _ptrMesh->getNumberOfElements(entity, types[i])
+ << "| edges of geometric type |" << geoNames[types[i]] <<"|in mesh |"
+ << _ptrMesh->_name.c_str() << "|" ));
+ }
+#if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
+ delete [] temp;
+#endif
+ delete[] familyArray ;
+ //if (true == ToDestroy) {
+ // int NumberOfFamilies = myFamilies->size();
+ // for (int i=0; i<NumberOfFamilies; i++)
+ // delete myFamilies[i];
+ //}
+ }
+ }
+
+ END_OF(LOC);
+ return MED_VALID;
+}
+
+int MED_MESH_WRONLY_DRIVER21::writeFamilies(vector<FAMILY*> & families ) const {
+
+ const char * LOC="int MED_MESH_WRONLY_DRIVER21::writeFamilies(vector<FAMILY*> families) const : ";
+ BEGIN_OF(LOC);
+
+ med_2_1::med_err err;
+
+ MESSAGE(LOC<<" families.size() :"<<families.size());
+
+ for (unsigned int i=0; i< families.size(); i++) {
+
+ int numberOfAttributes = families[i]->getNumberOfAttributes ();
+ string attributesDescriptions = "";
+
+ // Recompose the attributes descriptions arg for MED
+ for (int j=0; j < numberOfAttributes; j++) {
+
+ string attributeDescription = families[i]->getAttributeDescription(j+1);
+
+ if ( attributeDescription.size() > MED_TAILLE_DESC )
+ throw MEDEXCEPTION( LOCALIZED(STRING(LOC) << "The size of the attribute description n° |" << j+1 << "| of the family |" << families[i]->getName()
+ << "| with identifier |" << families[i]->getIdentifier() << "| is |"
+ << attributeDescription.size() <<"| and is more than |" << MED_TAILLE_DESC << "|")) ;
+
+ attributesDescriptions += attributeDescription;
+ }
+
+
+ int numberOfGroups = families[i]->getNumberOfGroups();
+ string groupsNames(numberOfGroups*MED_TAILLE_LNOM,'\0') ;
+ // Recompose the groups names arg for MED
+ for (int j=0; j < numberOfGroups; j++) {
+
+ string groupName = families[i]->getGroupName(j+1);
+
+ if ( groupName.size() > MED_TAILLE_LNOM )
+ throw MEDEXCEPTION( LOCALIZED(STRING(LOC) << "The size of the group name n° |" << j+1 << "| of the family |" << families[i]->getName()
+ << "| with identifier |" << families[i]->getIdentifier() << "| is |"
+ << groupName.size() <<"| and is more than |" << MED_TAILLE_LNOM << "|")) ;
+
+
+ int length = min(MED_TAILLE_LNOM,(int)groupName.size());
+ groupsNames.replace(j*MED_TAILLE_LNOM,length, groupName,0,length);
+
+ }
+
+ // test if the family already exists (HDF trick waiting a MED evolution to be replaced)
+ string dataGroupFam = "/ENS_MAA/"+_meshName+"/FAS/"+families[i]->getName()+"/";
+ SCRUTE("|"<<dataGroupFam<<"|");
+ err =med_2_1::_MEDdatagroupOuvrir(_medIdt,const_cast <char *> (dataGroupFam.c_str()) ) ;
+ if ( err < MED_VALID ) {
+ SCRUTE(err);
+
+ MESSAGE(LOC<<"families[i]->getName().c_str() : "<<families[i]->getName().c_str());
+ MESSAGE(LOC<<"_meshName.c_str() : "<<_meshName.c_str());
+ MESSAGE(LOC<<"families[i]->getIdentifier() : "<<families[i]->getIdentifier());
+ MESSAGE(LOC<<"numberOfAttributes : "<<numberOfAttributes);
+
+ //MESSAGE(LOC<<"families[i]->getAttributesIdentifiers() : "<<families[i]->getAttributesIdentifiers()[0]);
+ //MESSAGE(LOC<<"families[i]->getAttributesValues() : "<<families[i]->getAttributesValues()[0]);
+ MESSAGE(LOC<<"attributesDescriptions.c_str() : "<<attributesDescriptions.c_str());
+ MESSAGE(LOC<<"numberOfGroups : "<<numberOfGroups);
+ MESSAGE(LOC<<"groupsNames.c_str() : "<<groupsNames.c_str());
+#if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
+ int lgth=families[i]->getNumberOfAttributes();
+ med_2_1::med_int * AttributesIdentifier2 = new med_2_1::med_int[lgth] ;
+ med_2_1::med_int * AttributesValues2 = new med_2_1::med_int[lgth] ;
+ for(med_2_1::med_int i2=0;i2<lgth;i2++)
+ {
+ AttributesIdentifier2[i2]=(med_2_1::med_int)(families[i]->getAttributesIdentifiers()[i2]);
+ AttributesValues2[i2]=(med_2_1::med_int)(families[i]->getAttributesValues()[i2]);
+ }
+ err = med_2_1::MEDfamCr( _medIdt,
+ const_cast <char *> ( _meshName.c_str() ),
+ const_cast <char *> ( families[i]->getName().c_str() ),
+ families[i]->getIdentifier(),
+ AttributesIdentifier2,
+ AttributesValues2,
+ const_cast <char *> (attributesDescriptions.c_str()),
+ numberOfAttributes,
+ const_cast <char *> (groupsNames.c_str()),
+ numberOfGroups);
+ delete [] AttributesIdentifier2;
+ delete [] AttributesValues2;
+#else
+ err = med_2_1::MEDfamCr( _medIdt,
+ const_cast <char *> ( _meshName.c_str() ),
+ const_cast <char *> ( families[i]->getName().c_str() ),
+ families[i]->getIdentifier(),
+ families[i]->getAttributesIdentifiers(),
+ families[i]->getAttributesValues(),
+ const_cast <char *> (attributesDescriptions.c_str()),
+ numberOfAttributes,
+ const_cast <char *> (groupsNames.c_str()),
+ numberOfGroups);
+#endif
+ SCRUTE(err);
+ if ( err != MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't create family |" << families[i]->getName()
+ << "| with identifier |" << families[i]->getIdentifier() << "| groups names |"
+ << groupsNames <<"| and attributes descriptions |" << attributesDescriptions << "|")) ;
+ }
+ else
+ med_2_1::_MEDdatagroupFermer(_medIdt);
+
+
+ }
+
+ END_OF(LOC);
+
+ return MED_VALID;
+}
+
+
+// A FAIRE POUR LES NOEUDS ET LES ELEMENTS ret = MEDfamEcr(
+
+
+
+/*--------------------- RDWR PART -------------------------------*/
+
+MED_MESH_RDWR_DRIVER21::MED_MESH_RDWR_DRIVER21()
+{
+}
+
+MED_MESH_RDWR_DRIVER21::MED_MESH_RDWR_DRIVER21(const string & fileName,
+ MESH * ptrMesh):
+ MED_MESH_DRIVER(fileName,ptrMesh,MED_RDWR),
+ IMED_MESH_RDONLY_DRIVER(fileName,ptrMesh),
+ IMED_MESH_WRONLY_DRIVER(fileName,ptrMesh),
+ IMED_MESH_RDWR_DRIVER(fileName,ptrMesh),
+ MED_MESH_DRIVER21(fileName,ptrMesh,MED_RDWR),
+ MED_MESH_RDONLY_DRIVER21(fileName,ptrMesh),
+ MED_MESH_WRONLY_DRIVER21(fileName,ptrMesh)
+{
+ MESSAGE("MED_MESH_RDWR_DRIVER21::MED_MESH_RDWR_DRIVER21(const string & fileName, MESH * ptrMesh) has been created");
+}
+
+MED_MESH_RDWR_DRIVER21::MED_MESH_RDWR_DRIVER21(const MED_MESH_RDWR_DRIVER21 & driver):
+ MED_MESH_DRIVER(driver),
+ IMED_MESH_RDONLY_DRIVER(driver),
+ IMED_MESH_WRONLY_DRIVER(driver),
+ IMED_MESH_RDWR_DRIVER(driver),
+ MED_MESH_DRIVER21(driver),
+ MED_MESH_RDONLY_DRIVER21(driver),
+ MED_MESH_WRONLY_DRIVER21(driver)
+{
+}
+
+MED_MESH_RDWR_DRIVER21::~MED_MESH_RDWR_DRIVER21() {
+ //MESSAGE("MED_MESH_RDWR_DRIVER21::MED_MESH_RDWR_DRIVER21(const string & fileName, MESH * ptrMesh) has been destroyed");
+}
+
+GENDRIVER * MED_MESH_RDWR_DRIVER21::copy(void) const
+{
+ return new MED_MESH_RDWR_DRIVER21(*this);
+}
+
+void MED_MESH_RDWR_DRIVER21::write(void) const
+{
+ MED_MESH_WRONLY_DRIVER21::write();
+}
+void MED_MESH_RDWR_DRIVER21::read (void)
+{
+ MED_MESH_RDONLY_DRIVER21::read();
+}
+
--- /dev/null
+#ifndef MED_MESH_DRIVER21_HXX
+#define MED_MESH_DRIVER21_HXX
+
+#include "MEDMEM_MedMeshDriver.hxx"
+#include "MEDMEM_define.hxx"
+#include "MEDMEM_Compatibility21_22.hxx"
+
+/*!
+
+ Driver Med for MESH.
+
+ Generic part : implement open and close methods.
+
+*/
+
+namespace MEDMEM {
+class MESH;
+class FAMILY;
+class GROUP;
+class CONNECTIVITY;
+
+class MED_MESH_DRIVER21 : public virtual MED_MESH_DRIVER
+{
+protected:
+
+ med_2_1::med_idt _medIdt;
+
+public :
+
+ // all MED cell type
+ static const med_2_1::med_geometrie_element all_cell_type[MED_NBR_GEOMETRIE_MAILLE];
+
+ static const char * const all_cell_type_tab [MED_NBR_GEOMETRIE_MAILLE];
+
+ /*!
+ Constructor.
+ */
+ MED_MESH_DRIVER21() ;
+ /*!
+ Constructor.
+ */
+ MED_MESH_DRIVER21(const string & fileName,
+ MESH * ptrMesh,
+ MED_EN::med_mode_acces accessMode) ;
+ /*!
+ Copy constructor.
+ */
+ MED_MESH_DRIVER21(const MED_MESH_DRIVER21 & driver) ;
+
+ /*!
+ Destructor.
+ */
+ virtual ~MED_MESH_DRIVER21() ;
+
+ void open();
+ void close();
+};
+
+/*!
+
+ Driver Med for MESH : Read only.
+
+ Implement read method.
+
+*/
+
+ class MED_MESH_RDONLY_DRIVER21 : public virtual IMED_MESH_RDONLY_DRIVER , public virtual MED_MESH_DRIVER21
+{
+
+public :
+
+ /*!
+ Constructor.
+ */
+ MED_MESH_RDONLY_DRIVER21() ;
+ /*!
+ Constructor.
+ */
+ MED_MESH_RDONLY_DRIVER21(const string & fileName, MESH * ptrMesh) ;
+ /*!
+ Copy constructor.
+ */
+ MED_MESH_RDONLY_DRIVER21(const MED_MESH_RDONLY_DRIVER21 & driver) ;
+
+ /*!
+ Destructor.
+ */
+ virtual ~MED_MESH_RDONLY_DRIVER21() ;
+ void read(void);
+private:
+ int getCOORDINATE();
+ int getCONNECTIVITY();
+ int getFAMILY();
+ int getNodalConnectivity(CONNECTIVITY * Connectivity) ;
+ int getNodesFamiliesNumber(int * MEDArrayNodeFamily) ;
+ int getCellsFamiliesNumber(int** Arrays, CONNECTIVITY* Connectivity, MED_EN::medEntityMesh entity) ;
+ void getGRID ();
+
+ GENDRIVER * copy ( void ) const ;
+
+};
+
+/*!
+
+ Driver Med for MESH : Write only.
+
+ Implement write method.
+
+*/
+
+class MED_MESH_WRONLY_DRIVER21 : public virtual IMED_MESH_WRONLY_DRIVER, public virtual MED_MESH_DRIVER21 {
+
+public :
+
+ /*!
+ Constructor.
+ */
+ MED_MESH_WRONLY_DRIVER21() ;
+ /*!
+ Constructor.
+ */
+ MED_MESH_WRONLY_DRIVER21(const string & fileName, MESH * ptrMesh) ;
+ /*!
+ Copy constructor.
+ */
+ MED_MESH_WRONLY_DRIVER21(const MED_MESH_WRONLY_DRIVER21 & driver) ;
+
+ /*!
+ Destructor.
+ */
+ virtual ~MED_MESH_WRONLY_DRIVER21() ;
+
+ /*!
+ Write MESH in the specified file.
+ */
+ void write( void ) const;
+
+private:
+ int writeCoordinates () const;
+ int writeConnectivities (MED_EN::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_DRIVER21 : public IMED_MESH_RDWR_DRIVER, public MED_MESH_RDONLY_DRIVER21, public MED_MESH_WRONLY_DRIVER21 {
+
+public :
+
+ /*!
+ Constructor.
+ */
+ MED_MESH_RDWR_DRIVER21() ;
+ /*!
+ Constructor.
+ */
+ MED_MESH_RDWR_DRIVER21(const string & fileName, MESH * ptrMesh) ;
+ /*!
+ Copy constructor.
+ */
+ MED_MESH_RDWR_DRIVER21(const MED_MESH_RDWR_DRIVER21 & driver) ;
+
+ /*!
+ Destructor.
+ */
+ ~MED_MESH_RDWR_DRIVER21() ;
+
+ /*!
+ Write MESH in the specified file.
+ */
+ void write(void) const;
+ /*!
+ Read MESH in the specified file.
+ */
+ void read (void);
+
+private:
+ GENDRIVER * copy(void) const ;
+
+};
+};
+
+#endif /* MED_MESH_DRIVER21_HXX */
--- /dev/null
+#include "MEDMEM_MedMeshDriver22.hxx"
+
+#include "MEDMEM_DriversDef.hxx"
+
+#include "MEDMEM_Family.hxx"
+#include "MEDMEM_Group.hxx"
+#include "MEDMEM_Coordinate.hxx"
+#include "MEDMEM_Connectivity.hxx"
+#include "MEDMEM_Mesh.hxx"
+#include "MEDMEM_CellModel.hxx"
+#include "MEDMEM_Grid.hxx"
+
+using namespace std;
+using namespace MED_EN;
+using namespace MEDMEM;
+
+namespace med_2_2 {
+ extern "C" {
+ extern med_idt _MEDdatagroupOuvrir(med_idt pid, char *nom);
+ extern med_err _MEDdatagroupFermer(med_idt id);
+ }
+}
+
+// Every memory allocation made in the MedDriver members function are desallocated in the Mesh destructor
+
+MED_MESH_DRIVER22::MED_MESH_DRIVER22(): _medIdt(MED_INVALID)
+{
+}
+
+MED_MESH_DRIVER22::MED_MESH_DRIVER22(const string & fileName,
+ MESH * ptrMesh,
+ MED_EN::med_mode_acces accessMode):
+ _medIdt(MED_INVALID), MED_MESH_DRIVER(fileName,ptrMesh,accessMode)
+{
+}
+
+MED_MESH_DRIVER22::MED_MESH_DRIVER22(const MED_MESH_DRIVER22 & driver):
+ MED_MESH_DRIVER(driver),_medIdt(driver._medIdt)
+{
+}
+
+MED_MESH_DRIVER22::~MED_MESH_DRIVER22()
+{
+}
+
+void MED_MESH_DRIVER22::open()
+{
+ const char * LOC = "MED_MESH_DRIVER22::open()" ;
+ BEGIN_OF(LOC);
+
+ MESSAGE(LOC<<" : _fileName.c_str : "<< _fileName.c_str()<<",mode : "<< _accessMode);
+ _medIdt = med_2_2::MEDouvrir( (const_cast <char *> (_fileName.c_str())),(med_2_2::med_mode_acces) _accessMode);
+ MESSAGE(LOC<<" _medIdt : "<< _medIdt );
+ if (_medIdt > 0)
+ _status = MED_OPENED;
+ else {
+ _medIdt = MED_INVALID;
+ _status = MED_CLOSED;
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Could not open file "<<_fileName<<" in mode "<<_accessMode));
+ }
+
+ END_OF(LOC);
+}
+
+void MED_MESH_DRIVER22::close()
+{
+ const char * LOC = "MED_MESH_DRIVER22::close() " ;
+ BEGIN_OF(LOC);
+ int err = 0;
+ if ( _status == MED_OPENED) {
+ err = med_2_2::MEDfermer(_medIdt);
+ // san -- MED5873 : Calling H5close() here leads to failure of SALOMEDS::StudyManager_i::_SaveAs()
+ // method during study saving process. MEDfermer() seems sufficient for closing a file.
+ //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);
+}
+
+//A FAIRE UTILISER LES MAPS...
+const med_2_2::med_geometrie_element MED_MESH_DRIVER22::all_cell_type[MED_NBR_GEOMETRIE_MAILLE]=
+ { med_2_2::MED_POINT1,med_2_2::MED_SEG2,med_2_2::MED_SEG3,med_2_2::MED_TRIA3,med_2_2::MED_QUAD4,med_2_2::MED_TRIA6,med_2_2::MED_QUAD8,
+ med_2_2::MED_TETRA4,med_2_2::MED_PYRA5,med_2_2::MED_PENTA6,med_2_2::MED_HEXA8,med_2_2::MED_TETRA10,med_2_2::MED_PYRA13,
+ med_2_2::MED_PENTA15, med_2_2::MED_HEXA20};
+
+const char * const MED_MESH_DRIVER22::all_cell_type_tab [MED_NBR_GEOMETRIE_MAILLE]=
+ { "MED_POINT1","MED_SEG2","MED_SEG3","MED_TRIA3","MED_QUAD4","MED_TRIA6","MED_QUAD8",
+ "MED_TETRA4","MED_PYRA5","MED_PENTA6","MED_HEXA8","MED_TETRA10","MED_PYRA13",
+ "MED_PENTA15","MED_HEXA20"};
+
+
+//---------------------------------- RDONLY PART -------------------------------------------------------------
+
+MED_MESH_RDONLY_DRIVER22::MED_MESH_RDONLY_DRIVER22()
+{
+}
+
+MED_MESH_RDONLY_DRIVER22::MED_MESH_RDONLY_DRIVER22(const string & fileName,
+ MESH * ptrMesh):
+ IMED_MESH_RDONLY_DRIVER(fileName,ptrMesh),MED_MESH_DRIVER22(fileName,ptrMesh,MED_RDONLY),MED_MESH_DRIVER(fileName,ptrMesh,MED_RDONLY)
+{
+ MESSAGE("MED_MESH_RDONLY_DRIVER22::MED_MESH_RDONLY_DRIVER22(const string & fileName, MESH * ptrMesh) has been created");
+}
+
+MED_MESH_RDONLY_DRIVER22::MED_MESH_RDONLY_DRIVER22(const MED_MESH_RDONLY_DRIVER22 & driver):
+ IMED_MESH_RDONLY_DRIVER(driver),MED_MESH_DRIVER22(driver),MED_MESH_DRIVER(driver)
+{
+}
+
+MED_MESH_RDONLY_DRIVER22::~MED_MESH_RDONLY_DRIVER22()
+{
+ //MESSAGE("MED_MESH_RDONLY_DRIVER22::~MED_MESH_RDONLY_DRIVER() has been destroyed");
+}
+
+GENDRIVER * MED_MESH_RDONLY_DRIVER22::copy(void) const
+{
+ return new MED_MESH_RDONLY_DRIVER22(*this);
+}
+
+void MED_MESH_RDONLY_DRIVER22::read(void)
+{
+ const char * LOC = "MED_MESH_RDONLY_DRIVER22::read() : " ;
+ BEGIN_OF(LOC);
+ if (_status!=MED_OPENED)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "The _idt of file " << _fileName << " is : " << _medIdt << " (the file is not opened)." )) ;
+
+ _ptrMesh->_name = _meshName;
+
+ SCRUTE(_ptrMesh->getIsAGrid());
+
+ if (_ptrMesh->getIsAGrid())
+ {
+ getGRID( );
+
+ // always call getFAMILY : families are requiered !!!!
+
+// int nbFam = MEDnFam(_medIdt,
+// const_cast <char *> (_meshName.c_str()),
+// 0,
+// MED_FR::MED_FAMILLE);
+// if (nbFam > 0)
+ {
+// getFAMILY();
+
+ if (getFAMILY()!=MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERREUR in getFAMILY when the mesh is a grid")) ;
+
+ buildAllGroups(_ptrMesh->_groupNode,_ptrMesh->_familyNode) ;
+ }
+
+ END_OF(LOC);
+ return;
+ }
+
+ if (getCOORDINATE()!=MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERREUR in getCOORDINATE" )) ;
+
+ if (getCONNECTIVITY()!=MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERREUR in getCOONECTIVITY")) ;
+
+ if (getFAMILY()!=MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERREUR in getFAMILY" )) ;
+
+ updateFamily();
+
+ // we build all groups
+ // on node
+ buildAllGroups(_ptrMesh->_groupNode,_ptrMesh->_familyNode) ;
+ // on cell
+ buildAllGroups(_ptrMesh->_groupCell,_ptrMesh->_familyCell) ;
+ // on face
+ buildAllGroups(_ptrMesh->_groupFace,_ptrMesh->_familyFace) ;
+ // on edge
+ buildAllGroups(_ptrMesh->_groupEdge,_ptrMesh->_familyEdge) ;
+
+// MESSAGE(LOC<<"Checking of CellModel !!!!!!!");
+
+// int nbOfTypes = _ptrMesh->_connectivity->_numberOfTypes;
+// for(int i=0;i<nbOfTypes;i++)
+// {
+// MESSAGE(LOC << _ptrMesh->_connectivity->_type[i]) ;
+// }
+
+ END_OF(LOC);
+}
+
+//=======================================================================
+//function : getGRID
+//purpose :
+//=======================================================================
+
+void MED_MESH_RDONLY_DRIVER22::getGRID()
+{
+ const char * LOC = "MED_MESH_RDONLY_DRIVER22::getGRID() : " ;
+ BEGIN_OF(LOC);
+
+ if (_status!=MED_OPENED)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "med file is not opened"));
+
+ GRID * ptrGrid = (GRID *) _ptrMesh;
+
+ SCRUTE(ptrGrid);
+
+ int err, i;
+
+ int numberOfMeshesInFile = med_2_2::MEDnMaa(_medIdt);
+
+ if (numberOfMeshesInFile == MED_INVALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Problem in File where the mesh " << _meshName << " is supposed to be stored"));
+
+ for (int index = 0; index < numberOfMeshesInFile; index++)
+ {
+ char meshName[MED_TAILLE_NOM+1]="";
+ char meshDescription[MED_TAILLE_DESC+1]="";
+ int meshDim;
+ med_2_2::med_maillage meshType;
+
+ err = med_2_2::MEDmaaInfo(_medIdt, (index+1),meshName, &meshDim,
+ &meshType, meshDescription) ;
+
+ MESSAGE(LOC<<": Mesh n°"<< (index+1) <<" nammed "<< meshName << " with the description " << meshDescription << " is structured");
+
+ if (_meshName == string(meshName))
+ {
+ _ptrMesh->_description = meshDescription;
+ _ptrMesh->_name = meshName;
+ }
+ }
+
+ MED_EN::med_grid_type gridType = ptrGrid->getGridType();
+
+ MESSAGE(LOC<<": Mesh processed is nammed "<< _ptrMesh->_name << " with the description " << _ptrMesh->_description << " is structured with the type " << gridType);
+
+ // Read the dimension of the mesh <_meshName>
+ int MeshDimension = med_2_2::MEDdimLire(_medIdt, const_cast <char *>
+ (_meshName.c_str())) ;
+
+ if (MeshDimension == MED_INVALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "The mesh dimension |" <<
+ MeshDimension << "| seems to be incorrect " <<
+ "for the mesh : |" << _meshName << "|")) ;
+
+ _ptrMesh->_meshDimension = MeshDimension;
+
+ // Read or get the dimension of the space for the mesh <_meshName>
+ int SpaceDimension = MeshDimension;
+
+ int SpaceDimensionRead = med_2_2::MEDdimEspaceLire(_medIdt,
+ const_cast <char *>
+ (_meshName.c_str())) ;
+
+ if (SpaceDimensionRead != MED_INVALID) SpaceDimension = SpaceDimensionRead;
+
+ _ptrMesh->_spaceDimension = SpaceDimension;
+
+ med_2_2::med_repere rep ;
+ string tmp_nom_coord (MED_TAILLE_PNOM22*(_ptrMesh->_spaceDimension)+1,' ');
+ string tmp_unit_coord(MED_TAILLE_PNOM22*(_ptrMesh->_spaceDimension)+1,' ');
+ char * tmp_nom = (const_cast <char *> ( tmp_nom_coord.c_str()) ) ;
+ char * tmp_unit= (const_cast <char *> ( tmp_unit_coord.c_str()) ) ;
+
+ // Read Array length
+ int * ArrayLen[] = { & ptrGrid->_iArrayLength,
+ & ptrGrid->_jArrayLength,
+ & ptrGrid->_kArrayLength };
+
+ MESSAGE(LOC << "The mesh is a " << _ptrMesh->_meshDimension << "D mesh on a " << _ptrMesh->_spaceDimension << "D space");
+
+ int NumberOfNodes;
+
+ // if (gridType == MED_EN::MED_GRILLE_STANDARD)
+ if (gridType == MED_EN::MED_BODY_FITTED)
+ {
+ int * structure = new int[MeshDimension];
+
+ err = med_2_2::MEDstructureCoordLire(_medIdt,
+ const_cast <char *>
+ (_ptrMesh->_name.c_str()),
+ MeshDimension,structure);
+
+ if (err != MED_VALID)
+ throw MEDEXCEPTION(STRING(LOC) <<"Error in reading the structure of grid : |" << _meshName << "|" ) ;
+
+ NumberOfNodes = 1;
+
+ for (int idim = 0; idim < MeshDimension; idim++)
+ {
+ MESSAGE(LOC<<"structure dim " << idim << " " << structure[idim]);
+
+ ArrayLen [idim][0] = structure[idim];
+ NumberOfNodes = NumberOfNodes*structure[idim];
+ }
+
+ delete [] structure;
+
+// NumberOfNodes = MED_FR::MEDnEntMaa(_medIdt,
+// const_cast <char *>
+// (_ptrMesh->_name.c_str()),
+// MED_FR::MED_COOR,MED_FR::MED_NOEUD,
+// (MED_FR::med_geometrie_element) 0,
+// (MED_FR::med_connectivite) 0);
+
+ if ( NumberOfNodes == MED_INVALID )
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"The number of nodes |" <<
+ NumberOfNodes <<
+ "| seems to be incorrect "
+ << "for the mesh : |" <<
+ _meshName << "|" )) ;
+
+ _ptrMesh->_numberOfNodes = NumberOfNodes ;
+
+ // create coordinates and its structure
+ _ptrMesh->_coordinate = new COORDINATE(SpaceDimension,NumberOfNodes,
+ MED_EN::MED_FULL_INTERLACE);
+
+ err = MEDcoordLire(_medIdt,
+ const_cast <char *> (_ptrMesh->_name.c_str()),
+ _ptrMesh->_spaceDimension,
+ //const_cast <double *> ( _ptrMesh->_coordinate->_coordinate->get(MED_EN::MED_FULL_INTERLACE) ),
+ const_cast <double *> ( _ptrMesh->_coordinate->_coordinate.get(MED_EN::MED_FULL_INTERLACE) ),
+ med_2_2::MED_FULL_INTERLACE,
+ MED_ALL, // we read all the coordinates
+ NULL, // we don't use a profile
+ 0, // so the profile's size is 0
+ &rep,tmp_nom,tmp_unit);
+
+ if (err != MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't read coordinates of the |" <<
+ NumberOfNodes << "| nodes for the mesh : |" <<
+ _meshName << "| of space dimension |" <<
+ SpaceDimension << "| with units names |" <<
+ tmp_nom << "| and units |" <<
+ tmp_unit << " |")) ;
+
+ ptrGrid->_is_coordinates_filled = true;
+ }
+ else if ((gridType == MED_EN::MED_CARTESIAN) ||
+ (gridType == MED_EN::MED_POLAR))
+ {
+ NumberOfNodes = 1;
+
+ double * Array[] = { (double*) 0, (double*) 0, (double*) 0 };
+
+ for (int idim = 0; idim < _ptrMesh->_meshDimension; ++idim)
+ {
+ med_2_2::med_table table;
+ if (idim == 0) table = med_2_2::MED_COOR_IND1;
+ else if (idim == 1) table = med_2_2::MED_COOR_IND2;
+ else if (idim == 2) table = med_2_2::MED_COOR_IND3;
+
+ int length = med_2_2::MEDnEntMaa(_medIdt,
+ const_cast <char *> (_ptrMesh->_name.c_str()),
+ table,med_2_2::MED_NOEUD,
+ med_2_2::MED_NONE,
+ med_2_2::MED_NOD);
+ if ( length <= MED_VALID )
+ throw MEDEXCEPTION(STRING(LOC) <<"The number of nodes |" << length <<
+ "| seems to be incorrect "
+ << "for the mesh : |" << _meshName << "|" ) ;
+
+ ArrayLen [idim][0] = length;
+ NumberOfNodes *= length;
+
+ Array [idim] = new double [ length ];
+
+ err = med_2_2::MEDindicesCoordLire(_medIdt, const_cast <char *>
+ (_ptrMesh->_name.c_str()),
+ _ptrMesh->_meshDimension,
+ Array [idim], length, (idim+1),
+ tmp_nom+(idim*MED_TAILLE_PNOM22),
+ tmp_unit+(idim*MED_TAILLE_PNOM22));
+
+ if (err != MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Error in reading coordinates indices " <<
+ idim << "of the grid : |" <<
+ _meshName << "|" )) ;
+ }
+
+ ptrGrid->_iArray = Array[0];
+ ptrGrid->_jArray = Array[1];
+ ptrGrid->_kArray = Array[2];
+
+ _ptrMesh->_numberOfNodes = NumberOfNodes ;
+
+ // create coordinates
+ _ptrMesh->_coordinate = new COORDINATE(SpaceDimension,NumberOfNodes,
+ MED_EN::MED_FULL_INTERLACE);
+
+ if (gridType == MED_EN::MED_CARTESIAN)
+ rep = med_2_2::MED_CART;
+ else if (gridType == MED_EN::MED_POLAR)
+ {
+ if (SpaceDimension == 2) rep = med_2_2::MED_CYL;
+ else if (SpaceDimension == 3) rep = med_2_2::MED_SPHER;
+ }
+ }
+ else
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<" bad grid type : " << gridType));
+
+ // set coordinate names
+
+ for (i=0; i<_ptrMesh->_spaceDimension; ++i ) {
+ string myStringName(tmp_nom_coord,i*MED_TAILLE_PNOM22,MED_TAILLE_PNOM22) ;
+ string myStringUnit(tmp_unit_coord,i*MED_TAILLE_PNOM22,MED_TAILLE_PNOM22) ;
+ // suppress space at the end
+ int j ;
+ for(j=MED_TAILLE_PNOM22-1;j>=0;j--)
+ if (myStringName[j] != ' ') break ;
+ _ptrMesh->_coordinate->_coordinateName[i]=string(myStringName,0,j+1);
+ for(j=MED_TAILLE_PNOM22-1;j>=0;j--)
+ if (myStringUnit[j] != ' ') break ;
+ _ptrMesh->_coordinate->_coordinateUnit[i]=string(myStringUnit,0,j+1);
+ }
+
+ string coordinateSystem = "UNDEFINED";
+
+ if( rep == med_2_2::MED_CART) coordinateSystem = "CARTESIAN";
+ else if ( rep == med_2_2::MED_CYL) coordinateSystem = "CYLINDRICAL";
+ else if ( rep == med_2_2::MED_SPHER) coordinateSystem = "SPHERICAL";
+
+ _ptrMesh->_coordinate->setCoordinatesSystem(coordinateSystem);
+
+ END_OF(LOC);
+}
+
+//=======================================================================
+//function : getCOORDINATE
+// A FAIRE : RENVOYER DU VOID
+//=======================================================================
+int MED_MESH_RDONLY_DRIVER22::getCOORDINATE()
+{
+ const char * LOC = "MED_MESH_RDONLY_DRIVER22::getCOORDINATE() : " ;
+
+ BEGIN_OF(LOC);
+
+ if (_status==MED_OPENED)
+ {
+ int err ;
+
+ int numberOfMeshesInFile = med_2_2::MEDnMaa(_medIdt);
+
+ if (numberOfMeshesInFile == MED_INVALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Problem in File where the mesh " << _meshName << " is supposed to be stored"));
+
+ for (int index = 0; index < numberOfMeshesInFile; index++)
+ {
+ char meshName[MED_TAILLE_NOM+1]="";
+ char meshDescription[MED_TAILLE_DESC+1]="";
+ int meshDim;
+ med_2_2::med_maillage meshType;
+
+ err = med_2_2::MEDmaaInfo(_medIdt, (index+1), meshName, &meshDim,
+ &meshType, meshDescription) ;
+
+ MESSAGE(LOC<<": Mesh n°"<< (index+1) <<" nammed "<< meshName << " with the description " << meshDescription << " is structured");
+
+ if (_meshName == string(meshName))
+ {
+ _ptrMesh->_description = meshDescription;
+ }
+ }
+
+
+ // Read the dimension of the mesh <_meshName>
+ int MeshDimension = med_2_2::MEDdimLire(_medIdt, const_cast <char *>
+ (_meshName.c_str())) ;
+
+ if ( MeshDimension == MED_INVALID )
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "The mesh dimension |" <<
+ MeshDimension <<
+ "| seems to be incorrect " <<
+ "for the mesh : |" << _meshName << "|")) ;
+
+ _ptrMesh->_meshDimension = MeshDimension;
+
+ // Read or get the dimension of the space for the mesh <_meshName>
+ int SpaceDimension = MeshDimension;
+
+ int SpaceDimensionRead = med_2_2::MEDdimEspaceLire(_medIdt,
+ const_cast <char *>
+ (_meshName.c_str())) ;
+
+ if (SpaceDimensionRead != MED_INVALID)
+ SpaceDimension = SpaceDimensionRead;
+
+ _ptrMesh->_spaceDimension = SpaceDimension;
+
+ // Read the number of nodes used in the mesh <_meshName>
+ // to be able to create a COORDINATE object
+ int NumberOfNodes=MEDnEntMaa(_medIdt,
+ const_cast <char *> (_meshName.c_str()),
+ med_2_2::MED_COOR,
+ med_2_2::MED_NOEUD,
+ (med_2_2::med_geometrie_element) MED_NONE,
+ (med_2_2::med_connectivite) MED_NONE);
+ if ( NumberOfNodes <= MED_VALID )
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"The number of nodes |" << NumberOfNodes << "| seems to be incorrect "
+ << "for the mesh : |" << _meshName << "|" )) ;
+ _ptrMesh->_numberOfNodes = NumberOfNodes ;
+
+ // create a COORDINATE object
+ _ptrMesh->_coordinate = new COORDINATE(SpaceDimension, NumberOfNodes, MED_EN::MED_FULL_INTERLACE);
+
+ med_2_2::med_repere rep ; // ATTENTION ---> DOIT ETRE INTEGRE DS MESH EF: FAIT NON?
+ string tmp_nom_coord (MED_TAILLE_PNOM22*(_ptrMesh->_spaceDimension)+1,'\0');
+ string tmp_unit_coord(MED_TAILLE_PNOM22*(_ptrMesh->_spaceDimension)+1,'\0');
+ char * tmp_nom = (const_cast <char *> ( tmp_nom_coord.c_str()) ) ;
+ char * tmp_unit= (const_cast <char *> ( tmp_unit_coord.c_str()) ) ;
+
+ err=MEDcoordLire(_medIdt,
+ const_cast <char *> (_ptrMesh->_name.c_str()),
+ _ptrMesh->_spaceDimension,
+ //const_cast <double *> ( _ptrMesh->_coordinate->_coordinate->get(MED_EN::MED_FULL_INTERLACE) ),
+ const_cast <double *> ( _ptrMesh->_coordinate->_coordinate.get(MED_EN::MED_FULL_INTERLACE) ),
+ med_2_2::MED_FULL_INTERLACE,
+ MED_ALL, // we read all the coordinates
+ NULL, // we don't use a profile
+ 0, // so the profile's size is 0
+ &rep,tmp_nom,tmp_unit);
+ if (err != MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't read coordinates of the |" << NumberOfNodes << "| nodes "
+ << "for the mesh : |" << _meshName
+ << "| of space dimension |" << SpaceDimension
+ << "| with units names |" << tmp_nom
+ << "| and units |" << tmp_unit
+ << " |")) ;
+
+
+ for (int i=0;i<_ptrMesh->_spaceDimension;i++) {
+ string myStringName(tmp_nom_coord,i*MED_TAILLE_PNOM22,MED_TAILLE_PNOM22) ;
+ string myStringUnit(tmp_unit_coord,i*MED_TAILLE_PNOM22,MED_TAILLE_PNOM22) ;
+ // suppress space at the end
+ int j ;
+ for(j=MED_TAILLE_PNOM22-1;j>=0;j--)
+ if (myStringName[j] != ' ') break ;
+ _ptrMesh->_coordinate->_coordinateName[i]=string(myStringName,0,j+1);
+ for(j=MED_TAILLE_PNOM22-1;j>=0;j--)
+ if (myStringUnit[j] != ' ') break ;
+ _ptrMesh->_coordinate->_coordinateUnit[i]=string(myStringUnit,0,j+1);
+ }
+
+ // Pourquoi le stocker sous forme de chaîne ?
+ switch (rep)
+ {
+ case med_2_2::MED_CART :
+ {
+ _ptrMesh->_coordinate->_coordinateSystem = "CARTESIAN";
+ break ;
+ }
+ case med_2_2::MED_CYL :
+ {
+ _ptrMesh->_coordinate->_coordinateSystem = "CYLINDRICAL";
+ break ;
+ }
+ case med_2_2::MED_SPHER :
+ {
+ _ptrMesh->_coordinate->_coordinateSystem = "SPHERICAL";
+ break ;
+ }
+ default :
+ {
+ _ptrMesh->_coordinate->_coordinateSystem = "UNDEFINED"; // ?Erreur ?
+ break ;
+ }
+ }
+
+ // Read the unused optional node Names
+ char * tmp_node_name = new char[NumberOfNodes*MED_TAILLE_PNOM22+1];
+ tmp_node_name[NumberOfNodes]='\0' ;
+ err=MEDnomLire(_medIdt,const_cast <char*> (_ptrMesh->_name.c_str()),
+ tmp_node_name,NumberOfNodes*MED_TAILLE_PNOM22,med_2_2::MED_NOEUD,
+ (med_2_2::med_geometrie_element) MED_NONE);
+ if (err == MED_VALID)
+ MESSAGE(LOC<<"MED_MESH_RDONLY_DRIVER::getNoeuds() : WARNING : Nodes have names but we do not read them !");
+ delete[] tmp_node_name ;
+
+
+ // ??? Read the unused optional node Numbers ???
+ med_2_2::med_int * tmp_node_number = new med_2_2::med_int[NumberOfNodes] ;
+ err=MEDnumLire(_medIdt,const_cast <char*> (_ptrMesh->_name.c_str()),
+ tmp_node_number,NumberOfNodes,med_2_2::MED_NOEUD,(med_2_2::med_geometrie_element)0);
+ if (err == MED_VALID) {
+ // INFOS(LOC<<"WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING");
+ // INFOS(LOC<<"MED_MESH_RDONLY_DRIVER::getNoeuds() : WARNING : Nodes have numbers but we do not take care of them !");
+ // INFOS(LOC<<"WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING");
+ MESSAGE(LOC<<"MED_MESH_RDONLY_DRIVER::getNoeuds() : Nodes have numbers, we DO TAKE care of them !");
+ _ptrMesh->_coordinate->_nodeNumber.set(NumberOfNodes) ;
+#if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
+ for(med_2_2::med_int i2=0;i2<NumberOfNodes;i2++)
+ _ptrMesh->_coordinate->_nodeNumber[i2]=(int)(tmp_node_number[i2]);
+#else
+ memcpy((int*)_ptrMesh->_coordinate->_nodeNumber,tmp_node_number,sizeof(int)*NumberOfNodes) ;
+#endif
+
+ //////////////////////////////////////////////////////////////////////////////////////
+ /// Modification pour prise en compte de la numérotation optionnelle des noeuds ///
+ //////////////////////////////////////////////////////////////////////////////////////
+ ///
+ /// Calcule _optionnalToCanonicNodesNumbers de telle sorte que _optionnalToCanonicNodesNumbers[OptionnalNumber]==CanonicNumber
+
+// _ptrMesh->_arePresentOptionnalNodesNumbers=1;
+// for (int canonicNumber=1;canonicNumber<=NumberOfNodes;canonicNumber++) _ptrMesh->_optionnalToCanonicNodesNumbers[tmp_node_number[canonicNumber-1]]=canonicNumber;
+// ICI RETOUR A LA NORMALE::: AUCUNE PRISE EN COMPTE D'UN NUMEROTATION OPTIONNEL
+ _ptrMesh->_arePresentOptionnalNodesNumbers=0;
+ }
+ else _ptrMesh->_arePresentOptionnalNodesNumbers=0;
+
+ //////////////////////////////////////////////////////////////////////////////////////
+
+ delete[] tmp_node_number ;
+
+ END_OF(LOC);
+ return MED_VALID;
+ }
+ return MED_ERROR;
+}
+
+
+int MED_MESH_RDONLY_DRIVER22::getCONNECTIVITY()
+{
+ const char * LOC = "MED_MESH_RDONLY_DRIVER22::getCONNECTIVITY : " ;
+ BEGIN_OF(LOC);
+
+ if (_status==MED_OPENED)
+ {
+
+ int err = 0 ;
+ // read MED_CELL connectivity
+ CONNECTIVITY * Connectivity = new CONNECTIVITY(MED_CELL) ;
+ Connectivity->_numberOfNodes = _ptrMesh->_numberOfNodes ; // EF : Pourquoi cet attribut est-il dans MESH et non dans COORDINATE ?
+
+ // Try to read nodal connectivity of the cells <Connectivity->_nodal>
+ // then try to read descending connectivity <Connectivity->_descending>
+ // if neither nodal nor descending connectivity exists
+ // throw an exception.
+ err = getNodalConnectivity(Connectivity) ;
+ if (err!=MED_VALID)
+ {
+ Connectivity->_typeConnectivity = MED_DESCENDING ;
+ err = getDescendingConnectivity(Connectivity) ;
+ }
+ else
+ getDescendingConnectivity(Connectivity) ; // we read it if there is one
+
+ if (err!=MED_VALID)
+ {
+ delete Connectivity ;
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "We could not read " <<
+ "any Connectivity")) ;
+ }
+
+ if (Connectivity->_entityDimension != _ptrMesh->_meshDimension)
+ MESSAGE(LOC << "Small mesh dimension problem on the med file mounted in memory : diim stored " << _ptrMesh->_meshDimension << " dim computed using the connectivity " << Connectivity->_entityDimension);
+
+ _ptrMesh->_meshDimension = Connectivity->_entityDimension ;
+
+ // At this point Connectivity->_typeConnectivity is either NODAL or DESCENDING
+ // If both connectivities are found Connectivity->_typeConnectivity is NODAL
+ // If space dimension is 3
+ // try to read the nodal connectivity of the faces <ConnectivityFace->_nodal> then
+ // try to read the descending connectivity <ConnectivityFace->_descending>
+ // if there is no descending connectivity and the CELLS are
+ // defined in descending mode then throw an exception
+
+ // PROVISOIRE : if we have some face or edge in MED_MAILLE, we don't read more. There could not be have face or edge !!!!
+
+ if(Connectivity->_constituent==NULL) {
+
+ SCRUTE(_ptrMesh->_meshDimension);
+ SCRUTE(Connectivity->_entityDimension);
+ if (_ptrMesh->_meshDimension == 3) {
+ MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE DES FACES..." );
+ CONNECTIVITY * ConnectivityFace = new CONNECTIVITY(MED_EN::MED_FACE) ;
+ ConnectivityFace->_typeConnectivity = Connectivity->_typeConnectivity ; // NODAL or DESCENDING
+ SCRUTE(ConnectivityFace->_typeConnectivity);
+ if (Connectivity->_typeConnectivity == MED_DESCENDING) {
+ MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE DESCENDANTE DES FACES" );
+ err = getDescendingConnectivity(ConnectivityFace) ;
+ if (err!=MED_VALID)
+ throw MEDEXCEPTION ( LOCALIZED(STRING(LOC) << "No FACE in descending connectivity")) ;
+ getNodalConnectivity(ConnectivityFace) ; // if any !
+ } else {
+ MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE NODALE DES FACES" );
+ err = getNodalConnectivity(ConnectivityFace) ;
+ if (err!=MED_VALID) { // or error ????? we are in NODAL mode.
+ err = getDescendingConnectivity(ConnectivityFace) ;
+ } else
+ getDescendingConnectivity(ConnectivityFace); // if any !
+ }
+ if (err!=MED_VALID) {
+ delete ConnectivityFace ;
+ MESSAGE(LOC<<"No FACE defined.") ;
+ } else {
+ MESSAGE(LOC<<" SAUVEGARDE DE LA CONNECTIVITE DES FACES DANS L'OBJET CONNECTIVITY" );
+ Connectivity->_constituent=ConnectivityFace ;
+ }
+ }
+
+ // read MED_EDGE connectivity
+ if (_ptrMesh->_meshDimension > 1) { // we are in 3 or 2D
+ MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE DES ARRETES...." );
+ CONNECTIVITY * ConnectivityEdge = new CONNECTIVITY(MED_EDGE) ;
+ ConnectivityEdge->_typeConnectivity = Connectivity->_typeConnectivity ;
+ if (Connectivity->_typeConnectivity == MED_DESCENDING) {
+ MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE DESCENDANTE DES ARRETES" );
+ err = getDescendingConnectivity(ConnectivityEdge) ;
+ if (err!=MED_VALID)
+ throw MEDEXCEPTION ( LOCALIZED(STRING(LOC) << "No EDGE in descending connectivity")) ;
+ getNodalConnectivity(ConnectivityEdge) ; // if any !
+ } else {
+ MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE NODALE DES ARRETES" );
+ err = getNodalConnectivity(ConnectivityEdge) ;
+ if (err!=MED_VALID) { // or error ????? we are in NODAL mode.
+ err = getDescendingConnectivity(ConnectivityEdge) ;
+ } else
+ getDescendingConnectivity(ConnectivityEdge) ; // if any !
+ }
+ if (err!=MED_VALID) {
+ delete ConnectivityEdge ;
+ MESSAGE(LOC<<"No EDGE defined.") ;
+ } else {
+ if (_ptrMesh->_meshDimension == 3)
+ if (Connectivity->_constituent != NULL)
+ Connectivity->_constituent->_constituent=ConnectivityEdge ;
+ else
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<< "EDGE defined but there are no FACE !")) ;
+ else { // IN 2D
+ MESSAGE(LOC<<" SAUVEGARDE DE LA CONNECTIVITE DES ARETES DANS L'OBJET CONNECTIVITY" );
+ Connectivity->_constituent=ConnectivityEdge ;
+ }
+ }
+ }
+ }
+ _ptrMesh->_connectivity = Connectivity ;
+
+ // all right !
+
+ // we have read all connectivity in file, now we must build descending connectivity if necessary !
+
+ // If connectivity descending is defined, we have nothing to do, all constituent are defined !
+ // If connectivity is only nodal, we must rebuild descending if we have some contituent !
+
+ //A FAIRE !!!!
+// if (Connectivity->_descending == NULL)
+// if (Connectivity->_constituent != NULL){
+// // update Connectivity->_constituent
+// CONNECTIVITY * myConstituentOld = Connectivity->_constituent ;
+// Connectivity->_constituent = (CONNECTIVITY *)NULL ;
+// Connectivity->calculateDescendingConnectivity() ;
+
+// }
+
+ END_OF(LOC);
+ return MED_VALID;
+ }
+ return MED_ERROR;
+}
+
+int MED_MESH_RDONLY_DRIVER22::getNodalConnectivity(CONNECTIVITY * Connectivity)
+{
+ const char * LOC = "MED_MESH_RDONLY_DRIVER22::getNodalConnectivity : " ;
+ BEGIN_OF(LOC);
+
+ int spaceDimension = _ptrMesh->_spaceDimension;
+
+ if (_status==MED_OPENED)
+ {
+ // Get the type of entity to work on (previously set in the Connectivity Object)
+ med_2_2::med_entite_maillage Entity = (med_2_2::med_entite_maillage) Connectivity->getEntity();
+
+ // Get the number of cells of each type & store it in <tmp_cells_count>.
+ int * tmp_cells_count = new int[MED_NBR_GEOMETRIE_MAILLE] ;
+ int i;
+ for (i=1;i<MED_NBR_GEOMETRIE_MAILLE;i++)
+ { // EF :ON SCANNE DES GEOMETRIES INUTILES, UTILISER LES MAPS
+ tmp_cells_count[i]=MEDnEntMaa(_medIdt,(const_cast <char *> (_ptrMesh->_name.c_str())),
+ med_2_2::MED_CONN,(med_2_2::med_entite_maillage) Entity,
+ all_cell_type[i],med_2_2::MED_NOD);
+
+
+ // Get the greatest dimension of the cells : Connectivity->_entityDimension
+ // We suppose there is no cells used as faces in MED 2.2.x , this is forbidden !!!
+ // In version prior to 2.2.x, it is possible
+ if (tmp_cells_count[i]>0)
+ {
+ Connectivity->_entityDimension=all_cell_type[i]/100;
+ Connectivity->_numberOfTypes++;
+ }
+ }
+
+
+
+ // begin classic geometric types
+ if (Connectivity->_numberOfTypes > 0)
+ {
+ // if MED version < 2.2.x, we read only entity with dimention = Connectivity->_entityDimension. Lesser dimension are face or edge !
+
+ med_int major, minor, release;
+
+ if ( med_2_2::MEDversionLire(_medIdt, &major, &minor, &release) != 0 )
+ {
+ // error : we suppose we have not a good med file !
+ delete[] tmp_cells_count ;
+ return MED_ERROR ;
+ }
+
+ // we get MED version number
+ // If MED version is < 2.2 then the cells which dimension
+ // is lesser than the main dimension ( Connectivity->_entityDimension )
+ // are either faces or edges
+
+ // string medVersion(version_med);
+ // int firstNumber =
+ int * tmpEdgeCount = new int[MED_NBR_GEOMETRIE_MAILLE] ;
+ tmpEdgeCount[0] = 0 ;
+ int numberOfEdgesTypes = 0;
+ int * tmpFaceCount = new int[MED_NBR_GEOMETRIE_MAILLE] ;
+ tmpFaceCount[0] = 0 ;
+ int numberOfFacesTypes = 0;
+
+// if ((version_med != "2.2")&(Entity==MED_FR::MED_MAILLE))
+// {
+// Connectivity->_numberOfTypes=0;
+
+// for ( i=1;i<MED_NBR_GEOMETRIE_MAILLE;i++)
+// {
+// tmpFaceCount[i]=0;
+// tmpEdgeCount[i]=0;
+// if (tmp_cells_count[i]!=0)
+// {
+// int dimension = all_cell_type[i]/100 ;
+// if (Connectivity->_entityDimension==dimension)
+// Connectivity->_numberOfTypes++ ;
+
+// if (dimension == 2)
+// if (Connectivity->_entityDimension==3)
+// {
+// tmpFaceCount[i]=tmp_cells_count[i] ;
+// tmp_cells_count[i]=0 ;
+// numberOfFacesTypes++;
+// }
+// if (dimension == 1)
+// if (Connectivity->_entityDimension>dimension)
+// {
+// tmpEdgeCount[i]=tmp_cells_count[i] ;
+// tmp_cells_count[i]=0;
+// numberOfEdgesTypes++ ;
+// }
+// }
+// }
+// }
+
+ if (Entity==med_2_2::MED_MAILLE)
+ {
+ Connectivity->_numberOfTypes=0;
+
+ for ( i=1;i<MED_NBR_GEOMETRIE_MAILLE;i++)
+ {
+ tmpFaceCount[i]=0;
+ tmpEdgeCount[i]=0;
+ if (tmp_cells_count[i]!=0)
+ {
+ int dimension = all_cell_type[i]/100 ;
+ if (Connectivity->_entityDimension==dimension)
+ Connectivity->_numberOfTypes++ ;
+
+ if (dimension == 2)
+ if (Connectivity->_entityDimension==3)
+ {
+ tmpFaceCount[i]=tmp_cells_count[i] ;
+ //tmp_cells_count[i]=0 ;
+ //Connectivity->_numberOfTypes++ ;
+ numberOfFacesTypes++;
+ }
+ if (dimension == 1)
+ if (Connectivity->_entityDimension>dimension)
+ {
+ tmpEdgeCount[i]=tmp_cells_count[i] ;
+ //tmp_cells_count[i]=0;
+ //Connectivity->_numberOfTypes++ ;
+ numberOfEdgesTypes++ ;
+ }
+ }
+ }
+ }
+
+ // bloc to read CELL :
+ {
+ // Prepare an array of indexes on the different cell types to create a MEDSKYLINEARRAY
+ // We use <tmp_cells_count> to calculate <Connectivity->_count> then we release it
+ Connectivity->_geometricTypes = new MED_EN::medGeometryElement [Connectivity->_numberOfTypes] ; // Double emploi pour des raisons pratiques
+ Connectivity->_type = new CELLMODEL [Connectivity->_numberOfTypes] ; //
+ Connectivity->_count = new int [Connectivity->_numberOfTypes+1] ;
+ Connectivity->_count[0] = 1;
+
+ int size = 0 ;
+ int typeNumber=1 ;
+ int i;
+ for ( i=1;i<MED_NBR_GEOMETRIE_MAILLE;i++)
+ { // no point1 cell type (?)
+ int dimension = all_cell_type[i]/100 ;
+ if ((tmp_cells_count[i]>0) && (Connectivity->_entityDimension == dimension))
+ {
+ Connectivity->_count[typeNumber]=Connectivity->_count[typeNumber-1]+tmp_cells_count[i];
+
+ CELLMODEL t( (MED_EN::medGeometryElement) MED_MESH_DRIVER22::all_cell_type[i]) ;
+
+ Connectivity->_type[typeNumber-1] = t ;
+
+ Connectivity->_geometricTypes[typeNumber-1]=( MED_EN::medGeometryElement) MED_MESH_DRIVER22::all_cell_type[i] ;
+
+ // probleme avec les mailles de dimension < a dimension du maillage :
+ // Il faut oter le zero a la lecture est le remettre a l'ecriture : ce n'est pas fait !!!!! On interdit ce cas pour l'instant !!!
+
+
+ size+=tmp_cells_count[i]*((MED_MESH_DRIVER22::all_cell_type[i])%100) ;
+
+ MESSAGE(LOC
+ << Connectivity->_count[typeNumber]-1 << " cells of type "
+ << all_cell_type_tab[i] );
+ typeNumber++;
+ }
+ }
+
+ // Creation of the MEDSKYLINEARRAY
+ //Connectivity->_nodal = new MEDSKYLINEARRAY(Connectivity->_count[Connectivity->_numberOfTypes]-1,size) ;
+ //int * NodalIndex = Connectivity->_nodal->getIndex() ;
+ int * NodalValue = new int[size] ;
+ int * NodalIndex = new int[Connectivity->_count[Connectivity->_numberOfTypes]] ;
+ NodalIndex[0]=1 ;
+
+ // Fill the MEDSKYLINEARRAY by reading the MED file.
+ int j=0;
+ for ( i=0;i<Connectivity->_numberOfTypes;i++)
+ {
+ int multi = 0 ;
+ med_2_2::med_geometrie_element med_type = (med_2_2::med_geometrie_element) Connectivity->_type[i].getType() ;
+ // if ( Connectivity->_type[i].getDimension() < Connectivity->_entityDimension)
+ // if (Connectivity->_entity == MED_CELL)
+ // if ( Connectivity->_type[i].getDimension() < _ptrMesh->_spaceDimension)
+ // multi=1;
+
+ // int NumberOfCell = Connectivity->_count[i+1]-Connectivity->_count[i] ;
+ int NumberOfNodeByCell = Connectivity->_type[i].getNumberOfNodes() ;
+
+ // initialise index
+ for ( j=Connectivity->_count[i]; j<Connectivity->_count[i+1];j++)
+ NodalIndex[j]=NodalIndex[j-1]+NumberOfNodeByCell ;
+
+ int tmp_numberOfCells = Connectivity->_count[i+1]-Connectivity->_count[i] ;
+ int * tmp_ConnectivityArray = new int[(NumberOfNodeByCell+multi)*tmp_numberOfCells];
+
+ // int err=MEDconnLire(_medIdt,const_cast <char *> (_ptrMesh->_name.c_str()),
+ // Connectivity->_entityDimension,tmp_ConnectivityArray,
+ // MED_FR::MED_FULL_INTERLACE,NULL,0,Entity,med_type,MED_FR::MED_NOD);
+ int err=MEDconnLire(_medIdt,const_cast <char *> (_ptrMesh->_name.c_str()),
+ spaceDimension,tmp_ConnectivityArray,
+ med_2_2::MED_FULL_INTERLACE,NULL,0,Entity,med_type,med_2_2::MED_NOD);
+
+ if ( err != MED_VALID)
+ {
+ delete[] tmp_ConnectivityArray;
+ delete[] tmp_cells_count;
+ delete[] tmpFaceCount;
+ delete[] tmpEdgeCount;
+ MESSAGE(LOC<<": MEDconnLire returns "<<err) ;
+ return MED_ERROR ;
+ }
+
+ int * ConnectivityArray = NodalValue + NodalIndex[Connectivity->_count[i]-1]-1 ;
+
+ // version originale sans prise en compte des numéros optionnels
+ //
+ for ( j=0; j<tmp_numberOfCells; j++) for (int k=0; k<NumberOfNodeByCell; k++)
+ ConnectivityArray[j*NumberOfNodeByCell+k]=tmp_ConnectivityArray[j*(NumberOfNodeByCell+multi)+k] ;
+
+ //////////////////////////////////////////////////////////////////////////////
+ // Modification pour prise en compte de la numérotation optionnelle des noeuds ///
+ //////////////////////////////////////////////////////////////////////////////
+ //
+ // Rénumérote le tableau temporaire tmp_ConnectivityArray en utilisant _optionnalToCanonicNodesNumbers
+ // Le traitement est identique à la version originelle s'il n'y a pas de numérotation optionnelle
+
+ // if (_ptrMesh->_arePresentOptionnalNodesNumbers==1)
+ // {
+ // for ( j=0; j<tmp_numberOfCells; j++) for (int k=0; k<NumberOfNodeByCell; k++)
+ // ConnectivityArray[j*NumberOfNodeByCell+k]=_ptrMesh->_optionnalToCanonicNodesNumbers[tmp_ConnectivityArray[j*(NumberOfNodeByCell+multi)+k]] ;
+ // }
+ // else
+ // {
+ // for ( j=0; j<tmp_numberOfCells; j++) for (int k=0; k<NumberOfNodeByCell; k++)
+ // ConnectivityArray[j*NumberOfNodeByCell+k]=tmp_ConnectivityArray[j*(NumberOfNodeByCell+multi)+k] ;
+ // }
+ ////////////////////////////////////////////////////////////////////////////
+
+ delete[] tmp_ConnectivityArray;
+
+ }
+
+ Connectivity->_nodal = new MEDSKYLINEARRAY(Connectivity->_count[Connectivity->_numberOfTypes]-1,
+ size,
+ NodalIndex,
+ NodalValue) ;
+
+ delete[] NodalIndex;
+ delete[] NodalValue;
+
+ } // end of bloc to read CELL
+
+
+ // Get Face if any
+ // ===============
+
+ if (numberOfFacesTypes!=0)
+ {
+
+ // Create a CONNECTIVITY constituent to put in the top level CONNECTIVITY recursive class
+ CONNECTIVITY * constituent = new CONNECTIVITY(numberOfFacesTypes,MED_EN::MED_FACE) ;
+ constituent->_entityDimension = 2 ;
+ constituent->_count[0]=1 ;
+
+ // In order to create the MEDSKYLINEARRAY of the constituent object we need :
+ // 1:
+ // To initialize the _count array of the constituent object (containning cumulated face count by geometric type)
+ // _count[0]=1 and _count[_numberOfTypes] give the size of NodalIndex
+ // 2:
+ // To calculate the total number of face nodes whatever the geometric type is.
+ // The result is the size of the array containning all the nodes : NodalValue
+ // 3 :
+ // To calculate the starting indexes of the different face types in NodalValue,
+ // this is the NodalIndex array.
+
+ int size = 0 ;
+ int typeNumber = 1 ;
+ int i;
+ for ( i=1; i < MED_NBR_GEOMETRIE_MAILLE; i++)
+ { // no point1 cell type (?)
+ if (tmpFaceCount[i]>0)
+ {
+ constituent->_count[typeNumber] = constituent->_count[typeNumber-1] + tmpFaceCount[i];
+ CELLMODEL t( (MED_EN::medGeometryElement) MED_MESH_DRIVER22::all_cell_type[i]) ;
+ constituent->_type[typeNumber-1]=t ;
+
+ constituent->_geometricTypes[typeNumber-1]=( MED_EN::medGeometryElement) MED_MESH_DRIVER22::all_cell_type[i] ;
+
+ size+=tmpFaceCount[i]*((MED_MESH_DRIVER22::all_cell_type[i])%100) ;
+ typeNumber++;
+ }
+ }
+
+ // Creation of the MEDSKYLINEARRAY
+ //constituent->_nodal = new MEDSKYLINEARRAY(constituent->_count[constituent->_numberOfTypes]-1,size) ;
+ //int * NodalIndex = constituent->_nodal->getIndex() ;
+ int * NodalValue = new int[size] ;
+ int * NodalIndex = new int[constituent->_count[constituent->_numberOfTypes]] ;
+ NodalIndex[0]=1 ;
+
+ // Fill the MEDSKYLINEARRAY by reading the MED file.
+ for ( i=0; i<constituent->_numberOfTypes; i++)
+ {
+ med_2_2::med_geometrie_element med_type = (med_2_2::med_geometrie_element) constituent->_type[i].getType() ;
+
+ int NumberOfNodeByFace = constituent->_type[i].getNumberOfNodes() ;
+
+ // initialise NodalIndex
+ for (int j=constituent->_count[i]; j<constituent->_count[i+1];j++)
+ NodalIndex[j]=NodalIndex[j-1]+NumberOfNodeByFace ;
+
+ int tmp_numberOfFaces = constituent->_count[i+1]-constituent->_count[i] ;
+ // Il faut ajouter 1 pour le zero a la lecture !!!
+ // ATTENTION UNIQUEMENT POUR MED < 2.2.x
+ int * tmp_constituentArray = NULL;
+
+ MESSAGE(LOC << "Med file version used here " << major << " " << minor << " " << release);
+
+ if ((major == 2) && (minor <= 1))
+ tmp_constituentArray = new int[(NumberOfNodeByFace+1)*tmp_numberOfFaces] ;
+ else if ((major == 2) && (minor >= 2))
+ {
+ tmp_constituentArray = new int[NumberOfNodeByFace*tmp_numberOfFaces] ;
+ MESSAGE(LOC<<": WE ARE USING MED2.2 so there is no +1 for calculating the size of tmp_constituentArray !") ;
+ }
+
+ int err=MEDconnLire(_medIdt,const_cast <char *> (_ptrMesh->_name.c_str()),
+ Connectivity->_entityDimension,tmp_constituentArray,
+ med_2_2::MED_FULL_INTERLACE,NULL,0,med_2_2::MED_MAILLE,med_type,med_2_2::MED_NOD);
+
+ if ( err != MED_VALID)
+ {
+ MESSAGE(LOC<<": MEDconnLire returns "<<err) ;
+ delete constituent ;
+ delete[] tmp_constituentArray;
+ delete[] tmpFaceCount;
+ delete[] tmpEdgeCount;
+ return MED_ERROR ;
+ }
+
+ int * constituentArray = NodalValue + NodalIndex[constituent->_count[i]-1]-1 ;
+
+ // version originale sans prise en compte des numéros optionnels
+ //
+ int multi = 0; // quand est-ce que multi vaut 1 ?? en MED-fichier < 2.2 ??
+ MESSAGE(LOC << "Med file version used here " << major << " " << minor << " " << release);
+
+ if ((major == 2) && (minor <= 1))
+ for (int j=0; j<tmp_numberOfFaces; j++)
+ for (int k=0; k<NumberOfNodeByFace; k++)
+ constituentArray[j*NumberOfNodeByFace+k]=tmp_constituentArray[j*(NumberOfNodeByFace+1)+k] ;
+ else if ((major == 2) && (minor >= 2))
+ for (int j=0; j<tmp_numberOfFaces; j++)
+ for (int k=0; k<NumberOfNodeByFace; k++)
+ constituentArray[j*NumberOfNodeByFace+k]=tmp_constituentArray[j*(NumberOfNodeByFace+multi)+k] ;
+
+ //////////////////////////////////////////////////////////////////////////////////////
+ /// Modification pour prise en compte de la numérotation optionnelle des noeuds ///
+ //////////////////////////////////////////////////////////////////////////////////////
+ ///
+ /// Rénumérote le tableau temporaire tmp_constituentArray en utilisant _optionnalToCanonicNodesNumbers
+ /// Le traitement est identique à la version originelle s'il n'y a pas de numérotation optionnelle
+
+ // if (_ptrMesh->_arePresentOptionnalNodesNumbers)
+ // {
+ // for (int j=0; j<tmp_numberOfFaces; j++) for (int k=0; k<NumberOfNodeByFace; k++)
+ // constituentArray[j*NumberOfNodeByFace+k]=_ptrMesh->_optionnalToCanonicNodesNumbers[tmp_constituentArray[j*(NumberOfNodeByFace+1)+k]] ;
+ // }
+ // else
+ // {
+ // for (int j=0; j<tmp_numberOfFaces; j++) for (int k=0; k<NumberOfNodeByFace; k++)
+ // constituentArray[j*NumberOfNodeByFace+k]=tmp_constituentArray[j*(NumberOfNodeByFace+1)+k] ;
+ // }
+
+ //////////////////////////////////////////////////////////////////////////////////////
+
+ delete[] tmp_constituentArray;
+ }
+
+ constituent->_nodal = new MEDSKYLINEARRAY(constituent->_count[constituent->_numberOfTypes]-1,
+ size,
+ NodalIndex,
+ NodalValue) ;
+ delete[] NodalIndex ;
+ delete[] NodalValue ;
+
+
+ Connectivity->_constituent = constituent ;
+ }
+
+ delete[] tmpFaceCount;
+
+
+ // get Edge if any
+ // ===============
+ if (numberOfEdgesTypes!=0)
+ {
+ CONNECTIVITY * constituent = new CONNECTIVITY(numberOfEdgesTypes,MED_EDGE) ;
+ constituent->_entityDimension = 1 ;
+ constituent->_count[0]=1 ;
+
+ int size = 0 ;
+ int typeNumber=1 ;
+ // if you declare a variable <i> in two <for> initialization statement,
+ // compiler gcc2.95.3 says nothing but there are two <i> variables in the same block
+ //and the value you get in the common block seems to be the value of the first variable !
+ int i;
+
+ for ( i=1; i<MED_NBR_GEOMETRIE_MAILLE; i++)
+ { // no point1 cell type (?)
+ if (tmpEdgeCount[i]>0)
+ {
+
+ constituent->_count[typeNumber]=constituent->_count[typeNumber-1]+tmpEdgeCount[i];
+ CELLMODEL t( (MED_EN::medGeometryElement) MED_MESH_DRIVER22::all_cell_type[i]) ;
+ constituent->_type[typeNumber-1]=t ;
+
+ constituent->_geometricTypes[typeNumber-1]=( MED_EN::medGeometryElement) MED_MESH_DRIVER22::all_cell_type[i] ;
+
+ size+=tmpEdgeCount[i]*((MED_MESH_DRIVER22::all_cell_type[i])%100) ;
+ typeNumber++;
+ }
+ }
+
+ // Creation of the MEDSKYLINEARRAY
+ //constituent->_nodal = new MEDSKYLINEARRAY(constituent->_count[constituent->_numberOfTypes]-1,size) ;
+ //int * NodalIndex = constituent->_nodal->getIndex() ;
+ int * NodalValue = new int[size] ;
+ int * NodalIndex = new int[constituent->_count[constituent->_numberOfTypes]] ;
+ NodalIndex[0]=1 ;
+
+ // Fill the MEDSKYLINEARRAY by reading the MED file.
+ for ( i=0; i<constituent->_numberOfTypes; i++)
+ {
+ med_2_2::med_geometrie_element med_type = (med_2_2::med_geometrie_element) constituent->_type[i].getType() ;
+
+ int NumberOfNodeByEdge = constituent->_type[i].getNumberOfNodes() ;
+
+ // initialise index
+ for (int j=constituent->_count[i]; j<constituent->_count[i+1];j++)
+ NodalIndex[j]=NodalIndex[j-1]+NumberOfNodeByEdge ;
+
+ int tmp_numberOfEdges = constituent->_count[i+1]-constituent->_count[i] ;
+ // Il faut ajouter 1 pour le zero a la lecture !!!
+
+ // ATTENTION UNIQUEMENT POUR MED < 2.2.x
+ int * tmp_constituentArray = NULL;
+
+ MESSAGE(LOC << "Med file version used here " << major << " " << minor << " " << release);
+
+ if ((major == 2) && (minor <= 1))
+ tmp_constituentArray = new int[(NumberOfNodeByEdge+1)*tmp_numberOfEdges] ;
+ else if ((major == 2) && (minor >= 2))
+ {
+ tmp_constituentArray = new int[NumberOfNodeByEdge*tmp_numberOfEdges] ;
+ MESSAGE(LOC<<": WE ARE USING MED2.2 so there is no +1 for calculating the size of tmp_constituentArray !") ;
+ }
+
+ int err=MEDconnLire(_medIdt,const_cast <char *> (_ptrMesh->_name.c_str()),
+ spaceDimension,tmp_constituentArray,
+ med_2_2::MED_FULL_INTERLACE,NULL,0,med_2_2::MED_MAILLE,med_type,med_2_2::MED_NOD);
+ if ( err != MED_VALID)
+ {
+ MESSAGE(LOC<<": MEDconnLire returns "<<err) ;
+ delete constituent ;
+ delete[] tmp_constituentArray;
+ delete[] tmpEdgeCount;
+ return MED_ERROR ;
+ }
+
+ int * constituentArray = NodalValue + NodalIndex[constituent->_count[i]-1]-1 ;
+
+ // version originale sans prise en compte des numéros optionnels
+ //
+ int multi = 0; // quand est-ce que multi vaut 1 ?? en MED-fichier < 2.2 ??
+ MESSAGE(LOC << "Med file version used here " << major << " " << minor << " " << release);
+
+ if ((major == 2) && (minor <= 1))
+ for (int j=0; j<tmp_numberOfEdges; j++)
+ for (int k=0; k<NumberOfNodeByEdge; k++)
+ constituentArray[j*NumberOfNodeByEdge+k]=tmp_constituentArray[j*(NumberOfNodeByEdge+multi)+k] ;
+ else if ((major == 2) && (minor >= 2))
+ for (int j=0; j<tmp_numberOfEdges; j++)
+ for (int k=0; k<NumberOfNodeByEdge; k++)
+ constituentArray[j*NumberOfNodeByEdge+k]=tmp_constituentArray[j*(NumberOfNodeByEdge)+k] ;
+
+ //////////////////////////////////////////////////////////////////////////////////////
+ /// Modification pour prise en compte de la numérotation optionnelle des noeuds ///
+ //////////////////////////////////////////////////////////////////////////////////////
+ ///
+ /// Rénumérote le tableau temporaire tmp_constituentArray en utilisant _optionnalToCanonicNodesNumbers
+ /// Le traitement est identique à la version originelle s'il n'y a pas de numérotation optionnelle
+
+ // if (_ptrMesh->_arePresentOptionnalNodesNumbers)
+ // {
+ // for (int j=0; j<tmp_numberOfEdges; j++) for (int k=0; k<NumberOfNodeByEdge; k++)
+ // constituentArray[j*NumberOfNodeByEdge+k]=_ptrMesh->_optionnalToCanonicNodesNumbers[tmp_constituentArray[j*(NumberOfNodeByEdge+1)+k]] ;
+ // }
+ // else
+ // {
+ // for (int j=0; j<tmp_numberOfEdges; j++) for (int k=0; k<NumberOfNodeByEdge; k++)
+ // constituentArray[j*NumberOfNodeByEdge+k]=tmp_constituentArray[j*(NumberOfNodeByEdge+1)+k] ;
+ // }
+
+ //////////////////////////////////////////////////////////////////////////////////////
+
+ delete[] tmp_constituentArray;
+ }
+
+ constituent->_nodal = new MEDSKYLINEARRAY(constituent->_count[constituent->_numberOfTypes]-1,
+ size,
+ NodalIndex,
+ NodalValue) ;
+
+ delete[] NodalIndex ;
+ delete[] NodalValue ;
+
+ if (Connectivity->_entityDimension == 3)
+ {
+ if (Connectivity->_constituent==NULL)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Edges are defined but there are no Faces !"));
+ Connectivity->_constituent->_constituent = constituent ;
+ } else
+ Connectivity->_constituent = constituent ;
+ }
+
+ delete[] tmpEdgeCount;
+
+
+ } // end classic geometric types
+ delete[] tmp_cells_count;
+
+
+
+ // Lecture des polygones MED_CELL
+ int NumberOfPolygons = MEDnEntMaa(_medIdt,
+ const_cast <char *> (_ptrMesh->_name.c_str()),
+ med_2_2::MED_CONN,
+ Entity,
+ med_2_2::MED_POLYGONE,
+ med_2_2::MED_NOD);
+ if (NumberOfPolygons > 0)
+ {
+ if (Connectivity->_entityDimension == 1)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"In a 2D mesh, polygons need at least one 2D cell of a classic geometric type !"));
+ med_int ConnectivitySize;
+ med_err err1 = MEDpolygoneInfo(_medIdt,
+ const_cast <char *> (_ptrMesh->_name.c_str()),
+ Entity,
+ med_2_2::MED_NOD,
+ &ConnectivitySize);
+ if (err1 != MED_VALID)
+ {
+ MESSAGE(LOC<<": MEDpolygoneInfo returns "<<err1);
+ return MED_ERROR;
+ }
+
+ med_int* PolygonsConnectivity = new med_int[ConnectivitySize];
+ med_int* PolygonsConnectivityIndex = new med_int[NumberOfPolygons+1];
+
+ med_err err2 = MEDpolygoneConnLire(_medIdt,
+ const_cast <char *> (_ptrMesh->_name.c_str()),
+ PolygonsConnectivityIndex,
+ NumberOfPolygons+1,
+ PolygonsConnectivity,
+ Entity,
+ med_2_2::MED_NOD);
+ if (err2 != MED_VALID)
+ {
+ MESSAGE(LOC<<": MEDpolygoneConnLire returns "<<err2);
+ return MED_ERROR;
+ }
+
+ if (Connectivity->_entityDimension == 2) // 2D mesh : polygons in Connectivity
+ Connectivity->setPolygonsConnectivity(MED_NODAL,(medEntityMesh) Entity,PolygonsConnectivity,PolygonsConnectivityIndex,ConnectivitySize,NumberOfPolygons);
+ else if (Connectivity->_entityDimension == 3)
+ {
+ if (Connectivity->_constituent == NULL) // 3D mesh : polygons in Connectivity->_constituent
+ Connectivity->_constituent = new CONNECTIVITY(MED_FACE);
+ Connectivity->_constituent->setPolygonsConnectivity(MED_NODAL,MED_FACE,PolygonsConnectivity,PolygonsConnectivityIndex,ConnectivitySize,NumberOfPolygons);
+ }
+
+ delete[] PolygonsConnectivity;
+ delete[] PolygonsConnectivityIndex;
+ } // end polygons
+
+
+
+ // Lecture des polyedres MED_CELL
+ med_int NumberOfPolyhedron = MEDnEntMaa(_medIdt,
+ const_cast <char *> (_ptrMesh->_name.c_str()),
+ med_2_2::MED_CONN,
+ Entity,
+ med_2_2::MED_POLYEDRE,
+ med_2_2::MED_NOD);
+ if (NumberOfPolyhedron > 0)
+ {
+ if (Connectivity->_entityDimension == 2 || Connectivity->_entityDimension == 1)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"In a 3D mesh, polyhedron need at least one 3D cell of a classic geometric type !"));
+ med_int FacesIndexSize, NumberOfNodes, NumberOfFaces;
+ med_err err3 = MEDpolyedreInfo(_medIdt,
+ const_cast <char *> (_ptrMesh->_name.c_str()),
+ med_2_2::MED_NOD,
+ &FacesIndexSize,
+ &NumberOfNodes);
+ NumberOfFaces = FacesIndexSize-1;
+ if (err3 != MED_VALID)
+ {
+ MESSAGE(LOC<<": MEDpolyhedreInfo returns "<<err3);
+ return MED_ERROR;
+ }
+
+ med_int* Nodes = new med_int[NumberOfNodes];
+ med_int* FacesIndex = new med_int[NumberOfFaces+1];
+ med_int* PolyhedronIndex = new med_int[NumberOfPolyhedron+1];
+
+ med_err err4 = MEDpolyedreConnLire(_medIdt,
+ const_cast <char *> (_ptrMesh->_name.c_str()),
+ PolyhedronIndex,
+ NumberOfPolyhedron+1,
+ FacesIndex,
+ NumberOfFaces+1,
+ Nodes,
+ med_2_2::MED_NOD);
+ if (err4 != MED_VALID)
+ {
+ MESSAGE(LOC<<": MEDpolyedreConnLire returns "<<err4);
+ return MED_ERROR;
+ }
+
+ Connectivity->setPolyhedronConnectivity(MED_NODAL,Nodes,PolyhedronIndex,NumberOfNodes,NumberOfPolyhedron,FacesIndex,NumberOfFaces);
+
+ delete[] Nodes;
+ delete[] FacesIndex;
+ delete[] PolyhedronIndex;
+ } // end polyhedron
+
+
+
+ // If there is no nodal connectivity, we return MED_ERROR !
+ if (Connectivity->_numberOfTypes == 0 && NumberOfPolygons == 0 && NumberOfPolyhedron == 0)
+ return MED_ERROR ;
+ else
+ return MED_VALID;
+
+ }
+}
+
+int MED_MESH_RDONLY_DRIVER22::getFAMILY()
+{
+ const char * LOC = "MED_MESH_RDONLY_DRIVER22::getFAMILY() : " ;
+ BEGIN_OF(LOC);
+
+ if (_status==MED_OPENED)
+ {
+ int err = 0 ;
+
+ int * MEDArrayNodeFamily = NULL ;
+ int ** MEDArrayCellFamily = NULL ;
+ int ** MEDArrayFaceFamily = NULL ;
+ int ** MEDArrayEdgeFamily = NULL ;
+
+ // NODE :
+ MEDArrayNodeFamily = new int[_ptrMesh->getNumberOfNodes()] ;
+
+ err = getNodesFamiliesNumber(MEDArrayNodeFamily) ;
+ // error only if (_status!=MED_OPENED), other case exeception !
+ // CELL
+
+ MESSAGE(LOC << "error returned from getNodesFamiliesNumber " << err);
+
+ MEDArrayCellFamily = new int* [_ptrMesh->getNumberOfTypesWithPoly(MED_CELL)] ;
+ // ET SI IL N'Y A PAS DE CELLS ?
+
+ medGeometryElement * myTypes = _ptrMesh->getTypesWithPoly(MED_CELL);
+ for (int i=0;i<_ptrMesh->getNumberOfTypesWithPoly(MED_CELL);i++)
+ MEDArrayCellFamily[i] = new
+ int[_ptrMesh->getNumberOfElementsWithPoly(MED_CELL,myTypes[i])] ;
+
+ err = getCellsFamiliesNumber(MEDArrayCellFamily,
+ _ptrMesh->_connectivity,MED_CELL) ;
+ delete [] myTypes;
+
+ MESSAGE(LOC << "error returned from getCellsFamiliesNumber for Cells " << err);
+
+ if (_ptrMesh->_connectivity->_constituent != NULL)
+ {
+ if (_ptrMesh->_connectivity->_constituent->_entity == MED_EN::MED_FACE)
+ {
+ // FACE
+ MEDArrayFaceFamily = new
+ int* [_ptrMesh->getNumberOfTypesWithPoly(MED_FACE)] ;
+
+ myTypes = _ptrMesh->getTypesWithPoly(MED_FACE);
+ for (int i=0;i<_ptrMesh->getNumberOfTypesWithPoly(MED_FACE);i++)
+ MEDArrayFaceFamily[i] = new
+ int[_ptrMesh->getNumberOfElementsWithPoly(MED_FACE,myTypes[i])] ;
+
+ err =
+ getCellsFamiliesNumber(MEDArrayFaceFamily,
+ _ptrMesh->_connectivity->_constituent,MED_FACE) ;
+ delete [] myTypes;
+ MESSAGE(LOC << "error returned from getCellsFamiliesNumber for Faces " << err);
+ }
+ else
+ {
+ // EDGE in 2D
+ MEDArrayEdgeFamily = new
+ int* [_ptrMesh->getNumberOfTypes(MED_EDGE)] ;
+
+ const medGeometryElement *myTypes2 = _ptrMesh->getTypes(MED_EDGE);
+ for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_EDGE);i++)
+ MEDArrayEdgeFamily[i] = new
+ int[_ptrMesh->getNumberOfElements(MED_EDGE,myTypes2[i])] ;
+
+ err =
+ getCellsFamiliesNumber(MEDArrayEdgeFamily,
+ _ptrMesh->_connectivity->_constituent,MED_FACE) ;
+
+ MESSAGE(LOC << "error returned from getCellsFamiliesNumber for Edges in 2D " << err);
+ }
+ // EDGE in 3D
+ if (_ptrMesh->_connectivity->_constituent->_constituent != NULL)
+ {
+ MEDArrayEdgeFamily = new
+ int* [_ptrMesh->getNumberOfTypes(MED_EDGE)] ;
+
+ const medGeometryElement *myTypes2 = _ptrMesh->getTypes(MED_EDGE);
+ for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_EDGE);i++)
+ MEDArrayEdgeFamily[i] = new
+ int[_ptrMesh->getNumberOfElements(MED_EDGE,myTypes2[i])] ;
+
+ err =
+ getCellsFamiliesNumber(MEDArrayEdgeFamily,
+ _ptrMesh->_connectivity->_constituent->_constituent,MED_EDGE);
+ // we are in 3D !
+
+ MESSAGE(LOC << "error returned from getCellsFamiliesNumber for Edges in 3D " << err);
+
+ }
+ }
+
+ int NumberOfFamilies = med_2_2::MEDnFam(_medIdt, const_cast <char *>
+ (_meshName.c_str())) ;
+
+ if ( NumberOfFamilies < 1 ) // at least family 0 must exist
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"There is no FAMILY, FAMILY 0 must exists" ));
+
+ SCRUTE(NumberOfFamilies);
+
+ vector<FAMILY*> &NodeFamilyVector = _ptrMesh->_familyNode ;
+ vector<FAMILY*> &CellFamilyVector = _ptrMesh->_familyCell ;
+ vector<FAMILY*> &FaceFamilyVector = _ptrMesh->_familyFace ;
+ vector<FAMILY*> &EdgeFamilyVector = _ptrMesh->_familyEdge ;
+
+ int numberOfNodesFamilies = 0 ;
+ int numberOfCellsFamilies = 0 ;
+ int numberOfFacesFamilies = 0 ;
+ int numberOfEdgesFamilies = 0 ;
+
+ for (int i=0;i<NumberOfFamilies;i++)
+ {
+ int NumberOfAttributes = med_2_2::MEDnAttribut(_medIdt,
+ const_cast <char *>
+ (_meshName.c_str()),
+ (i+1));
+
+ if (NumberOfAttributes < 0)
+ throw MEDEXCEPTION("MED_MESH_RDONLY_DRIVER22::getFAMILY() : NumberOfAttributes" );
+
+ int NumberOfGroups = med_2_2::MEDnGroupe(_medIdt, const_cast <char *>
+ (_meshName.c_str()),(i+1)) ;
+
+ if (NumberOfGroups < 0)
+ throw MEDEXCEPTION("MED_MESH_RDONLY_DRIVER22::getFAMILY() : NumberOfGroups" );
+
+ int FamilyIdentifier ;
+ string FamilyName(MED_TAILLE_NOM,'\0');
+ int * AttributesIdentifier = new int[NumberOfAttributes] ;
+ int * AttributesValues = new int[NumberOfAttributes] ;
+ string AttributesDescription(MED_TAILLE_DESC*NumberOfAttributes,' ') ;
+ string GroupsNames(MED_TAILLE_LNOM*NumberOfGroups+1,'\0') ;
+ err = med_2_2::MEDfamInfo(_medIdt,const_cast <char *>
+ (_meshName.c_str()),
+ (i+1),const_cast <char *>
+ (FamilyName.c_str()), &FamilyIdentifier,
+ AttributesIdentifier,AttributesValues,
+ const_cast <char *>
+ (AttributesDescription.c_str()),
+ &NumberOfAttributes, const_cast <char *>
+ (GroupsNames.c_str()),&NumberOfGroups);
+
+
+ SCRUTE(GroupsNames);
+ SCRUTE(FamilyName);
+ SCRUTE(err);
+ SCRUTE(i);
+
+ if (err != MED_VALID)
+ throw MEDEXCEPTION("MED_MESH_RDONLY_DRIVER22::getFAMILY() : ERROR when get FAMILY informations" );
+
+ if (FamilyIdentifier != 0 )
+ {
+ FAMILY * Family = new FAMILY(_ptrMesh,FamilyIdentifier,FamilyName,
+ NumberOfAttributes,
+ AttributesIdentifier,
+ AttributesValues,
+ AttributesDescription,
+ NumberOfGroups,GroupsNames,
+ MEDArrayNodeFamily,
+ MEDArrayCellFamily,
+ MEDArrayFaceFamily,
+ MEDArrayEdgeFamily) ;
+
+ // All good ?
+ // if nothing found, delete Family
+
+ if (Family->getNumberOfTypes() == 0)
+ {
+ MESSAGE(LOC<<"Nothing found for family "<<FamilyName<<
+ " : skip");
+ delete Family;
+ }
+ else
+ switch (Family->getEntity())
+ {
+ case MED_EN::MED_NODE :
+ NodeFamilyVector.push_back(Family) ;
+ numberOfNodesFamilies++ ;
+ break ;
+ case MED_EN::MED_CELL :
+ CellFamilyVector.push_back(Family) ;
+ numberOfCellsFamilies++ ;
+ break ;
+ case MED_EN::MED_FACE :
+ FaceFamilyVector.push_back(Family) ;
+ numberOfFacesFamilies++ ;
+ break ;
+ case MED_EN::MED_EDGE :
+ EdgeFamilyVector.push_back(Family) ;
+ numberOfEdgesFamilies++ ;
+ break ;
+ }
+ // MESSAGE(LOC << (*Family));
+ }
+
+ delete [] AttributesIdentifier ;
+ delete [] AttributesValues ;
+ }
+
+ if (MEDArrayNodeFamily != NULL)
+ delete[] MEDArrayNodeFamily ;
+
+ if (MEDArrayCellFamily != NULL)
+ {
+ for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_CELL);i++)
+ delete[] MEDArrayCellFamily[i] ;
+ delete[] MEDArrayCellFamily ;
+ }
+
+ if (MEDArrayFaceFamily != NULL)
+ {
+ for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_FACE);i++)
+ delete[] MEDArrayFaceFamily[i] ;
+ delete[] MEDArrayFaceFamily ;
+ }
+
+ if (MEDArrayEdgeFamily != NULL)
+ {
+ for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_EDGE);i++)
+ delete[] MEDArrayEdgeFamily[i] ;
+ delete[] MEDArrayEdgeFamily ;
+ }
+
+ END_OF(LOC);
+ return MED_VALID ;
+ }
+
+ return MED_ERROR;
+}
+
+int MED_MESH_RDONLY_DRIVER22::getNodesFamiliesNumber(int * MEDArrayNodeFamily)
+{
+ const char * LOC = "MED_MESH_RDONLY_DRIVER22::getNodesFamiliesNumber() : " ;
+
+ BEGIN_OF(LOC);
+
+ if (_status==MED_OPENED)
+ {
+ int err = 0 ;
+
+ err = MEDfamLire(_medIdt, const_cast <char *>
+ (_ptrMesh->_name.c_str()), MEDArrayNodeFamily,
+ _ptrMesh->getNumberOfNodes(), med_2_2::MED_NOEUD,
+ (med_2_2::med_geometrie_element) MED_NONE);
+
+ if ( err != MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "There is no family for the |"<< _ptrMesh->getNumberOfNodes() << "| nodes in mesh |" << _ptrMesh->_name.c_str() << "|"));
+
+ END_OF(LOC);
+ return MED_VALID;
+ }
+
+ return MED_ERROR;
+}
+
+int MED_MESH_RDONLY_DRIVER22::getCellsFamiliesNumber(int **MEDArrayFamily,
+ CONNECTIVITY *Connectivity,
+ MED_EN::medEntityMesh entity)
+{
+ const char * LOC = "MED_MESH_RDONLY_DRIVER22::getCellsFamiliesNumber " ;
+
+ BEGIN_OF(LOC);
+
+ if (_status==MED_OPENED)
+ {
+ int i, err = 0 ;
+ MED_EN::medGeometryElement *types=Connectivity->getGeometricTypesWithPoly(Connectivity->_entity);
+ for (i=0;i<Connectivity->getNumberOfTypesWithPoly(Connectivity->_entity);i++)
+ {
+ int NumberOfCell=Connectivity->getNumberOfElementsWithPoly(Connectivity->_entity,types[i]);
+ err=MEDfamLire(_medIdt,const_cast <char *> (_ptrMesh->_name.c_str()),
+ MEDArrayFamily[i],NumberOfCell,
+ (med_2_2::med_entite_maillage) Connectivity->_entity,
+ (med_2_2::med_geometrie_element)types[i]);
+ if (err != MED_VALID)
+ {
+ err=MEDfamLire(_medIdt,const_cast <char *>
+ (_ptrMesh->_name.c_str()),
+ MEDArrayFamily[i],NumberOfCell,
+ med_2_2::MED_MAILLE,
+ (med_2_2::med_geometrie_element)types[i]);
+ if (err != MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Family not found for entity "<<Connectivity->_entity<<" and geometric type "<<Connectivity->_geometricTypes[i]));
+ }
+ }
+ delete [] types;
+ return MED_VALID;
+ }
+ return MED_ERROR;
+}
+
+/*--------------------- WRONLY PART -------------------------------*/
+
+MED_MESH_WRONLY_DRIVER22::MED_MESH_WRONLY_DRIVER22()
+{
+}
+
+MED_MESH_WRONLY_DRIVER22::MED_MESH_WRONLY_DRIVER22(const string & fileName,
+ MESH * ptrMesh):
+ MED_MESH_DRIVER22(fileName,ptrMesh,MED_WRONLY),IMED_MESH_WRONLY_DRIVER(fileName,ptrMesh),MED_MESH_DRIVER(fileName,ptrMesh,MED_WRONLY)
+{
+ MESSAGE("MED_MESH_WRONLY_DRIVER22::MED_MESH_WRONLY_DRIVER22(const string & fileName, MESH * ptrMesh) has been created");
+}
+
+MED_MESH_WRONLY_DRIVER22::MED_MESH_WRONLY_DRIVER22(const MED_MESH_WRONLY_DRIVER22 & driver):
+ IMED_MESH_WRONLY_DRIVER(driver),MED_MESH_DRIVER22(driver),MED_MESH_DRIVER(driver)
+{
+}
+
+MED_MESH_WRONLY_DRIVER22::~MED_MESH_WRONLY_DRIVER22()
+{
+ //MESSAGE("MED_MESH_WRONLY_DRIVER22::MED_MESH_WRONLY_DRIVER22(const string & fileName, MESH * ptrMesh) has been destroyed");
+}
+
+GENDRIVER * MED_MESH_WRONLY_DRIVER22::copy(void) const
+{
+ return new MED_MESH_WRONLY_DRIVER22(*this);
+}
+
+void MED_MESH_WRONLY_DRIVER22::write(void) const
+{
+ const char * LOC = "void MED_MESH_WRONLY_DRIVER22::write(void) const : ";
+ BEGIN_OF(LOC);
+
+ // we must first create mesh !!
+ MESSAGE(LOC << "MeshName : |" << _meshName << "| FileName : |"<<_fileName<<"| MedIdt : | "<< _medIdt << "|");
+
+ if (_status!=MED_OPENED)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "File "<<_fileName<<" is not open. Open it before write !"));
+
+ if (_ptrMesh->getIsAGrid())
+ {
+ if ( writeGRID() != MED_VALID )
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeGRID()" )) ;
+ }
+ else
+ {
+ if (writeCoordinates()!=MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeCoordinates()" )) ;
+
+ if (writeConnectivities(MED_EN::MED_CELL)!=MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeConnectivities(MED_CELL)" )) ;
+ if (writeConnectivities(MED_EN::MED_FACE)!=MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeConnectivities(MED_FACE)" )) ;
+ if (writeConnectivities(MED_EN::MED_EDGE)!=MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeConnectivities(MED_EDGE)" )) ;
+ }
+
+ if (writeFamilyNumbers() !=MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeFamilyNumbers()" )) ;
+
+
+ // well we must first write zero family :
+ if (_status==MED_OPENED) {
+ int err ;
+ // test if the family already exists (HDF trick waiting a MED evolution to be replaced)
+ string dataGroupFam = "/ENS_MAA/"+_meshName+"/FAS/FAMILLE_ZERO/";
+ MESSAGE("|"<<dataGroupFam<<"|");
+ err =med_2_2::_MEDdatagroupOuvrir(_medIdt,const_cast <char *> (dataGroupFam.c_str()) );
+ if ( err < MED_VALID ) {
+ SCRUTE(err);
+
+ char familyName[MED_TAILLE_NOM+1];
+ // strcpy(familyName,"FAMILLE_ZERO");
+ err = med_2_2::MEDfamCr( _medIdt,
+ const_cast <char *> ( _meshName.c_str() ),
+ familyName, 0,
+ (int*)NULL, (int*)NULL, (char*)NULL, 0,
+ (char*)NULL, 0);
+
+ SCRUTE(familyName);
+
+ if ( err != MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't create family |FAMILLE_ZERO| with identifier |0| groups names || and attributes descriptions ||")) ;
+ }
+ else
+ med_2_2::_MEDdatagroupFermer(_medIdt);
+
+ }
+
+ MESSAGE(LOC<<"writeFamilies(_ptrMesh->_familyNode)");
+ if (writeFamilies(_ptrMesh->_familyNode) !=MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeFamilies(_ptrMesh->_familyNode)" )) ;
+
+ MESSAGE(LOC<<"writeFamilies(_ptrMesh->_familyCell)");
+ if (writeFamilies(_ptrMesh->_familyCell) !=MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeFamilies(_ptrMesh->_familyCell)" )) ;
+
+ MESSAGE(LOC<<"writeFamilies(_ptrMesh->_familyFace)");
+ if (writeFamilies(_ptrMesh->_familyFace) !=MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeFamilies(_ptrMesh->_familyFace)" )) ;
+
+ MESSAGE(LOC<<"writeFamilies(_ptrMesh->_familyEdge)");
+ if (writeFamilies(_ptrMesh->_familyEdge) !=MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeFamilies(_ptrMesh->_familyEdge)" )) ;
+
+ END_OF(LOC);
+}
+
+//=======================================================================
+//function : writeGRID
+//purpose :
+//=======================================================================
+
+int MED_MESH_WRONLY_DRIVER22::writeGRID() const
+{
+ const char * LOC = "MED_MESH_WRONLY_DRIVER22::writeGRID() : " ;
+ BEGIN_OF(LOC);
+
+ if (_status!=MED_OPENED)
+ {
+ MESSAGE (LOC<<" Not open !!!");
+ return MED_ERROR;
+ }
+ GRID * ptrGrid = (GRID*) _ptrMesh;
+
+ med_2_2::med_err err = MED_ERROR;
+ med_2_2::med_repere rep;
+ string tmp_name(_ptrMesh->_spaceDimension*MED_TAILLE_PNOM22,' ');
+ string tmp_unit(_ptrMesh->_spaceDimension*MED_TAILLE_PNOM22,' ');
+
+ // Test if the mesh <_meshName> already exists
+ // If it doesn't exists create it
+ // If it already exists verify if its space and mesh dimensions are the same
+ // as <_ptrMesh->_spaceDimension>, <_ptrMesh->_meshDimension> respectively
+ // rem : <_meshName> is the driver meshName not <ptrMesh->_meshName>
+
+ int spaceDimension = med_2_2::MEDdimEspaceLire(_medIdt, const_cast <char *>
+ (_meshName.c_str()) );
+
+ int meshDimension = med_2_2::MEDdimLire(_medIdt, const_cast <char *>
+ (_meshName.c_str()) );
+
+
+ MESSAGE(LOC << "spacedim " << spaceDimension << " meshdim " << meshDimension);
+
+ MESSAGE(LOC << "From the mesh spacedim " << _ptrMesh->_spaceDimension << " meshdim " << _ptrMesh->_meshDimension);
+
+ if ((spaceDimension <= MED_VALID) && (meshDimension <= MED_VALID))
+ {
+ err = MEDmaaCr(_medIdt,
+ const_cast <char *> (_meshName.c_str()),
+ _ptrMesh->_meshDimension,med_2_2::MED_STRUCTURE,
+ const_cast <char *> (_ptrMesh->_description.c_str()));
+
+ meshDimension = _ptrMesh->_meshDimension;
+
+ if (err != MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Unable to create Grid"));
+ else
+ MESSAGE(LOC<<"Grid "<<_meshName<<" created in file "<<_fileName<<" !");
+ }
+ else if ((spaceDimension != _ptrMesh->_spaceDimension) &&
+ (meshDimension != _ptrMesh->_meshDimension))
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Grid |" << _meshName.c_str() <<
+ "| already exists in file |" << _fileName <<
+ "| with space dimension |" << spaceDimension <<
+ "| and mesh dimension |" << meshDimension <<
+ "| but the space dimension and the mesh dimension of the mesh we want to write are respectively |"
+ << _ptrMesh->_spaceDimension <<"|" <<
+ _ptrMesh->_meshDimension <<"|" )) ;
+
+ MED_EN::med_grid_type gridType = ptrGrid->getGridType();
+
+ err = med_2_2::MEDnatureGrilleEcr(_medIdt,
+ const_cast <char *> (_meshName.c_str()),
+ (med_2_2::med_type_grille) gridType);
+
+ if (err != MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Unable to write the type of the Grid"));
+
+ // Recompose the <_spaceDimension> strings in 1 string
+ int lengthString ;
+ string valueString ;
+ for (int i=0;i<_ptrMesh->_spaceDimension;i++) {
+ SCRUTE(i);
+ valueString = _ptrMesh->_coordinate->_coordinateName[i] ;
+ lengthString = (MED_TAILLE_PNOM22<valueString.size())?MED_TAILLE_PNOM22:valueString.size() ;
+ tmp_name.replace(i*MED_TAILLE_PNOM22,i*MED_TAILLE_PNOM22+lengthString,valueString,0,lengthString);
+ valueString = _ptrMesh->_coordinate->_coordinateUnit[i];
+ lengthString = (MED_TAILLE_PNOM22<valueString.size())?MED_TAILLE_PNOM22:valueString.size() ;
+ tmp_unit.replace(i*MED_TAILLE_PNOM22,i*MED_TAILLE_PNOM22+lengthString,valueString,0,lengthString);
+ }
+
+ // Pourquoi le stocker sous forme de chaîne ?
+ const string & coordinateSystem = _ptrMesh->_coordinate->_coordinateSystem;
+ if (coordinateSystem == "CARTESIAN")
+ rep = med_2_2::MED_CART;
+ else if ( coordinateSystem == "CYLINDRICAL")
+ rep = med_2_2::MED_CYL;
+ else if ( coordinateSystem == "SPHERICAL" )
+ rep = med_2_2::MED_SPHER;
+ else
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Grid |" << _meshName.c_str() <<
+ "| doesn't have a valid coordinate system : |"
+ << _ptrMesh->_coordinate->_coordinateSystem
+ << "|" )) ;
+
+ med_2_2::med_int ArrayLen[] = { (med_2_2::med_int) ptrGrid->_iArrayLength,
+ (med_2_2::med_int) ptrGrid->_jArrayLength,
+ (med_2_2::med_int) ptrGrid->_kArrayLength };
+
+ // Write node coordinates for MED_BODY_FITTED grid
+ if (gridType == MED_EN::MED_BODY_FITTED)
+ {
+ // Write Coordinates and families
+// double * coo = const_cast <double *>
+// (_ptrMesh->_coordinate->getCoordinates(MED_EN::MED_FULL_INTERLACE));
+
+ err = MEDcoordEcr(_medIdt, const_cast <char *> (_meshName.c_str()),
+ _ptrMesh->_spaceDimension,
+ //const_cast <double *> ( _ptrMesh->_coordinate->_coordinate->get(MED_EN::MED_FULL_INTERLACE) ),
+ const_cast <double *> ( _ptrMesh->_coordinate->_coordinate.get(MED_EN::MED_FULL_INTERLACE) ),
+ med_2_2::MED_FULL_INTERLACE, _ptrMesh->_numberOfNodes,
+ // _ptrMesh->_coordinate->_numberOfNodes
+ rep, const_cast <char *> (tmp_name.c_str()),
+ const_cast <char *> (tmp_unit.c_str()));
+
+ if (err != MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write coordinates of the grid |" << _meshName.c_str() << "| in file |" << _fileName
+ << "| with dimension |" << _ptrMesh->_spaceDimension <<"| and"
+ << " with units names |" << tmp_name
+ << "| and units |" << tmp_unit
+ << " |")) ;
+
+ int* structure = new int [meshDimension];
+
+ for (int idim = 0; idim < meshDimension; ++idim)
+ structure[idim] = ArrayLen [idim];
+
+
+ err = med_2_2::MEDstructureCoordEcr(_medIdt, const_cast <char *>
+ (_meshName.c_str()), meshDimension,
+ structure);
+
+ if (err != MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"error in writing the structure of the grid |" << _meshName.c_str()));
+
+ delete structure;
+ }
+ else if ((gridType == MED_EN::MED_CARTESIAN) ||
+ (gridType == MED_EN::MED_POLAR))
+ {
+ // Write Arrays of Cartesian or Polar Grid
+
+ double * Array[] = { ptrGrid->_iArray,
+ ptrGrid->_jArray,
+ ptrGrid->_kArray };
+
+ for (int idim = 0; idim < _ptrMesh->_meshDimension; ++idim)
+ {
+ string str_name = string (tmp_name,idim*MED_TAILLE_PNOM22,
+ MED_TAILLE_PNOM22);
+ string str_unit = string (tmp_unit,idim*MED_TAILLE_PNOM22,
+ MED_TAILLE_PNOM22);
+
+ err = med_2_2::MEDindicesCoordEcr(_medIdt, const_cast <char *>
+ (_ptrMesh->_name.c_str()),
+ _ptrMesh->_meshDimension,
+ Array[idim], ArrayLen[idim],
+ (idim+1), const_cast <char *>
+ (str_name.c_str()),
+ const_cast <char *>
+ (str_unit.c_str()));
+
+ if (err != MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<
+ "Can't write grid coordinates for " <<
+ idim << "-th dimention"));
+ }
+ } // end Write Cartesian or Polar Grid
+
+ END_OF(LOC);
+ return MED_VALID;
+}
+
+//=======================================================================
+//function : writeCoordinates
+//purpose :
+//=======================================================================
+
+int MED_MESH_WRONLY_DRIVER22::writeCoordinates() const {
+
+ const char * LOC = "int MED_MESH_WRONLY_DRIVER22::writeCoordinates() const : ";
+ BEGIN_OF(LOC);
+
+ med_2_2::med_err err = MED_ERROR;
+ med_2_2::med_repere rep;
+ string tmp_name(_ptrMesh->_spaceDimension*MED_TAILLE_PNOM22,' ');
+ string tmp_unit(_ptrMesh->_spaceDimension*MED_TAILLE_PNOM22,' ');
+
+ // Recompose the <_spaceDimension> strings in 1 string
+ int lengthString ;
+ string valueString ;
+ for (int i=0;i<_ptrMesh->_spaceDimension;i++) {
+ valueString = _ptrMesh->_coordinate->_coordinateName[i] ;
+ lengthString = (MED_TAILLE_PNOM22<valueString.size())?MED_TAILLE_PNOM22:valueString.size() ;
+ tmp_name.replace(i*MED_TAILLE_PNOM22,i*MED_TAILLE_PNOM22+lengthString,valueString,0,lengthString);
+ valueString = _ptrMesh->_coordinate->_coordinateUnit[i];
+ lengthString = (MED_TAILLE_PNOM22<valueString.size())?MED_TAILLE_PNOM22:valueString.size() ;
+ tmp_unit.replace(i*MED_TAILLE_PNOM22,i*MED_TAILLE_PNOM22+lengthString,valueString,0,lengthString);
+ }
+
+ // Test if the mesh <_meshName> already exists
+ // If it doesn't exists create it
+ // If it already exists verify if its space and mesh dimensions are the same
+ // as <_ptrMesh->_spaceDimension>, <_ptrMesh->_meshDimension> respectively
+ // rem : <_meshName> is the driver meshName not <ptrMesh->_meshName>
+
+ int spaceDimension = med_2_2::MEDdimEspaceLire(_medIdt, const_cast <char *>
+ (_meshName.c_str()));
+
+ int meshDimension = med_2_2::MEDdimLire(_medIdt, const_cast <char *>
+ (_meshName.c_str()) );
+
+ if ((spaceDimension != MED_VALID) && (meshDimension != MED_VALID))
+ {
+ err = MEDmaaCr(_medIdt, const_cast <char *> (_meshName.c_str()),
+ _ptrMesh->_meshDimension, med_2_2::MED_NON_STRUCTURE,
+ const_cast <char *> (_ptrMesh->_description.c_str()));
+
+ if (err != MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Unable to create Mesh : |" << _meshName << "|"));
+ else
+ MESSAGE(LOC<<"Mesh "<<_meshName<<" created in file "<<_fileName<<" !");
+ }
+ else if ((spaceDimension != _ptrMesh->_spaceDimension) &&
+ (meshDimension != _ptrMesh->_meshDimension))
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Mesh |" << _meshName.c_str() <<
+ "| already exists in file |" << _fileName <<
+ "| with space dimension |" << spaceDimension <<
+ "| and mesh dimension |" << meshDimension <<
+ "| but the space dimension and the mesh dimension of the mesh we want to write are respectively |"
+ << _ptrMesh->_spaceDimension <<"|" <<
+ _ptrMesh->_meshDimension << "|")) ;
+
+ // Pourquoi le stocker sous forme de chaîne ?
+ const string & coordinateSystem = _ptrMesh->_coordinate->_coordinateSystem;
+ if (coordinateSystem == "CARTESIAN")
+ rep = med_2_2::MED_CART;
+ else if ( coordinateSystem == "CYLINDRICAL")
+ rep = med_2_2::MED_CYL;
+ else if ( coordinateSystem == "SPHERICAL" )
+ rep = med_2_2::MED_SPHER;
+ else
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Mesh |" << _meshName.c_str() << "| doesn't have a valid coordinate system : |"
+ << _ptrMesh->_coordinate->_coordinateSystem
+ << "|" )) ;
+
+// err = MEDcoordEcr(_medIdt, const_cast <char *> (_meshName.c_str()),
+// _ptrMesh->_spaceDimension,
+// //const_cast <double *> ( _ptrMesh->_coordinate->_coordinate->get(MED_EN::MED_FULL_INTERLACE) ),
+// const_cast <double *> ( _ptrMesh->_coordinate->_coordinate.get(MED_EN::MED_FULL_INTERLACE) ),
+// MED_FR::MED_FULL_INTERLACE,
+// _ptrMesh->_numberOfNodes, // _ptrMesh->_coordinate->_numberOfNodes
+// MED_FR::MED_LECTURE_ECRITURE,
+// rep,
+// const_cast <char *> (tmp_name.c_str()),
+// const_cast <char *> (tmp_unit.c_str())
+// );
+
+ err = MEDcoordEcr(_medIdt, const_cast <char *> (_meshName.c_str()),
+ _ptrMesh->_spaceDimension,
+ //const_cast <double *> ( _ptrMesh->_coordinate->_coordinate->get(MED_EN::MED_FULL_INTERLACE) ),
+ const_cast <double *> ( _ptrMesh->_coordinate->_coordinate.get(MED_EN::MED_FULL_INTERLACE) ),
+ med_2_2::MED_FULL_INTERLACE, _ptrMesh->_numberOfNodes,
+ // _ptrMesh->_coordinate->_numberOfNodes
+ rep, const_cast <char *> (tmp_name.c_str()),
+ const_cast <char *> (tmp_unit.c_str()));
+
+ if (err<0)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write coordinates of mesh |" << _meshName.c_str() << "| in file |" << _fileName
+ << "| with dimension |" << _ptrMesh->_spaceDimension <<"| and"
+ << " with units names |" << tmp_name
+ << "| and units |" << tmp_unit
+ << " |")) ;
+
+
+ //////////////////////////////////////////////////////////////////////////////////////
+ /// Modification pour prise en compte de la numérotation optionnelle des noeuds ///
+ //////////////////////////////////////////////////////////////////////////////////////
+ ///
+ /// Ecrit les numéros optionnels des noeuds
+ /// Le traitement est identique à la version originelle s'il n'y a pas de numérotation optionnelle
+
+
+ if (_ptrMesh->_arePresentOptionnalNodesNumbers==1) {
+
+ err = MEDnumEcr(_medIdt, const_cast <char *> (_meshName.c_str()),
+ const_cast <med_int *> (_ptrMesh->_coordinate->getNodesNumbers() ),
+ _ptrMesh->_numberOfNodes, med_2_2::MED_NOEUD,
+ med_2_2::med_geometrie_element(0) );
+
+ if (err != MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write optionnal numbers of mesh |" <<
+ _meshName.c_str() << "| in file |" <<
+ _fileName << " |")) ;
+ }
+ //////////////////////////////////////////////////////////////////////////////////////
+
+ END_OF(LOC);
+
+ return MED_VALID;
+}
+
+
+
+
+int MED_MESH_WRONLY_DRIVER22::writeConnectivities(medEntityMesh entity) const
+{
+ const char * LOC="int MED_MESH_WRONLY_DRIVER22::writeConnectivities() const : ";
+ BEGIN_OF(LOC);
+
+ med_2_2::med_err err;
+
+ // REM SI LA METHODE EST APPELEE DIRECTEMENT ET QUE LE MAILLAGE N'EST PAS CREE IL Y A PB !
+ // PG : IMPOSSIBLE : LA METHODE EST PRIVEE !
+
+ // A FAIRE : A tester surtout dans les methodes de MESH.
+ // if ( _ptrMesh->_connectivity == (CONNECTIVITY *) MED_INVALID )
+ if ( _ptrMesh->_connectivity == (CONNECTIVITY *) NULL )
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "The connectivity is not defined in the MESH object ")) ;
+
+
+ // Nodal connectivity for classic geometric types
+ if ( _ptrMesh->existConnectivity(MED_NODAL,entity) )
+ {
+
+ int numberOfTypes = _ptrMesh->getNumberOfTypes (entity) ;
+ const medGeometryElement * types = _ptrMesh->getTypes (entity) ;
+
+ for (int i=0; i<numberOfTypes; i++)
+ {
+
+ int numberOfElements = _ptrMesh->getNumberOfElements (entity,types[i]);
+ const int * connectivity = _ptrMesh->getConnectivity (MED_EN::MED_FULL_INTERLACE,
+ MED_NODAL, entity, types[i]); // ?? et SI MED_NODAL n'existe pas, recalcul auto ??
+
+ // Pour l'instant la class utilise le multi.....
+ int multi = 0 ;
+ // if (entity==MED_EN::MED_CELL)
+ // if ( (types[i]/ 100) < _ptrMesh->_spaceDimension)
+ // multi=1 ;
+ int numberOfNodes = types[i]%100 ;
+ int * connectivityArray = new int[numberOfElements*(numberOfNodes+multi)];
+
+ // version originale sans prise en compte des numéros optionnels
+ //
+ for (int j=0 ; j<numberOfElements; j++)
+ {
+ for (int k=0; k<numberOfNodes; k++)
+ connectivityArray[j*(numberOfNodes+multi)+k]=connectivity[j*numberOfNodes+k] ;
+
+ if (multi>0) connectivityArray[j*(numberOfNodes+multi)+numberOfNodes]=0;
+ }
+
+ //////////////////////////////////////////////////////////////////////////////////////
+ /// Modification pour prise en compte de la numérotation optionnelle des noeuds ///
+ //////////////////////////////////////////////////////////////////////////////////////
+ ///
+ /// Dénumérote les sommets des mailles pour leur rendre leurs numéros optionnels
+ /// Le traitement est identique à la version originelle s'il n'y a pas de numérotation optionnelle
+
+ // if (_ptrMesh->_arePresentOptionnalNodesNumbers==1)
+ // {
+ // const int * nodesNumbers = _ptrMesh->_coordinate->getNodesNumbers();
+ // for (int j=0 ; j<numberOfElements; j++)
+ // {
+ // for (int k=0; k<numberOfNodes; k++) connectivityArray[j*(numberOfNodes+multi)+k]=nodesNumbers[connectivity[j*numberOfNodes+k]-1] ;
+ // if (multi>0) connectivityArray[j*(numberOfNodes+multi)+numberOfNodes]=0;
+ // }
+ // }
+ // else
+ // {
+ // for (int j=0 ; j<numberOfElements; j++)
+ // {
+ // for (int k=0; k<numberOfNodes; k++) connectivityArray[j*(numberOfNodes+multi)+k]=connectivity[j*numberOfNodes+k] ;
+ // if (multi>0) connectivityArray[j*(numberOfNodes+multi)+numberOfNodes]=0;
+ // }
+ // }
+
+ //////////////////////////////////////////////////////////////////////////////////////
+
+ // err = MEDconnEcr( _medIdt, const_cast <char *> ( _meshName.c_str()), _ptrMesh->_spaceDimension,
+ // connectivityArray, MED_FR::MED_FULL_INTERLACE , numberOfElements,
+ // MED_FR::MED_LECTURE_ECRITURE,
+ // (MED_FR::med_entite_maillage ) entity,
+ // (MED_FR::med_geometrie_element) types[i], MED_FR::MED_NOD );
+
+ // err = MEDconnEcr(_medIdt, const_cast <char *> ( _meshName.c_str()),
+ // _ptrMesh->_spaceDimension, connectivityArray,
+ // MED_FR::MED_FULL_INTERLACE , numberOfElements,
+ // (MED_FR::med_entite_maillage ) entity,
+ // (MED_FR::med_geometrie_element) types[i],
+ // med_2_2::MED_NOD);
+
+ err = MEDconnEcr(_medIdt, const_cast <char *> ( _meshName.c_str()),
+ _ptrMesh->_spaceDimension, connectivityArray,
+ med_2_2::MED_FULL_INTERLACE , numberOfElements,
+ (med_2_2::med_entite_maillage ) MED_CELL,
+ (med_2_2::med_geometrie_element) types[i],
+ med_2_2::MED_NOD);
+
+ delete[] connectivityArray ;
+
+ if (err<0) // ETENDRE LES EXPLICATIONS
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write connectivities of mesh |" << _meshName.c_str() << "| in file |" << _fileName
+ << "| with dimension |" << _ptrMesh->_spaceDimension <<"| and"
+ ));
+ }
+
+ }
+
+
+ // Polygons writing
+ if (_ptrMesh->existPolygonsConnectivity(MED_NODAL,entity))
+ {
+ err = MEDpolygoneConnEcr(_medIdt,
+ const_cast <char *> (_meshName.c_str()),
+ const_cast <med_int*> (_ptrMesh->getPolygonsConnectivityIndex(MED_NODAL,entity)),
+ _ptrMesh->getNumberOfPolygons()+1,
+ const_cast <med_int*> (_ptrMesh->getPolygonsConnectivity(MED_NODAL,entity)),
+ (med_2_2::med_entite_maillage) entity,
+ med_2_2::MED_NOD);
+
+ if (err<0)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write polygons nodal connectivities of mesh |" << _meshName.c_str() << "| in file |" << _fileName
+ << "| with dimension |" << _ptrMesh->_spaceDimension <<"| and"
+ ));
+ }
+
+
+ // Polyhedron writing
+ if (_ptrMesh->existPolyhedronConnectivity(MED_NODAL,entity))
+ {
+ err = MEDpolyedreConnEcr(_medIdt,
+ const_cast <char *> (_meshName.c_str()),
+ const_cast <med_int*> (_ptrMesh->getPolyhedronIndex(MED_NODAL)),
+ _ptrMesh->getNumberOfPolyhedron()+1,
+ const_cast <med_int*> (_ptrMesh->getPolyhedronFacesIndex()),
+ _ptrMesh->getNumberOfPolyhedronFaces()+1,
+ const_cast <med_int*> (_ptrMesh->getPolyhedronConnectivity(MED_NODAL)),
+ med_2_2::MED_NOD);
+
+ if (err<0)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write polyhedron nodal connectivities of mesh |" << _meshName.c_str() << "| in file |" << _fileName
+ << "| with dimension |" << _ptrMesh->_spaceDimension <<"| and"
+ ));
+ }
+
+
+ // Descending connectivity for classic geometric types
+ if ( _ptrMesh->existConnectivity(MED_DESCENDING,entity) )
+ {
+
+ int numberOfTypes = _ptrMesh->getNumberOfTypes (entity) ;
+ const medGeometryElement * types = _ptrMesh->getTypes (entity) ;
+
+ for (int i=0; i<numberOfTypes; i++)
+ {
+
+ int numberOfElements = _ptrMesh->getNumberOfElements (entity,types[i]);
+ const int * connectivity = _ptrMesh->getConnectivity(MED_EN::MED_FULL_INTERLACE, MED_DESCENDING, entity, types[i]);
+
+ // Pour l'instant la class utilise le multi.....
+ // err = MED_FR::MEDconnEcr( _medIdt,
+ // const_cast <char *> ( _meshName.c_str()),
+ // _ptrMesh->_spaceDimension,
+ // const_cast <int *> (connectivity),
+ // MED_FR::MED_FULL_INTERLACE,
+ // numberOfElements,
+ // MED_FR::MED_LECTURE_ECRITURE,
+ // (MED_FR::med_entite_maillage ) entity,
+ // (MED_FR::med_geometrie_element) types[i],
+ // MED_FR::MED_DESC );
+
+ err = med_2_2::MEDconnEcr(_medIdt,
+ const_cast <char *> ( _meshName.c_str()),
+ _ptrMesh->_spaceDimension,
+ const_cast <int *> (connectivity),
+ med_2_2::MED_FULL_INTERLACE,
+ numberOfElements,
+ (med_2_2::med_entite_maillage ) entity,
+ (med_2_2::med_geometrie_element) types[i],
+ med_2_2::MED_DESC );
+
+ if (err<0) // ETENDRE LES EXPLICATIONS
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write connectivities of mesh |" << _meshName.c_str() << "| in file |" << _fileName
+ << "| with dimension |" << _ptrMesh->_spaceDimension <<"| and"
+ )) ;
+
+ }
+ }
+
+
+ // Polygons writing
+ if (_ptrMesh->existPolygonsConnectivity(MED_DESCENDING,entity))
+ {
+ err = MEDpolygoneConnEcr(_medIdt,
+ const_cast <char *> (_meshName.c_str()),
+ const_cast <med_int*> (_ptrMesh->getPolygonsConnectivityIndex(MED_DESCENDING,entity)),
+ _ptrMesh->getNumberOfPolygons()+1,
+ const_cast <med_int*> (_ptrMesh->getPolygonsConnectivity(MED_DESCENDING,entity)),
+ (med_2_2::med_entite_maillage) entity,
+ med_2_2::MED_DESC);
+
+ if (err<0)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write polygons descending connectivities of mesh |" << _meshName.c_str() << "| in file |" << _fileName
+ << "| with dimension |" << _ptrMesh->_spaceDimension <<"| and"
+ ));
+ }
+
+
+ // Polyhedron writing
+ if (_ptrMesh->existPolyhedronConnectivity(MED_DESCENDING,entity))
+ {
+ med_int NumberOfFaces = _ptrMesh->getPolyhedronIndex(MED_DESCENDING)[_ptrMesh->getNumberOfPolyhedron()]-1;
+ vector<med_int> FacesGeometricTypes(NumberOfFaces,MED_POLYGON); // by default all polyhedron faces are polygons
+
+ err = MEDpolyedreConnEcr(_medIdt,
+ const_cast <char *> (_meshName.c_str()),
+ const_cast <med_int*> (_ptrMesh->getPolyhedronIndex(MED_DESCENDING)),
+ _ptrMesh->getNumberOfPolyhedron()+1,
+ &FacesGeometricTypes[0],
+ NumberOfFaces,
+ const_cast <med_int*> (_ptrMesh->getPolyhedronConnectivity(MED_DESCENDING)),
+ med_2_2::MED_DESC);
+
+ if (err<0)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write polyhedron descending connectivities of mesh |" << _meshName.c_str() << "| in file |" << _fileName
+ << "| with dimension |" << _ptrMesh->_spaceDimension <<"| and"
+ ));
+ }
+
+
+ END_OF(LOC);
+ return MED_VALID;
+}
+
+int MED_MESH_WRONLY_DRIVER22::writeFamilyNumbers() const {
+
+ const char * LOC="int MED_MESH_WRONLY_DRIVER22::writeFamilyNumbers() const : ";
+ BEGIN_OF(LOC);
+
+ med_2_2::med_err err;
+
+ // SOLUTION TEMPORAIRE CAR _ptrMesh->_MEDArrayNodeFamily DOIT ETRE ENLEVER DE LA CLASSE MESH
+
+ { // Node related block
+
+ // We build the array from the families list objects :
+ int NumberOfNodes = _ptrMesh->getNumberOfNodes() ;
+ int * MEDArrayNodeFamily = new int[NumberOfNodes] ;
+ // family 0 by default
+ for (int i=0; i<NumberOfNodes; i++)
+ MEDArrayNodeFamily[i]=0;
+ //vector<FAMILY*> myFamilies = _ptrMesh->getFamilies(MED_NODE);
+ vector<FAMILY*> * myFamilies = &_ptrMesh->_familyNode;
+ int NumberOfNodesFamilies = myFamilies->size() ;
+ //bool ToDestroy = false;
+ if (0 == NumberOfNodesFamilies) {
+ //ToDestroy = true ;
+ vector<GROUP*> myGroups = _ptrMesh->getGroups(MED_NODE);
+ int NumberOfGroups = myGroups.size() ;
+ // build families from groups
+ for (int i=0; i<NumberOfGroups; i++) {
+ SUPPORT * mySupport = myGroups[i] ;
+ FAMILY* myFamily = new FAMILY(*mySupport);
+ myFamily->setIdentifier(i+1);
+ myFamilies->push_back(myFamily);
+ }
+ NumberOfNodesFamilies=myFamilies->size() ;
+ }
+ for (int i=0 ; i<NumberOfNodesFamilies; i++) {
+ //SCRUTE(i);
+ //SCRUTE(myFamilies[i]->getName());
+ int FamilyIdentifier = (*myFamilies)[i]->getIdentifier() ;
+ int TotalNumber = (*myFamilies)[i]->getNumberOfElements(MED_ALL_ELEMENTS) ;
+ if ((*myFamilies)[i]->isOnAllElements())
+ for (int j=0; j<TotalNumber; j++)
+ MEDArrayNodeFamily[j]=FamilyIdentifier;
+ else {
+ const int * Number = (*myFamilies)[i]->getNumber(MED_ALL_ELEMENTS) ;
+ for (int j=0; j<TotalNumber; j++)
+ MEDArrayNodeFamily[Number[j]-1]=FamilyIdentifier ;
+ }
+ }
+
+ for(int j=0; j<NumberOfNodes; j++) {
+ SCRUTE(MEDArrayNodeFamily[j]);
+ }
+
+// if ( !_ptrMesh->getIsAGrid() )
+
+ err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
+ MEDArrayNodeFamily, NumberOfNodes, med_2_2::MED_NOEUD,
+ (med_2_2::med_geometrie_element) MED_NONE);
+
+// else
+// err = MEDfamGridEcr(_medIdt,
+// const_cast <char *> (_ptrMesh->_name.c_str()),
+// MEDArrayNodeFamily,
+// NumberOfNodes,
+// MED_FR::MED_LECTURE_ECRITURE,
+// MED_FR::MED_NOEUD);
+
+ if ( err != MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't write node family for the |"<< NumberOfNodes
+ << "| nodes in mesh |"
+ << _ptrMesh->_name.c_str() << "|" ));
+ delete[] MEDArrayNodeFamily;
+ //if (true == ToDestroy)
+ // for (int i=0; i<NumberOfNodesFamilies; i++)
+ // delete myFamilies[i];
+ }
+
+ { // CELLS RELATED BLOCK
+ medEntityMesh entity=MED_EN::MED_CELL;
+ // SOLUTION TEMPORAIRE CAR _ptrMesh->_MEDArray____Family DOIT ETRE ENLEVER DE LA CLASSE MESH
+ if ( ( _ptrMesh->existConnectivity(MED_NODAL,entity) )|( _ptrMesh->existConnectivity(MED_DESCENDING,entity) ) ) {
+
+ int numberOfTypes = _ptrMesh->getNumberOfTypes (entity) ;
+ const medGeometryElement * types = _ptrMesh->getTypes (entity) ;
+
+ // We build the array from the families list objects :
+ int NumberOfElements = _ptrMesh->getNumberOfElements(entity, MED_ALL_ELEMENTS);
+ int * MEDArrayFamily = new int[NumberOfElements] ;
+ // family 0 by default
+ for (int i=0; i<NumberOfElements; i++)
+ MEDArrayFamily[i]=0;
+ //vector<FAMILY*> myFamilies = _ptrMesh->getFamilies(entity);
+ vector<FAMILY*> * myFamilies = &_ptrMesh->_familyCell ;
+ int NumberOfFamilies = myFamilies->size() ;
+ //bool ToDestroy = false;
+ if (0 == NumberOfFamilies) {
+ //ToDestroy = true ;
+ vector<GROUP*> myGroups = _ptrMesh->getGroups(entity);
+ int NumberOfGroups = myGroups.size() ;
+ // build families from groups
+ for (int i=0; i<NumberOfGroups; i++) {
+ SCRUTE( myGroups[i]->getName() );
+ SUPPORT * mySupport = myGroups[i] ;
+ FAMILY* myFamily = new FAMILY(*mySupport);
+ myFamily->setIdentifier(-i-1);
+ myFamilies->push_back(myFamily);
+ }
+ NumberOfFamilies=myFamilies->size() ;
+ }
+ for (int i=0 ; i<NumberOfFamilies; i++) {
+ int FamilyIdentifier = (*myFamilies)[i]->getIdentifier() ;
+ int TotalNumber = (*myFamilies)[i]->getNumberOfElements(MED_ALL_ELEMENTS) ;
+ if ((*myFamilies)[i]->isOnAllElements())
+ for (int ii=0; ii<TotalNumber; ii++)
+ MEDArrayFamily[ii]=FamilyIdentifier;
+ else {
+ const int * Number = (*myFamilies)[i]->getNumber(MED_ALL_ELEMENTS) ;
+ for (int ii=0; ii<TotalNumber; ii++)
+ MEDArrayFamily[Number[ii]-1]=FamilyIdentifier ;
+ }
+ }
+
+ const int * typeCount = _ptrMesh->getGlobalNumberingIndex(entity) ;
+#if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
+ int lgth=NumberOfElements;
+ med_2_2::med_int *temp=new med_2_2::med_int[lgth];
+ for(int i2=0;i2<lgth;i2++)
+ temp[i2]=(med_2_2::med_int) (MEDArrayFamily[i2]);
+#endif
+ for (int i=0; i<numberOfTypes; i++) {
+#if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
+ err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
+ temp+typeCount[i]-1,typeCount[i+1]-typeCount[i],
+ med_2_2::MED_REMP ,
+ (med_2_2::med_entite_maillage) entity,
+ (med_2_2::med_geometrie_element) types[i]
+);
+#else
+ err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
+ (MEDArrayFamily+typeCount[i]-1),
+ (typeCount[i+1]-typeCount[i]),
+ (med_2_2::med_entite_maillage) entity,
+ (med_2_2::med_geometrie_element) types[i]);
+
+ MESSAGE("OK "<<i);
+ if ( err != MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't write family for the |"<< _ptrMesh->getNumberOfElements(entity, types[i])
+ << "| cells of geometric type |" << geoNames[types[i]] <<"|in mesh |"
+ << _ptrMesh->_name.c_str() << "|" ));
+ }
+#if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
+ delete [] temp;
+#endif
+ delete[] MEDArrayFamily ;
+ //if (true == ToDestroy) {
+ // int NumberOfFamilies = myFamilies->size();
+ // for (int i=0; i<NumberOfFamilies; i++)
+ // delete myFamilies[i];
+ //}
+ }
+ }
+
+ { // FACE RELATED BLOCK
+ medEntityMesh entity=MED_EN::MED_FACE;
+ // SOLUTION TEMPORAIRE CAR _ptrMesh->_MEDArray____Family DOIT ETRE ENLEVER DE LA CLASSE MESH
+ if ( ( _ptrMesh->existConnectivity(MED_NODAL,entity) )|( _ptrMesh->existConnectivity(MED_DESCENDING,entity) ) ) {
+
+ int numberOfTypes = _ptrMesh->getNumberOfTypes (entity) ;
+ const medGeometryElement * types = _ptrMesh->getTypes (entity) ;
+ SCRUTE(numberOfTypes);
+
+ int numberOfElements = _ptrMesh->getNumberOfElements(entity, MED_ALL_ELEMENTS) ;
+ int * familyArray = new int[numberOfElements] ;
+ for (int i=0;i<numberOfElements;i++)
+ familyArray[i]=0;
+
+ int numberOfFamilies = _ptrMesh->getNumberOfFamilies(entity) ;
+ //vector<FAMILY*> myFamilies = _ptrMesh->getFamilies(entity) ;
+ vector<FAMILY*> * myFamilies = &_ptrMesh->_familyFace ;
+ //bool ToDestroy = false;
+ if (0 == numberOfFamilies) {
+ //ToDestroy = true ;
+ vector<GROUP*> myGroups = _ptrMesh->getGroups(entity);
+ int NumberOfGroups = myGroups.size() ;
+ // build families from groups
+ for (int i=0; i<NumberOfGroups; i++) {
+ SCRUTE( myGroups[i]->getName() );
+ SUPPORT * mySupport = myGroups[i] ;
+ FAMILY* myFamily = new FAMILY(*mySupport);
+ myFamily->setIdentifier(-i-1000);
+ myFamilies->push_back(myFamily);
+ }
+ numberOfFamilies=myFamilies->size() ;
+ }
+ for (int i=0;i<numberOfFamilies;i++) {
+ int familyNumber = (*myFamilies)[i]->getIdentifier() ;
+ int numberOfFamilyElements = (*myFamilies)[i]->getNumberOfElements(MED_ALL_ELEMENTS) ;
+ if ((*myFamilies)[i]->isOnAllElements())
+ for (int ii=0; ii<numberOfFamilyElements; ii++)
+ familyArray[ii]=familyNumber;
+ else {
+ const int * myFamilyElements = (*myFamilies)[i]->getNumber(MED_ALL_ELEMENTS) ;
+ for (int ii=0;ii<numberOfFamilyElements;ii++)
+ familyArray[myFamilyElements[ii]-1]=familyNumber;
+ }
+ }
+
+ const int * typeCount = _ptrMesh->getGlobalNumberingIndex(entity) ;
+#if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
+ int lgth=numberOfElements;
+ med_2_2::med_int *temp=new med_2_2::med_int[lgth];
+ for(int i2=0;i2<lgth;i2++)
+ temp[i2]=(med_2_2::med_int) (familyArray[i2]);
+#endif
+ for (int i=0; i<numberOfTypes; i++) {
+ int typeNumberOfElements = typeCount[i+1] - typeCount[i] ;
+
+ err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
+ familyArray+typeCount[i]-1, typeNumberOfElements,
+ (med_2_2::med_entite_maillage) entity,
+ (med_2_2::med_geometrie_element) types[i]);
+#endif
+ if ( err != MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't write family for the |"<< _ptrMesh->getNumberOfElements(entity, types[i])
+ << "| faces of geometric type |" << geoNames[types[i]] <<"|in mesh |"
+ << _ptrMesh->_name.c_str() << "|" ));
+ }
+#if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
+ delete [] temp;
+#endif
+ delete[] familyArray ;
+ //if (true == ToDestroy) {
+ // int NumberOfFamilies = myFamilies->size();
+ // for (int i=0; i<NumberOfFamilies; i++)
+ // delete myFamilies[i];
+ //}
+ }
+ }
+
+ { // EDGE RELATED BLOCK
+ //medEntityMesh entity=MED_EN::MED_FACE;
+ medEntityMesh entity=MED_EN::MED_EDGE;
+ // SOLUTION TEMPORAIRE CAR _ptrMesh->_MEDArray____Family DOIT ETRE ENLEVER DE LA CLASSE MESH
+ if ( ( _ptrMesh->existConnectivity(MED_NODAL,entity) )|( _ptrMesh->existConnectivity(MED_DESCENDING,entity) ) ) {
+
+ int numberOfTypes = _ptrMesh->getNumberOfTypes (entity) ;
+ const medGeometryElement * types = _ptrMesh->getTypes (entity) ;
+
+ int numberOfElements = _ptrMesh->getNumberOfElements(entity, MED_ALL_ELEMENTS) ;
+ int * familyArray = new int[numberOfElements] ;
+ for (int i=0;i<numberOfElements;i++)
+ familyArray[i]=0;
+
+ int numberOfFamilies = _ptrMesh->getNumberOfFamilies(entity) ;
+ //vector<FAMILY*> myFamilies = _ptrMesh->getFamilies(entity) ;
+ vector<FAMILY*> * myFamilies = &_ptrMesh->_familyEdge ;
+ //bool ToDestroy = false;
+ if (0 == numberOfFamilies) {
+ //ToDestroy = true ;
+ vector<GROUP*> myGroups = _ptrMesh->getGroups(entity);
+ int NumberOfGroups = myGroups.size() ;
+ // build families from groups
+ for (int i=0; i<NumberOfGroups; i++) {
+ SCRUTE( myGroups[i]->getName() );
+ SUPPORT * mySupport = myGroups[i] ;
+ FAMILY* myFamily = new FAMILY(*mySupport);
+ myFamily->setIdentifier(-i-2000);
+ myFamilies->push_back(myFamily);
+ }
+ numberOfFamilies=myFamilies->size() ;
+ }
+ for (int i=0;i<numberOfFamilies;i++) {
+ int familyNumber = (*myFamilies)[i]->getIdentifier() ;
+ int numberOfFamilyElements = (*myFamilies)[i]->getNumberOfElements(MED_ALL_ELEMENTS) ;
+ if ((*myFamilies)[i]->isOnAllElements())
+ for (int ii=0; ii<numberOfFamilyElements; ii++)
+ familyArray[ii]=familyNumber;
+ else {
+ const int * myFamilyElements = (*myFamilies)[i]->getNumber(MED_ALL_ELEMENTS) ;
+ for (int ii=0;ii<numberOfFamilyElements;ii++)
+ familyArray[myFamilyElements[ii]-1]=familyNumber;
+ }
+ }
+
+ const int * typeCount = _ptrMesh->getGlobalNumberingIndex(entity) ;
+#if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
+ int lgth=numberOfElements;
+ med_2_2::med_int *temp=new med_2_2::med_int[lgth];
+ for(int i2=0;i2<lgth;i2++)
+ temp[i2]=(med_2_2::med_int) (familyArray[i2]);
+#endif
+ for (int i=0; i<numberOfTypes; i++) {
+ int typeNumberOfElements = typeCount[i+1] - typeCount[i] ;
+
+ err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
+ familyArray+typeCount[i]-1, typeNumberOfElements,
+ (med_2_2::med_entite_maillage) entity,
+ (med_2_2::med_geometrie_element) types[i]);
+
+ if ( err != MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't write family for the |"<< _ptrMesh->getNumberOfElements(entity, types[i])
+ << "| edges of geometric type |" << geoNames[types[i]] <<"|in mesh |"
+ << _ptrMesh->_name.c_str() << "|" ));
+ }
+#if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
+ delete [] temp;
+#endif
+ delete[] familyArray ;
+ //if (true == ToDestroy) {
+ // int NumberOfFamilies = myFamilies->size();
+ // for (int i=0; i<NumberOfFamilies; i++)
+ // delete myFamilies[i];
+ //}
+ }
+ }
+
+ END_OF(LOC);
+ return MED_VALID;
+}
+
+int MED_MESH_WRONLY_DRIVER22::writeFamilies(vector<FAMILY*> & families ) const
+{
+
+ const char * LOC="int MED_MESH_WRONLY_DRIVER22::writeFamilies(vector<FAMILY*> families) const : ";
+ BEGIN_OF(LOC);
+
+ med_2_2::med_err err;
+
+ MESSAGE(LOC<<" families.size() :"<<families.size());
+
+ for (unsigned int i=0; i< families.size(); i++) {
+
+ int numberOfAttributes = families[i]->getNumberOfAttributes ();
+ string attributesDescriptions = "";
+
+ // Recompose the attributes descriptions arg for MED
+ for (int j=0; j < numberOfAttributes; j++) {
+
+ string attributeDescription = families[i]->getAttributeDescription(j+1);
+
+ if ( attributeDescription.size() > MED_TAILLE_DESC )
+ throw MEDEXCEPTION( LOCALIZED(STRING(LOC) << "The size of the attribute description n° |" << j+1 << "| of the family |" << families[i]->getName()
+ << "| with identifier |" << families[i]->getIdentifier() << "| is |"
+ << attributeDescription.size() <<"| and is more than |" << MED_TAILLE_DESC << "|")) ;
+
+ attributesDescriptions += attributeDescription;
+ }
+
+
+ int numberOfGroups = families[i]->getNumberOfGroups();
+ string groupsNames(numberOfGroups*MED_TAILLE_LNOM,'\0') ;
+ // Recompose the groups names arg for MED
+ for (int j=0; j < numberOfGroups; j++) {
+
+ string groupName = families[i]->getGroupName(j+1);
+
+ if ( groupName.size() > MED_TAILLE_LNOM )
+ throw MEDEXCEPTION( LOCALIZED(STRING(LOC) << "The size of the group name n° |" << j+1 << "| of the family |" << families[i]->getName()
+ << "| with identifier |" << families[i]->getIdentifier() << "| is |"
+ << groupName.size() <<"| and is more than |" << MED_TAILLE_LNOM << "|")) ;
+
+
+ int length = min(MED_TAILLE_LNOM,(int)groupName.size());
+ groupsNames.replace(j*MED_TAILLE_LNOM,length, groupName,0,length);
+
+ }
+
+ // test if the family already exists (HDF trick waiting a MED evolution to be replaced)
+
+ string dataGroupFam;
+ if (families[i]->getEntity() == MED_NODE)
+ dataGroupFam = "/ENS_MAA/"+_meshName+"/FAS/NOEUD/"+families[i]->getName()+"/";
+ else
+ dataGroupFam = "/ENS_MAA/"+_meshName+"/FAS/ELEM/"+families[i]->getName()+"/";
+
+ SCRUTE("|"<<dataGroupFam<<"|");
+ err = med_2_2::_MEDdatagroupOuvrir(_medIdt,const_cast <char *> (dataGroupFam.c_str()) ) ;
+ if ( err < MED_VALID ) {
+ SCRUTE(err);
+
+ MESSAGE(LOC<<"families[i]->getName().c_str() : "<<families[i]->getName().c_str());
+ MESSAGE(LOC<<"_meshName.c_str() : "<<_meshName.c_str());
+ MESSAGE(LOC<<"families[i]->getIdentifier() : "<<families[i]->getIdentifier());
+ MESSAGE(LOC<<"numberOfAttributes : "<<numberOfAttributes);
+
+ //MESSAGE(LOC<<"families[i]->getAttributesIdentifiers() : "<<families[i]->getAttributesIdentifiers()[0]);
+ //MESSAGE(LOC<<"families[i]->getAttributesValues() : "<<families[i]->getAttributesValues()[0]);
+ MESSAGE(LOC<<"attributesDescriptions.c_str() : "<<attributesDescriptions.c_str());
+ MESSAGE(LOC<<"numberOfGroups : "<<numberOfGroups);
+ MESSAGE(LOC<<"groupsNames.c_str() : "<<groupsNames.c_str());
+#if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
+ int lgth=families[i]->getNumberOfAttributes();
+ med_2_2::med_int * AttributesIdentifier2 = new med_2_2::med_int[lgth] ;
+ med_2_2::med_int * AttributesValues2 = new med_2_2::med_int[lgth] ;
+ for(med_2_2::med_int i2=0;i2<lgth;i2++)
+ {
+ AttributesIdentifier2[i2]=(med_2_2::med_int)(families[i]->getAttributesIdentifiers()[i2]);
+ AttributesValues2[i2]=(med_2_2::med_int)(families[i]->getAttributesValues()[i2]);
+ }
+ err = med_2_2::MEDfamCr( _medIdt,
+ const_cast <char *> ( _meshName.c_str() ),
+ const_cast <char *> ( families[i]->getName().c_str() ),
+ families[i]->getIdentifier(),
+ AttributesIdentifier2,
+ AttributesValues2,
+ const_cast <char *> (attributesDescriptions.c_str()),
+ numberOfAttributes,
+ const_cast <char *> (groupsNames.c_str()),
+ numberOfGroups);
+ delete [] AttributesIdentifier2;
+ delete [] AttributesValues2;
+#else
+ err = med_2_2::MEDfamCr( _medIdt,
+ const_cast <char *> ( _meshName.c_str() ),
+ const_cast <char *> ( families[i]->getName().c_str() ),
+ families[i]->getIdentifier(),
+ families[i]->getAttributesIdentifiers(),
+ families[i]->getAttributesValues(),
+ const_cast <char *> (attributesDescriptions.c_str()),
+ numberOfAttributes,
+ const_cast <char *> (groupsNames.c_str()),
+ numberOfGroups);
+#endif
+ SCRUTE(err);
+ if ( err != MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't create family |" << families[i]->getName()
+ << "| with identifier |" << families[i]->getIdentifier() << "| groups names |"
+ << groupsNames <<"| and attributes descriptions |" << attributesDescriptions << "|")) ;
+ }
+ else
+ med_2_2::_MEDdatagroupFermer(_medIdt);
+
+
+ }
+
+ END_OF(LOC);
+
+ return MED_VALID;
+}
+
+
+// A FAIRE POUR LES NOEUDS ET LES ELEMENTS ret = MEDfamEcr(
+
+
+
+/*--------------------- RDWR PART -------------------------------*/
+
+MED_MESH_RDWR_DRIVER22::MED_MESH_RDWR_DRIVER22()
+{
+}
+
+MED_MESH_RDWR_DRIVER22::MED_MESH_RDWR_DRIVER22(const string & fileName,
+ MESH * ptrMesh):
+ MED_MESH_DRIVER(fileName,ptrMesh,MED_RDWR),
+ IMED_MESH_RDONLY_DRIVER(fileName,ptrMesh),
+ IMED_MESH_WRONLY_DRIVER(fileName,ptrMesh),
+ IMED_MESH_RDWR_DRIVER(fileName,ptrMesh),
+ MED_MESH_DRIVER22(fileName,ptrMesh,MED_RDWR),
+ MED_MESH_RDONLY_DRIVER22(fileName,ptrMesh),
+ MED_MESH_WRONLY_DRIVER22(fileName,ptrMesh)
+{
+ MESSAGE("MED_MESH_RDWR_DRIVER22::MED_MESH_RDWR_DRIVER22(const string & fileName, MESH * ptrMesh) has been created");
+}
+
+MED_MESH_RDWR_DRIVER22::MED_MESH_RDWR_DRIVER22(const MED_MESH_RDWR_DRIVER22 & driver):
+ MED_MESH_DRIVER(driver),
+ IMED_MESH_RDONLY_DRIVER(driver),
+ IMED_MESH_WRONLY_DRIVER(driver),
+ IMED_MESH_RDWR_DRIVER(driver),
+ MED_MESH_DRIVER22(driver),
+ MED_MESH_RDONLY_DRIVER22(driver),
+ MED_MESH_WRONLY_DRIVER22(driver)
+{
+}
+
+MED_MESH_RDWR_DRIVER22::~MED_MESH_RDWR_DRIVER22() {
+ //MESSAGE("MED_MESH_RDWR_DRIVER22::MED_MESH_RDWR_DRIVER22(const string & fileName, MESH * ptrMesh) has been destroyed");
+}
+
+GENDRIVER * MED_MESH_RDWR_DRIVER22::copy(void) const
+{
+ return new MED_MESH_RDWR_DRIVER22(*this);
+}
+
+void MED_MESH_RDWR_DRIVER22::write(void) const
+{
+ MED_MESH_WRONLY_DRIVER22::write();
+}
+void MED_MESH_RDWR_DRIVER22::read (void)
+{
+ MED_MESH_RDONLY_DRIVER22::read();
+}
+
--- /dev/null
+#ifndef MED_MESH_DRIVER22_HXX
+#define MED_MESH_DRIVER22_HXX
+
+#include "MEDMEM_MedMeshDriver.hxx"
+#include "MEDMEM_define.hxx"
+#include "MEDMEM_Compatibility21_22.hxx"
+
+/*!
+
+ Driver Med for MESH.
+
+ Generic part : implement open and close methods.
+
+*/
+
+namespace MEDMEM {
+class MESH;
+class FAMILY;
+class GROUP;
+class CONNECTIVITY;
+
+class MED_MESH_DRIVER22 : public virtual MED_MESH_DRIVER
+{
+protected:
+
+ med_2_2::med_idt _medIdt ;
+
+public :
+
+ // all MED cell type
+ static const med_2_2::med_geometrie_element all_cell_type[MED_NBR_GEOMETRIE_MAILLE];
+
+ static const char * const all_cell_type_tab [MED_NBR_GEOMETRIE_MAILLE];
+
+ /*!
+ Constructor.
+ */
+ MED_MESH_DRIVER22() ;
+ /*!
+ Constructor.
+ */
+ MED_MESH_DRIVER22(const string & fileName,
+ MESH * ptrMesh,
+ MED_EN::med_mode_acces accessMode) ;
+ /*!
+ Copy constructor.
+ */
+ MED_MESH_DRIVER22(const MED_MESH_DRIVER22 & driver) ;
+
+ /*!
+ Destructor.
+ */
+ virtual ~MED_MESH_DRIVER22() ;
+
+ void open();
+ void close();
+};
+
+/*!
+
+ Driver Med for MESH : Read only.
+
+ Implement read method.
+
+*/
+
+class MED_MESH_RDONLY_DRIVER22 : public virtual IMED_MESH_RDONLY_DRIVER, public virtual MED_MESH_DRIVER22
+{
+
+public :
+
+ /*!
+ Constructor.
+ */
+ MED_MESH_RDONLY_DRIVER22() ;
+ /*!
+ Constructor.
+ */
+ MED_MESH_RDONLY_DRIVER22(const string & fileName, MESH * ptrMesh) ;
+ /*!
+ Copy constructor.
+ */
+ MED_MESH_RDONLY_DRIVER22(const MED_MESH_RDONLY_DRIVER22 & driver) ;
+
+ /*!
+ Destructor.
+ */
+ virtual ~MED_MESH_RDONLY_DRIVER22() ;
+
+ /*!
+ Read MESH in the specified file.
+ */
+ void read ( void );
+
+private:
+ int getCOORDINATE();
+ int getCONNECTIVITY();
+ int getFAMILY();
+ int getNodalConnectivity(CONNECTIVITY * Connectivity) ;
+ int getNodesFamiliesNumber(int * MEDArrayNodeFamily) ;
+ int getCellsFamiliesNumber(int** Arrays, CONNECTIVITY* Connectivity, MED_EN::medEntityMesh entity) ;
+ void getGRID ();
+
+ GENDRIVER * copy ( void ) const ;
+
+};
+
+/*!
+
+ Driver Med for MESH : Write only.
+
+ Implement write method.
+
+*/
+
+class MED_MESH_WRONLY_DRIVER22 : public virtual IMED_MESH_WRONLY_DRIVER, public virtual MED_MESH_DRIVER22 {
+
+public :
+
+ /*!
+ Constructor.
+ */
+ MED_MESH_WRONLY_DRIVER22() ;
+ /*!
+ Constructor.
+ */
+ MED_MESH_WRONLY_DRIVER22(const string & fileName, MESH * ptrMesh) ;
+ /*!
+ Copy constructor.
+ */
+ MED_MESH_WRONLY_DRIVER22(const MED_MESH_WRONLY_DRIVER22 & driver) ;
+
+ /*!
+ Destructor.
+ */
+ virtual ~MED_MESH_WRONLY_DRIVER22() ;
+
+ /*!
+ Write MESH in the specified file.
+ */
+ void write( void ) const;
+
+private:
+ int writeCoordinates () const;
+ int writeConnectivities (MED_EN::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_DRIVER22 : public IMED_MESH_RDWR_DRIVER, public MED_MESH_RDONLY_DRIVER22, public MED_MESH_WRONLY_DRIVER22 {
+
+public :
+
+ /*!
+ Constructor.
+ */
+ MED_MESH_RDWR_DRIVER22() ;
+ /*!
+ Constructor.
+ */
+ MED_MESH_RDWR_DRIVER22(const string & fileName, MESH * ptrMesh) ;
+ /*!
+ Copy constructor.
+ */
+ MED_MESH_RDWR_DRIVER22(const MED_MESH_RDWR_DRIVER22 & driver) ;
+
+ /*!
+ Destructor.
+ */
+ ~MED_MESH_RDWR_DRIVER22() ;
+
+ /*!
+ Write MESH in the specified file.
+ */
+ void write(void) const;
+ /*!
+ Read MESH in the specified file.
+ */
+ void read (void);
+
+private:
+ GENDRIVER * copy(void) const ;
+
+};
+};
+
+#endif /* MED_MESH_DRIVER22_HXX */
--- /dev/null
+#include "MEDMEM_MedVersion.hxx"
+#include "utilities.h"
+#include "MEDMEM_Compatibility21_22.hxx"
+
+using namespace MEDMEM;
+using namespace MED_EN;
+
+medFileVersion MEDMEM::getMedFileVersion(const string & fileName)
+ throw (MEDEXCEPTION)
+{
+ medFileVersion version;
+
+ med_2_1::med_idt fid21;
+ med_2_2::med_idt fid22;
+
+ med_2_1::med_err ret21;
+ med_2_2::med_err ret22;
+
+ med_2_1::med_int major21;
+ med_2_1::med_int minor21;
+ med_2_1::med_int release21;
+
+ med_2_2::med_int major22;
+ med_2_2::med_int minor22;
+ med_2_2::med_int release22;
+
+ med_2_2::med_mode_acces access22 = med_2_2::MED_LECTURE;
+ med_2_1::med_mode_acces access21 = med_2_1::MED_LECT;
+
+ /*
+ Med Version 2.1 access to the file
+ */
+
+ fid21 = med_2_1::MEDouvrir((const_cast <char *> (fileName.c_str())),
+ access21);
+
+ if (fid21 < 0)
+ throw MEDEXCEPTION("Problem in getMedFileVersion(const string &) Med file V2.1 access");
+
+ ret21 = med_2_1::MEDversionLire(fid21,&major21,&minor21,&release21);
+
+ if (ret21 < 0)
+ throw MEDEXCEPTION("Problem in getMedFileVersion(const string &) Med file V2.1 version numbers reading");
+
+ if ((minor21 == -1) || (release21 == -1))
+ {
+ MESSAGE("getMedFileVersion the file may have been produced by a version 2.1.x x<5");
+ minor21 = 1;
+ release21 = 5;
+ }
+
+ ret21 = med_2_1::MEDfermer(fid21);
+
+ if (ret21 < 0)
+ throw MEDEXCEPTION("Problem in getMedFileVersion(const string &) Med file V2.1 file closing");
+
+ /*
+ Med Version 2.2 access to the file
+ */
+
+ fid22 = med_2_2::MEDouvrir((const_cast <char *> (fileName.c_str())),
+ access22);
+
+ if (fid22 < 0)
+ throw MEDEXCEPTION("Problem in getMedFileVersion(const string &) Med file V2.2 access");
+
+ ret22 = med_2_2::MEDversionLire(fid22,&major22,&minor22,&release22);
+
+ if (ret22 < 0)
+ throw MEDEXCEPTION("Problem in getMedFileVersion(const string &) Med file V2.2 version numbers reading");
+
+ if ((minor22 == -1) || (release22 == -1))
+ {
+ MESSAGE("getMedFileVersion the file may have been produced by a version 2.1.x x<5");
+ minor22 = 1;
+ release22 = 5;
+ }
+
+ ret22 = med_2_2::MEDfermer(fid22);
+
+ if (ret22 < 0)
+ throw MEDEXCEPTION("Problem in getMedFileVersion(const string &) Med file V2.2 file closing");
+
+ if ((major21 != major22) || (minor21 != minor22) || (release21 != release22))
+ throw MEDEXCEPTION("Problem in getMedFileVersion(const string &) Med file V21 and V22 version numbers are different");
+
+ MESSAGE("getMedFileVersion: status version 21 of the file major " << major21 << " minor " << minor21 << " release " << release21);
+
+ MESSAGE("getMedFileVersion: status version 22 of the file major " << major22 << " minor " << minor22 << " release " << release22);
+
+ if (major21 == 2)
+ {
+ if (minor21 == 1)
+ version = V21;
+ else if (minor21 > 1)
+ version = V22;
+ }
+ else
+ version = V22;
+
+ MESSAGE("getMedFileVersion the version of the file is " << version);
+
+ return version;
+}
--- /dev/null
+#ifndef MED_VERSION_HXX
+#define MED_VERSION_HXX
+
+#include <string>
+#include "MEDMEM_Exception.hxx"
+#include "MEDMEM_define.hxx"
+
+namespace MEDMEM {
+
+ MED_EN::medFileVersion getMedFileVersion(const string & fileName)
+ throw (MEDEXCEPTION);
+}
+
+#endif /* MED_VERSION_HXX */
*/
#include <math.h>
-
-#include <list>
#include <map>
#include <sstream>
#include "MEDMEM_Coordinate.hxx"
#include "MEDMEM_Connectivity.hxx"
#include "MEDMEM_CellModel.hxx"
-
+#include "MEDMEM_Formulae.hxx"
+#include "MEDMEM_InterpolationHighLevelObjects.hxx"
#include "MEDMEM_DriverFactory.hxx"
using namespace std;
using namespace MEDMEM;
using namespace MED_EN;
-//#include "MEDMEM_Grid.hxx" this inclision should have never be here !!!
-
-//update Families with content list
-//int family_count(int family_number, int count, int * entities_number, int * entities_list) ;
+#define MED_NOPDT -1
+#define MED_NONOR -1
// ------- Drivers Management Part
}
+/*
+ Method equivalent to getNumberOfTypes except that it includes not only classical Types but polygons/polyhedra also.
+ */
+int MESH::getNumberOfTypesWithPoly(MED_EN::medEntityMesh Entity) const
+{
+ if(_connectivity!= NULL)
+ return _connectivity->getNumberOfTypesWithPoly(Entity);
+ throw MEDEXCEPTION(LOCALIZED("MESH::getNumberOfTypesWithPoly( medEntityMesh ) : Connectivity not defined !"));
+}
+
+/*
+ Method equivalent to getTypesWithPoly except that it includes not only classical Types but polygons/polyhedra also.
+ WARNING the returned array MUST be deallocated.
+ */
+MED_EN::medGeometryElement * MESH::getTypesWithPoly(MED_EN::medEntityMesh Entity) const
+{
+ if (Entity == MED_EN::MED_NODE)
+ throw MEDEXCEPTION(LOCALIZED("MESH::getTypes( medEntityMesh ) : No medGeometryElement with MED_NODE entity !"));
+ if (_connectivity != NULL)
+ return _connectivity->getGeometricTypesWithPoly(Entity);
+ throw MEDEXCEPTION(LOCALIZED("MESH::getTypes( medEntityMesh ) : Connectivity not defined !"));
+}
+
+/*
+ Method equivalent to getNumberOfElementsWithPoly except that it includes not only classical Types but polygons/polyhedra also.
+ */
+int MESH::getNumberOfElementsWithPoly(MED_EN::medEntityMesh Entity, MED_EN::medGeometryElement Type) const
+{
+ if(Type==MED_POLYGON || Type==MED_POLYHEDRA)
+ {
+ int nbOfPolygs=_connectivity->getNumberOfElementOfPolyType(Entity);
+ return nbOfPolygs;
+ }
+ else if(Type==MED_ALL_ELEMENTS)
+ {
+ int nbOfClassicalTypes=getNumberOfElements(Entity,MED_ALL_ELEMENTS);
+ int nbOfClassicalTypes2=_connectivity->getNumberOfElementOfPolyType(Entity);
+ return nbOfClassicalTypes+nbOfClassicalTypes2;
+ }
+ else
+ return getNumberOfElements(Entity,Type);
+}
+
MESH & MESH::operator=(const MESH &m)
{
const char * LOC = "MESH & MESH::operator=(const MESH &m) : ";
return *this;
}
+bool MESH::operator==(const MESH& other) const
+{
+ BEGIN_OF("MESH::operator==");
+ return this==&other;
+}
+
/*! Create a %MESH object using a %MESH driver of type %driverTypes (MED_DRIVER, ....) associated with file fileName.
The meshname driverName must already exists in the file.*/
MESH::MESH(driverTypes driverType, const string & fileName/*=""*/, const string & driverName/*=""*/) throw (MEDEXCEPTION)
_drivers[current]->read();
_drivers[current]->close();
-// if (_isAGrid)
-// ((GRID *) this)->fillMeshAfterRead();
-
END_OF(LOC);
};
+/*
+ for a deep comparison of 2 meshes.
+*/
+bool MESH::deepCompare(const MESH& other) const
+{
+ int size1=getSpaceDimension()*getNumberOfNodes();
+ int size2=other.getSpaceDimension()*other.getNumberOfNodes();
+ if(size1!=size2)
+ return false;
+ const double* coord1=getCoordinates(MED_FULL_INTERLACE);
+ const double* coord2=other.getCoordinates(MED_FULL_INTERLACE);
+ bool ret=true;
+ for(int i=0;i<size1 && ret;i++)
+ {
+ ret=(fabs(coord1[i]-coord2[i])<1e-15);
+ }
+ if(ret)
+ {
+ return _connectivity->deepCompare(*other._connectivity);
+ }
+ return ret;
+}
-// Node MESH::Donne_Barycentre(const Maille &m) const
-// {
-// Node N=node[m[0]];
-// for (int i=1;i<m.donne_nbr_sommets();i++) N=N+node[m[i]];
-// N=N*(1.0/m.donne_nbr_sommets());
-// return N;
-// }
-
-ostream & MEDMEM::operator<<(ostream &os, const MESH &myMesh)
+ostream & ::MEDMEM::operator<<(ostream &os, const MESH &myMesh)
{
int spacedimension = myMesh.getSpaceDimension();
int meshdimension = myMesh.getMeshDimension();
return cellsList.front() ;
}
-
/*!
Return a support which reference all elements on the boundary of mesh.
BEGIN_OF(LOC) ;
// some test :
// actually we could only get face (in 3D) and edge (in 2D)
- if (_spaceDimension == 3)
+ medEntityMesh entityToParse=Entity;
+ 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<<" !"));
-
- // well, all rigth !
- SUPPORT * mySupport = new SUPPORT(this,"Boundary",Entity);
- //mySupport.setDescription("boundary of type ...");
- mySupport->setAll(false);
+ if(Entity==MED_NODE)
+ entityToParse=MED_FACE;
+ else
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined in 3D mesh for entity "<<Entity<<" !"));
+ if(_spaceDimension == 2)
+ if(Entity != MED_EDGE)
+ if(Entity==MED_NODE)
+ entityToParse=MED_EDGE;
+ else
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined in 2D mesh for entity "<<Entity<<" !"));
-
const int * myConnectivityValue = getReverseConnectivity(MED_DESCENDING) ;
const int * myConnectivityIndex = getReverseConnectivityIndex(MED_DESCENDING) ;
- int numberOf = getNumberOfElements(Entity,MED_ALL_ELEMENTS) ;
- list<int> myElementsList ;
- int size = 0 ;
+ int numberOf = getNumberOfElementsWithPoly(entityToParse,MED_ALL_ELEMENTS) ;
+ list<int> myElementsList;
+
for (int i=0 ; i<numberOf; i++)
if (myConnectivityValue[myConnectivityIndex[i]] == 0) {
- myElementsList.push_back(i+1) ;
- size++ ;
+ myElementsList.push_back(i+1);
+
}
- // 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) ;
- id ++ ;
- }
+ if(Entity==MED_NODE)
+ return buildSupportOnNodeFromElementList(myElementsList,entityToParse);
+ else
+ return buildSupportOnElementsFromElementList(myElementsList,entityToParse);
+}
- int numberOfGeometricType ;
- medGeometryElement* geometricType ;
- int * numberOfGaussPoint ;
- int * geometricTypeNumber ;
- int * numberOfElements ;
- //MEDSKYLINEARRAY * mySkyLineArray = new MEDSKYLINEARRAY() ;
- int * mySkyLineArrayIndex ;
+/*!
+ Method that do the same thing as buildSupportOnNodeFromElementList except that a SUPPORT is not created.
+ */
+void MESH::fillSupportOnNodeFromElementList(const list<int>& listOfElt, SUPPORT *supportToFill) const throw (MEDEXCEPTION)
+{
+ MED_EN::medEntityMesh entity=supportToFill->getEntity();
+ supportToFill->setAll(false);
+ supportToFill->setMesh((MESH *)this);
- int numberOfType = getNumberOfTypes(Entity) ;
- if (numberOfType == 1) { // wonderfull : it's easy !
- numberOfGeometricType = 1 ;
- geometricType = new medGeometryElement[1] ;
- const medGeometryElement * allType = 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 = 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 = getTypes(Entity); !! UNUSZED VARIABLE !!
- 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++ ;
+ int i;
+ set<int> nodes;
+ for(list<int>::const_iterator iter=listOfElt.begin();iter!=listOfElt.end();iter++)
+ {
+ int lgth;
+ const int *conn=_connectivity->getConnectivityOfAnElementWithPoly(MED_NODAL,entity,*iter,lgth);
+ for(i=0;i<lgth;i++)
+ nodes.insert(conn[i]);
}
- }
- //mySkyLineArray->setMEDSKYLINEARRAY(numberOfGeometricType,size,mySkyLineArrayIndex,myListArray) ;
- MEDSKYLINEARRAY * mySkyLineArray = new MEDSKYLINEARRAY(numberOfGeometricType,size,mySkyLineArrayIndex,myListArray) ;
+ list<int> nodesList;
+ for(set<int>::iterator iter2=nodes.begin();iter2!=nodes.end();iter2++)
+ nodesList.push_back(*iter2);
+ supportToFill->fillFromNodeList(nodesList);
+}
- mySupport->setNumberOfGeometricType(numberOfGeometricType) ;
- mySupport->setGeometricType(geometricType) ;
- mySupport->setNumberOfGaussPoint(numberOfGaussPoint) ;
- mySupport->setNumberOfElements(numberOfElements) ;
- mySupport->setTotalNumberOfElements(size) ;
- // mySupport->setGeometricTypeNumber(geometricTypeNumber) ;
- mySupport->setNumber(mySkyLineArray) ;
-
- delete[] numberOfElements;
- delete[] geometricTypeNumber;
- delete[] numberOfGaussPoint;
- delete[] geometricType;
- delete[] mySkyLineArrayIndex;
- delete[] myListArray;
-// delete mySkyLineArray;
+/*!
+ Method created to factorize code. This method creates a new support on NODE (to deallocate) containing all the nodes id contained in elements 'listOfElt' of
+ entity 'entity'.
+ */
+SUPPORT *MESH::buildSupportOnNodeFromElementList(const list<int>& listOfElt,MED_EN::medEntityMesh entity) const throw (MEDEXCEPTION)
+{
+ SUPPORT * mySupport = new SUPPORT((MESH *)this,"Boundary",entity);
+ fillSupportOnNodeFromElementList(listOfElt,mySupport);
+ return mySupport;
+}
+/*!
+ Method created to factorize code. This method creates a new support on entity 'entity' (to deallocate) containing all the entities contained in
+ elements 'listOfElt' of entity 'entity'.
+ */
+SUPPORT *MESH::buildSupportOnElementsFromElementList(const list<int>& listOfElt, MED_EN::medEntityMesh entity) const throw (MEDEXCEPTION)
+{
+ const char * LOC = "MESH::buildSupportOnElementsFromElementList : " ;
+ BEGIN_OF(LOC);
+ SUPPORT *mySupport=new SUPPORT((MESH *)this,"Boundary",entity);
+ mySupport->fillFromElementList(listOfElt);
END_OF(LOC) ;
return mySupport ;
}
int nb_entity_type;
// !!!! WARNING : use of nodal global numbering in the mesh !!!!
const int* global_connectivity;
-
-// if (onAll)
-// {
-// nb_type = myMesh->getNumberOfTypes(support_entity);
-// length_values = getNumberOfElements(support_entity,MED_ALL_ELEMENTS);
-// types = getTypes(support_entity);
-// }
-// else
- {
- nb_type = Support->getNumberOfTypes();
- length_values = Support->getNumberOfElements(MED_ALL_ELEMENTS);
- types = Support->getTypes();
- }
-
+ nb_type = Support->getNumberOfTypes();
+ length_values = Support->getNumberOfElements(MED_ALL_ELEMENTS);
+ types = Support->getTypes();
int index;
FIELD<double>* Volume = new FIELD<double>(Support,1);
// double *volume = new double [length_values];
Volume->setIterationNumber(0);
Volume->setOrderNumber(0);
Volume->setTime(0.0);
-
- //const double *volume = Volume->getValue(MED_FULL_INTERLACE);
MEDARRAY<double> *volume = Volume->getvalue();
-
index = 1;
const double * coord = getCoordinates(MED_FULL_INTERLACE);
{
medGeometryElement type = types[i] ;
double xvolume;
-
- if (onAll)
+ nb_entity_type = Support->getNumberOfElements(type);
+ if(type != MED_EN::MED_POLYHEDRA)
{
- nb_entity_type = getNumberOfElements(support_entity,type);
- global_connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,type);
- }
- else
- {
- // throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Support must be on all"));
-
- nb_entity_type = Support->getNumberOfElements(type);
-
- const int * supp_number = Support->getNumber(type);
- const int * connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,MED_ALL_ELEMENTS);
- const int * connectivityIndex = getConnectivityIndex(MED_NODAL,support_entity);
- int * global_connectivity_tmp = new int[(type%100)*nb_entity_type];
+ if (onAll)
+ {
+ global_connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,type);
+ }
+ else
+ {
+ const int * supp_number = Support->getNumber(type);
+ const int * connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,MED_ALL_ELEMENTS);
+ const int * connectivityIndex = getConnectivityIndex(MED_NODAL,support_entity);
+ int * global_connectivity_tmp = new int[(type%100)*nb_entity_type];
- for (int k_type = 0; k_type<nb_entity_type; k_type++) {
- for (int j_ent = 0; j_ent<(type%100); j_ent++) {
- global_connectivity_tmp[k_type*(type%100)+j_ent] = connectivity[connectivityIndex[supp_number[k_type]-1]+j_ent-1];
- }
- }
- global_connectivity = global_connectivity_tmp ;
+ for (int k_type = 0; k_type<nb_entity_type; k_type++) {
+ for (int j_ent = 0; j_ent<(type%100); j_ent++) {
+ global_connectivity_tmp[k_type*(type%100)+j_ent] = connectivity[connectivityIndex[supp_number[k_type]-1]+j_ent-1];
+ }
+ }
+ global_connectivity = global_connectivity_tmp ;
+ }
}
switch (type)
for (int tetra=0;tetra<nb_entity_type;tetra++)
{
int tetra_index = (type%100)*tetra;
-
int N1 = global_connectivity[tetra_index]-1;
int N2 = global_connectivity[tetra_index+1]-1;
int N3 = global_connectivity[tetra_index+2]-1;
int N4 = global_connectivity[tetra_index+3]-1;
-
- double x1 = coord[dim_space*N1];
- double x2 = coord[dim_space*N2];
- double x3 = coord[dim_space*N3];
- double x4 = coord[dim_space*N4];
-
- double y1 = coord[dim_space*N1+1];
- double y2 = coord[dim_space*N2+1];
- double y3 = coord[dim_space*N3+1];
- double y4 = coord[dim_space*N4+1];
-
- double z1 = coord[dim_space*N1+2];
- double z2 = coord[dim_space*N2+2];
- double z3 = coord[dim_space*N3+2];
- double z4 = coord[dim_space*N4+2];
-
- xvolume = ((x3-x1)*((y2-y1)*(z4-z1) - (z2-z1)*(y4-y1)) -
- (x2-x1)*((y3-y1)*(z4-z1) - (z3-z1)*(y4-y1)) +
- (x4-x1)*((y3-y1)*(z2-z1) - (z3-z1)*(y2-y1)))/6.0;
-
- //volume[index] = xvolume ;
+ xvolume=CalculateVolumeForTetra(coord+dim_space*N1,coord+dim_space*N2,coord+dim_space*N3,coord+dim_space*N4);
volume->setIJ(index,1,xvolume) ;
index++;
}
for (int pyra=0;pyra<nb_entity_type;pyra++)
{
int pyra_index = (type%100)*pyra;
-
int N1 = global_connectivity[pyra_index]-1;
int N2 = global_connectivity[pyra_index+1]-1;
int N3 = global_connectivity[pyra_index+2]-1;
int N4 = global_connectivity[pyra_index+3]-1;
int N5 = global_connectivity[pyra_index+4]-1;
-
- double x1 = coord[dim_space*N1];
- double x2 = coord[dim_space*N2];
- double x3 = coord[dim_space*N3];
- double x4 = coord[dim_space*N4];
- double x5 = coord[dim_space*N5];
-
- double y1 = coord[dim_space*N1+1];
- double y2 = coord[dim_space*N2+1];
- double y3 = coord[dim_space*N3+1];
- double y4 = coord[dim_space*N4+1];
- double y5 = coord[dim_space*N5+1];
-
- double z1 = coord[dim_space*N1+2];
- double z2 = coord[dim_space*N2+2];
- double z3 = coord[dim_space*N3+2];
- double z4 = coord[dim_space*N4+2];
- double z5 = coord[dim_space*N5+2];
-
- xvolume = (((x3-x1)*((y2-y1)*(z5-z1) - (z2-z1)*(y5-y1)) -
- (x2-x1)*((y3-y1)*(z5-z1) - (z3-z1)*(y5-y1)) +
- (x5-x1)*((y3-y1)*(z2-z1) - (z3-z1)*(y2-y1))) +
- ((x4-x1)*((y3-y1)*(z5-z1) - (z3-z1)*(y5-y1)) -
- (x3-x1)*((y4-y1)*(z5-z1) - (z4-z1)*(y5-y1)) +
- (x5-x1)*((y4-y1)*(z3-z1) - (z4-z1)*(y3-y1)))
- )/6.0;
-
- //volume[index] = xvolume ;
+ xvolume=CalculateVolumeForPyra(coord+dim_space*N1,coord+dim_space*N2,coord+dim_space*N3,coord+dim_space*N4,coord+dim_space*N5);
volume->setIJ(index,1,xvolume) ;
index = index++;
}
for (int penta=0;penta<nb_entity_type;penta++)
{
int penta_index = (type%100)*penta;
-
int N1 = global_connectivity[penta_index]-1;
int N2 = global_connectivity[penta_index+1]-1;
int N3 = global_connectivity[penta_index+2]-1;
int N4 = global_connectivity[penta_index+3]-1;
int N5 = global_connectivity[penta_index+4]-1;
int N6 = global_connectivity[penta_index+5]-1;
-
- double x1 = coord[dim_space*N1];
- double x2 = coord[dim_space*N2];
- double x3 = coord[dim_space*N3];
- double x4 = coord[dim_space*N4];
- double x5 = coord[dim_space*N5];
- double x6 = coord[dim_space*N6];
-
- double y1 = coord[dim_space*N1+1];
- double y2 = coord[dim_space*N2+1];
- double y3 = coord[dim_space*N3+1];
- double y4 = coord[dim_space*N4+1];
- double y5 = coord[dim_space*N5+1];
- double y6 = coord[dim_space*N6+1];
-
- double z1 = coord[dim_space*N1+2];
- double z2 = coord[dim_space*N2+2];
- double z3 = coord[dim_space*N3+2];
- double z4 = coord[dim_space*N4+2];
- double z5 = coord[dim_space*N5+2];
- double z6 = coord[dim_space*N6+2];
-
- double a1 = (x2-x3)/2.0, a2 = (y2-y3)/2.0, a3 = (z2-z3)/2.0;
- double b1 = (x5-x6)/2.0, b2 = (y5-y6)/2.0, b3 = (z5-z6)/2.0;
- double c1 = (x4-x1)/2.0, c2 = (y4-y1)/2.0, c3 = (z4-z1)/2.0;
- double d1 = (x5-x2)/2.0, d2 = (y5-y2)/2.0, d3 = (z5-z2)/2.0;
- double e1 = (x6-x3)/2.0, e2 = (y6-y3)/2.0, e3 = (z6-z3)/2.0;
- double f1 = (x1-x3)/2.0, f2 = (y1-y3)/2.0, f3 = (z1-z3)/2.0;
- double h1 = (x4-x6)/2.0, h2 = (y4-y6)/2.0, h3 = (z4-z6)/2.0;
-
- double A = a1*c2*f3 - a1*c3*f2 - a2*c1*f3 + a2*c3*f1 +
- a3*c1*f2 - a3*c2*f1;
- double B = b1*c2*h3 - b1*c3*h2 - b2*c1*h3 + b2*c3*h1 +
- b3*c1*h2 - b3*c2*h1;
- double C = (a1*c2*h3 + b1*c2*f3) - (a1*c3*h2 + b1*c3*f2) -
- (a2*c1*h3 + b2*c1*f3) + (a2*c3*h1 + b2*c3*f1) +
- (a3*c1*h2 + b3*c1*f2) - (a3*c2*h1 + b3*c2*f1);
- double D = a1*d2*f3 - a1*d3*f2 - a2*d1*f3 + a2*d3*f1 +
- a3*d1*f2 - a3*d2*f1;
- double E = b1*d2*h3 - b1*d3*h2 - b2*d1*h3 + b2*d3*h1 +
- b3*d1*h2 - b3*d2*h1;
- double F = (a1*d2*h3 + b1*d2*f3) - (a1*d3*h2 + b1*d3*f2) -
- (a2*d1*h3 + b2*d1*f3) + (a2*d3*h1 + b2*d3*f1) +
- (a3*d1*h2 + b3*d1*f2) - (a3*d2*h1 + b3*d2*f1);
- double G = a1*e2*f3 - a1*e3*f2 - a2*e1*f3 + a2*e3*f1 +
- a3*e1*f2 - a3*e2*f1;
- double H = b1*e2*h3 - b1*e3*h2 - b2*e1*h3 + b2*e3*h1 +
- b3*e1*h2 - b3*e2*h1;
- double P = (a1*e2*h3 + b1*e2*f3) - (a1*e3*h2 + b1*e3*f2) -
- (a2*e1*h3 + b2*e1*f3) + (a2*e3*h1 + b2*e3*f1) +
- (a3*e1*h2 + b3*e1*f2) - (a3*e2*h1 + b3*e2*f1);
-
- xvolume = -2.0*(2.0*(A + B + D + E + G + H) + C + F + P)/9.0;
-
- //volume[index] = xvolume ;
+ xvolume=CalculateVolumeForPenta(coord+dim_space*N1,coord+dim_space*N2,coord+dim_space*N3,coord+dim_space*N4,coord+dim_space*N5,coord+dim_space*N6);
volume->setIJ(index,1,xvolume) ;
index++;
}
int N6 = global_connectivity[hexa_index+5]-1;
int N7 = global_connectivity[hexa_index+6]-1;
int N8 = global_connectivity[hexa_index+7]-1;
-
- double x1 = coord[dim_space*N1];
- double x2 = coord[dim_space*N2];
- double x3 = coord[dim_space*N3];
- double x4 = coord[dim_space*N4];
- double x5 = coord[dim_space*N5];
- double x6 = coord[dim_space*N6];
- double x7 = coord[dim_space*N7];
- double x8 = coord[dim_space*N8];
-
- double y1 = coord[dim_space*N1+1];
- double y2 = coord[dim_space*N2+1];
- double y3 = coord[dim_space*N3+1];
- double y4 = coord[dim_space*N4+1];
- double y5 = coord[dim_space*N5+1];
- double y6 = coord[dim_space*N6+1];
- double y7 = coord[dim_space*N7+1];
- double y8 = coord[dim_space*N8+1];
-
- double z1 = coord[dim_space*N1+2];
- double z2 = coord[dim_space*N2+2];
- double z3 = coord[dim_space*N3+2];
- double z4 = coord[dim_space*N4+2];
- double z5 = coord[dim_space*N5+2];
- double z6 = coord[dim_space*N6+2];
- double z7 = coord[dim_space*N7+2];
- double z8 = coord[dim_space*N8+2];
-
- double a1 = (x3-x4)/8.0, a2 = (y3-y4)/8.0, a3 = (z3-z4)/8.0;
- double b1 = (x2-x1)/8.0, b2 = (y2-y1)/8.0, b3 = (z2-z1)/8.0;
- double c1 = (x7-x8)/8.0, c2 = (y7-y8)/8.0, c3 = (z7-z8)/8.0;
- double d1 = (x6-x5)/8.0, d2 = (y6-y5)/8.0, d3 = (z6-z5)/8.0;
- double e1 = (x3-x2)/8.0, e2 = (y3-y2)/8.0, e3 = (z3-z2)/8.0;
- double f1 = (x4-x1)/8.0, f2 = (y4-y1)/8.0, f3 = (z4-z1)/8.0;
- double h1 = (x7-x6)/8.0, h2 = (y7-y6)/8.0, h3 = (z7-z6)/8.0;
- double p1 = (x8-x5)/8.0, p2 = (y8-y5)/8.0, p3 = (z8-z5)/8.0;
- double q1 = (x3-x7)/8.0, q2 = (y3-y7)/8.0, q3 = (z3-z7)/8.0;
- double r1 = (x4-x8)/8.0, r2 = (y4-y8)/8.0, r3 = (z4-z8)/8.0;
- double s1 = (x2-x6)/8.0, s2 = (y2-y6)/8.0, s3 = (z2-z6)/8.0;
- double t1 = (x1-x5)/8.0, t2 = (y1-y5)/8.0, t3 = (z1-z5)/8.0;
-
- double A = a1*e2*q3 - a1*e3*q2 - a2*e1*q3 + a2*e3*q1 +
- a3*e1*q2 - a3*e2*q1;
- double B = c1*h2*q3 - c1*h3*q2 - c2*h1*q3 + c2*h3*q1 +
- c3*h1*q2 - c3*h2*q1;
- double C = (a1*h2 + c1*e2)*q3 - (a1*h3 + c1*e3)*q2 -
- (a2*h1 + c2*e1)*q3 + (a2*h3 + c2*e3)*q1 +
- (a3*h1 + c3*e1)*q2 - (a3*h2 + c3*e2)*q1;
- double D = b1*e2*s3 - b1*e3*s2 - b2*e1*s3 + b2*e3*s1 +
- b3*e1*s2 - b3*e2*s1;
- double E = d1*h2*s3 - d1*h3*s2 - d2*h1*s3 + d2*h3*s1 +
- d3*h1*s2 - d3*h2*s1;
- double F = (b1*h2 + d1*e2)*s3 - (b1*h3 + d1*e3)*s2 -
- (b2*h1 + d2*e1)*s3 + (b2*h3 + d2*e3)*s1 +
- (b3*h1 + d3*e1)*s2 - (b3*h2 + d3*e2)*s1;
- double G = (a1*e2*s3 + b1*e2*q3) - (a1*e3*s2 + b1*e3*q2) -
- (a2*e1*s3 + b2*e1*q3) + (a2*e3*s1 + b2*e3*q1) +
- (a3*e1*s2 + b3*e1*q2) - (a3*e2*s1 + b3*e2*q1);
- double H = (c1*h2*s3 + d1*h2*q3) - (c1*h3*s2 + d1*h3*q2) -
- (c2*h1*s3 + d2*h1*q3) + (c2*h3*s1 + d2*h3*q1) +
- (c3*h1*s2 + d3*h1*q2) - (c3*h2*s1 + d3*h2*q1);
- double I = ((a1*h2 + c1*e2)*s3 + (b1*h2 + d1*e2)*q3) -
- ((a1*h3 + c1*e3)*s2 + (b1*h3 + d1*e3)*q2) -
- ((a2*h1 + c2*e1)*s3 + (b2*h1 + d2*e1)*q3) +
- ((a2*h3 + c2*e3)*s1 + (b2*h3 + d2*e3)*q1) +
- ((a3*h1 + c3*e1)*s2 + (b3*h1 + d3*e1)*q2) -
- ((a3*h2 + c3*e2)*s1 + (b3*h2 + d3*e2)*q1);
- double J = a1*f2*r3 - a1*f3*r2 - a2*f1*r3 + a2*f3*r1 +
- a3*f1*r2 - a3*f2*r1;
- double K = c1*p2*r3 - c1*p3*r2 - c2*p1*r3 + c2*p3*r1 +
- c3*p1*r2 - c3*p2*r1;
- double L = (a1*p2 + c1*f2)*r3 - (a1*p3 + c1*f3)*r2 -
- (a2*p1 + c2*f1)*r3 + (a2*p3 + c2*f3)*r1 +
- (a3*p1 + c3*f1)*r2 - (a3*p2 + c3*f2)*r1;
- double M = b1*f2*t3 - b1*f3*t2 - b2*f1*t3 + b2*f3*t1 +
- b3*f1*t2 - b3*f2*t1;
- double N = d1*p2*t3 - d1*p3*t2 - d2*p1*t3 + d2*p3*t1 +
- d3*p1*t2 - d3*p2*t1;
- double O = (b1*p2 + d1*f2)*t3 - (b1*p3 + d1*f3)*t2 -
- (b2*p1 + d2*f1)*t3 + (b2*p3 + d2*f3)*t1 +
- (b3*p1 + d3*f1)*t2 - (b3*p2 + d3*f2)*t1;
- double P = (a1*f2*t3 + b1*f2*r3) - (a1*f3*t2 + b1*f3*r2) -
- (a2*f1*t3 + b2*f1*r3) + (a2*f3*t1 + b2*f3*r1) +
- (a3*f1*t2 + b3*f1*r2) - (a3*f2*t1 + b3*f2*r1);
- double Q = (c1*p2*t3 + d1*p2*r3) - (c1*p3*t2 + d1*p3*r2) -
- (c2*p1*t3 + d2*p1*r3) + (c2*p3*t1 + d2*p3*r1) +
- (c3*p1*t2 + d3*p1*r2) - (c3*p2*t1 + d3*p2*r1);
- double R = ((a1*p2 + c1*f2)*t3 + (b1*p2 + d1*f2)*r3) -
- ((a1*p3 + c1*f3)*t2 + (b1*p3 + d1*f3)*r2) -
- ((a2*p1 + c2*f1)*t3 + (b2*p1 + d2*f1)*r3) +
- ((a2*p3 + c2*f3)*t1 + (b2*p3 + d2*f3)*r1) +
- ((a3*p1 + c3*f1)*t2 + (b3*p1 + d3*f1)*r2) -
- ((a3*p2 + c3*f2)*t1 + (b3*p2 + d3*f2)*r1);
- double S = (a1*e2*r3 + a1*f2*q3) - (a1*e3*r2 + a1*f3*q2) -
- (a2*e1*r3 + a2*f1*q3) + (a2*e3*r1 + a2*f3*q1) +
- (a3*e1*r2 + a3*f1*q2) - (a3*e2*r1 + a3*f2*q1);
- double T = (c1*h2*r3 + c1*p2*q3) - (c1*h3*r2 + c1*p3*q2) -
- (c2*h1*r3 + c2*p1*q3) + (c2*h3*r1 + c2*p3*q1) +
- (c3*h1*r2 + c3*p1*q2) - (c3*h2*r1 + c3*p2*q1);
- double U = ((a1*h2 + c1*e2)*r3 + (a1*p2 + c1*f2)*q3) -
- ((a1*h3 + c1*e3)*r2 + (a1*p3 + c1*f3)*q2) -
- ((a2*h1 + c2*e1)*r3 + (a2*p1 + c2*f1)*q3) +
- ((a2*h3 + c2*e3)*r1 + (a2*p3 + c2*f3)*q1) +
- ((a3*h1 + c3*e1)*r2 + (a3*p1 + c3*f1)*q2) -
- ((a3*h2 + c3*e2)*r1 + (a3*p2 + c3*f2)*q1);
- double V = (b1*e2*t3 + b1*f2*s3) - (b1*e3*t2 + b1*f3*s2) -
- (b2*e1*t3 + b2*f1*s3) + (b2*e3*t1 + b2*f3*s1) +
- (b3*e1*t2 + b3*f1*s2) - (b3*e2*t1 + b3*f2*s1);
- double W = (d1*h2*t3 + d1*p2*s3) - (d1*h3*t2 + d1*p3*s2) -
- (d2*h1*t3 + d2*p1*s3) + (d2*h3*t1 + d2*p3*s1) +
- (d3*h1*t2 + d3*p1*s2) - (d3*h2*t1 + d3*p2*s1);
- double X = ((b1*h2 + d1*e2)*t3 + (b1*p2 + d1*f2)*s3) -
- ((b1*h3 + d1*e3)*t2 + (b1*p3 + d1*f3)*s2) -
- ((b2*h1 + d2*e1)*t3 + (b2*p1 + d2*f1)*s3) +
- ((b2*h3 + d2*e3)*t1 + (b2*p3 + d2*f3)*s1) +
- ((b3*h1 + d3*e1)*t2 + (b3*p1 + d3*f1)*s2) -
- ((b3*h2 + d3*e2)*t1 + (b3*p2 + d3*f2)*s1);
- double Y = (a1*e2*t3 + a1*f2*s3 + b1*e2*r3 + b1*f2*q3) -
- (a1*e3*t2 + a1*f3*s2 + b1*e3*r2 + b1*f3*q2) -
- (a2*e1*t3 + a2*f1*s3 + b2*e1*r3 + b2*f1*q3) +
- (a2*e3*t1 + a2*f3*s1 + b2*e3*r1 + b2*f3*q1) +
- (a3*e1*t2 + a3*f1*s2 + b3*e1*r2 + b3*f1*q2) -
- (a3*e2*t1 + a3*f2*s1 + b3*e2*r1 + b3*f2*q1);
- double Z = (c1*h2*t3 + c1*p2*s3 + d1*h2*r3 + d1*p2*q3) -
- (c1*h3*t2 + c1*p3*s2 + d1*h3*r2 + d1*p3*q2) -
- (c2*h1*t3 + c2*p1*s3 + d2*h1*r3 + d2*p1*q3) +
- (c2*h3*t1 + c2*p3*s1 + d2*h3*r1 + d2*p3*q1) +
- (c3*h1*t2 + c3*p1*s2 + d3*h1*r2 + d3*p1*q2) -
- (c3*h2*t1 + c3*p2*s1 + d3*h2*r1 + d3*p2*q1);
- double AA = ((a1*h2 + c1*e2)*t3 + (a1*p2 + c1*f2)*s3 +
- (b1*h2 + d1*e2)*r3 + (b1*p2 + d1*f2)*q3) -
- ((a1*h3 + c1*e3)*t2 + (a1*p3 + c1*f3)*s2 +
- (b1*h3 + d1*e3)*r2 + (b1*p3 + d1*f3)*q2) -
- ((a2*h1 + c2*e1)*t3 + (a2*p1 + c2*f1)*s3 +
- (b2*h1 + d2*e1)*r3 + (b2*p1 + d2*f1)*q3) +
- ((a2*h3 + c2*e3)*t1 + (a2*p3 + c2*f3)*s1 +
- (b2*h3 + d2*e3)*r1 + (b2*p3 + d2*f3)*q1) +
- ((a3*h1 + c3*e1)*t2 + (a3*p1 + c3*f1)*s2 +
- (b3*h1 + d3*e1)*r2 + (b3*p1 + d3*f1)*q2) -
- ((a3*h2 + c3*e2)*t1 + (a3*p2 + c3*f2)*s1 +
- (b3*h2 + d3*e2)*r1 + (b3*p2 + d3*f2)*q1);
-
- xvolume = 64.0*(8.0*(A + B + D + E + J + K + M + N) +
- 4.0*(C + F + G + H + L + O + P + Q + S + T +
- V + W) + 2.0*(I + R + U + X + Y + Z) +
- AA)/27.0;
-
- //volume[index] = xvolume ;
+ xvolume=CalculateVolumeForHexa(coord+dim_space*N1,coord+dim_space*N2,coord+dim_space*N3,coord+dim_space*N4,coord+dim_space*N5,coord+dim_space*N6,coord+dim_space*N7,coord+dim_space*N8);
volume->setIJ(index,1,xvolume) ;
index++;
}
break;
}
+ case MED_POLYHEDRA:
+ {
+ double bary[3];
+ if(onAll)
+ {
+ for (int polyhs=0;polyhs<nb_entity_type;polyhs++)
+ {
+ int lgthNodes,iPts,iFaces,iPtsInFace;
+ int offsetWithClassicType=getNumberOfElements(support_entity,MED_ALL_ELEMENTS);
+ int *nodes=_connectivity->getNodesOfPolyhedron(offsetWithClassicType+polyhs+1,lgthNodes);
+ int nbOfFaces,*nbOfNodesPerFaces;
+ int **nodes1=_connectivity->getNodesPerFaceOfPolyhedron(offsetWithClassicType+polyhs+1,nbOfFaces,nbOfNodesPerFaces);
+ double **pts=new double * [lgthNodes];
+ double ***pts1=new double ** [nbOfFaces];
+ for(iPts=0;iPts<lgthNodes;iPts++)
+ pts[iPts]=(double *)(coord+3*(nodes[iPts]-1));
+ for(iFaces=0;iFaces<nbOfFaces;iFaces++)
+ {
+ pts1[iFaces]=new double* [nbOfNodesPerFaces[iFaces]];
+ for(iPtsInFace=0;iPtsInFace<nbOfNodesPerFaces[iFaces];iPtsInFace++)
+ pts1[iFaces][iPtsInFace]=(double *)(coord+3*(nodes1[iFaces][iPtsInFace]-1));
+ }
+ delete [] nodes1;
+ CalculateBarycenterDyn((const double **)pts,lgthNodes,3,bary);
+ delete [] nodes;
+ delete [] pts;
+ xvolume=CalculateVolumeForPolyh((const double ***)pts1,nbOfNodesPerFaces,nbOfFaces,bary);
+ delete [] nbOfNodesPerFaces;
+ for(iFaces=0;iFaces<nbOfFaces;iFaces++)
+ delete [] pts1[iFaces];
+ delete [] pts1;
+ volume->setIJ(index,1,xvolume) ;
+ index++;
+ }
+ }
+ else
+ {
+ const int * supp_number = Support->getNumber(MED_EN::MED_POLYHEDRA);
+ for (int polyhs=0;polyhs<nb_entity_type;polyhs++)
+ {
+ int lgthNodes,iPts,iFaces,iPtsInFace;
+ int *nodes=_connectivity->getNodesOfPolyhedron(supp_number[polyhs],lgthNodes);
+ int nbOfFaces,*nbOfNodesPerFaces;
+ int **nodes1=_connectivity->getNodesPerFaceOfPolyhedron(supp_number[polyhs],nbOfFaces,nbOfNodesPerFaces);
+ double **pts=new double * [lgthNodes];
+ double ***pts1=new double ** [nbOfFaces];
+ for(iPts=0;iPts<lgthNodes;iPts++)
+ pts[iPts]=(double *)(coord+3*(nodes[iPts]-1));
+ for(iFaces=0;iFaces<nbOfFaces;iFaces++)
+ {
+ pts1[iFaces]=new double* [nbOfNodesPerFaces[iFaces]];
+ for(iPtsInFace=0;iPtsInFace<nbOfNodesPerFaces[iFaces];iPtsInFace++)
+ pts1[iFaces][iPtsInFace]=(double *)(coord+3*(nodes1[iFaces][iPtsInFace]-1));
+ }
+ delete [] nodes1;
+ CalculateBarycenterDyn((const double **)pts,lgthNodes,3,bary);
+ delete [] nodes;
+ delete [] pts;
+ xvolume=CalculateVolumeForPolyh((const double ***)pts1,nbOfNodesPerFaces,nbOfFaces,bary);
+ delete [] nbOfNodesPerFaces;
+ for(iFaces=0;iFaces<nbOfFaces;iFaces++)
+ delete [] pts1[iFaces];
+ delete [] pts1;
+ volume->setIJ(index,1,xvolume) ;
+ index++;
+ }
+ }
+ break;
+ }
default :
throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Bad Support to get Volumes on it !"));
break;
}
- if (!onAll) delete [] global_connectivity ;
+ if (!onAll && type!=MED_EN::MED_POLYHEDRA)
+ delete [] global_connectivity ;
}
return Volume;
// !!!! WARNING : use of nodal global numbering in the mesh !!!!
const int* global_connectivity;
-// if (onAll)
-// {
-// nb_type = myMesh->getNumberOfTypes(support_entity);
-// length_values = getNumberOfElements(support_entity,MED_ALL_ELEMENTS);
-// types = getTypes(support_entity);
-// }
-// else
- {
- nb_type = Support->getNumberOfTypes();
- length_values = Support->getNumberOfElements(MED_ALL_ELEMENTS);
- types = Support->getTypes();
- }
+ nb_type = Support->getNumberOfTypes();
+ length_values = Support->getNumberOfElements(MED_ALL_ELEMENTS);
+ types = Support->getTypes();
int index;
FIELD<double>* Area;
Area->setOrderNumber(0);
Area->setTime(0.0);
- double *area = new double[length_values];
- //double *area = Area->getValue(MED_FULL_INTERLACE);
+ double *area = (double *)Area->getValue(MED_FULL_INTERLACE);
const double * coord = getCoordinates(MED_FULL_INTERLACE);
index = 0;
for (int i=0;i<nb_type;i++)
{
medGeometryElement type = types[i] ;
- double xarea;
-
- if (onAll)
- {
- nb_entity_type = getNumberOfElements(support_entity,type);
- global_connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,type);
- }
- else
- {
- // throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Support must be on all !"));
-
- nb_entity_type = Support->getNumberOfElements(type);
-
- const int * supp_number = Support->getNumber(type);
- const int * connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,MED_ALL_ELEMENTS);
- const int * connectivityIndex = getConnectivityIndex(MED_NODAL,support_entity);
- int * global_connectivity_tmp = new int[(type%100)*nb_entity_type];
+ nb_entity_type = Support->getNumberOfElements(type);
+ const int *global_connectivityIndex = getConnectivityIndex(MED_NODAL,support_entity);
+ if(type != MED_EN::MED_POLYGON && type != MED_EN::MED_POLYHEDRA)
+ {
+ if (onAll)
+ {
+ global_connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,type);
+ }
+ else
+ {
+ const int * supp_number = Support->getNumber(type);
+ const int * connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,MED_ALL_ELEMENTS);
+ int * global_connectivity_tmp = new int[(type%100)*nb_entity_type];
- for (int k_type = 0; k_type<nb_entity_type; k_type++) {
- for (int j_ent = 0; j_ent<(type%100); j_ent++) {
- global_connectivity_tmp[k_type*(type%100)+j_ent] = connectivity[connectivityIndex[supp_number[k_type]-1]+j_ent-1];
- }
- }
-
- global_connectivity = global_connectivity_tmp ;
-
+ for (int k_type = 0; k_type<nb_entity_type; k_type++) {
+ for (int j_ent = 0; j_ent<(type%100); j_ent++) {
+ global_connectivity_tmp[k_type*(type%100)+j_ent] = connectivity[global_connectivityIndex[supp_number[k_type]-1]+j_ent-1];
+ }
+ }
+ global_connectivity = global_connectivity_tmp ;
+ }
}
-
switch (type)
{
case MED_TRIA3 : case MED_TRIA6 :
int N2 = global_connectivity[tria_index+1]-1;
int N3 = global_connectivity[tria_index+2]-1;
- double x1 = coord[dim_space*N1];
- double x2 = coord[dim_space*N2];
- double x3 = coord[dim_space*N3];
-
- double y1 = coord[dim_space*N1+1];
- double y2 = coord[dim_space*N2+1];
- double y3 = coord[dim_space*N3+1];
-
- if (dim_space==2)
- {
- xarea = - ((x2-x1)*(y3-y1) - (x3-x1)*(y2-y1))/2.0;
- }
- else
- {
- double z1 = coord[dim_space*N1+2];
- double z2 = coord[dim_space*N2+2];
- double z3 = coord[dim_space*N3+2];
-
- xarea = sqrt(((y2-y1)*(z3-z1) - (y3-y1)*(z2-z1))*
- ((y2-y1)*(z3-z1) - (y3-y1)*(z2-z1)) +
- ((x3-x1)*(z2-z1) - (x2-x1)*(z3-z1))*
- ((x3-x1)*(z2-z1) - (x2-x1)*(z3-z1)) +
- ((x2-x1)*(y3-y1) - (x3-x1)*(y2-y1))*
- ((x2-x1)*(y3-y1) - (x3-x1)*(y2-y1)))/2.0;
- }
-
- area[index] = xarea ;
+ area[index]=CalculateAreaForTria(coord+(dim_space*N1),
+ coord+(dim_space*N2),
+ coord+(dim_space*N3),dim_space);
index++;
}
break;
int N2 = global_connectivity[quad_index+1]-1;
int N3 = global_connectivity[quad_index+2]-1;
int N4 = global_connectivity[quad_index+3]-1;
-
- double x1 = coord[dim_space*N1];
- double x2 = coord[dim_space*N2];
- double x3 = coord[dim_space*N3];
- double x4 = coord[dim_space*N4];
-
- double y1 = coord[dim_space*N1+1];
- double y2 = coord[dim_space*N2+1];
- double y3 = coord[dim_space*N3+1];
- double y4 = coord[dim_space*N4+1];
-
- if (dim_space==2)
+
+ area[index]=CalculateAreaForQuad(coord+dim_space*N1,
+ coord+dim_space*N2,
+ coord+dim_space*N3,
+ coord+dim_space*N4,dim_space);
+ index++;
+ }
+ break;
+ }
+ case MED_POLYGON :
+ {
+ if(onAll)
+ {
+ const int * connectivity = getPolygonsConnectivity(MED_EN::MED_NODAL,support_entity);
+ const int * connectivity_index = getPolygonsConnectivityIndex(MED_EN::MED_NODAL,support_entity);
+ for (int polygs=0;polygs<nb_entity_type;polygs++)
{
- double a1 = (x2-x1)/4.0, a2 = (y2-y1)/4.0;
- double b1 = (x3-x4)/4.0, b2 = (y3-y4)/4.0;
- double c1 = (x3-x2)/4.0, c2 = (y3-y2)/4.0;
- double d1 = (x4-x1)/4.0, d2 = (y4-y1)/4.0;
-
- xarea = - 4.0*(b1*c2 - c1*b2 + a1*c2 - c1*a2 + b1*d2 -
- d1*b2 + a1*d2 - d1*a2);
+ int size=connectivity_index[polygs+1]-connectivity_index[polygs];
+ double **pts=new double * [size];
+ for(int iPts=0;iPts<size;iPts++)
+ pts[iPts]=(double *)(coord+dim_space*(connectivity[connectivity_index[polygs]+iPts-1]-1));
+ area[index] = CalculateAreaForPolyg((const double **)pts,size,dim_space);
+ delete [] pts;
+ index++;
}
- else
+ }
+ else
+ {
+ const int * supp_number = Support->getNumber(MED_EN::MED_POLYGON);
+ const int * connectivity = getPolygonsConnectivity(MED_EN::MED_NODAL,support_entity);
+ const int * connectivity_index = getPolygonsConnectivityIndex(MED_EN::MED_NODAL,support_entity);
+ int offsetWithClassicType=getNumberOfElements(support_entity,MED_ALL_ELEMENTS);
+ for (int polygs=0;polygs<nb_entity_type;polygs++)
{
- double z1 = coord[dim_space*N1+2];
- double z2 = coord[dim_space*N2+2];
- double z3 = coord[dim_space*N3+2];
- double z4 = coord[dim_space*N4+2];
-
- xarea = (sqrt(((y2-y1)*(z4-z1) - (y4-y1)*(z2-z1))*
- ((y2-y1)*(z4-z1) - (y4-y1)*(z2-z1)) +
- ((x4-x1)*(z2-z1) - (x2-x1)*(z4-z1))*
- ((x4-x1)*(z2-z1) - (x2-x1)*(z4-z1)) +
- ((x2-x1)*(y4-y1) - (x4-x1)*(y2-y1))*
- ((x2-x1)*(y4-y1) - (x4-x1)*(y2-y1))) +
- sqrt(((y4-y3)*(z2-z3) - (y2-y3)*(z4-z3))*
- ((y4-y3)*(z2-z3) - (y2-y3)*(z4-z3)) +
- ((x2-x3)*(z4-z3) - (x4-x3)*(z2-z3))*
- ((x2-x3)*(z4-z3) - (x4-x3)*(z2-z3)) +
- ((x4-x3)*(y2-y3) - (x2-x3)*(y4-y3))*
- ((x4-x3)*(y2-y3) - (x2-x3)*(y4-y3))))/2.0;
+ int size=connectivity_index[supp_number[polygs]-offsetWithClassicType]-connectivity_index[supp_number[polygs]-offsetWithClassicType-1];
+ double **pts=new double * [size];
+ for(int iPts=0;iPts<size;iPts++)
+ pts[iPts]=(double *)(coord+dim_space*(connectivity[connectivity_index[supp_number[polygs]-offsetWithClassicType-1]+iPts-1]-1));
+ area[index]=CalculateAreaForPolyg((const double **)pts,size,dim_space);
+ delete [] pts;
+ index++;
}
-
- area[index] = xarea ;
- index++;
}
break;
}
break;
}
- if (!onAll) delete [] global_connectivity ;
+ if (!onAll)
+ if(type != MED_EN::MED_POLYGON && type != MED_EN::MED_POLYHEDRA)
+ delete [] global_connectivity ;
}
-
- Area->setValue(MED_FULL_INTERLACE,area);
- delete[] area;
return Area;
}
// !!!! WARNING : use of nodal global numbering in the mesh !!!!
const int* global_connectivity;
-// if (onAll)
-// {
-// nb_type = myMesh->getNumberOfTypes(support_entity);
-// length_values = getNumberOfElements(support_entity,MED_ALL_ELEMENTS);
-// types = getTypes(support_entity);
-// }
-// else
- {
- nb_type = Support->getNumberOfTypes();
- length_values = Support->getNumberOfElements(MED_ALL_ELEMENTS);
- types = Support->getTypes();
- }
+ nb_type = Support->getNumberOfTypes();
+ length_values = Support->getNumberOfElements(MED_ALL_ELEMENTS);
+ types = Support->getTypes();
int index;
FIELD<double>* Length;
}
else
{
- //throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Support must be on all !"));
-
nb_entity_type = Support->getNumberOfElements(type);
-
const int * supp_number = Support->getNumber(type);
const int * connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,MED_ALL_ELEMENTS);
const int * connectivityIndex = getConnectivityIndex(MED_NODAL,support_entity);
throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"no compatibility between *this and SUPPORT::_mesh : pointeur problem !"));
int dim_space = getSpaceDimension();
+ int mesh_dim=getMeshDimension();
medEntityMesh support_entity = Support->getEntity();
bool onAll = Support->isOnAllElements();
+ if( support_entity!=MED_EDGE && (mesh_dim!=1 || support_entity!=MED_CELL) && ( mesh_dim!=2 || support_entity!=MED_CELL ) && ( mesh_dim!=3 || support_entity!=MED_FACE ))
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"incompatible mesh dimension and entity"));
int nb_type, length_values;
const medGeometryElement* types;
int nb_entity_type;
// !!!! WARNING : use of nodal global numbering in the mesh !!!!
const int* global_connectivity;
-// if (onAll)
-// {
-// nb_type = myMesh->getNumberOfTypes(support_entity);
-// length_values = getNumberOfElements(support_entity,MED_ALL_ELEMENTS);
-// types = getTypes(support_entity);
-// }
-// else
- {
- nb_type = Support->getNumberOfTypes();
- length_values = Support->getNumberOfElements(MED_ALL_ELEMENTS);
- types = Support->getTypes();
- }
+ nb_type = Support->getNumberOfTypes();
+ length_values = Support->getNumberOfElements(MED_ALL_ELEMENTS);
+ types = Support->getTypes();
int index;
Normal->setIterationNumber(MED_NOPDT);
Normal->setOrderNumber(MED_NONOR);
Normal->setTime(0.0);
-
- double * normal = new double [dim_space*length_values];
- //double *normal = Normal->getValue(MED_FULL_INTERLACE);
+ double *normal = (double *)Normal->getValue(MED_FULL_INTERLACE);
const double * coord = getCoordinates(MED_FULL_INTERLACE);
index = 0;
for (int i=0;i<nb_type;i++)
{
medGeometryElement type = types[i] ;
-
+ nb_entity_type = Support->getNumberOfElements(type);
+
// Make sure we trying to get Normals on
// TRIA3 or TRIA6 or QUAD4 QUAD8 (2D) cells on a 3D mesh
// or on SEG2 or SEG3 (1D) cells on a 2D mesh
if ( (((type==MED_TRIA3) || (type==MED_TRIA6) ||
- (type==MED_QUAD4) || (type==MED_QUAD8)) &&
+ (type==MED_QUAD4) || (type==MED_QUAD8) || (type==MED_POLYGON)) &&
(dim_space != 3)) || (((type==MED_SEG2) || (type==MED_SEG3)) &&
(dim_space != 2)) )
throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"no compatibility between *this and SUPPORT::_mesh : dimension problem !"));
-
- double xnormal1, xnormal2, xnormal3 ;
-
- if (onAll)
- {
- nb_entity_type = getNumberOfElements(support_entity,type);
- global_connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,type);
- }
- else
+ if(type != MED_EN::MED_POLYGON && type != MED_EN::MED_POLYHEDRA)
{
- // throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Support must be on all for instance !"));
- nb_entity_type = Support->getNumberOfElements(type);
-
- const int * supp_number = Support->getNumber(type);
- const int * connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,MED_ALL_ELEMENTS);
- const int * connectivityIndex = getConnectivityIndex(MED_NODAL,support_entity);
- int * global_connectivity_tmp = new int[(type%100)*nb_entity_type];
-
- for (int k_type = 0; k_type<nb_entity_type; k_type++) {
- for (int j_ent = 0; j_ent<(type%100); j_ent++) {
- global_connectivity_tmp[k_type*(type%100)+j_ent] = connectivity[connectivityIndex[supp_number[k_type]-1]+j_ent-1];
- }
- }
-
- global_connectivity = global_connectivity_tmp ;
-
+ if (onAll)
+ {
+ global_connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,type);
+ }
+ else
+ {
+ const int * supp_number = Support->getNumber(type);
+ const int * connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,MED_ALL_ELEMENTS);
+ const int * connectivityIndex = getConnectivityIndex(MED_NODAL,support_entity);
+ int * global_connectivity_tmp = new int[(type%100)*nb_entity_type];
+
+ for (int k_type = 0; k_type<nb_entity_type; k_type++) {
+ for (int j_ent = 0; j_ent<(type%100); j_ent++) {
+ global_connectivity_tmp[k_type*(type%100)+j_ent] = connectivity[connectivityIndex[supp_number[k_type]-1]+j_ent-1];
+ }
+ }
+
+ global_connectivity = global_connectivity_tmp ;
+ }
}
switch (type)
for (int tria=0;tria<nb_entity_type;tria++)
{
int tria_index = (type%100)*tria;
-
int N1 = global_connectivity[tria_index]-1;
int N2 = global_connectivity[tria_index+1]-1;
int N3 = global_connectivity[tria_index+2]-1;
-
- //double xarea; !! UNUSED VARIABLE !!
- double x1 = coord[dim_space*N1];
- double x2 = coord[dim_space*N2];
- double x3 = coord[dim_space*N3];
-
- double y1 = coord[dim_space*N1+1];
- double y2 = coord[dim_space*N2+1];
- double y3 = coord[dim_space*N3+1];
-
- double z1 = coord[dim_space*N1+2];
- double z2 = coord[dim_space*N2+2];
- double z3 = coord[dim_space*N3+2];
-
- xnormal1 = ((y2-y1)*(z3-z1) - (y3-y1)*(z2-z1))/2.0;
- xnormal2 = ((x3-x1)*(z2-z1) - (x2-x1)*(z3-z1))/2.0;
- xnormal3 = ((x2-x1)*(y3-y1) - (x3-x1)*(y2-y1))/2.0;
-
- normal[3*index] = xnormal1 ;
- normal[3*index+1] = xnormal2 ;
- normal[3*index+2] = xnormal3 ;
-
+ CalculateNormalForTria(coord+dim_space*N1,coord+dim_space*N2,coord+dim_space*N3,normal+3*index);
index++;
}
break;
for (int quad=0;quad<nb_entity_type;quad++)
{
int quad_index = (type%100)*quad;
-
int N1 = global_connectivity[quad_index]-1;
int N2 = global_connectivity[quad_index+1]-1;
int N3 = global_connectivity[quad_index+2]-1;
int N4 = global_connectivity[quad_index+3]-1;
-
- double xarea;
- double x1 = coord[dim_space*N1];
- double x2 = coord[dim_space*N2];
- double x3 = coord[dim_space*N3];
- double x4 = coord[dim_space*N4];
-
- double y1 = coord[dim_space*N1+1];
- double y2 = coord[dim_space*N2+1];
- double y3 = coord[dim_space*N3+1];
- double y4 = coord[dim_space*N4+1];
-
- double z1 = coord[dim_space*N1+2];
- double z2 = coord[dim_space*N2+2];
- double z3 = coord[dim_space*N3+2];
- double z4 = coord[dim_space*N4+2];
-
- xnormal1 = (y2-y1)*(z4-z1) - (y4-y1)*(z2-z1);
- xnormal2 = (x4-x1)*(z2-z1) - (x2-x1)*(z4-z1);
- xnormal3 = (x2-x1)*(y4-y1) - (x4-x1)*(y2-y1);
- xarea = sqrt(xnormal1*xnormal1 + xnormal2*xnormal2 +
- xnormal3*xnormal3);
-
- xnormal1 = xnormal1/xarea;
- xnormal2 = xnormal2/xarea;
- xnormal3 = xnormal3/xarea;
-
- xarea = (sqrt(((y2-y1)*(z4-z1) - (y4-y1)*(z2-z1))*
- ((y2-y1)*(z4-z1) - (y4-y1)*(z2-z1)) +
- ((x4-x1)*(z2-z1) - (x2-x1)*(z4-z1))*
- ((x4-x1)*(z2-z1) - (x2-x1)*(z4-z1)) +
- ((x2-x1)*(y4-y1) - (x4-x1)*(y2-y1))*
- ((x2-x1)*(y4-y1) - (x4-x1)*(y2-y1))) +
- sqrt(((y4-y3)*(z2-z3) - (y2-y3)*(z4-z3))*
- ((y4-y3)*(z2-z3) - (y2-y3)*(z4-z3)) +
- ((x2-x3)*(z4-z3) - (x4-x3)*(z2-z3))*
- ((x2-x3)*(z4-z3) - (x4-x3)*(z2-z3)) +
- ((x4-x3)*(y2-y3) - (x2-x3)*(y4-y3))*
- ((x4-x3)*(y2-y3) - (x2-x3)*(y4-y3))))/2.0;
-
-// sqrt(((y3-y2)*(z4-z3) - (y4-y3)*(z3-z2))*
-// ((y3-y2)*(z4-z3) - (y4-y3)*(z3-z2)) +
-// ((x4-x3)*(z2-z2) - (x3-x2)*(z4-z3))*
-// ((x4-x3)*(z4-z2) - (x3-x2)*(z4-z3)) +
-// ((x3-x2)*(y4-y3) - (x4-x3)*(y3-y2))*
-// ((x3-x2)*(y4-y3) - (x4-x3)*(y3-y2))))/2.0;
-
- xnormal1 = xnormal1*xarea;
- xnormal2 = xnormal2*xarea;
- xnormal3 = xnormal3*xarea;
-
- normal[3*index] = xnormal1 ;
- normal[3*index+1] = xnormal2 ;
- normal[3*index+2] = xnormal3 ;
-
+ CalculateNormalForQuad(coord+dim_space*N1,coord+dim_space*N2,coord+dim_space*N3,coord+dim_space*N4,normal+3*index);
index++;
}
break;
}
case MED_SEG2 : case MED_SEG3 :
{
+ double xnormal1, xnormal2;
for (int edge=0;edge<nb_entity_type;edge++)
{
int edge_index = (type%100)*edge;
}
break;
}
+ case MED_POLYGON :
+ {
+ if(onAll)
+ {
+ const int * connectivity = getPolygonsConnectivity(MED_EN::MED_NODAL,support_entity);
+ const int * connectivity_index = getPolygonsConnectivityIndex(MED_EN::MED_NODAL,support_entity);
+ for (int polygs=0;polygs<nb_entity_type;polygs++)
+ {
+ int size=connectivity_index[polygs+1]-connectivity_index[polygs];
+ double **pts=new double * [size];
+ for(int iPts=0;iPts<size;iPts++)
+ pts[iPts]=(double *)(coord+dim_space*(connectivity[connectivity_index[polygs]+iPts-1])-1);
+ CalculateNormalForPolyg((const double **)pts,size,normal+3*index);
+ delete [] pts;
+ index++;
+ }
+ }
+ else
+ {
+ const int * supp_number = Support->getNumber(MED_EN::MED_POLYGON);
+ const int * connectivity = getPolygonsConnectivity(MED_EN::MED_NODAL,support_entity);
+ const int * connectivity_index = getPolygonsConnectivityIndex(MED_EN::MED_NODAL,support_entity);
+ int offsetWithClassicType=getNumberOfElements(support_entity,MED_ALL_ELEMENTS);
+ for (int polygs=0;polygs<nb_entity_type;polygs++)
+ {
+ int localPolygsNbP1=supp_number[polygs]-offsetWithClassicType;
+ int size=connectivity_index[localPolygsNbP1]-connectivity_index[localPolygsNbP1-1];
+ double **pts=new double * [size];
+ for(int iPts=0;iPts<size;iPts++)
+ pts[iPts]=(double *)(coord+dim_space*(connectivity[connectivity_index[localPolygsNbP1-1]+iPts-1])-1);
+ CalculateNormalForPolyg((const double **)pts,size,normal+3*index);
+ delete [] pts;
+ index++;
+ }
+ }
+ break;
+ }
default :
throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Bad Support to get Normals on it !"));
break;
}
-
- if (!onAll) delete [] global_connectivity ;
+ if (!onAll && type!=MED_EN::MED_POLYGON)
+ delete [] global_connectivity ;
}
-
- Normal->setValue(MED_FULL_INTERLACE,normal);
- delete[] normal ;
-
END_OF(LOC);
return Normal;
FIELD<double>* MESH::getBarycenter(const SUPPORT * Support) const throw (MEDEXCEPTION)
{
const char * LOC = "MESH::getBarycenter(SUPPORT*) : ";
- BEGIN_OF(LOC);
-
- // Make sure that the MESH class is the same as the MESH class attribut
- // in the class Support
MESH* myMesh = Support->getMesh();
if (this != myMesh)
throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"no compatibility between *this and SUPPORT::_mesh !"));
int nb_type, length_values;
const medGeometryElement* types;
int nb_entity_type;
- // !!!! WARNING : use of nodal global numbering in the mesh !!!!
const int* global_connectivity;
+ const int * global_connectivityIndex;
-// if (onAll)
-// {
-// nb_type = myMesh->getNumberOfTypes(support_entity);
-// length_values = getNumberOfElements(support_entity,MED_ALL_ELEMENTS);
-// types = getTypes(support_entity);
-// }
-// else
- {
- nb_type = Support->getNumberOfTypes();
- length_values = Support->getNumberOfElements(MED_ALL_ELEMENTS);
- types = Support->getTypes();
- }
+ nb_type = Support->getNumberOfTypes();
+ length_values = Support->getNumberOfElements(MED_ALL_ELEMENTS);
+ types = Support->getTypes();
- int index;
FIELD<double>* Barycenter;
-
Barycenter = new FIELD<double>(Support,dim_space);
Barycenter->setName("BARYCENTER");
Barycenter->setDescription("cells or faces barycenter");
Barycenter->setComponentDescription(kp1,"desc-comp");
Barycenter->setMEDComponentUnit(kp1,myMesh->getCoordinatesUnits()[k]);
}
-
Barycenter->setValueType(MED_REEL64);
-
Barycenter->setIterationNumber(0);
Barycenter->setOrderNumber(0);
Barycenter->setTime(0.0);
-
- double *barycenter = new double [dim_space*length_values];
- // double *barycenter = Barycenter->getValue(MED_FULL_INTERLACE);
-
+ double *barycenter=(double *)Barycenter->getValue(MED_FULL_INTERLACE);
const double * coord = getCoordinates(MED_FULL_INTERLACE);
- index = 0;
-
+ int index=0;
for (int i=0;i<nb_type;i++)
{
medGeometryElement type = types[i] ;
- double xbarycenter1, xbarycenter2, xbarycenter3;
-
- if (onAll)
- {
- nb_entity_type = getNumberOfElements(support_entity,type);
- global_connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,type);
- }
- else
+ nb_entity_type = Support->getNumberOfElements(type);
+ global_connectivityIndex = getConnectivityIndex(MED_NODAL,support_entity);
+ if(type != MED_EN::MED_POLYGON && type != MED_EN::MED_POLYHEDRA )
{
- // throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Support must be on all !"));
- nb_entity_type = Support->getNumberOfElements(type);
-
- const int * supp_number = Support->getNumber(type);
- const int * connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,MED_ALL_ELEMENTS);
- const int * connectivityIndex = getConnectivityIndex(MED_NODAL,support_entity);
- int * global_connectivity_tmp = new int[(type%100)*nb_entity_type];
-
- for (int k_type = 0; k_type<nb_entity_type; k_type++) {
- for (int j_ent = 0; j_ent<(type%100); j_ent++) {
- global_connectivity_tmp[k_type*(type%100)+j_ent] = connectivity[connectivityIndex[supp_number[k_type]-1]+j_ent-1];
- }
- }
- global_connectivity = global_connectivity_tmp;
+ if (onAll)
+ {
+ global_connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,type);
+ }
+ else
+ {
+ const int * supp_number = Support->getNumber(type);
+ const int * connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,MED_ALL_ELEMENTS);
+ int * global_connectivity_tmp = new int[(type%100)*nb_entity_type];
+
+ for (int k_type = 0; k_type<nb_entity_type; k_type++) {
+ for (int j_ent = 0; j_ent<(type%100); j_ent++) {
+ global_connectivity_tmp[k_type*(type%100)+j_ent] = connectivity[global_connectivityIndex[supp_number[k_type]-1]+j_ent-1];
+ }
+ }
+ global_connectivity = global_connectivity_tmp;
+ }
}
switch (type)
int N2 = global_connectivity[tetra_index+1]-1;
int N3 = global_connectivity[tetra_index+2]-1;
int N4 = global_connectivity[tetra_index+3]-1;
-
- double x1 = coord[dim_space*N1];
- double x2 = coord[dim_space*N2];
- double x3 = coord[dim_space*N3];
- double x4 = coord[dim_space*N4];
-
- double y1 = coord[dim_space*N1+1];
- double y2 = coord[dim_space*N2+1];
- double y3 = coord[dim_space*N3+1];
- double y4 = coord[dim_space*N4+1];
-
- double z1 = coord[dim_space*N1+2];
- double z2 = coord[dim_space*N2+2];
- double z3 = coord[dim_space*N3+2];
- double z4 = coord[dim_space*N4+2];
-
- xbarycenter1 = (x1 + x2 + x3 + x4)/4.0;
- xbarycenter2 = (y1 + y2 + y3 + y4)/4.0;
- xbarycenter3 = (z1 + z2 + z3 + z4)/4.0;
- barycenter[3*index] = xbarycenter1 ;
- barycenter[3*index+1] = xbarycenter2 ;
- barycenter[3*index+2] = xbarycenter3 ;
+ double *pts[4];
+ pts[0]=(double *)coord+dim_space*N1;
+ pts[1]=(double *)coord+dim_space*N2;
+ pts[2]=(double *)coord+dim_space*N3;
+ pts[3]=(double *)coord+dim_space*N4;
+ CalculateBarycenter<4,3>((const double **)pts,barycenter+3*index);
index++;
}
break;
int N3 = global_connectivity[pyra_index+2]-1;
int N4 = global_connectivity[pyra_index+3]-1;
int N5 = global_connectivity[pyra_index+4]-1;
-
- double x1 = coord[dim_space*N1];
- double x2 = coord[dim_space*N2];
- double x3 = coord[dim_space*N3];
- double x4 = coord[dim_space*N4];
- double x5 = coord[dim_space*N5];
-
- double y1 = coord[dim_space*N1+1];
- double y2 = coord[dim_space*N2+1];
- double y3 = coord[dim_space*N3+1];
- double y4 = coord[dim_space*N4+1];
- double y5 = coord[dim_space*N5+1];
-
- double z1 = coord[dim_space*N1+2];
- double z2 = coord[dim_space*N2+2];
- double z3 = coord[dim_space*N3+2];
- double z4 = coord[dim_space*N4+2];
- double z5 = coord[dim_space*N5+2];
-
- xbarycenter1 = (x1 + x2 + x3 + x4 + x5)/5.0;
- xbarycenter2 = (y1 + y2 + y3 + y4 + y5)/5.0;
- xbarycenter3 = (z1 + z2 + z3 + z4 + z5)/5.0;
- barycenter[3*index] = xbarycenter1 ;
- barycenter[3*index+1] = xbarycenter2 ;
- barycenter[3*index+2] = xbarycenter3 ;
+ double *pts[5];
+ pts[0]=(double *)coord+dim_space*N1;
+ pts[1]=(double *)coord+dim_space*N2;
+ pts[2]=(double *)coord+dim_space*N3;
+ pts[3]=(double *)coord+dim_space*N4;
+ pts[4]=(double *)coord+dim_space*N5;
+ CalculateBarycenter<5,3>((const double **)pts,barycenter+3*index);
index++;
}
break;
int N4 = global_connectivity[penta_index+3]-1;
int N5 = global_connectivity[penta_index+4]-1;
int N6 = global_connectivity[penta_index+5]-1;
-
- double x1 = coord[dim_space*N1];
- double x2 = coord[dim_space*N2];
- double x3 = coord[dim_space*N3];
- double x4 = coord[dim_space*N4];
- double x5 = coord[dim_space*N5];
- double x6 = coord[dim_space*N6];
-
- double y1 = coord[dim_space*N1+1];
- double y2 = coord[dim_space*N2+1];
- double y3 = coord[dim_space*N3+1];
- double y4 = coord[dim_space*N4+1];
- double y5 = coord[dim_space*N5+1];
- double y6 = coord[dim_space*N6+1];
-
- double z1 = coord[dim_space*N1+2];
- double z2 = coord[dim_space*N2+2];
- double z3 = coord[dim_space*N3+2];
- double z4 = coord[dim_space*N4+2];
- double z5 = coord[dim_space*N5+2];
- double z6 = coord[dim_space*N6+2];
-
- xbarycenter1 = (x1 + x2 + x3 + x4 + x5 + x6)/6.0;
- xbarycenter2 = (y1 + y2 + y3 + y4 + y5 + y6)/6.0;
- xbarycenter3 = (z1 + z2 + z3 + z4 + z5 + z6)/6.0;
- barycenter[3*index] = xbarycenter1 ;
- barycenter[3*index+1] = xbarycenter2 ;
- barycenter[3*index+2] = xbarycenter3 ;
+ double *pts[6];
+ pts[0]=(double *)coord+dim_space*N1;
+ pts[1]=(double *)coord+dim_space*N2;
+ pts[2]=(double *)coord+dim_space*N3;
+ pts[3]=(double *)coord+dim_space*N4;
+ pts[4]=(double *)coord+dim_space*N5;
+ pts[5]=(double *)coord+dim_space*N6;
+ CalculateBarycenter<6,3>((const double **)pts,barycenter+3*index);
index++;
}
break;
int N6 = global_connectivity[hexa_index+5]-1;
int N7 = global_connectivity[hexa_index+6]-1;
int N8 = global_connectivity[hexa_index+7]-1;
-
- double x1 = coord[dim_space*N1];
- double x2 = coord[dim_space*N2];
- double x3 = coord[dim_space*N3];
- double x4 = coord[dim_space*N4];
- double x5 = coord[dim_space*N5];
- double x6 = coord[dim_space*N6];
- double x7 = coord[dim_space*N7];
- double x8 = coord[dim_space*N8];
-
- double y1 = coord[dim_space*N1+1];
- double y2 = coord[dim_space*N2+1];
- double y3 = coord[dim_space*N3+1];
- double y4 = coord[dim_space*N4+1];
- double y5 = coord[dim_space*N5+1];
- double y6 = coord[dim_space*N6+1];
- double y7 = coord[dim_space*N7+1];
- double y8 = coord[dim_space*N8+1];
-
- double z1 = coord[dim_space*N1+2];
- double z2 = coord[dim_space*N2+2];
- double z3 = coord[dim_space*N3+2];
- double z4 = coord[dim_space*N4+2];
- double z5 = coord[dim_space*N5+2];
- double z6 = coord[dim_space*N6+2];
- double z7 = coord[dim_space*N7+2];
- double z8 = coord[dim_space*N8+2];
-
- xbarycenter1 = (x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8)/8.0;
- xbarycenter2 = (y1 + y2 + y3 + y4 + y5 + y6 + y7 + y8)/8.0;
- xbarycenter3 = (z1 + z2 + z3 + z4 + z5 + z6 + z7 + z8)/8.0;
-
- barycenter[3*index] = xbarycenter1 ;
- barycenter[3*index+1] = xbarycenter2 ;
- barycenter[3*index+2] = xbarycenter3 ;
-
+ double *pts[8];
+ pts[0]=(double *)coord+dim_space*N1;
+ pts[1]=(double *)coord+dim_space*N2;
+ pts[2]=(double *)coord+dim_space*N3;
+ pts[3]=(double *)coord+dim_space*N4;
+ pts[4]=(double *)coord+dim_space*N5;
+ pts[5]=(double *)coord+dim_space*N6;
+ pts[6]=(double *)coord+dim_space*N7;
+ pts[7]=(double *)coord+dim_space*N8;
+ CalculateBarycenter<8,3>((const double **)pts,barycenter+3*index);
index++;
}
break;
for (int tria=0;tria<nb_entity_type;tria++)
{
int tria_index = (type%100)*tria;
-
int N1 = global_connectivity[tria_index]-1;
int N2 = global_connectivity[tria_index+1]-1;
int N3 = global_connectivity[tria_index+2]-1;
-
- double x1 = coord[dim_space*N1];
- double x2 = coord[dim_space*N2];
- double x3 = coord[dim_space*N3];
-
- double y1 = coord[dim_space*N1+1];
- double y2 = coord[dim_space*N2+1];
- double y3 = coord[dim_space*N3+1];
-
- xbarycenter1 = (x1 + x2 + x3)/3.0;
- xbarycenter2 = (y1 + y2 + y3)/3.0;
-
+ double *pts[3];
+ pts[0]=(double *)coord+dim_space*N1;
+ pts[1]=(double *)coord+dim_space*N2;
+ pts[2]=(double *)coord+dim_space*N3;
if (dim_space==2)
- {
- barycenter[2*index] = xbarycenter1 ;
- barycenter[2*index+1] = xbarycenter2 ;
- }
+ CalculateBarycenter<3,2>((const double **)pts,barycenter+2*index);
else
- {
- double z1 =
- coord[dim_space*N1+2];
- double z2 =
- coord[dim_space*N2+2];
- double z3 =
- coord[dim_space*N3+2];
-
- xbarycenter3 = (z1 + z2 + z3)/3.0;
-
- barycenter[3*index] = xbarycenter1 ;
- barycenter[3*index+1] = xbarycenter2 ;
- barycenter[3*index+2] = xbarycenter3 ;
- }
-
+ CalculateBarycenter<3,3>((const double **)pts,barycenter+3*index);
index++;
}
break;
for (int quad=0;quad<nb_entity_type;quad++)
{
int quad_index = (type%100)*quad;
-
int N1 = global_connectivity[quad_index]-1;
int N2 = global_connectivity[quad_index+1]-1;
int N3 = global_connectivity[quad_index+2]-1;
int N4 = global_connectivity[quad_index+3]-1;
-
- double x1 = coord[dim_space*N1];
- double x2 = coord[dim_space*N2];
- double x3 = coord[dim_space*N3];
- double x4 = coord[dim_space*N4];
-
- double y1 = coord[dim_space*N1+1];
- double y2 = coord[dim_space*N2+1];
- double y3 = coord[dim_space*N3+1];
- double y4 = coord[dim_space*N4+1];
-
- xbarycenter1 = (x1 + x2 + x3 + x4)/4.0;
- xbarycenter2 = (y1 + y2 + y3 + y4)/4.0;
-
+ double *pts[4];
+ pts[0]=(double *)coord+dim_space*N1;
+ pts[1]=(double *)coord+dim_space*N2;
+ pts[2]=(double *)coord+dim_space*N3;
+ pts[3]=(double *)coord+dim_space*N4;
if (dim_space==2)
- {
- barycenter[2*index] = xbarycenter1 ;
- barycenter[2*index+1] = xbarycenter2 ;
- }
+ CalculateBarycenter<4,2>((const double **)pts,barycenter+2*index);
else
- {
- double z1 = coord[dim_space*N1+2];
- double z2 = coord[dim_space*N2+2];
- double z3 = coord[dim_space*N3+2];
- double z4 = coord[dim_space*N4+2];
-
- xbarycenter3 = (z1 + z2 + z3 + z4)/4.0;
-
- barycenter[3*index] = xbarycenter1 ;
- barycenter[3*index+1] = xbarycenter2 ;
- barycenter[3*index+2] = xbarycenter3 ;
- }
+ CalculateBarycenter<4,3>((const double **)pts,barycenter+3*index);
index++;
}
break;
for (int edge=0;edge<nb_entity_type;edge++)
{
int edge_index = (type%100)*edge;
-
int N1 = global_connectivity[edge_index]-1;
int N2 = global_connectivity[edge_index+1]-1;
-
- double x1 = coord[dim_space*N1];
- double x2 = coord[dim_space*N2];
-
- double y1 = coord[dim_space*N1+1];
- double y2 = coord[dim_space*N2+1];
-
- xbarycenter1 = (x1 + x2)/2.0;
- xbarycenter2 = (y1 + y2)/2.0;
-
+ double *pts[2];
+ pts[0]=(double *)coord+dim_space*N1;
+ pts[1]=(double *)coord+dim_space*N2;
if (dim_space==2)
+ CalculateBarycenter<2,2>((const double **)pts,barycenter+2*index);
+ else
+ CalculateBarycenter<2,3>((const double **)pts,barycenter+3*index);
+ index++;
+ }
+ break;
+ }
+ case MED_POLYGON :
+ {
+ if(onAll)
+ {
+ const int * connectivity = getPolygonsConnectivity(MED_EN::MED_NODAL,support_entity);
+ const int * connectivity_index = getPolygonsConnectivityIndex(MED_EN::MED_NODAL,support_entity);
+ for (int polygs=0;polygs<nb_entity_type;polygs++)
{
- barycenter[2*index] = xbarycenter1 ;
- barycenter[2*index+1] = xbarycenter2 ;
+ int size=connectivity_index[polygs+1]-connectivity_index[polygs];
+ double **pts=new double * [size];
+ for(int iPts=0;iPts<size;iPts++)
+ pts[iPts]=(double *)coord+dim_space*(connectivity[connectivity_index[polygs]+iPts-1]-1);
+ CalculateBarycenterDyn((const double **)pts,size,dim_space,barycenter+dim_space*index);
+ delete [] pts;
}
- else
+ }
+ else
+ {
+ const int * supp_number = Support->getNumber(MED_EN::MED_POLYGON);
+ const int * connectivity = getPolygonsConnectivity(MED_EN::MED_NODAL,support_entity);
+ const int * connectivity_index = getPolygonsConnectivityIndex(MED_EN::MED_NODAL,support_entity);
+ int offsetWithClassicType=getNumberOfElements(support_entity,MED_ALL_ELEMENTS);
+ for (int polygs=0;polygs<nb_entity_type;polygs++)
{
- double z1 = coord[dim_space*N1+2];
- double z2 = coord[dim_space*N2+2];
-
- xbarycenter3 = (z1 + z2)/2.0;
-
- barycenter[3*index] = xbarycenter1 ;
- barycenter[3*index+1] = xbarycenter2 ;
- barycenter[3*index+2] = xbarycenter3 ;
+ int localPolygsNbP1=supp_number[polygs]-offsetWithClassicType;
+ int size=connectivity_index[localPolygsNbP1]-connectivity_index[localPolygsNbP1-1];
+ double **pts=new double * [size];
+ for(int iPts=0;iPts<size;iPts++)
+ pts[iPts]=(double *)coord+dim_space*(connectivity[connectivity_index[localPolygsNbP1-1]+iPts-1]-1);
+ CalculateBarycenterDyn((const double **)pts,size,dim_space,barycenter+dim_space*index);
+ delete [] pts;
+ }
+ }
+ index++;
+ break;
+ }
+ case MED_EN::MED_POLYHEDRA:
+ {
+ if(onAll)
+ {
+ for (int polyhs=0;polyhs<nb_entity_type;polyhs++)
+ {
+ int lgthNodes;
+ int offsetWithClassicType=getNumberOfElements(support_entity,MED_ALL_ELEMENTS);
+ int *nodes=_connectivity->getNodesOfPolyhedron(offsetWithClassicType+polyhs+1,lgthNodes);
+ double **pts=new double * [lgthNodes];
+ for(int iPts=0;iPts<lgthNodes;iPts++)
+ pts[iPts]=(double *)coord+3*(nodes[iPts]-1);
+ CalculateBarycenterDyn((const double **)pts,lgthNodes,3,barycenter+3*index);
+ delete [] pts;
+ delete [] nodes;
+ index++;
+ }
+ }
+ else
+ {
+ const int * supp_number = Support->getNumber(MED_EN::MED_POLYHEDRA);
+ for (int polyhs=0;polyhs<nb_entity_type;polyhs++)
+ {
+ int lgthNodes;
+ int *nodes=_connectivity->getNodesOfPolyhedron(supp_number[polyhs],lgthNodes);
+ double **pts=new double * [lgthNodes];
+ for(int iPts=0;iPts<lgthNodes;iPts++)
+ pts[iPts]=(double *)coord+3*(nodes[iPts]-1);
+ CalculateBarycenterDyn((const double **)pts,lgthNodes,3,barycenter+3*index);
+ delete [] pts;
+ delete [] nodes;
+ index++;
}
- index++;
}
break;
}
break;
}
- if (!onAll) delete [] global_connectivity ;
+ if (!onAll)
+ if(type != MED_EN::MED_POLYGON && type != MED_EN::MED_POLYHEDRA)
+ delete [] global_connectivity;
}
-
- Barycenter->setValue(MED_FULL_INTERLACE,barycenter);
-
- delete[] barycenter ;
-
END_OF(LOC);
-
return Barycenter;
}
-//=======================================================================
-//function : checkGridFillCoords
-//purpose : if this->_isAGrid, assure that _coordinate is filled
-//=======================================================================
-
-// inline void MESH::checkGridFillCoords() const
-// {
-// if (_isAGrid)
-// ((GRID *) this)->fillCoordinates();
-// }
-
-//=======================================================================
-//function : checkGridFillConnectivity
-//purpose : if this->_isAGrid, assure that _connectivity is filled
-//=======================================================================
-
-// inline void MESH::checkGridFillConnectivity() const
-// {
-// if (_isAGrid)
-// ((GRID *) this)->fillConnectivity();
-// }
-
bool MESH::isEmpty() const
{
bool notempty = _name != "NOT DEFINED" || _coordinate != NULL || _connectivity != NULL ||
<< _drivers.size()
)
);
-// if (_isAGrid)
-// ((GRID *) this)->fillMeshAfterRead();
-
END_OF(LOC);
}
//=======================================================================
return a SUPPORT pointer on the union of all SUPPORTs in Supports.
You should delete this pointer after use to avoid memory leaks.
*/
-SUPPORT * MESH::mergeSupports(const vector<SUPPORT *> Supports) const throw (MEDEXCEPTION)
+SUPPORT * MESH::mergeSupports(const vector<SUPPORT *> Supports) throw (MEDEXCEPTION)
{
const char * LOC = "MESH:::mergeSupports(const vector<SUPPORT *> ) : " ;
BEGIN_OF(LOC) ;
The (SUPPORT *) NULL pointer is returned if the intersection is empty.
You should delete this pointer after use to avois memory leaks.
*/
-SUPPORT * MESH::intersectSupports(const vector<SUPPORT *> Supports) const throw (MEDEXCEPTION)
+SUPPORT * MESH::intersectSupports(const vector<SUPPORT *> Supports) throw (MEDEXCEPTION)
{
const char * LOC = "MESH:::intersectSupports(const vector<SUPPORT *> ) : " ;
BEGIN_OF(LOC) ;
// internal helper type
struct _cell
{
- //int number;
std::vector<int> groups;
MED_EN::medGeometryElement geometricType;
};
// Create families from groups
void MESH::createFamilies()
{
- int nbFam=0; // count the families we create, used as identifier ???????????
-
int idFamNode = 0; // identifier for node families
int idFamElement = 0; // identifier for cell, face or edge families
}
tab_families[key.str()].push_back(n+1); // fill the vector of contained cells associated whith the family
- /* fam = tab_families.find(key.str());
- if( fam != tab_families.end())
- fam->second.push_back(n+1); // +1 : convention Fortran de MED
- else
- {
- vector<int> newfamily;
- newfamily.push_back(n+1); // +1 : convention Fortran de MED
- tab_families.insert(make_pair(key.str(),newfamily));
- }*/
}
// creation of support, check if it already exist.
}
}
+
+int MESH::getElementContainingPoint(const double *coord)
+{
+ if(_spaceDimension==3)
+ {
+ Meta_Wrapper<3> *fromWrapper=new Meta_Wrapper<3> (getNumberOfNodes(),const_cast<double *>(getCoordinates(MED_FULL_INTERLACE)),
+ const_cast<CONNECTIVITY *>(getConnectivityptr()));
+ Meta_Wrapper<3> *toWrapper=new Meta_Wrapper<3> (1,const_cast<double *>(coord));
+ Meta_Mapping<3> *mapping=new Meta_Mapping<3> (fromWrapper,toWrapper);
+ mapping->Cree_Mapping(1);
+ vector<int> vectormapping=mapping->Get_Mapping();
+ return vectormapping[0]+1;
+ }
+ else if(_spaceDimension==2)
+ {
+ Meta_Wrapper<2> *fromWrapper=new Meta_Wrapper<2> (getNumberOfNodes(),const_cast<double *>(getCoordinates(MED_FULL_INTERLACE)),
+ const_cast<CONNECTIVITY *>(getConnectivityptr()));
+ Meta_Wrapper<2> *toWrapper=new Meta_Wrapper<2> (1,const_cast<double *>(coord));
+ Meta_Mapping<2> *mapping=new Meta_Mapping<2> (fromWrapper,toWrapper);
+ mapping->Cree_Mapping(1);
+ vector<int> vectormapping=mapping->Get_Mapping();
+ return vectormapping[0]+1;
+ }
+ else
+ throw MEDEXCEPTION("MESH::getElementContainingPoint : invalid _spaceDimension must be equal to 2 or 3 !!!");
+}
+
+//Presently disconnected in C++
+void MESH::addReference() const
+{
+}
+
+//Presently disconnected in C++
+void MESH::removeReference() const
+{
+}
#include <string>
#include <vector>
+#include <list>
#include <map>
#include "utilities.h"
#include "MEDMEM_STRING.hxx"
#include "MEDMEM_Exception.hxx"
#include "MEDMEM_define.hxx"
-
-//#include "MEDMEM_Support.hxx"
#include "MEDMEM_Coordinate.hxx"
#include "MEDMEM_Connectivity.hxx"
#include "MEDMEM_GenDriver.hxx"
+#include "MEDMEM_RCBase.hxx"
/*! This class contains all the informations related with a MESH :
- COORDINATES
class FAMILY;
class GROUP;
class SUPPORT;
-class MESH
+class MESH : public RCBASE
{
//-----------------------//
protected :
string _name; // A POSITIONNER EN FCT DES IOS ?
+ string _description;
mutable COORDINATE * _coordinate;
mutable CONNECTIVITY * _connectivity;
// inline void checkGridFillConnectivity() const;
bool isEmpty() const;
// if this->_isAGrid, assure that _coordinate and _connectivity are filled
-
public :
// Add your personnal driver line (step 2)
- friend class MED_MESH_RDONLY_DRIVER;
- friend class MED_MESH_WRONLY_DRIVER;
-
- friend class MED_MED_RDONLY_DRIVER;
- friend class MED_MED_WRONLY_DRIVER;
- friend class MED_MED_RDWR_DRIVER;
+ friend class IMED_MESH_RDONLY_DRIVER;
+ friend class IMED_MESH_WRONLY_DRIVER;
+ friend class MED_MESH_RDONLY_DRIVER21;
+ friend class MED_MESH_WRONLY_DRIVER21;
+ friend class MED_MESH_RDONLY_DRIVER22;
+ friend class MED_MESH_WRONLY_DRIVER22;
+
+ friend class MED_MED_RDONLY_DRIVER21;
+ friend class MED_MED_WRONLY_DRIVER21;
+ friend class MED_MED_RDWR_DRIVER21;
+ friend class MED_MED_RDONLY_DRIVER22;
+ friend class MED_MED_WRONLY_DRIVER22;
+ friend class MED_MED_RDWR_DRIVER22;
friend class GIBI_MESH_RDONLY_DRIVER;
friend class GIBI_MESH_WRONLY_DRIVER;
MESH();
MESH(MESH &m);
MESH & operator=(const MESH &m);
+ virtual bool operator==(const MESH& other) const;
+ virtual bool deepCompare(const MESH& other) const;
MESH( driverTypes driverType, const string & fileName="",
const string & meshName="") throw (MEDEXCEPTION);
virtual ~MESH();
inline void write(int index=0, const string & driverName = "");
inline void write(const GENDRIVER & genDriver);
- // void calculateReverseConnectivity();
- // void createFaces(); //Faces creation => full constituent informations
- // void buildConstituent(); // calculate descendent connectivity + face-cell connectivity
-
-
inline void setName(string name);
-
+ inline void setDescription(string description);
inline string getName() const;
+ inline string getDescription() const;
inline int getSpaceDimension() const;
inline int getMeshDimension() const;
inline bool getIsAGrid();
//inline int * getNodesNumbers();
virtual inline int getNumberOfTypes(MED_EN::medEntityMesh Entity) const;
+ virtual int getNumberOfTypesWithPoly(MED_EN::medEntityMesh Entity) const;
virtual inline const MED_EN::medGeometryElement * getTypes(MED_EN::medEntityMesh Entity) const;
+ virtual MED_EN::medGeometryElement * getTypesWithPoly(MED_EN::medEntityMesh Entity) const;
virtual inline const CELLMODEL * getCellsTypes(MED_EN::medEntityMesh Entity) const;
virtual const int * getGlobalNumberingIndex(MED_EN::medEntityMesh Entity) const;
virtual inline int getNumberOfElements(MED_EN::medEntityMesh Entity,
MED_EN::medGeometryElement Type) const;
+ virtual int getNumberOfElementsWithPoly(MED_EN::medEntityMesh Entity,
+ MED_EN::medGeometryElement Type) const;
virtual inline bool existConnectivity(MED_EN::medConnectivity ConnectivityType,
MED_EN::medEntityMesh Entity) const;
+ inline bool existPolygonsConnectivity(MED_EN::medConnectivity ConnectivityType,
+ MED_EN::medEntityMesh Entity) const;
+ inline bool existPolyhedronConnectivity(MED_EN::medConnectivity ConnectivityType,
+ MED_EN::medEntityMesh Entity) const;
virtual inline MED_EN::medGeometryElement getElementType(MED_EN::medEntityMesh Entity,
int Number) const;
+ virtual inline MED_EN::medGeometryElement getElementTypeWithPoly(MED_EN::medEntityMesh Entity,
+ int Number) const;
virtual inline void calculateConnectivity(MED_EN::medModeSwitch Mode,
MED_EN::medConnectivity ConnectivityType,
MED_EN::medEntityMesh Entity) const ;
MED_EN::medGeometryElement Type) const;
virtual inline const int * getConnectivityIndex(MED_EN::medConnectivity ConnectivityType,
MED_EN::medEntityMesh Entity) const;
+
+ inline const int * getPolygonsConnectivity(MED_EN::medConnectivity ConnectivityType,
+ MED_EN::medEntityMesh Entity) const;
+ inline const int * getPolygonsConnectivityIndex(MED_EN::medConnectivity ConnectivityType,
+ MED_EN::medEntityMesh Entity) const;
+ inline int getNumberOfPolygons() const;
+ inline const int * getPolyhedronConnectivity(MED_EN::medConnectivity ConnectivityType) const;
+ inline const int * getPolyhedronFacesIndex() const;
+ inline const int * getPolyhedronIndex(MED_EN::medConnectivity ConnectivityType) const;
+ inline int getNumberOfPolyhedronFaces() const;
+ inline int getNumberOfPolyhedron() const;
+
virtual int getElementNumber(MED_EN::medConnectivity ConnectivityType,
MED_EN::medEntityMesh Entity,
MED_EN::medGeometryElement Type,
// throw (MEDEXCEPTION); // Il faut preciser !
/*!
- return a SUPPORT pointer on the union of all SUPPORTs in Supports.
+ returns a SUPPORT pointer on the union of all SUPPORTs in Supports.
You should delete this pointer after use to avois memory leaks.
*/
- SUPPORT * mergeSupports(const vector<SUPPORT *> Supports) const throw (MEDEXCEPTION) ;
+ static SUPPORT * mergeSupports(const vector<SUPPORT *> Supports) throw (MEDEXCEPTION) ;
/*!
- return a SUPPORT pointer on the intersection of all SUPPORTs in Supports.
+ returns a SUPPORT pointer on the intersection of all SUPPORTs in Supports.
The (SUPPORT *) NULL pointer is returned if the intersection is empty.
You should delete this pointer after use to avois memory leaks.
*/
- SUPPORT * intersectSupports(const vector<SUPPORT *> Supports) const throw (MEDEXCEPTION) ;
+ static SUPPORT * intersectSupports(const vector<SUPPORT *> Supports) throw (MEDEXCEPTION) ;
/*!
* Create families from groups.
* (There is no way to know which family has change.)
*/
void createFamilies();
+ SUPPORT *buildSupportOnNodeFromElementList(const list<int>& listOfElt, MED_EN::medEntityMesh entity) const throw (MEDEXCEPTION);
+ void fillSupportOnNodeFromElementList(const list<int>& listOfElt, SUPPORT *supportToFill) const throw (MEDEXCEPTION);
+ SUPPORT *buildSupportOnElementsFromElementList(const list<int>& listOfElt, MED_EN::medEntityMesh entity) const throw (MEDEXCEPTION);
+ int getElementContainingPoint(const double *coord);
+ template<class T>
+ static FIELD<T> *mergeFields(const vector< FIELD<T>* >& others,bool meshCompare=false);
+ /*!
+ *For ref counter. Only for client
+ */
+ virtual void addReference() const;
+ virtual void removeReference() const;
};
// ---------------------------------------
return _name;
}
+/*! Set the MESH description */
+inline void MESH::setDescription(string description)
+{
+ _description=description; //NOM interne à la classe
+}
+
+/*! Get the MESH description */
+inline string MESH::getDescription() const
+{
+ return _description;
+}
+
/*! Get the dimension of the space */
inline int MESH::getSpaceDimension() const
{
}
/*!
- Get the list of geometric types used by a given entity.
+ Gets the list of geometric types used by a given entity.
medEntityMesh entity : MED_CELL, MED_FACE, MED_EDGE, MED_ALL_ENTITIES
REM : Don't use MED_NODE
- If entity is not defined, return an exception.
+ If entity is not defined, it returns an exception.
*/
inline const MED_EN::medGeometryElement * MESH::getTypes(MED_EN::medEntityMesh entity) const
{
throw MEDEXCEPTION(LOCALIZED("MESH::getCellsTypes( medEntityMesh ) : Connectivity not defined !"));
}
-/*! Return an array of size NumbreOfTypes+1 which contains, for each
+/*! Returns an array of size NumbreOfTypes+1 which contains, for each
geometric type of the given entity, the first global element number
of this type.
throw MEDEXCEPTION(LOCALIZED("MESH::getNumberOfTypes( medEntityMesh ) : Connectivity not defined !"));
}
/*!
- Return the number of element of given geometric type of given entity. Return 0 if query is not defined.
+ Returns the number of element of given geometric type of given entity. Return 0 if query is not defined.
Example :
- getNumberOfElements(MED_NODE,MED_NONE) : number of node
- - getNumberOfElements(MED_NODE,MED_TRIA3) : return 0 (not defined)
- - getNumberOfElements(MED_FACE,MED_TRIA3) : return number of triangles
+ - getNumberOfElements(MED_NODE,MED_TRIA3) : returns 0 (not defined)
+ - getNumberOfElements(MED_FACE,MED_TRIA3) : returns number of triangles
elements defined in face entity (0 if not defined)
- - getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS) : return total number
+ - getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS) : returns total number
of elements defined in cell entity
*/
inline int MESH::getNumberOfElements(MED_EN::medEntityMesh entity, MED_EN::medGeometryElement Type) const
}
}
/*!
- Return true if the wanted connectivity exist, else return false
+ Returns true if the wanted connectivity exist, else returns false
(to use before a getSomething method).
*/
inline bool MESH::existConnectivity(MED_EN::medConnectivity connectivityType, MED_EN::medEntityMesh entity) const
return _connectivity->existConnectivity(connectivityType,entity);
}
/*!
- Return the geometric type of global element Number of entity Entity.
+ Returns true if the wanted polygons connectivity exist, else returns false
+*/
+inline bool MESH::existPolygonsConnectivity(MED_EN::medConnectivity connectivityType, MED_EN::medEntityMesh entity) const
+{
+ if (_connectivity == (CONNECTIVITY*) NULL)
+ throw MEDEXCEPTION("MESH::existPolygonsConnectivity(medConnectivity,medEntityMesh) : no connectivity defined !");
+ return _connectivity->existPolygonsConnectivity(connectivityType,entity);
+}
+/*!
+ Returns true if the wanted polyhedron connectivity exist, else returns false
+*/
+inline bool MESH::existPolyhedronConnectivity(MED_EN::medConnectivity connectivityType, MED_EN::medEntityMesh entity) const
+{
+ if (_connectivity == (CONNECTIVITY*) NULL)
+ throw MEDEXCEPTION("MESH::existPolyhedronConnectivity(medConnectivity,medEntityMesh) : no connectivity defined !");
+ return _connectivity->existPolyhedronConnectivity(connectivityType,entity);
+}
+/*!
+ Returns the geometric type of global element Number of entity Entity.
Throw an exception if Entity is not defined or Number are wrong (too big).
*/
throw MEDEXCEPTION("MESH::getElementType(medEntityMesh,int) : no connectivity defined !");
return _connectivity->getElementType(Entity,Number);
}
+
+/*
+ Method equivalent to getElementType except that it includes not only classical Types but polygons/polyhedra also.
+ */
+MED_EN::medGeometryElement MESH::getElementTypeWithPoly(MED_EN::medEntityMesh Entity, int Number) const
+{
+ if (_connectivity==(CONNECTIVITY*)NULL)
+ throw MEDEXCEPTION("MESH::getElementType(medEntityMesh,int) : no connectivity defined !");
+ return _connectivity->getElementTypeWithPoly(Entity,Number);
+}
+
/*!
- Calculate the ask connectivity. Return an exception if this could not be
+ Calculate the ask connectivity. Returns an exception if this could not be
done. Do nothing if connectivity already exist.
*/
throw MEDEXCEPTION(LOCALIZED("MESH::calculateConnectivity : only for MED_FULL_INTERLACE mode"));
}
/*!
- Return the corresponding length of the array returned by MESH::getConnectivity with exactly the same arguments.
+ Returns the corresponding length of the array returned by MESH::getConnectivity with exactly the same arguments.
Used particulary for wrapping CORBA and python.
*/
inline int MESH::getConnectivityLength(MED_EN::medModeSwitch Mode,MED_EN::medConnectivity ConnectivityType,MED_EN::medEntityMesh entity, MED_EN::medGeometryElement Type) const
return size;
}
/*!
- Return the required connectivity in the right mode for the given
+ Returns the required connectivity in the right mode for the given
geometric type of the given entity.
To get connectivity for all geometric type, use Mode=MED_FULL_INTERLACE
throw MEDEXCEPTION(LOCALIZED("MESH::getConnectivity : only for MED_FULL_INTERLACE mode"));
}
/*!
- Return the required index array for a connectivity received in
+ Returns the required index array for a connectivity received in
MED_FULL_ENTERLACE mode and MED_ALL_ELEMENTS type.
This array allow to find connectivity of each elements.
return _connectivity->getConnectivityIndex(ConnectivityType, entity);
}
/*!
- Return the corresponding length of the array returned by MESH::getReverseConnectivity with exactly the same arguments.
+ Return the required connectivity of polygons for the given entity.
+ You must also get the corresponding index array.
+ */
+inline const int * MESH::getPolygonsConnectivity(MED_EN::medConnectivity ConnectivityType,
+ MED_EN::medEntityMesh Entity) const
+{
+ return _connectivity->getPolygonsConnectivity(ConnectivityType,Entity);
+}
+/*!
+ Return the required index array for polygons connectivity.
+ */
+inline const int * MESH::getPolygonsConnectivityIndex(MED_EN::medConnectivity ConnectivityType,
+ MED_EN::medEntityMesh Entity) const
+{
+ return _connectivity->getPolygonsConnectivityIndex(ConnectivityType,Entity);
+}
+/*!
+ Return the number of polygons.
+ */
+inline int MESH::getNumberOfPolygons() const
+{
+ return _connectivity->getNumberOfPolygons();
+}
+/*!
+ Return the required connectivity of polyhedron :
+ - in nodal mode, it gives you the polyhedron faces nodal connectivity.
+ - in descending mode, it gives you the polyhedron faces list.
+ You must also get :
+ - faces index and polyhedron index arrays in nodal mode.
+ - polyhedron index array in descending mode.
+ */
+inline const int * MESH::getPolyhedronConnectivity(MED_EN::medConnectivity ConnectivityType) const
+{
+ return _connectivity->getPolyhedronConnectivity(ConnectivityType);
+}
+/*!
+ Return the index array of polyhedron faces in nodal mode.
+ You must also get the polyhedron index array.
+ */
+inline const int * MESH::getPolyhedronFacesIndex() const
+{
+ return _connectivity->getPolyhedronFacesIndex();
+}
+/*!
+ Return the required polyhedron index array.
+ */
+inline const int * MESH::getPolyhedronIndex(MED_EN::medConnectivity ConnectivityType) const
+{
+ return _connectivity->getPolyhedronIndex(ConnectivityType);
+}
+/*!
+ Return the number of polyhedron faces.
+ */
+inline int MESH::getNumberOfPolyhedronFaces() const
+{
+ return _connectivity->getNumberOfPolyhedronFaces();
+}
+/*!
+ Return the number of polyhedron.
+ */
+inline int MESH::getNumberOfPolyhedron() const
+{
+ return _connectivity->getNumberOfPolyhedron();
+}
+/*!
+ Returns the corresponding length of the array returned by MESH::getReverseConnectivity with exactly the same arguments.
Used particulary for wrapping CORBA and python.
*/
return getReverseConnectivityIndex(ConnectivityType)[nb]-1;
}
/*!
- Return the reverse connectivity required by ConnectivityType :
- - If ConnectivityType=MED_NODAL : return connectivity node-cell
- - If ConnectivityType=MED_DESCENDING : return connectivity face-cell
+ Returns the reverse connectivity required by ConnectivityType :
+ - If ConnectivityType=MED_NODAL : returns connectivity node-cell
+ - If ConnectivityType=MED_DESCENDING : returns connectivity face-cell
You must get ReverseConnectivityIndex array to use it.
*/
return _connectivity->getReverseConnectivity(ConnectivityType,Entity);
}
/*!
- Return the corresponding length of the array returned by MESH::getReverseConnectivityIndex with exactly the same arguments.
+ Returns the corresponding length of the array returned by MESH::getReverseConnectivityIndex with exactly the same arguments.
Used particulary for wrapping CORBA and python.
*/
inline int MESH::getReverseConnectivityIndexLength(MED_EN::medConnectivity ConnectivityType,
}
}
/*!
- Return the index array required by ConnectivityType.
+ Returns the index array required by ConnectivityType.
This array allow to find reverse connectivity of each elements.
}
+#include "MEDMEM_Support.hxx"
+
+namespace MEDMEM {
+
+//Create a new FIELD that should be deallocated based on a SUPPORT that should be deallocated too.
+template<class T>
+FIELD<T> *MESH::mergeFields(const vector< FIELD<T>* >& others,bool meshCompare)
+{
+ const char * LOC = "MESH::mergeFields(const vector< FIELD<T>* >& others,bool meshCompare): ";
+ BEGIN_OF(LOC);
+ int i,j;
+ if(others.size()==0)
+ return 0;
+ vector<SUPPORT *> sup;
+ typename vector< FIELD<T>* >::const_iterator iter;
+ for(iter=others.begin();iter!=others.end();iter++)
+ {
+ sup.push_back((SUPPORT *)(*iter)->getSupport());
+ }
+ iter=others.begin();
+ SUPPORT *retSup=mergeSupports(sup);
+ int retNumberOfComponents=(*iter)->getNumberOfComponents();
+ FIELD<T> *ret=new FIELD<T>(retSup,retNumberOfComponents,MED_EN::MED_FULL_INTERLACE);
+ ret->setValueType((*iter)->getValueType());
+ T* valuesToSet=(T*)ret->getValue(MED_EN::MED_FULL_INTERLACE);
+ int nbOfEltsRetSup=retSup->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS);
+ T* tempValues=new T[retNumberOfComponents];
+ if(retSup->isOnAllElements())
+ {
+ for(i=0;i<nbOfEltsRetSup;i++)
+ {
+ bool found=false;
+ for(iter=others.begin();iter!=others.end() && !found;iter++)
+ {
+ found=(*iter)->getValueOnElement(i+1,tempValues);
+ if(found)
+ for(j=0;j<retNumberOfComponents;j++)
+ valuesToSet[i*retNumberOfComponents+j]=tempValues[j];
+ }
+ }
+ }
+ else
+ {
+ const int *eltsRetSup=retSup->getNumber(MED_EN::MED_ALL_ELEMENTS);
+ for(i=0;i<nbOfEltsRetSup;i++)
+ {
+ bool found=false;
+ for(iter=others.begin();iter!=others.end() && !found;iter++)
+ {
+ found=(*iter)->getValueOnElement(eltsRetSup[i],tempValues);
+ if(found)
+ for(j=0;j<retNumberOfComponents;j++)
+ valuesToSet[i*retNumberOfComponents+j]=tempValues[j];
+ }
+ if(!found)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Merging error due to an error in merging support"));
+ }
+ }
+ delete [] tempValues;
+ END_OF(LOC);
+ return ret;
+}
+
+}
+
#endif /* MESH_HXX */
_spaceDimension = SpaceDimension ;
}
-/* Set the dimension of the MESHING */
-// void MESHING::setMeshDimension(const int MeshDimension)
-// {
-// _meshDimension = MeshDimension ;
-// }
+/*! Set the dimension of the MESHING */
+void MESHING::setMeshDimension(const int MeshDimension)
+{
+ _meshDimension = MeshDimension ;
+ _connectivity->setEntityDimension(MeshDimension);
+}
/*! Set the number of nodes used in the MESH */
void MESHING::setNumberOfNodes(const int NumberOfNodes)
_connectivity->setNodal(Connectivity,Entity,Type) ;
}
+void MESHING::setPolygonsConnectivity (const int * ConnectivityIndex,
+ const int * ConnectivityValue,
+ int nbOfPolygons,
+ const MED_EN::medEntityMesh Entity)
+ throw (MEDEXCEPTION)
+{
+ if (_connectivity == (CONNECTIVITY*)NULL)
+ throw MEDEXCEPTION("No connectivity defined !");
+ if(_connectivity->getPolyTypeRelativeTo()==MED_EN::MED_POLYGON)
+ {
+ _connectivity->setPolygonsConnectivity(MED_NODAL, Entity, ConnectivityValue, ConnectivityIndex,ConnectivityIndex[nbOfPolygons]-1,nbOfPolygons) ;
+ }
+ else
+ throw MEDEXCEPTION("Invalid connectivity for polygons !!!");
+}
+
+void MESHING::setPolyhedraConnectivity (const int * PolyhedronIndex,
+ const int * FacesIndex,
+ const int * Nodes,
+ int nbOfPolyhedra,
+ const MED_EN::medEntityMesh Entity)
+ throw (MEDEXCEPTION)
+{
+ if (_connectivity == (CONNECTIVITY*)NULL)
+ throw MEDEXCEPTION("No connectivity defined !");
+ if(_connectivity->getPolyTypeRelativeTo()==MED_EN::MED_POLYHEDRA)
+ {
+ int nbOfFacesOfAllPolyhedra=PolyhedronIndex[nbOfPolyhedra]-1;
+ _connectivity->setPolyhedronConnectivity(MED_NODAL, Nodes, PolyhedronIndex, FacesIndex[nbOfFacesOfAllPolyhedra]-1 , nbOfPolyhedra, FacesIndex, nbOfFacesOfAllPolyhedra) ;
+ }
+ else
+ throw MEDEXCEPTION("Invalid connectivity for polyhedra !!!");
+}
+
/*!
NOT YET IMPLEMENTED !! WARNING
*/
~MESHING();
void setSpaceDimension (const int SpaceDimension) ;
- //void setMeshDimension (const int MeshDimension) ;
+ void setMeshDimension (const int MeshDimension) ;
void setNumberOfNodes (const int NumberOfNodes) ;
void setCoordinates (const int SpaceDimension,
const int NumberOfNodes,
const MED_EN::medEntityMesh Entity,
const MED_EN::medGeometryElement Type)
throw (MEDEXCEPTION) ;
+
+ void setPolygonsConnectivity (const int * ConnectivityIndex,
+ const int * ConnectivityValue,
+ int nbOfPolygons,
+ const MED_EN::medEntityMesh Entity)
+ throw (MEDEXCEPTION) ;
+
+ void setPolyhedraConnectivity (const int * PolyhedronIndex,
+ const int * FacesIndex,
+ const int * Nodes,
+ int nbOfPolyhedra,
+ const MED_EN::medEntityMesh Entity)
+ throw (MEDEXCEPTION) ;
void setConnectivities (const int * ConnectivityIndex,
const int * ConnectivityValue,
--- /dev/null
+using namespace std;
+#include "MEDMEM_PolyhedronArray.hxx"
+using namespace MEDMEM;
+using MED_EN::med_int;
+
+POLYHEDRONARRAY::POLYHEDRONARRAY():_numberOfPolyhedron(0), _numberOfFaces(0), _numberOfNodes(0), _polyhedronIndex((med_int*)NULL), _facesIndex((med_int*)NULL), _nodes((med_int*)NULL)
+{}
+
+POLYHEDRONARRAY::POLYHEDRONARRAY(med_int numberofpolyhedron,med_int numberoffaces,med_int numberofnodes):_numberOfPolyhedron(numberofpolyhedron), _numberOfFaces(numberoffaces), _numberOfNodes(numberofnodes), _polyhedronIndex(numberofpolyhedron+1), _facesIndex(numberoffaces+1), _nodes(numberofnodes)
+{}
+
+POLYHEDRONARRAY::POLYHEDRONARRAY(const POLYHEDRONARRAY& m):_numberOfPolyhedron(m._numberOfPolyhedron), _numberOfFaces(m._numberOfFaces), _numberOfNodes(m._numberOfNodes), _polyhedronIndex(m._numberOfPolyhedron+1), _facesIndex(m._numberOfFaces+1), _nodes(m._numberOfNodes)
+{
+ _polyhedronIndex.set(m._numberOfPolyhedron+1, m.getPolyhedronIndex());
+ _facesIndex.set(m._numberOfFaces+1, m.getFacesIndex());
+ _nodes.set(m._numberOfNodes, m.getNodes());
+}
--- /dev/null
+# ifndef __POLYHEDRONARRAY_H__
+# define __POLYHEDRONARRAY_H__
+
+#include "MEDMEM_Exception.hxx"
+#include "MEDMEM_PointerOf.hxx"
+#include "MEDMEM_define.hxx"
+
+namespace MEDMEM {
+class POLYHEDRONARRAY
+{
+private :
+ MED_EN::med_int _numberOfPolyhedron;
+ MED_EN::med_int _numberOfFaces;
+ MED_EN::med_int _numberOfNodes;
+ PointerOf <MED_EN::med_int> _polyhedronIndex;
+ PointerOf <MED_EN::med_int> _facesIndex;
+ PointerOf <MED_EN::med_int> _nodes;
+
+public :
+ POLYHEDRONARRAY();
+ POLYHEDRONARRAY(MED_EN::med_int numberofpolyhedron,MED_EN::med_int numberoffaces,MED_EN::med_int numberofnodes);
+ POLYHEDRONARRAY(const POLYHEDRONARRAY& m);
+
+ inline MED_EN::med_int getNumberOfPolyhedron() const;
+ inline MED_EN::med_int getNumberOfFaces() const;
+ inline MED_EN::med_int getNumberOfNodes() const;
+ inline const MED_EN::med_int* getPolyhedronIndex() const;
+ inline const MED_EN::med_int* getFacesIndex() const;
+ inline const MED_EN::med_int* getNodes() const;
+
+ inline void setPolyhedronIndex(const MED_EN::med_int* polyhedronindex);
+ inline void setFacesIndex(const MED_EN::med_int* facesindex);
+ inline void setNodes(const MED_EN::med_int* nodes);
+};
+
+// ----------------------------------------------------------
+// Methodes Inline
+// ----------------------------------------------------------
+inline MED_EN::med_int POLYHEDRONARRAY::getNumberOfPolyhedron() const
+{
+ return _numberOfPolyhedron;
+};
+inline MED_EN::med_int POLYHEDRONARRAY::getNumberOfFaces() const
+{
+ return _numberOfFaces;
+};
+inline MED_EN::med_int POLYHEDRONARRAY::getNumberOfNodes() const
+{
+ return _numberOfNodes;
+};
+inline const MED_EN::med_int* POLYHEDRONARRAY::getPolyhedronIndex() const
+{
+ return (const MED_EN::med_int*) _polyhedronIndex;
+};
+inline const MED_EN::med_int* POLYHEDRONARRAY::getFacesIndex() const
+{
+ return (const MED_EN::med_int*) _facesIndex;
+};
+inline const MED_EN::med_int* POLYHEDRONARRAY::getNodes() const
+{
+ return (const MED_EN::med_int*) _nodes;
+};
+
+
+inline void POLYHEDRONARRAY::setPolyhedronIndex(const MED_EN::med_int* polyhedronindex)
+{
+ _polyhedronIndex.set(_numberOfPolyhedron+1, polyhedronindex);
+}
+inline void POLYHEDRONARRAY::setFacesIndex(const MED_EN::med_int* facesindex)
+{
+ _facesIndex.set(_numberOfFaces+1, facesindex);
+}
+inline void POLYHEDRONARRAY::setNodes(const MED_EN::med_int* nodes)
+{
+ _nodes.set(_numberOfNodes, nodes);
+}
+
+}
+
+# endif
// the syntax corresponding to the use of input file is not implemented
if ( isKeyWord(buf_ligne,"LOCA") )
{
- MESSAGE("Mot clé LOCA détecté");
+ MESSAGE("Mot clé LOCA détecté");
processLoca=true;
// if currentGroup is not empty, a group has been precessed
// -> we store it, clear currentGroup, and start the precessing of a new group
// the syntax corresponding to structured grids is not implemented
else if ( isKeyWord(buf_ligne,"GRID") )
{
- MESSAGE("Mot clé GRID détecté");
+ MESSAGE("Mot clé GRID détecté");
processLoca=false;
pos=buf_ligne.find("UNST",0);
if ( pos != string::npos ) // unstructured grid
// the default option is HYBR
else if ( isKeyWord(buf_ligne,"CONN") )
{
- MESSAGE("Mot clé CONN détecté");
+ MESSAGE("Mot clé CONN détecté");
processLoca=false;
string fileCONN=getPorflowFileName(buf_ligne,"CONN");
if(fileCONN.rfind('/') == string::npos)
// no directory was specified -> we add dirName, which may be empty
+
connFileName=dirName+fileCONN;
else
connFileName=fileCONN;
// expected syntax : COOR {VERT} {filename}
else if ( isKeyWord(buf_ligne,"COOR") )
{
- MESSAGE("Mot clé COOR détecté");
+ MESSAGE("Mot clé COOR");
processLoca=false;
string fileCOOR=getPorflowFileName(buf_ligne,"COOR");
if ( isGroupAList[i] )
{
// medi.groupes[i].groupes is a vector of element numbers; it points to it
+ medi.groupes[i].mailles.resize( medi.groupes[i].groupes.size() );
std::vector<int>::const_iterator it=medi.groupes[i].groupes.begin();
- for( ; it!=medi.groupes[i].groupes.end(); ++it)
+ for(int j = 0 ; it!=medi.groupes[i].groupes.end(); ++it, ++j)
{
// insert the iterator to the corresponding cell we stored in p_ma_table
- medi.groupes[i].mailles.insert( p_ma_table[*it] );
+ medi.groupes[i].mailles[j] = p_ma_table[*it];
}
}
int nelem=0;
int nface=0;
int ngeom=0;
+ int ielem=0;
std::set<_maille>::iterator p_ma;
_maille maille2D;
// medi.groupes[i].groupes is a vector of paired element and surface numbers
// *it points to the element number, *(it+1) points to the surface number
std::vector<int>::const_iterator it=medi.groupes[i].groupes.begin();
+ medi.groupes[i].mailles.resize( medi.groupes[i].groupes.size() / 2 );
for( ; it!=medi.groupes[i].groupes.end(); ++it)
{
nelem=*it;
maille2D.sommets.resize(l);
maille2D.geometricType = get2DMedGeomType(l);
p_ma = medi.maillage.insert(maille2D).first; // we insert the face in our mesh
- medi.groupes[i].mailles.insert(p_ma); // and insert an iterator on it in our group
+ medi.groupes[i].mailles[ielem++]=p_ma; // and insert an iterator on it in our group
maille2D.sommets.clear();
}
}
- // medi.groupes[i].groupes.clear(); // we don't need element numbers anymore
+ medi.groupes[i].groupes.clear(); // we don't need element numbers anymore
}
p_ma_table.clear(); // we don't need it anymore
- MESSAGE(LOC << "GIBI_MESH_RDONLY_DRIVER::read : RESULTATS STRUCTURE INTERMEDIAIRES : ");
+ MESSAGE(LOC << "PORFLOW_MESH_RDONLY_DRIVER::read : RESULTATS STRUCTURE INTERMEDIAIRES : ");
MESSAGE(LOC << medi );
// TRANSFORMATION EN STRUCTURES MED
if ( ! _ptrMesh->isEmpty() )
// appele en dernier car cette fonction detruit le maillage intermediaire!
_ptrMesh->_connectivity = medi.getConnectivity();
- MESSAGE(LOC << "GIBI_MESH_RDONLY_DRIVER::read : FIN ");
+ MESSAGE(LOC << "PORFLOW_MESH_RDONLY_DRIVER::read : FIN ");
// calcul de la connectivite d-1 complete, avec renumerotation des groupes
// if (_ptrMesh->_spaceDimension==3)
// else if (_ptrMesh->_spaceDimension==2)
// _ptrMesh->_connectivity->updateGroup(_ptrMesh->_groupEdge) ;
- // Creation des familles à partir des groupes
- // NC : Cet appel pourra être différé quand la gestion de la cohérence famille/groupes sera assurée
- _ptrMesh->createFamilies();
+ // Creation des familles ?artir des groupes
+ // NC : Cet appel pourra ?e diff鲩 quand la gestion de la coh鲥nce famille/groupes sera assur饊 _ptrMesh->createFamilies();
}
#include "MEDMEM_define.hxx"
#include "MEDMEM_GenDriver.hxx"
-#include "MEDMEM_DriverTools.hxx"
+//#include "MEDMEM_DriverTools.hxx"
#include "MEDMEM_STRING.hxx"
#include "MEDMEM_Exception.hxx"
#include "utilities.h"
+#include <vector>
+#include <set>
+
/*!
Driver PORFLOW for MESH.
class FAMILY;
class GROUP;
class CONNECTIVITY;
+class _intermediateMED;
+class _maille;
class PORFLOW_MESH_DRIVER : public GENDRIVER
{
protected:
--- /dev/null
+#ifndef __MEDMEM_RCBASE_HXX__
+#define __MEDMEM_RCBASE_HXX__
+
+namespace MEDMEM {
+
+ class RCBASE {
+ public:
+ virtual void addReference() const = 0;
+ virtual void removeReference() const = 0;
+ };
+
+}
+
+#endif
#include <algorithm>
#include <list>
-//#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_Mesh.hxx"
using namespace std;
using namespace MED_EN;
using namespace MEDMEM;
+#define MED_NBR_GEOMETRIE_MAILLE 15
+
/* This class is a generic class for family and group */
/*!
_entity(MED_CELL), _numberOfGeometricType(0),
_geometricType((medGeometryElement*)NULL),
_numberOfGaussPoint((int*)NULL),
- //_geometricTypeNumber((int*)NULL),
_isOnAllElts(false),
_numberOfElements((int*)NULL),
_totalNumberOfElements(0),
_numberOfGeometricType(0),
_geometricType((medGeometryElement*)NULL),
_numberOfGaussPoint((int*)NULL),
- //_geometricTypeNumber((int*)NULL),
_isOnAllElts(true),
_numberOfElements((int*)NULL),
_totalNumberOfElements(0),
}
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;
_isOnAllElts = m._isOnAllElts;
if (m._numberOfElements != NULL)
{
//-----------------
{
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 ;
+ clearDataOnNumbers();
}
/*!
_numberOfGaussPoint = new int[1] ;
_numberOfGaussPoint[0]=1;
} else { // we duplicate information from _mesh
- _numberOfGeometricType=_mesh->getNumberOfTypes(_entity);
+ _numberOfGeometricType=_mesh->getNumberOfTypesWithPoly(_entity);
if (_geometricType == (medGeometryElement *) NULL)
- _geometricType = new medGeometryElement[_numberOfGeometricType] ;
- memcpy(_geometricType,_mesh->getTypes(_entity),_numberOfGeometricType*sizeof(medGeometryElement));
+ _geometricType=_mesh->getTypesWithPoly(_entity);
+ else
+ 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]) ;
+ _numberOfElements[i]=_mesh->getNumberOfElementsWithPoly(_entity,_geometricType[i]) ;
_totalNumberOfElements+=_numberOfElements[i];
_numberOfGaussPoint[i]=1 ;
}
void SUPPORT::blending(SUPPORT * mySupport) throw (MEDEXCEPTION)
//-------------------
{
- const char * LOC = "SUPPORT::blending() : " ;
- BEGIN_OF(LOC) ;
-
- MESSAGE(LOC<< "SUPPORT entry : " << *mySupport) ;
-
- // on same entity :
- if ( _entity != mySupport->getEntity() )
+ const char * LOC="SUPPORT::blending(SUPPORT *) : ";
+ BEGIN_OF(LOC);
+ if (_entity!=mySupport->getEntity())
throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Entities are different !"));
-
- int * tmp_NumberOfElementsInType = new int[MED_NBR_GEOMETRIE_MAILLE];
- medGeometryElement * myType = new medGeometryElement[MED_NBR_GEOMETRIE_MAILLE];
- int * whereIsType = new int[MED_NBR_GEOMETRIE_MAILLE];
- //MESH_ENTITIES myMeshEntities() ;
- list<MED_EN::medGeometryElement>::const_iterator listIt ;
- int it=0 ;
- for(listIt=(meshEntities[_entity]).begin();listIt!=(meshEntities[_entity]).end();listIt++) {
- tmp_NumberOfElementsInType[it]=0;
- whereIsType[it]=0 ;
- try {
- int tmp_int = 0;
- tmp_int = getNumberOfElements((medGeometryElement)(*listIt)) ;
- tmp_NumberOfElementsInType[it]+=tmp_int ;
- whereIsType[it]+=1 ;
- }
- catch (MEDEXCEPTION & ex) { SCRUTE(sizeof(ex)); };
- try {
- int tmp_int = 0;
- tmp_int = mySupport->getNumberOfElements((medGeometryElement)(*listIt)) ;
- tmp_NumberOfElementsInType[it]+=tmp_int ;
- whereIsType[it]+=2 ;
- }
- catch (const MEDEXCEPTION & ex) {};
- if (whereIsType[it]!=0) {
- myType[it]=(medGeometryElement)(*listIt) ;
- SCRUTE(myType[it]);SCRUTE(it);SCRUTE((*listIt));
- it++;
+ if(!(*_mesh == *mySupport->getMesh()))
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Mesh are different !"));
+ if(_isOnAllElts)
+ return;
+ if(mySupport->isOnAllElements())
+ {
+ *this=*mySupport;
+ return;
}
- }
- // set new value :
-// int * numberOfElements=_numberOfElements ;
-// _numberOfElements = new int[it] ;
- int * 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] ;
- numberOfElements[i] = numberOfElementsInType ;
- tmp_array[i] = new int[numberOfElementsInType] ;
- //totalSize+=numberOfElementsInType*(myType[i]%100) ;
- _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
- memcpy(tmp_array[i],mySupport->getNumber(myType[i]),sizeof(int)*numberOfElementsInType);
- } else if (whereIsType[i] == 3) { // more difficult :-)
- set<int> elementList ;
- //int i1 = 0 ; !! UNUSED VARIABLE !!
- //int i2 = 0 ; !!UNUSED VARIABLE !!
- int ii = 0 ;
- const int * number1 = getNumber(myType[i]) ;
- const int * number2 = mySupport->getNumber(myType[i]) ;
-
- SCRUTE(number1);
- SCRUTE(number2);
-
- int numberOfElements1 = getNumberOfElements(myType[i]) ;
- int numberOfElements2 = mySupport->getNumberOfElements(myType[i]) ;
-
- SCRUTE(numberOfElements1);
- SCRUTE(numberOfElements2);
-
- MESSAGE(LOC << " Type : " << myType[i] << " " << i);
-
- for(int j=0;j<numberOfElements1;j++){
- elementList.insert(number1[j]) ;
- }
-
- for(int j=0;j<numberOfElements2;j++){
- elementList.insert(number2[j]) ;
- }
-
- //create the array !
- int newNumberOfElements = elementList.size() ;
-
- SCRUTE(newNumberOfElements);
-
- numberOfElements[i] = newNumberOfElements ;
- int * tmp_arrayNew = new int[newNumberOfElements];
-
- set<int>::iterator its ;
- for(its=elementList.begin();its!=elementList.end(); its++) {
- tmp_arrayNew[ii]=*its ;
- ii++;
- }
-
- delete[] tmp_array[i] ;
- tmp_array[i] = tmp_arrayNew ;
- _totalNumberOfElements-=(numberOfElementsInType-newNumberOfElements) ;
-
- } else
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"ERROR")) ;
- }
- delete[] whereIsType ;
- delete[] tmp_NumberOfElementsInType ;
- delete [] _numberOfElements;
-
- _numberOfElements = numberOfElements;
-
- _numberOfGeometricType = it ;
- medGeometryElement * geometricType=_geometricType ;
- _geometricType = new medGeometryElement[it] ;
- int * numberOfGaussPoint=_numberOfGaussPoint ;
- _numberOfGaussPoint= new int[it] ;
-// int * geometricTypeNumber=_geometricTypeNumber ;
-// _geometricTypeNumber = new int[it] ;
-
-// 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(numberValue+numberIndex[i]-1,tmp_array[i],sizeof(int)*_numberOfElements[i]) ;
- delete[] tmp_array[i] ;
- numberIndex[i+1]=numberIndex[i]+_numberOfElements[i] ;
-
- _geometricType[i]=myType[i] ;
- _numberOfGaussPoint[i]=1 ;
- }
- 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[] numberOfElements ;
-
-
-
-
- MESSAGE(LOC<<"Printing of the object SUPPORT blended "<< *this);
-
-
-
-
+ if(mySupport->_totalNumberOfElements==0)
+ return;
+ const int *ids=getNumber(MED_ALL_ELEMENTS);
+ set<int> idsSet(ids,ids+getNumberOfElements(MED_ALL_ELEMENTS));
+ const int *idsMySupport=mySupport->getNumber(MED_ALL_ELEMENTS);
+ int mySupportSize=mySupport->getNumberOfElements(MED_ALL_ELEMENTS);
+ set<int>::iterator iter;
+ for(int i=0;i<mySupportSize;i++)
+ idsSet.insert(idsMySupport[i]);
+ int size=idsSet.size();
+ if(size!=0)
+ {
+ list<int> idsList;
+ for(iter=idsSet.begin();iter!=idsSet.end();iter++)
+ idsList.push_back(*iter);
+ if(_entity==MED_NODE)
+ fillFromNodeList(idsList);
+ else
+ fillFromElementList(idsList);
+ }
+ else
+ clearDataOnNumbers();
END_OF(LOC);
-};
+}
/*!
This function allows the user to set a support not on all entities Entity,
_numberOfGaussPoint = new int[NumberOfGeometricType];
int * index = new int[_numberOfGeometricType+1];
index[0]=1;
+ int elemDim = -1;
for (int i=0;i<_numberOfGeometricType;i++) {
+ if(GeometricType[i]/100 != elemDim)
+ if(i==0)
+ elemDim=GeometricType[i]/100;
+ else
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"unhomogeneous geometric types (dimension) !"));
_geometricType[i] = GeometricType[i] ;
_numberOfElements[i] = NumberOfElements[i] ;
_numberOfGaussPoint[i] = 1 ;
void SUPPORT::intersecting(SUPPORT * mySupport) throw (MEDEXCEPTION)
//-------------------
{
- const char * LOC = "SUPPORT::intersecting(SUPPORT *) : " ;
- BEGIN_OF(LOC) ;
-
- MESSAGE(LOC<< "SUPPORT entry : " << *mySupport) ;
-
- MESSAGE(LOC<< "SUPPORT (calling object) : " << *this) ;
-
- // on same entity :
- if ( _entity != mySupport->getEntity() )
+ const char * LOC="SUPPORT::intersecting(SUPPORT *) : ";
+ BEGIN_OF(LOC);
+ if (_entity!=mySupport->getEntity())
throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Entities are different !"));
-
- int * tmp_NumberOfElementsInType = new int[MED_NBR_GEOMETRIE_MAILLE];
- medGeometryElement * myType = new medGeometryElement[MED_NBR_GEOMETRIE_MAILLE];
- int * whereIsType = new int[MED_NBR_GEOMETRIE_MAILLE];
- //MESH_ENTITIES myMeshEntities() ;
- list<MED_EN::medGeometryElement>::const_iterator listIt ;
- int it=0 ;
- for(listIt=(meshEntities[_entity]).begin();listIt!=(meshEntities[_entity]).end();listIt++) {
- tmp_NumberOfElementsInType[it]=0;
- whereIsType[it]=0 ;
- myType[it]= MED_NONE;
- try {
- tmp_NumberOfElementsInType[it]+=getNumberOfElements((medGeometryElement)(*listIt)) ;
- whereIsType[it]+=1 ;
- }
- catch (const MEDEXCEPTION & ex) {};
- try {
- tmp_NumberOfElementsInType[it]+=mySupport->getNumberOfElements((medGeometryElement)(*listIt)) ;
- whereIsType[it]+=2 ;
- }
- catch (const MEDEXCEPTION & ex) {};
- if (whereIsType[it]==3) {
- myType[it]=(medGeometryElement)(*listIt) ;
- it++;
+ if(!(*_mesh == *mySupport->getMesh()))
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Mesh are different !"));
+ if(mySupport->isOnAllElements())
+ return;
+ if(_isOnAllElts)
+ {
+ *this=*mySupport;
+ return;
}
- }
-
- MESSAGE("it = "<< it);
-
- // set new value :
- 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] ;
- _numberOfElements[i] = numberOfElementsInType ;
- tmp_array[i] = new int[numberOfElementsInType] ;
- _totalNumberOfElements+=numberOfElementsInType ;
- if (whereIsType[i] == 3) {
- const int * number1 = getNumber(myType[i]) ;
- const int * number2 = mySupport->getNumber(myType[i]) ;
-
- SCRUTE(number1);
- SCRUTE(number2);
-
- int numberOfElements1 = numberOfElements[i] ;
- int numberOfElements2 = mySupport->getNumberOfElements(myType[i]) ;
-
- SCRUTE(numberOfElements1);
- SCRUTE(numberOfElements2);
-
- set<int> setList1(number1,number1+numberOfElements1);
- set<int> setList2(number2,number2+numberOfElements2);
-
- for(set<int>::iterator its=setList1.begin();its!=setList1.end(); its++)
- {
- MESSAGE("Number1 " << *its);
- }
-
- for(set<int>::iterator its=setList2.begin();its!=setList2.end(); its++)
- {
- MESSAGE("Number2 " << *its);
- }
-
- set<int> setListIntersect;
-
- set_intersection(setList1.begin(),setList1.end(),setList2.begin(),
- setList2.end(),inserter(setListIntersect,
- setListIntersect.begin()));
-
- for(set<int>::iterator its=setListIntersect.begin();
- its!=setListIntersect.end(); its++)
- {
- MESSAGE("Number1 intersect Number2 " << *its);
- }
-
- int newNumberOfElements = setListIntersect.size() ;
-
- SCRUTE(newNumberOfElements);
-
- _numberOfElements[i] = newNumberOfElements ;
- int * tmp_arrayNew = new int[newNumberOfElements];
-
- int ii = 0 ;
-
- for(set<int>::iterator its=setListIntersect.begin();
- its!=setListIntersect.end(); its++) {
- tmp_arrayNew[ii]=*its ;
- SCRUTE(tmp_arrayNew[ii]);
- ii++;
- }
-
- delete[] tmp_array[i] ;
- tmp_array[i] = tmp_arrayNew ;
- _totalNumberOfElements-=(numberOfElementsInType-newNumberOfElements) ;
-
- } else
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"ERROR")) ;
- }
- delete[] whereIsType ;
- delete[] tmp_NumberOfElementsInType ;
-
- _numberOfGeometricType = it ;
- medGeometryElement * geometricType=_geometricType ;
- _geometricType = new medGeometryElement[it] ;
- int * numberOfGaussPoint=_numberOfGaussPoint ;
- _numberOfGaussPoint= new int[it] ;
-
- 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(numberValue+numberIndex[i]-1,tmp_array[i],sizeof(int)*_numberOfElements[i]) ;
- delete[] tmp_array[i] ;
- numberIndex[i+1]=numberIndex[i]+_numberOfElements[i] ;
-
- _geometricType[i]=myType[i] ;
- _numberOfGaussPoint[i]=1 ;
- }
- if ( _number != (MEDSKYLINEARRAY *) NULL) delete _number ;
-
- _number = new MEDSKYLINEARRAY(it,_totalNumberOfElements,numberIndex,numberValue);
- delete[] numberIndex;
+ if(_totalNumberOfElements==0)
+ return;
+ const int *ids=getNumber(MED_ALL_ELEMENTS);
+ set<int> idsSet(ids,ids+getNumberOfElements(MED_ALL_ELEMENTS));
+ const int *idsMySupport=mySupport->getNumber(MED_ALL_ELEMENTS);
+ int mySupportSize=mySupport->getNumberOfElements(MED_ALL_ELEMENTS);
+ set<int> idsSetMySupport(idsMySupport,idsMySupport+mySupportSize);
+ set<int>::iterator iter;
+ list<int> idsList;
+ for(iter=idsSet.begin();iter!=idsSet.end();iter++)
+ if(idsSetMySupport.find(*iter)!=idsSetMySupport.end())
+ idsList.push_back(*iter);
+ int size=idsSet.size();
+ if(size!=0)
+ {
+ if(_entity==MED_NODE)
+ fillFromNodeList(idsList);
+ else
+ fillFromElementList(idsList);
+ }
+ else
+ {
+ clearDataOnNumbers();
+ }
+ END_OF(LOC);
+};
- delete[] numberValue;
+/*!
+ operator = perform et deep copy except for attribute _mesh
+ */
+SUPPORT& MEDMEM::SUPPORT::operator=(const SUPPORT &other)
+{
+ const char * LOC = "SUPPORT::operator=(const SUPPORT & m) : ";
+ BEGIN_OF(LOC);
- delete[] myType ;
- delete[] tmp_array ;
+ _name=other._name;
+ _description=other._description;
+ _mesh=other._mesh;
+ _entity=other._entity;
+ _isOnAllElts=other._isOnAllElts;
+ clearDataOnNumbers();
+ _numberOfGeometricType=other._numberOfGeometricType;
+ _totalNumberOfElements=other._totalNumberOfElements;
- delete[] geometricType ;
- delete[] numberOfGaussPoint ;
-// delete[] geometricTypeNumber ;
- delete[] numberOfElements ;
+ if(other._geometricType != NULL)
+ {
+ _geometricType=new medGeometryElement[other._numberOfGeometricType];
+ memcpy(_geometricType,other._geometricType,other._numberOfGeometricType*sizeof(medGeometryElement));
+ }
+ if (other._numberOfGaussPoint != NULL)
+ {
+ _numberOfGaussPoint=new int[other._numberOfGeometricType];
+ memcpy(_numberOfGaussPoint,other._numberOfGaussPoint,other._numberOfGeometricType*sizeof(int));
+ }
+ if(other._numberOfElements != NULL)
+ {
+ _numberOfElements=new int[_numberOfGeometricType];
+ memcpy(_numberOfElements,other._numberOfElements,_numberOfGeometricType*sizeof(int));
+ }
+ if(!_isOnAllElts)
+ {
+ _number=new MEDSKYLINEARRAY(* other._number);
+ }
+ return *this;
+}
- END_OF(LOC);
-};
+/*!
+ Method that cleans up all the fields related to _numbers. Defined for code factorization.
+ */
+//--------------------------------------------------
+void MEDMEM::SUPPORT::clearDataOnNumbers()
+//--------------------------------------------------
+{
+ _numberOfGeometricType=0;
+ _totalNumberOfElements=0;
+ if(_geometricType)
+ {
+ delete [] _geometricType;
+ _geometricType=(medGeometryElement *) NULL;
+ }
+ if(_numberOfGaussPoint)
+ {
+ delete [] _numberOfGaussPoint;
+ _numberOfGaussPoint=(int *) NULL;
+ }
+ if(_numberOfElements)
+ {
+ delete [] _numberOfElements;
+ _numberOfElements=(int *) NULL;
+ }
+ if(_number)
+ {
+ delete _number;
+ _number=(MEDSKYLINEARRAY *) NULL;
+ }
+}
/*!
operator == This operator does not compare attributs _name and _description.
bool operatorReturn = false;
- operatorReturn = (_mesh == support._mesh) && (_entity == support._entity) &&
+ operatorReturn = (*_mesh == *support._mesh) && (_entity == support._entity) &&
(_numberOfGeometricType == support._numberOfGeometricType) &&
- (_isOnAllElts == support._isOnAllElts) &&
+ ((_isOnAllElts && support._isOnAllElts) || (!_isOnAllElts && !support._isOnAllElts)) &&
(_totalNumberOfElements == support._totalNumberOfElements);
if (operatorReturn)
return operatorReturn;
};
+
+void SUPPORT::changeElementsNbs(MED_EN::medEntityMesh entity, const int *renumberingFromOldToNew, int limitNbClassicPoly, const int *renumberingFromOldToNewPoly)
+{
+ if(entity != _entity)
+ throw MEDEXCEPTION("SUPPORT::changeElementsNbs : Renumbering on a mismatch entity");
+ list<int> newNbs;
+ if(!_isOnAllElts)
+ {
+ const int *oldNbs=_number->getValue();
+ for(int i=0;i<_totalNumberOfElements;i++)
+ {
+ int globNb=oldNbs[i];
+ if(globNb<=limitNbClassicPoly)
+ newNbs.push_back(renumberingFromOldToNew[globNb-1]);
+ else
+ newNbs.push_back(renumberingFromOldToNewPoly[globNb-limitNbClassicPoly-1]);
+ }
+ newNbs.sort();
+ fillFromElementList(newNbs);
+ }
+ else
+ update();
+}
+
+/*!
+ operator == + in case false a test if coordinates and connectivity of _mesh and support->_mesh are the same
+*/
+bool MEDMEM::SUPPORT::deepCompare(const SUPPORT &support) const
+{
+ bool operatorReturn =(_entity == support._entity) &&
+ (_numberOfGeometricType == support._numberOfGeometricType) &&
+ ( (_isOnAllElts && support._isOnAllElts) || (!_isOnAllElts && !support._isOnAllElts) ) &&
+ (_totalNumberOfElements == support._totalNumberOfElements);
+ if (operatorReturn)
+ {
+ if (!_isOnAllElts)
+ {
+ for (int i=0; i<_numberOfGeometricType && operatorReturn; i++)
+ {
+ operatorReturn = (_geometricType[i] == support._geometricType[i]) &&
+ (_numberOfElements[i] == support._numberOfElements[i]) &&
+ (_numberOfGaussPoint[i] == support._numberOfGaussPoint[i]);
+ if (operatorReturn)
+ {
+ for (int j=0; j<_numberOfElements[i]; j++)
+ {
+ operatorReturn = (getNumber(_geometricType[i])[j] ==
+ support.getNumber(_geometricType[i])[j]);
+ }
+ }
+ }
+ }
+ }
+ if(operatorReturn)
+ {
+ if(!(*_mesh == *support._mesh))
+ {
+ return _mesh->deepCompare(*support._mesh);
+ }
+ }
+ return operatorReturn;
+}
+
+/*!
+ States if this is included in other.
+ */
+bool MEDMEM::SUPPORT::belongsTo(const SUPPORT& other, bool deepCompare) const
+{
+ if(!(*_mesh == *other._mesh))
+ {
+ if(!deepCompare)
+ return false;
+ if(!_mesh->deepCompare(*other._mesh))
+ return false;
+ }
+ if(_entity!=other._entity)
+ return false;
+ if(other._isOnAllElts)
+ return true;
+ if(_isOnAllElts && !other._isOnAllElts)
+ return false;
+ if(_numberOfGeometricType>other._numberOfGeometricType)
+ return false;
+ for(int i=0; i<_numberOfGeometricType; i++)
+ {
+ MED_EN::medGeometryElement curGeomType=_geometricType[i];
+ int iOther=-1;
+ for(int j=0; j<other._numberOfGeometricType; j++)
+ if(other._geometricType[j]==curGeomType)
+ iOther=j;
+ if(iOther==-1)
+ return false;
+ if(_numberOfElements[i]>other._numberOfElements[iOther])
+ return false;
+ const int *numbers1=_number->getI(i+1);
+ const int *numbers2=other._number->getI(iOther+1);
+ for (int k=0; k<_numberOfElements[i]; k++)
+ {
+ bool found=false;
+ for(int l=0;l<other._numberOfElements[iOther] && !found;l++)
+ {
+ if(numbers1[k]==numbers2[l])
+ found=true;
+ }
+ if(!found)
+ return false;
+ }
+ }
+ return true;
+}
+/*!
+ Method used to sort array of id.
+ */
+int compareId(const void *x, const void *y)
+{
+ const int *x1=(const int *)x;
+ const int *y1=(const int *)y;
+ if(*x1<*y1)
+ return -1;
+ else if(*x1>*y1)
+ return 1;
+ else
+ return 0;
+}
+
+/*!
+ performs a common operation : Sub builds a sorted int array that is obtained by supression of all ids contained
+ in array defined by (idsToSuppress,lgthIdsToSuppress) from array [start ... end]
+ Example sub(0,7,{1,2,5},3) => {0,3,4,6,7} - WARNING returned list should be deallocated !
+ */
+list<int> *MEDMEM::SUPPORT::sub(int start,int end,const int *idsToSuppress,int lgthIdsToSuppress)
+{
+ int size=end-start+1;
+ int sizeRet=size-lgthIdsToSuppress;
+ list<int> *ret;
+ if(sizeRet<0)
+ throw MEDEXCEPTION("MEDMEM::SUPPORT::sub");
+ else if(sizeRet==0)
+ {
+ return 0;
+ }
+ if(idsToSuppress==0)
+ {
+ ret=new list<int>;
+ for(int l=0;l<size;l++)
+ ret->push_back(start+l);
+ return ret;
+ }
+ ret=new list<int>;
+ int *temp=new int[lgthIdsToSuppress];
+ memcpy(temp,idsToSuppress,sizeof(int)*lgthIdsToSuppress);
+ qsort(temp,lgthIdsToSuppress,sizeof(int),compareId);
+ int k=0;
+ for(int i=start;i<=end;i++)
+ if(temp[k]!=i)
+ ret->push_back(i);
+ else
+ k++;
+ delete [] temp;
+ return ret;
+}
+
+/*!
+ performs a common operation : Sub builds a sorted int array that is obtained by supression of all ids contained
+ in array defined by (idsToSuppress,lgthIdsToSuppress) from array [start ... end]
+ Example sub({1,3,4,5,6,7,9},7,{1,2,5},3) => {3,4,6,7,9} - WARNING returned list should be deallocated !
+ */
+list<int> *MEDMEM::SUPPORT::sub(const int *ids,int lgthIds,const int *idsToSuppress,int lgthIdsToSuppress)
+{
+ list<int> *ret;
+ int i,j=0;
+ if(lgthIds<0)
+ throw MEDEXCEPTION("MEDMEM::SUPPORT::sub");
+ else if(lgthIds==0)
+ return 0;
+ ret=new list<int>;
+ int *temp1=new int[lgthIds];
+ memcpy(temp1,ids,sizeof(int)*lgthIds);
+ qsort(temp1,lgthIds,sizeof(int),compareId);
+ int *temp2=new int[lgthIdsToSuppress];
+ memcpy(temp2,idsToSuppress,sizeof(int)*lgthIdsToSuppress);
+ qsort(temp2,lgthIdsToSuppress,sizeof(int),compareId);
+ for(i=0;i<lgthIds;)
+ {
+ if(j>=lgthIdsToSuppress)
+ ret->push_back(temp1[i++]);
+ else if(temp1[i]>temp2[j])
+ j++;
+ else if(temp1[i]<temp2[j])
+ ret->push_back(temp1[i++]);
+ else
+ i++;
+ }
+ delete [] temp1;
+ delete [] temp2;
+ return ret;
+}
+
+/*!
+ returns a new SUPPORT (responsability to caller to destroy it)
+ that is the complement to "this", lying on the same entity than "this".
+ */
+SUPPORT *MEDMEM::SUPPORT::getComplement() const
+{
+ SUPPORT *ret;
+ const int nbOfElt=_mesh->getNumberOfElements(_entity,MED_EN::MED_ALL_ELEMENTS);
+ int nbOfEltInSupp=getNumberOfElements(MED_EN::MED_ALL_ELEMENTS);
+ if(_isOnAllElts || nbOfElt==nbOfEltInSupp)
+ {
+ ret=new SUPPORT;
+ ret->setMesh(_mesh);
+ ret->setEntity(_entity);
+ string name="Complement of ";
+ name+=_name;
+ ret->setName(name);
+ return ret;
+ }
+ const int *nbs=_number->getValue();
+ list<int> *ids=sub(1,nbOfElt,nbs,nbOfEltInSupp);
+ if(_entity==MED_EN::MED_NODE)
+ ret=_mesh->buildSupportOnNodeFromElementList(*ids,_entity);
+ else
+ ret=_mesh->buildSupportOnElementsFromElementList(*ids,_entity);
+ delete ids;
+ return ret;
+}
+
+/*!
+ returns a new support the user should delete.
+ */
+SUPPORT *MEDMEM::SUPPORT::substract(const SUPPORT& other) const throw (MEDEXCEPTION)
+{
+ const char * LOC = "SUPPORT *MEDMEM::subtract(const SUPPORT * other) : ";
+ BEGIN_OF(LOC);
+ SUPPORT *ret;
+ if (_entity!=other.getEntity())
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Entities are different !"));
+ if(!(*_mesh == *other.getMesh()))
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Mesh are different !"));
+ if(other._isOnAllElts)
+ {
+ ret=new SUPPORT;
+ ret->setMesh(_mesh);
+ ret->setEntity(_entity);
+ return ret;
+ }
+ if(_isOnAllElts)
+ return other.getComplement();
+ int nbOfEltInThis=getNumberOfElements(MED_EN::MED_ALL_ELEMENTS);
+ const int *nbsThis=_number->getValue();
+ int nbOfEltInOther=other.getNumberOfElements(MED_EN::MED_ALL_ELEMENTS);
+ const int *nbsOther=other._number->getValue();
+ list<int> *ids=sub(nbsThis,nbOfEltInThis,nbsOther,nbOfEltInOther);
+ if(_entity==MED_EN::MED_NODE)
+ ret=_mesh->buildSupportOnNodeFromElementList(*ids,_entity);
+ else
+ ret=_mesh->buildSupportOnElementsFromElementList(*ids,_entity);
+ delete ids;
+ return ret;
+ END_OF(LOC);
+}
+
+/*!
+ returns a new support the user has to delete. Entity is either MED_NODE to obtain node elements lying on boundary of "this"
+ or MED_FACE,MED_EDGE (depends on the this->_mesh dimension).
+ */
+SUPPORT *MEDMEM::SUPPORT::getBoundaryElements(MED_EN::medEntityMesh Entity) const throw (MEDEXCEPTION)
+{
+ const char * LOC = "SUPPORT *MEDMEM::SUPPORT::getBoundaryElements(MED_EN::medEntityMesh Entity) : ";
+ BEGIN_OF(LOC);
+ int spaceDimension=_mesh->getSpaceDimension();
+ MED_EN::medEntityMesh baseEntity=Entity;
+ if (spaceDimension == 3)
+ if (Entity!=MED_FACE)
+ if(Entity==MED_NODE)
+ baseEntity=MED_FACE;
+ else
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined in 3D mesh for entity "<<Entity<<" !"));
+ if (spaceDimension == 2)
+ if (Entity!=MED_EDGE)
+ if(Entity==MED_NODE)
+ baseEntity=MED_EDGE;
+ else
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined in 2D mesh for entity "<<Entity<<" !"));
+ if(_isOnAllElts)
+ return _mesh->getBoundaryElements(Entity);
+
+ const int * myConnectivityValue=_mesh->getReverseConnectivity(MED_DESCENDING);
+ const int * myConnectivityIndex=_mesh->getReverseConnectivityIndex(MED_DESCENDING);
+ int numberOf=_mesh->getNumberOfElements(baseEntity,MED_ALL_ELEMENTS);
+ const int *ids=_number->getValue();
+ set<int> idsSet(ids,ids+_totalNumberOfElements);
+ list<int> myElementsList;
+ for (int i=0;i<numberOf;i++)
+ {
+ int nbOfDP1EntitySharing=0;
+ if(idsSet.find(myConnectivityValue[myConnectivityIndex[i]-1])!=idsSet.end())
+ nbOfDP1EntitySharing++;
+ if(idsSet.find(myConnectivityValue[myConnectivityIndex[i]])!=idsSet.end())
+ nbOfDP1EntitySharing++;
+ if(nbOfDP1EntitySharing==1)
+ myElementsList.push_back(i+1);
+ }
+ if(Entity==MED_NODE)
+ {
+ return _mesh->buildSupportOnNodeFromElementList(myElementsList,baseEntity);
+ }
+ else
+ {
+ return _mesh->buildSupportOnElementsFromElementList(myElementsList,baseEntity);
+ }
+}
+
+/*!
+ Method that fills this and updates all its attributes in order to lye on the the listOfNode.
+ */
+void MEDMEM::SUPPORT::fillFromNodeList(const list<int>& listOfNode) throw (MEDEXCEPTION)
+{
+ setEntity(MED_EN::MED_NODE);
+ clearDataOnNumbers();
+ int size=listOfNode.size();
+ int totalNbInMesh=_mesh->getNumberOfElements(_entity,MED_ALL_ELEMENTS);
+ if(totalNbInMesh==size)
+ {
+ _isOnAllElts=true;
+ update();
+ return;
+ }
+ else
+ _isOnAllElts=false;
+ int numberOfGeometricType=1;
+ medGeometryElement* geometricType=new medGeometryElement[1];
+ geometricType[0]=MED_NONE;
+ int *numberOfGaussPoint=new int[1];
+ numberOfGaussPoint[0]=1;
+ int *numberOfElements=new int[1];
+ numberOfElements[0]=size;
+ int *mySkyLineArrayIndex=new int[2];
+ mySkyLineArrayIndex[0]=1;
+ mySkyLineArrayIndex[1]=1+numberOfElements[0];
+ int *tab=new int[numberOfElements[0]];
+ int i=0;
+ for(list<int>::const_iterator iter2=listOfNode.begin();iter2!=listOfNode.end();iter2++)
+ tab[i++]=*iter2;
+ MEDSKYLINEARRAY * mySkyLineArray = new MEDSKYLINEARRAY(1,numberOfElements[0],mySkyLineArrayIndex,tab,true);
+ setNumberOfGeometricType(numberOfGeometricType);
+ setGeometricType(geometricType);
+ setNumberOfGaussPoint(numberOfGaussPoint);
+ setNumberOfElements(numberOfElements);
+ setTotalNumberOfElements(numberOfElements[0]);
+ setNumber(mySkyLineArray);
+
+ delete[] numberOfElements;
+ delete[] numberOfGaussPoint;
+ delete[] geometricType;
+}
+
+/*
+ Method created to factorize code. This method fills the current SUPPORT on entity 'entity' containing all the entities contained in
+ elements 'listOfElt' of entity 'entity'. Warning this method should be called after both the attributes this->_mesh and this->_entity are correctly set.
+ */
+void MEDMEM::SUPPORT::fillFromElementList(const list<int>& listOfElt) throw (MEDEXCEPTION)
+{
+ clearDataOnNumbers();
+ int size=listOfElt.size();
+ int totalNbInMesh=_mesh->getNumberOfElementsWithPoly(_entity,MED_ALL_ELEMENTS);
+ if(totalNbInMesh==size){
+ _isOnAllElts=true;
+ update();
+ return;
+ }
+ else
+ _isOnAllElts=false;
+ // Well, we must know how many geometric type we have found
+ int * myListArray = new int[size] ;
+ int id = 0 ;
+ list<int>::const_iterator myElementsListIt ;
+ for (myElementsListIt=listOfElt.begin();myElementsListIt!=listOfElt.end();myElementsListIt++)
+ myListArray[id++]=(*myElementsListIt) ;
+ int numberOfGeometricType ;
+ medGeometryElement* geometricType ;
+ int * numberOfGaussPoint ;
+ int * numberOfElements ;
+ int * mySkyLineArrayIndex ;
+
+ int numberOfType = _mesh->getNumberOfTypesWithPoly(_entity) ;
+ if (numberOfType == 1) {
+ numberOfGeometricType = 1 ;
+ geometricType = new medGeometryElement[1] ;
+ medGeometryElement * allType = _mesh->getTypesWithPoly(_entity);
+ geometricType[0] = allType[0] ;
+ numberOfGaussPoint = new int[1] ;
+ numberOfGaussPoint[0] = 1 ;
+ numberOfElements = new int[1] ;
+ numberOfElements[0] = size ;
+ mySkyLineArrayIndex = new int[2] ;
+ mySkyLineArrayIndex[0]=1 ;
+ mySkyLineArrayIndex[1]=1+size ;
+ delete [] allType;
+ }
+ else {// hemmm
+ map<medGeometryElement,int> theType ;
+ for (myElementsListIt=listOfElt.begin();myElementsListIt!=listOfElt.end();myElementsListIt++) {
+ medGeometryElement myType = _mesh->getElementTypeWithPoly(_entity,*myElementsListIt) ;
+ if (theType.find(myType) != theType.end() )
+ theType[myType]+=1 ;
+ else
+ theType[myType]=1 ;
+ }
+ numberOfGeometricType = theType.size() ;
+ geometricType = new medGeometryElement[numberOfGeometricType] ;
+ numberOfGaussPoint = new int[numberOfGeometricType] ;
+ 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 ;
+ numberOfElements[index] = (*theTypeIt).second ;
+ mySkyLineArrayIndex[index+1]=mySkyLineArrayIndex[index]+numberOfElements[index] ;
+ index++ ;
+ }
+ }
+ MEDSKYLINEARRAY * mySkyLineArray = new MEDSKYLINEARRAY(numberOfGeometricType,size,mySkyLineArrayIndex,myListArray,true) ;
+ setNumberOfGeometricType(numberOfGeometricType) ;
+ setGeometricType(geometricType) ;
+ setNumberOfGaussPoint(numberOfGaussPoint) ;
+ setNumberOfElements(numberOfElements) ;
+ setTotalNumberOfElements(size) ;
+ setNumber(mySkyLineArray) ;
+
+ delete[] numberOfElements;
+ delete[] numberOfGaussPoint;
+ delete[] geometricType;
+}
+
+/*! set the reference _mesh to Mesh */
+//--------------------------------------
+void SUPPORT::setMesh(MESH *Mesh)
+//--------------------------------------
+{
+ if(_mesh)
+ _mesh->removeReference();
+ _mesh=Mesh;
+ if(_mesh)
+ _mesh->addReference();
+}
+
+/*!
+ addReference : reference counter presently disconnected in C++ -> just connected for client.
+*/
+void MEDMEM::SUPPORT::addReference() const
+{
+}
+
+/*!
+ removeReference : reference counter presently disconnected in C++ -> just connected for client.
+*/
+void MEDMEM::SUPPORT::removeReference() const
+{
+}
#include <vector>
#include <string>
+#include <list>
#include "utilities.h"
#include "MEDMEM_STRING.hxx"
#include "MEDMEM_Exception.hxx"
#include "MEDMEM_define.hxx"
#include "MEDMEM_SkyLineArray.hxx"
+#include "MEDMEM_RCBase.hxx"
/*!
namespace MEDMEM {
class MESH ;
-class SUPPORT
+class SUPPORT : public RCBASE
{
protected:
/*!
// the two following arrays are defined only if _isOnAllElts is false :
- /*
- \if developper
- array of size _numberOfType+1 wich contains for
- each geometric type, index in _number._value
- (if _all is true, we must ask _mesh to get
- information). _typeIndex[i+1]-_typeIndex[i]
- represents count of entities of ith geometric
- type. _typeIndex[_numberOfType] contains total
- entities count. If _numberOf[i]=0,
- _typeIndex[i+1]=_typeIndex[i]
- defined only if _isOnAllElts is false
- \endif
- */
- // int * _typeIndex;
-
/*!
\if developper
Array of size _index[_numberOfType]-1 wich contain number of
virtual ~SUPPORT();
friend ostream & operator<<(ostream &os,const SUPPORT &my);
+ SUPPORT& operator=(const SUPPORT &support);
bool operator == (const SUPPORT &support) const;
-
+ bool deepCompare(const SUPPORT &support) const;
// function to set all value when SUPPORT was created by MedMedDriver without all MESH information !!! Change with new API !
void update();
inline void setName(string Name);
inline void setDescription(string Description);
- inline void setMesh(MESH *Mesh);
+ void setMesh(MESH *Mesh);
inline void setAll(bool All);
inline void setEntity(MED_EN::medEntityMesh Entity);
inline void setNumberOfGeometricType(int NumberOfGeometricType);
inline void setGeometricType(const MED_EN::medGeometryElement *GeometricType);
inline void setNumberOfGaussPoint(const int *NumberOfGaussPoint);
- // inline void setGeometricTypeNumber(int *GeometricTypeNumber);
inline void setNumberOfElements(const int *NumberOfElements);
inline void setTotalNumberOfElements(int TotalNumberOfElements);
inline void setNumber(MEDSKYLINEARRAY * Number);
inline const MED_EN::medGeometryElement* getTypes() const ;
inline const int * getNumberOfGaussPoint() const throw (MEDEXCEPTION);
inline int getNumberOfGaussPoint(MED_EN::medGeometryElement geomElement) const throw (MEDEXCEPTION);
- //inline int * getGeometricTypeNumber() const;
- //inline int getTotalNumberOfElement() const;
inline int getNumberOfElements(MED_EN::medGeometryElement GeometricType) const throw (MEDEXCEPTION);
virtual inline MEDSKYLINEARRAY * getnumber() const throw (MEDEXCEPTION);
virtual inline const int * getNumber(MED_EN::medGeometryElement GeometricType) const throw (MEDEXCEPTION);
int *NumberOfEntity, int *NumberValue);
void getBoundaryElements() throw (MEDEXCEPTION);
-
+ void changeElementsNbs(MED_EN::medEntityMesh entity, const int *renumberingFromOldToNew, int limitNbClassicPoly, const int *renumberingFromOldToNewPoly=0);
void intersecting(SUPPORT * mySupport) throw (MEDEXCEPTION) ;
+ bool belongsTo(const SUPPORT& other, bool deepCompare=false) const;
+ SUPPORT *getComplement() const;
+ SUPPORT *substract(const SUPPORT& other) const throw (MEDEXCEPTION) ;
+ SUPPORT *getBoundaryElements(MED_EN::medEntityMesh Entity) const throw (MEDEXCEPTION);
+ void fillFromNodeList(const list<int>& listOfNode) throw (MEDEXCEPTION);
+ void fillFromElementList(const list<int>& listOfElt) throw (MEDEXCEPTION);
+ void clearDataOnNumbers();
+ //A.G. Addings for RC
+ virtual void addReference() const;
+ virtual void removeReference() const;
+protected:
+ static list<int> *sub(int start,int end,const int *idsToSuppress,int lgthIdsToSuppress);
+ static list<int> *sub(const int *ids,int lgthIds,const int *idsToSuppress,int lgthIdsToSuppress);
};
// _____________________
throw (MEDEXCEPTION)
//---------------------------------------------------------------------
{
- const char * LOC = "Support::getNumber : " ;
if (_isOnAllElts)
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined, support is on all entity !")) ;
+ throw MEDEXCEPTION("Support::getNumber : Not defined, support is on all entity !") ;
if (GeometricType==MED_EN::MED_ALL_ELEMENTS)
return _number->getValue() ;
for (int i=0;i<_numberOfGeometricType;i++)
if (_geometricType[i]==GeometricType)
return _number->getI(i+1) ;
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"GeometricType not found !")) ;
+ throw MEDEXCEPTION("Support::getNumber : GeometricType not found !") ;
}
/*!
} else
throw MEDEXCEPTION("Support::getNumberOfGaussPoint : Not defined !") ;
}
-// inline int SUPPORT::getNumberLength() const
-// throw (MEDEXCEPTION)
-// {
-// if (_isOnAllElts)
-// throw MEDEXCEPTION("Support::getNumberLength : Not defined, support is on all entity !") ;
-// return _number->getLength() ;
-// }
/*! set the attribute _name to Name */
//--------------------------------------
_description=Description;
}
-/*! set the reference _mesh to Mesh */
-//--------------------------------------
-inline void SUPPORT::setMesh(MESH *Mesh)
-//--------------------------------------
-{
- _mesh=Mesh;
-}
-
/*! set the attribute _isOnAllElts to All */
//------------------------------------------
inline void SUPPORT::setAll(bool All)
inline void SUPPORT::setEntity(MED_EN::medEntityMesh Entity)
{
_entity=Entity;
-// if ( Entity == MED_NODE) {
-// _numberOfGeometricType=1 ;
-// if (_geometricType == (medGeometryElement *) NULL)
-// _geometricType=new medGeometryElement[1] ;
-// else
-// {
-// // delete previous ???
-// delete [] _geometricType;
-// _geometricType=new medGeometryElement[1] ;
-// }
-// _geometricType[0]=MED_NONE ;
-// }
}
/*! set the attribute _numberOfGeometricType to NumberOfGeometricType */
_geometricType=new MED_EN::medGeometryElement[_numberOfGeometricType];
for (int i=0;i<_numberOfGeometricType;i++)
_geometricType[i] = GeometricType[i];
- // _geometricType=GeometricType;
}
/*! set the attribute _numberOfGaussPoint to NumberOfGaussPoint */
_numberOfGaussPoint=new int[_numberOfGeometricType];
for (int i=0;i<_numberOfGeometricType;i++)
_numberOfGaussPoint[i] = NumberOfGaussPoint[i];
- // _numberOfGaussPoint = NumberOfGaussPoint ;
}
-/*! set the attribute _geometricTypeNumber to GeometricTypeNumber */
-//-------------------------------------------------------------------
-//inline void SUPPORT::setGeometricTypeNumber(int *GeometricTypeNumber)
-//-------------------------------------------------------------------
-//{
-// _geometricTypeNumber=GeometricTypeNumber;
-//}
-
/*!
Set the attribute _numberOfElements to NumberOfElements and
calculate the total number of elements.
inline const MED_EN::medGeometryElement * SUPPORT::getTypes() const
//---------------------------------------------------
{
- // if ((_isOnAllElts)&(_entity != MED_NODE))
- // return _mesh->getTypes(_entity) ;
- // else
return _geometricType;
}
-//---------------------------------------------------
-//inline int * SUPPORT::getGeometricTypeNumber() const
-//---------------------------------------------------
-// {
-// const char * LOC = "SUPPORT::getGeometricTypeNumber() : ";
-// if (_isOnAllElts)
-// throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined (is on all elements) !"));
-// if (_geometricTypeNumber==NULL)
-// throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined !"));
-// return _geometricTypeNumber;
-// }
-
}//End namespace MEDMEM
#include "MEDMEM_GenDriver.hxx"
#include "utilities.h"
-#include "MEDMEM_STRING.hxx"
#include "MEDMEM_Exception.hxx"
#include "MEDMEM_Unit.hxx"
#include "MEDMEM_Array.hxx"
#include "MEDMEM_Support.hxx"
-//#include "MEDMEM_Field.hxx"
#include "MEDMEM_Mesh.hxx"
#include "MEDMEM_CellModel.hxx"
Constructor.
*/
VTK_FIELD_DRIVER():GENDRIVER(),
- _ptrField((FIELD<T> *)MED_NULL), _fieldName(""),
+ _ptrField((FIELD<T> *) 0), _fieldName(""),
_fieldNum(MED_INVALID)
{
const char * LOC = "VTK_FIELD_DRIVER::VTK_FIELD_DRIVER() ";
using namespace MEDMEM;
using namespace MED_EN;
+#define MED_NULL NULL
+
VTK_MESH_DRIVER::VTK_MESH_DRIVER(): GENDRIVER(),
_ptrMesh((MESH * const)MED_NULL)
{
#include <assert.h>
// UTILE AUX DEUX NAMESPACES
+extern "C"{
#include <hdf5.h>
+}
-# include <med.hxx>
-# include <med_proto.hxx>
-
-// namespace MED_FR {
-// extern "C" {
-// # include <med.h>
-// # include <med_proto.h>
-// }
-// }
namespace MED_EN {
- extern "C" {
+ extern "C" { // on est la
-#define MED_NULL (void *) NULL
-#define MED_MAX_PARA 20
+// #define MED_NULL (void *) NULL
+// #define MED_MAX_PARA 20
-#define MED_TAILLE_DESC 200
-#define MED_TAILLE_IDENT 8
-#define MED_TAILLE_NOM 32
-#define MED_TAILLE_LNOM 80
-#define MED_TAILLE_PNOM 8
+// #define MED_TAILLE_DESC 200
+// #define MED_TAILLE_IDENT 8
+// #define MED_TAILLE_NOM 32
+// #define MED_TAILLE_LNOM 80
+// #define MED_TAILLE_PNOM 8
typedef long medGeometryElement;
const medGeometryElement MED_PYRA13 = 313;
const medGeometryElement MED_PENTA15 = 315;
const medGeometryElement MED_HEXA20 = 320;
+ const medGeometryElement MED_POLYGON = 400;
+ const medGeometryElement MED_POLYHEDRA = 500;
const medGeometryElement MED_ALL_ELEMENTS = 999;
typedef long medEntityMesh;
typedef enum {MED_CARTESIAN, MED_POLAR, MED_BODY_FITTED} med_grid_type;
- typedef enum {MED_LECT,MED_ECRI,MED_REMP} med_mode_acces;
-
- typedef enum {MED_COOR, MED_CONN, MED_NOM, MED_NUM, MED_FAM} med_table;
+ typedef enum {MED_LECT,MED_ECRI,MED_REMP} med_mode_acces;
+
+ typedef enum {ASCENDING=7,DESCENDING=77} med_sort_direc;
- typedef enum {MED_REEL64=6, MED_INT32=24,MED_INT64=26, MED_INT} med_type_champ;
+ typedef enum {MED_REEL64=6, MED_INT32=24,MED_INT64=26} med_type_champ;
-#define MED_NBR_GEOMETRIE_MAILLE 15
-#define MED_NBR_GEOMETRIE_FACE 4
-#define MED_NBR_GEOMETRIE_ARETE 2
+// #define MED_NBR_GEOMETRIE_MAILLE 15
+// #define MED_NBR_GEOMETRIE_FACE 4
+// #define MED_NBR_GEOMETRIE_ARETE 2
typedef enum {MED_CART, MED_CYL, MED_SPHER} med_repere;
typedef enum {MED_HDF_VERSION, MED_VERSION, MED_FICH_DES} med_fich_info;
-#define MED_NOPG 1 /* -> pas de point de Gauss */
-#define MED_NOPFL "" /* -> pas de profils utilisateur */
-#define MED_NOPFLi " " /* Variable Interne */
-#define MED_NOPF 0 /* -> pas de profils pour _MEDdataseNnumEcrire */
-#define MED_NOPDT -1 /* rem: pas de pas de temps negatifs */
-#define MED_NONOR -1 /* rem: pas de n°ordre negatif */
-#define MED_DIM1 1 /* PAS */
- //#define MED_ALL 0 !!!!! NB: WARNING MED_ALL deja utilise dans l'enum medGeometryElement !!!!!!!!
-#define MED_ALL 0
+// #define MED_NOPG 1 /* -> pas de point de Gauss */
+// #define MED_NOPFL "" /* -> pas de profils utilisateur */
+// #define MED_NOPFLi " " /* Variable Interne */
+// #define MED_NOPF 0 /* -> pas de profils pour _MEDdataseNnumEcrire */
+// #define MED_NOPDT -1 /* rem: pas de pas de temps negatifs */
+// #define MED_NONOR -1 /* rem: pas de n°ordre negatif */
+// #define MED_DIM1 1 /* PAS */
+// //#define MED_ALL 0 !!!!! NB: WARNING MED_ALL deja utilise dans l'enum medGeometryElement !!!!!!!!
+// #define MED_ALL 0
#if defined(SUN4SOL2) || defined(PCLINUX) || defined(OSF1_32) || defined(IRIX64_32) || defined(RS6000)
/* interface C/FORTRAN */
/* this true only with g77 and gcc : we must change it to use directly NOMF_... and INT32 or INT64 - it will be more simple to understand and to use ! */
-#define NOMF_POST_UNDERSCORE
+// #define NOMF_POST_UNDERSCORE
/* correspondance des types avec HDF 5 */
typedef hsize_t med_size;
typedef hssize_t med_ssize;
-typedef hid_t med_idt;
+ //typedef hid_t med_idt;
typedef herr_t med_err;
/* types elementaires */
/* correspondance des types avec HDF 5 */
typedef hsize_t med_size;
typedef hssize_t med_ssize;
-typedef hid_t med_idt;
+ //typedef hid_t med_idt;
typedef herr_t med_err;
/* types elementaires */
#endif
#if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
-#define NOMF_POST_UNDERSCORE
+// #define NOMF_POST_UNDERSCORE
/* correspondance des types avec HDF 5 */
typedef hsize_t med_size;
typedef hssize_t med_ssize;
-typedef hid_t med_idt;
+ //typedef hid_t med_idt;
typedef herr_t med_err;
/* types elementaires */
/* correspondance des types avec HDF 5 */
typedef hsize_t med_size;
typedef hssize_t med_ssize;
-typedef hid_t med_idt;
+ //typedef hid_t med_idt;
typedef herr_t med_err;
/* types elementaires */
#endif
-#if defined(NOMF_PRE_UNDERSCORE) && defined(NOMF_POST_UNDERSCORE)
-# define NOMF(x) _##x##_
-#endif
-#if defined(NOMF_PRE_UNDERSCORE) && !defined(NOMF_POST_UNDERSCORE)
-# define NOMF(x) _##x
-#endif
-#if !defined(NOMF_PRE_UNDERSCORE) && defined(NOMF_POST_UNDERSCORE)
-# define NOMF(x) x##_
-#endif
-#if !defined(NOMF_PRE_UNDERSCORE) && !defined(NOMF_POST_UNDERSCORE)
-# define NOMF(x) x
-#endif
+// #if defined(NOMF_PRE_UNDERSCORE) && defined(NOMF_POST_UNDERSCORE)
+// # define NOMF(x) _##x##_
+// #endif
+// #if defined(NOMF_PRE_UNDERSCORE) && !defined(NOMF_POST_UNDERSCORE)
+// # define NOMF(x) _##x
+// #endif
+// #if !defined(NOMF_PRE_UNDERSCORE) && defined(NOMF_POST_UNDERSCORE)
+// # define NOMF(x) x##_
+// #endif
+// #if !defined(NOMF_PRE_UNDERSCORE) && !defined(NOMF_POST_UNDERSCORE)
+// # define NOMF(x) x
+// #endif
//#include "med_proto.h"
// retour des fonctions
#define OK 0
#define KO 1
-// fin
+ /*
+ enum definition for the used Med File version V2.1 or V2.2
+ because of incompatibility between them.
+ */
+
+ typedef enum {V21 = 26, V22 = 75} medFileVersion;
+
+// fin
}
// End Of NameSpace MED_EN
--- /dev/null
+/*************************************************************************
+* COPYRIGHT (C) 1999 - 2003 EDF R&D
+* 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, OR (AT YOUR OPTION) ANY LATER VERSION.
+*
+* 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
+*
+*************************************************************************/
+#include "MEDMEM_medimport_src.hxx"
+
+using namespace med_2_2;
+using namespace MEDMEM;
+
+extern "C" {
+ extern med_err MEDgaussInfo(med_idt fid, int indice, char * locname,
+ med_geometrie_element * type_geo,
+ med_int * ngauss );
+
+ extern void _MEDmodeErreurVerrouiller(void);
+
+ extern med_err _MEDnomGeometrie(char *nom_geo,
+ med_geometrie_element type_geo);
+}
+
+med_err med_2_2::OLD_MEDattrNumLire(med_idt pere, med_type_champ type,
+ char *nom, unsigned char *val,
+ hid_t hdf_file)
+{
+ med_idt attid;
+ med_err ret;
+ int type_hdf;
+
+ if ((attid = H5Aopen_name(pere,nom)) < 0)
+ return -1;
+
+ switch(type)
+ {
+ case MED_FLOAT64 :
+#if defined(PCLINUX) || defined(OSF1)
+/* type_hdf = H5T_IEEE_F64BE; */
+ if (H5Tequal(hdf_file,H5T_IEEE_F64BE))
+ type_hdf = H5T_IEEE_F64LE;
+ if (H5Tequal(hdf_file,H5T_IEEE_F64LE))
+ type_hdf = H5T_IEEE_F64BE;
+#else
+/* type_hdf = H5T_IEEE_F64LE; */
+ if (H5Tequal(hdf_file,H5T_IEEE_F64BE))
+ type_hdf = H5T_IEEE_F64LE;
+ if (H5Tequal(hdf_file,H5T_IEEE_F64LE))
+ type_hdf = H5T_IEEE_F64BE;
+#endif
+ break;
+
+ case MED_INT :
+#if defined(IRIX64) || defined(OSF1)
+ type_hdf = H5T_NATIVE_LONG;
+#else
+ type_hdf = H5T_NATIVE_INT;
+#endif
+ break;
+
+ default :
+ return -1;
+ }
+
+ if ((ret = H5Aread(attid,type_hdf,val)) < 0)
+ return -1;
+
+ if ((ret = H5Aclose(attid)) < 0)
+ return -1;
+
+ return 0;
+}
+
+
+med_err med_2_2::OLD_MEDdatasetNumLire(med_idt pere, char *nom,
+ med_type_champ type,
+ med_mode_switch interlace,
+ med_size nbdim, med_size fixdim,
+ med_size psize, med_ssize * pfltab,
+ med_int ngauss,
+ unsigned char *val,hid_t hdf_file)
+{
+ med_idt dataset, dataspace = 0, memspace = 0;
+ med_ssize start_mem[1],start_data[1],*pflmem=0,*pfldsk=0;
+ med_size stride[1],count[1],pcount[1],size[1],pflsize[1];
+ med_err ret;
+ int i,j,index,type_hdf;
+ hid_t datatype;
+ size_t typesize;
+ int dim, firstdim, dimutil, lastdim;
+ med_mode_profil pflmod;
+
+ /* Verify fixdim is between [0, nbdim] ( 0 is MED_ALL ) */
+ if ( ( fixdim < 0 ) || ( fixdim > nbdim ) )
+ return -1;
+
+ /* block pflmod to MED_COMPACT (until med2.2) */
+ pflmod = MED_COMPACT;
+
+ switch(type)
+ {
+ case MED_FLOAT64 :
+ /* 1) IA32 is LE but due to an (?HDF convertion BUG?) when using H5T_NATIVE_DOUBLE/MED_REEL64? under PCLINUX
+ the file read under SGI is incorrect
+ 2) Compaq OSF/1 is LE, since we force SGI64,SUN4SOL2,HP to write double in LE even if they are BE, mips OSF/1 must be BE
+ REM : Be careful of compatibility between MED files when changing this (med2.2) */
+#if defined(PCLINUX) || defined(OSF1)
+/* type_hdf = H5T_IEEE_F64BE; */
+ if (H5Tequal(hdf_file,H5T_IEEE_F64BE))
+ type_hdf = H5T_IEEE_F64LE;
+ if (H5Tequal(hdf_file,H5T_IEEE_F64LE))
+ type_hdf = H5T_IEEE_F64BE;
+#else
+/* type_hdf = H5T_IEEE_F64LE; */
+ if (H5Tequal(hdf_file,H5T_IEEE_F64BE))
+ type_hdf = H5T_IEEE_F64LE;
+ if (H5Tequal(hdf_file,H5T_IEEE_F64LE))
+ type_hdf = H5T_IEEE_F64BE;
+#endif
+ break;
+
+ case MED_INT32 :
+ type_hdf = H5T_NATIVE_INT;
+ break;
+
+ case MED_INT64 :
+ type_hdf = H5T_NATIVE_LONG;
+ break;
+
+ default :
+ return -1;
+ }
+
+ /* Ouverture du Dataset à lire */
+ if ((dataset = H5Dopen(pere,nom)) < 0)
+ return -1;
+
+ /* Interrogation de la taille du dataset */
+ if ( (datatype = H5Dget_type(dataset )) < 0) return -1;
+ if ( (typesize = H5Tget_size(datatype)) < 0) return -1;
+ size[0] = H5Dget_storage_size(dataset) / typesize;
+ if ( H5Tclose(datatype) < 0) return -1;
+
+ /* Create dataspace */
+ if ((dataspace = H5Screate_simple(1,size,NULL)) < 0)
+ return -1;
+
+ switch(interlace)
+ {
+ case MED_FULL_INTERLACE :
+
+ /*Initialisation des indices de boucle du traitement de l'entrelacement en fonction de la dimension fixee*/
+ if ( fixdim != MED_ALL)
+ {
+ firstdim = fixdim-1;
+ lastdim = fixdim;
+ dimutil = 1;
+ } else {
+ firstdim = 0;
+ lastdim = nbdim;
+ dimutil = nbdim;
+ }
+
+ count [0] = (*size)/(nbdim);
+
+
+ /*rem: Pas de vérification de l'assertion (*size)=n*nbdim */
+ if ( psize == MED_NOPF ) {
+
+ /* Creation d'un data space mémoire de dimension 1, de longeur size, et de longeur maxi size */
+ if ( (memspace = H5Screate_simple (1, size, NULL)) <0)
+ return -1;
+
+ stride[0] = nbdim;
+
+ for (dim=firstdim; dim < lastdim; dim++) {
+
+ start_mem[0] = dim;
+ if ( (ret = H5Sselect_hyperslab (memspace, H5S_SELECT_SET, start_mem, stride,
+ count, NULL)) <0)
+ return -1;
+
+ start_data[0] = dim*count[0];
+ if ( (ret = H5Sselect_hyperslab (dataspace, H5S_SELECT_SET, start_data, NULL,
+ count, NULL)) <0)
+ return -1;
+
+ if ((ret = H5Dread(dataset,type_hdf,memspace,dataspace,
+ H5P_DEFAULT, val)) < 0)
+ return -1;
+ }
+
+ } else {
+
+ pflsize [0] = psize*ngauss*nbdim;
+ pcount [0] = psize*ngauss*dimutil;
+ pflmem = (med_ssize *) malloc (sizeof(med_ssize)*pcount[0]);
+ pfldsk = (med_ssize *) malloc (sizeof(med_ssize)*pcount[0]);
+
+ switch(pflmod)
+ { /* switch pflmod pour FULL_INTERLACE*/
+ case MED_GLOBAL :
+
+ /* Creation d'un data space mémoire de dimension 1, de longeur size, et de longeur maxi size */
+ if ( (memspace = H5Screate_simple (1, size, NULL)) <0)
+ return -1;
+
+ for (dim=firstdim; dim < lastdim; dim++) {
+
+ for (i=0; i < psize; i++) /* i balaye les élements du profil */
+ for (j=0; j < ngauss; j++) {
+ index = i*ngauss+j + (dim-firstdim)*(psize*ngauss);
+ pflmem[index] = (pfltab[i]-1)*ngauss*nbdim + j*nbdim+dim;
+ pfldsk[index] = dim*count[0] + (pfltab[i]-1)*ngauss+j;
+ }
+ }
+
+ if ( (ret = H5Sselect_elements(memspace ,H5S_SELECT_SET, pcount[0], (const hssize_t **) pflmem ) ) <0)
+ return -1;
+
+ if ( (ret = H5Sselect_elements(dataspace,H5S_SELECT_SET, pcount[0], (const hssize_t **) pfldsk ) ) <0)
+ return -1;
+
+ break;
+
+ case MED_COMPACT :
+
+ /* Creation d'un data space mémoire de dimension 1, de la longeur du profil */
+ /* La dimension utilisée est ici nbdim, même pour un profil compact on suppose */
+ /* que l'utilisateur a toutes les coordonées stockées, même si il en demande qu'une */
+
+ if ( (memspace = H5Screate_simple (1, pflsize, NULL)) <0)
+ return -1;
+
+ for (dim=firstdim; dim < lastdim; dim++) {
+
+ for (i=0; i < psize; i++) /* i balaye les élements du profil */
+ for (j=0; j < ngauss; j++) {
+ index = i*ngauss+j + (dim-firstdim)*(psize*ngauss);
+ pflmem[index] = i*ngauss*nbdim + j*nbdim+dim;
+ pfldsk[index] = dim*count[0] + (pfltab[i]-1)*ngauss+j;
+ }
+ }
+
+ if ( (ret = H5Sselect_elements(memspace ,H5S_SELECT_SET, pcount[0], (const hssize_t **) pflmem ) ) <0)
+ return -1;
+
+ if ( (ret = H5Sselect_elements(dataspace,H5S_SELECT_SET, pcount[0], (const hssize_t **) pfldsk ) ) <0)
+ return -1;
+
+ break;
+
+ default :
+ return -1;
+ }
+
+ if ((ret = H5Dread(dataset,type_hdf,memspace,dataspace,H5P_DEFAULT, val)) < 0)
+ return -1;
+
+ free(pflmem);
+ free(pfldsk);
+ }
+
+ break;
+
+ case MED_NO_INTERLACE :
+
+ /*Initialisation des indices de boucle du traitement de l'entrelacement en fonction de la dimension fixee*/
+
+ count[0] = (*size)/nbdim;
+
+ if ( psize == MED_NOPF ) {
+
+ if ( fixdim != MED_ALL)
+ start_data[0] = (fixdim-1)*count[0];
+ else {
+ count[0] = *size;
+ start_data[0] = 0;
+ };
+
+ if ( (ret = H5Sselect_hyperslab (dataspace, H5S_SELECT_SET, start_data, NULL,
+ count, NULL)) <0)
+ return -1;
+
+ if ((ret = H5Dread(dataset,type_hdf,dataspace,dataspace,
+ H5P_DEFAULT, val)) < 0)
+ return -1;
+
+ } else {
+
+ if ( fixdim != MED_ALL)
+ {
+ firstdim = fixdim-1;
+ lastdim = fixdim;
+ dimutil = 1;
+ } else {
+ firstdim = 0;
+ lastdim = nbdim;
+ dimutil = nbdim;
+ }
+
+ pflsize [0] = psize*ngauss*nbdim;
+ pcount [0] = psize*ngauss*dimutil; /* nom pas très coherent avec count !!! A revoir */
+ pfldsk = (med_ssize *) malloc(sizeof(med_ssize)*pcount[0]);
+
+ switch(pflmod)
+ { /*switch plfmod pour NO_INTERLACE */
+ case MED_GLOBAL :
+
+ for (dim=firstdim; dim < lastdim; dim++) {
+
+ for (i=0; i < psize; i++) /* i balaye le nbre d'élements du profil */
+ for (j=0; j < ngauss; j++) {
+ index = i*ngauss+j + (dim-firstdim)*(psize*ngauss);
+ pfldsk[index] = dim*count[0]+(pfltab[i]-1)*ngauss+j;
+ }
+ }
+
+ if ( (ret = H5Sselect_elements(dataspace,H5S_SELECT_SET,pcount[0], (const hssize_t **) pfldsk ) ) <0)
+ return -1;
+
+ if ((ret = H5Dread(dataset,type_hdf,dataspace,dataspace,H5P_DEFAULT, val)) < 0)
+ return -1;
+
+ break;
+
+ case MED_COMPACT :
+
+ /* Creation d'un data space mémoire de dimension 1, de la longeur du profil */
+ /* La dimension utilisée est ici nbdim, même pour un profil compact on suppose */
+ /* que l'utilisateur a toutes les coordonées stockées, même si il en demande qu'une */
+
+ if ( (memspace = H5Screate_simple (1, pflsize, NULL)) <0)
+ return -1;
+
+ pflmem = (med_ssize *) malloc (sizeof(med_ssize)*pcount[0]);
+
+ /* Le profil COMPACT est contigüe, mais il est possible que l'on selectionne uniquemenent une dimension*/
+
+ for (dim=firstdim; dim < lastdim; dim++) {
+
+ for (i=0; i < psize; i++) /* i balaye le nbre d'élements du profil */
+ for (j=0; j < ngauss; j++) {
+ index = i*ngauss+j + (dim-firstdim)*(psize*ngauss);
+ pflmem[index] = dim*(psize*ngauss) + (pfltab[i]-1)*ngauss+j;
+ pfldsk[index] = dim*count[0] + (pfltab[i]-1)*ngauss+j;
+ }
+ }
+
+ if ( (ret = H5Sselect_elements(memspace ,H5S_SELECT_SET, pcount[0], (const hssize_t **) pflmem ) ) <0)
+ return -1;
+
+ if ( (ret = H5Sselect_elements(dataspace,H5S_SELECT_SET,pcount[0], (const hssize_t **) pfldsk ) ) <0)
+ return -1;
+
+ if ((ret = H5Dread(dataset,type_hdf,memspace,dataspace,H5P_DEFAULT, val)) < 0)
+ return -1;
+
+ break;
+
+ default :
+ return -1;
+
+ }
+
+ free(pfldsk);
+
+ };
+
+ break;
+
+ default :
+ return -1;
+ }
+
+
+
+ if (memspace)
+ if ((ret = H5Sclose(memspace)) < 0)
+ return -1;
+
+ if ((ret = H5Sclose(dataspace)) < 0)
+ return -1;
+
+ if ((ret = H5Dclose(dataset)) < 0)
+ return -1;
+
+ return 0;
+}
+
+
+void med_2_2::conversion_chaine(char *ancienne_chaine,
+ char *nouvelle_chaine,
+ med_int n)
+{
+ int i;
+ int j;
+ char tmp[MED_TAILLE_PNOM+1];
+
+ for (i=0;i<n;i++) {
+ if (i == n-1) {
+ strcpy(tmp,ancienne_chaine+i*ANCIEN_MED_TAILLE_PNOM);
+ if (strlen(tmp) < ANCIEN_MED_TAILLE_PNOM)
+ for(j=strlen(tmp);j<ANCIEN_MED_TAILLE_PNOM;j++)
+ tmp[j] = ' ';
+ }
+ else
+ strncpy(tmp,ancienne_chaine+i*ANCIEN_MED_TAILLE_PNOM,ANCIEN_MED_TAILLE_PNOM);
+ tmp[ANCIEN_MED_TAILLE_PNOM] = '\0';
+ /* 12345678 */
+ strcat(tmp," ");
+ /* printf("[%s]\n",tmp); */
+ if (i == 0)
+ strcpy(nouvelle_chaine,tmp);
+ else
+ strcat(nouvelle_chaine,tmp);
+ }
+ *(nouvelle_chaine+MED_TAILLE_PNOM*n) = '\0';
+}
+
+void med_2_2::MAJ_version(med_idt fid) throw (MEDEXCEPTION)
+{
+ med_err ret;
+ med_idt gid;
+ med_int majeur, mineur, release;
+
+ /* On ecrit le bon numero de version */
+ majeur = 2;
+ mineur = 2;
+ release = 1;
+ gid = _MEDdatagroupOuvrir(fid,MED_NOM_INFOS);
+ if (gid < 0)
+ gid = _MEDdatagroupCreer(fid,MED_NOM_INFOS);
+
+// EXIT_IF(gid < 0,"Ouverture du groupe HDF MED_NOM_INFOS",NULL);
+
+ if (gid < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ ret = _MEDattrEntierEcrire(gid,MED_NOM_MAJEUR,&majeur);
+
+// EXIT_IF(ret < 0,"Ecriture du numéro majeur",NULL);
+
+ if (ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ ret = _MEDattrEntierEcrire(gid,MED_NOM_MINEUR,&mineur);
+
+// EXIT_IF(ret < 0,"Ecriture du numéro mineur",NULL);
+
+ if (ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ ret = _MEDattrEntierEcrire(gid,MED_NOM_RELEASE,&release);
+
+// EXIT_IF(ret < 0,"Ecrriture du numéro de release",NULL);
+
+ if (ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ ret = _MEDdatagroupFermer(gid);
+
+// EXIT_IF(ret < 0,"Fermeture du groupe HDF MED_NOM_INFOS",NULL);
+
+ if (ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+}
+
+void med_2_2::MAJ_noeuds_maillage(med_idt mid, med_int dimension)
+ throw (MEDEXCEPTION)
+{
+ med_idt nid, gid, tid;
+ med_float *coo;
+ char *nom, *unit;
+ char tmp[MED_TAILLE_PNOM+1];
+ char *nouvelle_chaine;
+ med_int n;
+ med_size dimd[1];
+ med_err ret;
+ int i;
+ hid_t hdf_type;
+ med_repere repere;
+
+ /* Accès aux noeuds du maillage */
+ nid = _MEDdatagroupOuvrir(mid,MED_NOM_NOE);
+
+// EXIT_IF(nid < 0,"Ouverture du groupe HDF MED_NOM_NOE",NULL);
+
+ if(nid < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ /* Lecture du nombre de noeuds */
+ gid = _MEDdatasetOuvrir(nid,MED_NOM_COO);
+ if (gid > 0)
+ ret = _MEDattrEntierLire(gid,MED_NOM_NBR,&n);
+
+// EXIT_IF(gid < 0,"Lecture du nombre de noeuds",NULL);
+
+ if(gid < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ /* Mise a jour des coordonnees */
+ /* On cree un groupe HDF tampon */
+ /* Lecture des coordonnées */
+ hdf_type = H5Dget_type(gid);
+
+// EXIT_IF(hdf_type < 0,"Lecture du type HDF de stockage des coordonnées",NULL);
+
+ if(hdf_type < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ coo = (med_float *) malloc(sizeof(med_float)*n*dimension);
+
+// EXIT_IF(coo == NULL,NULL,NULL);
+
+ if(coo == NULL)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ ret = OLD_MEDdatasetNumLire(nid,MED_NOM_COO,MED_FLOAT64,
+ MED_FULL_INTERLACE,dimension,MED_ALL,
+ 0,NULL,MED_NOPG,
+ (unsigned char*) coo,hdf_type);
+
+// EXIT_IF(ret < 0,"Lecture des coordonnées des noeuds",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ dimd[0] = n*dimension;
+ /* printf("EGALITE des types : %d \n",H5Tequal(hdf_type,H5T_NATIVE_DOUBLE)); */
+ /* printf("Avant conversion : [%f] [%f] [%f] \n",*(coo),*(coo+1),*(coo+2)); */
+ if (! H5Tequal(hdf_type,H5T_NATIVE_DOUBLE)) {
+ ret = H5Tconvert(hdf_type,H5T_NATIVE_DOUBLE,(hsize_t)*dimd,(void *)coo,NULL,0);
+ /* printf("Après conversion éventuelle : [%f] [%f] [%f] \n",*(coo),*(coo+1),*(coo+2)); */
+
+// EXIT_IF(ret < 0,"Conversion des coordonnées des noeuds",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+ }
+ ret = H5Tclose(hdf_type);
+
+// EXIT_IF(ret < 0,"Fermeture du data type HDF",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ /* On reporte les coordonnées dans le groupe HDF TMP */
+ ret = _MEDdatasetNumEcrire(nid,"TMP",MED_FLOAT64,MED_FULL_INTERLACE,
+ dimension,MED_ALL,MED_NOPF,MED_NO_PFLMOD,0,MED_NOPG,dimd,
+ (unsigned char*) coo);
+
+// EXIT_IF(ret < 0,"Ecriture des coordonnées des noeuds après conversion",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ free(coo);
+
+ /* Ecriture du nombre de noeuds et du type du repertoire dans le dataset TMP */
+ tid = _MEDdatasetOuvrir(nid,"TMP");
+
+// EXIT_IF(tid < 0,"Ouverture du dataset HDF TMP",NULL);
+
+ if(tid < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ ret = _MEDattrEntierEcrire(tid,MED_NOM_NBR,&n);
+
+// EXIT_IF(ret < 0,"Ecriture du nombre de noeuds dans le dataset HDF TMP",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ ret = _MEDattrEntierLire(gid,MED_NOM_REP,&repere);
+
+// EXIT_IF(ret < 0,"Lecture du type de repere des coordonnées", NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ ret = _MEDattrEntierEcrire(tid,MED_NOM_REP,&repere);
+
+// EXIT_IF(ret < 0,"Ecriture du type de répertoire dans le dataset HDF TMP",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ /* Mise a jour des noms et types des unités des coordonnees */
+ nom = (char *) malloc(dimension*ANCIEN_MED_TAILLE_PNOM+1);
+
+// EXIT_IF(nom == NULL,NULL,NULL);
+
+ if(nom == NULL)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ unit = (char *) malloc(dimension*ANCIEN_MED_TAILLE_PNOM+1);
+
+// EXIT_IF(unit == NULL,NULL,NULL);
+
+ if(unit == NULL)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ nouvelle_chaine = (char *) malloc(dimension*MED_TAILLE_PNOM+1);
+
+// EXIT_IF(nouvelle_chaine == NULL,NULL,NULL);
+
+ if(nouvelle_chaine == NULL)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ ret = _MEDattrStringLire(gid,MED_NOM_NOM,dimension*ANCIEN_MED_TAILLE_PNOM,nom);
+
+// EXIT_IF(ret < 0,"Lecture des noms des coordonnées des noeuds",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ ret = _MEDattrStringLire(gid,MED_NOM_UNI,dimension*ANCIEN_MED_TAILLE_PNOM,unit);
+
+// EXIT_IF(ret < 0,"Lecture des unités des coordonnées des noeuds",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ conversion_chaine(nom,nouvelle_chaine,dimension);
+ ret = _MEDattrStringEcrire(tid,MED_NOM_NOM,dimension*MED_TAILLE_PNOM,nouvelle_chaine);
+
+// EXIT_IF(ret < 0,"Ecriture des nouveaux noms des coordonnées des noeuds",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ conversion_chaine(unit,nouvelle_chaine,dimension);
+ ret = _MEDattrStringEcrire(tid,MED_NOM_UNI,dimension*MED_TAILLE_PNOM,nouvelle_chaine);
+
+// EXIT_IF(ret < 0,"Ecriture des nouvelles unités des coordonnées des noeuds",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ free(nom);
+ free(unit);
+ free(nouvelle_chaine);
+
+ /* Fermeture de l'accès aux coordonnées */
+ ret = _MEDdatasetFermer(gid);
+
+// EXIT_IF(ret < 0,"Fermeture du dataset HDF MED_NOM_COO",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ ret = H5Gunlink(nid,MED_NOM_COO);
+
+// EXIT_IF(ret < 0,"Suppression des anciennes coordonnées",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ ret = _MEDdatasetFermer(tid);
+
+// EXIT_IF(ret < 0,"Fermeture du dataset HDF TMP",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ ret = H5Gmove(nid,"TMP",MED_NOM_COO);
+
+// EXIT_IF(ret < 0,"Mise en place des nouvelles coordonnées",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ /* Mise a jour des noms des noeuds */
+ nom = (char *) malloc(n*ANCIEN_MED_TAILLE_PNOM+1);
+
+// EXIT_IF(nom == NULL,NULL,NULL);
+
+ if(nom == NULL)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ nouvelle_chaine = (char *) malloc(n*MED_TAILLE_PNOM+1);
+
+// EXIT_IF(nouvelle_chaine == NULL,NULL,NULL);
+
+ if(nouvelle_chaine == NULL)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ ret = _MEDdatasetStringLire(nid,MED_NOM_NOM,nom);
+ if (ret == 0) {
+ conversion_chaine(nom,nouvelle_chaine,n);
+ H5Gunlink(nid,MED_NOM_NOM);
+ dimd[0] = n*MED_TAILLE_PNOM+1;
+ ret = _MEDdatasetStringEcrire(nid,MED_NOM_NOM,dimd,nouvelle_chaine);
+
+// EXIT_IF(ret < 0,"Ecriture des nouveaux noms des noeuds",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ gid = _MEDdatasetOuvrir(nid,MED_NOM_NOM);
+ ret = _MEDattrEntierEcrire(gid,MED_NOM_NBR,&n);
+ ret = _MEDdatasetFermer(gid);
+ }
+ free(nom);
+ free(nouvelle_chaine);
+
+ /* on ferme tout */
+ ret = _MEDdatagroupFermer(nid);
+
+// EXIT_IF(ret < 0,"Fermeture de l'accès aux noeuds",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+}
+
+void med_2_2::MAJ_elements_maillage(med_idt mid, med_int dimension)
+ throw (MEDEXCEPTION)
+{
+ med_idt eid,gid,did,tid;
+ med_err ret;
+ int i,j;
+ med_geometrie_element typmai[MED_NBR_GEOMETRIE_MAILLE] = {MED_POINT1,MED_SEG2,
+ MED_SEG3,MED_TRIA3,
+ MED_TRIA6,MED_QUAD4,
+ MED_QUAD8,MED_TETRA4,
+ MED_TETRA10,MED_HEXA8,
+ MED_HEXA20,MED_PENTA6,
+ MED_PENTA15,MED_PYRA5,
+ MED_PYRA13};
+ int taille, edim;
+ char *nom, *nouvelle_chaine;
+ char nomgroup[MED_TAILLE_NOM_ENTITE+1];
+ med_int n;
+ med_size dimd[1];
+ med_int *old_conn,*conn;
+
+ /* On ne regarde que les mailles et la connectivité nodale */
+ eid = _MEDdatagroupOuvrir(mid,MED_NOM_MAI);
+
+// EXIT_IF(eid < 0,"Ouverture du groupe HDF MED_NOM_MAI",NULL);
+
+ if(eid < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ /* On normalise selon tous les types geometriques */
+ for (i=0;i<MED_NBR_GEOMETRIE_MAILLE;i++) {
+
+ /* On recupere le nom du groupe HDF */
+ _MEDnomGeometrie(nomgroup,typmai[i]);
+
+ /* On accède au type s'il existe dans le fichier */
+ gid = _MEDdatagroupOuvrir(eid,nomgroup);
+ if (gid < 0)
+ continue;
+
+ /* Nombre d'element ? */
+ did = _MEDdatasetOuvrir(gid,MED_NOM_NOD);
+
+// EXIT_IF(did < 0,"Ouverture du dataset HDF MED_NOM_NOD",NULL);
+
+ if(did < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ ret = _MEDattrEntierLire(did,MED_NOM_NBR,&n);
+
+// EXIT_IF(ret < 0,"Lecture du nombre d'elements",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ ret = _MEDdatasetFermer(did);
+
+// EXIT_IF(ret < 0,"Fermeture du dataset HDF MED_NOM_NOD",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ /* on normalise la connectivité si edim < dimension */
+ edim = typmai[i] / 100;
+ if (edim < dimension) {
+ taille = typmai[i]%100 + 1;
+ old_conn = (med_int *) malloc(sizeof(med_int)*taille*n);
+
+// EXIT_IF(old_conn == NULL,NULL,NULL);
+
+ if(old_conn == NULL)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+#if defined(IRIX64)||defined(OSF1)
+ ret = OLD_MEDdatasetNumLire(gid,MED_NOM_NOD,MED_INT64,
+ MED_NO_INTERLACE,(med_size)taille,MED_ALL,
+ 0,NULL,MED_NOPG,
+ (unsigned char*) old_conn,H5T_NATIVE_INT);
+#else
+ ret = OLD_MEDdatasetNumLire(gid,MED_NOM_NOD,MED_INT32,
+ MED_NO_INTERLACE,(med_size) taille,MED_ALL,
+ 0,NULL,MED_NOPG,
+ (unsigned char*) old_conn,H5T_NATIVE_INT);
+#endif
+ /* On recopie dans le bon tableau */
+ taille --;
+ conn = (med_int *) malloc(sizeof(med_int)*taille*n);
+
+// EXIT_IF(conn == NULL,NULL,NULL);
+
+ if(conn == NULL)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ for (j=0;j<n*taille;j++)
+ *(conn+j) = *(old_conn+j);
+ dimd[0] = n*taille;
+#if defined(IRIX64)||defined(OSF1)
+ ret = _MEDdatasetNumEcrire(gid,"TMP",MED_INT64,MED_NO_INTERLACE,
+ taille,MED_ALL,MED_NOPF,MED_NO_PFLMOD,0,MED_NOPG,dimd,
+ (unsigned char*) conn);
+#else
+ ret = _MEDdatasetNumEcrire(gid,"TMP",MED_INT32,MED_NO_INTERLACE,
+ taille,MED_ALL,MED_NOPF,MED_NO_PFLMOD,0,MED_NOPG,dimd,
+ (unsigned char*) conn);
+#endif
+
+// EXIT_IF(ret < 0,"Ecriture de la nouvelle connectivité des mailles",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ /* Ecriture du nombre de mailles dans le dataset HDF TMP */
+ tid = _MEDdatasetOuvrir(gid,"TMP");
+
+// EXIT_IF(tid < 0,"Ouverture du dataset HDF TMP",NULL);
+
+ if(tid < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ ret = _MEDattrEntierEcrire(tid,MED_NOM_NBR,&n);
+
+// EXIT_IF(ret < 0,"Ecriture du nombre de noeuds dans le dataset HDF TMP",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ ret = _MEDdatasetFermer(tid);
+
+// EXIT_IF(ret < 0,"Fermeture du dataset HDF TMP",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ /* Fermeture de l'accès aux connectivites */
+ ret = H5Gunlink(gid,MED_NOM_NOD);
+
+// EXIT_IF(ret < 0,"Suppression des anciennes connectivités",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ ret = H5Gmove(gid,"TMP",MED_NOM_NOD);
+
+// EXIT_IF(ret < 0,"Mise en place des nouvelles connectivités",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ /* on libere la memoire */
+ free(old_conn);
+ free(conn);
+ }
+
+ /* Mise a niveau des noms */
+ nom = (char *) malloc(n*ANCIEN_MED_TAILLE_PNOM+1);
+
+// EXIT_IF(nom == NULL,NULL,NULL);
+
+ if(nom == NULL)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ nouvelle_chaine = (char *) malloc(n*MED_TAILLE_PNOM+1);
+
+// EXIT_IF(nouvelle_chaine == NULL,NULL,NULL);
+
+ if(nouvelle_chaine == NULL)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ ret = _MEDdatasetStringLire(gid,MED_NOM_NOM,nom);
+ if (ret == 0) {
+ conversion_chaine(nom,nouvelle_chaine,n);
+ H5Gunlink(gid,MED_NOM_NOM);
+ dimd[0] = n*MED_TAILLE_PNOM+1;
+ ret = _MEDdatasetStringEcrire(gid,MED_NOM_NOM,dimd,nouvelle_chaine);
+
+// EXIT_IF(ret < 0,"Ecriture des nouveaux noms des éléments",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ did = _MEDdatasetOuvrir(gid,MED_NOM_NOM);
+ ret = _MEDattrEntierEcrire(did,MED_NOM_NBR,&n);
+ ret = _MEDdatasetFermer(did);
+ }
+ free(nom);
+ free(nouvelle_chaine);
+
+ /* on ferme avant de passer au type geometrique suivant */
+ ret = _MEDdatagroupFermer(gid);
+
+// EXIT_IF(ret < 0,"Fermeture de l'accès aux mailles",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+ }
+
+ /* On ferme tout */
+ ret = _MEDdatagroupFermer(eid);
+
+// EXIT_IF(ret < 0,"Fermeture de l'accès aux mailles",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+}
+
+void med_2_2::MAJ_familles_maillage(med_idt mid) throw (MEDEXCEPTION)
+{
+ med_idt fid, gid;
+ char *nouvelle_chaine;
+ int n;
+ med_size dimd[1];
+ med_err ret;
+ int i;
+ char chemin[MED_TAILLE_FAS+2*MED_TAILLE_NOM+1];
+ char nom[MED_TAILLE_NOM+1];
+ char *noeuds, *elements;
+ int nnoeuds = 0;
+ int nelements = 0;
+ med_int numero;
+ char *groupe_noeuds = "NOEUD";
+ char *groupe_elements = "ELEME";
+ char *nom_famille_zero = "FAMILLE_ZERO";
+ char famille0[MED_TAILLE_NOM+1];
+ int *index_noeuds, *index_elements;
+ char stockage[MED_TAILLE_DESC];
+ med_float *valr;
+
+ /* Combien de famille ? */
+ fid = _MEDdatagroupOuvrir(mid,"FAS");
+
+// EXIT_IF(fid < 0,"Ouverture du groupe HDF 'FAS'",NULL);
+
+ if(fid < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ n = 0;
+ _MEDnObjets(fid,".",&n);
+
+// EXIT_IF(n < 0,"Lecture du nombre de famille",NULL);
+
+ if(n < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ noeuds = (char *) malloc(n*MED_TAILLE_NOM+1);
+
+// EXIT_IF(noeuds == NULL,NULL,NULL);
+
+ if(noeuds == NULL)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ index_noeuds = (int *) malloc(sizeof(int)*(n+1));
+
+// EXIT_IF(index_noeuds == NULL,NULL,NULL);
+
+ if(index_noeuds < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ elements = (char *) malloc(n*MED_TAILLE_NOM+1);
+
+// EXIT_IF(elements == NULL,NULL,NULL);
+
+ if(elements == NULL)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ index_elements = (int *) malloc(sizeof(int)*(n+1));
+
+// EXIT_IF(index_elements == NULL,NULL,NULL);
+
+ if(index_elements == NULL)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ /* On recupere les familles une par une et on les
+ normalise */
+ for (i=0;i<n;i++) {
+ ret = _MEDobjetIdentifier(fid,".",i,nom);
+
+// EXIT_IF(ret < 0,"Identification d'une famille",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ /* On accede a la famille */
+ gid = _MEDdatagroupOuvrir(fid,nom);
+
+// EXIT_IF(gid < 0,"Ouverture de l'accès à la famille",nom);
+
+ if(gid < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ /* On lit le numero de la famille */
+ ret = _MEDattrEntierLire(gid,MED_NOM_NUM,&numero);
+
+// EXIT_IF(ret < 0,"Lecture du numéro de la famille",nom);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ /* On ferme l'acces a la famille */
+ ret = _MEDdatagroupFermer(gid);
+
+// EXIT_IF(ret < 0,"Fermeture de l'accès a la famille",nom);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ if (numero == 0)
+ strcpy(famille0,nom);
+
+ if (numero < 0) {
+ if (nelements == 0) {
+ *(index_elements) = 0;
+ strcpy(elements,nom);
+ }
+ else
+ strcat(elements,nom);
+ nelements ++;
+ *(index_elements+nelements) = strlen(nom) + *(index_elements+nelements-1);
+ }
+
+ if (numero > 0) {
+ if (nnoeuds == 0) {
+ strcpy(noeuds,nom);
+ *(index_noeuds) = 0;
+ }
+ else
+ strcat(noeuds,nom);
+ nnoeuds++;
+ *(index_noeuds+nnoeuds) = strlen(nom) + *(index_noeuds+nnoeuds-1);
+ }
+ }
+
+ /* Normalisation de la famille 0 */
+ ret = H5Gmove(fid,famille0,nom_famille_zero);
+
+// EXIT_IF(ret < 0,"Normalisation de la famille ZERO",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ /* On cree les groupes HDF pour les familles de noeuds et d'elements */
+ gid = _MEDdatagroupCreer(fid,groupe_noeuds);
+
+// EXIT_IF(gid < 0,"Creation du grupe HDF pour les familles de noeuds",NULL);
+
+ if(gid < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ ret = _MEDdatagroupFermer(gid);
+
+// EXIT_IF(ret < 0,"Fermeture du groupe HDF pour les familles de noeuds",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ gid = _MEDdatagroupCreer(fid,groupe_elements);
+
+// EXIT_IF(gid < 0,"Creation du groupe HDF pour les familles d'éléments",NULL);
+
+ if(gid < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ ret = _MEDdatagroupFermer(gid);
+
+// EXIT_IF(ret < 0,"Fermeture du groupe HDF pour les familles d'éléments",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ /* On deplace les groupes HDF des familles en fonction de la nature de
+ chaque famille */
+ for (i=0;i<nnoeuds;i++) {
+ strncpy(nom,noeuds+*(index_noeuds+i),*(index_noeuds+i+1)-*(index_noeuds+i));
+ nom[*(index_noeuds+i+1)-*(index_noeuds+i)] = '\0';
+ strcpy(stockage,groupe_noeuds);
+ strcat(stockage,"/");
+ strcat(stockage,nom);
+ ret = H5Gmove(fid,nom,stockage);
+
+// EXIT_IF(ret < 0,"Normalisation de la famille",nom);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+ }
+
+ for (i=0;i<nelements;i++) {
+ strncpy(nom,elements+*(index_elements+i),*(index_elements+i+1)-*(index_elements+i));
+ nom[*(index_elements+i+1)-*(index_elements+i)] = '\0';
+ strcpy(stockage,groupe_elements);
+ strcat(stockage,"/");
+ strcat(stockage,nom);
+ ret = H5Gmove(fid,nom,stockage);
+
+// EXIT_IF(ret < 0,"Normalisation de la famille",nom);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+ }
+
+ /* On libere la memoire */
+ free(noeuds);
+ free(index_noeuds);
+ free(elements);
+ free(index_elements);
+
+ /* On ferme tout */
+ ret = _MEDdatagroupFermer(fid);
+
+// EXIT_IF(ret < 0,"Fermeture du groupe HDF 'FAS'",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+}
+
+void med_2_2::MAJ_maillages(med_idt fid) throw (MEDEXCEPTION)
+{
+ med_idt gid;
+ med_err ret;
+ int n,i;
+ char nom[MED_TAILLE_NOM+1];
+ char chemin[MED_TAILLE_MAA+MED_TAILLE_NOM+1];
+ char description[MED_TAILLE_DESC+1] = "Maillage converti au format MED V2.2";
+ med_int type = (med_int) MED_NON_STRUCTURE;
+ med_int dimension;
+
+ /* Lecture du nombre de maillages */
+ n = 0;
+ _MEDnObjets(fid,MED_MAA,&n);
+
+// EXIT_IF(n < 0,"Erreur a la lecture du nombre de maillage",NULL);
+
+ if(n < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ /*
+ * Mise a jour des maillages :
+ * - type : MED_NON_STRUCTURE
+ * - description : "Maillage converti au format V2.2"
+ */
+ for (i=0;i<n;i++) {
+ /* on recupere le nom du maillage */
+ ret = _MEDobjetIdentifier(fid,MED_MAA,i,nom);
+
+// EXIT_IF(ret < 0,"Identification d'un maillage",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+// fprintf(stdout," >>> Normalisation du maillage [%s] \n",nom);
+
+ MESSAGE("med File convertor 2.1 to 2.2 :: >>> Normalisation du maillage [" << nom << "]");
+
+ /* on accede au maillage */
+ strcpy(chemin,MED_MAA);
+ strcat(chemin,nom);
+ gid = _MEDdatagroupOuvrir(fid,chemin);
+
+// EXIT_IF(gid < 0,"Accès au maillage",nom);
+
+ if(gid < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ /* lecture de la dimension du maillage */
+ ret = _MEDattrEntierLire(gid,MED_NOM_DIM,&dimension);
+
+// EXIT_IF(ret < 0,"Lecture de la dimension du maillage",nom);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ /* Ecriture du type et de la description */
+ ret = _MEDattrStringEcrire(gid,MED_NOM_DES,MED_TAILLE_DESC,description);
+
+// EXIT_IF(ret < 0,"Ecriture de la description du maillage ",nom);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ ret = _MEDattrEntierEcrire(gid,MED_NOM_TYP,&type);
+
+// EXIT_IF(ret < 0,"Ecriture de la dimension du maillage ",nom);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ /* Mise a jour des noeuds du maillage */
+ MAJ_noeuds_maillage(gid,dimension);
+
+// fprintf(stdout," ... Normalisation des noeuds effectuée ... \n");
+
+ MESSAGE("med File convertor 2.1 to 2.2 :: ... Normalisation des noeuds effectuée ...");
+
+ /* Mise a jour des éléments du maillage */
+ MAJ_elements_maillage(gid,dimension);
+
+// fprintf(stdout," ... Normalisation des éléments effectuée ... \n");
+
+ MESSAGE("med File convertor 2.1 to 2.2 :: ... Normalisation des éléments effectuée ...");
+
+ /* Mise a jour des familles du maillage */
+ MAJ_familles_maillage(gid);
+
+// fprintf(stdout," ... Normalisation des familles effectuée ... \n");
+
+ MESSAGE("med File convertor 2.1 to 2.2 :: ... Normalisation des familles effectuée ...");
+
+ /* On ferme tout */
+ ret = _MEDdatagroupFermer(gid);
+
+// EXIT_IF(ret < 0,"Fermeture de l'accès au maillage",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+// fprintf(stdout," >>> Normalisation du maillage [%s] ... OK ... \n",nom);
+
+ MESSAGE("med File convertor 2.1 to 2.2 :: Normalisation du maillage [" << nom << "] ... OK ... ");
+ }
+}
+
+void med_2_2::MAJ_localisation_Gauss(med_idt fid,char *nom_modele,
+ med_int ngauss)
+ throw (MEDEXCEPTION)
+{
+ med_err ret;
+ med_geometrie_element type;
+ med_float *refcoo, *gaucoo, *poids;
+ char nom_type[4];
+ med_int edim, nsom,n,nlu;
+ int i;
+ char nom[MED_TAILLE_NOM+1];
+
+ /* On regarde si la localisation bidon existe deja
+ Si oui on s'en va */
+ n = MEDnGauss(fid);
+ if (n > 0)
+ for (i=1;i<=n;i++) {
+ ret = MEDgaussInfo(fid,i,nom,&type,&nlu);
+ if (! strcmp(nom,nom_modele)) return;
+ }
+
+ /* On deduit le type en fonction de nom_modele */
+ strncpy(nom_type,nom_modele,3);
+ nom_type[3] = '\0';
+ if (! strcmp(nom_type,MED_NOM_SE2))
+ type = MED_SEG2;
+ if (! strcmp(nom_type,MED_NOM_SE3))
+ type = MED_SEG3;
+ if (! strcmp(nom_type,MED_NOM_TR3))
+ type = MED_TRIA3;
+ if (! strcmp(nom_type,MED_NOM_TR6))
+ type = MED_TRIA6;
+ if (! strcmp(nom_type,MED_NOM_QU4))
+ type = MED_QUAD4;
+ if (! strcmp(nom_type,MED_NOM_QU8))
+ type = MED_QUAD8;
+ if (! strcmp(nom_type,MED_NOM_TE4))
+ type = MED_TETRA4;
+ if (! strcmp(nom_type,MED_NOM_T10))
+ type = MED_TETRA10;
+ if (! strcmp(nom_type,MED_NOM_HE8))
+ type = MED_HEXA8;
+ if (! strcmp(nom_type,MED_NOM_H20))
+ type = MED_HEXA20;
+ if (! strcmp(nom_type,MED_NOM_PE6))
+ type = MED_PENTA6;
+ if (! strcmp(nom_type,MED_NOM_P15))
+ type = MED_PENTA15;
+ if (! strcmp(nom_type,MED_NOM_PY5))
+ type = MED_PYRA5;
+ if (! strcmp(nom_type,MED_NOM_P13))
+ type = MED_PYRA13;
+
+ /* Dimension de la maille */
+ edim = type / 100;
+ nsom = type % 100;
+
+ /* On definit des coordonnées et des poids bidon */
+ refcoo = (med_float*) malloc(sizeof(med_float)*edim*nsom);
+
+// EXIT_IF(refcoo == NULL,NULL,NULL);
+
+ if(refcoo == NULL)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ for (i=0;i<edim*nsom;i++) *(refcoo+i) = 0.;
+ gaucoo = (med_float*) malloc(sizeof(med_float)*edim*ngauss);
+
+// EXIT_IF(gaucoo == NULL,NULL,NULL);
+
+ if(gaucoo == NULL)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ for (i=0;i<edim*ngauss;i++) *(gaucoo+i) = 0.;
+ poids = (med_float*) malloc(sizeof(med_float)*ngauss);
+
+// EXIT_IF(poids == NULL,NULL,NULL);
+
+ if(poids == NULL)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ for (i=0;i<ngauss;i++) *(poids+i) = 0.;
+
+ /* On ecrit la localisation bidon */
+ ret = MEDgaussEcr(fid,type,refcoo,MED_FULL_INTERLACE,ngauss,gaucoo,poids,nom_modele);
+
+// EXIT_IF(ret < 0,"Ecriture de la localisation des points de Gauss",nom_modele);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ /* On libere la memoire */
+ free(refcoo);
+ free(gaucoo);
+ free(poids);
+}
+
+void med_2_2::MAJ_champs(med_idt fid) throw (MEDEXCEPTION)
+{
+ med_idt gid,eid,pid,mid,did,aid;
+ med_err ret;
+ int n,i,j,k;
+ char nom[MED_TAILLE_NOM+1];
+ char chemin[MED_TAILLE_CHA+MED_TAILLE_NOM+1];
+ char maillage[MED_TAILLE_NOM+1];
+ med_int type;
+ char *comp, *unit;
+ char *nouvelle_chaine;
+ med_int ncomp;
+ int nent, npdt;
+ char noment[MED_TAILLE_NOM+1];
+ char nompdt[2*MED_MAX_PARA+1];
+ char oldunidt[ANCIEN_MED_TAILLE_PNOM+1];
+ char unitdt[MED_TAILLE_PNOM+1];
+ char tmp[MED_TAILLE_DESC+1];
+ med_int att;
+ char profil[MED_TAILLE_NOM+1];
+ char gauss[MED_TAILLE_NOM+1];
+ med_float *valr;
+ med_int nval;
+ hid_t hdf_type;
+ med_size dimd[1];
+ med_float pdt;
+
+ /* Lecture du nombre de champs */
+ n = 0;
+ _MEDnObjets(fid,MED_CHA,&n);
+
+// EXIT_IF(n < 0,"Erreur a la lecture du nombre de champ",NULL);
+
+ if(n < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ for (i=0;i<n;i++) {
+ /* on recupere le nom du champ */
+ ret = _MEDobjetIdentifier(fid,MED_CHA,i,nom);
+
+// EXIT_IF(ret < 0,"Identification d'un champ",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+// fprintf(stdout," >>> Normalisation du champ [%s] \n",nom);
+
+ MESSAGE("med File convertor 2.1 to 2.2 :: Normalisation du champ [" << nom << "]");
+
+ /* on accede au champ */
+ strcpy(chemin,MED_CHA);
+ strcat(chemin,nom);
+ gid = _MEDdatagroupOuvrir(fid,chemin);
+
+// EXIT_IF(gid < 0,"Accès au champ",nom);
+
+ if(gid < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ /* Lecture du nombre de composantes */
+ ret = _MEDattrEntierLire(gid,MED_NOM_NCO,&ncomp);
+
+// EXIT_IF(ret < 0,"Lecture du nombre de composante",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ /* Lecture du type du champ */
+ ret = _MEDattrEntierLire(gid,MED_NOM_TYP,&type);
+
+// EXIT_IF(ret < 0,"Lecture du type du champ",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ /* Normalisation des nom et unites des composantes */
+ comp = (char *) malloc(ncomp*ANCIEN_MED_TAILLE_PNOM+1);
+
+// EXIT_IF(comp == NULL,NULL,NULL);
+
+ if(comp == NULL)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ unit = (char *) malloc(ncomp*ANCIEN_MED_TAILLE_PNOM+1);
+
+// EXIT_IF(unit == NULL,NULL,NULL);
+
+ if(unit == NULL)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ nouvelle_chaine = (char *) malloc(ncomp*MED_TAILLE_PNOM+1);
+
+// EXIT_IF(nouvelle_chaine == NULL,NULL,NULL);
+
+ if(nouvelle_chaine == NULL)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ ret = _MEDattrStringLire(gid,MED_NOM_NOM,ncomp*ANCIEN_MED_TAILLE_PNOM,comp);
+
+// EXIT_IF(ret < 0,"Lecture des noms des composantes du champ",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ conversion_chaine(comp,nouvelle_chaine,ncomp);
+ H5Adelete(gid,MED_NOM_NOM);
+ ret = _MEDattrStringEcrire(gid,MED_NOM_NOM,MED_TAILLE_PNOM*ncomp,nouvelle_chaine);
+
+// EXIT_IF(ret < 0,"Ecriture des nouveaux noms des composantes du champ",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ free(comp);
+
+ ret = _MEDattrStringLire(gid,MED_NOM_UNI,ncomp*ANCIEN_MED_TAILLE_PNOM,unit);
+
+// EXIT_IF(ret < 0,"Lecture des unités des composantes du champ",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ conversion_chaine(unit,nouvelle_chaine,ncomp);
+ H5Adelete(gid,MED_NOM_UNI);
+ ret = _MEDattrStringEcrire(gid,MED_NOM_UNI,MED_TAILLE_PNOM*ncomp,nouvelle_chaine);
+
+// EXIT_IF(ret < 0,"Ecriture des nouvelles unités des composantes du champ",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ free(unit);
+
+ free(nouvelle_chaine);
+
+// fprintf(stdout," ... Normalisation des noms et unités des composantes effectuée...\n");
+
+ MESSAGE("med File convertor 2.1 to 2.2 :: ... Normalisation des noms et unités des composantes effectuée...");
+
+ /* On ajoute le groupe HDF correspondant au maillage */
+ /* On recupere le nom du maillage par defaut */
+ nent = 0;
+ _MEDnObjets(gid,"./",&nent);
+
+// EXIT_IF(nent < 0,"Erreur a la lecture du nombre d'entité dans un champ",NULL);
+
+ if(nent < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ for (j=0;j<nent;j++) {
+ /* on recupere le nom du groupe HDF correspondant a l'entite */
+ ret = _MEDobjetIdentifier(gid,"./",j,noment);
+
+// EXIT_IF(ret < 0,"Identification des objets de niveau 1 dans le champ",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ /* On ouvre le groupe HDF */
+ eid = _MEDdatagroupOuvrir(gid,noment);
+
+// EXIT_IF(eid < 0,"Ouverture du groupe HDF de niveau 1",NULL);
+
+ if(eid < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ /* On recupere le nombre de pas de temps */
+ npdt = 0;
+ _MEDnObjets(eid,"./",&npdt);
+
+// EXIT_IF(nent < 0,"Erreur a la lecture du nombre de pas de temps",NULL);
+
+ if(nent < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ /* On traite chaque pas de temps */
+ for (k=0;k<npdt;k++) {
+ /* On recupere le nom du groupe HDF correspondant au pas de temps */
+ ret = _MEDobjetIdentifier(eid,"./",k,nompdt);
+
+// EXIT_IF(ret < 0,"Identification des objets de niveau 2 dans le champ",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ /* On ouvre le groupe HDF correspondant au pas de temps */
+ pid = _MEDdatagroupOuvrir(eid,nompdt);
+
+// EXIT_IF(pid < 0,"Ouverture du groupe HDF de niveau 2",NULL);
+
+ if(pid < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ /* On lit le pas de temps */
+ aid = H5Aopen_name(pid,MED_NOM_PDT);
+
+// EXIT_IF(aid < 0,"Ouverture de l'attribut HDF MED_NOM_PDT",NULL);
+
+ if(aid < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ hdf_type = H5Aget_type(aid);
+
+// EXIT_IF(hdf_type < 0,"Lecture du type de l'attribut HDF MED_NOM_PDT",NULL);
+
+ if(hdf_type < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ ret = H5Aclose(aid);
+
+// EXIT_IF(ret < 0,"Fermeture de l'attribut MED_NOM_PDT",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ ret = OLD_MEDattrNumLire(pid,MED_FLOAT64,MED_NOM_PDT,(unsigned char*)(&pdt),hdf_type);
+
+// EXIT_IF(ret < 0,"Lecture du pas de temps dans MED_NOM_PDT",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ dimd[0] = 1;
+ /* printf("EGALITE des types : %d \n",H5Tequal(hdf_type,H5T_NATIVE_DOUBLE)); */
+ /* printf("Avant conversion : [%f]\n",pdt); */
+ if (! H5Tequal(hdf_type,H5T_NATIVE_DOUBLE)) {
+ ret = H5Tconvert(hdf_type,H5T_NATIVE_DOUBLE,(hsize_t)*dimd,(void *)(&pdt),NULL,0);
+ /* printf("Après conversion éventuelle : [%f] \n",pdt); */
+
+// EXIT_IF(ret < 0,"Conversion du pas de temps",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+ }
+ H5Tclose(hdf_type);
+ /* printf("pdt = %f\n",pdt); */
+ H5Adelete(pid,MED_NOM_PDT);
+ ret = _MEDattrFloatEcrire(pid,MED_NOM_PDT,&pdt);
+
+// EXIT_IF(ret < 0,"Ecriture du nouveau pas de temps",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ /* On met a jour l'unité du pas de temps : 8 -> 16 caractères
+ Si on rencontre " " => on ecrit ""
+ */
+ ret = _MEDattrStringLire(pid,MED_NOM_UNI,ANCIEN_MED_TAILLE_PNOM,oldunidt);
+
+// EXIT_IF(ret < 0,"Lecture de l'unite du pas de temps",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ if (! strcmp(oldunidt,ANCIEN_MED_BLANC_PNOM))
+ strcpy(unitdt,"");
+ else
+ conversion_chaine(oldunidt,unitdt,1);
+ H5Adelete(pid,MED_NOM_UNI);
+ ret = _MEDattrStringEcrire(pid,MED_NOM_UNI,MED_TAILLE_PNOM,unitdt);
+
+// EXIT_IF(ret < 0,"Ecriture de la nouvelle unité du pas de temps",NULL);
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ /* On recupere le nom du maillage */
+ ret = _MEDattrStringLire(pid,MED_NOM_MAI,MED_TAILLE_NOM,maillage);
+
+// EXIT_IF(ret < 0,"Lecture du nom du maillage du pas de temps",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ /* On cree le groupe HDF de niveau 3 qui porte le nom du maillage */
+ mid = _MEDdatagroupCreer(pid,maillage);
+
+// EXIT_IF(mid < 0,"Creation du groupe HDF de niveau 3",NULL);
+
+ if(mid < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ /* Déplacement de l'attribut MED_NOM_NBR */
+ ret = _MEDattrEntierLire(pid,MED_NOM_NBR,&nval);
+
+// EXIT_IF(ret < 0,"Lecture de l'attribut MED_NOM_NBR",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ ret = H5Adelete(pid,MED_NOM_NBR);
+
+// EXIT_IF(ret < 0,"Destruction de l'attribut MED_NOM_NBR",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ ret = _MEDattrEntierEcrire(mid,MED_NOM_NBR,&nval);
+
+// EXIT_IF(ret < 0,"Ecriture de l'attribut MED_NOM_NBR au niveau 3",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ /* Deplacement de l'attribut MED_NOM_NGA */
+ ret = _MEDattrEntierLire(pid,MED_NOM_NGA,&att);
+
+// EXIT_IF(ret < 0,"Lecture de l'attribut MED_NOM_NGA",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ ret = H5Adelete(pid,MED_NOM_NGA);
+
+// EXIT_IF(ret < 0,"Destruction de l'attribut MED_NOM_NGA",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ ret = _MEDattrEntierEcrire(mid,MED_NOM_NGA,&att);
+
+// EXIT_IF(ret < 0,"Ecriture de l'attribut MED_NOM_NGA au niveau 3",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ /* Ecriture de l'attribut MED_NOM_GAU : localisation des points de Gauss */
+ if (att < 2)
+ strcpy(gauss,MED_NOM_BLANC);
+ else {
+ /* on prend en compte que les 3 dernières lettres de noment :
+ Exemple : "MAI.QU4" => gauss="QU4_LocalisationDefaut_MEDIMPORT */
+ strcpy(gauss,noment+4);
+ strcat(gauss,"_LocalisationDefaut_MEDIMPORT");
+ /* On ecrit en plus la localisation bidon des points de Gauss */
+ MAJ_localisation_Gauss(fid,gauss,att);
+ }
+ ret = _MEDattrStringEcrire(mid,MED_NOM_GAU,MED_TAILLE_NOM,gauss);
+
+// EXIT_IF(ret < 0,"Ecriture de la localisation des points de Gauss",NULL);
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ /* Deplacement de l'attribut MED_NOM_PFL */
+ ret = _MEDattrStringLire(pid,MED_NOM_PFL,MED_TAILLE_NOM,profil);
+
+// EXIT_IF(ret < 0,"Lecture de l'attribut MED_NOM_PFL",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ ret = H5Adelete(pid,MED_NOM_PFL);
+
+// EXIT_IF(ret < 0,"Desctruction de l'attribut MED_NOM_PFL",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ ret = _MEDattrStringEcrire(mid,MED_NOM_PFL,MED_TAILLE_NOM,profil);
+
+// EXIT_IF(ret < 0,"Ecriture de l'attribut MED_NOM_PFL au niveau 3",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ /* On ferme le groupe HDF de niveau 3 */
+ ret = _MEDdatagroupFermer(mid);
+
+// EXIT_IF(ret < 0,"fermeture du groupe HDF de niveau 3",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ /* On deplace du niveau 2 -> 3, le dataset MED_NOM_CO
+ avec si type==MED_FLOAT_64 une conversion au passage */
+ strcpy(tmp,maillage);
+ strcat(tmp,"/");
+ strcat(tmp,MED_NOM_CO);
+ if (type != MED_FLOAT64) {
+ ret = H5Gmove(pid,MED_NOM_CO,tmp);
+
+// EXIT_IF(ret < 0,"Transfert du dataset MED_NOM_CO",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+ } else {
+ did = _MEDdatasetOuvrir(pid,MED_NOM_CO);
+
+// EXIT_IF(did < 0,"Ouverture du dataset HDF des valeurs",NULL);
+
+ if(did < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ hdf_type = H5Dget_type(did);
+
+// EXIT_IF(hdf_type < 0,"Lecture du type HDF de stockage des valeurs",NULL);
+
+ if(hdf_type < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ ret = _MEDdatasetFermer(did);
+
+// EXIT_IF(ret < 0,"Fermeture du dataset HDF des valeurs",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ valr = (med_float *) malloc(sizeof(med_float)*ncomp*nval);
+
+// EXIT_IF(valr == NULL,NULL,NULL);
+
+ if(valr == NULL)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ ret = OLD_MEDdatasetNumLire(pid,MED_NOM_CO,MED_FLOAT64,
+ MED_FULL_INTERLACE,ncomp,MED_ALL,
+ 0,NULL,MED_NOPG,
+ (unsigned char*) valr,hdf_type);
+
+// EXIT_IF(ret < 0,"Lecture des valeurs du champ",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ H5Gunlink(pid,MED_NOM_CO);
+ dimd[0] = ncomp*nval;
+ ret = H5Tconvert(hdf_type,H5T_NATIVE_DOUBLE,(hsize_t)*dimd,(void *)valr,NULL,0);
+
+// EXIT_IF(ret < 0,"Conversion des valeurs",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ H5Tclose(hdf_type);
+ /* On reporte les valeurs dans le groupe HDF TMP */
+ ret = _MEDdatasetNumEcrire(pid,tmp,MED_FLOAT64,MED_FULL_INTERLACE,
+ ncomp,MED_ALL,MED_NOPF,MED_NO_PFLMOD,0,MED_NOPG,dimd,
+ (unsigned char*) valr);
+
+// EXIT_IF(ret < 0,"Ecriture des valeurs après conversion",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ free(valr);
+ }
+
+ /* On ferme le groupe HDF de niveau 2*/
+ ret = _MEDdatagroupFermer(pid);
+
+// EXIT_IF(ret < 0,"Fermeture du groupe HDF de niveau 2",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+ }
+
+ /* On ferme le groupe HDF */
+ ret = _MEDdatagroupFermer(eid);
+
+ // EXIT_IF(ret < 0,"Fermeture du groupe HDF de niveau 1",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+ }
+
+// fprintf(stdout," ... Normalisation de tous les pas de temps effectuée...\n");
+
+ MESSAGE("med File convertor 2.1 to 2.2 :: ... Normalisation de tous les pas de temps effectuée...\n");
+
+ /* On ferme tout */
+ ret = _MEDdatagroupFermer(gid);
+
+// EXIT_IF(ret < 0,"Fermeture de l'accès au champ",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+// fprintf(stdout," >>> Normalisation du champ [%s] : ... OK ... \n",nom);
+
+ MESSAGE("med File convertor 2.1 to 2.2 :: Normalisation du champ [" << nom << "] : ... OK ... ");
+ }
+}
+
+void med_2_2::MAJ_profils(med_idt fid,med_int nprofil) throw (MEDEXCEPTION)
+{
+ med_err ret;
+ med_int i;
+ char nom[MED_TAILLE_NOM+1];
+ char chemin[MED_TAILLE_DESC+1];
+ med_idt gid;
+ med_int att;
+
+ for (i=0;i<nprofil;i++)
+ {
+ /* on recupere le nom du profil */
+ ret = _MEDobjetIdentifier(fid,MED_PROFILS,i,nom);
+
+ // EXIT_IF(ret < 0,"Identification d'un profil",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+// fprintf(stdout," >>> Normalisation du profil [%s] \n",nom);
+
+ MESSAGE("med File convertor 2.1 to 2.2 :: Normalisation du profil [" << nom << "] ");
+
+ /* on accede au profil */
+ strcpy(chemin,MED_PROFILS);
+ strcat(chemin,nom);
+ gid = _MEDdatagroupOuvrir(fid,chemin);
+
+// EXIT_IF(gid < 0,"Accès au profil",nom);
+
+ if(gid < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+
+ /* On change l'attribut MED_NOM_N => MED_NOM_NBR */
+ ret = _MEDattrEntierLire(gid,"N",&att);
+
+// EXIT_IF(ret < 0,"Lecture de l'attribut MED_NOM_N",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ ret = H5Adelete(gid,"N");
+
+// EXIT_IF(ret < 0,"Destruction de l'attribut MED_NOM_N",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ ret = _MEDattrEntierEcrire(gid,MED_NOM_NBR,&att);
+
+// EXIT_IF(ret < 0,"Ecriture de l'attribut MED_NOM_NBR dans le profil ",nom);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ /* on ferme le profil */
+ ret = _MEDdatagroupFermer(gid);
+
+// EXIT_IF(ret < 0,"Fermeture de l'acces au profil",nom);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+// fprintf(stdout," >>> Normalisation du profil [%s] effectuée \n",nom);
+
+ MESSAGE("med File convertor 2.1 to 2.2 :: Normalisation du profil [" << nom << "]");
+ }
+}
+
+char * MEDMEM::med2_1_To_med2_2(char * fileNameIn) throw (MEDEXCEPTION)
+{
+ med_idt fid, gid;
+ med_err ret;
+ med_int majeur, mineur, release;
+/* char *nom; */
+ char *commande;
+ med_int nprofil;
+ char chemin_profils[MED_TAILLE_PROFILS+1];
+ char chemin_liens[MED_TAILLE_LIENS+1];
+
+ char * InternalFileNameOut;
+
+ char * envHome = (char *) malloc(sizeof(char)*(strlen("HOME")+1));
+
+ strcpy(envHome,"HOME");
+
+ char * envHomeChar = getenv(envHome);
+
+ /* Test du nombre d'argument */
+// EXIT_IF(argc != 2,"Nombre de parametre incorrect",NULL);
+
+ /* Test du format du fichier */
+/* EXIT_IF(MEDformatConforme(argv[1]) < 0, */
+/* "Le fichier n'est pas au format HDF 5 : ", argv[1]); */
+
+// EXIT_IF(MEDformatConforme(fileNameIn) < 0,
+// "Le fichier n'est pas au format HDF 5 : ", fileNameIn);
+
+ if(MEDformatConforme(fileNameIn) < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check the med File you wanted to mount in memory");
+
+ /* opening the old file to check the versions (Med File and HDF) */
+
+ fid = MEDouvrir(fileNameIn,MED_LECTURE);
+
+/* EXIT_IF(fid < 0,"Ouverture du fichier : ", */
+/* nom); */
+
+// EXIT_IF(fid < 0,"Ouverture du fichier : ",
+// InternalFileNameOut);
+
+ MESSAGE("med File convertor 2.1 to 2.2 :: opening of the old file id " << fid);
+
+ if(fid < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check you have enough memory and/or space disc to write the new med 2.2 file : openning of the file");
+
+ /* Verification du numero de version */
+ ret = MEDversionLire(fid,&majeur,&mineur,&release);
+
+// EXIT_IF(ret < 0,"Lecture du numero de version de MED-fichier",NULL);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check you have enough memory and/or space disc to write the new med 2.2 file");
+
+ if (majeur == 2 && mineur == 2) {
+/* fprintf(stdout,"Le fichier %s est déjà au format V2.2 !!! \n",nom); */
+
+// fprintf(stdout,"Le fichier %s est déjà au format V2.2 !!! \n",InternalFileNameOut);
+
+ MESSAGE("med File convertor 2.1 to 2.2 :: the file " << fileNameIn << " is already a med 2.2 file");
+
+ ret = MEDfermer(fid);
+/* EXIT_IF(ret < 0,"Fermeture du fichier",argv[1]); */
+
+// EXIT_IF(ret < 0,"Fermeture du fichier",fileNameIn);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check you have enough memory and/or space disc to write the new med 2.2 file");
+
+ return fileNameIn ;
+ }
+
+ ret = MEDfermer(fid);
+
+ /*
+ we are sure now that the file is an old version one
+ creation of the directory if it does not existe
+ */
+
+ commande = (char *) malloc(sizeof(char)*(strlen("mkdir ")+
+ strlen(envHomeChar)+
+ strlen("/TMP_Med2_2Files/")+1));
+
+// EXIT_IF(commande == NULL,NULL,NULL);
+
+ if(commande == NULL)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check you have enough memory and/or space disc to write the new med 2.2 file");
+
+ strcpy(commande,"ls ");
+ strcat(commande,envHomeChar);
+ strcat(commande,"/TMP_Med2_2Files/");
+
+ int systemReturn = system(commande);
+
+ if (systemReturn != 0)
+ {
+ strcpy(commande,"mkdir ");
+ strcat(commande,envHomeChar);
+ strcat(commande,"/TMP_Med2_2Files/");
+
+ systemReturn = system(commande);
+ }
+
+ free(commande);
+
+ free(envHome);
+
+ string::size_type pos1 = string(fileNameIn).rfind('/');
+ string::size_type pos = strlen(fileNameIn);
+ InternalFileNameOut = (char *) malloc(sizeof(char)*(strlen(envHomeChar)+
+ strlen("/TMP_Med2_2Files/")
+ +strlen(string(fileNameIn,pos1+1,pos-pos1-1).c_str())+1));
+
+ strcpy(InternalFileNameOut,envHomeChar);
+ strcat(InternalFileNameOut,"/TMP_Med2_2Files/");
+ strcat(InternalFileNameOut,string(fileNameIn,pos1+1,pos-pos1-1).c_str());
+
+ MESSAGE("med File convertor 2.1 to 2.2 :: " << InternalFileNameOut);
+
+ /* Creation et ouverture du fichier que l'on va convertire au format MED V2.2 */
+/* commande = (char *) malloc(sizeof(char)*(strlen("cp ")+2*strlen(argv[1])+strlen(" ")+strlen("2.2")+1)); */
+
+ commande = (char *) malloc(sizeof(char)*(strlen("cp -f ") +
+ strlen(fileNameIn) + strlen(" ") +
+ strlen(InternalFileNameOut) +
+ strlen(" ; chmod ug+rw ") +
+ strlen(InternalFileNameOut) + 1));
+
+// EXIT_IF(commande == NULL,NULL,NULL);
+
+ if(commande == NULL)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check you have enough memory and/or space disc to write the new med 2.2 file");
+
+/* nom = (char *) malloc(sizeof(char)*(strlen(argv[1])+strlen("2.2")+1)); */
+
+/* nom = (char *) malloc(sizeof(char)*(strlen(fileNameIn)+strlen("2.2")+1)); */
+
+/* EXIT_IF(nom == NULL,NULL,NULL); */
+/* strcpy(nom,argv[1]); */
+
+/* strcpy(nom,fileNameIn); */
+
+/* strcat(nom,"2.2"); */
+
+// strcpy(fileNameOut,fileNameIn);
+
+// strcat(fileNameOut,"2.2");
+
+ strcpy(commande,"cp -f ");
+/* strcat(commande,argv[1]); */
+
+ strcat(commande,fileNameIn);
+
+ strcat(commande," ");
+/* strcat(commande,nom); */
+
+ strcat(commande,InternalFileNameOut);
+
+ strcat(commande," ; chmod ug+rw ");
+
+ strcat(commande,InternalFileNameOut);
+
+ system(commande);
+/* fprintf(stdout,">>> Creation du fichier %s : %s \n",nom,commande); */
+
+// fprintf(stdout,">>> Creation du fichier %s : %s \n",InternalFileNameOut,commande);
+
+ MESSAGE("med File convertor 2.1 to 2.2 :: Creation du fichier " << InternalFileNameOut << " with the commande " << commande);
+
+ free(commande);
+
+/* fid = MEDouvrir(nom,MED_LECTURE_ECRITURE); */
+
+ fid = MEDouvrir(InternalFileNameOut,MED_LECTURE_ECRITURE);
+
+/* EXIT_IF(fid < 0,"Ouverture du fichier : ", */
+/* nom); */
+
+// EXIT_IF(fid < 0,"Ouverture du fichier : ",
+// InternalFileNameOut);
+
+ MESSAGE("med File convertor 2.1 to 2.2 :: opening of the new file id " << fid);
+
+ if(fid < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check you have enough memory and/or space disc to write the new med 2.2 file : openning of the file");
+
+ /* On avertit qu'on commence la conversion */
+
+// fprintf(stdout,">>> Lancement de la normalisation du fichier selon le format MED V2.2 ...\n");
+
+ MESSAGE("med File convertor 2.1 to 2.2 :: Running the convertor fromV 2.1 to V2.2");
+
+ /* On inhibe le gestionnaire d'erreur HDF5 */
+ _MEDmodeErreurVerrouiller();
+
+ /* Mise a jour du numero de version */
+
+// fprintf(stdout,"- Lancement de la mise à jour du numéro de version ... \n");
+
+ MESSAGE("med File convertor 2.1 to 2.2 :: Running the update of the version number");
+
+ MAJ_version(fid);
+
+// fprintf(stdout," Numéro de version : ... OK ... \n");
+
+ MESSAGE("med File convertor 2.1 to 2.2 :: Version number OK ...");
+
+ /* Mise a jour des maillages : type = MED_NON_STRUCTURE, description, ... */
+
+// fprintf(stdout,"- Lancement de la mise à jour des maillages ... \n");
+
+ MESSAGE("med File convertor 2.1 to 2.2 :: Running the update of all meshes");
+
+ MAJ_maillages(fid);
+
+// fprintf(stdout," Maillage(s) : ... OK ...\n");
+
+ MESSAGE("med File convertor 2.1 to 2.2 :: meshes are OK....");
+
+ /* Mise a jour des champs */
+
+// fprintf(stdout,"- Lancement de la mise à jour des champs de résultats ... \n");
+
+ MESSAGE("med File convertor 2.1 to 2.2 :: Running of the update of all fields ..");
+
+ MAJ_champs(fid);
+
+// fprintf(stdout," Champs(s) : ... OK ...\n");
+
+ MESSAGE("med File convertor 2.1 to 2.2 :: Fields are OK ..");
+
+ /* Mise a jour des profils eventuels */
+ nprofil = MEDnProfil(fid);
+ if (nprofil > 0) {
+// fprintf(stdout,"- Lancement de la mise à jour des profils ... \n");
+
+ MESSAGE("med File convertor 2.1 to 2.2 :: Running the update of all profils");
+
+ MAJ_profils(fid,nprofil);
+
+// fprintf(stdout," Profils(s) : ... OK ...\n");
+
+ MESSAGE("med File convertor 2.1 to 2.2 :: Profils are OK ... ");
+ } else {
+ strncpy(chemin_profils,MED_PROFILS,MED_TAILLE_PROFILS-1);
+ chemin_profils[MED_TAILLE_PROFILS-1] = '\0';
+ gid = _MEDdatagroupCreer(fid,chemin_profils);
+
+// EXIT_IF(gid < 0,"Creation du groupe HDF sur les profils",chemin_profils);
+
+ if(gid < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check you have enough memory and/or space disc to write the new med 2.2 file");
+
+ ret = _MEDdatagroupFermer(gid);
+
+// EXIT_IF(ret < 0,"Fermeture du groupe HDF sur les profils",chemin_profils);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check you have enough memory and/or space disc to write the new med 2.2 file");
+
+ }
+
+ /* On cree le groupe HDF pour les liens */
+ strncpy(chemin_liens,MED_LIENS,MED_TAILLE_LIENS-1);
+ chemin_liens[MED_TAILLE_LIENS-1] = '\0';
+ gid = _MEDdatagroupCreer(fid,chemin_liens);
+
+// EXIT_IF(gid < 0,"Creation du groupe HDF sur les liens",chemin_liens);
+
+ if(gid < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check you have enough memory and/or space disc to write the new med 2.2 file");
+
+ ret = _MEDdatagroupFermer(gid);
+
+// EXIT_IF(ret < 0,"Fermeture du groupe HDF sur les liens",chemin_liens);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check you have enough memory and/or space disc to write the new med 2.2 file");
+
+ /* Fermeture du fichier */
+ ret = MEDfermer(fid);
+/* EXIT_IF(ret < 0,"Fermeture du fichier",nom); */
+
+// EXIT_IF(ret < 0,"Fermeture du fichier",InternalFileNameOut);
+
+ if(ret < 0)
+ throw MEDEXCEPTION("Problem in the med File convertor 2.1 to 2.2, you should check you have enough memory and/or space disc to write the new med 2.2 file");
+
+ /* On avertit que c'est fini */
+/* fprintf(stdout,">>> Conversion du fichier %s au format MED V2.2. terminée\n", */
+/* nom); */
+
+// fprintf(stdout,">>> Conversion du fichier %s au format MED V2.2. terminée\n",
+// InternalFileNameOut);
+
+ /* On libere la memoire */
+/* free(nom); */
+
+ char * fileNameOut = new char[strlen(InternalFileNameOut)+1];
+
+ fileNameOut = strcpy(fileNameOut,InternalFileNameOut);
+
+ free(InternalFileNameOut);
+
+ MESSAGE("med File convertor 2.1 to 2.2 :: Convertion of the med file " << fileNameOut << " has run OK");
+
+ return fileNameOut;
+}
--- /dev/null
+/*************************************************************************
+* COPYRIGHT (C) 1999 - 2003 EDF R&D
+* 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, OR (AT YOUR OPTION) ANY LATER VERSION.
+*
+* 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
+*
+*************************************************************************/
+#ifndef IMPORT_HXX
+#define IMPORT_HXX
+
+#include "utilities.h"
+#include "MEDMEM_STRING.hxx"
+#include "MEDMEM_Exception.hxx"
+// #include "MEDMEM_define.hxx"
+
+
+/*
+ Med File V 2.2 attributes in the med_2_2 namespace
+*/
+
+#undef MED_H
+
+namespace med_2_2 {
+ extern "C" {
+#include <med.h>
+#include <med_proto.h>
+#include <med_hdfi.h>
+
+ /*
+ Med File V 2.2 attributes more addings to encapsulate the Med File V2_2
+ medimport utilitary
+ */
+
+#define MED_NOM_INFOS "INFOS_GENERALES"
+#define MED_NOM_MAJEUR "MAJ"
+#define MED_NOM_MINEUR "MIN"
+#define MED_NOM_RELEASE "REL"
+#define MED_NOM_NOE "NOE"
+#define MED_NOM_NBR "NBR"
+#define MED_NOM_REP "REP"
+#define MED_NOM_NOM "NOM"
+#define MED_NOM_UNI "UNI"
+#define MED_NOM_COO "COO"
+#define MED_TAILLE_NOM_ENTITE 3
+#define MED_NOM_MAI "MAI"
+#define MED_NOM_NOD "NOD"
+#define MED_TAILLE_FAS 5
+#define MED_NOM_NUM "NUM"
+#define MED_TAILLE_MAA 9
+#define MED_MAA "/ENS_MAA/"
+#define MED_NOM_DIM "DIM"
+#define MED_NOM_DES "DES"
+#define MED_NOM_TYP "TYP"
+#define MED_NOM_PO1 "PO1"
+#define MED_NOM_SE2 "SE2"
+#define MED_NOM_SE3 "SE3"
+#define MED_NOM_TR3 "TR3"
+#define MED_NOM_TR6 "TR6"
+#define MED_NOM_QU4 "QU4"
+#define MED_NOM_QU8 "QU8"
+#define MED_NOM_TE4 "TE4"
+#define MED_NOM_T10 "T10"
+#define MED_NOM_HE8 "HE8"
+#define MED_NOM_H20 "H20"
+#define MED_NOM_PE6 "PE6"
+#define MED_NOM_P15 "P15"
+#define MED_NOM_PY5 "PY5"
+#define MED_NOM_P13 "P13"
+#define MED_CHA "/CHA/"
+#define MED_TAILLE_CHA 5
+#define MED_NOM_NCO "NCO"
+#define MED_NOM_PDT "PDT"
+#define MED_NOM_NGA "NGA"
+#define MED_NOM_GAU "GAU"
+#define MED_NOM_PFL "PFL"
+#define MED_NOM_CO "CO"
+#define MED_PROFILS "/PROFILS/"
+#define MED_TAILLE_PROFILS 9
+#define MED_LIENS "/LIENS/"
+#define MED_TAILLE_LIENS 7
+ }
+}
+
+// namespace med_2_2 {
+// extern "C" {
+// #include <med_hdfi.h>
+// #include <med_misc.h>
+
+// #define MED_NOM_MAJEUR "MAJ"
+// #define MED_NOM_MINEUR "MIN"
+// #define MED_NOM_RELEASE "REL"
+
+// #define MED_NUM_MAJEUR 2
+// #define MED_NUM_MINEUR 2
+// #define MED_NUM_RELEASE 1
+
+// #define MED_NOM_INFOS "INFOS_GENERALES"
+
+// #define MED_NOM_DESCRIPTEUR "descripteur de fichier"
+// #define MED_VERSION_ACTUELLE "2.2.1"
+// #define HDF_VERSION_ACTUELLE "5-1.4.4"
+
+// /* Noms des data sets ou attributs correspondant a des entites MED */
+// #define MED_TAILLE_NOM_ENTITE 3
+// #define MED_NOM_NUM "NUM"
+// #define MED_NOM_NBR "NBR"
+// #define MED_NOM_NOM "NOM"
+// #define MED_NOM_UNV "UNV"
+// #define MED_NOM_NNS "NNS"
+// #define MED_NOM_NNM "NNM"
+// #define MED_NOM_NNI "NNI"
+// #define MED_NOM_GRO "GRO"
+// #define MED_NOM_ATT "ATT"
+// #define MED_NOM_NCO "NCO"
+// #define MED_NOM_DIM "DIM"
+// #define MED_NOM_ESP "ESP"
+// #define MED_NOM_FAM "FAM"
+// #define MED_NOM_IDE "IDE"
+// #define MED_NOM_VAL "VAL"
+// #define MED_NOM_DES "DES"
+// #define MED_NOM_COR "COR"
+// #define MED_NOM_DIM "DIM"
+// #define MED_NOM_NOE "NOE"
+// #define MED_NOM_COO "COO"
+// #define MED_NOM_IN1 "IN1"
+// #define MED_NOM_IN2 "IN2"
+// #define MED_NOM_IN3 "IN3"
+// #define MED_NOM_REP "REP"
+// #define MED_NOM_UNI "UNI"
+// #define MED_NOM_NOD "NOD"
+// #define MED_NOM_TYP "TYP"
+// #define MED_NOM_GTY "GTY"
+// #define MED_NOM_CO "CO"
+// #define MED_NOM_NCW "NCW"
+// #define MED_NOM_TYW "TYW"
+
+// #define MED_NOM_MAI "MAI"
+// #define MED_NOM_FAC "FAC"
+// #define MED_NOM_ARE "ARE"
+
+// #define MED_NOM_PO1 "PO1"
+// #define MED_NOM_SE2 "SE2"
+// #define MED_NOM_SE3 "SE3"
+// #define MED_NOM_TR3 "TR3"
+// #define MED_NOM_TR6 "TR6"
+// #define MED_NOM_QU4 "QU4"
+// #define MED_NOM_QU8 "QU8"
+// #define MED_NOM_TE4 "TE4"
+// #define MED_NOM_T10 "T10"
+// #define MED_NOM_HE8 "HE8"
+// #define MED_NOM_H20 "H20"
+// #define MED_NOM_PE6 "PE6"
+// #define MED_NOM_P15 "P15"
+// #define MED_NOM_PY5 "PY5"
+// #define MED_NOM_P13 "P13"
+
+// #define MED_NOM_TAI "TAI"
+// #define MED_NOM_TTI "TTI"
+// #define MED_NOM_IFN "IFN"
+// #define MED_NOM_IFD "IFD"
+// #define MED_NOM_INN "INN"
+// #define MED_NOM_IND "IND"
+// #define MED_NOM_POG "POG"
+// #define MED_NOM_POE "POE"
+
+// #define MED_NOM_GEO "GEO"
+// #define MED_NOM_GAU "GAU"
+// #define MED_NOM_NGA "NGA"
+// #define MED_NOM_PFL "PFL"
+// #define MED_NOM_NDT "NDT"
+// #define MED_NOM_PDT "PDT"
+// #define MED_NOM_NOR "NOR"
+// #define MED_NOM_LIE "LIE"
+
+// /* Nom du DATA GROUP CONTENANT TOUS LES MAILLAGES DU FICHIER HDF */
+// #define MED_MAA "/ENS_MAA/"
+// #define MED_TAILLE_MAA 9
+
+// /* Nom du data group ou ranger les champs solution */
+// #define MED_CHA "/CHA/"
+// #define MED_TAILLE_CHA 5
+
+// /* Nom du data group point de montage */
+// #define MED_MNT "/MNT/"
+// #define MED_TAILLE_MNT 5
+
+// /* Nom du data group ou ranger les familles */
+// #define FAMILLE_ZERO "FAMILLE_ZERO"
+// #define MED_FAS "/FAS/"
+// #define MED_TAILLE_FAS 5
+// #define MED_FAS_NOEUD "/NOEUD/"
+// #define MED_FAS_NOEUD_NOM "NOEUD"
+// #define MED_FAS_ELEME "/ELEME/"
+// #define MED_FAS_ELEME_NOM "ELEME"
+// #define MED_TAILLE_FAS_ENTITE 7
+
+
+// /* Nom du data group ou ranger les equivalences */
+// #define MED_EQS "/EQS/"
+// #define MED_TAILLE_EQS 5
+
+// /* Nom du data group contenant les profils */
+// #define MED_PROFILS "/PROFILS/"
+// #define MED_TAILLE_PROFILS 9
+
+// /* Nom du data group contenant la localisation des points de GAUSS */
+// #define MED_GAUSS "/GAUSS/"
+// #define MED_TAILLE_GAUSS 7
+
+// /* Nom du groupe HDF ou sont rangees les valeurs numeriques scalaires
+// non liees au modele de donnees
+// */
+// #define MED_NUM_DATA "/NUM_DATA/"
+// #define MED_TAILLE_NUM_DATA 10
+
+// /* Nom du data group contenant les liens */
+// #define MED_LIENS "/LIENS/"
+// #define MED_TAILLE_LIENS 7
+
+// }
+// }
+
+#include <stdio.h>
+#include <string.h>
+
+#define ANCIEN_MED_TAILLE_PNOM 8
+/* 12345678 */
+#define ANCIEN_MED_BLANC_PNOM " "
+
+namespace med_2_2 {
+
+med_err OLD_MEDattrNumLire(med_idt pere, med_type_champ type, char *nom,
+ unsigned char *val, hid_t hdf_file);
+
+med_err OLD_MEDdatasetNumLire(med_idt pere, char *nom, med_type_champ type,
+ med_mode_switch interlace, med_size nbdim,
+ med_size fixdim, med_size psize,
+ med_ssize * pfltab, med_int ngauss,
+ unsigned char *val,hid_t hdf_file);
+
+void conversion_chaine(char *ancienne_chaine, char *nouvelle_chaine,
+ med_int n);
+
+void MAJ_version(med_idt fid) throw (MEDMEM::MEDEXCEPTION) ;
+
+void MAJ_noeuds_maillage(med_idt mid, med_int dimension) throw (MEDMEM::MEDEXCEPTION) ;
+
+void MAJ_elements_maillage(med_idt mid, med_int dimension)
+ throw (MEDMEM::MEDEXCEPTION);
+
+void MAJ_familles_maillage(med_idt mid) throw (MEDMEM::MEDEXCEPTION) ;
+
+void MAJ_maillages(med_idt fid) throw (MEDMEM::MEDEXCEPTION) ;
+
+void MAJ_localisation_Gauss(med_idt fid,char *nom_modele,med_int ngauss)
+ throw (MEDMEM::MEDEXCEPTION) ;
+
+void MAJ_champs(med_idt fid) throw (MEDMEM::MEDEXCEPTION) ;
+
+void MAJ_profils(med_idt fid,med_int nprofil) throw (MEDMEM::MEDEXCEPTION) ;
+}
+
+namespace MEDMEM {
+
+/*!
+ This method is supposed to be the same as the med File V2.2 medimport
+ utility. fileNameIn is .med V2.1 file supplied by the user including
+ all the directory path. fileNameOut is .med V2.2 file produced by this
+ command in the directory $HOME/TMP_Med2_2Files/
+*/
+
+char * med2_1_To_med2_2(char * fileNameIn) throw (MEDMEM::MEDEXCEPTION) ;
+}
+
+#endif /* IMPORT_HXX */
MEDMEM_Array.hxx \
MEDMEM_Exception.hxx \
MEDMEM_MedFieldDriver.hxx \
+MEDMEM_AsciiFieldDriver.hxx \
MEDMEM_Med.hxx \
MEDMEM_MedMedDriver.hxx \
MEDMEM_MedMeshDriver.hxx \
MEDMEM_STRING.hxx \
MEDMEM_Support.hxx \
MEDMEM_Unit.hxx \
-MEDMEM_Grid.hxx
+MEDMEM_Grid.hxx \
+MEDMEM_RCBase.hxx \
+MEDMEM_medimport_src.hxx \
+MEDMEM_MedVersion.hxx \
+MEDMEM_Compatibility21_22.hxx \
+MEDMEM_MedFieldDriver21.hxx \
+MEDMEM_MedMeshDriver21.hxx \
+MEDMEM_MedMedDriver21.hxx \
+MEDMEM_PolyhedronArray.hxx \
+MEDMEM_MedFieldDriver22.hxx \
+MEDMEM_MedMedDriver22.hxx \
+MEDMEM_MedMeshDriver22.hxx
# Libraries targets
MEDMEM_Unit.cxx \
MEDMEM_VtkMedDriver.cxx \
MEDMEM_VtkMeshDriver.cxx \
-MEDMEM_Grid.cxx
-
+MEDMEM_Grid.cxx \
+MEDMEM_MedVersion.cxx \
+MEDMEM_MedMeshDriver21.cxx \
+MEDMEM_MedMedDriver21.cxx \
+MEDMEM_medimport_src.cxx \
+MEDMEM_PolyhedronArray.cxx \
+MEDMEM_MedMedDriver22.cxx \
+MEDMEM_MedMeshDriver22.cxx
# Executables targets
-BIN = med2vtk duplicateMED med_test duplicateMEDMESH
+BIN = med2_1_To_med2_2 med2vtk duplicateMED med_test duplicateMEDMESH
BIN_SRC =
BIN_SERVER_IDL =
BIN_CLIENT_IDL =
-TEST_PROGS = test_MEDMEM_ModulusArray test_MEDMEM_Array test_MEDMEM_SkyLineArray test_MEDMEM_CellModel testUPointerOf testUCoordinate testUUnit testUGeoNameMeshEntities testUMedException testUModulusArray testUSkyLineArray testUArray testUCellModel readEntete readCoordinate test_copie_field_ test_copie_fieldT test_copie_coordinate test_copie_medarray test_copie_connectivity test_copie_support test_copie_family test_copie_group test_copie_mesh test_affect_medarray test_MEDMEM_Meshing test_operation_fielddouble test_operation_fieldint test_gibi_driver test_porflow_driver test_grid
+TEST_PROGS = test_MEDMEM_ModulusArray test_MEDMEM_Array test_MEDMEM_SkyLineArray test_MEDMEM_CellModel testUPointerOf testUCoordinate testUUnit testUGeoNameMeshEntities testUMedException testUModulusArray testUSkyLineArray testUArray testUCellModel readEntete readCoordinate test_copie_field_ test_copie_fieldT test_copie_coordinate test_copie_medarray test_copie_connectivity test_copie_support test_copie_family test_copie_group test_copie_mesh test_affect_medarray test_MEDMEM_Meshing test_MEDMEM_MeshingPoly test_operation_fielddouble test_operation_fieldint test_gibi_driver test_porflow_driver test_grid test_MEDMEM_PolyhedronArray test_MEDMEM_PolyConnectivity test_MEDMEM_PolyDriverMedMeshRead test_MEDMEM_PolyDriverMedMeshWrite test_MEDMEM_poly3D
+# test_MEDMEM_Meshing_poly
# testUCellModel -> a revoir car l'API a changee (plus de vector)
--- /dev/null
+/*
+ creation d'une geometrie 2d :
+ maillé en 4 quadrangles reguliers
+ 1 triangle et 1 polygone.
+
+*/
+
+#include <med.h>
+#include <string.h>
+
+int main (int argc, char **argv)
+{
+ med_err ret;
+ med_idt fid;
+ char maa[MED_TAILLE_NOM+1] = "poly2D";
+ char maadesc[MED_TAILLE_DESC+1] = "Example de maillage non structure 2D avec 1 polygone";
+ med_int mdim = 2;
+ med_int nnoe = 11;
+ /*
+ les noeuds:
+ */
+ med_float coo[22] = {
+ 0.0, 0.0,
+ 0.5, 0.0,
+ 1.0, 0.0,
+ 0.25, 0.5,
+ 0.5, 0.5,
+ 0.75, 0.5,
+ 0.0, 1.0,
+ 0.5, 1.0,
+ 1.0, 1.0,
+ 1.5, 0.0,
+ 1.5, 1.0
+ };
+ char nomcoo[2*MED_TAILLE_PNOM+1] = "x y ";
+ char unicoo[2*MED_TAILLE_PNOM+1] = "cm cm ";
+ /* char nomnoe[19*MED_TAILLE_PNOM+1] = "nom1 nom2 nom3 nom4";*/
+ char *nomnoe ;
+ med_int numnoe[11] = {1,2,3,4,5,6,7,8,9,10,11};
+ med_int nufano[11] = {0,0,0,0,0,0,0,0,0,0,0};
+ /*
+ les elements:
+ */
+ med_int nquad4 = 4;
+ med_int quad4[16] = {
+ 4, 5, 2, 1,
+ 5, 6, 3, 2,
+ 7, 8, 5, 4,
+ 8, 9, 6, 5
+ };
+ char nomquad4[MED_TAILLE_PNOM*4+1] = "quad1 quad2 quad3 quad4 ";
+ med_int numquad4[4] = {1,2,3,4};
+ med_int nufaquad4[4] = {-1,-1,0,0};
+
+ med_int ntria3 = 1;
+ med_int tria3[3] = {
+ 7, 4, 1
+ };
+ char nomtria3[MED_TAILLE_PNOM+1] = "tria1 ";
+ med_int numtria3[1] = {1};
+ med_int nufatria3[1] = {-2};
+
+ med_int npoly = 1;
+ med_int nindexpoly = 2;
+ med_int indexpoly [2] = {
+ 1,6
+ };
+ med_int poly[5] = {
+ 9,11,10,3,6
+ };
+ char nompoly[MED_TAILLE_PNOM+1] = "poly ";
+ med_int numpoly[1] = {1};
+ med_int nufapoly[1] = {-3};
+
+ char nomfam[MED_TAILLE_NOM+1];
+ med_int numfam;
+ char attdes[MED_TAILLE_DESC+1];
+ med_int natt;
+ med_int attide;
+ med_int attval;
+ med_int ngro;
+ char gro[MED_TAILLE_LNOM+1];
+ int i;
+ int nfame = 2;
+ int nfamn = 1;
+
+ /*
+ Some fields : 2 on nodes : one int and one double , one on cells : double
+ */
+ char champ1[MED_TAILLE_NOM+1]="fieldnodeint" ;
+ char champ1_comp[MED_TAILLE_PNOM+1]="comp1 " ;
+ char champ1_unit[MED_TAILLE_PNOM+1]="M " ;
+ med_int fieldnodeint[9] = {1,1,3,2,2,3,4,4,5};
+
+ char champ2[MED_TAILLE_NOM+1]="fieldnodedouble" ;
+ char champ2_comp[MED_TAILLE_PNOM+1]="comp1 " ;
+ char champ2_unit[MED_TAILLE_PNOM+1]="J " ;
+ med_float fieldnodedouble1[9] = {1.,3.,4.,1.,3.,4.,3.,2.,5.};
+ med_float fieldnodedouble2[9] = {1.,2.,2.,3.,3.,3.,4.,4.,5.};
+
+ char champ3[MED_TAILLE_NOM+1]="fieldcelldouble" ;
+ char champ3_comp[MED_TAILLE_PNOM*2+1]="comp1 comp2 " ;
+ char champ3_unit[MED_TAILLE_PNOM*2+1]="M/S m/s " ;
+ med_float fieldcelldouble[4*2] = {0.,1.,1.,1.,1.,2.,2.,3.};
+
+ /***************************************************************************/
+ fid = MEDouvrir("poly2D.med",MED_LECTURE_ECRITURE);
+ if (fid < 0)
+ ret = -1;
+ else
+ ret = 0;
+ printf("MEDouvrir : %d\n",ret);
+
+ /***************************************************************************/
+ if (ret == 0)
+ ret = MEDmaaCr(fid,maa,mdim,MED_NON_STRUCTURE,maadesc);
+ printf("MEDmaaCr : %d\n",ret);
+ if (ret == 0)
+ ret = MEDunvCr(fid,maa);
+ printf("MEDunvCr : %d\n",ret);
+
+ /***************************************************************************/
+ if (ret == 0)
+ ret = MEDnoeudsEcr(fid,maa,mdim,coo,MED_FULL_INTERLACE,MED_CART,
+ nomcoo,unicoo,nomnoe,MED_FAUX,numnoe,MED_VRAI,
+ nufano,nnoe);
+ printf("MEDnoeudsEcr : %d\n",ret);
+
+ /* ecriture des mailles MED_QUAD4 :
+ - connectivite
+ - noms (optionnel)
+ - numeros (optionnel)
+ - numeros des familles */
+ if (ret == 0)
+ ret = MEDelementsEcr(fid,maa,mdim,quad4,MED_FULL_INTERLACE,
+ nomquad4,MED_FAUX,numquad4,MED_VRAI,nufaquad4,nquad4,
+ MED_MAILLE,MED_QUAD4,MED_NOD);
+ printf("MEDelementsEcr for quad : %d \n",ret);
+
+ /* ecriture des mailles MED_TRIA3 :
+ - connectivite
+ - noms (optionnel)
+ - numeros (optionnel)
+ - numeros des familles */
+ if (ret == 0)
+ ret = MEDelementsEcr(fid,maa,mdim,tria3,MED_FULL_INTERLACE,
+ nomtria3,MED_FAUX,numtria3,MED_VRAI,nufatria3,ntria3,
+ MED_MAILLE,MED_TRIA3,MED_NOD);
+ printf("MEDelementsEcr for tria : %d \n",ret);
+
+ /* ecriture des mailles MED_POLYGONE:
+ - connectivite
+ - noms (optionnel)
+ - numeros (optionnel)
+ - numeros des familles
+ Dans ce cas il n existe pas de routine globale (Warning !!)
+ */
+
+ if (ret == 0)
+ ret = MEDpolygoneConnEcr(fid,maa,indexpoly,nindexpoly,poly,
+ MED_MAILLE,MED_NOD);
+ printf("MEDpolygoneConnEcr: %d \n",ret);
+
+ if (ret == 0)
+ MEDnomEcr(fid,maa,nompoly,npoly,MED_MAILLE,MED_POLYGONE);
+ printf("MEDnomEcr for poly : %d \n",ret);
+
+ if (ret == 0)
+ MEDnumEcr(fid,maa,numpoly,npoly,MED_MAILLE,MED_POLYGONE);
+ printf("MEDnumEcr for poly : %d \n",ret);
+
+ if (ret == 0)
+ MEDfamEcr(fid,maa,nufapoly,npoly,MED_MAILLE,MED_POLYGONE);
+ printf("MEDfamEcr for poly : %d \n",ret);
+
+
+ /***************************************************************************/
+ /* ecriture des familles */
+ /* Conventions :
+ - toujours creer une famille de numero 0 ne comportant aucun attribut
+ ni groupe (famille de reference pour les noeuds ou les elements
+ qui ne sont rattaches a aucun groupe ni attribut)
+ - les numeros de familles de noeuds sont > 0
+ - les numeros de familles des elements sont < 0
+ - rien d'imposer sur les noms de familles
+ */
+
+ /* la famille 0 */
+ if (ret == 0)
+ {
+ strcpy(nomfam,"FAMILLE_0");
+ numfam = 0;
+ ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,0,
+ gro,0);
+ }
+ printf("MEDfamCr : %d \n",ret);
+
+ /* on cree :
+ - 2 familles d'elements de dimension (d)
+ en fait de face (-10)
+ */
+ if (ret == 0)
+ {
+ numfam = -1;
+ strcpy(nomfam,"FAMILLE_CELL_");
+ sprintf(nomfam,"%s%d",nomfam,-numfam);
+ attide = 1;
+ attval = numfam*100;
+ natt = 1;
+ strcpy(attdes,"description attribut");
+ strcpy(gro,"groupe0");
+ ngro = 1;
+
+ ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,
+ natt,gro,ngro);
+ printf("MEDfamCr : %d\n",ret);
+
+ numfam = -2;
+ strcpy(nomfam,"FAMILLE_CELL_");
+ sprintf(nomfam,"%s%d",nomfam,-numfam);
+ attide = 1;
+ attval = numfam*100;
+ natt = 1;
+ strcpy(attdes,"description attribut");
+ strcpy(gro,"groupe0");
+ ngro = 1;
+
+ ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,
+ natt,gro,ngro);
+ printf("MEDfamCr : %d\n",ret);
+
+ numfam = -3;
+ strcpy(nomfam,"FAMILLE_CELL_");
+ sprintf(nomfam,"%s%d",nomfam,-numfam);
+ attide = 1;
+ attval = numfam*100;
+ natt = 1;
+ strcpy(attdes,"description attribut");
+ strcpy(gro,"groupe0");
+ ngro = 1;
+
+ ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,
+ natt,gro,ngro);
+ printf("MEDfamCr : %d\n",ret);
+ }
+
+ /***************************************************************************/
+ /*
+ Les champs
+ */
+ if (ret == 0)
+ {
+ ret = MEDchampCr(fid,champ1,MED_INT32,champ1_comp,champ1_unit,1);
+ printf("MEDchampCr : %d \n",ret);
+ if (ret == 0) {
+ ret = MEDchampEcr(fid, maa, champ1, (unsigned char *)fieldnodeint,
+ MED_NO_INTERLACE, nnoe, MED_NOGAUSS, MED_ALL,
+ MED_NOPFL, MED_NO_PFLMOD, MED_NOEUD, 0,
+ MED_NOPDT," ", 0., MED_NONOR);
+
+ printf("MEDchampEcr : %d \n",ret);
+ }
+ }
+
+ if (ret == 0)
+ {
+ ret = MEDchampCr(fid,champ2,MED_FLOAT64,champ2_comp,champ2_unit,1);
+ printf("MEDchampCr : %d \n",ret);
+ if (ret == 0) {
+ ret = MEDchampEcr(fid, maa, champ2, (unsigned char *)fieldnodedouble1,
+ MED_NO_INTERLACE, nnoe, MED_NOGAUSS, MED_ALL,
+ MED_NOPFL, MED_NO_PFLMOD, MED_NOEUD, 0,
+ 1,"S ", 1.1 , MED_NONOR);
+ printf("MEDchampEcr1 : %d \n",ret);
+ ret = MEDchampEcr(fid, maa, champ2, (unsigned char *)fieldnodedouble2,
+ MED_NO_INTERLACE, nnoe, MED_NOGAUSS, MED_ALL,
+ MED_NOPFL, MED_NO_PFLMOD, MED_NOEUD, 0,
+ 2,"S ", 1.2 , MED_NONOR);
+ printf("MEDchampEcr2 : %d \n",ret);
+ }
+ }
+
+ // on met champ2 sans pas de temps pour pouvoir le lire aussi par defaut !
+ if (ret == 0)
+ {
+ ret = MEDchampEcr(fid, maa, champ2, (unsigned char *)fieldnodedouble1,
+ MED_NO_INTERLACE, nnoe, MED_NOGAUSS, MED_ALL,
+ MED_NOPFL, MED_NO_PFLMOD, MED_NOEUD, 0,
+ MED_NOPDT," ", 0. , MED_NONOR);
+ printf("MEDchampEcr : %d \n",ret);
+ }
+
+ if (ret == 0)
+ {
+ ret = MEDchampCr(fid,champ3,MED_FLOAT64,champ3_comp,champ3_unit,2);
+ printf("MEDchampCr : %d \n",ret);
+ if (ret == 0) {
+ ret = MEDchampEcr(fid, maa, champ3, (unsigned char *)fieldcelldouble,
+ MED_NO_INTERLACE, nquad4, MED_NOGAUSS, MED_ALL,
+ MED_NOPFL, MED_NO_PFLMOD, MED_MAILLE, MED_QUAD4,
+ MED_NOPDT," ", 0., MED_NONOR);
+ printf("MEDchampEcr : %d \n",ret);
+ }
+ }
+
+ /***************************************************************************/
+
+ ret = MEDfermer(fid);
+ printf("MEDfermer : %d\n",ret);
+
+ return 0;
+}
+
--- /dev/null
+/*
+ creation d'une geometrie 3d :
+ maillé en :
+ - 2 polyedres
+ ayant pour faces 3 polygones
+ 9 quadrangles
+ 6 triangles
+ - 1 tetra4
+
+*/
+
+#include <med.h>
+#include <string.h>
+
+int main (int argc, char **argv)
+{
+ med_err ret;
+ med_idt fid;
+ char maa[MED_TAILLE_NOM+1] = "poly3D";
+ char maadesc[MED_TAILLE_DESC+1] = "Example de maillage non structure 3D avec 2 polyedres+1tetra4 comme mailles et 3 polygones comme faces";
+ med_int mdim = 3;
+ med_int nnoe = 19;
+ /*
+ les noeuds:
+ */
+ med_float coo[57] = {
+ 2.0, 3.0, 2.0,
+ 3.0, 2.0, 2.0,
+ 4.0, 1.0, 2.0,
+ 2.0, 0.0, 2.0,
+ 0.0, 1.0, 2.0,
+ 1.0, 2.0, 2.0,
+ 2.0, 3.0, 1.0,
+ 3.0, 2.0, 0.0,
+ 4.0, 1.0, 0.0,
+ 2.0, 0.0, 0.0,
+ 0.0, 1.0, 0.0,
+ 1.0, 2.0, 0.0,
+ 5.0, 3.0, 2.0,
+ 7.0, 2.0, 2.0,
+ 6.0, 0.0, 2.0,
+ 6.0, 3.0, 0.0,
+ 7.0, 2.0, 0.0,
+ 6.0, 0.0, -1.0,
+ 5.0, 1.0, -3.0
+ };
+ char nomcoo[3*MED_TAILLE_PNOM+1] = "x y z ";
+ char unicoo[3*MED_TAILLE_PNOM+1] = "cm cm cm ";
+ /* char nomnoe[18*MED_TAILLE_PNOM+1] = "nom1 nom2 nom3 nom4";*/
+ char *nomnoe ;
+ med_int numnoe[19] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19};
+ med_int nufano[19] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
+ /*
+ les elements:
+ */
+ /* Faces QUAD4 */
+ med_int nquad4 = 8;
+ med_int quad4[32] = {
+ 1, 7, 8, 2,
+ 2, 8, 9, 3,
+ 4, 3, 9, 10,
+ 5, 4, 10, 11,
+ 6, 5, 11, 12,
+ 1, 6, 12, 7,
+ 14, 13, 16, 17,
+ 8, 9, 17, 16
+ };
+ char nomquad4[MED_TAILLE_PNOM*8+1] = "quad1 quad2 quad3 quad4 quad5 quad6 quad7 quad8 ";
+ med_int numquad4[9] = {2,3,4,5,6,7,12,17};
+ med_int nufaquad4[9] = {-1,-1,-1,-1,-1,-1,-1,-1};
+
+ /* Faces TRIA3 */
+ med_int ntria3 = 6;
+ med_int tria3[18] = {
+ 7, 12, 8,
+ 15, 14, 17,
+ 15, 17, 18,
+ 15, 18, 9,
+ 3, 15, 9,
+ 18, 17, 9
+ };
+ char nomtria3[MED_TAILLE_PNOM*6+1] = "tria1 tria2 tria3 tria4 tria5 tria6 ";
+ med_int numtria3[6] = {8,13,14,15,16,18};
+ med_int nufatria3[6] = {-2,-2,-2,-2,-2,-2};
+
+ /* Faces POLYGONE */
+ med_int npolygon = 3;
+ med_int nindexpolygon = 4;
+ med_int indexpolygon [4] = {
+ 1, 7, 12, 17
+ };
+ med_int polygon[16] = {
+ 1, 2, 3, 4, 5, 6,
+ 10, 9, 8, 12, 11,
+ 13, 14, 15, 3, 2
+ };
+ char nompolygon[MED_TAILLE_PNOM*3+1] = "polygon1 polygon2 polygon3 ";
+ med_int numpolygon[3] = {1,9,10};
+ med_int nufapolygon[3] = {-3,-3,-3};
+
+ /* Mailles POLYEDRE */
+ med_int npolyhedron = 2;
+ med_int npolyhedronfaces = 19;
+ med_int npolyhedronnodes = 74;
+ med_int polyhedronconnectivity[74] = {1,2,3,4,5,6,1,7,8,2,2,8,9,3,4,3,9,10,5,4,10,11,6,5,11,12,1,6,12,7,7,12,8,10,9,8,12,11,
+ 13,14,15,3,2,13,2,8,16,14,13,16,17,15,14,17,15,17,18,15,18,9,3,15,9,2,3,9,8,8,9,17,16,9,18,17};
+ med_int polyhedronfacesindex[20] = {1,7,11,15,19,23,27,31,34,
+ 39,44,48,52,55,58,61,64,68,72,75};
+ med_int polyhedronindex[3] = {1,10,20};
+ char nompolyhedron[MED_TAILLE_PNOM*2+1] = "polyhedron1 polyhedron2 ";
+ med_int numpolyhedron[2] = {2,3};
+ med_int nufapolyhedron[2] = {-4,-4};
+
+ /* Mailles TETRA4 */
+ med_int ntetra4 = 1;
+ med_int tetra4[4] = {
+ 17, 9, 18, 19
+ };
+ char nomtetra4[MED_TAILLE_PNOM*1+1] = "tetra1 ";
+ med_int numtetra4[1] = {1};
+ med_int nufatetra4[1] = {-5};
+
+
+ char nomfam[MED_TAILLE_NOM+1];
+ med_int numfam;
+ char attdes[MED_TAILLE_DESC+1];
+ med_int natt;
+ med_int attide;
+ med_int attval;
+ med_int ngro;
+ char gro[MED_TAILLE_LNOM+1];
+ int i;
+ int nfame = 2;
+ int nfamn = 1;
+
+ /*
+ Some fields : 2 on nodes : one int and one double , one on cells : double
+ */
+ char champ1[MED_TAILLE_NOM+1]="fieldnodeint" ;
+ char champ1_comp[MED_TAILLE_PNOM+1]="comp1 " ;
+ char champ1_unit[MED_TAILLE_PNOM+1]="M " ;
+ med_int fieldnodeint[19] = {1,1,3,2,2,3,4,4,5,6,6,7,8,8,9,9,9,10,5};
+
+ char champ2[MED_TAILLE_NOM+1]="fieldnodedouble" ;
+ char champ2_comp[MED_TAILLE_PNOM+1]="comp1 " ;
+ char champ2_unit[MED_TAILLE_PNOM+1]="J " ;
+ med_float fieldnodedouble1[19] = {1.,3.,4.,1.,3.,4.,3.,2.,5.,6.,4.,3.,1.,5.,6.,4.,3.,7.,3.};
+ med_float fieldnodedouble2[19] = {1.,2.,2.,3.,3.,3.,4.,4.,5.,2.,8.,9.,6.,7.,1.,2.,5.,8.,4.};
+
+ char champ3[MED_TAILLE_NOM+1]="fieldfacedouble" ;
+ char champ3_comp[MED_TAILLE_PNOM*2+1]="comp1 comp2 " ;
+ char champ3_unit[MED_TAILLE_PNOM*2+1]="M/S m/s " ;
+ med_float fieldfacedouble[6*2] = {0.,1.,1.,1.,1.,2.,2.,3.,3.,4.,4.,6.};
+
+ /***************************************************************************/
+ fid = MEDouvrir("poly3D.med",MED_LECTURE_ECRITURE);
+ if (fid < 0)
+ ret = -1;
+ else
+ ret = 0;
+ printf("MEDouvrir : %d\n",ret);
+
+ /***************************************************************************/
+ if (ret == 0)
+ ret = MEDmaaCr(fid,maa,mdim,MED_NON_STRUCTURE,maadesc);
+ printf("MEDmaaCr : %d\n",ret);
+ if (ret == 0)
+ ret = MEDunvCr(fid,maa);
+ printf("MEDunvCr : %d\n",ret);
+
+ /***************************************************************************/
+ if (ret == 0)
+ ret = MEDnoeudsEcr(fid,maa,mdim,coo,MED_FULL_INTERLACE,MED_CART,
+ nomcoo,unicoo,nomnoe,MED_FAUX,numnoe,MED_VRAI,
+ nufano,nnoe);
+ printf("MEDnoeudsEcr : %d\n",ret);
+
+ /* ecriture des faces MED_QUAD4 :
+ - connectivite
+ - noms (optionnel)
+ - numeros (optionnel)
+ - numeros des familles */
+ if (ret == 0)
+ ret = MEDelementsEcr(fid,maa,mdim,quad4,MED_FULL_INTERLACE,
+ nomquad4,MED_FAUX,numquad4,MED_VRAI,nufaquad4,nquad4,
+ MED_MAILLE,MED_QUAD4,MED_NOD);
+ printf("MEDelementsEcr for quad : %d \n",ret);
+
+ /* ecriture des faces MED_TRIA3 :
+ - connectivite
+ - noms (optionnel)
+ - numeros (optionnel)
+ - numeros des familles */
+ if (ret == 0)
+ ret = MEDelementsEcr(fid,maa,mdim,tria3,MED_FULL_INTERLACE,
+ nomtria3,MED_FAUX,numtria3,MED_VRAI,nufatria3,ntria3,
+ MED_MAILLE,MED_TRIA3,MED_NOD);
+ printf("MEDelementsEcr for tria : %d \n",ret);
+
+ /* ecriture des faces MED_POLYGONE :
+ - connectivite
+ - noms (optionnel)
+ - numeros (optionnel)
+ - numeros des familles
+ Dans ce cas il n existe pas de routine globale (Warning !!) */
+ if (ret == 0)
+ ret = MEDpolygoneConnEcr(fid,maa,indexpolygon,nindexpolygon,polygon,
+ MED_MAILLE,MED_NOD);
+ printf("MEDpolygoneConnEcr: %d \n",ret);
+
+ if (ret == 0)
+ MEDnomEcr(fid,maa,nompolygon,npolygon,MED_MAILLE,MED_POLYGONE);
+ printf("MEDnomEcr for polygon : %d \n",ret);
+
+ if (ret == 0)
+ MEDnumEcr(fid,maa,numpolygon,npolygon,MED_MAILLE,MED_POLYGONE);
+ printf("MEDnumEcr for polygon : %d \n",ret);
+
+ if (ret == 0)
+ MEDfamEcr(fid,maa,nufapolygon,npolygon,MED_MAILLE,MED_POLYGONE);
+ printf("MEDfamEcr for polygon : %d \n",ret);
+
+ /* ecriture des mailles MED_POLYEDRE :
+ - connectivite
+ - noms (optionnel)
+ - numeros (optionnel)
+ - numeros des familles
+ Dans ce cas il n existe pas de routine globale (Warning !!) */
+ if (ret == 0)
+ ret = MEDpolyedreConnEcr(fid,maa,polyhedronindex,npolyhedron+1,polyhedronfacesindex,npolyhedronfaces+1,polyhedronconnectivity,MED_NOD);
+ printf("MEDpolyedreConnEcr: %d \n",ret);
+
+ if (ret == 0)
+ ret = MEDnomEcr(fid,maa,nompolyhedron,npolyhedron,MED_MAILLE,MED_POLYEDRE);
+ printf("MEDnomEcr for polyhedron : %d \n",ret);
+
+ if (ret == 0)
+ ret = MEDnumEcr(fid,maa,numpolyhedron,npolyhedron,MED_MAILLE,MED_POLYEDRE);
+ printf("MEDnumEcr for polyhedron : %d \n",ret);
+
+ if (ret == 0)
+ ret = MEDfamEcr(fid,maa,nufapolyhedron,npolyhedron,MED_MAILLE,MED_POLYEDRE);
+ printf("MEDfamEcr for polyhedron : %d \n",ret);
+
+ /* ecriture des mailles TETRA4 :
+ - connectivite
+ - noms (optionnel)
+ - numeros (optionnel)
+ - numeros des familles */
+ if (ret == 0)
+ ret = MEDelementsEcr(fid,maa,mdim,tetra4,MED_FULL_INTERLACE,
+ nomtetra4,MED_FAUX,numtetra4,MED_VRAI,nufatetra4,ntetra4,
+ MED_MAILLE,MED_TETRA4,MED_NOD);
+ printf("MEDelementsEcr for tetra : %d \n",ret);
+
+ /***************************************************************************/
+ /* ecriture des familles */
+ /* Conventions :
+ - toujours creer une famille de numero 0 ne comportant aucun attribut
+ ni groupe (famille de reference pour les noeuds ou les elements
+ qui ne sont rattaches a aucun groupe ni attribut)
+ - les numeros de familles de noeuds sont > 0
+ - les numeros de familles des elements sont < 0
+ - rien d'imposer sur les noms de familles
+ */
+
+ /* la famille 0 */
+ if (ret == 0)
+ {
+ strcpy(nomfam,"FAMILLE_0");
+ numfam = 0;
+ ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,0,
+ gro,0);
+ }
+ printf("MEDfamCr : %d \n",ret);
+
+ /* on cree :
+ - 2 familles d'elements de dimension (d)
+ en fait de face (-10)
+ */
+ /*
+ if (ret == 0)
+ {
+ numfam = -1;
+ strcpy(nomfam,"FAMILLE_FACE_QUAD4");
+ sprintf(nomfam,"%s%d",nomfam,-numfam);
+ attide = 1;
+ attval = numfam*100;
+ natt = 1;
+ strcpy(attdes,"description attribut");
+ strcpy(gro,"groupe0");
+ ngro = 1;
+
+ ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,
+ natt,gro,ngro);
+ printf("MEDfamCr : %d\n",ret);
+
+ numfam = -2;
+ strcpy(nomfam,"FAMILLE_FACE_TRIA3");
+ sprintf(nomfam,"%s%d",nomfam,-numfam);
+ attide = 1;
+ attval = numfam*100;
+ natt = 1;
+ strcpy(attdes,"description attribut");
+ strcpy(gro,"groupe0");
+ ngro = 1;
+
+ ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,
+ natt,gro,ngro);
+ printf("MEDfamCr : %d\n",ret);
+
+ numfam = -3;
+ strcpy(nomfam,"FAMILLE_FACE_POLYGONS");
+ sprintf(nomfam,"%s%d",nomfam,-numfam);
+ attide = 1;
+ attval = numfam*100;
+ natt = 1;
+ strcpy(attdes,"description attribut");
+ strcpy(gro,"groupe0");
+ ngro = 1;
+
+ ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,
+ natt,gro,ngro);
+ printf("MEDfamCr : %d\n",ret);
+
+ numfam = -4;
+ strcpy(nomfam,"FAMILLE_MAILLE_POLYHEDRON");
+ sprintf(nomfam,"%s%d",nomfam,-numfam);
+ attide = 1;
+ attval = numfam*100;
+ natt = 1;
+ strcpy(attdes,"description attribut");
+ strcpy(gro,"groupe0");
+ ngro = 1;
+
+ ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,
+ natt,gro,ngro);
+ printf("MEDfamCr : %d\n",ret);
+
+ numfam = -5;
+ strcpy(nomfam,"FAMILLE_MAILLE_TETRA4");
+ sprintf(nomfam,"%s%d",nomfam,-numfam);
+ attide = 1;
+ attval = numfam*100;
+ natt = 1;
+ strcpy(attdes,"description attribut");
+ strcpy(gro,"groupe0");
+ ngro = 1;
+
+ ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,
+ natt,gro,ngro);
+ printf("MEDfamCr : %d\n",ret);
+ }
+ */
+ /***************************************************************************/
+ /*
+ Les champs
+ */
+ if (ret == 0)
+ {
+ ret = MEDchampCr(fid,champ1,MED_INT32,champ1_comp,champ1_unit,1);
+ printf("MEDchampCr : %d \n",ret);
+ if (ret == 0) {
+ ret = MEDchampEcr(fid, maa, champ1, (unsigned char *)fieldnodeint,
+ MED_NO_INTERLACE, nnoe, MED_NOGAUSS, MED_ALL,
+ MED_NOPFL, MED_NO_PFLMOD, MED_NOEUD, 0,
+ MED_NOPDT," ", 0., MED_NONOR);
+
+ printf("MEDchampEcr : %d \n",ret);
+ }
+ }
+
+ if (ret == 0)
+ {
+ ret = MEDchampCr(fid,champ2,MED_FLOAT64,champ2_comp,champ2_unit,1);
+ printf("MEDchampCr : %d \n",ret);
+ if (ret == 0) {
+ ret = MEDchampEcr(fid, maa, champ2, (unsigned char *)fieldnodedouble1,
+ MED_NO_INTERLACE, nnoe, MED_NOGAUSS, MED_ALL,
+ MED_NOPFL, MED_NO_PFLMOD, MED_NOEUD, 0,
+ 1,"S ", 1.1 , MED_NONOR);
+ printf("MEDchampEcr1 : %d \n",ret);
+ ret = MEDchampEcr(fid, maa, champ2, (unsigned char *)fieldnodedouble2,
+ MED_NO_INTERLACE, nnoe, MED_NOGAUSS, MED_ALL,
+ MED_NOPFL, MED_NO_PFLMOD, MED_NOEUD, 0,
+ 2,"S ", 1.2 , MED_NONOR);
+ printf("MEDchampEcr2 : %d \n",ret);
+ }
+ }
+
+ // on met champ2 sans pas de temps pour pouvoir le lire aussi par defaut !
+ if (ret == 0)
+ {
+ ret = MEDchampEcr(fid, maa, champ2, (unsigned char *)fieldnodedouble1,
+ MED_NO_INTERLACE, nnoe, MED_NOGAUSS, MED_ALL,
+ MED_NOPFL, MED_NO_PFLMOD, MED_NOEUD, 0,
+ MED_NOPDT," ", 0. , MED_NONOR);
+ printf("MEDchampEcr : %d \n",ret);
+ }
+
+ if (ret == 0)
+ {
+ ret = MEDchampCr(fid,champ3,MED_FLOAT64,champ3_comp,champ3_unit,2);
+ printf("MEDchampCr : %d \n",ret);
+ if (ret == 0) {
+ ret = MEDchampEcr(fid, maa, champ3, (unsigned char *)fieldfacedouble,
+ MED_NO_INTERLACE, ntria3, MED_NOGAUSS, MED_ALL,
+ MED_NOPFL, MED_NO_PFLMOD, MED_FACE, MED_TRIA3,
+ MED_NOPDT," ", 0., MED_NONOR);
+ printf("MEDchampEcr : %d \n",ret);
+ }
+ }
+ /***************************************************************************/
+
+ ret = MEDfermer(fid);
+ printf("MEDfermer : %d\n",ret);
+
+ return 0;
+}
+
#include "MEDMEM_Exception.hxx"
#include "MEDMEM_Med.hxx"
+#ifdef _DEBUG_
+#include "LocalTraceCollector.hxx"
+#endif /* ifdef _DEBUG_*/
+
using namespace std;
using namespace MEDMEM;
void usage(char * name)
}
int main (int argc, char ** argv) {
-
+#ifdef _DEBUG_
+ LocalTraceCollector::instance();
+#endif /* ifdef _DEBUG_*/
+
if (argc != 3) usage(argv[0]);
string filenameIN = argv[1] ;
#include "MEDMEM_MedMedDriver.hxx"
#include "MEDMEM_MedMeshDriver.hxx"
+#ifdef _DEBUG_
+#include "LocalTraceCollector.hxx"
+#endif /* ifdef _DEBUG_*/
+
using namespace std;
using namespace MEDMEM;
int main (int argc, char ** argv) {
-
+#ifdef _DEBUG_
+ LocalTraceCollector::instance();
+#endif /* ifdef _DEBUG_*/
+
string filenameIN = argv[1] ;
string filenameOUT = argv[2] ;
--- /dev/null
+#include "MEDMEM_Exception.hxx"
+#include "MEDMEM_medimport_src.hxx"
+
+using namespace std;
+using namespace MEDMEM;
+
+int main (int argc, char ** argv)
+{
+ if (argc != 2)
+ {
+ cerr << "Usage : " << argv[0]
+ << " fileNameIn" << endl ;
+ cerr << "Where - fileNameIn is .med V2.1 file supplied by the user including all the directory path" << endl;
+ cerr << "fileNameOut is .med V2.2 file produced by this command in the directory $HOME/TMP_Med2_2Files/" << endl;
+ cerr << "This command is supposed to be the same as the med File V2.2 medimport utility" << endl << endl;
+ cerr << "It will produce a med V2.2 file fileNameOut which will be in the directory $HOME/TMP_Med2_2Files/" << endl;
+ cerr << "with the same root name as fileNameIn: " << endl;
+ cerr << "If fileNameIn is /aPath/file.med so fileNameOut will be $HOME/TMP_Med2_2Files/file.med" << endl;
+ exit(-1);
+ }
+
+ string fileNameIn = argv[1] ;
+ char * fileNameOut = med2_1_To_med2_2((const_cast <char *>
+ (fileNameIn.c_str())));
+
+ if (fileNameOut == ((char *) NULL))
+ {
+ cerr << "A problem has occured in the importation of the file " << fileNameIn.c_str() << " into " << fileNameOut << endl;
+ }
+ else if(fileNameOut != string(fileNameIn).c_str())
+ {
+ cerr << "the convertion has been successfull !! The resulting file is " << string(fileNameOut).c_str() << endl;
+ }
+ else
+ {
+ cerr << "No nedd to converte because the file is al ready a med 2.2 file" << endl;
+ }
+
+ return 0;
+}
#include "MEDMEM_Field.hxx"
#include "MEDMEM_VtkMedDriver.hxx"
+#ifdef _DEBUG_
+#include "LocalTraceCollector.hxx"
+#endif /* ifdef _DEBUG_*/
+
using namespace std;
using namespace MEDMEM;
void usage(char * name)
}
int main (int argc, char ** argv) {
-
+#ifdef _DEBUG_
+ LocalTraceCollector::instance();
+#endif /* ifdef _DEBUG_*/
+
if (argc != 3) usage(argv[0]);
string filenameIN = argv[1] ;
#include "MEDMEM_Family.hxx"
#include "MEDMEM_Group.hxx"
-#include "MEDMEM_MedMeshDriver.hxx"
-#include "MEDMEM_MedFieldDriver.hxx"
#include "MEDMEM_Support.hxx"
#include "MEDMEM_Field.hxx"
+#include "MEDMEM_MedMeshDriver.hxx"
+#include "MEDMEM_MedFieldDriver.hxx"
#include "MEDMEM_define.hxx"
+#ifdef _DEBUG_
+#include "LocalTraceCollector.hxx"
+#endif /* ifdef _DEBUG_*/
+
using namespace std;
using namespace MEDMEM;
using namespace MED_EN;
}
int main (int argc, char ** argv) {
+#ifdef _DEBUG_
+ LocalTraceCollector::instance();
+#endif /* ifdef _DEBUG_*/
int read;
#include "utilities.h"
#include "MEDMEM_Array.hxx"
+#ifdef _DEBUG_
+#include "LocalTraceCollector.hxx"
+#endif /* ifdef _DEBUG_*/
+
using namespace std;
using namespace MEDMEM;
int main (int argc, char ** argv) {
+#ifdef _DEBUG_
+ LocalTraceCollector::instance();
+#endif /* ifdef _DEBUG_*/
+
int SpaceDimension = 3 ;
int NumberOfNodes = 4 ;
MEDARRAY<int> * myArray = new MEDARRAY<int>(SpaceDimension,NumberOfNodes,MED_EN::MED_FULL_INTERLACE) ;
#include "MEDMEM_CellModel.hxx"
#include "MEDMEM_DriversDef.hxx"
+#ifdef _DEBUG_
+#include "LocalTraceCollector.hxx"
+#endif /* ifdef _DEBUG_*/
+
using namespace std;
using namespace MEDMEM;
using namespace MED_EN;
int main (int argc, char ** argv) {
+#ifdef _DEBUG_
+ LocalTraceCollector::instance();
+#endif /* ifdef _DEBUG_*/
+
list<medGeometryElement> geomList = meshEntities[MED_CELL] ;
list<medGeometryElement>::iterator itGeomList ;
for(itGeomList=geomList.begin();itGeomList!=geomList.end();itGeomList++) {
#include "MEDMEM_Group.hxx"
#include "MEDMEM_Field.hxx"
+#ifdef _DEBUG_
+#include "LocalTraceCollector.hxx"
+#endif /* ifdef _DEBUG_*/
+
using namespace std;
using namespace MEDMEM;
using namespace MED_EN;
exit(-1);
}
+#ifdef _DEBUG_
+ LocalTraceCollector::instance();
+#endif /* ifdef _DEBUG_*/
+
// filename to save the generated MESH
string filenameRoot = argv[1] ;
--- /dev/null
+#include "MEDMEM_Meshing.hxx"
+#include "MEDMEM_Field.hxx"
+#include "LocalTraceCollector.hxx"
+
+using namespace std;
+using namespace MEDMEM;
+using namespace MED_EN;
+
+int main (int argc, char ** argv) {
+ LocalTraceCollector::instance();
+
+ double Coordinates[57] = {
+ 2.0, 3.0, 2.0,
+ 3.0, 2.0, 2.0,
+ 4.0, 1.0, 2.0,
+ 2.0, 0.0, 2.0,
+ 0.0, 1.0, 2.0,
+ 1.0, 2.0, 2.0,
+ 2.0, 3.0, 1.0,
+ 3.0, 2.0, 0.0,
+ 4.0, 1.0, 0.0,
+ 2.0, 0.0, 0.0,
+ 0.0, 1.0, 0.0,
+ 1.0, 2.0, 0.0,
+ 5.0, 3.0, 2.0,
+ 7.0, 2.0, 2.0,
+ 6.0, 0.0, 2.0,
+ 6.0, 3.0, 0.0,
+ 7.0, 2.0, 0.0,
+ 6.0, 0.0, -1.0,
+ 5.0, 1.0, -3.0};
+
+ const int REFnodalConnOfFaces[74] = {
+ 1, 2, 3, 4, 5, 6, // Polyhedron 1
+ 1, 7, 8, 2,
+ 2, 8, 9, 3,
+ 4, 3, 9, 10,
+ 5, 4, 10, 11,
+ 6, 5, 11, 12,
+ 1, 6, 12, 7,
+ 7, 12, 8,
+ 10, 9, 8, 12, 11,
+
+ 13, 14, 15, 3, 2, // Polyhedron 2
+ 13, 2, 8, 16,
+ 14, 13, 16, 17,
+ 15, 14, 17,
+ 15, 17, 18,
+ 15, 18, 9,
+ 3, 15, 9,
+ 2, 3, 9, 8,
+ 8, 9, 17, 16,
+ 9, 18, 17};
+
+ const int REFfacesIndex[20] = {
+ 1, 7, 11, 15, 19, 23, 27, 31, 34,
+ 39, 44, 48, 52, 55, 58, 61, 64, 68, 72, 75};
+
+ const int REFpolyIndex[3] = {1, 10, 20};
+
+ double PolygonCoordinates[27] = {
+ 2.0, 3.0, 12.0,
+ 3.0, 2.0, 12.0,
+ 4.0, 1.0, 12.0,
+ 2.0, 0.0, 12.0,
+ 0.0, 1.0, 12.0,
+ 1.0, 2.0, 12.0,
+ 5.0, 3.0, 12.0,
+ 7.0, 2.0, 12.0,
+ 6.0, 0.0, 12.0};
+
+ const int REFpolygonFaces[11] = {
+ 1, 2, 3, 4, 5, 6, // Polygon 1
+ 7, 8, 9, 3, 2}; // Polygon 2
+
+ const int REFpolygonIndex[3] = {1, 7, 12};
+
+ MESHING myMeshing;
+ myMeshing.setName("meshing");
+
+ int NumberOfNodes = 19;
+ int SpaceDimension = 3;
+ int MeshDimension = 3;
+
+ const int NumberOfTypes = 1;
+ medGeometryElement Types[NumberOfTypes] = {MED_TETRA4};
+ const int NumberOfElements[NumberOfTypes] = {1};
+
+ myMeshing.setNumberOfTypes(NumberOfTypes, MED_CELL);
+
+ myMeshing.setCoordinates(SpaceDimension, NumberOfNodes, Coordinates,
+ "CARTESIAN", MED_FULL_INTERLACE);
+ myMeshing.setSpaceDimension(SpaceDimension);
+ myMeshing.setMeshDimension(MeshDimension);
+ myMeshing.setTypes(Types, MED_CELL);
+ myMeshing.setNumberOfElements(NumberOfElements, MED_CELL);
+
+ string Names[3] = {"X","Y","Z"};
+ myMeshing.setCoordinatesNames(Names);
+
+ string Units[3] = {"cm","cm","cm"};
+ myMeshing.setCoordinatesUnits(Units);
+
+ const int sizeTetra = 4*1 ;
+ int ConnectivityTetra[sizeTetra]=
+ {
+ 17, 9, 18, 19
+ };
+
+ myMeshing.setConnectivity(ConnectivityTetra, MED_CELL, MED_TETRA4);
+
+ myMeshing.setPolyhedraConnectivity(REFpolyIndex, REFfacesIndex,
+ REFnodalConnOfFaces, 2, MED_CELL);
+
+
+ MESHING myPolygonMeshing;
+ myPolygonMeshing.setName("PolygonMeshing");
+
+ NumberOfNodes = 9;
+ SpaceDimension = 3;
+ MeshDimension = 2;
+ medGeometryElement PolygonTypes[NumberOfTypes] = {MED_TRIA3};
+ const int PolygonNumberOfElements[NumberOfTypes] = {2};
+
+ myPolygonMeshing.setNumberOfTypes(NumberOfTypes, MED_CELL);
+
+ myPolygonMeshing.setCoordinates(SpaceDimension, NumberOfNodes, PolygonCoordinates,
+ "CARTESIAN", MED_FULL_INTERLACE);
+ myPolygonMeshing.setSpaceDimension(SpaceDimension);
+ myPolygonMeshing.setMeshDimension(MeshDimension);
+ myPolygonMeshing.setTypes(PolygonTypes, MED_CELL);
+ myPolygonMeshing.setNumberOfElements(PolygonNumberOfElements, MED_CELL);
+
+ myPolygonMeshing.setCoordinatesNames(Names);
+ myPolygonMeshing.setCoordinatesUnits(Units);
+
+ const int sizeTri = 3*2 ;
+ int ConnectivityTri[sizeTri]=
+ {
+ 1, 7, 2, 3, 9, 4
+ };
+
+ myPolygonMeshing.setConnectivity(ConnectivityTri, MED_CELL, MED_TRIA3);
+ myPolygonMeshing.setPolygonsConnectivity(REFpolygonIndex, REFpolygonFaces, 2, MED_CELL);
+ SUPPORT *sup2 = new SUPPORT(&myPolygonMeshing);
+ FIELD<double> *areas = myPolygonMeshing.getArea(sup2);
+ const double *vals2 = areas->getValue(MED_FULL_INTERLACE);
+ const double REFAreaOfPolyg[4] ={1.5, 2, 6, 6.5};
+ int nbPts=0;
+ int i;
+ for(i=0;i<4;i++)
+ if(fabs(REFAreaOfPolyg[i]-vals2[i])<1e-12)
+ nbPts++;
+ delete sup2;
+ delete areas;
+
+ SUPPORT *sup = new SUPPORT(&myMeshing);
+ FIELD<double> *vols = myMeshing.getVolume(sup);
+ const double *vals = vols->getValue(MED_FULL_INTERLACE);
+ const double REFVolOfPolyHedron[3] = {2.333333333333333, 11.66666666666666, 13.83224131414673};
+ for(i=0;i<3;i++)
+ if(fabs(REFVolOfPolyHedron[i]-vals[i])<1e-12)
+ nbPts++;
+
+ delete vols;
+ delete sup;
+ if(nbPts==7)
+ {
+ cout << "ALL TESTS OK !!!" << endl;
+ return 0;
+ }
+ else
+ {
+ cout << "TEST FAILS !!!" << endl;
+ return -1;
+ }
+
+}
--- /dev/null
+#include "MEDMEM_Meshing.hxx"
+
+using namespace std;
+using namespace MEDMEM;
+using namespace MED_EN;
+
+int main (int argc, char ** argv)
+{
+ // Traitement arguments
+ if (argc != 2)
+ {
+ cerr << "Usage : " << argv[0]
+ << " medfilename" << endl << endl
+ << "-> cré un maillage et le sauve dans le fichier medfilename." << endl;
+ exit(-1);
+ }
+ string medfilename = argv[1];
+
+ // Creation maillage
+ //***********************************************************************************
+
+ MESHING myMeshing;
+ myMeshing.setName("myMeshing");
+
+ // define coordinates
+
+ int SpaceDimension = 2;
+ int MeshDimension = SpaceDimension ;
+ int NumberOfNodes = 11;
+ double Coordinates[2*11] = {
+ 0.0, 0.0,
+ 0.5, 0.0,
+ 1.0, 0.0,
+ 0.25, 0.5,
+ 0.5, 0.5,
+ 0.75, 0.5,
+ 0.0, 1.0,
+ 0.5, 1.0,
+ 1.0, 1.0,
+ 1.5, 0.0,
+ 1.5, 1.0,
+ };
+
+ myMeshing.setMeshDimension(MeshDimension) ;
+
+ myMeshing.setCoordinates(SpaceDimension,NumberOfNodes,Coordinates,"CARTESIAN",MED_FULL_INTERLACE);
+
+ string Names[3] = { "X","Y","Z" };
+ myMeshing.setCoordinatesNames(Names);
+
+ string Units[3] = { "cm","cm","cm" };
+ myMeshing.setCoordinatesUnits(Units);
+
+ // define conectivities
+
+ // cell part
+
+ const int NumberOfTypes = 3;
+ medGeometryElement Types[NumberOfTypes] = {MED_TRIA3,MED_QUAD4,MED_POLYGON};
+ const int NumberOfElements[NumberOfTypes] = {1,4,1};
+
+ myMeshing.setNumberOfTypes(NumberOfTypes,MED_CELL);
+ myMeshing.setTypes(Types,MED_CELL);
+
+ int ConnectivityTria[1*3]=
+ {
+ 7,4,1
+ };
+
+
+ int ConnectivityQuad[4*4]=
+ {
+ 4,5,2,1,
+ 5,6,3,2,
+ 7,8,5,4,
+ 8,9,6,5
+ };
+
+ int ConnectivityPolygon[1*5]=
+ {
+ 9,11,10,3,6
+ };
+ int ConnectivityPolygonIndex[2]=
+ {
+ 1,6
+ };
+
+ myMeshing.setNumberOfElements(NumberOfElements,MED_CELL,ConnectivityPolygonIndex,1);
+ myMeshing.setConnectivity(ConnectivityTria,MED_CELL,MED_TRIA3);
+ myMeshing.setConnectivity(ConnectivityQuad,MED_CELL,MED_QUAD4);
+ myMeshing.setConnectivity(ConnectivityPolygon,MED_CELL,MED_POLYGON,ConnectivityPolygonIndex,1);
+
+ /*
+ // face part
+
+ const int NumberOfFacesTypes = 2 ;
+ medGeometryElement FacesTypes[NumberOfFacesTypes] = {MED_TRIA3,MED_QUAD4} ;
+ const int NumberOfFacesElements[NumberOfFacesTypes] = {4,4} ;
+
+ myMeshing.setNumberOfTypes(NumberOfFacesTypes,MED_FACE);
+ myMeshing.setTypes(FacesTypes,MED_FACE);
+ myMeshing.setNumberOfElements(NumberOfFacesElements,MED_FACE);
+
+ const int sizeTria = 3*4 ;
+ int ConnectivityTria[sizeTria]=
+ {
+ 1,4,3,
+ 1,5,4,
+ 1,6,5,
+ 1,3,6
+ };
+
+ myMeshing.setConnectivity(ConnectivityTria,MED_FACE,MED_TRIA3);
+
+ int ConnectivityQua[4*4]=
+ {
+ 7,8,9,10,
+ 11,12,13,14,
+ 11,7,8,12,
+ 12,8,9,13
+ };
+
+ myMeshing.setConnectivity(ConnectivityQua,MED_FACE,MED_QUAD4);
+ */
+
+ /*
+ // edge part
+
+ // not yet implemented : if set, results are unpredictable.
+ */
+
+
+ // Ecriture fichier
+
+ int idMed = myMeshing.addDriver(MED_DRIVER,medfilename,myMeshing.getName());
+ myMeshing.write(idMed) ;
+
+ // int idVtk = myMeshing.addDriver(VTK_DRIVER,"toto.vtk",myMeshing.getName());
+ // myMeshing.write(idVtk) ;
+
+ //************************************************************************************
+
+ // impression de controle
+ cout << endl;
+ cout << "Impression de MESHING : " << endl;
+ cout << myMeshing;
+
+}
#include "MEDMEM_ModulusArray.hxx"
+#ifdef _DEBUG_
+#include "LocalTraceCollector.hxx"
+#endif /* ifdef _DEBUG_*/
+
using namespace std;
using namespace MEDMEM;
int main (int argc, char ** argv) {
+#ifdef _DEBUG_
+ LocalTraceCollector::instance();
+#endif /* ifdef _DEBUG_*/
using namespace std ;
--- /dev/null
+// This program test the implementation of the class CONNECTIVITY for Polygons and Polyhedron. //
+
+#include "MEDMEM_Connectivity.hxx"
+
+#ifdef _DEBUG_
+#include "LocalTraceCollector.hxx"
+#endif /* ifdef _DEBUG_*/
+
+using namespace std;
+using namespace MEDMEM;
+using namespace MED_EN;
+
+int main(void)
+{
+#ifdef _DEBUG_
+ LocalTraceCollector::instance();
+#endif /* ifdef _DEBUG_*/
+
+ CONNECTIVITY myNodalConnectivity;
+ CONNECTIVITY myDescendingConnectivity;
+
+ //POLYGONS
+ const med_int NumberOfPolygons = 2;
+ const med_int ConnectivitySize = 12;
+ med_int PolygonsConnectivityIndex[NumberOfPolygons+1] = {1,7,13};
+
+ //Nodal
+ med_int PolygonsNodalConnectivity[ConnectivitySize] = {1,2,3,4,5,10,10,5,6,7,8,9};
+
+ myNodalConnectivity.setPolygonsConnectivity(MED_NODAL,MED_CELL,PolygonsNodalConnectivity,PolygonsConnectivityIndex,ConnectivitySize,NumberOfPolygons);
+
+ //Descending
+ med_int PolygonsDescendingConnectivity[ConnectivitySize] = {1,2,3,4,11,10,11,5,6,7,8,9};
+
+ myDescendingConnectivity.setPolygonsConnectivity(MED_DESCENDING,MED_CELL,PolygonsDescendingConnectivity,PolygonsConnectivityIndex,ConnectivitySize,NumberOfPolygons);
+
+ //POLYHEDRON
+ const med_int NumberOfPolyhedron = 2;
+ med_int PolyhedronIndex[NumberOfPolyhedron+1] = {1,10,20};
+
+ //Nodal
+ const med_int NumberOfFaces = 19;
+ const med_int NumberOfNodes = 74;
+ med_int PolyhedronFacesIndex[NumberOfFaces+1] = {1,7,11,15,19,23,27,31,34,39,44,48,52,55,58,61,64,68,72,75};
+ med_int PolyhedronNodalConnectivity[NumberOfNodes] = {1,2,3,4,5,6,1,7,8,2,2,8,9,3,4,3,9,10,5,4,10,11,6,5,11,12,1,6,12,7,7,12,8,10,9,8,12,11,13,14,15,3,2,13,2,8,16,14,13,16,17,15,14,17,15,17,18,15,18,9,3,15,9,2,3,9,8,8,9,17,16,9,18,17};
+
+ myNodalConnectivity.setPolyhedronConnectivity(MED_NODAL,PolyhedronNodalConnectivity,PolyhedronIndex,NumberOfNodes,NumberOfPolyhedron,PolyhedronFacesIndex,NumberOfFaces);
+
+ //Descending
+ const med_int DescendingConnectivitySize = 19;
+ med_int PolyhedronDescendingConnectivity[DescendingConnectivitySize] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,3,17,18};
+
+ myDescendingConnectivity.setPolyhedronConnectivity(MED_DESCENDING,PolyhedronDescendingConnectivity,PolyhedronIndex,DescendingConnectivitySize,NumberOfPolyhedron);
+
+ cout << myNodalConnectivity;
+ cout << myDescendingConnectivity;
+
+ return 0;
+}
--- /dev/null
+// This program test the implementation of the class MED_MESH_RDONLY_DRIVER for Polygons and Polyhedron. //
+
+#include "MEDMEM_define.hxx"
+#include "MEDMEM_Mesh.hxx"
+#include "MEDMEM_MedMeshDriver.hxx"
+
+#ifdef _DEBUG_
+#include "LocalTraceCollector.hxx"
+#endif /* ifdef _DEBUG_*/
+
+using namespace std;
+using namespace MEDMEM;
+
+
+int main (int argc, char ** argv)
+{
+ if (argc <3) // after 3, ignored !
+ {
+ cerr << "Usage : " << argv[0]
+ << " filename meshname" << endl << endl;
+ exit(-1);
+ }
+
+#ifdef _DEBUG_
+ LocalTraceCollector::instance();
+#endif /* ifdef _DEBUG_*/
+
+ string filename = argv[1];
+ string meshname = argv[2];
+
+ MESH * myMesh = new MESH();
+ myMesh->setName(meshname);
+ MED_MESH_RDONLY_DRIVER myMeshReadDriver(filename,myMesh);
+ myMeshReadDriver.setMeshName(meshname);
+ myMeshReadDriver.open();
+ myMeshReadDriver.read();
+ myMeshReadDriver.close();
+
+ cout << * myMesh << endl;
+
+ delete myMesh;
+ return 0;
+}
--- /dev/null
+// This program test the implementation of the class MED_MESH_WRONLY_DRIVER for Polygons and Polyhedron. //
+
+#include "MEDMEM_define.hxx"
+#include "MEDMEM_Mesh.hxx"
+#include "MEDMEM_MedMeshDriver.hxx"
+
+#ifdef _DEBUG_
+#include "LocalTraceCollector.hxx"
+#endif /* ifdef _DEBUG_*/
+
+using namespace std;
+using namespace MEDMEM;
+
+
+int main (int argc, char ** argv)
+{
+ if (argc <3) // after 3, ignored !
+ {
+ cerr << "Usage : " << argv[0]
+ << " filename meshname" << endl << endl;
+ exit(-1);
+ }
+
+#ifdef _DEBUG_
+ LocalTraceCollector::instance();
+#endif /* ifdef _DEBUG_*/
+
+ string filename = argv[1];
+ string meshname = argv[2];
+
+ // Lecture d'un fichier MED
+ MESH * myMesh = new MESH();
+ myMesh->setName(meshname);
+ MED_MESH_RDONLY_DRIVER myMeshReadDriver(filename,myMesh);
+ myMeshReadDriver.setMeshName(meshname);
+ myMeshReadDriver.open();
+ myMeshReadDriver.read();
+ myMeshReadDriver.close();
+
+ // Ecriture dans un fichier MED
+ string filename2 = filename + "_copy";
+ MED_MESH_WRONLY_DRIVER myMeshWriteDriver(filename2,myMesh);
+ myMeshWriteDriver.setMeshName(meshname);
+ myMeshWriteDriver.open();
+ myMeshWriteDriver.write();
+ myMeshWriteDriver.close();
+
+
+ delete myMesh;
+ return 0;
+}
--- /dev/null
+// This program test the implementation of the POLYHEDRONARRAY class. //
+
+#include "MEDMEM_PolyhedronArray.hxx"
+
+#ifdef _DEBUG_
+#include "LocalTraceCollector.hxx"
+#endif /* ifdef _DEBUG_*/
+
+using namespace std;
+using namespace MEDMEM;
+using namespace MED_EN;
+
+int main(void)
+{
+#ifdef _DEBUG_
+ LocalTraceCollector::instance();
+#endif /* ifdef _DEBUG_*/
+
+ POLYHEDRONARRAY myPArray(2,11,40);
+ med_int polyhedronindex[2] = {1,7};
+ med_int facesindex[11] = {1,5,9,13,17,21,25,28,31,34,37};
+ med_int nodes[40] = {1,2,6,5,2,3,7,6,4,3,7,8,1,4,8,5,1,2,3,4,5,6,7,8,5,6,9,6,7,9,7,8,9,8,5,9,5,6,7,8};
+
+ myPArray.setPolyhedronIndex(polyhedronindex);
+ myPArray.setFacesIndex(facesindex);
+ myPArray.setNodes(nodes);
+
+ POLYHEDRONARRAY myPArray2(myPArray);
+
+ const med_int* __polyhedronindex = myPArray2.getPolyhedronIndex();
+ const med_int* __facesindex = myPArray2.getFacesIndex();
+ const med_int* __nodes = myPArray2.getNodes();
+
+ cout << "__polyhedronindex =" << endl;
+ for (int i=0; i<2; i++)
+ cout << __polyhedronindex[i] << endl;
+ cout << "__facesindex =" << endl;
+ for (int i=0; i<11; i++)
+ cout << __facesindex[i] << endl;
+ cout << "__nodes =" << endl;
+ for (int i=0; i<40; i++)
+ cout << __nodes[i] << endl;
+
+ return 0;
+}
#include "utilities.h"
#include "MEDMEM_SkyLineArray.hxx"
+#ifdef _DEBUG_
+#include "LocalTraceCollector.hxx"
+#endif /* ifdef _DEBUG_*/
+
using namespace std;
using namespace MEDMEM;
int main (int argc, char ** argv) {
+#ifdef _DEBUG_
+ LocalTraceCollector::instance();
+#endif /* ifdef _DEBUG_*/
int NumberOfCell = 3 ; // 1 triangle,1 quadrangle,1 triangle
int Size = 10 ; // 10 nodes
--- /dev/null
+// This program test the implementation of the class MED_MESH_RDONLY_DRIVER for Polygons and Polyhedron. //
+
+#include "MEDMEM_define.hxx"
+#include "MEDMEM_Mesh.hxx"
+#include "MEDMEM_Support.hxx"
+#include "MEDMEM_Family.hxx"
+#include "MEDMEM_Field.hxx"
+#include "MEDMEM_ModulusArray.hxx"
+#include "MEDMEM_MedMeshDriver.hxx"
+#include "LocalTraceCollector.hxx"
+#include <vector>
+
+#define MESHNAME "poly3D"
+
+using namespace std;
+using namespace MEDMEM;
+using namespace MED_EN;
+
+#define DIM_OF_FIELD 3
+
+
+class SupportTester {
+private:
+ const int *_tabOfNodes;
+ vector<int> _eltsActiveYet;
+ vector<int> _lgthOfEltsActiveYet;
+public:
+ SupportTester(const int *tabOfNodes, int nbOfElts, int nbOfNodesPerElt);
+ SupportTester(const int *tabOfNodes, int nbOfElts, const int *nbOfNodesPerElt);
+ bool isIncludedAndNotAlreadyConsumed(const int *tabOfNodesOfTheElementToTest);
+ bool areAllEltsConsumed();
+private:
+ static bool areEquivalent(const int *nodes1, const int *nodes2, int nbOfNodes);
+};
+
+SupportTester::SupportTester(const int *tabOfNodes, int nbOfElts, int nbOfNodesPerElt):_tabOfNodes(tabOfNodes)
+{
+ for(int i=0;i<nbOfElts;i++)
+ {
+ _eltsActiveYet.push_back(i*nbOfNodesPerElt);
+ _lgthOfEltsActiveYet.push_back(nbOfNodesPerElt);
+ }
+}
+
+SupportTester::SupportTester(const int *tabOfNodes, int nbOfElts, const int *nbOfNodesPerElt):_tabOfNodes(tabOfNodes)
+{
+ int offset=0;
+ for(int i=0;i<nbOfElts;i++)
+ {
+ _eltsActiveYet.push_back(offset);
+ _lgthOfEltsActiveYet.push_back(nbOfNodesPerElt[i]);
+ }
+}
+
+bool SupportTester::isIncludedAndNotAlreadyConsumed(const int *tabOfNodesOfTheElementToTest)
+{
+ vector<int>::iterator iter2=_lgthOfEltsActiveYet.begin();
+ for(vector<int>::iterator iter=_eltsActiveYet.begin();iter!=_eltsActiveYet.end();iter++)
+ if(areEquivalent(_tabOfNodes+(*iter),tabOfNodesOfTheElementToTest,*iter2))
+ {
+ _eltsActiveYet.erase(iter);
+ _lgthOfEltsActiveYet.erase(iter2);
+ return true;
+ }
+ else
+ {
+ iter2++;
+ }
+ return false;
+}
+
+bool SupportTester::areAllEltsConsumed()
+{
+ return _eltsActiveYet.size()==0;
+}
+
+bool SupportTester::areEquivalent(const int *nodes1, const int *nodes2, int nbOfNodes)
+{
+ MEDMODULUSARRAY arr1(nbOfNodes,nodes1);
+ MEDMODULUSARRAY arr2(nbOfNodes,nodes2);
+ return arr1.compare(arr2)!=0;
+}
+
+int main (int argc, char ** argv)
+{
+ LocalTraceCollector::instance();
+ if (argc<2) // after 2, ignored !
+ {
+ cerr << "Usage : " << argv[0] << " poly3D.med typically in ../../share/salome/resources" << endl << endl;
+ exit(-1);
+ }
+ int nbOfPtsForTest=0;
+ int i;
+ string filename = argv[1];
+ MESH * myMesh = new MESH;
+ myMesh->setName(MESHNAME);
+ MED_MESH_RDONLY_DRIVER myMeshReadDriver(filename,myMesh);
+ myMeshReadDriver.setMeshName(MESHNAME);
+ myMeshReadDriver.open();
+ myMeshReadDriver.read();
+ myMeshReadDriver.close();
+ //Test 1 : test if connectivity of poly3D mesh is OK
+ if(myMesh->getMeshDimension()==3 && myMesh->getSpaceDimension()==3)
+ nbOfPtsForTest++;
+ if(myMesh->getNumberOfElementsWithPoly(MED_EN::MED_CELL,MED_EN::MED_TETRA4)==1 && myMesh->getNumberOfElementsWithPoly(MED_EN::MED_CELL,MED_EN::MED_POLYHEDRA)==2)
+ nbOfPtsForTest++;
+ const int REFnodalConnForTetra[4]={17, 9, 18, 19};
+ const int *connForTetraToTest=myMesh->getConnectivity(MED_FULL_INTERLACE,MED_NODAL,MED_CELL,MED_TETRA4);
+ const int *connIndForTetraToTest=myMesh->getConnectivityIndex(MED_NODAL,MED_CELL);
+ for(i=connIndForTetraToTest[0]-1;i<connIndForTetraToTest[1]-1;i++)
+ if(connForTetraToTest[i]==REFnodalConnForTetra[i])
+ nbOfPtsForTest++;
+ //6
+ const int *globIndex=myMesh->getPolyhedronIndex(MED_NODAL);
+ const int *nodalConnOfFaces=myMesh->getPolyhedronConnectivity(MED_NODAL);
+ const int *facesIndex=myMesh->getPolyhedronFacesIndex();
+ if(globIndex[1]-globIndex[0]==9 && globIndex[2]-globIndex[1]==10)// resp 9 faces and 10 faces are in polyh 1 and 2.
+ nbOfPtsForTest++;
+ //7
+ const int REFfacesIndex[20]={1, 7, 11, 15, 19, 23, 27, 31, 34, 39, 44, 48, 52, 55, 58, 61, 64, 68, 72, 75};
+ const int REFnodalConnOfFaces[74]={1, 2, 3, 4, 5, 6, // Polyhedron 1
+ 1, 7, 8, 2,
+ 2, 8, 9, 3,
+ 4, 3, 9, 10,
+ 5, 4, 10, 11,
+ 6, 5, 11, 12,
+ 1, 6, 12, 7,
+ 7, 12, 8, 10,
+ 9, 8, 12, 11,
+
+ 13, 14, 15, 3, 2, // Polyhedron 2
+ 13, 2, 8, 16,
+ 14, 13, 16, 17,
+ 15, 14, 17, 15,
+ 17, 18, 15,
+ 18, 9, 3,
+ 15, 9, 2,
+ 3, 9, 8,
+ 8, 9, 17, 16,
+ 9, 18, 17 };
+ for(i=0;i<20;i++)
+ if(REFfacesIndex[i]==facesIndex[i])
+ nbOfPtsForTest++;
+ for(i=0;i<74;i++)
+ if(REFnodalConnOfFaces[i]==nodalConnOfFaces[i])
+ nbOfPtsForTest++;
+ if(nbOfPtsForTest!=101)
+ {
+ cout << "TEST1 K0 ! : Invalid Globaldata in memory..." << endl;
+ return 1;
+ }
+ // TEST 2 : FAMILY
+ nbOfPtsForTest=0;
+ vector<FAMILY*> families=myMesh->getFamilies(MED_FACE);
+ if(families.size()==3)
+ nbOfPtsForTest++;
+ vector<FAMILY *>::iterator iter=families.begin();
+ FAMILY *fam1=*(iter++);
+ FAMILY *fam2=*(iter++);
+ FAMILY *fam3=*(iter);
+ const int *nbs;
+ // family 1
+ if(fam1->getNumberOfTypes()==1 && fam1->getTypes()[0]==MED_POLYGON && fam1->getNumberOfElements(MED_ALL_ELEMENTS)==3)
+ nbOfPtsForTest++;
+ nbs=fam1->getNumber(MED_ALL_ELEMENTS);
+ const int REFTabForPolyg[16]={1, 2, 3, 4, 5, 6, 10, 9, 8, 12, 11, 13, 14, 15, 3, 2};
+ const int REFTabForPolygLgth[3]={6,5,5};
+ SupportTester test1(REFTabForPolyg,3,REFTabForPolygLgth);
+ for(i=0;i<3;i++)
+ {
+ int lgth;
+ const int *conn=((CONNECTIVITY *)myMesh->getConnectivityptr())->getConnectivityOfAnElementWithPoly(MED_NODAL,MED_FACE,nbs[i],lgth);
+ if(test1.isIncludedAndNotAlreadyConsumed(conn))
+ nbOfPtsForTest++;
+ }
+ if(test1.areAllEltsConsumed())
+ nbOfPtsForTest++;
+ // family 2
+ if(fam2->getNumberOfElements(MED_ALL_ELEMENTS)==8)
+ nbOfPtsForTest++;
+ nbs=fam2->getNumber(MED_ALL_ELEMENTS);
+ const int REFTabForQuad[32]={1, 7, 8, 2, 2, 8, 9, 3, 4, 3, 9, 10, 5, 4, 10, 11, 6, 5, 11, 12, 1, 6, 12, 7, 14, 13, 16, 17, 8, 9, 17, 16};
+ SupportTester test2(REFTabForQuad,8,4);
+ for(i=0;i<8;i++)
+ {
+ int lgth;
+ const int *conn=((CONNECTIVITY *)myMesh->getConnectivityptr())->getConnectivityOfAnElementWithPoly(MED_NODAL,MED_FACE,nbs[i],lgth);
+ if(test2.isIncludedAndNotAlreadyConsumed(conn))
+ nbOfPtsForTest++;
+ }
+ if(test2.areAllEltsConsumed())
+ nbOfPtsForTest++;
+ // family 3
+ if(fam3->getNumberOfElements(MED_ALL_ELEMENTS)==6)
+ nbOfPtsForTest++;
+ nbs=fam3->getNumber(MED_ALL_ELEMENTS);
+ const int REFTabForTria[18]={7, 12, 8, 15, 14, 17, 15, 17, 18, 15, 18, 9, 3, 15, 9, 18, 17, 9};
+ SupportTester test3(REFTabForTria,6,3);
+ for(i=0;i<6;i++)
+ {
+ int lgth;
+ const int *conn=((CONNECTIVITY *)myMesh->getConnectivityptr())->getConnectivityOfAnElementWithPoly(MED_NODAL,MED_FACE,nbs[i],lgth);
+ if(test3.isIncludedAndNotAlreadyConsumed(conn))
+ nbOfPtsForTest++;
+ }
+ if(test3.areAllEltsConsumed())
+ nbOfPtsForTest++;
+ if(nbOfPtsForTest!=21)
+ {
+ cout << "TEST2 K0 ! : Invalid data in memory for families !!!" << endl;
+ return 1;
+ }
+ // TEST 3 : volumes, aeras, barycenter
+ nbOfPtsForTest=0;
+ SUPPORT *supOnCell=new SUPPORT(myMesh);
+ FIELD<double>* vol1=myMesh->getVolume(supOnCell);
+ int lgth=vol1->getValueLength(MED_FULL_INTERLACE);
+ const double *vals=vol1->getValue(MED_FULL_INTERLACE);
+ if(lgth==3)
+ nbOfPtsForTest++;
+ const double REFVolOfPolyHedron[3]={2.333333333333333,11.66666666666666,13.83224131414673};
+ for(i=0;i<3;i++)
+ if(fabs(REFVolOfPolyHedron[i]-vals[i])<1e-12)
+ nbOfPtsForTest++;
+ delete vol1;
+ FIELD<double>* bary=myMesh->getBarycenter(supOnCell);
+ lgth=bary->getValueLength(MED_FULL_INTERLACE);
+ vals=bary->getValue(MED_FULL_INTERLACE);
+ if(lgth==9)
+ nbOfPtsForTest++;
+ const double REFBaryOfPolyHedron[9]= {5.5, 1, -1, 2, 1.5, 1.0833333333333333, 5.1, 1.6, 0.9};
+ for(i=0;i<9;i++)
+ if(fabs(REFBaryOfPolyHedron[i]-vals[i])<1e-12)
+ nbOfPtsForTest++;
+ delete bary;
+ delete supOnCell;
+ //area
+ vol1=myMesh->getArea(fam1);
+ lgth=vol1->getValueLength(MED_FULL_INTERLACE);
+ vals=vol1->getValue(MED_FULL_INTERLACE);
+ if(lgth==3)
+ nbOfPtsForTest++;
+ const double REFAreaForPolyg[3]={6,5,6.5};
+ for(i=0;i<3;i++)
+ if(fabs(REFAreaForPolyg[i]-vals[i])<1e-12)
+ nbOfPtsForTest++;
+
+ vol1=myMesh->getArea(fam2);
+ lgth=vol1->getValueLength(MED_FULL_INTERLACE);
+ vals=vol1->getValue(MED_FULL_INTERLACE);
+ if(lgth==8)
+ nbOfPtsForTest++;
+ const double REFAreaForQuad[8]={2.1213203435596424, 2.8284271247461903, 4.4721359549995796, 4.4721359549995796,
+ 2.8284271247461903, 2.1213203435596428, 3.6798724963767362, 4};
+ for(i=0;i<8;i++)
+ if(fabs(REFAreaForQuad[i]-vals[i])<1e-12)
+ nbOfPtsForTest++;
+ delete vol1;
+
+ vol1=myMesh->getArea(fam3);
+ lgth=vol1->getValueLength(MED_FULL_INTERLACE);
+ vals=vol1->getValue(MED_FULL_INTERLACE);
+ if(lgth==6)
+ nbOfPtsForTest++;
+ const double REFAreaForTri[6]={2.9580398915498081, 1.4142135623730951, 2.2360679774997898,
+ 3.3541019662496847, 3.3541019662496847, 2.2360679774997898};
+ for(i=0;i<6;i++)
+ if(fabs(REFAreaForTri[i]-vals[i])<1e-12)
+ nbOfPtsForTest++;
+ delete vol1;
+ if(nbOfPtsForTest!=34)
+ {
+ cout << "TEST3 K0 ! : Error in caluclation of basic properties !!!" << endl;
+ return 1;
+ }
+ // TEST 4 -- CHECK FOR Reverse descending using getBoundaryElements.
+ nbOfPtsForTest=0;
+ SUPPORT *bound=myMesh->getBoundaryElements(MED_NODE);
+ if(bound->getNumberOfElements(MED_ALL_ELEMENTS)==19)
+ nbOfPtsForTest++;
+ if(bound->isOnAllElements())
+ nbOfPtsForTest++;
+ if(nbOfPtsForTest!=2)
+ {
+ cout << "TEST4 K0 ! : Error in getBoundaryElements probably due to Reverse descending !!!" << endl;
+ return 1;
+ }
+ delete bound;
+ ///////////
+ cout << "ALL TESTS OK !!!" << endl;
+ delete myMesh;
+ return 0;
+}
#include "MEDMEM_Field.hxx"
#include "MEDMEM_define.hxx"
+#ifdef _DEBUG_
+#include "LocalTraceCollector.hxx"
+#endif /* ifdef _DEBUG_*/
+
using namespace std;
using namespace MEDMEM;
using namespace MED_EN;
int main (int argc, char ** argv) {
+#ifdef _DEBUG_
+ LocalTraceCollector::instance();
+#endif /* ifdef _DEBUG_*/
/*
if ((argc !=3) && (argc != 4)) {
#include "MEDMEM_Field.hxx"
#include "MEDMEM_define.hxx"
+#ifdef _DEBUG_
+#include "LocalTraceCollector.hxx"
+#endif /* ifdef _DEBUG_*/
+
using namespace std;
using namespace MEDMEM;
using namespace MED_EN;
int main (int argc, char ** argv) {
-
if (argc <3) { // after 3, ignored !
cerr << "Usage : " << argv[0]
<< " filename meshname" << endl << endl;
exit(-1);
}
+
+#ifdef _DEBUG_
+ LocalTraceCollector::instance();
+#endif /* ifdef _DEBUG_*/
+
string filename = argv[1] ;
string meshname = argv[2] ;
#include "MEDMEM_Field.hxx"
#include "MEDMEM_define.hxx"
+#ifdef _DEBUG_
+#include "LocalTraceCollector.hxx"
+#endif /* ifdef _DEBUG_*/
+
using namespace std;
using namespace MEDMEM;
using namespace MED_EN;
int main (int argc, char ** argv) {
+#ifdef _DEBUG_
+ LocalTraceCollector::instance();
+#endif /* ifdef _DEBUG_*/
/*
if ((argc !=3) && (argc != 4)) {
#include "MEDMEM_Field.hxx"
#include "MEDMEM_define.hxx"
+#ifdef _DEBUG_
+#include "LocalTraceCollector.hxx"
+#endif /* ifdef _DEBUG_*/
+
using namespace std;
using namespace MEDMEM;
using namespace MED_EN;
}
int main (int argc, char ** argv) {
+#ifdef _DEBUG_
+ LocalTraceCollector::instance();
+#endif /* ifdef _DEBUG_*/
int read;
#include "MEDMEM_Field.hxx"
#include "MEDMEM_define.hxx"
+#ifdef _DEBUG_
+#include "LocalTraceCollector.hxx"
+#endif /* ifdef _DEBUG_*/
+
using namespace std;
using namespace MEDMEM;
using namespace MED_EN;
}
int main (int argc, char ** argv) {
+#ifdef _DEBUG_
+ LocalTraceCollector::instance();
+#endif /* ifdef _DEBUG_*/
// int read; !! UNUSED VARIABLE !!
#include "MEDMEM_Support.hxx"
#include "MEDMEM_Field.hxx"
#include "MEDMEM_define.hxx"
+
+#ifdef _DEBUG_
+#include "LocalTraceCollector.hxx"
+#endif /* ifdef _DEBUG_*/
+
using namespace MEDMEM;
using namespace MED_EN;
int main (int argc, char ** argv) {
+#ifdef _DEBUG_
+ LocalTraceCollector::instance();
+#endif /* ifdef _DEBUG_*/
// int read; !! UNUSED VARIABLE !!
#include "MEDMEM_Field.hxx"
#include "MEDMEM_define.hxx"
+#ifdef _DEBUG_
+#include "LocalTraceCollector.hxx"
+#endif /* ifdef _DEBUG_*/
+
using namespace std;
using namespace MEDMEM;
using namespace MED_EN;
}
int main (int argc, char ** argv) {
+#ifdef _DEBUG_
+ LocalTraceCollector::instance();
+#endif /* ifdef _DEBUG_*/
int read;
#include "MEDMEM_Field.hxx"
#include "MEDMEM_define.hxx"
+#ifdef _DEBUG_
+#include "LocalTraceCollector.hxx"
+#endif /* ifdef _DEBUG_*/
+
using namespace std;
using namespace MEDMEM;
using namespace MED_EN;
int main (int argc, char ** argv) {
+#ifdef _DEBUG_
+ LocalTraceCollector::instance();
+#endif /* ifdef _DEBUG_*/
/*
if ((argc !=3) && (argc != 4)) {
#include "MEDMEM_Field.hxx"
#include "MEDMEM_define.hxx"
+#ifdef _DEBUG_
+#include "LocalTraceCollector.hxx"
+#endif /* ifdef _DEBUG_*/
+
using namespace std;
using namespace MEDMEM;
-
int main (int argc, char ** argv) {
+#ifdef _DEBUG_
+ LocalTraceCollector::instance();
+#endif /* ifdef _DEBUG_*/
int read;
#include "MEDMEM_Field.hxx"
#include "MEDMEM_define.hxx"
+#ifdef _DEBUG_
+#include "LocalTraceCollector.hxx"
+#endif /* ifdef _DEBUG_*/
+
using namespace std;
using namespace MEDMEM;
using namespace MED_EN;
}
int main (int argc, char ** argv) {
+#ifdef _DEBUG_
+ LocalTraceCollector::instance();
+#endif /* ifdef _DEBUG_*/
int read;
#include "MEDMEM_GibiMeshDriver.hxx"
#include "MEDMEM_Mesh.hxx"
+#ifdef _DEBUG_
+#include "LocalTraceCollector.hxx"
+#endif /* ifdef _DEBUG_*/
+
using namespace std;
using namespace MEDMEM;
int main (int argc, char ** argv)
<< "-> lit le fichier gibi filename ,crée 2 fichiers : MED et VTK" << endl;
exit(-1);
}
+
+#ifdef _DEBUG_
+ LocalTraceCollector::instance();
+#endif /* ifdef _DEBUG_*/
+
string gibifilename = argv[1];
// Construction des noms de fichier
#include "MEDMEM_Grid.hxx"
+#ifdef _DEBUG_
+#include "LocalTraceCollector.hxx"
+#endif /* ifdef _DEBUG_*/
+
using namespace MEDMEM;
using namespace MED_EN;
if (argc != 3)
usage(argv[0]);
+#ifdef _DEBUG_
+ LocalTraceCollector::instance();
+#endif /* ifdef _DEBUG_*/
+
const int SpaceDimension=atoi(argv[1]);
const int nbMaille=atoi(argv[2]);
if(SpaceDimension>3 || SpaceDimension<1 || nbMaille<1)
#include "MEDMEM_Field.hxx"
#include "MEDMEM_define.hxx"
+#ifdef _DEBUG_
+#include "LocalTraceCollector.hxx"
+#endif /* ifdef _DEBUG_*/
+
double myfunction1(double x)
{
return 0.25*(x-1.0);
<< "Use optional option -v to select verbose mode" << endl;
exit(-1);
}
+
+#ifdef _DEBUG_
+ LocalTraceCollector::instance();
+#endif /* ifdef _DEBUG_*/
+
string filename = argv[verbose+1];
string meshname = argv[verbose+2];
string fieldname = argv[verbose+3];
#include "MEDMEM_Field.hxx"
#include "MEDMEM_define.hxx"
+#ifdef _DEBUG_
+#include "LocalTraceCollector.hxx"
+#endif /* ifdef _DEBUG_*/
+
using namespace MEDMEM;
using namespace MED_EN;
<< " filename meshname fieldname" << endl << endl;
exit(-1);
}
+
+#ifdef _DEBUG_
+ LocalTraceCollector::instance();
+#endif /* ifdef _DEBUG_*/
+
string filename = argv[1] ;
string meshname = argv[2] ;
string fieldname = argv[3];
#include "MEDMEM_PorflowMeshDriver.hxx"
#include "MEDMEM_Mesh.hxx"
+#ifdef _DEBUG_
+#include "LocalTraceCollector.hxx"
+#endif /* ifdef _DEBUG_*/
+
using namespace std;
using namespace MEDMEM;
using namespace MED_EN;
<< "-> lit le fichier Porflowfilename ,crée 2 fichiers : MED et VTK" << endl;
exit(-1);
}
+
+#ifdef _DEBUG_
+ LocalTraceCollector::instance();
+#endif /* ifdef _DEBUG_*/
+
string porflowfilename = argv[1];
// Construction des noms de fichier
using namespace std;
using namespace MEDMEM;
+#define MED_TAILLE_PNOM 16
+
void usage(char * name)
{
cout << " " << name <<" <file name>"<< " <mesh name> " << " <interlace mode>" << endl;
cout << "(* INFORMATIONS GENERALES : *)" << endl;
cout << "(****************************)" << endl;
- string chainevide(MED_TAILLE_PNOM+2,' ');
+ // string chainevide(MED_TAILLE_PNOM+2,' ');
cout << "- Nom du maillage : <<" << meshName << ">>" << endl;
cout << "- Dimension d'espace : "<< SpaceDimension << endl;
cout << "- Dimension du maillage : "<< MeshDimension << endl;
using namespace MEDMEM;
using namespace MED_EN;
+#define MED_NBR_GEOMETRIE_MAILLE 15
+
void usage(char * name)
{
cout << " " << name << endl;
cout << "CELLMODEL Test" << endl ;
cout << "--------------" << endl;
-/* -----------------------------------------------------
+ /* -----------------------------------------------------
Construction de tous les types de cellmodel possibles
-----------------------------------------------------
-*/
+ */
- CELLMODEL * tous =new CELLMODEL[MED_NBR_GEOMETRIE_MAILLE ];
- const medGeometryElement allCellType[MED_NBR_GEOMETRIE_MAILLE ]=
- {MED_POINT1, MED_SEG2, MED_SEG3, MED_TRIA3,
- MED_QUAD4, MED_TRIA6, MED_QUAD8, MED_TETRA4,
- MED_PYRA5, MED_PENTA6, MED_HEXA8, MED_TETRA10,
- MED_PYRA13, MED_PENTA15, MED_HEXA20 };
+ CELLMODEL * tous =new CELLMODEL[MED_NBR_GEOMETRIE_MAILLE ];
+ const medGeometryElement allCellType[MED_NBR_GEOMETRIE_MAILLE ]=
+ {MED_POINT1, MED_SEG2, MED_SEG3, MED_TRIA3,
+ MED_QUAD4, MED_TRIA6, MED_QUAD8, MED_TETRA4,
+ MED_PYRA5, MED_PENTA6, MED_HEXA8, MED_TETRA10,
+ MED_PYRA13, MED_PENTA15, MED_HEXA20 };
for (int i=0; i<MED_NBR_GEOMETRIE_MAILLE ; i++)
- {
- tous[i]=CELLMODEL(allCellType[i]);
- }
+ {
+ tous[i]=CELLMODEL(allCellType[i]);
+ }
-/* -----------------------------------------------------
+ /* -----------------------------------------------------
Boucle sur tous les types de cellmodel possibles
- Chaque Méthode de cellmodel est appelee
-----------------------------------------------------
-*/
+ */
for (int i=0; i<MED_NBR_GEOMETRIE_MAILLE ; i++)
- {
- cout << endl;
- cout << geoNames[tous[i].getType()] << endl;
- cout << "__________________" << endl;
+ {
+ cout << endl;
+ cout << geoNames[tous[i].getType()] << endl;
+ cout << "__________________" << endl;
- try
+ try
{
- cout << "CellModel de Nom : " << tous[i].getName() << endl;
+ cout << "CellModel de Nom : " << tous[i].getName() << endl;
}
- catch ( const std::exception &e )
+ catch ( const std::exception &e )
{
- cout << "-------------------------------" << endl;
- cout << " Pb au getName() " << endl;
- cout << "-------------------------------" << endl;
- MESSAGE( "catched exception : " << e.what() ) ;
- return EXIT_FAILURE ;
+ cout << "-------------------------------" << endl;
+ cout << " Pb au getName() " << endl;
+ cout << "-------------------------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
}
- catch (...)
+ catch (...)
{
- cout << "-------------------------------" << endl;
- cout << " Pb au getName() " << endl;
- cout << "-------------------------------" << endl;
- return EXIT_FAILURE ;
+ cout << "-------------------------------" << endl;
+ cout << " Pb au getName() " << endl;
+ cout << "-------------------------------" << endl;
+ return EXIT_FAILURE ;
};
- try
+ try
{
- cout << "Nb de Vertexes : " << tous[i].getNumberOfVertexes() << endl;
+ cout << "Nb de Vertexes : " << tous[i].getNumberOfVertexes() << endl;
}
- catch ( const std::exception &e )
+ catch ( const std::exception &e )
{
- cout << "-------------------------------" << endl;
- cout << " Pb au getNumberOfVertexes() " << endl;
- cout << "-------------------------------" << endl;
- MESSAGE( "catched exception : " << e.what() ) ;
- return EXIT_FAILURE ;
+ cout << "-------------------------------" << endl;
+ cout << " Pb au getNumberOfVertexes() " << endl;
+ cout << "-------------------------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
}
- catch (...)
+ catch (...)
{
- cout << "---------------------------------------" << endl;
- cout << " Pb au getNumberOfVertexes() " << endl;
- cout << "---------------------------------------" << endl;
- return EXIT_FAILURE ;
+ cout << "---------------------------------------" << endl;
+ cout << " Pb au getNumberOfVertexes() " << endl;
+ cout << "---------------------------------------" << endl;
+ return EXIT_FAILURE ;
};
- try
+ try
{
- cout << "Nb de Noeuds : " << tous[i].getNumberOfNodes() << endl;
+ cout << "Nb de Noeuds : " << tous[i].getNumberOfNodes() << endl;
}
- catch ( const std::exception &e )
+ catch ( const std::exception &e )
{
- cout << "-------------------------------" << endl;
- cout << " Pb au getNumberOfNodes() " << endl;
- cout << "-------------------------------" << endl;
- MESSAGE( "catched exception : " << e.what() ) ;
- return EXIT_FAILURE ;
+ cout << "-------------------------------" << endl;
+ cout << " Pb au getNumberOfNodes() " << endl;
+ cout << "-------------------------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
}
- catch (...)
+ catch (...)
{
- cout << "---------------------------------" << endl;
- cout << " Pb au getNumberOfNodes() " << endl;
- cout << "---------------------------------" << endl;
- return EXIT_FAILURE ;
+ cout << "---------------------------------" << endl;
+ cout << " Pb au getNumberOfNodes() " << endl;
+ cout << "---------------------------------" << endl;
+ return EXIT_FAILURE ;
};
- int dimension;
- try
+ int dimension;
+ try
{
- dimension=tous[i].getDimension();
- cout << "Dimension : " << dimension << endl;
+ dimension=tous[i].getDimension();
+ cout << "Dimension : " << dimension << endl;
}
- catch ( const std::exception &e )
+ catch ( const std::exception &e )
{
- cout << "-------------------------------" << endl;
- cout << " Pb au getDimension() " << endl;
- cout << "-------------------------------" << endl;
- MESSAGE( "catched exception : " << e.what() ) ;
- return EXIT_FAILURE ;
+ cout << "-------------------------------" << endl;
+ cout << " Pb au getDimension() " << endl;
+ cout << "-------------------------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
}
- catch (...)
+ catch (...)
{
- cout << "-------------------------------" << endl;
- cout << " Pb au getDimension() " << endl;
- cout << "-------------------------------" << endl;
- return EXIT_FAILURE ;
+ cout << "-------------------------------" << endl;
+ cout << " Pb au getDimension() " << endl;
+ cout << "-------------------------------" << endl;
+ return EXIT_FAILURE ;
}
- for (int dim=1; dim< dimension; dim++)
+ for (int dim=1; dim< dimension; dim++)
{
- int dim2=dimension - dim;
- cout << "Nb d elements de dimension " << dim << " : ";
+ int dim2=dimension - dim;
+ cout << "Nb d elements de dimension " << dim << " : ";
- try
- {
- cout << tous[i].getNumberOfConstituents(dim)<< endl;
- }
- catch ( const std::exception &e )
- {
- cout << "------------------------------------" << endl;
- cout << " Pb au getNumberOfConstituents() " << endl;
- cout << "------------------------------------" << endl;
- MESSAGE( "catched exception : " << e.what() ) ;
- return EXIT_FAILURE ;
- }
- catch (...)
- {
- cout << "------------------------------------" << endl;
- cout << " Pb au getNumberOfConstituents() " << endl;
- cout << "------------------------------------" << endl;
- return EXIT_FAILURE ;
- };
+ try
+ {
+ cout << tous[i].getNumberOfConstituents(dim)<< endl;
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "------------------------------------" << endl;
+ cout << " Pb au getNumberOfConstituents() " << endl;
+ cout << "------------------------------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "------------------------------------" << endl;
+ cout << " Pb au getNumberOfConstituents() " << endl;
+ cout << "------------------------------------" << endl;
+ return EXIT_FAILURE ;
+ };
}
/*
}
*/
- cout << endl;
+ cout << endl;
/*
if ( dimension > 1 )
{
}
*/
- }
+ }
delete[] tous ;
return EXIT_SUCCESS ;
/*
-Reste a Tester
+ Reste a Tester
// Return number of constituents foreach type (which dimension is _dimension-1).
map <medGeometryElement,int> getNumberOfConstituentsForeachType() const;
*/
{
medModeSwitch modemed=convertIdlModeToMedMode(mode);
// ::FIELD<double> *ptrD=dynamic_cast< ::FIELD<double>* >(_fieldTptr);
-// the alternative is not safe but the previous fails using the python API
- MEDMEM::FIELD<double> *ptrD = (MEDMEM::FIELD<double> *) _fieldTptr;
+// the alternative is not safe but the dynamic_cast fails using the python API
+ MEDMEM::FIELD<double> *ptrD = static_cast<MEDMEM::FIELD<double>* >(_fieldTptr);
const double * values =ptrD->getValue(modemed);
int nbval=ptrD->getValueLength(modemed);
myseq->length(nbval);
*/
//=============================================================================
-SALOME::Sender_ptr FIELDDOUBLE_i::getSenderForValue( SALOME_MED::medModeSwitch mode )
+SALOME::SenderDouble_ptr FIELDDOUBLE_i::getSenderForValue( SALOME_MED::medModeSwitch mode )
throw (SALOME::SALOME_Exception)
{
if (_fieldTptr==NULL)
THROW_SALOME_CORBA_EXCEPTION("No associated Field", \
SALOME::INTERNAL_ERROR);
- SALOME::Sender_ptr ret;
+ SALOME::SenderDouble_ptr ret;
try
{
medModeSwitch modemed=convertIdlModeToMedMode(mode);
- ::FIELD<double> *ptrD=dynamic_cast< ::FIELD<double>* >(_fieldTptr);
+ // ::FIELD<double> *ptrD=dynamic_cast< ::FIELD<double>* >(_fieldTptr);
+ // the alternative is not safe but the dynamic_cast fails using the python API
+ MEDMEM::FIELD<double> *ptrD=static_cast< MEDMEM::FIELD<double>* >(_fieldTptr);
const double * values =ptrD->getValue(modemed);
int nbval=ptrD->getValueLength(modemed);
ret=SenderFactory::buildSender(*this,values,nbval);
SALOME_MED::double_array * getValue (SALOME_MED::medModeSwitch mode )
throw (SALOME::SALOME_Exception);
- SALOME::Sender_ptr getSenderForValue(SALOME_MED::medModeSwitch mode)
+ SALOME::SenderDouble_ptr getSenderForValue(SALOME_MED::medModeSwitch mode)
throw (SALOME::SALOME_Exception);
};
}
try
{
medModeSwitch modemed=convertIdlModeToMedMode(mode);
-// ::FIELD<int> *ptrI=dynamic_cast< ::FIELD<int>* >(_fieldTptr);
-//the alternative is not safe but the previous one fails using the python API
- MEDMEM::FIELD<int> *ptrI = (MEDMEM::FIELD<int> *) _fieldTptr;
+ // ::FIELD<int> *ptrI=dynamic_cast< ::FIELD<int>* >(_fieldTptr);
+ //the alternative is not safe but the previous one fails using the python API
+ MEDMEM::FIELD<int> *ptrI = static_cast< MEDMEM::FIELD<int>* >(_fieldTptr);
const int * values =ptrI->getValue(modemed);
int nbval=ptrI->getValueLength(modemed);
*/
//=============================================================================
-SALOME::Sender_ptr FIELDINT_i::getSenderForValue( SALOME_MED::medModeSwitch mode )
+SALOME::SenderInt_ptr FIELDINT_i::getSenderForValue( SALOME_MED::medModeSwitch mode )
throw (SALOME::SALOME_Exception)
{
if (_fieldTptr==NULL)
THROW_SALOME_CORBA_EXCEPTION("No associated Field", \
SALOME::INTERNAL_ERROR);
- SALOME::Sender_ptr ret;
+ SALOME::SenderInt_ptr ret;
try
{
medModeSwitch modemed=convertIdlModeToMedMode(mode);
- ::FIELD<int> *ptrI=dynamic_cast< ::FIELD<int>* >(_fieldTptr);
+ //::FIELD<int> *ptrI=dynamic_cast< ::FIELD<int>* >(_fieldTptr);
+ //the alternative is not safe but the previous one fails using the python API
+ MEDMEM::FIELD<int> *ptrI=static_cast< MEDMEM::FIELD<int>* >(_fieldTptr);
const int * values =ptrI->getValue(modemed);
int nbval=ptrI->getValueLength(modemed);
ret=SenderFactory::buildSender(*this,values,nbval);
FIELDINT_i(FIELDINT_i & f);
SALOME_MED::long_array * getValue (SALOME_MED::medModeSwitch mode )
throw (SALOME::SALOME_Exception);
- SALOME::Sender_ptr getSenderForValue(SALOME_MED::medModeSwitch mode)
+ SALOME::SenderInt_ptr getSenderForValue(SALOME_MED::medModeSwitch mode)
throw (SALOME::SALOME_Exception);
};
}
* CORBA: 2nd Accessor for Coordinates
*/
//=============================================================================
-SALOME::Sender_ptr MESH_i::getSenderForCoordinates(SALOME_MED::medModeSwitch typeSwitch)
+SALOME::SenderDouble_ptr MESH_i::getSenderForCoordinates(SALOME_MED::medModeSwitch typeSwitch)
throw (SALOME::SALOME_Exception)
{
if (_mesh==NULL)
THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
SALOME::INTERNAL_ERROR);
- SALOME::Sender_ptr ret;
+ SALOME::SenderDouble_ptr ret;
try
{
int spaceDimension=_mesh->getSpaceDimension();
* CORBA: 2nd Accessor for connectivities
*/
//=============================================================================
-SALOME::Sender_ptr MESH_i::getSenderForConnectivity(SALOME_MED::medModeSwitch typeSwitch,
+SALOME::SenderInt_ptr MESH_i::getSenderForConnectivity(SALOME_MED::medModeSwitch typeSwitch,
SALOME_MED::medConnectivity mode,
SALOME_MED::medEntityMesh entity,
SALOME_MED::medGeometryElement geomElement)
if (verifieParam(entity,geomElement)==false)
THROW_SALOME_CORBA_EXCEPTION("parameters don't match",\
SALOME::BAD_PARAM);
- SALOME::Sender_ptr ret;
+ SALOME::SenderInt_ptr ret;
try
{
int nbelements=_mesh->getConnectivityLength(convertIdlModeToMedMode(typeSwitch),
}
}
+//=============================================================================
+/*!
+ * CORBA : Test if this and other aggregate the same MESH using the virtual MESH::operator==
+ */
+//=============================================================================
+CORBA::Boolean MESH_i::areEquals(SALOME_MED::MESH_ptr other)
+{
+ PortableServer::ServantBase *baseServ;
+ try {
+ baseServ=_default_POA()->reference_to_servant(other);
+ }
+ catch(...){
+ baseServ=0;
+ }
+ if(baseServ)
+ {
+ baseServ->_remove_ref();
+ MESH_i *otherServ=dynamic_cast<MESH_i *>(baseServ);
+ return *_mesh==*otherServ->_mesh;
+ }
+ return false;
+}
+
//=============================================================================
/*!
* CORBA : Servant destruction
SALOME_MED::double_array* getCoordinates(SALOME_MED::medModeSwitch typeSwitch)
throw (SALOME::SALOME_Exception);
- SALOME::Sender_ptr getSenderForCoordinates(SALOME_MED::medModeSwitch typeSwitch)
+ SALOME::SenderDouble_ptr getSenderForCoordinates(SALOME_MED::medModeSwitch typeSwitch)
throw (SALOME::SALOME_Exception);
CORBA::Double getCoordinate(CORBA::Long Number, CORBA::Long Axis)
SALOME_MED::medGeometryElement geomElement)
throw (SALOME::SALOME_Exception);
- SALOME::Sender_ptr getSenderForConnectivity(SALOME_MED::medModeSwitch typeSwitch,
+ SALOME::SenderInt_ptr getSenderForConnectivity(SALOME_MED::medModeSwitch typeSwitch,
SALOME_MED::medConnectivity mode,
SALOME_MED::medEntityMesh entity,
SALOME_MED::medGeometryElement geomElement)
SALOME_MED::MESH::connectivityInfos * getConnectGlobal
(SALOME_MED::medEntityMesh entity)
throw (SALOME::SALOME_Exception);
+ CORBA::Boolean areEquals(SALOME_MED::MESH_ptr other);
void release();
};
* CORBA: 2nd get Nodes
*/
//=============================================================================
-SALOME::Sender_ptr SUPPORT_i::getSenderForNumber(SALOME_MED::medGeometryElement geomElement)
+SALOME::SenderInt_ptr SUPPORT_i::getSenderForNumber(SALOME_MED::medGeometryElement geomElement)
throw (SALOME::SALOME_Exception)
{
SCRUTE(_support);
if (_support==NULL)
THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
SALOME::INTERNAL_ERROR);
- SALOME::Sender_ptr ret;
+ SALOME::SenderInt_ptr ret;
try
{
int nbelements=_support->getNumberOfElements(convertIdlEltToMedElt(geomElement));
*/
//=============================================================================
-SALOME::Sender_ptr SUPPORT_i::getSenderForNumberIndex()
+SALOME::SenderInt_ptr SUPPORT_i::getSenderForNumberIndex()
throw (SALOME::SALOME_Exception)
{
if (_support==NULL)
THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
SALOME::INTERNAL_ERROR);
- SALOME::Sender_ptr ret;
+ SALOME::SenderInt_ptr ret;
try
{
MESSAGE ("Nombre d'elements mis de façon stupide a MED_ALL_ELEMENTS");
throw (SALOME::SALOME_Exception);
SALOME_MED::long_array* getNumber(SALOME_MED::medGeometryElement geomElement)
throw (SALOME::SALOME_Exception);
- SALOME::Sender_ptr getSenderForNumber(SALOME_MED::medGeometryElement geomElement)
+ SALOME::SenderInt_ptr getSenderForNumber(SALOME_MED::medGeometryElement geomElement)
throw (SALOME::SALOME_Exception);
SALOME_MED::long_array* getNumberIndex()
throw (SALOME::SALOME_Exception);
- SALOME::Sender_ptr getSenderForNumberIndex()
+ SALOME::SenderInt_ptr getSenderForNumberIndex()
throw (SALOME::SALOME_Exception);
CORBA::Long getNumberOfGaussPoint(SALOME_MED::medGeometryElement geomElement)
throw (SALOME::SALOME_Exception);
LIB=libMEDMEMImpl.la
LIB_SRC = MEDMEM_Med_i.cxx MEDMEM_Family_i.cxx MEDMEM_FieldDouble_i.cxx MEDMEM_FieldInt_i.cxx MEDMEM_Field_i.cxx MEDMEM_Group_i.cxx MEDMEM_Mesh_i.cxx MEDMEM_Support_i.cxx MEDMEM_convert.cxx
LIB_SERVER_IDL = MED.idl
-LIB_CLIENT_IDL= SALOME_Component.idl SALOMEDS.idl SALOMEDS_Attributes.idl SALOME_Exception.idl SALOME_Comm.idl
+LIB_CLIENT_IDL= SALOME_Component.idl SALOMEDS.idl SALOMEDS_Attributes.idl SALOME_Exception.idl SALOME_Comm.idl SALOME_GenericObj.idl
# Executables targets
BIN_SRC =
--- /dev/null
+#include "MEDMEM_SWIG_AsciiFieldDoubleDriver.hxx"
+
+using namespace std;
+using namespace MEDMEM;
+using namespace MED_EN;
+
+ASCII_FIELDDOUBLE_DRIVER::ASCII_FIELDDOUBLE_DRIVER(const string & fileName, FIELDDOUBLE * ptrField,
+ MED_EN::med_sort_direc direction, const char *priority):
+ ASCII_FIELD_DRIVER<double>(fileName,(FIELD<double> *) ptrField,direction,priority)
+{
+ BEGIN_OF("Constructor with arguments (for Python API) ASCII_FIELDDOUBLE_DRIVER");
+
+ END_OF("Constructor with arguments (for Python API) ASCII_FIELDDOUBLE_DRIVER");
+}
+
+ASCII_FIELDDOUBLE_DRIVER::~ASCII_FIELDDOUBLE_DRIVER()
+{
+ BEGIN_OF("Default Destructor (for Python API) ASCII_FIELDDOUBLE_DRIVER");
+
+ END_OF("Default Destructor (for Python API) ASCII_FIELDDOUBLE_DRIVER");
+}
--- /dev/null
+#ifndef MEDMEM_SWIG_ASCIIFIELDDOUBLEDRIVER_HXX_
+#define MEDMEM_SWIG_ASCIIDFIELDDOUBLEDRIVER_HXX_
+
+#include "MEDMEM_AsciiFieldDriver.hxx"
+#include "MEDMEM_SWIG_FieldDouble.hxx"
+
+class ASCII_FIELDDOUBLE_DRIVER : public MEDMEM::ASCII_FIELD_DRIVER<double>
+{
+public:
+
+ ASCII_FIELDDOUBLE_DRIVER(const string & fileName, FIELDDOUBLE * ptrField,
+ MED_EN::med_sort_direc direction, const char *priority);
+
+ ~ASCII_FIELDDOUBLE_DRIVER();
+};
+
+#endif
--- /dev/null
+#include "MEDMEM_SWIG_AsciiFieldIntDriver.hxx"
+
+using namespace std;
+using namespace MEDMEM;
+using namespace MED_EN;
+
+ASCII_FIELDINT_DRIVER::ASCII_FIELDINT_DRIVER(const string & fileName, FIELDINT * ptrField,
+ MED_EN::med_sort_direc direction, const char *priority):
+ ASCII_FIELD_DRIVER<int>(fileName,(FIELD<int> *) ptrField,direction,priority)
+{
+ BEGIN_OF("Constructor with arguments (for Python API) ASCII_FIELDINT_DRIVER");
+
+ END_OF("Constructor with arguments (for Python API) ASCII_FIELDINT_DRIVER");
+}
+
+ASCII_FIELDINT_DRIVER::~ASCII_FIELDINT_DRIVER()
+{
+ BEGIN_OF("Default Destructor (for Python API) ASCII_FIELDINT_DRIVER");
+
+ END_OF("Default Destructor (for Python API) ASCII_FIELDINT_DRIVER");
+}
--- /dev/null
+#ifndef MEDMEM_SWIG_ASCIIFIELDINTDRIVER_HXX_
+#define MEDMEM_SWIG_ASCIIFIELDINTDRIVER_HXX_
+
+#include "MEDMEM_AsciiFieldDriver.hxx"
+#include "MEDMEM_SWIG_FieldInt.hxx"
+
+class ASCII_FIELDINT_DRIVER : public MEDMEM::ASCII_FIELD_DRIVER<int>
+{
+public:
+
+ ASCII_FIELDINT_DRIVER(const string & fileName, FIELDINT * ptrField,
+ MED_EN::med_sort_direc direction, const char *priority);
+
+ ~ASCII_FIELDINT_DRIVER();
+};
+
+#endif
*/
//=============================================================================
MED_FIELDDOUBLE_RDONLY_DRIVER::MED_FIELDDOUBLE_RDONLY_DRIVER() :
- MED_FIELD_RDONLY_DRIVER<double>()
+ MEDMEM::MED_FIELD_RDONLY_DRIVER<double>()
{
BEGIN_OF("Default Constructor (for Python API) MED_FIELDDOUBLE_RDONLY_DRIVER");
//=============================================================================
MED_FIELDDOUBLE_RDONLY_DRIVER::MED_FIELDDOUBLE_RDONLY_DRIVER(const string & fileName,
FIELDDOUBLE * ptrField) :
- MED_FIELD_RDONLY_DRIVER<double>(fileName,(FIELD<double> *) ptrField)
+ MEDMEM::MED_FIELD_RDONLY_DRIVER<double>(fileName,(FIELD<double> *) ptrField)
{
BEGIN_OF("Constructor with arguments (for Python API) MED_FIELDDOUBLE_RDONLY_DRIVER");
*/
//=============================================================================
MED_FIELDDOUBLE_WRONLY_DRIVER::MED_FIELDDOUBLE_WRONLY_DRIVER() :
- MED_FIELD_WRONLY_DRIVER<double>()
+ MEDMEM::MED_FIELD_WRONLY_DRIVER<double>()
{
BEGIN_OF("Default Constructor (for Python API) MED_FIELDDOUBLE_WRONLY_DRIVER");
//=============================================================================
MED_FIELDDOUBLE_WRONLY_DRIVER::MED_FIELDDOUBLE_WRONLY_DRIVER(const string & fileName,
FIELDDOUBLE * ptrField) :
- MED_FIELD_WRONLY_DRIVER<double>(fileName,(FIELD<double> *) ptrField)
+ MEDMEM::MED_FIELD_WRONLY_DRIVER<double>(fileName,(FIELD<double> *) ptrField)
{
BEGIN_OF("Constructor with arguments (for Python API) MED_FIELDDOUBLE_WRONLY_DRIVER");
*/
//=============================================================================
MED_FIELDDOUBLE_RDWR_DRIVER::MED_FIELDDOUBLE_RDWR_DRIVER() :
- MED_FIELD_RDWR_DRIVER<double>()
+ MEDMEM::MED_FIELD_RDWR_DRIVER<double>()
{
BEGIN_OF("Default Constructor (for Python API) MED_FIELDDOUBLE_RDWR_DRIVER");
//=============================================================================
MED_FIELDDOUBLE_RDWR_DRIVER::MED_FIELDDOUBLE_RDWR_DRIVER(const string & fileName,
FIELDDOUBLE * ptrField) :
- MED_FIELD_RDWR_DRIVER<double>(fileName,(FIELD<double> *) ptrField)
+ MEDMEM::MED_FIELD_RDWR_DRIVER<double>(fileName,(FIELD<double> *) ptrField)
{
BEGIN_OF("Constructor with arguments (for Python API) MED_FIELDDOUBLE_RDWR_DRIVER");
#ifndef MEDMEM_SWIG_MEDFIELDDOUBLEDRIVER_HXX_
#define MEDMEM_SWIG_MEDFIELDDOUBLEDRIVER_HXX_
-#include "MEDMEM_MedFieldDriver.hxx"
#include "MEDMEM_SWIG_FieldDouble.hxx"
+#include "MEDMEM_MedFieldDriver.hxx"
+
+class FIELDDOUBLE;
class MED_FIELDDOUBLE_DRIVER : public MEDMEM::MED_FIELD_DRIVER<double>
{
*/
//=============================================================================
MED_FIELDINT_RDONLY_DRIVER::MED_FIELDINT_RDONLY_DRIVER() :
- MED_FIELD_RDONLY_DRIVER<int>()
+ MEDMEM::MED_FIELD_RDONLY_DRIVER<int>()
{
BEGIN_OF("Default Constructor (for Python API) MED_FIELDINT_RDONLY_DRIVER");
//=============================================================================
MED_FIELDINT_RDONLY_DRIVER::MED_FIELDINT_RDONLY_DRIVER(const string & fileName,
FIELDINT * ptrField) :
- MED_FIELD_RDONLY_DRIVER<int>(fileName,(FIELD<int> *) ptrField)
+ MEDMEM::MED_FIELD_RDONLY_DRIVER<int>(fileName,(FIELD<int> *) ptrField)
{
BEGIN_OF("Constructor with arguments (for Python API) MED_FIELDINT_RDONLY_DRIVER");
*/
//=============================================================================
MED_FIELDINT_WRONLY_DRIVER::MED_FIELDINT_WRONLY_DRIVER() :
- MED_FIELD_WRONLY_DRIVER<int>()
+ MEDMEM::MED_FIELD_WRONLY_DRIVER<int>()
{
BEGIN_OF("Default Constructor (for Python API) MED_FIELDINT_WRONLY_DRIVER");
//=============================================================================
MED_FIELDINT_WRONLY_DRIVER::MED_FIELDINT_WRONLY_DRIVER(const string & fileName,
FIELDINT * ptrField) :
- MED_FIELD_WRONLY_DRIVER<int>(fileName,(FIELD<int> *) ptrField)
+ MEDMEM::MED_FIELD_WRONLY_DRIVER<int>(fileName,(FIELD<int> *) ptrField)
{
BEGIN_OF("Constructor with arguments (for Python API) MED_FIELDINT_WRONLY_DRIVER");
*/
//=============================================================================
MED_FIELDINT_RDWR_DRIVER::MED_FIELDINT_RDWR_DRIVER() :
- MED_FIELD_RDWR_DRIVER<int>()
+ MEDMEM::MED_FIELD_RDWR_DRIVER<int>()
{
BEGIN_OF("Default Constructor (for Python API) MED_FIELDINT_RDWR_DRIVER");
//=============================================================================
MED_FIELDINT_RDWR_DRIVER::MED_FIELDINT_RDWR_DRIVER(const string & fileName,
FIELDINT * ptrField) :
- MED_FIELD_RDWR_DRIVER<int>(fileName,(FIELD<int> *) ptrField)
+ MEDMEM::MED_FIELD_RDWR_DRIVER<int>(fileName,(FIELD<int> *) ptrField)
{
BEGIN_OF("Constructor with arguments (for Python API) MED_FIELDINT_RDWR_DRIVER");
#ifndef MEDMEM_SWIG_MEDFIELDINTDRIVER_HXX_
#define MEDMEM_SWIG_MEDFIELDINTDRIVER_HXX_
-#include "MEDMEM_MedFieldDriver.hxx"
#include "MEDMEM_SWIG_FieldInt.hxx"
+#include "MEDMEM_MedFieldDriver.hxx"
class MED_FIELDINT_DRIVER : public MEDMEM::MED_FIELD_DRIVER<int>
{
--- /dev/null
+#ifndef MEDMEM_SWIG_TEMPLATES_HXX_
+#define MEDMEM_SWIG_TEMPLATES_HXX_
+
+#include "MEDMEM_Exception.hxx"
+
+template<class T>
+ struct Binding {
+// static T Checker(PyObject *a);
+// static T Traducer(PyObject *a);
+ };
+
+template<>
+ struct Binding<double> {
+ //const char *TypeBuild="d";
+ static int Checker(PyObject *a) { return PyFloat_Check(a); }
+ static double Traducer(PyObject *a) { return PyFloat_AsDouble(a); }
+ };
+
+template<>
+ struct Binding<int> {
+ //static const char *TypeBuild="i";
+ static int Checker(PyObject *a) { return PyInt_Check(a); }
+ static int Traducer(PyObject *a) { return (int) PyInt_AsLong(a); }
+ };
+
+template<class T>
+ class MyFunction {
+ public:
+ static PyObject *_pyFunc;
+ static int _nbOfComponent;
+ static int _spaceDim;
+ static void EvalPy2Cpp(const double *coord, T* outputValues)
+ {
+ int i=0,err;
+ PyObject * tuple=PyTuple_New(_spaceDim);
+ for(i=0;i<_spaceDim;i++)
+ {
+ err=PyTuple_SetItem(tuple,i,Py_BuildValue("d",coord[i]));
+ if (err != 0)
+ throw MEDMEM::MEDEXCEPTION("Internal Error in createFieldDoubleFromAnalytic");
+ }
+ PyObject * function_ret = PyObject_CallObject(_pyFunc,tuple);
+ err = PyList_Check(function_ret);
+ if (!err)
+ {
+ Py_DECREF(function_ret);
+ throw MEDMEM::MEDEXCEPTION("Internal Error in createFieldIntFromAnalytic : the call to the user callable fonction has failed (check its API list of integer fonct (double, double))");
+ }
+ int size=PyList_Size(function_ret);
+ if (size!=_nbOfComponent)
+ {
+ Py_DECREF(function_ret);
+ throw MEDMEM::MEDEXCEPTION("Internal Error in createFieldIntFromAnalytic : the call to the user callable fonction has failed (check its API list of integer fonct (double, double), especially the size of the returned list)");
+ }
+ for(i=0;i<_spaceDim;i++)
+ {
+ PyObject * tmp=PyList_GetItem(function_ret,i);
+ err = Binding<T>::Checker(tmp);
+ if (!err)
+ {
+ Py_DECREF(function_ret);
+ throw MEDMEM::MEDEXCEPTION("Internal Error in createFieldDoubleFromAnalytic : the call to the user callable fonction has failed (check its API list of double fonct (double, double), especially the type of the returned list)");
+ }
+ outputValues[i]=Binding<T>::Traducer(tmp);
+ }
+ }
+ };
+
+template<class T>
+PyObject *MyFunction<T>::_pyFunc=0;
+
+template<class T>
+int MyFunction<T>::_nbOfComponent=0;
+
+template<class T>
+int MyFunction<T>::_spaceDim=0;
+
+#endif
MEDMEM_SWIG_FieldDouble.hxx \
MEDMEM_SWIG_FieldInt.hxx \
MEDMEM_SWIG_MedFieldDoubleDriver.hxx \
- MEDMEM_SWIG_MedFieldIntDriver.hxx
+ MEDMEM_SWIG_MedFieldIntDriver.hxx \
+ MEDMEM_SWIG_AsciiFieldDoubleDriver.hxx \
+ MEDMEM_SWIG_AsciiFieldIntDriver.hxx \
+ MEDMEM_SWIG_Templates.hxx
# Libraries targets
LIB_SRC = MEDMEM_SWIG_FieldDouble.cxx \
MEDMEM_SWIG_FieldInt.cxx \
MEDMEM_SWIG_MedFieldDoubleDriver.cxx \
- MEDMEM_SWIG_MedFieldIntDriver.cxx
+ MEDMEM_SWIG_MedFieldIntDriver.cxx \
+ MEDMEM_SWIG_AsciiFieldDoubleDriver.cxx \
+ MEDMEM_SWIG_AsciiFieldIntDriver.cxx
+ifeq (@SWIG_VERSION@, 1.3.21)
+SWIG_DEF = libMEDMEM_Swig.i dummy.i
+
+dummy_wrap.cxx: libMEDMEM_Swig_wrap.cxx
+ sed -e 's/SwigValueWrapper< vector<FAMILY \* > >/vector<FAMILY \* >/g' libMEDMEM_Swig_wrap.cxx > toto
+ mv toto libMEDMEM_Swig_wrap.cxx
+ sed -e 's/SwigValueWrapper< vector<SUPPORT \* > const >/vector<SUPPORT \* >/g' libMEDMEM_Swig_wrap.cxx > toto
+ mv toto libMEDMEM_Swig_wrap.cxx
+ touch dummy_wrap.cxx
+else
SWIG_DEF = libMEDMEM_Swig.i
+endif
EXPORT_PYSCRIPTS = libMEDMEM_Swig.py \
med_test1.py \
#include "MEDMEM_SWIG_FieldInt.hxx"
#include "MEDMEM_SWIG_MedFieldDoubleDriver.hxx"
#include "MEDMEM_SWIG_MedFieldIntDriver.hxx"
+#include "MEDMEM_SWIG_AsciiFieldDoubleDriver.hxx"
+#include "MEDMEM_SWIG_AsciiFieldIntDriver.hxx"
#include "MEDMEM_Meshing.hxx"
+#include "MEDMEM_DriverFactory.hxx"
+#include "MEDMEM_SWIG_Templates.hxx"
+
+#ifdef _DEBUG_
+#include "LocalTraceCollector.hxx"
+#endif /* ifdef _DEBUG_*/
using namespace MEDMEM;
using namespace MED_EN;
}
}
+/*
+ Initialisation block in the case of the debug mode (definition of _DEBUG_
+ compilation switch) and due to the LocalTraceCollector mechanism
+*/
+
+%init %{
+#ifdef _DEBUG_
+ LocalTraceCollector::instance();
+#endif /* ifdef _DEBUG_*/
+%}
+
/*
managing the use of operator= of any class by renaming it assign()
because assignment can't be overloaded in python.
PyErr_SetString(PyExc_RuntimeError, message);
return NULL;
}
-
- $1[i] = f;
+ // mpv: for compatibility with SWIG 1.3.24 SwigValueWrapper
+ // $1[i] = f;
+ $1.at(i) = f;
}
}
else
for (int i=0;i<size;i++)
{
- PyObject * tmp = SWIG_NewPointerObj($1[i],$descriptor(FAMILY *),0);
+ // mpv: for compatibility with SWIG 1.3.24 SwigValueWrapper
+ //PyObject * tmp = SWIG_NewPointerObj($1[i],$descriptor(FAMILY *),0);
+ PyObject * tmp = SWIG_NewPointerObj($1.at(i),$descriptor(FAMILY *),0);
PyList_SetItem($result,i,tmp);
}
PyErr_SetString(PyExc_RuntimeError, message);
return NULL;
}
-
- $1[i] = s;
+ // mpv: for compatibility with SWIG 1.3.24 SwigValueWrapper
+ //$1[i] = s;
+ $1.at(i) = s;
}
}
else
for (int i=0;i<size;i++)
{
- PyObject * tmp = SWIG_NewPointerObj($1[i],$descriptor(SUPPORT *),0);
+ // mpv: for compatibility with SWIG 1.3.24 SwigValueWrapper
+ //PyObject * tmp = SWIG_NewPointerObj($1[i],$descriptor(SUPPORT *),0);
+ PyObject * tmp = SWIG_NewPointerObj($1.at(i),$descriptor(SUPPORT *),0);
+
+ PyList_SetItem($result,i,tmp);
+ }
+}
+
+%typemap(python,in) vector< FIELD<double> * >, const vector< FIELD<double> * >
+{
+ /* typemap in for vector<FIELD<double> *> */
+ /* Check if is a list */
+
+ if (PyList_Check($input)) {
+ int size = PyList_Size($input);
+ $1.resize(size);
+
+ for (int i=0; i < size; i++)
+ {
+ PyObject * tmp = PyList_GetItem($input,i);
+ FIELDDOUBLE * s;
+
+ int err = SWIG_ConvertPtr(tmp, (void **) &s, $descriptor(FIELDDOUBLE *),
+ SWIG_POINTER_EXCEPTION);
+
+ if (err == -1)
+ {
+ char * message = "Error in typemap(python,in) for vector<FIELD<double> *> each component should be a SUPPORT pointer";
+ PyErr_SetString(PyExc_RuntimeError, message);
+ return NULL;
+ }
+
+ // mpv: for compatibility with SWIG 1.3.24 SwigValueWrapper
+ //$1[i] = s;
+ $1.at(i) = s;
+ }
+ }
+ else
+ {
+ PyErr_SetString(PyExc_TypeError,"not a list");
+ return NULL;
+ }
+}
+
+%typemap(python,out) vector<FIELD<double> *>
+{
+ /* typemap out for vector<FIELD<double> *> */
+ int size = $1.size();
+ $result = PyList_New(size);
+
+ for (int i=0;i<size;i++)
+ {
+ // mpv: for compatibility with SWIG 1.3.24 SwigValueWrapper
+ //PyObject * tmp = SWIG_NewPointerObj($1[i],$descriptor(FIELD<double> *),0);
+ PyObject * tmp = SWIG_NewPointerObj($1.at(i),$descriptor(FIELD<double> *),0);
+
+ PyList_SetItem($result,i,tmp);
+ }
+}
+
+%typemap(python,in) vector<FIELD<int> *>, const vector<FIELD<int> *>
+{
+ /* typemap in for vector<FIELD<int> *> */
+ /* Check if is a list */
+
+ if (PyList_Check($input)) {
+ int size = PyList_Size($input);
+ $1.resize(size);
+
+ for (int i=0; i < size; i++)
+ {
+ PyObject * tmp = PyList_GetItem($input,i);
+ FIELD<int> * s;
+
+ int err = SWIG_ConvertPtr(tmp, (void **) &s, $descriptor(FIELD<int> *),
+ SWIG_POINTER_EXCEPTION);
+
+ if (err == -1)
+ {
+ char * message = "Error in typemap(python,in) for vector<FIELD<int> *> each component should be a SUPPORT pointer";
+ PyErr_SetString(PyExc_RuntimeError, message);
+ return NULL;
+ }
+
+ // mpv: for compatibility with SWIG 1.3.24 SwigValueWrapper
+ //$1[i] = s;
+ $1.at(i) = s;
+ }
+ }
+ else
+ {
+ PyErr_SetString(PyExc_TypeError,"not a list");
+ return NULL;
+ }
+}
+
+%typemap(python,out) vector<FIELD<int> *>
+{
+ /* typemap out for vector<FIELD<int> *> */
+ int size = $1.size();
+ $result = PyList_New(size);
+
+ for (int i=0;i<size;i++)
+ {
+ // mpv: for compatibility with SWIG 1.3.24 SwigValueWrapper
+ //PyObject * tmp = SWIG_NewPointerObj($1[i],$descriptor(FIELD<int> *),0);
+ PyObject * tmp = SWIG_NewPointerObj($1.at(i),$descriptor(FIELD<int> *),0);
PyList_SetItem($result,i,tmp);
}
typedef enum {MED_LECT, MED_ECRI, MED_REMP} med_mode_acces;
+typedef enum {ASCENDING=7,DESCENDING=77} med_sort_direc;
+
typedef enum {MED_CELL, MED_FACE, MED_EDGE, MED_NODE,
MED_ALL_ENTITIES} medEntityMesh;
typedef enum {MED_NODAL, MED_DESCENDING} medConnectivity ;
typedef enum {MED_DRIVER=0, GIBI_DRIVER=1, PORFLOW_DRIVER = 2, VTK_DRIVER=254,
- NO_DRIVER=255} driverTypes;
+ NO_DRIVER=255, ASCII_DRIVER = 3} driverTypes;
-typedef enum {MED_REEL64=6, MED_INT32=24, MED_INT64=26,
- MED_INT} med_type_champ;
+typedef enum {MED_REEL64=6, MED_INT32=24, MED_INT64=26} med_type_champ;
typedef struct { int dt; int it; } DT_IT_;
+typedef enum {V21 = 26, V22 = 75} medFileVersion;
+
+medFileVersion getMedFileVersionForWriting();
+
+void setMedFileVersionForWriting(medFileVersion version);
+
+%{
+ medFileVersion getMedFileVersionForWriting()
+ {
+ return (medFileVersion) DRIVERFACTORY::getMedFileVersionForWriting();
+ }
+
+ void setMedFileVersionForWriting(medFileVersion version)
+ {
+ DRIVERFACTORY::setMedFileVersionForWriting((medFileVersion) version);
+ }
+%}
+
%extend DT_IT_ {
int getdt()
{
void setNumber(const int * index, const int* value);
+ bool deepCompare(const SUPPORT &support) const;
+
%extend {
SUPPORT(MESH* Mesh, char * Name="", medEntityMesh Entity=MED_CELL)
{
Py_DECREF(py_list);
return result;
}
+ %newobject getComplement() const;
+ SUPPORT *getComplement() const
+ {
+ return self->getComplement();
+ }
+
+ %newobject substract(const SUPPORT& other) const;
+ SUPPORT *substract(const SUPPORT& other) const
+ {
+ return self->substract(other);
+ }
+
+ %newobject getBoundaryElements(medEntityMesh Entity) const;
+ SUPPORT *getBoundaryElements(medEntityMesh Entity) const
+ {
+ return self->getBoundaryElements(Entity);
+ }
}
};
return self->addDriver(driverType,string(fileName),
string(driverName),access);
}
-
+ %newobject getSupportAndOwner();
+ SUPPORT * getSupportAndOwner()
+ {
+ return (SUPPORT *)self->getSupport();
+ }
}
};
void applyLin(double a, double n);
+ void applyPow(double scalar);
+
double normMax();
double norm2();
double normL2(int component, const FIELDDOUBLE * p_field_volume=NULL) const;
FIELD<double>* result = FIELD<double>::add( *(FIELD<double>*)self , (FIELD<double>&)m );
return (FIELDDOUBLE*) result;
-
-/* const FIELD<double> result = (*(FIELD<double>*)self) +
- (FIELD<double>&)m;
- return new FIELDDOUBLE(result); */
}
%newobject __sub__(const FIELDDOUBLE & );
return (FIELDDOUBLE*) result;
}
+ %newobject addDeep(const FIELDINT & );
+ FIELDDOUBLE * addDeep(const FIELDDOUBLE & m)
+ {
+ MESSAGE("operator + : Creation of the addition of two FIELDINTs");
+ FIELD<double>* result = FIELD<double>::addDeep( *(FIELD<double>*)self , (FIELD<double>&)m );
+ return (FIELDDOUBLE*) result;
+ }
+
+ %newobject subDeep(const FIELDDOUBLE & );
+ FIELDDOUBLE * subDeep(const FIELDDOUBLE & m)
+ {
+ MESSAGE("operator - : Creation of the substraction of two FIELDDOUBLEs");
+ FIELD<double>* result = FIELD<double>::subDeep( *(FIELD<double>*)self , (FIELD<double>&)m );
+ return (FIELDDOUBLE*) result;
+ }
+
+ %newobject mulDeep(const FIELDDOUBLE & );
+ FIELDDOUBLE * mulDeep(const FIELDDOUBLE & m)
+ {
+ MESSAGE("operator * : Creation of the multiplication of two FIELDDOUBLEs");
+ FIELD<double>* result = FIELD<double>::mulDeep( *(FIELD<double>*)self , (FIELD<double>&)m );
+ return (FIELDDOUBLE*) result;
+ }
+
+ %newobject divDeep(const FIELDDOUBLE & );
+ FIELDDOUBLE * divDeep(const FIELDDOUBLE & m)
+ {
+ MESSAGE("operator / : Creation of the division of two FIELDDOUBLEs");
+ FIELD<double>* result = FIELD<double>::divDeep( *(FIELD<double>*)self , (FIELD<double>&)m );
+ return (FIELDDOUBLE*) result;
+ }
+
FIELDDOUBLE (const SUPPORT * Support, driverTypes driverType,
char * fileName, char * fieldName,
const int iterationNumber,
{
self->allocValue(NumberOfComponents, LengthValue);
}
+
+ %newobject extract(const SUPPORT *subSupport);
+ FIELDDOUBLE *extract(const SUPPORT *subSupport)
+ {
+ FIELD<double>* result=self->extract(subSupport);
+ return (FIELDDOUBLE *)result;
+ }
}
};
void applyLin(int a, int n);
+ void applyPow(int scalar);
+
double normMax();
double norm2();
double normL2(int component, const FIELDDOUBLE * p_field_volume=NULL) const;
return (FIELDINT*) result;
}
+ %newobject addDeep(const FIELDINT & );
+ FIELDINT * addDeep(const FIELDINT & m)
+ {
+ MESSAGE("operator + : Creation of the addition of two FIELDINTs");
+ FIELD<int>* result = FIELD<int>::addDeep( *(FIELD<int>*)self , (FIELD<int>&)m );
+ return (FIELDINT*) result;
+ }
+
+ %newobject subDeep(const FIELDINT & );
+ FIELDINT * subDeep(const FIELDINT & m)
+ {
+ MESSAGE("operator - : Creation of the substraction of two FIELDINTs");
+ FIELD<int>* result = FIELD<int>::subDeep( *(FIELD<int>*)self , (FIELD<int>&)m );
+ return (FIELDINT*) result;
+ }
+
+ %newobject mulDeep(const FIELDINT & );
+ FIELDINT * mulDeep(const FIELDINT & m)
+ {
+ MESSAGE("operator * : Creation of the multiplication of two FIELDINTs");
+ FIELD<int>* result = FIELD<int>::mulDeep( *(FIELD<int>*)self , (FIELD<int>&)m );
+ return (FIELDINT*) result;
+ }
+
+ %newobject divDeep(const FIELDINT & );
+ FIELDINT * divDeep(const FIELDINT & m)
+ {
+ MESSAGE("operator / : Creation of the division of two FIELDINTs");
+ FIELD<int>* result = FIELD<int>::divDeep( *(FIELD<int>*)self , (FIELD<int>&)m );
+ return (FIELDINT*) result;
+ }
+
FIELDINT(const SUPPORT * Support, driverTypes driverType,
char * fileName, char * fieldName,
const int iterationNumber,
{
self->allocValue(NumberOfComponents, LengthValue);
}
+
+ %newobject extract(const SUPPORT *subSupport);
+ FIELDINT *extract(const SUPPORT *subSupport)
+ {
+ FIELD<int>* result=self->extract(subSupport);
+ return (FIELDINT *)result;
+ }
}
};
medGeometryElement getElementType(medEntityMesh Entity,int Number);
+ int getElementContainingPoint(const double *coord);
+
%extend {
%newobject getBoundaryElements(medEntityMesh );
SUPPORT * getBoundaryElements(medEntityMesh Entity)
return self->intersectSupports(Supports);
}
+ %newobject mergeFieldsDouble(const vector< FIELD<double>* > others);
+ FIELDDOUBLE * mergeFieldsDouble(const vector< FIELD<double>* > others)
+ {
+ return (FIELDDOUBLE *)self->mergeFields<double>(others);
+ }
+
+ %newobject mergeFieldsInt(const vector< FIELD<int>* > others);
+ FIELDINT * mergeFieldsInt(const vector< FIELD<int>* > others)
+ {
+ return (FIELDINT *)self->mergeFields<int>(others);
+ }
+
CELLMODEL getCellType(medEntityMesh Entity,int i)
{
return self->getCellsTypes(Entity)[i];
void addGroup (const GROUP & Group) ;
+ void setPolygonsConnectivity (const int * ConnectivityIndex,
+ const int * ConnectivityValue,
+ int nbOfPolygons,
+ const medEntityMesh Entity);
+
+ void setPolyhedraConnectivity (const int * PolyhedronIndex,
+ const int * FacesIndex,
+ const int * Nodes,
+ int nbOfPolyhedra,
+ const MED_EN::medEntityMesh Entity);
+
%extend {
void setCoordinates(const int SpaceDimension, const int NumberOfNodes,
const double * Coordinates, const char * System,
return self->getField(string(fieldName),dt,it);
}
+ FIELD_ * getField2(char * fieldName,double time, int it=0)
+ {
+ return self->getField2(string(fieldName),time,it);
+ }
+
SUPPORT * getSupport(char * meshName, medEntityMesh entity)
{
return self->getSupport(string(meshName),entity);
}
};
+class GIBI_MED_RDONLY_DRIVER
+{
+public :
+ GIBI_MED_RDONLY_DRIVER() ;
+
+ GIBI_MED_RDONLY_DRIVER(const GIBI_MED_RDONLY_DRIVER & driver) ;
+
+ ~GIBI_MED_RDONLY_DRIVER() ;
+
+ void open();
+
+ void write( void );
+
+ void read ( void );
+
+ void close();
+
+ %extend {
+ GIBI_MED_RDONLY_DRIVER(char * fileName, MED * ptrMed)
+ {
+ return new GIBI_MED_RDONLY_DRIVER(string(fileName), ptrMed) ;
+ }
+
+ %newobject __str__();
+ const char* __str__()
+ {
+ ostringstream mess;
+ mess << "Python Printing GIBI_MED_RDONLY_DRIVER : " << *self << endl;
+ return strdup(mess.str().c_str());
+ }
+
+ }
+};
+
+class GIBI_MED_WRONLY_DRIVER
+{
+public :
+ GIBI_MED_WRONLY_DRIVER() ;
+
+ GIBI_MED_WRONLY_DRIVER(const GIBI_MED_WRONLY_DRIVER & driver) ;
+
+ ~GIBI_MED_WRONLY_DRIVER() ;
+
+ void open();
+
+ void write( void );
+
+ void read ( void );
+
+ void close();
+
+ %extend {
+ GIBI_MED_WRONLY_DRIVER(char * fileName, MED * ptrMed, MESH * ptrMesh)
+ {
+ return new GIBI_MED_WRONLY_DRIVER(string(fileName), ptrMed, ptrMesh) ;
+ }
+
+ %newobject __str__();
+ const char* __str__()
+ {
+ ostringstream mess;
+ mess << "Python Printing GIBI_MED_WRONLY_DRIVER : " << *self << endl;
+ return strdup(mess.str().c_str());
+ }
+
+ }
+};
+
/*
API de PORFLOW_MESH_[RDONLY,WRONLY,RDWR]_DRIVER
*/
}
};
+class ASCII_FIELDDOUBLE_DRIVER {
+public:
+ ~ASCII_FIELDDOUBLE_DRIVER();
+
+ void open();
+
+ void close();
+
+ void write( void ) const ;
+
+
+ %extend {
+ ASCII_FIELDDOUBLE_DRIVER(const char *fileName, FIELDDOUBLE * ptrField, med_sort_direc direction, const char *priority)
+ {
+ return new ASCII_FIELDDOUBLE_DRIVER(string(fileName), ptrField, (MED_EN::med_sort_direc)direction, priority);
+ }
+ }
+};
+
+class ASCII_FIELDINT_DRIVER {
+public:
+ ~ASCII_FIELDINT_DRIVER();
+
+ void open();
+
+ void close();
+
+ void write( void ) const ;
+
+
+ %extend {
+ ASCII_FIELDINT_DRIVER(const char *fileName, FIELDINT * ptrField, med_sort_direc direction, const char *priority)
+ {
+ return new ASCII_FIELDINT_DRIVER(string(fileName), ptrField, (MED_EN::med_sort_direc)direction, priority);
+ }
+ }
+};
+
%newobject createFieldDoubleScalarProduct(FIELDDOUBLE * field1, FIELDDOUBLE * field2) ;
FIELDDOUBLE * createFieldDoubleScalarProduct(FIELDDOUBLE * field1, FIELDDOUBLE * field2) ;
%newobject createFieldIntScalarProduct(FIELDINT * field1, FIELDINT * field2) ;
FIELDINT * createFieldIntScalarProduct(FIELDINT * field1, FIELDINT * field2) ;
+%newobject createFieldDoubleScalarProductDeep(FIELDDOUBLE * field1, FIELDDOUBLE * field2) ;
+FIELDDOUBLE * createFieldDoubleScalarProductDeep(FIELDDOUBLE * field1, FIELDDOUBLE * field2) ;
+
+%newobject createFieldIntScalarProductDeep(FIELDINT * field1, FIELDINT * field2) ;
+FIELDINT * createFieldIntScalarProductDeep(FIELDINT * field1, FIELDINT * field2) ;
+
FIELDDOUBLE * createFieldDoubleFromField(FIELD_ * field) ;
FIELDINT * createFieldIntFromField(FIELD_ * field) ;
{
return (FIELDINT *) FIELD<int>::scalarProduct( (FIELD<int>)*field1, (FIELD<int>)*field2);
}
+
+ FIELDDOUBLE * createFieldDoubleScalarProductDeep(FIELDDOUBLE * field1, FIELDDOUBLE * field2)
+ {
+ return (FIELDDOUBLE *) FIELD<double>::scalarProduct( (FIELD<double>)*field1, (FIELD<double>)*field2, true);
+ }
+
+ FIELDINT * createFieldIntScalarProductDeep(FIELDINT * field1, FIELDINT * field2)
+ {
+ return (FIELDINT *) FIELD<int>::scalarProduct( (FIELD<int>)*field1, (FIELD<int>)*field2, true);
+ }
FIELDDOUBLE * createFieldDoubleFromField(FIELD_ * field)
{
PyObject * double_function)
{
MESSAGE("createFieldDoubleFromAnalytic : Constructor (for Python API) FIELDDOUBLE from an analytic fonction");
-
FIELDDOUBLE * fieldDouble = new FIELDDOUBLE(Support,NumberOfComponents);
-
- int NumberOfValues = fieldDouble->getNumberOfValues();
- double * values = new double[NumberOfValues*NumberOfComponents];
-
- const double * x = (const double *) NULL;
- const double * y = (const double *) NULL;
- const double * z = (const double *) NULL;
-
- FIELD<double> * barycenterField = (FIELD<double> *) NULL;
-
- medEntityMesh entity = Support->getEntity();
- bool onAll = Support->isOnAllElements();
-
- MESH * mesh = Support->getMesh();
- int spaceDim = mesh->getSpaceDimension();
-
- if (entity == MED_NODE)
- {
- if (onAll)
- {
- const double * coord = mesh->getCoordinates(MED_NO_INTERLACE);
-
- x = coord;
- y = coord+NumberOfValues;
- if (spaceDim == 3) z = y+NumberOfValues;
- }
- else
- {
- const int * nodesNumber = Support->getNumber(MED_ALL_ELEMENTS);
- const double * coord = mesh->getCoordinates(MED_FULL_INTERLACE);
-
- double * x_tmp = new double [NumberOfValues];
- double * y_tmp = new double [NumberOfValues];
-
- for (int i=0; i<NumberOfValues; i++)
- {
- int j = nodesNumber[i]*spaceDim;
- x_tmp[i] = coord[j];
- y_tmp[i] = coord[j+1];
- }
-
- x = x_tmp;
- y = y_tmp;
-
- if (spaceDim == 3)
- {
- double * z_tmp = new double [NumberOfValues];
-
- for (int i=0; i<NumberOfValues; i++)
- {
- int j = nodesNumber[i]*spaceDim + 2;
- z_tmp[i] = coord[j];
- }
-
- z = z_tmp;
- }
- }
- }
- else
- {
- barycenterField = mesh->getBarycenter(Support);
- const double * barycenter =
- barycenterField->getValue(MED_NO_INTERLACE);
-
- x = barycenter;
- y = barycenter+NumberOfValues;
- if (spaceDim == 3) z = y+NumberOfValues;
- }
-
- for (int i=0; i<NumberOfValues; i++)
- {
- double x_val = x[i];
- double y_val = y[i];
- double z_val = 0.0;
-
- if (spaceDim == 2)
- {
- MESSAGE("debug ...... x = " << x_val << " y = " << y_val);
- }
- else if (spaceDim == 3)
- {
- z_val = z[i];
- MESSAGE("debug ...... x = " << x_val << " y = " << y_val << " z = " << z_val);
- }
-
- PyObject * tuple;
-
- if (spaceDim == 2) tuple = PyTuple_New(2);
- else if (spaceDim == 3) tuple = PyTuple_New(3);
-
- int index = 0;
- int err = PyTuple_SetItem(tuple,index,Py_BuildValue("d",x_val));
-
- if (err != 0)
- throw MEDEXCEPTION("Internal Error in createFieldDoubleFromAnalytic");
-
- index = 1;
- err = PyTuple_SetItem(tuple,index,Py_BuildValue("d",y_val));
-
- if (err != 0)
- throw MEDEXCEPTION("Internal Error in createFieldDoubleFromAnalytic");
-
- if (spaceDim == 3)
- {
- index = 2;
- err = PyTuple_SetItem(tuple,index,Py_BuildValue("d",z_val));
-
- if (err != 0)
- throw MEDEXCEPTION("Internal Error in createFieldDoubleFromAnalytic");
- }
-
- PyObject * function_ret = PyObject_CallObject(double_function,
- tuple);
-
- SCRUTE(function_ret);
-
- if ((function_ret == (PyObject *) NULL) && (spaceDim == 2))
- throw MEDEXCEPTION("Internal Error in createFieldDoubleFromAnalytic : the call to the user callable fonction has failed (check its API (double, double))");
- else if ((function_ret == (PyObject *) NULL) && (spaceDim == 3))
- throw MEDEXCEPTION("Internal Error in createFieldDoubleFromAnalytic : the call to the user callable fonction has failed (check its API (double, double, double))");
-
- err = PyList_Check(function_ret);
-
- if (!err)
- if (spaceDim == 2)
- {
- Py_DECREF(function_ret);
- throw MEDEXCEPTION("Internal Error in createFieldDoubleFromAnalytic : the call to the user callable fonction has failed (check its API list of double fonct (double, double))");
- }
- else if (spaceDim == 3)
- {
- Py_DECREF(function_ret);
- throw MEDEXCEPTION("Internal Error in createFieldDoubleFromAnalytic : the call to the user callable fonction has failed (check its API list of double fonct (double, double, double))");
- }
-
- int size = PyList_Size(function_ret);
-
- if (size != NumberOfComponents)
- if (spaceDim == 2)
- {
- Py_DECREF(function_ret);
- throw MEDEXCEPTION("Internal Error in createFieldDoubleFromAnalytic : the call to the user callable fonction has failed (check its API list of double fonct (double, double), especially the size of the returned list)");
- }
- else if (spaceDim == 3)
- {
- Py_DECREF(function_ret);
- throw MEDEXCEPTION("Internal Error in createFieldDoubleFromAnalytic : the call to the user callable fonction has failed (check its API list of double fonct (double, double, double), especially the size of the returned list)");
- }
-
- for (int j=0; j<NumberOfComponents; j++)
- {
- PyObject * tmp = PyList_GetItem(function_ret,j);
-
- err = PyFloat_Check(tmp);
-
- if (!err)
- if (spaceDim == 2)
- {
- Py_DECREF(function_ret);
- throw MEDEXCEPTION("Internal Error in createFieldDoubleFromAnalytic : the call to the user callable fonction has failed (check its API list of double fonct (double, double), especially the type of the returned list)");
- }
- else if (spaceDim == 3)
- {
- Py_DECREF(function_ret);
- throw MEDEXCEPTION("Internal Error in createFieldDoubleFromAnalytic : the call to the user callable fonction has failed (check its API list of double fonct (double, double, double), especially the type of the returned list)");
- }
-
- values[i*NumberOfComponents+j] = PyFloat_AsDouble(tmp);
- }
-
- Py_DECREF(function_ret);
- Py_DECREF(tuple);
- }
-
- fieldDouble->setValue(MED_FULL_INTERLACE,values);
-
- delete [] values;
-
- if ((entity == MED_NODE) && (!onAll))
- {
- delete [] x;
- delete [] y;
-
- if (Support->getMesh()->getSpaceDimension() == 3)
- delete [] z;
- }
- else if (entity != MED_NODE) delete barycenterField ;
-
+ MyFunction<double>::_pyFunc=double_function;
+ MyFunction<double>::_nbOfComponent=NumberOfComponents;
+ MyFunction<double>::_spaceDim=Support->getMesh()->getSpaceDimension();
+ fieldDouble->fillFromAnalytic< MyFunction<double>::EvalPy2Cpp >();
return fieldDouble;
}
PyObject * integer_function)
{
MESSAGE("createFieldIntFromAnalytic : Constructor (for Python API) FIELDINT from an analytic fonction");
-
- FIELDINT * fieldInt = new FIELDINT(Support,NumberOfComponents);
-
- int NumberOfValues = fieldInt->getNumberOfValues();
- int * values = new int[NumberOfValues*NumberOfComponents];
-
- const double * x = (const double *) NULL;
- const double * y = (const double *) NULL;
- const double * z = (const double *) NULL;
-
- FIELD<double> * barycenterField = (FIELD<double> *) NULL;
-
- medEntityMesh entity = Support->getEntity();
- bool onAll = Support->isOnAllElements();
-
- MESH * mesh = Support->getMesh();
- int spaceDim = mesh->getSpaceDimension();
-
- if (entity == MED_NODE)
- {
- if (onAll)
- {
- const double * coord = mesh->getCoordinates(MED_NO_INTERLACE);
-
- x = coord;
- y = coord+NumberOfValues;
- if (spaceDim == 3) z = y+NumberOfValues;
- }
- else
- {
- const int * nodesNumber = Support->getNumber(MED_ALL_ELEMENTS);
- const double * coord = mesh->getCoordinates(MED_FULL_INTERLACE);
-
- double * x_tmp = new double [NumberOfValues];
- double * y_tmp = new double [NumberOfValues];
-
- for (int i=0; i<NumberOfValues; i++)
- {
- int j = nodesNumber[i]*spaceDim;
- x_tmp[i] = coord[j];
- y_tmp[i] = coord[j+1];
- }
-
- x = x_tmp;
- y = y_tmp;
-
- if (spaceDim == 3)
- {
- double * z_tmp = new double [NumberOfValues];
-
- for (int i=0; i<NumberOfValues; i++)
- {
- int j = nodesNumber[i]*spaceDim + 2;
- z_tmp[i] = coord[j];
- }
-
- z = z_tmp;
- }
- }
- }
- else
- {
- barycenterField = mesh->getBarycenter(Support);
- const double * barycenter =
- barycenterField->getValue(MED_NO_INTERLACE);
-
- x = barycenter;
- y = barycenter+NumberOfValues;
- if (spaceDim == 3) z = y+NumberOfValues;
- }
-
- for (int i=0; i<NumberOfValues; i++)
- {
- double x_val = x[i];
- double y_val = y[i];
- double z_val = 0.0;
-
- if (spaceDim == 2)
- {
- MESSAGE("debug ...... x = " << x_val << " y = " << y_val);
- }
- else if (spaceDim == 3)
- {
- z_val = z[i];
- MESSAGE("debug ...... x = " << x_val << " y = " << y_val << " z = " << z_val);
- }
-
- PyObject * tuple;
-
- if (spaceDim == 2) tuple = PyTuple_New(2);
- else if (spaceDim == 3) tuple = PyTuple_New(3);
-
- int index = 0;
- int err = PyTuple_SetItem(tuple,index,Py_BuildValue("d",x_val));
-
- if (err != 0)
- throw MEDEXCEPTION("Internal Error in createFieldIntFromAnalytic");
-
- index = 1;
- err = PyTuple_SetItem(tuple,index,Py_BuildValue("d",y_val));
-
- if (err != 0)
- throw MEDEXCEPTION("Internal Error in createFieldIntFromAnalytic");
-
- if (spaceDim == 3)
- {
- index = 2;
- err = PyTuple_SetItem(tuple,index,Py_BuildValue("d",z_val));
-
- if (err != 0)
- throw MEDEXCEPTION("Internal Error in createFieldIntFromAnalytic");
- }
-
- PyObject * function_ret = PyObject_CallObject(integer_function,
- tuple);
-
- if ((function_ret == (PyObject *) NULL) && (spaceDim == 2))
- throw MEDEXCEPTION("Internal Error in createFieldIntFromAnalytic : the call to the user callable fonction has failed (check its API (double, double))");
- else if ((function_ret == (PyObject *) NULL) && (spaceDim == 3))
- throw MEDEXCEPTION("Internal Error in createFieldIntFromAnalytic : the call to the user callable fonction has failed (check its API (double, double, double))");
-
- err = PyList_Check(function_ret);
-
- if (!err)
- if (spaceDim == 2)
- {
- Py_DECREF(function_ret);
- throw MEDEXCEPTION("Internal Error in createFieldIntFromAnalytic : the call to the user callable fonction has failed (check its API list of integer fonct (double, double))");
- }
- else if (spaceDim == 3)
- {
- Py_DECREF(function_ret);
- throw MEDEXCEPTION("Internal Error in createFieldIntFromAnalytic : the call to the user callable fonction has failed (check its API list of integer fonct (double, double, double))");
- }
-
- int size = PyList_Size(function_ret);
-
- if (size != NumberOfComponents)
- if (spaceDim == 2)
- {
- Py_DECREF(function_ret);
- throw MEDEXCEPTION("Internal Error in createFieldIntFromAnalytic : the call to the user callable fonction has failed (check its API list of integer fonct (double, double), especially the size of the returned list)");
- }
- else if (spaceDim == 3)
- {
- Py_DECREF(function_ret);
- throw MEDEXCEPTION("Internal Error in createFieldIntFromAnalytic : the call to the user callable fonction has failed (check its API list of integer fonct (double, double, double), especially the size of the returned list)");
- }
-
- for (int j=0; j<NumberOfComponents; j++)
- {
- PyObject * tmp = PyList_GetItem(function_ret,j);
-
- err = PyInt_Check(tmp);
-
- if (!err)
- if (spaceDim == 2)
- {
- Py_DECREF(function_ret);
- throw MEDEXCEPTION("Internal Error in createFieldIntFromAnalytic : the call to the user callable fonction has failed (check its API list of integer fonct (double, double), especially the type of the returned list)");
- }
- else if (spaceDim == 3)
- {
- Py_DECREF(function_ret);
- throw MEDEXCEPTION("Internal Error in createFieldIntFromAnalytic : the call to the user callable fonction has failed (check its API list of integer fonct (double, double, double), especially the type of the returned list)");
- }
-
- values[i*NumberOfComponents+j] = (int) PyInt_AsLong(tmp);
- }
-
- Py_DECREF(function_ret);
- Py_DECREF(tuple);
- }
-
- fieldInt->setValue(MED_FULL_INTERLACE,values);
-
- delete [] values;
-
- if ((entity == MED_NODE) && (!onAll))
- {
- delete [] x;
- delete [] y;
-
- if (Support->getMesh()->getSpaceDimension() == 3)
- delete [] z;
- }
- else if (entity != MED_NODE) delete barycenterField ;
-
+ FIELDINT * fieldInt = new FIELDINT(Support,NumberOfComponents);
+ MyFunction<int>::_pyFunc=integer_function;
+ MyFunction<int>::_nbOfComponent=NumberOfComponents;
+ MyFunction<int>::_spaceDim=Support->getMesh()->getSpaceDimension();
+ fieldInt->fillFromAnalytic< MyFunction<int>::EvalPy2Cpp >();
return fieldInt;
}
support1Description = "Partial Support 1"
support1NbOfTypes = 3
support1TotNbElm = 8
-support1GeoType = [MED_TRIA3,MED_HEXA8,MED_PYRA5]
+support1GeoType = [MED_TETRA4,MED_HEXA8,MED_PYRA5]
support1NbOfElm = [4,2,2]
support1NbValue = [1,2,3,4,15,16,13,14]
support2Description = "Partial Support 2"
support2NbOfTypes = 3
support2TotNbElm = 8
-support2GeoType = [MED_TRIA3,MED_HEXA8,MED_PYRA5]
+support2GeoType = [MED_TETRA4,MED_HEXA8,MED_PYRA5]
support2NbOfElm = [6,1,1]
support2NbValue = [3,4,9,10,11,12,16,14]
--- /dev/null
+from libMEDMEM_Swig import *
+
+import os,string
+
+filesPath=os.environ["MED_ROOT_DIR"]
+filesPath=filesPath+"/share/salome/resources/"
+
+testExecfiles = []
+argListTest = []
+rootFileTest = []
+meshTest = []
+fieldTest = []
+
+# executables list to test functionalities
+
+testExecfiles.append("testUArray")
+argListTest.append("")
+rootFileTest.append("")
+meshTest.append("")
+fieldTest.append("")
+
+testExecfiles.append("testUCellModel")
+argListTest.append("")
+rootFileTest.append("")
+meshTest.append("")
+fieldTest.append("")
+
+testExecfiles.append("testUCoordinate")
+argListTest.append("")
+rootFileTest.append("")
+meshTest.append("")
+fieldTest.append("")
+
+testExecfiles.append("testUGeoNameMeshEntities")
+argListTest.append("")
+rootFileTest.append("")
+meshTest.append("")
+fieldTest.append("")
+
+testExecfiles.append("testUMedException")
+argListTest.append("")
+rootFileTest.append("")
+meshTest.append("")
+fieldTest.append("")
+
+testExecfiles.append("testUModulusArray")
+argListTest.append("")
+rootFileTest.append("")
+meshTest.append("")
+fieldTest.append("")
+
+testExecfiles.append("testUPointerOf")
+argListTest.append("")
+rootFileTest.append("")
+meshTest.append("")
+fieldTest.append("")
+
+testExecfiles.append("testUSkyLineArray")
+argListTest.append("")
+rootFileTest.append("")
+meshTest.append("")
+fieldTest.append("")
+
+testExecfiles.append("testUUnit")
+argListTest.append("")
+rootFileTest.append("")
+meshTest.append("")
+fieldTest.append("")
+
+testExecfiles.append("test_MEDMEM_PolyConnectivity")
+argListTest.append("")
+rootFileTest.append("")
+meshTest.append("")
+fieldTest.append("")
+
+testExecfiles.append("test_affect_medarray")
+argListTest.append("")
+rootFileTest.append("")
+meshTest.append("")
+fieldTest.append("")
+
+testExecfiles.append("test_copie_coordinate")
+argListTest.append("")
+rootFileTest.append("")
+meshTest.append("")
+fieldTest.append("")
+
+testExecfiles.append("test_copie_medarray")
+argListTest.append("")
+rootFileTest.append("")
+meshTest.append("")
+fieldTest.append("")
+
+testExecfiles.append("test_MEDMEM_Array")
+argListTest.append("")
+rootFileTest.append("")
+meshTest.append("")
+fieldTest.append("")
+
+testExecfiles.append("test_MEDMEM_CellModel")
+argListTest.append("")
+rootFileTest.append("")
+meshTest.append("")
+fieldTest.append("")
+
+testExecfiles.append("test_MEDMEM_ModulusArray")
+argListTest.append("")
+rootFileTest.append("")
+meshTest.append("")
+fieldTest.append("")
+
+testExecfiles.append("test_MEDMEM_PolyhedronArray")
+argListTest.append("")
+rootFileTest.append("")
+meshTest.append("")
+fieldTest.append("")
+
+testExecfiles.append("test_MEDMEM_SkyLineArray")
+argListTest.append("")
+rootFileTest.append("")
+meshTest.append("")
+fieldTest.append("")
+
+testExecfiles.append("test_MEDMEM_Meshing")
+argListTest.append("toto")
+rootFileTest.append("")
+meshTest.append("")
+fieldTest.append("")
+
+testExecfiles.append("test_gibi_driver")
+rootFileTest.append("Darcy3_3D_H_10x10x10")
+argListTest.append(filesPath+"Darcy3_3D_H_10x10x10.sauve")
+meshTest.append("")
+fieldTest.append("")
+
+testExecfiles.append("test_gibi_driver")
+rootFileTest.append("dx200_dy1_avec_2couches")
+argListTest.append(filesPath+"dx200_dy1_avec_2couches.sauve")
+meshTest.append("")
+fieldTest.append("")
+
+testExecfiles.append("test_gibi_driver")
+rootFileTest.append("elle_2D_QT_10x10")
+argListTest.append(filesPath+"elle_2D_QT_10x10.sauve")
+meshTest.append("")
+fieldTest.append("")
+
+testExecfiles.append("test_gibi_driver")
+rootFileTest.append("elle_2D_QT_2x2")
+argListTest.append(filesPath+"elle_2D_QT_2x2.sauve")
+meshTest.append("")
+fieldTest.append("")
+
+testExecfiles.append("test_gibi_driver")
+rootFileTest.append("elle_2D_QT_40x40")
+argListTest.append(filesPath+"elle_2D_QT_40x40.sauve")
+meshTest.append("")
+fieldTest.append("")
+
+testExecfiles.append("test_gibi_driver")
+rootFileTest.append("elle_2D_QT_4x4")
+argListTest.append(filesPath+"elle_2D_QT_4x4.sauve")
+meshTest.append("")
+fieldTest.append("")
+
+testExecfiles.append("test_gibi_driver")
+rootFileTest.append("elle_3D_HPr_10x10x10")
+argListTest.append(filesPath+"elle_3D_HPr_10x10x10.sauve")
+meshTest.append("")
+fieldTest.append("")
+
+testExecfiles.append("test_gibi_driver")
+rootFileTest.append("elle_3D_HPr_2x2x2")
+argListTest.append(filesPath+"elle_3D_HPr_2x2x2.sauve")
+meshTest.append("")
+fieldTest.append("")
+
+testExecfiles.append("test_gibi_driver")
+rootFileTest.append("elle_3D_HPr_4x4x4")
+argListTest.append(filesPath+"elle_3D_HPr_4x4x4.sauve")
+meshTest.append("")
+fieldTest.append("")
+
+testExecfiles.append("test_gibi_driver")
+rootFileTest.append("inclusion_2d_raf")
+argListTest.append(filesPath+"inclusion_2d_raf.sauve")
+meshTest.append("")
+fieldTest.append("")
+
+testExecfiles.append("test_gibi_driver")
+rootFileTest.append("inclusion_2d")
+argListTest.append(filesPath+"inclusion_2d.sauve")
+meshTest.append("")
+fieldTest.append("")
+
+testExecfiles.append("test_gibi_driver")
+rootFileTest.append("mail_ktest1-3-hexa")
+argListTest.append(filesPath+"mail_ktest1-3-hexa.sauve")
+meshTest.append("")
+fieldTest.append("")
+
+testExecfiles.append("test_gibi_driver")
+rootFileTest.append("mail_ktest1-3-tetra")
+argListTest.append(filesPath+"mail_ktest1-3-tetra.sauve")
+meshTest.append("")
+fieldTest.append("")
+
+testExecfiles.append("test_gibi_driver")
+rootFileTest.append("mail_ktest3-1")
+argListTest.append(filesPath+"mail_ktest3-1.sauve")
+meshTest.append("")
+fieldTest.append("")
+
+testExecfiles.append("test_gibi_driver")
+rootFileTest.append("mail_ktest3-2")
+argListTest.append(filesPath+"mail_ktest3-2.sauve")
+meshTest.append("")
+fieldTest.append("")
+
+testExecfiles.append("test_gibi_driver")
+rootFileTest.append("maillage_andra2_100elts")
+argListTest.append(filesPath+"maillage_andra2_100elts.sauve")
+meshTest.append("")
+fieldTest.append("")
+
+testExecfiles.append("test_gibi_driver")
+rootFileTest.append("maillage_cas2_2d")
+argListTest.append(filesPath+"maillage_cas2_2d.sauve")
+meshTest.append("")
+fieldTest.append("")
+
+testExecfiles.append("test_gibi_driver")
+rootFileTest.append("maillage_cas4_234elts")
+argListTest.append(filesPath+"maillage_cas4_234elts.sauve")
+meshTest.append("")
+fieldTest.append("")
+
+testExecfiles.append("test_gibi_driver")
+rootFileTest.append("maillage_CHEMVAL_100elts")
+argListTest.append(filesPath+"maillage_CHEMVAL_100elts.sauve")
+meshTest.append("")
+fieldTest.append("")
+
+testExecfiles.append("test_gibi_driver")
+rootFileTest.append("maillage_CHEMVAL_40elts")
+argListTest.append(filesPath+"maillage_CHEMVAL_40elts.sauve")
+meshTest.append("")
+fieldTest.append("")
+
+testExecfiles.append("test_gibi_driver")
+rootFileTest.append("maillage_chemvalIV_cas1_100elts")
+argListTest.append(filesPath+"maillage_chemvalIV_cas1_100elts.sauve")
+meshTest.append("")
+fieldTest.append("")
+
+testExecfiles.append("test_gibi_driver")
+rootFileTest.append("maillage_chemvalIV_cas1_40elts")
+argListTest.append(filesPath+"maillage_chemvalIV_cas1_40elts.sauve")
+meshTest.append("")
+fieldTest.append("")
+
+testExecfiles.append("test_gibi_driver")
+rootFileTest.append("maill_mistra_elim")
+argListTest.append(filesPath+"maill_mistra_elim.sauve")
+meshTest.append("")
+fieldTest.append("")
+
+testExecfiles.append("test_gibi_driver")
+rootFileTest.append("mail_test1-1-qua")
+argListTest.append(filesPath+"mail_test1-1-qua.sauve")
+meshTest.append("")
+fieldTest.append("")
+
+testExecfiles.append("test_gibi_driver")
+rootFileTest.append("mail_test1-1-tri")
+argListTest.append(filesPath+"mail_test1-1-tri.sauve")
+meshTest.append("")
+fieldTest.append("")
+
+testExecfiles.append("test_gibi_driver")
+rootFileTest.append("mail_test1-2-qua")
+argListTest.append(filesPath+"mail_test1-2-qua.sauve")
+meshTest.append("")
+fieldTest.append("")
+
+testExecfiles.append("test_gibi_driver")
+rootFileTest.append("mail_test1-2-tri")
+argListTest.append(filesPath+"mail_test1-2-tri.sauve")
+meshTest.append("")
+fieldTest.append("")
+
+testExecfiles.append("test_gibi_driver")
+rootFileTest.append("mail-test1-4-1")
+argListTest.append(filesPath+"mail-test1-4-1.sauve")
+meshTest.append("")
+fieldTest.append("")
+
+testExecfiles.append("test_gibi_driver")
+rootFileTest.append("mail-test1-4-2")
+argListTest.append(filesPath+"mail-test1-4-2.sauve")
+meshTest.append("")
+fieldTest.append("")
+
+testExecfiles.append("test_porflow_driver")
+rootFileTest.append("boitenew")
+argListTest.append(filesPath+"boitenew.inp")
+meshTest.append("")
+fieldTest.append("")
+
+testExecfiles.append("test_porflow_driver")
+rootFileTest.append("Case1")
+argListTest.append(filesPath+"Case1.inp")
+meshTest.append("")
+fieldTest.append("")
+
+testExecfiles.append("test_porflow_driver")
+rootFileTest.append("cube")
+argListTest.append(filesPath+"cube.inp")
+meshTest.append("")
+fieldTest.append("")
+
+testExecfiles.append("test_porflow_driver")
+rootFileTest.append("test3")
+argListTest.append(filesPath+"test3.inp")
+meshTest.append("")
+fieldTest.append("")
+
+testExecfiles.append("test_porflow_driver")
+rootFileTest.append("titi")
+argListTest.append(filesPath+"titi.inp")
+meshTest.append("")
+fieldTest.append("")
+
+testExecfiles.append("test_copie_connectivity")
+rootFileTest.append("mesh")
+meshTest.append("Mesh 1")
+fieldTest.append("")
+argListTest.append(filesPath+"mesh.med" + " " + "'Mesh 1'")
+
+testExecfiles.append("test_copie_connectivity")
+rootFileTest.append("maillage_UniSegFam")
+meshTest.append("maillage_CHEMVAL_100elts")
+fieldTest.append("")
+argListTest.append(filesPath+"maillage_UniSegFam.med" + " " + "maillage_CHEMVAL_100elts")
+
+testExecfiles.append("test_copie_connectivity")
+rootFileTest.append("carre_en_quad4")
+meshTest.append("carre_en_quad4")
+fieldTest.append("")
+argListTest.append(filesPath+"carre_en_quad4.med" + " " + "carre_en_quad4")
+
+testExecfiles.append("test_copie_connectivity")
+rootFileTest.append("cube_hexa8")
+meshTest.append("CUBE_EN_HEXA8")
+fieldTest.append("")
+argListTest.append(filesPath+"cube_hexa8.med" + " " + "CUBE_EN_HEXA8")
+
+testExecfiles.append("test_copie_connectivity")
+rootFileTest.append("test19")
+meshTest.append("maa1")
+fieldTest.append("")
+argListTest.append(filesPath+"test19.med" + " " + "maa1")
+
+testExecfiles.append("test_copie_connectivity")
+rootFileTest.append("carre_en_quad4_seg2")
+meshTest.append("carre_en_quad4_seg2")
+fieldTest.append("")
+argListTest.append(filesPath+"carre_en_quad4_seg2.med" + " " + "carre_en_quad4_seg2")
+
+testExecfiles.append("test_copie_connectivity")
+rootFileTest.append("cube_hexa8_quad4")
+meshTest.append("CUBE_EN_HEXA8_QUAD4")
+fieldTest.append("")
+argListTest.append(filesPath+"cube_hexa8_quad4.med" + " " + "CUBE_EN_HEXA8_QUAD4")
+
+testExecfiles.append("test_copie_connectivity")
+rootFileTest.append("pointe")
+meshTest.append("maa1")
+fieldTest.append("")
+argListTest.append(filesPath+"pointe.med" + " " + "maa1")
+
+testExecfiles.append("test_copie_family")
+rootFileTest.append("mesh")
+meshTest.append("Mesh 1")
+fieldTest.append("")
+argListTest.append(filesPath+"mesh.med" + " " + "'Mesh 1'")
+
+testExecfiles.append("test_copie_family")
+rootFileTest.append("maillage_UniSegFam")
+meshTest.append("maillage_CHEMVAL_100elts")
+fieldTest.append("")
+argListTest.append(filesPath+"maillage_UniSegFam.med" + " " + "maillage_CHEMVAL_100elts")
+
+testExecfiles.append("test_copie_family")
+rootFileTest.append("carre_en_quad4")
+meshTest.append("carre_en_quad4")
+fieldTest.append("")
+argListTest.append(filesPath+"carre_en_quad4.med" + " " + "carre_en_quad4")
+
+testExecfiles.append("test_copie_family")
+rootFileTest.append("cube_hexa8")
+meshTest.append("CUBE_EN_HEXA8")
+fieldTest.append("")
+argListTest.append(filesPath+"cube_hexa8.med" + " " + "CUBE_EN_HEXA8")
+
+testExecfiles.append("test_copie_family")
+rootFileTest.append("test19")
+meshTest.append("maa1")
+fieldTest.append("")
+argListTest.append(filesPath+"test19.med" + " " + "maa1")
+
+testExecfiles.append("test_copie_family")
+rootFileTest.append("carre_en_quad4_seg2")
+meshTest.append("carre_en_quad4_seg2")
+fieldTest.append("")
+argListTest.append(filesPath+"carre_en_quad4_seg2.med" + " " + "carre_en_quad4_seg2")
+
+testExecfiles.append("test_copie_family")
+rootFileTest.append("cube_hexa8_quad4")
+meshTest.append("CUBE_EN_HEXA8_QUAD4")
+fieldTest.append("")
+argListTest.append(filesPath+"cube_hexa8_quad4.med" + " " + "CUBE_EN_HEXA8_QUAD4")
+
+testExecfiles.append("test_copie_family")
+rootFileTest.append("pointe")
+meshTest.append("maa1")
+fieldTest.append("")
+argListTest.append(filesPath+"pointe.med" + " " + "maa1")
+
+testExecfiles.append("test_copie_group")
+rootFileTest.append("mesh")
+meshTest.append("Mesh 1")
+fieldTest.append("")
+argListTest.append(filesPath+"mesh.med" + " " + "'Mesh 1'")
+
+testExecfiles.append("test_copie_group")
+rootFileTest.append("maillage_UniSegFam")
+meshTest.append("maillage_CHEMVAL_100elts")
+fieldTest.append("")
+argListTest.append(filesPath+"maillage_UniSegFam.med" + " " + "maillage_CHEMVAL_100elts")
+
+testExecfiles.append("test_copie_group")
+rootFileTest.append("carre_en_quad4")
+meshTest.append("carre_en_quad4")
+fieldTest.append("")
+argListTest.append(filesPath+"carre_en_quad4.med" + " " + "carre_en_quad4")
+
+testExecfiles.append("test_copie_group")
+rootFileTest.append("cube_hexa8")
+meshTest.append("CUBE_EN_HEXA8")
+fieldTest.append("")
+argListTest.append(filesPath+"cube_hexa8.med" + " " + "CUBE_EN_HEXA8")
+
+testExecfiles.append("test_copie_group")
+rootFileTest.append("test19")
+meshTest.append("maa1")
+fieldTest.append("")
+argListTest.append(filesPath+"test19.med" + " " + "maa1")
+
+testExecfiles.append("test_copie_group")
+rootFileTest.append("carre_en_quad4_seg2")
+meshTest.append("carre_en_quad4_seg2")
+fieldTest.append("")
+argListTest.append(filesPath+"carre_en_quad4_seg2.med" + " " + "carre_en_quad4_seg2")
+
+testExecfiles.append("test_copie_group")
+rootFileTest.append("cube_hexa8_quad4")
+meshTest.append("CUBE_EN_HEXA8_QUAD4")
+fieldTest.append("")
+argListTest.append(filesPath+"cube_hexa8_quad4.med" + " " + "CUBE_EN_HEXA8_QUAD4")
+
+testExecfiles.append("test_copie_group")
+rootFileTest.append("pointe")
+meshTest.append("maa1")
+fieldTest.append("")
+argListTest.append(filesPath+"pointe.med" + " " + "maa1")
+
+testExecfiles.append("test_copie_mesh")
+rootFileTest.append("mesh")
+meshTest.append("Mesh 1")
+fieldTest.append("")
+argListTest.append(filesPath+"mesh.med" + " " + "'Mesh 1'")
+
+testExecfiles.append("test_copie_mesh")
+rootFileTest.append("maillage_UniSegFam")
+meshTest.append("maillage_CHEMVAL_100elts")
+fieldTest.append("")
+argListTest.append(filesPath+"maillage_UniSegFam.med" + " " + "maillage_CHEMVAL_100elts")
+
+testExecfiles.append("test_copie_mesh")
+rootFileTest.append("carre_en_quad4")
+meshTest.append("carre_en_quad4")
+fieldTest.append("")
+argListTest.append(filesPath+"carre_en_quad4.med" + " " + "carre_en_quad4")
+
+testExecfiles.append("test_copie_mesh")
+rootFileTest.append("cube_hexa8")
+meshTest.append("CUBE_EN_HEXA8")
+fieldTest.append("")
+argListTest.append(filesPath+"cube_hexa8.med" + " " + "CUBE_EN_HEXA8")
+
+testExecfiles.append("test_copie_mesh")
+rootFileTest.append("test19")
+meshTest.append("maa1")
+fieldTest.append("")
+argListTest.append(filesPath+"test19.med" + " " + "maa1")
+
+testExecfiles.append("test_copie_mesh")
+rootFileTest.append("carre_en_quad4_seg2")
+meshTest.append("carre_en_quad4_seg2")
+fieldTest.append("")
+argListTest.append(filesPath+"carre_en_quad4_seg2.med" + " " + "carre_en_quad4_seg2")
+
+testExecfiles.append("test_copie_mesh")
+rootFileTest.append("cube_hexa8_quad4")
+meshTest.append("CUBE_EN_HEXA8_QUAD4")
+fieldTest.append("")
+argListTest.append(filesPath+"cube_hexa8_quad4.med" + " " + "CUBE_EN_HEXA8_QUAD4")
+
+testExecfiles.append("test_copie_mesh")
+rootFileTest.append("pointe")
+meshTest.append("maa1")
+fieldTest.append("")
+argListTest.append(filesPath+"pointe.med" + " " + "maa1")
+
+testExecfiles.append("test_copie_support")
+rootFileTest.append("mesh")
+meshTest.append("Mesh 1")
+fieldTest.append("")
+argListTest.append(filesPath+"mesh.med" + " " + "'Mesh 1'")
+
+testExecfiles.append("test_copie_support")
+rootFileTest.append("maillage_UniSegFam")
+meshTest.append("maillage_CHEMVAL_100elts")
+fieldTest.append("")
+argListTest.append(filesPath+"maillage_UniSegFam.med" + " " + "maillage_CHEMVAL_100elts")
+
+testExecfiles.append("test_copie_support")
+rootFileTest.append("carre_en_quad4")
+meshTest.append("carre_en_quad4")
+fieldTest.append("")
+argListTest.append(filesPath+"carre_en_quad4.med" + " " + "carre_en_quad4")
+
+testExecfiles.append("test_copie_support")
+rootFileTest.append("cube_hexa8")
+meshTest.append("CUBE_EN_HEXA8")
+fieldTest.append("")
+argListTest.append(filesPath+"cube_hexa8.med" + " " + "CUBE_EN_HEXA8")
+
+testExecfiles.append("test_copie_support")
+rootFileTest.append("test19")
+meshTest.append("maa1")
+fieldTest.append("")
+argListTest.append(filesPath+"test19.med" + " " + "maa1")
+
+testExecfiles.append("test_copie_support")
+rootFileTest.append("carre_en_quad4_seg2")
+meshTest.append("carre_en_quad4_seg2")
+fieldTest.append("")
+argListTest.append(filesPath+"carre_en_quad4_seg2.med" + " " + "carre_en_quad4_seg2")
+
+testExecfiles.append("test_copie_support")
+rootFileTest.append("cube_hexa8_quad4")
+meshTest.append("CUBE_EN_HEXA8_QUAD4")
+fieldTest.append("")
+argListTest.append(filesPath+"cube_hexa8_quad4.med" + " " + "CUBE_EN_HEXA8_QUAD4")
+
+testExecfiles.append("test_copie_support")
+rootFileTest.append("pointe")
+meshTest.append("maa1")
+fieldTest.append("")
+argListTest.append(filesPath+"pointe.med" + " " + "maa1")
+
+###############################################################################
+
+nbOfTests = len(testExecfiles)
+
+print "Running all test programs with several arguments ... total = ",nbOfTests
+
+testOutfiles = []
+testErrfiles = []
+
+for i in range(nbOfTests):
+ if (rootFileTest[i] == ""):
+ testOutfiles.append(testExecfiles[i] + ".out")
+ else:
+ if (meshTest[i] == ""):
+ testOutfiles.append(testExecfiles[i]+ "_" + rootFileTest[i] + ".out")
+ else:
+ if (fieldTest[i] == ""):
+ meshName = string.replace(meshTest[i]," ","_")
+ testOutfiles.append(testExecfiles[i]+ "_" + rootFileTest[i] + "_" + meshName + ".out")
+ else:
+ meshName = string.replace(meshTest[i]," ","_")
+ fieldName = string.replace(fieldTest[i]," ","_")
+ testOutfiles.append(testExecfiles[i]+ "_" + rootFileTest[i] + "_" + meshName + "_" + fieldName + ".out")
+ testErrfiles.append(testExecfiles[i] + ".err")
+
+for i in range(nbOfTests):
+ aCommand = testExecfiles[i] + " " + argListTest[i] + " > " + testOutfiles[i] + " 2> " + testErrfiles[i]
+ status = os.system(aCommand)
+ if (status != 0):
+ print "problem with the command ", aCommand
+
+print "END of the Pyhton script ..... Ctrl D to exit"
filesPath=os.environ["MED_ROOT_DIR"]
filesPath=filesPath+"/share/salome/resources/"
+os.system("rm -rf "+filesPath+"*_test.*")
+
files = []
meshNameFiles = []
files.append("mesh.med")
meshNameFiles.append("Mesh 1")
+files.append("mesh_import22.med")
+meshNameFiles.append("Mesh 1")
+
#
# from other source including LGLS ones
#
files.append("maillage_UniSegFam.med")
meshNameFiles.append("maillage_CHEMVAL_100elts")
+files.append("maillage_UniSegFam_import22.med")
+meshNameFiles.append("maillage_CHEMVAL_100elts")
+
files.append("carre_en_quad4.med")
meshNameFiles.append("carre_en_quad4")
+files.append("carre_en_quad4_import22.med")
+meshNameFiles.append("carre_en_quad4")
+
files.append("cube_hexa8.med")
meshNameFiles.append("CUBE_EN_HEXA8")
+files.append("cube_hexa8_import22.med")
+meshNameFiles.append("CUBE_EN_HEXA8")
+
files.append("test19.med")
meshNameFiles.append("CartGrid")
files.append("test19.med")
meshNameFiles.append("bodyfitted")
-files.append("test19.med")
-meshNameFiles.append("maa1")
+##files.append("test19.med")
+##meshNameFiles.append("maa1")
files.append("carre_en_quad4_seg2.med")
meshNameFiles.append("carre_en_quad4_seg2")
+files.append("carre_en_quad4_seg2_import22.med")
+meshNameFiles.append("carre_en_quad4_seg2")
+
files.append("cube_hexa8_quad4.med")
meshNameFiles.append("CUBE_EN_HEXA8_QUAD4")
+files.append("cube_hexa8_quad4_import22.med")
+meshNameFiles.append("CUBE_EN_HEXA8_QUAD4")
+
files.append("pointe.med")
meshNameFiles.append("maa1")
+files.append("pointe_import22.med")
+meshNameFiles.append("maa1")
+
files.append("Mistrat.med")
meshNameFiles.append("Mistrat_Hexa")
-## files.append("TimeStamps.med")
-## meshNameFiles.append("dom")
+files.append("Mistrat_import22.med")
+meshNameFiles.append("Mistrat_Hexa")
+
+##files.append("TimeStamps.med")
+##meshNameFiles.append("dom")
#
# Castem or Gibi file list
for k in range(1,lenDecompFileM1):
rootFile = rootFile + "." + decompFile[k]
- medFileName = rootFile + "_test.med"
+ medV21FileName = rootFile + "V21_test.med"
+ medV22FileName = rootFile + "V22_test.med"
vtkFileName = rootFile + "_test.vtk"
try:
print "Saving in file the mesh under the med and vtk format"
- print "Med file = ",medFileName
+ medFileVersion = getMedFileVersionForWriting()
+ print "Med File Version For Writing ",medFileVersion
+ print "Med V21 file = ",medV21FileName
+ print "Med V22 file = ",medV22FileName
print "vtk file = ",vtkFileName
- idMed = mesh.addDriver(MED_DRIVER,medFileName,mesh.getName(),MED_REMP)
- mesh.write(idMed)
+
+ if (medFileVersion == V22):
+ setMedFileVersionForWriting(V21)
+
+ idMedV21 = mesh.addDriver(MED_DRIVER,medV21FileName,mesh.getName(),MED_REMP)
+ mesh.write(idMedV21)
+
+ if (medFileVersion == V21):
+ setMedFileVersionForWriting(V22)
+
+ idMedV22 = mesh.addDriver(MED_DRIVER,medV22FileName,mesh.getName(),MED_REMP)
+ mesh.write(idMedV22)
idVtk = mesh.addDriver(VTK_DRIVER,vtkFileName,mesh.getName())
mesh.write(idVtk)
print ""
print "Saving in file the cell barycenter field under the med and vtk format"
- print "Med file = ",medFileName
+ medFileVersion = getMedFileVersionForWriting()
+ print "Med File Version For Writing ",medFileVersion
+
+ print "Med V21 file = ",medV21FileName
+ print "Med V22 file = ",medV22FileName
print "vtk file = ",vtkFileName
- idMed = barycenter.addDriver(MED_DRIVER,medFileName,barycenter.getName())
- barycenter.write(idMed)
+
+ if (medFileVersion == V22):
+ setMedFileVersionForWriting(V21)
+
+ idMedV21 = barycenter.addDriver(MED_DRIVER,medV21FileName,barycenter.getName())
+ barycenter.write(idMedV21)
+
+ if (medFileVersion == V21):
+ setMedFileVersionForWriting(V22)
+
+ idMedV22 = barycenter.addDriver(MED_DRIVER,medV22FileName,barycenter.getName())
+ barycenter.write(idMedV22)
idVtk = barycenter.addDriver(VTK_DRIVER,vtkFileName,barycenter.getName())
barycenter.write(idVtk)
print ""
print "Saving in file the cell volume field under the med and vtk format"
- print "Med file = ",medFileName
+ medFileVersion = getMedFileVersionForWriting()
+ print "Med File Version For Writing ",medFileVersion
+ print "Med V21 file = ",medV21FileName
+ print "Med V22 file = ",medV22FileName
print "vtk file = ",vtkFileName
- idMed = volume.addDriver(MED_DRIVER,medFileName,volume.getName())
- volume.write(idMed)
+
+ if (medFileVersion == V22):
+ setMedFileVersionForWriting(V21)
+
+ idMedV21 = volume.addDriver(MED_DRIVER,medV21FileName,volume.getName())
+ volume.write(idMedV21)
+
+ if (medFileVersion == V21):
+ setMedFileVersionForWriting(V22)
+
+ idMedV22 = volume.addDriver(MED_DRIVER,medV22FileName,volume.getName())
+ volume.write(idMedV22)
idVtk = volume.addDriver(VTK_DRIVER,vtkFileName,volume.getName())
volume.write(idVtk)
print ""
print "Saving in file the face normal field under the med format"
- print "Med file = ",medFileName
- idMed = normal.addDriver(MED_DRIVER,medFileName,normal.getName())
- normal.write(idMed)
+ medFileVersion = getMedFileVersionForWriting()
+ print "Med File Version For Writing ",medFileVersion
+ print "Med V21 file = ",medV21FileName
+ print "Med V22 file = ",medV22FileName
+
+ if (medFileVersion == V22):
+ setMedFileVersionForWriting(V21)
+
+ idMedV21 = normal.addDriver(MED_DRIVER,medV21FileName,normal.getName())
+ normal.write(idMedV21)
+
+ if (medFileVersion == V21):
+ setMedFileVersionForWriting(V22)
+
+ idMedV22 = normal.addDriver(MED_DRIVER,medV22FileName,normal.getName())
+ normal.write(idMedV22)
+
print "but not in vtk format because vtk does not offer the possibility to view a field on edges or faces"
print ""
print ""
print "Saving in file the cell area field under the med and vtk format"
- print "Med file = ",medFileName
+ medFileVersion = getMedFileVersionForWriting()
+ print "Med File Version For Writing ",medFileVersion
+ print "Med V21 file = ",medV21FileName
+ print "Med V22 file = ",medV22FileName
print "vtk file = ",vtkFileName
- idMed = area.addDriver(MED_DRIVER,medFileName,area.getName())
- area.write(idMed)
+
+
+ if (medFileVersion == V22):
+ setMedFileVersionForWriting(V21)
+
+ idMedV21 = area.addDriver(MED_DRIVER,medV21FileName,area.getName())
+ area.write(idMedV21)
+
+
+ if (medFileVersion == V21):
+ setMedFileVersionForWriting(V22)
+
+ idMedV22 = area.addDriver(MED_DRIVER,medV22FileName,area.getName())
+ area.write(idMedV22)
idVtk = area.addDriver(VTK_DRIVER,vtkFileName,area.getName())
area.write(idVtk)
print ""
print "Saving in file the face normal field under the med format"
- print "Med file = ",medFileName
- idMed = normal.addDriver(MED_DRIVER,medFileName,normal.getName())
- normal.write(idMed)
+ medFileVersion = getMedFileVersionForWriting()
+ print "Med File Version For Writing ",medFileVersion
+ print "Med V21 file = ",medV21FileName
+ print "Med V22 file = ",medV22FileName
+
+ if (medFileVersion == V22):
+ setMedFileVersionForWriting(V21)
+
+ idMedV21 = normal.addDriver(MED_DRIVER,medV21FileName,normal.getName())
+ normal.write(idMedV21)
+
+
+ if (medFileVersion == V21):
+ setMedFileVersionForWriting(V22)
+
+ idMedV22 = normal.addDriver(MED_DRIVER,medV22FileName,normal.getName())
+ normal.write(idMedV22)
+
print "but no in vtk format because vtk does not offer the possibility to view a field on edges or faces"
print ""
print ""
- mesh_name = md.getMeshName(0)
+# mesh_name = md.getMeshName(0)
+ mesh_name = meshNameFiles[i]
mesh = md.getMesh(mesh_name)
mesh.read()
spaceDim = mesh.getSpaceDimension()
filePath=os.environ["MED_ROOT_DIR"]
filePath=filePath+"/share/salome/resources/"
porflowFile = "boitenew.inp"
-mesh1Name = string.split(gibiFile,".")[0]+"_fromPorflowDriver"
+mesh1Name = string.split(porflowFile,".")[0]+"_fromPorflowDriver"
porflowFile = filePath + porflowFile
medFile = string.split(porflowFile,".")[0]+"_fromPorflowDriver.med"
@COMMENCE@
ifeq (@WITHIHM@,yes)
-SUBDIRS = MEDMEM MEDMEM_SWIG MEDMEM_I MED MEDGUI MedCorba_Swig MED_SWIG MedClient INTERPOLATION
+SUBDIRS = INTERPOLATION MEDMEM MEDMEM_SWIG MEDMEM_I MED MEDGUI MedCorba_Swig MED_SWIG MedClient
endif
ifeq (@WITHIHM@,no)
-SUBDIRS = MEDMEM MEDMEM_SWIG MEDMEM_I MED MedCorba_Swig MED_SWIG MedClient INTERPOLATION
+SUBDIRS = INTERPOLATION MEDMEM MEDMEM_SWIG MEDMEM_I MED MedCorba_Swig MED_SWIG MedClient
endif
int kT = Count[iT+1]-Count[iT];
SCRUTE(kT);
- pC=(int *)ReceiverFactory::getValue(IOR_Mesh->getSenderForConnectivity(MED_FULL_INTERLACE, MED_NODAL, Entity, T[iT]),nC);
+ SALOME::SenderInt_var senderForConnectivity=IOR_Mesh->getSenderForConnectivity(MED_FULL_INTERLACE, MED_NODAL, Entity, T[iT]);
+ pC=ReceiverFactory::getValue(senderForConnectivity,nC);
SCRUTE(nC);
ASSERT(nC == (T[iT]%100) * kT);
long nN = IOR_Mesh->getNumberOfNodes();
double *tC;
long nC;
- tC=(double *)ReceiverFactory::getValue(IOR_Mesh->getSenderForCoordinates(MED_FULL_INTERLACE),nC);
+
+ SALOME::SenderDouble_var senderForCoords=IOR_Mesh->getSenderForCoordinates(MED_FULL_INTERLACE);
+ tC=ReceiverFactory::getValue(senderForCoords,nC);
+
ASSERT(nC == (getSpaceDimension() * nN));
MEDARRAY<double> mC(tC, getSpaceDimension(), nN,MED_FULL_INTERLACE,true);
-template<class T1,class T2>
-FIELDClient<T1,T2>::FIELDClient(typename T2::_ptr_type ptrCorba,MEDMEM::SUPPORT * S):_fieldPtr(T2::_duplicate(ptrCorba)),_ownSupport(false)
+template<class T>
+FIELDClient<T>::FIELDClient(typename MapCppFieldServ<T>::FieldPtrType ptrCorba,MEDMEM::SUPPORT * S):_fieldPtr(MapCppFieldServ<T>::FieldGlobalType::_duplicate(ptrCorba)),_refCounter(1)
{
if (!S)
- {
- _ownSupport=true;
- S=new MEDMEM::SUPPORTClient(_fieldPtr->getSupport());
- }
- MEDMEM::FIELD<T1>::setSupport(S);
-
+ MEDMEM::FIELD<T>::_support=new MEDMEM::SUPPORTClient(_fieldPtr->getSupport());
+ else
+ MEDMEM::FIELD<T>::setSupport(S);
+
setName(_fieldPtr->getName());
- MEDMEM::FIELD<T1>::setDescription(_fieldPtr->getDescription());
+ MEDMEM::FIELD<T>::setDescription(_fieldPtr->getDescription());
int nc = _fieldPtr->getNumberOfComponents();
- MEDMEM::FIELD<T1>::setNumberOfComponents(nc);
+ MEDMEM::FIELD<T>::setNumberOfComponents(nc);
- MEDMEM::FIELD<T1>::setNumberOfValues( S->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS));
+ MEDMEM::FIELD<T>::setNumberOfValues( MEDMEM::FIELD<T>::_support->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS));
string * _s = new string[nc];
s = _fieldPtr->getComponentsNames();
for (int i=0; i<nc; i++)
_s[i] = s[i];
- MEDMEM::FIELD<T1>::setComponentsNames(_s);
+ MEDMEM::FIELD<T>::setComponentsNames(_s);
s = _fieldPtr->getComponentsDescriptions();
for (int i=0; i<nc; i++)
_s[i] = s[i];
- MEDMEM::FIELD<T1>::setComponentsDescriptions(_s);
+ MEDMEM::FIELD<T>::setComponentsDescriptions(_s);
s = _fieldPtr->getComponentsUnits();
for (int i=0; i<nc; i++)
_s[i] = s[i];
- MEDMEM::FIELD<T1>::setMEDComponentsUnits(_s);
+ MEDMEM::FIELD<T>::setMEDComponentsUnits(_s);
delete [] _s;
fillCopy();
}
-template<class T1,class T2>
-void FIELDClient<T1,T2>::fillCopy()
+template<class T>
+void FIELDClient<T>::fillCopy()
{
//setValueType(typeChamps); WARNING TO DO.....
//setValueType(_fieldPtr->getValueType());
long n;
- T1 *v = (T1 *)ReceiverFactory::getValue(_fieldPtr->getSenderForValue(MED_EN::MED_FULL_INTERLACE),n);
- MEDMEM::MEDARRAY<T1> * M = new MEDMEM::MEDARRAY<T1>(v, MEDMEM::FIELD<T1>::getNumberOfComponents(),MEDMEM::FIELD<T1>::getNumberOfValues(),MED_EN::MED_FULL_INTERLACE,true,true);
+ typename mapCppSender<T>::SenderVarType sender=_fieldPtr->getSenderForValue(MED_EN::MED_FULL_INTERLACE);
+ T *v = (T *)ReceiverFactory::getValue(sender,n);
+ MEDMEM::MEDARRAY<T> * M = new MEDMEM::MEDARRAY<T>(v, MEDMEM::FIELD<T>::getNumberOfComponents(),MEDMEM::FIELD<T>::getNumberOfValues(),MED_EN::MED_FULL_INTERLACE,true,true);
setValue(M);
}
-template<class T1,class T2>
-FIELDClient<T1,T2>::~FIELDClient()
+template<class T>
+FIELDClient<T>::~FIELDClient()
{
_fieldPtr->release();
CORBA::release(_fieldPtr);
- if(_ownSupport)
- delete MEDMEM::FIELD<T1>::_support;
+ if(FIELD<T>::_support)
+ FIELD<T>::_support->removeReference();
}
#include "MEDMEM_Field.hxx"
#include "SUPPORTClient.hxx"
#include "ReceiverFactory.hxx"
+#include "SenderFactory.hxx"
#include CORBA_CLIENT_HEADER(MED)
-//exemple _FIELDClient<double,FIELDDOUBLE_ptr>
-//_FIELDClient<int,FIELDINT_ptr>
-template<class T1,class T2>
-class FIELDClient : public MEDMEM::FIELD<T1>
+template<class T>
+struct MapCppFieldServ {
+ typedef T FieldPtrType;
+ typedef T FieldGlobalType;
+};
+
+template<>
+struct MapCppFieldServ<int> {
+ typedef SALOME_MED::FIELDINT_ptr FieldPtrType;
+ typedef SALOME_MED::FIELDINT FieldGlobalType;
+};
+
+template<>
+struct MapCppFieldServ<double> {
+ typedef SALOME_MED::FIELDDOUBLE_ptr FieldPtrType;
+ typedef SALOME_MED::FIELDDOUBLE FieldGlobalType;
+};
+
+namespace MEDMEM{
+
+template<class T>
+class FIELDClient : public MEDMEM::FIELD<T>
{
private:
- typename T2::_ptr_type _fieldPtr;
- bool _ownSupport;
+ typename MapCppFieldServ<T>::FieldPtrType _fieldPtr;
+ int _refCounter;
public:
- FIELDClient(typename T2::_ptr_type ptrCorba,MEDMEM::SUPPORT * S = NULL);
+ FIELDClient(typename MapCppFieldServ<T>::FieldPtrType ptrCorba,MEDMEM::SUPPORT * S = NULL);
~FIELDClient();
private:
void fillCopy();
#include "FIELDClient.cxx"
+}
#endif
#include "FIELDDOUBLEClient.hxx"
+namespace MEDMEM{
//=============================================================================
/*!
//=============================================================================
FIELDDOUBLEClient::FIELDDOUBLEClient(SALOME_MED::FIELDDOUBLE_ptr ptrCorba,
MEDMEM::SUPPORT * S) :
- FIELDClient<double,SALOME_MED::FIELDDOUBLE>(ptrCorba,S)
+ FIELDClient<double>(ptrCorba,S)
{
BEGIN_OF("Constructor with arguments (for Python API) FIELDDOUBLEClient");
END_OF("Default Destructor (for Python API) FIELDDOUBLEClient");
}
+
+}
#include "FIELDClient.hxx"
+namespace MEDMEM{
+
class FIELDDOUBLEClient :
- public FIELDClient<double,SALOME_MED::FIELDDOUBLE>
+ public FIELDClient<double>
{
public:
FIELDDOUBLEClient(SALOME_MED::FIELDDOUBLE_ptr ptrCorba,
~FIELDDOUBLEClient();
};
+}
#endif
#include "FIELDINTClient.hxx"
-
+namespace MEDMEM{
+
//=============================================================================
/*!
* Constructor with arguments
//=============================================================================
FIELDINTClient::FIELDINTClient(SALOME_MED::FIELDINT_ptr ptrCorba,
MEDMEM::SUPPORT * S) :
- FIELDClient<int,SALOME_MED::FIELDINT>(ptrCorba,S)
+ FIELDClient<int>(ptrCorba,S)
{
BEGIN_OF("Constructor with arguments (for Python API) FIELDINTClient");
END_OF("Default Destructor (for Python API) FIELDINTClient");
}
+
+}
#include "FIELDClient.hxx"
+namespace MEDMEM{
class FIELDINTClient :
- public FIELDClient<int,SALOME_MED::FIELDINT>
+ public FIELDClient<int>
{
public:
FIELDINTClient(SALOME_MED::FIELDINT_ptr ptrCorba,
MEDMEM::SUPPORT * S = NULL);
~FIELDINTClient();
};
-
+}
#endif
//=============================================================================
MESHClient::MESHClient(const SALOME_MED::MESH_ptr m) :
- MESH(),
+ MESH(), _refCounter(1),
IOR_Mesh(SALOME_MED::MESH::_duplicate(m)),
_complete(false)
END_OF("MESHClient::fillCopy()");
}
+//=============================================================================
+/*!
+ * Test equality between 2 MESHClients.
+ */
+//=============================================================================
+bool MESHClient::operator==(const MESH& other) const
+{
+ BEGIN_OF("MESHClient::operator==");
+ const MESHClient* otherClt=dynamic_cast<const MESHClient *>(&other);
+ if(otherClt)
+ {
+ if(this==otherClt)
+ {
+ return true;
+ }
+ return IOR_Mesh->areEquals(otherClt->IOR_Mesh);
+ }
+ return false;
+}
+
//=============================================================================
/*!
* Destructeur
END_OF("MESHClient::~MESHClient()");
}
+//=============================================================================
+/*!
+ * For refCounter
+ */
+//=============================================================================
+
+void MESHClient::addReference() const
+{
+ _refCounter++;
+}
+
+//=============================================================================
+/*!
+ * For refCounter
+ */
+//=============================================================================
+
+void MESHClient::removeReference() const
+{
+ if (--_refCounter <= 0)
+ {
+ delete this;
+ }
+}
mutable bool _complete;
+ mutable int _refCounter;
public :
MESHClient(const SALOME_MED::MESH_ptr m);
-
- virtual ~MESHClient();
+ virtual bool operator==(const MESH& other) const;
void blankCopy();
void fillCopy();
+ virtual void addReference() const;
+ virtual void removeReference() const;
+private:
+ virtual ~MESHClient();
};
}
FIELDINTClient.hxx \
libMEDClient.i
+ifeq (@SWIG_VERSION@, 1.3.21)
+SWIG_DEF = libMEDClient.i dummy.i
+
+dummy_wrap.cxx: libMEDClient_wrap.cxx
+ sed -e 's/SwigValueWrapper< vector<FAMILY \* > >/vector<FAMILY \* >/g' libMEDClient_wrap.cxx > toto
+ mv toto libMEDClient_wrap.cxx
+ sed -e 's/SwigValueWrapper< vector<SUPPORT \* > const >/vector<SUPPORT \* >/g' libMEDClient_wrap.cxx > toto
+ mv toto libMEDClient_wrap.cxx
+ touch dummy_wrap.cxx
+else
SWIG_DEF = libMEDClient.i
+endif
EXPORT_PYSCRIPTS = libMEDClient.py
SALOMEDS_Attributes.idl \
SALOME_Exception.idl \
SALOME_Comm.idl \
- MED.idl
+ MED.idl \
+ SALOME_GenericObj.idl
# Executables targets
BIN_SRC =
SUPPORTClient::SUPPORTClient(const SALOME_MED::SUPPORT_ptr S,
MESH * M) :
SUPPORT(),
- IOR_Support(SALOME_MED::SUPPORT::_duplicate(S)),
- _ownMesh(false)
+ IOR_Support(SALOME_MED::SUPPORT::_duplicate(S)),_refCounter(1)
{
BEGIN_OF("SUPPORTClient::SUPPORTClient(SALOME_MED::SUPPORT_ptr m)");
else
{
_mesh=new MESHClient(IOR_Support->getMesh());
- _ownMesh=true;
}
blankCopy();
SCRUTE(_totalNumberOfElements);
_complete_support = false;
+ //Gauss points settings
+ _numberOfGaussPoint = new int[_numberOfGeometricType];
+ for (int i=0;i<_numberOfGeometricType;i++)
+ _numberOfGaussPoint[i] = 1 ;
}
catch( const CORBA::Exception &ex )
{
const int * index, * value;
long n_index, n_value;
-
- value=(const int *)ReceiverFactory::getValue(IOR_Support->getSenderForNumber(MED_ALL_ELEMENTS),n_value);
- index=(const int *)ReceiverFactory::getValue(IOR_Support->getSenderForNumberIndex(),n_index);
+
+ SALOME::SenderInt_var senderForValue=IOR_Support->getSenderForNumber(MED_ALL_ELEMENTS);
+ value=(const int *)ReceiverFactory::getValue(senderForValue,n_value);
+ SALOME::SenderInt_var senderForIndex=IOR_Support->getSenderForNumberIndex();
+ index=(const int *)ReceiverFactory::getValue(senderForIndex,n_index);
SCRUTE(n_index);
SCRUTE(n_value);
{
BEGIN_OF("SUPPORTClient::~SUPPORTClient");
IOR_Support->release();
- if(_ownMesh)
- delete _mesh;
+ if(_mesh)
+ _mesh->removeReference();
END_OF("SUPPORTClient::~SUPPORTClient");
}
return n;
}
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+void SUPPORTClient::addReference() const
+{
+ _refCounter++;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+void SUPPORTClient::removeReference() const
+{
+ if (--_refCounter <= 0)
+ {
+ delete this;
+ }
+}
const SALOME_MED::SUPPORT_var IOR_Support;
- bool _ownMesh;
-
mutable bool _complete_support;
+ mutable int _refCounter;
+
+protected:
+
+ virtual ~SUPPORTClient();
+
public :
SUPPORTClient(const SALOME_MED::SUPPORT_ptr S,
MESH * M = NULL);
- virtual ~SUPPORTClient();
void blankCopy();
void fillCopy();
const throw (MEDEXCEPTION);
const int * getNumberIndex()
const throw (MEDEXCEPTION);
-
+ void addReference() const;
+ void removeReference() const;
};
}
#endif
+
public:
MESHClient(const SALOME_MED::MESH_ptr m);
- virtual ~MESHClient();
void blankCopy();
void fillCopy();
-
+ %extend {
+ ~MESHClient(){
+ self->removeReference();
+ }
+ }
};
class SUPPORTClient : public SUPPORT {
SUPPORTClient(const SALOME_MED::SUPPORT_ptr S,
MESH * M = NULL);
- virtual ~SUPPORTClient();
void blankCopy();
void fillCopy();
+ %extend {
+ ~SUPPORTClient() {
+ self->removeReference();
+ }
+ }
};
LIB = libCompo2cmodule.la
LIB_SRC = Compo2.cxx
-LIB_CLIENT_IDL= SALOME_Component.idl SALOMEDS.idl SALOMEDS_Attributes.idl SALOME_Exception.idl SALOME_Comm.idl MED.idl
+LIB_CLIENT_IDL= SALOME_Component.idl SALOMEDS.idl SALOMEDS_Attributes.idl SALOME_Exception.idl SALOME_Comm.idl MED.idl SALOME_GenericObj.idl
LDFLAGS= -L$(top_builddir)/lib/salome
LDFLAGSFORBIN= -L$(top_builddir)/lib/salome
# Executables targets
+ifeq (@SWIG_VERSION@, 1.3.21)
+SWIG_DEF = libCompo2.i dummy.i
+
+dummy_wrap.cxx: libCompo2_wrap.cxx
+ sed -e 's/SwigValueWrapper< vector<FAMILY \* > >/vector<FAMILY \* >/g' libCompo2_wrap.cxx > toto
+ mv toto libCompo2_wrap.cxx
+ sed -e 's/SwigValueWrapper< vector<SUPPORT \* > const >/vector<SUPPORT \* >/g' libCompo2_wrap.cxx > toto
+ mv toto libCompo2_wrap.cxx
+ touch dummy_wrap.cxx
+else
SWIG_DEF = libCompo2.i
+endif
MED.hh MEDSK.cc: MED.idl
omniidl -bcxx -Wbtp -I$(top_builddir)/idl -I${KERNEL_ROOT_DIR}/idl/salome $^
LIB_SRC =
+ifeq (@SWIG_VERSION@, 1.3.21)
+SWIG_DEF = libMedCorba_Swig.i dummy.i
+
+dummy_wrap.cxx: libMedCorba_Swig_wrap.cxx
+ sed -e 's/SwigValueWrapper< vector<FAMILY \* > >/vector<FAMILY \* >/g' libMedCorba_Swig_wrap.cxx > toto
+ mv toto libMedCorba_Swig_wrap.cxx
+ sed -e 's/SwigValueWrapper< vector<SUPPORT \* > const >/vector<SUPPORT \* >/g' libMedCorba_Swig_wrap.cxx > toto
+ mv toto libMedCorba_Swig_wrap.cxx
+ touch dummy_wrap.cxx
+else
SWIG_DEF = libMedCorba_Swig.i
+endif
LIB_SERVER_IDL = MED.idl
-LIB_CLIENT_IDL= SALOME_Component.idl SALOMEDS.idl SALOMEDS_Attributes.idl SALOME_Exception.idl SALOME_Comm.idl
+LIB_CLIENT_IDL= SALOME_Component.idl SALOMEDS.idl SALOMEDS_Attributes.idl SALOME_Exception.idl SALOME_Comm.idl SALOME_GenericObj.idl
EXPORT_PYSCRIPTS = libMedCorba_Swig.py medcorba_test.py batchmode_medcorba_test.py batchmode_medcorba_test1.py