-This is the version 3.1.0 of MED
+This is the version 3.2.0a1 of MED
Compatible with :
- KERNEL 3.1.0
- SALOMEGUI 3.1.0
elle_3D_HPr_10x10x10_2.med \
elle_3D_HPr_2x2x2_2.med \
elle_3D_HPr_4x4x4_2.med \
+test_2D.med \
Darcy3_3D_H_10x10x10.sauve \
dx200_dy1_avec_2couches.sauve \
elle_2D_QT_10x10.sauve \
ac_cc_warnings.m4 check_qt.m4 check_swig.m4
endif
-$(top_srcdir)/aclocal.m4: $(ACLOCAL_SRC:%=$(top_srcdir)/salome_adm/unix/config_files/%)
- cd $(top_srcdir) ; aclocal --acdir=adm_local/unix/config_files -I $(top_srcdir)/salome_adm/unix/config_files
+$(top_srcdir)/aclocal.m4: $(ACLOCAL_SRC:%=@KERNEL_ROOT_DIR@/salome_adm/unix/config_files/%)
+ cd $(top_srcdir) ; aclocal --acdir=adm_local/unix/config_files -I @KERNEL_ROOT_DIR@/salome_adm/unix/config_files
-THIS IS SALOME - MED VERSION: 3.1.0
+THIS IS SALOME - MED VERSION: 3.2.0a1
CHECK_MSG2QM
-echo
-echo ---------------------------------------------
-echo Testing html generators
-echo ---------------------------------------------
-echo
-
-CHECK_HTML_GENERATORS
-
}
else
{
}
fi # MED_WITH_KERNEL
+echo
+echo ---------------------------------------------
+echo Testing html generators
+echo ---------------------------------------------
+echo
+
+CHECK_HTML_GENERATORS
+
echo
echo ---------------------------------------------
echo Summary
// How many Value :
int NumberOfValue = mySupport->getNumberOfElements(MED_ALL_ELEMENTS);
// Value
- const double * Value = myField.getValue(MED_FULL_INTERLACE);
+ const double * Value = myField.getValue();
for(int i=0; i<NumberOfValue; i++) {
for(int j=0; j<NumberOfCompoennts; j++)
cout << Value[i*NumberOfCompoennts+j] << " " ;
myElementConnectivity);
\end{verbatim}
+%%%%%%%%%%% WITH POLY METHODS %%%%%%%%%%%%
+
+\item The listed above methods do not take into account information about
+ \verb+polygonal+ and \verb+polyhedral+ cells contained in a MESH object. To get
+ full information about cell types, use the same methods with
+ \verb+WithPoly+ postfix:
+\begin{itemize}
+\item use \method{getNumberOfTypesWithPoly} to get the number of
+ geometric types for a mesh entity;
+\item use \method{getTypesWithPoly} to get all geometric types for a mesh entity;
+\item use \method{getNumberOfElementsWithPoly} to get the number of cells;
+\item use \method{getElementTypeWithPoly} to get the geometric type of
+ one element.
+\end{itemize}
+There are separate methods to get number of polygons and polyhedrons:
+\method{getNumberOfPolygons} and \method{getNumberOfPolyhedron}
+
+To get connectivity of polygonal elements, use \method{getPolygonsConnectivity} along with
+\method{getPolygonsConnectivityIndex} (see example \myref{MESHconnectivities.cxx}).
+
+To get nodal connectivity of polyhedral elements, it is necessary use together
+3 methods: \method{getPolyhedronConnectivity}, \method{getPolyhedronFacesIndex}
+and \method{getPolyhedronIndex} (see example \myref{MESHconnectivities.cxx}).
+
\end{enumerate}
\fileCxx{MESHconnectivities.cxx}
\item \method{setNumberOfElements} to set the number of elements for
each geometric type. This method allocates connectivities array ;
\item \method{setConnectivity} to set the connectivity in MED\_FULL\_INTERLACE
-mode for each geometric type ;
+mode for each geometric type (use \method{setPolygonsConnectivity} and
+\method{setPolyhedraConnectivity} for poly elements);
\end{itemize}
\textbf{C++ Example~:}
int main (int argc, char ** argv) {
+// const string MedFile = "polyedres.med" ;
+// const string MeshName = "Erreur orientation" ;
+// const string MedFile = "polygones.med" ;
+// const string MeshName = "Bord" ;
const string MedFile = "pointe.med" ;
const string MeshName = "maa1" ;
MESH myMesh(MED_DRIVER,MedFile,MeshName) ;
cout << endl ;
}
+ int nbPolygons = myMesh.getNumberOfPolygons();
+ if ( nbPolygons > 0 )
+ {
+ cout << "Show Connectivity (Nodal) of POLYGONS:" << endl ;
+ const int* Connectivity = myMesh.getPolygonsConnectivity(MED_NODAL,MED_CELL);
+ const int* ConnectivityIndex = myMesh.getPolygonsConnectivityIndex(MED_NODAL,MED_CELL);
+ for (int j=0; j<nbPolygons; j++){
+ cout << "Polygon "<< j+1 <<" : " ;
+ int IndexBegin = ConnectivityIndex[j];
+ int IndexEnd = ConnectivityIndex[j+1];
+ for (int k=IndexBegin; k<IndexEnd; k++)
+ cout << Connectivity[k-1]<<" ";
+ cout << endl ;
+ }
+ }
+
+ int nbPolyhedrons = myMesh.getNumberOfPolyhedron();
+ if ( nbPolyhedrons > 0 )
+ {
+ cout << "Show Connectivity (Nodal) of POLYHEDRONS:" << endl ;
+ const int* Connectivity = myMesh.getPolyhedronConnectivity(MED_NODAL);
+ const int* FaceIndex = myMesh.getPolyhedronFacesIndex();
+ const int* Index = myMesh.getPolyhedronIndex(MED_NODAL);
+ for (int j=0; j<nbPolyhedrons; j++){
+ cout << "Polyhedron "<< j+1 <<" : " << endl;
+ int FaceIndexBegin = Index[j];
+ int FaceIndexEnd = Index[j+1];
+ for (int k=FaceIndexBegin; k<FaceIndexEnd; k++) {
+ cout << " Face " << k - FaceIndexBegin + 1 << " : ";
+ int IndexBegin = FaceIndex[k-1];
+ int IndexEnd = FaceIndex[k];
+ for (int i=IndexBegin; i<IndexEnd; i++)
+ cout << Connectivity[i-1]<<" ";
+ cout << endl ;
+ }
+ }
+ }
+
return 0 ;
}
MedFile = "pointe.med"
#MedFile = "carre_quad4_3.med"
+#MedFile = "polyedres.med"
+#MedFile = "polygones.med"
meshName = "maa1"
#meshName = "CARRE_EN_QUAD4"
+#meshName = "Erreur orientation"
+#meshName = "Bord"
myMesh = MESH(MED_DRIVER,MedFile,meshName)
myMesh.read()
print constituent," : ",(i+1)," : ",constituentConnectivity[
(indexBegin-1):(indexEnd-1)]
+ pass
+ pass
+
+nbPolygons = myMesh.getNumberOfPolygons()
+if nbPolygons > 0 :
+ print ""
+ print " Show Connectivity (Nodal) of POLYGONS:"
+ print ""
+ connectivity = myMesh.getPolygonsConnectivity(MED_NODAL,MED_CELL)
+ index = myMesh.getPolygonsConnectivityIndex(MED_NODAL,MED_CELL)
+ for j in range(nbPolygons):
+ print " Polygon",(j+1)," ",connectivity[ index[j]-1 : index[j+1]-1 ]
+ pass
+ pass
+
+nbPolyhedrons = myMesh.getNumberOfPolyhedron()
+if nbPolyhedrons > 0 :
+ print ""
+ print " Show Connectivity (Nodal) of POLYHEDRONS:"
+ print ""
+ connectivity = myMesh.getPolyhedronConnectivity(MED_NODAL)
+ fIndex = myMesh.getPolyhedronFacesIndex()
+ index = myMesh.getPolyhedronIndex(MED_NODAL)
+ for j in range(nbPolyhedrons):
+ print " Polyhedra",(j+1)
+ iF1, iF2 = index[ j ]-1, index[ j+1 ]-1
+ for f in range( iF2 - iF1 ):
+ iN1, iN2 = fIndex[ iF1+f ]-1, fIndex[ iF1+f+1 ]-1
+ print " Face",f+1," ",connectivity[ iN1 : iN2 ]
+ pass
+ pass
+ pass
*/
long getOrderNumber() raises (SALOME::SALOME_Exception);
+ /*!
+ Returns if gauss points are present.
+ */
+ boolean getGaussPresence();
+
// Read & Write
// -----------
raises (SALOME::SALOME_Exception);
};
+ interface FIELDDOUBLENO : FIELDDOUBLE {
+ };
+
+ interface FIELDDOUBLEFULL : FIELDDOUBLE {
+ };
+
interface FIELDINT : FIELD , SALOME::MultiCommClass {
/*!
raises (SALOME::SALOME_Exception);
};
+ interface FIELDINTNO : FIELDINT {
+ };
+
+ interface FIELDINTFULL : FIELDINT {
+ };
+
// MED interface
interface MED : SALOME::GenericObj {
<component-username>Med</component-username>
<component-type>MESH</component-type>
<component-author>Patrick GOLDBRONN</component-author>
- <component-version>3.1.0</component-version>
+ <component-version>3.2.0</component-version>
<component-comment>MED memory component</component-comment>
<component-multistudy>1</component-multistudy>
<component-icone>ModuleMed.png</component-icone>
_toField->setIterationNumber ( _fromField->getIterationNumber() );
_toField->setTime ( _fromField->getTime() );
_toField->setOrderNumber ( _fromField->getOrderNumber() );
- _toField->setValueType ( MED_EN::MED_REEL64 );
+ // _toField->setValueType ( MED_EN::MED_REEL64 );
SUPPORT * mySupport(new SUPPORT(_toMesh,"support",MED_EN::MED_NODE));
_toField->setSupport(mySupport);
_toField->allocValue(_toField->getNumberOfComponents(),_toField->getNumberOfValues());
- _toField->setValue( MED_EN::MED_FULL_INTERLACE,resultat.Get_Valeurs());
+ _toField->setValue(resultat.Get_Valeurs());
_toWrapper->Construit_Wrapper_Champ(_toField);
Wrapper_MED_Field(int nv, int nc, double * v):nbr_valeurs(nv),nbr_composantes(nc),valeurs(v)
{
}
- Wrapper_MED_Field(const MEDMEM::FIELD<double> * medfield)
+ Wrapper_MED_Field(const MEDMEM::FIELD<double,MEDMEM::FullInterlace> * medfield)
{
nbr_valeurs=medfield->getNumberOfValues();
nbr_composantes=medfield->getNumberOfComponents();
- valeurs=const_cast<double *>(medfield->getValue(MED_EN::MED_FULL_INTERLACE));
+ valeurs=const_cast<double *>(medfield->getValue());
}
~Wrapper_MED_Field(){}
inline Valeur<double> operator[](int i)
#include "MEDMEM_Mesh_i.hxx"
#include "MEDMEM_Med_i.hxx"
-#include "MEDMEM_FieldInt_i.hxx"
-#include "MEDMEM_FieldDouble_i.hxx"
+#include "MEDMEM_FieldTemplate_i.hxx"
#include "MEDMEM_Support_i.hxx"
#include "MEDMEM_Mesh.hxx"
try
{
((FIELD<int>*)myField)->read() ;
- FIELDINT_i * myFieldIntI = new FIELDINT_i((FIELD<int>*)myField);
+ FIELDTEMPLATE_I<int,FullInterlace> * myFieldIntI = new FIELDTEMPLATE_I<int,FullInterlace>((FIELD<int,FullInterlace>*)myField);
SALOME_MED::FIELD_ptr myFieldIOR = myFieldIntI->_this();
// if (!_duringLoad) myFieldIntI->addInStudy(myStudy,myFieldIOR) ;
endService("Med_Gen_i::readFieldInFile");
try
{
((FIELD<double>*)myField)->read() ;
- FIELDDOUBLE_i * myFieldDoubleI = new FIELDDOUBLE_i((FIELD<double>*)myField);
+ FIELDTEMPLATE_I<double,FullInterlace> * myFieldDoubleI = new FIELDTEMPLATE_I<double,FullInterlace>((FIELD<double,FullInterlace>*)myField);
SALOME_MED::FIELD_ptr myFieldIOR = myFieldDoubleI->_this() ;
// if (!_duringLoad) myFieldDoubleI->addInStudy(myStudy,myFieldIOR) ;
endService("Med_Gen_i::readFieldInFile");
# General configuration options
#---------------------------------------------------------------------------
PROJECT_NAME = "Med Memory Developpers'"
-PROJECT_NUMBER = 1.0.2
+PROJECT_NUMBER = 3.2.0
OUTPUT_DIRECTORY = doc_ref_devel
OUTPUT_LANGUAGE = English
EXTRACT_ALL = YES
# General configuration options
#---------------------------------------------------------------------------
PROJECT_NAME = "Med Memory Users'"
-PROJECT_NUMBER = 1.0.2
+PROJECT_NUMBER = 3.2.0
OUTPUT_DIRECTORY = doc_ref_user
OUTPUT_LANGUAGE = English
EXTRACT_ALL = YES
--- /dev/null
+#ifndef MEDMEM_ARRAY_CONVERT_HXX
+#define MEDMEM_ARRAY_CONVERT_HXX
+
+namespace MEDMEM {
+
+template <class T, class CHECKING_POLICY >
+MEDMEM_Array<T, FullInterlaceGaussPolicy, CHECKING_POLICY> *
+ArrayConvert(
+ const MEDMEM_Array< T, NoInterlaceGaussPolicy, CHECKING_POLICY > &array, T* values=0
+ )
+{
+ MEDMEM_Array<T,FullInterlaceGaussPolicy,CHECKING_POLICY> * myArray;
+ if(values)
+ myArray = new MEDMEM_Array<T,FullInterlaceGaussPolicy,CHECKING_POLICY>
+ (values,
+ array.getDim(),
+ array.getNbElem(),
+ array.getNbGeoType(),
+ array.getNbElemGeoC(),
+ array.getNbGaussGeo(),
+ true,false
+ );
+ else
+ myArray= new MEDMEM_Array<T,FullInterlaceGaussPolicy,CHECKING_POLICY>
+ (array.getDim(),
+ array.getNbElem(),
+ array.getNbGeoType(),
+ array.getNbElemGeoC(),
+ array.getNbGaussGeo()
+ );
+ for (int i=1; i <= array.getNbElem() ; i++ )
+ for (int k=1; k<= array.getNbGauss(i); k++ )
+ for (int j=1; j<= array.getDim(); j++ )
+ myArray->setIJK(i,j,k,array.getIJK(i,j,k));
+
+ return myArray;
+
+};
+
+template <class T, class CHECKING_POLICY>
+MEDMEM_Array<T, NoInterlaceGaussPolicy, CHECKING_POLICY> *
+ArrayConvert(
+ const MEDMEM_Array< T, FullInterlaceGaussPolicy, CHECKING_POLICY > &array, T* values=0
+ )
+{
+ MEDMEM_Array<T,NoInterlaceGaussPolicy,CHECKING_POLICY> * myArray;
+ if(values)
+ myArray = new MEDMEM_Array<T, NoInterlaceGaussPolicy,CHECKING_POLICY> (
+ values,
+ array.getDim(),
+ array.getNbElem(),
+ array.getNbGeoType(),
+ array.getNbElemGeoC(),
+ array.getNbGaussGeo(),
+ true,false
+ );
+ else
+ myArray = new MEDMEM_Array<T, NoInterlaceGaussPolicy,CHECKING_POLICY> (
+ array.getDim(),
+ array.getNbElem(),
+ array.getNbGeoType(),
+ array.getNbElemGeoC(),
+ array.getNbGaussGeo()
+ );
+ for (int i=1; i <= array.getNbElem() ; i++ )
+ for (int k=1; k<= array.getNbGauss(i); k++ )
+ for (int j=1; j<= array.getDim(); j++ )
+ myArray->setIJK(i,j,k,array.getIJK(i,j,k));
+
+ return myArray;
+
+};
+
+template <class T, class CHECKING_POLICY>
+MEDMEM_Array<T, NoInterlaceNoGaussPolicy, CHECKING_POLICY> *
+ArrayConvert(
+ const MEDMEM_Array< T, FullInterlaceNoGaussPolicy, CHECKING_POLICY > &array, T* values=0
+ )
+{
+ MEDMEM_Array<T,NoInterlaceNoGaussPolicy,CHECKING_POLICY> * myArray;
+ if(values)
+ myArray=new MEDMEM_Array<T, NoInterlaceNoGaussPolicy, CHECKING_POLICY> ( values,
+ array.getDim(),
+ array.getNbElem(),
+ true,false
+ );
+ else
+ myArray = new MEDMEM_Array<T, NoInterlaceNoGaussPolicy, CHECKING_POLICY> (
+ array.getDim(),
+ array.getNbElem()
+ );
+ for (int i=1; i <= array.getNbElem() ; i++ )
+ for (int j=1; j<= array.getDim(); j++ )
+ myArray->setIJ(i,j,array.getIJ(i,j));
+
+ return myArray;
+
+};
+
+template <class T, class CHECKING_POLICY>
+MEDMEM_Array<T, FullInterlaceNoGaussPolicy, CHECKING_POLICY> *
+ArrayConvert(
+ const MEDMEM_Array< T, NoInterlaceNoGaussPolicy, CHECKING_POLICY > &array, T* values=0
+ )
+{
+ MEDMEM_Array<T,FullInterlaceNoGaussPolicy,CHECKING_POLICY> * myArray;
+ if(values)
+ myArray= new MEDMEM_Array<T, FullInterlaceNoGaussPolicy, CHECKING_POLICY> (values,
+ array.getDim(),
+ array.getNbElem(),
+ true,false
+ );
+ else
+ myArray= new MEDMEM_Array<T, FullInterlaceNoGaussPolicy, CHECKING_POLICY> (
+ array.getDim(),
+ array.getNbElem()
+ );
+ for (int i=1; i <= array.getNbElem() ; i++ )
+ for (int j=1; j<= array.getDim(); j++ )
+ myArray->setIJ(i,j,array.getIJ(i,j));
+
+ return myArray;
+
+};
+
+
+
+// template <class T,class INTERLACING_POLICY,class INTERLACING_POLICY_OTHER,
+// class CHECKING_POLICY>
+// void ArrayConvert(
+// const MEDMEM_Array< T, INTERLACING_POLICY, CHECKING_POLICY > & arrayin,
+// MEDMEM_Array< T, INTERLACING_POLICY_OTHER, CHECKING_POLICY> * & arrayout
+// )
+// {
+
+// MEDMEM_Array<T,INTERLACING_POLICY_OTHER,CHECKING_POLICY> * myArray;
+// myArray= new MEDMEM_Array< T, INTERLACING_POLICY_OTHER, CHECKING_POLICY > (
+// arrayin.getDim(),
+// arrayin.getNbElem(),
+// arrayin.getNbGeoType(),
+// arrayin.getNbElemGeoC(),
+// arrayin.getNbGaussGeo()
+// );
+
+// for (int i=1; i <= arrayin.getNbElem() ; i++ )
+// for (int k=1; k<= arrayin.getNbGauss(i); k++ )
+// for (int j=1; j<= arrayin.getDim(); j++ )
+// myArray->setIJK(i,j,k,arrayin.getIJK(i,j,k));
+
+// arrayout=myArray;
+
+// };
+
+
+
+
+
+// template <class ARRAY_ELEMENT_TYPE,
+// class GAUSS_TAG,class CHECKING_POLICY=IndexCheckPolicy>
+// typename MEDMEM_ArrayInterface<ARRAY_ELEMENT_TYPE,
+// FullInterlace,
+// GAUSS_TAG,
+// CHECKING_POLICY>::Array &
+// convertBis(const typename MEDMEM_ArrayInterface<
+// ARRAY_ELEMENT_TYPE,
+// NoInterlace,
+// GAUSS_TAG,
+// CHECKING_POLICY>::Array & array ) {
+// std::cout << "-------- Convert 3" << std::endl;
+// };
+
+} //END NAMESPACE
+#endif
--- /dev/null
+#ifndef MEDMEM_ARRAYINTERFACE_HXX
+#define MEDMEM_ARRAYINTERFACE_HXX
+
+#include "MEDMEM_nArray.hxx"
+#include "MEDMEM_InterlacingTraits.hxx"
+
+// L'astuce d'une classe d'interface consiste en
+// 1) La déclaration d'un type qui est celui de la classe d'implémentation
+// 2) D'utiliser ce nouveau nom de type comme paramètres de toutes
+// les méthodes de l'interface.
+// L'inconvenient est qu'il faut justement passer en argument une instance de
+// le classe d'implémentation dans toutes les méthodes et que la classe
+// appelante aura aussi à faire ce travail.
+// Ne surtout pas oublier inline sinon l'interface couterait cher à l'appel
+// des méthodes !
+namespace MEDMEM {
+
+template < class ARRAY_ELEMENT_TYPE,
+ class INTERLACE_TAG,
+ class GAUSS_TAG,
+ class CHECKING_POLICY=IndexCheckPolicy>
+ //NoIndexCheckPolicy>
+class MEDMEM_ArrayInterface {
+
+public:
+
+ // Les type ElementType et Array sont a définir aussi dans les classes utilisatrice
+ // par une déclaration du type : typedef typename ArrayInterface::Array Array;
+
+ typedef ARRAY_ELEMENT_TYPE ElementType;
+ typedef INTERLACE_TAG Interlacing;
+ typedef GAUSS_TAG GaussPresence;
+ typedef typename MEDMEM_InterlacingTraits<Interlacing,GaussPresence>::Type InterlacingPolicy;
+ typedef CHECKING_POLICY CheckingPolicy;
+ typedef MEDMEM_Array<ElementType,InterlacingPolicy,CheckingPolicy> Array;
+
+ static inline int getNbGauss(int i, const Array & array) {
+ return array.getNbGauss(i);
+ };
+
+ static inline ElementType * getPtr( Array & array) {
+ return array.getPtr();
+ };
+
+ static inline void setPtr( ElementType * arrayptr, Array & array,
+ bool shallowCopy=false,
+ bool ownershipOfValues=false ) {
+ array.setPtr(arrayptr,shallowCopy,ownershipOfValues);
+ };
+
+ static inline const ElementType * getRow(int i, const Array & array ) {
+ return array.getRow(i);
+ }
+
+ static inline void setRow(int i, const ElementType & value, const Array & array ) {
+ return array.setRow(i,value);
+ }
+
+ static inline const ElementType * getColumn(int j, const Array & array ) {
+ return array.getColumn(j);
+ }
+
+ static inline void setColumn(int j, const ElementType & value, const Array & array ) {
+ return array.setColumn(j,value);
+ }
+
+ static inline const ElementType & getIJ(int i, int j, const Array & array) {
+ return array.getIJ(i,j);
+ }
+
+ static inline const ElementType & getIJK(int i, int j, int k, const Array & array) {
+ return array.getIJK(i,j,k);
+ }
+
+ static inline void setIJ(int i, int j, const ElementType & value, Array & array) {
+ array.setIJ(i,j,value);
+ }
+
+ static inline void setIJK(int i, int j, int k, const ElementType & value, Array & array) {
+ array.setIJK(i,j,k,value);
+ }
+
+};
+
+} //END NAMESPACE
+#endif
#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 "MEDMEM_Support.hxx"
+#include "MEDMEM_Mesh.hxx"
+#include "MEDMEM_ArrayInterface.hxx"
+#include "MEDMEM_ArrayConvert.hxx"
#include <list>
#include <string>
namespace MEDMEM {
- template<class T>
- class FIELD;
template<int N,unsigned int CODE>
void fill(double *a, const double *b)
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;
+ 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,
+ template <class INTERLACING_TAG>
+ ASCII_FIELD_DRIVER():GENDRIVER(),
+ _ptrField((FIELD<T>)MED_NULL),
+ _fileName("") {};
+
+ template <class INTERLACING_TAG>
+ ASCII_FIELD_DRIVER(const string & fileName, FIELD<T,INTERLACING_TAG> * 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();
};
}
-#include "MEDMEM_Field.hxx"
namespace MEDMEM {
}
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");
+ template <class INTERLACING_TAG>
+ ASCII_FIELD_DRIVER<T>::ASCII_FIELD_DRIVER(const string & fileName,
+ FIELD<T,INTERLACING_TAG> * ptrField,
+ MED_EN::med_sort_direc direction,
+ const char *priority)
+ :GENDRIVER(fileName,MED_EN::MED_ECRI),_ptrField((FIELD<T>*)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--)
{
- char c=toupper(priority[i]);
- if(int(c-'X')>(_spaceDimension-1))
- throw MEDEXCEPTION("ASCII_FIELD_DRIVER : Invalid priority definition");
_code<<=2;
- _code+=c-'X';
+ _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)
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 << endl;
}
+}
+
+#include "MEDMEM_Field.hxx"
+namespace MEDMEM
+{
template <class T>
template<int SPACEDIMENSION, unsigned int SORTSTRATEGY>
void ASCII_FIELD_DRIVER<T>::sortAndWrite() const
{
+ typedef typename MEDMEM_ArrayInterface<double,NoInterlace,NoGauss>::Array ArrayDoubleNo;
+ typedef typename MEDMEM_ArrayInterface<double,FullInterlace,NoGauss>::Array ArrayDoubleFull;
+ typedef typename MEDMEM_ArrayInterface<T,NoInterlace,NoGauss>::Array ArrayNo;
+ typedef typename MEDMEM_ArrayInterface<T,FullInterlace,NoGauss>::Array ArrayFull;
+
int i,j;
int numberOfValues=_ptrField->getNumberOfValues();
std::list< SDForSorting<T,SPACEDIMENSION,SORTSTRATEGY > > li;
const double * coord;
- FIELD<double> * barycenterField=0;
+ FIELD<double,FullInterlace> * barycenterField=0;
+ ArrayDoubleNo * baryArrayTmp = NULL;
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);
+
+ 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);
+ 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];
+ }
}
- T* valsToSet=(T*)_ptrField->getValue(MED_EN::MED_FULL_INTERLACE);
+ } else {
+
+ barycenterField = _mesh->getBarycenter(_support);
+ baryArrayTmp = ArrayConvert
+ ( *( static_cast<ArrayDoubleFull*>(barycenterField->getArray()) ) );
+ coord = baryArrayTmp->getPtr();
+ for(i=0; i<SPACEDIMENSION; i++)
+ xyz[i]=(double *)(coord+i*numberOfValues);
+ }
+
+ const T * valsToSet;
+ ArrayFull * tmpArray = NULL;
+ if ( _ptrField->getInterlacingType() == MED_EN::MED_FULL_INTERLACE )
+ valsToSet= _ptrField->getValue();
+ else {
+ tmpArray = ArrayConvert
+ ( *( static_cast<ArrayNo*>(_ptrField->getArray()) ) );
+ valsToSet= tmpArray->getPtr();
+ }
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;
+ 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 (baryArrayTmp) delete baryArrayTmp;
+ if (tmpArray) delete tmpArray;
+
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
+ 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> ();
int CONNECTIVITY::getNumberOfTypesWithPoly(MED_EN::medEntityMesh Entity) const
{
+ SCRUTE(_entity);
+ SCRUTE(Entity);
if (_entity==Entity)
- return _numberOfTypes+getNumberOfPolyType();
+ {
+ SCRUTE(_numberOfTypes);
+ SCRUTE(getNumberOfPolyType());
+ return _numberOfTypes+getNumberOfPolyType();
+ }
else if (_constituent!=NULL)
return _constituent->getNumberOfTypesWithPoly(Entity);
else
#include "MEDMEM_GenDriver.hxx"
#include "MEDMEM_define.hxx"
+#include "MEDMEM_FieldForward.hxx"
+
#include <string>
namespace MEDMEM {
class MESH;
- template<class T> class FIELD;
class MED;
class GENDRIVER;
const std::string & fileName,
MESH *mesh,const string & driverName,
MED_EN::med_mode_acces access);
- template<class T>
+
+ template<class T, class INTERLACING_TAG>
GENDRIVER * buildDriverForField(driverTypes driverType,
const std::string & fileName,
- FIELD<T> *fielde,
+ FIELD<T,INTERLACING_TAG> *fielde,
MED_EN::med_mode_acces access);
GENDRIVER * buildDriverForMed(driverTypes driverType,
const std::string & fileName,
GENDRIVER * buildMeshDriverFromFile(const string & fileName,
MESH * ptrMesh,
MED_EN::med_mode_acces access);
- template<class T>
+ template<class T, class INTERLACING_TAG>
GENDRIVER * buildFieldDriverFromFile(const string & fileName,
- FIELD<T> * ptrField,
+ FIELD<T,INTERLACING_TAG> * 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>
+ template<class T, class INTERLACING_TAG>
GENDRIVER * buildConcreteMedDriverForField(const std::string & fileName,
- FIELD<T> *fielde,
+ FIELD<T,INTERLACING_TAG> *fielde,
MED_EN::med_mode_acces access,
MED_EN::medFileVersion version);
}
#include "MEDMEM_AsciiFieldDriver.hxx"
namespace MEDMEM {
- template<class T>
+ template<class T, class INTERLACING_TAG>
GENDRIVER * DRIVERFACTORY::buildDriverForField(driverTypes driverType,
const std::string & fileName,
- FIELD<T> *field,
+ FIELD<T,INTERLACING_TAG> *field,
MED_EN::med_mode_acces access)
{
GENDRIVER *ret;
return ret;
}
- template<class T>
+ template<class T, class INTERLACING_TAG>
GENDRIVER * DRIVERFACTORY::buildFieldDriverFromFile(const string & fileName,
- FIELD<T> * ptrField,
+ FIELD<T,INTERLACING_TAG> * ptrField,
MED_EN::med_mode_acces access)
{
MED_EN::medFileVersion version;
}
}
- template<class T>
+ template<class T, class INTERLACING_TAG>
GENDRIVER * DRIVERFACTORY::buildConcreteMedDriverForField(const std::string & fileName,
- FIELD<T> *ptrField,
+ FIELD<T,INTERLACING_TAG> *ptrField,
MED_EN::med_mode_acces access,
MED_EN::medFileVersion version)
{
#include "MEDMEM_Exception.hxx"
#include "MEDMEM_Mesh.hxx"
#include "MEDMEM_Group.hxx"
+#include "MEDMEM_Field.hxx"
#include <iomanip>
#include <algorithm>
#ifndef DRIVERTOOLS_HXX
#define DRIVERTOOLS_HXX
-
#include "MEDMEM_define.hxx"
#include "MEDMEM_Exception.hxx"
-#include "MEDMEM_Field.hxx"
+#include "MEDMEM_FieldForward.hxx"
+#include "MEDMEM_ArrayInterface.hxx"
#include <string>
#include <vector>
#include <set>
class COORDINATE;
class GROUP;
class FAMILY;
+class FIELD_;
struct _noeud
{
mutable int number;
if ( !grp || grp->empty() )
return res;
}
- FIELD< T > * f = 0;
+ FIELD< T, NoInterlace > * f = 0;
int i_comp_tot = 0, nb_fields = 0;
std::set<int> supp_id_set;
// loop on subs of this field
{
supp_id_set.clear();
++nb_fields;
- f = new FIELD< T >;
+ f = new FIELD< T, NoInterlace >();
f->setNumberOfComponents( sub_data->nbComponents() );
f->setComponentsNames( & sub_data->_comp_names[ 0 ] );
f->setNumberOfValues ( nb_val );
f->setName( _name );
- f->setValueType( _type );
+ // f->setValueType( _type );
vector<string> str( sub_data->nbComponents() );
f->setComponentsDescriptions( &str[0] );
f->setMEDComponentsUnits( &str[0] );
MESSAGE(" MAKE " << nb_fields << "-th field <" << _name << "> on group_id " << _group_id );
}
// set values
- MEDARRAY< T > * medarray =
- new MEDARRAY< T >( sub_data->nbComponents(), nb_val, MED_EN::MED_NO_INTERLACE );
- f->setValue( medarray );
+ MEDMEM_Array< T, NoInterlaceNoGaussPolicy > * medarray =
+ new MEDMEM_Array < T, NoInterlaceNoGaussPolicy >( sub_data->nbComponents(),
+ nb_val );
+ f->setArray( medarray );
// loop on components of a sub
for ( int i_comp = 0; i_comp < sub_data->nbComponents(); ++i_comp )
{
using namespace std;
#ifndef LOCALIZED
-#define LOCALIZED(message) message , __FILE__ , __LINE__
+#define LOCALIZED(message) static_cast<const char *> (message) , __FILE__ , __LINE__
#endif
#define MED_EXCEPTION MEDEXCEPTION
#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)
+FAMILY::FAMILY():_identifier(0), _numberOfAttribute(0), _numberOfGroup(0)
{
MESSAGE("FAMILY::FAMILY()");
};
MESSAGE("FAMILY(int Identifier, string Name, int NumberOfAttribute,int *AttributeIdentifier,int *AttributeValue,string AttributeDescription,int NumberOfGroup,string GroupName, int ** Number) : "<<Identifier);
_isOnAllElts = false ;
- // replace them by pointerOf ?
- _attributeIdentifier = new int[_numberOfAttribute] ;
- memcpy(_attributeIdentifier,AttributeIdentifier,_numberOfAttribute*sizeof(int));
- _attributeValue = new int[_numberOfAttribute] ;
- memcpy(_attributeValue,AttributeValue,_numberOfAttribute*sizeof(int));
-
- _attributeDescription=new string[_numberOfAttribute];
- for (int i=0;i<NumberOfAttribute;i++) {
- _attributeDescription[i].assign(AttributeDescription,i*MED_TAILLE_DESC,MED_TAILLE_DESC);
- _attributeDescription[i].erase(strlen(_attributeDescription[i].c_str()));
- //SCRUTE(_attributeDescription[i]);
- }
+ SCRUTE(_numberOfAttribute);
+ if (_numberOfAttribute > 0)
+ {
+ _attributeIdentifier.set(_numberOfAttribute,AttributeIdentifier);
+ _attributeValue.set(_numberOfAttribute,AttributeValue);
+
+ _attributeDescription.set(_numberOfAttribute);
+ for (int i=0;i<NumberOfAttribute;i++) {
+ _attributeDescription[i].assign(AttributeDescription,i*MED_TAILLE_DESC,MED_TAILLE_DESC);
+ _attributeDescription[i].erase(strlen(_attributeDescription[i].c_str()));
+ //SCRUTE(_attributeDescription[i]);
+ }
+ }
+ else
+ {
+ _attributeIdentifier.set(_numberOfAttribute);
+ _attributeValue.set(_numberOfAttribute);
+ _attributeDescription.set(_numberOfAttribute);
+ }
- _groupName=new string[_numberOfGroup];
+ _groupName.set(_numberOfGroup);
for (int i=0;i<NumberOfGroup;i++) {
_groupName[i].assign(GroupName,i*MED_TAILLE_LNOM,MED_TAILLE_LNOM);
_groupName[i].erase(strlen(_groupName[i].c_str()));
update();
} else {
_numberOfGeometricType = 1 ;
- if (_geometricType!=NULL) delete[] _geometricType ;
- _geometricType = new medGeometryElement[1] ;
+
+ _geometricType.set(1) ;
+
_geometricType[0]=MED_NONE ;
_isOnAllElts= false ;
- if (_numberOfElements!=NULL) delete[] _numberOfElements ;
- _numberOfElements = new int[1] ;
+
+ _numberOfElements.set(1) ;
+
_numberOfElements[0]=NumberOfNodesInFamily ;
_totalNumberOfElements=NumberOfNodesInFamily;
MESSAGE("FAMILY::FAMILY(FAMILY & m)");
_identifier = m._identifier;
_numberOfAttribute = m._numberOfAttribute;
- if (m._attributeIdentifier != NULL)
- {
- _attributeIdentifier = new int[m._numberOfAttribute];
- memcpy(_attributeIdentifier,m._attributeIdentifier,m._numberOfAttribute*sizeof(int));
- }
- else
- _attributeIdentifier = (int *) NULL;
- if (m._attributeValue != NULL)
- {
- _attributeValue = new int[m._numberOfAttribute];
- memcpy(_attributeValue,m._attributeValue,m._numberOfAttribute*sizeof(int));
- }
- else
- _attributeValue = (int *) NULL;
- if (m._attributeDescription != NULL)
- {
- _attributeDescription = new string[m._numberOfAttribute];
- for (int i=0;i<m._numberOfAttribute;i++)
- _attributeDescription[i] = m._attributeDescription[i];
- }
- else
- _attributeDescription = (string *) NULL;
+
+ _attributeIdentifier.set(_numberOfAttribute,m._attributeIdentifier);
+ _attributeValue.set(_numberOfAttribute,m._attributeValue);
+ _attributeDescription.set(_numberOfAttribute);
+
+ for (int i=0;i<m._numberOfAttribute;i++)
+ _attributeDescription[i] = m._attributeDescription[i];
+
_numberOfGroup = m._numberOfGroup;
- if (m._groupName != NULL)
- {
- _groupName = new string[m._numberOfGroup];
- for (int i=0;i<m._numberOfGroup;i++)
- _groupName[i]=m._groupName[i];
- }
- else
- _groupName = (string *) NULL;
+
+ _groupName.set(_numberOfGroup) ;
+
+ for (int i=0;i<m._numberOfGroup;i++)
+ _groupName[i]=m._groupName[i];
};
FAMILY::FAMILY(const SUPPORT & s):SUPPORT(s)
_identifier = 0;
_numberOfAttribute = 0;
- _attributeIdentifier = (int*) NULL;
- _attributeValue = (int*) NULL;
- _attributeDescription = (string*) NULL;
+
_numberOfGroup = 0;
- _groupName= (string*) NULL;
};
FAMILY::~FAMILY()
{
MESSAGE("~FAMILY()");
- if(_attributeIdentifier!=NULL)
- delete[] _attributeIdentifier;
- if(_attributeValue!=NULL)
- delete[] _attributeValue;
- if(_attributeDescription!=NULL)
- delete[] _attributeDescription;
- if(_groupName!=NULL)
- delete[] _groupName;
};
FAMILY & FAMILY::operator=(const FAMILY &fam)
{
MESSAGE("FAMILY::operator=");
+ if ( this == &fam ) return *this;
+
+ //Etant donné que l'opérateur d'affectation de la classe SUPPORT effectuait
+ //une recopie profonde j'ai mis en cohérence l'opérateur d'affectation
+ // de la classe FAMILY
+ SUPPORT::operator=(fam);
+
+
_identifier = fam._identifier;
_numberOfAttribute = fam._numberOfAttribute;
- _attributeIdentifier = fam._attributeIdentifier;
- _attributeValue = fam._attributeValue;
- _attributeDescription = fam._attributeDescription;
+ _attributeIdentifier.set(_numberOfAttribute, fam._attributeIdentifier) ;
+ _attributeValue.set(_numberOfAttribute, fam._attributeValue) ;
+ _attributeDescription.set(_numberOfAttribute, fam._attributeDescription) ;
_numberOfGroup = fam._numberOfGroup;
- _groupName = fam._groupName;
+ _groupName.set(_numberOfGroup, fam._groupName) ;
return *this;
};
Find = true ;
_entity = Entity ;
_numberOfGeometricType = numberOfElementTypesInFamily ;
- if (_geometricType!=NULL) delete[] _geometricType ;
- _geometricType = new medGeometryElement[numberOfElementTypesInFamily] ;
+ _geometricType.set(numberOfElementTypesInFamily) ;
+
_isOnAllElts = false ;
- if (_numberOfElements!=NULL) delete[] _numberOfElements ;
- _numberOfElements = new int[numberOfElementTypesInFamily] ;
+
+ _numberOfElements.set(numberOfElementTypesInFamily) ;
_totalNumberOfElements=0;
//_numberOfGaussPoint = new int[numberOfElementTypesInFamily] ;
There is one for each attribute.
\endif
*/
- int * _attributeIdentifier ;
+ PointerOf<int> _attributeIdentifier ;
/*!
\if developper
Array of all attributes' values.
There is one for each attribute.
\endif
*/
- int * _attributeValue ;
+ PointerOf<int> _attributeValue ;
/*!
\if developper
Array of all attributes' descriptions.
There is one for each attribute.
\endif
*/
- string * _attributeDescription ;
+ PointerOf<string> _attributeDescription ;
/*!
\if developper
Number of the group the family belongs to.
Name of the group the family belongs to.
\endif
*/
- string * _groupName ;
+ PointerOf<string> _groupName ;
public:
/*! Constructor. */
bool build(MED_EN::medEntityMesh Entity,int **FamilyNumber);
+ // Il faudrait mettre en cohérence les méthodes set
+ // avec l'opérateur d'affection ! Rmq from EF !!!
+
inline void setIdentifier (int Identifier);
inline void setNumberOfAttributes (int NumberOfAttribute);
inline void setAttributesIdentifiers (int * AttributeIdentifier);
inline void setNumberOfGroups (int NumberOfGroups);
inline void setGroupsNames (string * GroupName);
- inline int getIdentifier() const;
- inline int getNumberOfAttributes() const;
- inline int * getAttributesIdentifiers() const;
- inline int * getAttributesValues() const;
- inline string * getAttributesDescriptions() const;
- inline int getNumberOfGroups() const;
- inline string * getGroupsNames() const;
+ inline int getIdentifier() const;
+ inline int getNumberOfAttributes() const;
+ inline const int * getAttributesIdentifiers() const;
+ inline const int * getAttributesValues() const;
+ inline const string * getAttributesDescriptions() const;
+ inline int getNumberOfGroups() const;
+ inline const string * getGroupsNames() const;
// A FAIRE : VERIFIER LA VALIDITE DES PARAMETRES !
inline int getAttributeIdentifier(int i) const;
/*! Returns a pointer to attributes identifiers .
(There are _numberOfAttribute attributes) */
//---------------------------------------------------
-inline int * FAMILY::getAttributesIdentifiers() const
+inline const int * FAMILY::getAttributesIdentifiers() const
//---------------------------------------------------
{
return _attributeIdentifier ;
/*! Returns a pointer to attributes values.
(There are _numberOfAttribute attributes)*/
//----------------------------------------------
-inline int * FAMILY::getAttributesValues() const
+inline const int * FAMILY::getAttributesValues() const
//----------------------------------------------
{
return _attributeValue ;
return _attributeValue[i-1] ;
}
//-------------------------------------------------------
-inline string * FAMILY::getAttributesDescriptions() const
+inline const string * FAMILY::getAttributesDescriptions() const
//-------------------------------------------------------
{
return _attributeDescription ;
}
/*! Returns a pointer to the names of the groups the family belongs to */
//--------------------------------------------
-inline string * FAMILY::getGroupsNames() const
+inline const string * FAMILY::getGroupsNames() const
//--------------------------------------------
{
return _groupName ;
_componentsDescriptions((string *)NULL),
_componentsUnits((UNIT*)NULL),
_MEDComponentsUnits((string *)NULL),
- _iterationNumber(-1),_time(0.0),_orderNumber(-1)
+ _iterationNumber(-1),_time(0.0),_orderNumber(-1),
+ _valueType(MED_EN::MED_UNDEFINED_TYPE),
+ _interlacingType(MED_EN::MED_UNDEFINED_INTERLACE)
{
MESSAGE("Constructeur FIELD_ sans parametre");
}
_isRead(false),
_name(""), _description(""), _support(Support),
_numberOfComponents(NumberOfComponents),
- _iterationNumber(-1),_time(0.0),_orderNumber(-1)
+ _iterationNumber(-1),_time(0.0),_orderNumber(-1),
+ _valueType(MED_EN::MED_UNDEFINED_TYPE),
+ _interlacingType(MED_EN::MED_UNDEFINED_INTERLACE)
{
MESSAGE("FIELD_(const SUPPORT * Support, const int NumberOfComponents)");
_support->addReference();
}
+FIELD_& FIELD_::operator=(const FIELD_ &m) {
+
+ if ( this == &m) return *this;
+
+ _isRead = m._isRead ;
+ _name = m._name;
+ _description = m._description;
+ _support = m._support; //Cf Opérateur de recopie du Support?
+ _numberOfComponents = m._numberOfComponents;
+ _numberOfValues = m._numberOfValues;
+
+ 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];}
+ _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;
+
+ // _valueType et _interlacingType doivent uniquement être recopiés
+ // par l'opérateur de recopie de FIELD<T,...>
+
+ //_drivers = m._drivers ; // PG : Well, same driver, what about m destructor !
+
+ return *this;
+}
+
FIELD_::FIELD_(const FIELD_ &m)
{
_isRead = m._isRead ;
_numberOfComponents = m._numberOfComponents;
_numberOfValues = m._numberOfValues;
copyGlobalInfo(m);
- _valueType = m._valueType;
+ //_valueType = m._valueType;
+ // _valueType et _interlacingType doivent uniquement être recopiés
+ // par l'opérateur de recopie de FIELD<T,...>
//_drivers = m._drivers ; // PG : Well, same driver, what about m destructor !
}
string diagnosis;
// check-up, fill diagnosis if some incompatibility is found.
+
+ // Ne pas vérifier l'entrelacement
+ // Le compilo s'en occupe Rmq from EF
+
if(m._support != n._support)
{
if(!(*m._support==*n._support))
}
else if(m._numberOfComponents != n._numberOfComponents)
diagnosis+="They don't have the same number of components!";
+ else if (m._valueType != n._valueType)
+ diagnosis+="They don't have the same type!";
else if(m._numberOfValues != n._numberOfValues)
diagnosis+="They don't have the same number of values!";
else
{
string diagnosis;
- // check-up, fill diagnosis if some incompatibility is found.
+ // check-up, fill diagnosis if some incompatibility is found.
+
+ // Ne pas vérifier l'entrelacement
+ // Le compilo s'en occupe Rmq from EF
+
if(m._support != n._support)
{
if(!(m._support->deepCompare(*n._support)))
diagnosis+="They don't have the same support!";
}
+ else if (m._valueType != n._valueType)
+ diagnosis+="They don't have the same type!";
else if(m._numberOfComponents != n._numberOfComponents)
diagnosis+="They don't have the same number of components!";
else if(m._numberOfValues != n._numberOfValues)
#include "MEDMEM_define.hxx"
#include "MEDMEM_Support.hxx"
#include "MEDMEM_Unit.hxx"
-#include "MEDMEM_Array.hxx"
+#include "MEDMEM_nArray.hxx"
#include "MEDMEM_GenDriver.hxx"
+#include "MEDMEM_ArrayInterface.hxx"
+#include "MEDMEM_FieldForward.hxx"
/*!
namespace MEDMEM {
- template<class T> class FIELD;
-
-class FIELD_ // GENERIC POINTER TO a template <class T> class FIELD
-{
+ template < typename T > struct SET_VALUE_TYPE {
+ static const MED_EN::med_type_champ _valueType = MED_EN::MED_UNDEFINED_TYPE;};
+ template < > struct SET_VALUE_TYPE<double> {
+ static const MED_EN::med_type_champ _valueType = MED_EN::MED_REEL64; };
+ template < > struct SET_VALUE_TYPE<int> {
+ static const MED_EN::med_type_champ _valueType = MED_EN::MED_INT32; };
+
+ template < typename T > struct SET_INTERLACING_TYPE {
+ static const MED_EN::medModeSwitch _interlacingType = MED_EN::MED_UNDEFINED_INTERLACE; };
+ template < > struct SET_INTERLACING_TYPE<FullInterlace>{
+ static const MED_EN::medModeSwitch _interlacingType = MED_EN::MED_FULL_INTERLACE; };
+ template < > struct SET_INTERLACING_TYPE<NoInterlace> {
+ static const MED_EN::medModeSwitch _interlacingType = MED_EN::MED_NO_INTERLACE; };
+
+class FIELD_ // GENERIC POINTER TO a template <class T, class INTERLACING_TAG> class FIELD
+{ // ùpihjpmoçhmpç_hmù
protected:
bool _isRead ;
\endif
*/
string * _MEDComponentsUnits;
+ /*!
+ \if developper
+ Iteration number of the field.
+ \endif
+ */
int _iterationNumber ;
+ /*!
+ \if developper
+ Time of the field.
+ \endif
+ */
double _time;
+ /*!
+ \if developper
+ Order number of the field.
+ \endif
+ */
int _orderNumber ;
-
- // _valueType should be a static const. Here is an initialization exemple
- // template < classType T > struct SET_VALUE_TYPE { static const med_type_champ _valueType = 0; }
- // template < > struct SET_VALUE_TYPE<double> { static const med_type_champ _valueType = MED_EN::MED_REEL64; }
- // template < > struct SET_VALUE_TYPE<int> { static const med_type_champ _valueType = MED_EN::MED_INT32; }
- // static const med_type_champ _valueType = SET_VALUE_TYPE <T>::_valueType;
+ /*!
+ \if developper
+ At the initialization step of the field using the constructors; this attribute,
+ the value type (integer or real) , is set automatically. There is a get method
+ but not a set method for this attribute.
+ \endif
+ */
MED_EN::med_type_champ _valueType ;
+ /*!
+ \if developper
+ At the initialization step of the field using the constructors; this attribute,
+ the interlacing type (full interlace or no interlace field value storage), is set
+ automatically. There is a get method but not a set method for this attribute.
+ \endif
+ */
+ MED_EN::medModeSwitch _interlacingType;
vector<GENDRIVER *> _drivers; // Storage of the drivers currently in use
static void _checkFieldCompatibility(const FIELD_& m, const FIELD_& n, bool checkUnit=true) throw (MEDEXCEPTION);
*/
virtual ~FIELD_();
-// virtual void setIterationNumber (int IterationNumber);
-// virtual void setOrderNumber (int OrderNumber);
-// virtual void setFieldName (string& fieldName);
+ FIELD_& operator=(const FIELD_ &m);
virtual void rmDriver(int index=0);
virtual int addDriver(driverTypes driverType,
inline void setOrderNumber(int OrderNumber);
inline int getOrderNumber() const;
- inline void setValueType (const MED_EN::med_type_champ ValueType) ;
inline MED_EN::med_type_champ getValueType () const;
+ inline MED_EN::medModeSwitch getInterlacingType() const;
+ virtual inline bool getGaussPresence() const throw (MEDEXCEPTION);
protected:
void copyGlobalInfo(const FIELD_& m);
};
{
return _valueType ;
}
+
/*!
- Set the FIELD med value type (MED_INT32 or MED_REEL64).
+ Get the FIELD med interlacing type (MED_FULL_INTERLACE or MED_NO_INTERLACE).
*/
-inline void FIELD_::setValueType (const MED_EN::med_type_champ ValueType)
+ inline MED_EN::medModeSwitch FIELD_::getInterlacingType () const
{
- _valueType = ValueType ;
+ return _interlacingType ;
}
-}//End namespace MEDMEM
+/*!
+ Get the FIELD gauss presence.
+*/
+ inline bool FIELD_::getGaussPresence() const throw (MEDEXCEPTION)
+{
+ const char * LOC = "FIELD_::getGaussPresence() : ";
+ throw MEDEXCEPTION(STRING(LOC) << " This FIELD_ doesn't rely on a FIELD<T>" );
+}
+
+} //End namespace MEDMEM
/////////////////////////
// END OF CLASS FIELD_ //
/*!
This template class contains informations related with a FIELD :
- - Values of the field
+ - Values of the field, their type (real or integer), the storage mode (full interlace or
+ no interlace).
*/
template<class T2> class MED_FIELD_WRONLY_DRIVER22;
template<class T2> class VTK_FIELD_DRIVER;
-template <class T> class FIELD : public FIELD_
+ template <class T,
+ class INTERLACING_TAG
+ > class FIELD : public FIELD_
{
protected:
- // ------ End of Drivers Management Part
+
+ typedef typename MEDMEM_ArrayInterface<T,INTERLACING_TAG,NoGauss>::Array ArrayNoGauss;
+ typedef typename MEDMEM_ArrayInterface<T,INTERLACING_TAG,Gauss>::Array ArrayGauss;
+ typedef typename MEDMEM_ArrayInterface<T,NoInterlace,NoGauss>::Array ArrayNo;
+ typedef typename MEDMEM_ArrayInterface<T,FullInterlace,NoGauss>::Array ArrayFull;
+ typedef MEDMEM_Array_ Array;
// array of value of type T
- MEDARRAY<T> *_value ;
+ Array *_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 _operation(const FIELD& m,const FIELD& n, char* Op);
void _operationInitialize(const FIELD& m,const FIELD& n, char* Op);
- void _add_in_place(const FIELD& m,const FIELD& n, const MED_EN::medModeSwitch mode);
- void _sub_in_place(const FIELD& m,const FIELD& n, const MED_EN::medModeSwitch mode);
- void _mul_in_place(const FIELD& m,const FIELD& n, const MED_EN::medModeSwitch mode);
- void _div_in_place(const FIELD& m,const FIELD& n, const MED_EN::medModeSwitch mode) throw (MEDEXCEPTION);
+ void _add_in_place(const FIELD& m,const FIELD& n);
+ void _sub_in_place(const FIELD& m,const FIELD& n);
+ void _mul_in_place(const FIELD& m,const FIELD& n);
+ void _div_in_place(const FIELD& m,const FIELD& n) throw (MEDEXCEPTION);
//setValueType() ;
- FIELD & operator=(const FIELD &m); // A FAIRE
public:
FIELD();
FIELD(const FIELD &m);
- FIELD(const SUPPORT * Support, const int NumberOfComponents, const MED_EN::medModeSwitch Mode=MED_EN::MED_FULL_INTERLACE) throw (MEDEXCEPTION) ; // Ajout NB Constructeur FIELD avec allocation de memoire de tous ses attribut
+ FIELD(const SUPPORT * Support, const int NumberOfComponents) throw (MEDEXCEPTION) ;
+ FIELD( driverTypes driverType,
+ const string & fileName, const string & fieldDriverName,
+ const int iterationNumber=-1, const int orderNumber=-1)
+ throw (MEDEXCEPTION);
FIELD(const SUPPORT * Support, driverTypes driverType,
const string & fileName="", const string & fieldName="",
const int iterationNumber = -1, const int orderNumber = -1)
throw (MEDEXCEPTION);
~FIELD();
+ FIELD & operator=(const FIELD &m);
+
const FIELD operator+(const FIELD& m) const;
const FIELD operator-(const FIELD& m) const;
const FIELD operator*(const FIELD& m) const;
template <T T_function(T)> void applyFunc();
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;
+ double normL2(int component, const FIELD<double,FullInterlace> * p_field_volume=NULL) const;
+ double normL2(const FIELD<double,FullInterlace> * p_field_volume=NULL) const;
+ double normL1(int component, const FIELD<double,FullInterlace> * p_field_volume=NULL) const;
+ double normL1(const FIELD<double,FullInterlace> * p_field_volume=NULL) const;
FIELD* extract(const SUPPORT *subSupport) const throw (MEDEXCEPTION);
friend class MED_FIELD_RDONLY_DRIVER21<T>;
inline void writeAppend(int index=0, const string & driverName = "");
inline void writeAppend(const GENDRIVER &);
- inline void setValue(MEDARRAY<T> *Value);
+ inline MEDMEM_Array_ * getArray() const throw (MEDEXCEPTION);
+ inline ArrayGauss * getArrayGauss() const throw (MEDEXCEPTION);
+ inline ArrayNoGauss * getArrayNoGauss() const throw (MEDEXCEPTION);
+ inline bool getGaussPresence() const throw (MEDEXCEPTION);
- inline MEDARRAY<T>* getvalue() const;
- inline int getValueLength(MED_EN::medModeSwitch Mode) const;
- 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 int getValueLength() const throw (MEDEXCEPTION);
+ inline const T* getValue() const throw (MEDEXCEPTION);
+ inline const T* getRow(int i) const throw (MEDEXCEPTION);
+ inline const T* getColumn(int j) const throw (MEDEXCEPTION);
+ inline T getValueIJ(int i,int j) const throw (MEDEXCEPTION);
+ bool getValueOnElement(int eltIdInSup,T* retValues) const throw (MEDEXCEPTION);
- inline void setValue(MED_EN::medModeSwitch mode, T* value);
- inline void setValueI(MED_EN::medModeSwitch mode, int i, T* value);
- inline void setValueIJ(int i, int j, T value);
+ inline void setArray(MEDMEM_Array_ *value) throw (MEDEXCEPTION);
+ inline void setValue( T* value) throw (MEDEXCEPTION);
+ inline void setRow( int i, T* value) throw (MEDEXCEPTION);
+ inline void setColumn( int i, T* value) throw (MEDEXCEPTION);
+ inline void setValueIJ(int i, int j, T value) throw (MEDEXCEPTION);
/*!
This fonction feeds the FIELD<double> private attributs _value with the
initialised via the constructor FIELD<double>(const SUPPORT * , const int )
with Support as SUPPORT argument, 1 has the number of components, and Support
has be a SUPPORT on 3D cells. This initialisation could be done by the empty
- constructor followed by a setSupport and setNumberOfComponents call but it has
- be followed by a setValueType(MED_REEL64) call.
+ constructor followed by a setSupport and setNumberOfComponents call.
*/
void getVolume() const throw (MEDEXCEPTION) ;
/*!
has to be initialised via the constructor FIELD<double>(const SUPPORT * ,
const int ) with 1 has the number of components, and _support has be a
SUPPORT on 2D cells or 3D faces. This initialisation could be done by the
- empty constructor followed by a setSupport and setNumberOfComponents call but
- it has be followed by a setValueType(MED_REEL64) call.
+ empty constructor followed by a setSupport and setNumberOfComponents call.
*/
void getArea() const throw (MEDEXCEPTION) ;
/*!
to be initialised via the constructor FIELD<double>(const SUPPORT * ,
const int ) with 1 has the number of components, and _support has be a
SUPPORT on 3D edges or 2D faces. This initialisation could be done by the
- empty constructor followed by a setSupport and setNumberOfComponents call but
- it has be followed by a setValueType(MED_REEL64) call.
+ empty constructor followed by a setSupport and setNumberOfComponents call.
*/
void getLength() const throw (MEDEXCEPTION) ;
/*!
const int ) with the space dimension has the number of components, and
_support has be a SUPPORT on 3D or 2D faces. This initialisation could be done
by the empty constructor followed by a setSupport and setNumberOfComponents
- call but it has be followed by a setValueType(MED_REEL64) call.
+ call.
*/
void getNormal() const throw (MEDEXCEPTION) ;
/*!
FIELD<double>(const SUPPORT * ,const int ) with the space dimension has the
number of components, and _support has be a SUPPORT on 3D cells or 2D faces.
This initialisation could be done by the empty constructor followed by a
- setSupport and setNumberOfComponents call but it has be followed by a
- setValueType(MED_REEL64) call.
+ setSupport and setNumberOfComponents call.
*/
void getBarycenter() const throw (MEDEXCEPTION) ;
- template<void T_Analytic(const double *,T*)>
- void fillFromAnalytic();
+
+ typedef void (*myFuncType)(const double *,T*);
+ void fillFromAnalytic(myFuncType f) throw (MEDEXCEPTION);
};
}
namespace MEDMEM {
-template <class T> T FIELD<T>::_scalarForPow=1;
+template <class T,class INTERLACING_TAG> T FIELD<T, INTERLACING_TAG>::_scalarForPow=1;
// --------------------
// Implemented Methods
/*!
Constructor with no parameter, most of the attribut members are set to NULL.
*/
-template <class T> FIELD<T>::FIELD():
- _value((MEDARRAY<T>*)NULL)
+template <class T, class INTERLACING_TAG>
+FIELD<T, INTERLACING_TAG>::FIELD():FIELD_()
{
MESSAGE("Constructeur FIELD sans parametre");
+
+ //INITIALISATION DE _valueType DS LE CONSTRUCTEUR DE FIELD_
+ ASSERT(FIELD_::_valueType == MED_EN::MED_UNDEFINED_TYPE);
+ FIELD_::_valueType=SET_VALUE_TYPE<T>::_valueType;
+
+ //INITIALISATION DE _interlacingType DS LE CONSTRUCTEUR DE FIELD_
+ ASSERT(FIELD_::_interlacingType == MED_EN::MED_UNDEFINED_INTERLACE);
+ FIELD_::_interlacingType=SET_INTERLACING_TYPE<INTERLACING_TAG>::_interlacingType;
+
+ _value = ( ArrayNoGauss * ) NULL;
}
/*!
Constructor with parameters such that all attrribut are set but the _value
attribut is allocated but not set.
*/
-template <class T> FIELD<T>::FIELD(const SUPPORT * Support,
- const int NumberOfComponents, const MED_EN::medModeSwitch Mode) throw (MEDEXCEPTION) :
- FIELD_(Support, NumberOfComponents)
+template <class T, class INTERLACING_TAG>
+FIELD<T, INTERLACING_TAG>::FIELD(const SUPPORT * Support,
+ const int NumberOfComponents) throw (MEDEXCEPTION) :
+ FIELD_(Support, NumberOfComponents),_value()
{
- BEGIN_OF("FIELD<T>::FIELD(const SUPPORT * Support, const int NumberOfComponents, const medModeSwitch Mode)");
+ BEGIN_OF("FIELD<T>::FIELD(const SUPPORT * Support, const int NumberOfComponents)");
SCRUTE(this);
+ //INITIALISATION DE _valueType DS LE CONSTRUCTEUR DE FIELD_
+ ASSERT(FIELD_::_valueType == MED_EN::MED_UNDEFINED_TYPE)
+ FIELD_::_valueType=SET_VALUE_TYPE<T>::_valueType;
+
+ //INITIALISATION DE _interlacingType DS LE CONSTRUCTEUR DE FIELD_
+ ASSERT(FIELD_::_interlacingType == MED_EN::MED_UNDEFINED_INTERLACE)
+ FIELD_::_interlacingType=SET_INTERLACING_TYPE<INTERLACING_TAG>::_interlacingType;
+
try {
+ // becarefull about the numbre of gauss point
_numberOfValues = Support->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS);
}
catch (MEDEXCEPTION &ex) {
MESSAGE("No value defined ! ("<<ex.what()<<")");
- _value = (MEDARRAY<T>*)NULL ;
}
MESSAGE("FIELD : constructeur : "<< _numberOfValues <<" et "<< NumberOfComponents);
if (0<_numberOfValues) {
- _value = new MEDARRAY<T>(_numberOfComponents,_numberOfValues,Mode);
+ _value = new ArrayNoGauss (_numberOfComponents,_numberOfValues);
_isRead = true ;
- } else
- _value = (MEDARRAY<T>*)NULL ;
+ }
- END_OF("FIELD<T>::FIELD(const SUPPORT * Support, const int NumberOfComponents, const medModeSwitch Mode)");
+ END_OF("FIELD<T>::FIELD(const SUPPORT * Support, const int NumberOfComponents)");
}
/*!
\if developper
\endif
*/
-template <class T> void FIELD<T>::init ()
+template <class T, class INTERLACING_TAG> void FIELD<T, INTERLACING_TAG>::init ()
{
}
/*!
Copy constructor.
*/
-template <class T> FIELD<T>::FIELD(const FIELD & m):
+template <class T, class INTERLACING_TAG> FIELD<T, INTERLACING_TAG>::FIELD(const FIELD & m):
FIELD_((FIELD_) m)
{
MESSAGE("Constructeur FIELD de recopie");
+
+ // RECOPIE PROFOND Rmq from EF
if (m._value != NULL)
{
- // copie only default !
- _value = new MEDARRAY<T>(* m._value,false);
+ if ( m.getGaussPresence() )
+ _value = new ArrayGauss( *(dynamic_cast< ArrayGauss * > (m._value) ) ,false);
+ else
+ _value = new ArrayNoGauss( *(dynamic_cast< ArrayNoGauss * > (m._value)) ,false);
}
else
- _value = (MEDARRAY<T> *) NULL;
- //_drivers = m._drivers;
+ _value = (ArrayNoGauss *) NULL;
+
+ _valueType = m._valueType;
+ _interlacingType = m._interlacingType;
+ //drivers = m._drivers;
}
/*!
Not implemented.
\endif
*/
-template <class T> FIELD<T> & FIELD<T>::operator=(const FIELD &m)
+template <class T, class INTERLACING_TAG>
+FIELD<T, INTERLACING_TAG> & FIELD<T, INTERLACING_TAG>::operator=(const FIELD &m)
{
MESSAGE("Appel de FIELD<T>::operator=") ;
- // operator= on FIELD_
- // ignore driver
+ if ( this == &m) return *this;
+
// copy values array
+ FIELD_::operator=(m); // Driver are ignored & ?copie su pointeur de Support?
+
+ _value = m._value; //PROBLEME RECOPIE DES POINTEURS PAS COHERENT AVEC LE
+ //CONSTRUCTEUR PAR RECOPIE
+ //CF :Commentaire dans MEDMEM_Array
+ _valueType = m._valueType;
+ _interlacingType = m._interlacingType;
}
/*!
no optimisation is performed : the evaluation of last expression requires the construction of
3 temporary fields.
*/
-template <class T>
-const FIELD<T> FIELD<T>::operator+(const FIELD & m) const
+template <class T, class INTERLACING_TAG>
+const FIELD<T, INTERLACING_TAG> FIELD<T, INTERLACING_TAG>::operator+(const FIELD & m) const
{
BEGIN_OF("FIELD<T>::operator+(const FIELD & m)");
FIELD_::_checkFieldCompatibility(*this, m); // may throw exception
- // Select mode : avoid if possible any calculation of other mode for fields m or *this
- MED_EN::medModeSwitch mode;
- if(this->getvalue()->getMode()==m.getvalue()->getMode() || this->getvalue()->isOtherCalculated())
- mode=m.getvalue()->getMode();
- else
- mode=this->getvalue()->getMode();
-
// Creation of the result - memory is allocated by FIELD constructor
- FIELD<T> result(this->getSupport(),this->getNumberOfComponents(),mode);
+ FIELD<T, INTERLACING_TAG> result(this->getSupport(),this->getNumberOfComponents());
//result._operation(*this,m,mode,"+"); // perform Atribute's initialization & addition
result._operationInitialize(*this,m,"+"); // perform Atribute's initialization
- result._add_in_place(*this,m,mode); // perform addition
+ result._add_in_place(*this,m); // perform addition
END_OF("FIELD<T>::operator+(const FIELD & m)");
return result;
* Operations are directly performed in the first field's array.
* This operation is authorized only for compatible fields that have the same support.
*/
-template <class T>
-FIELD<T>& FIELD<T>::operator+=(const FIELD & m)
+template <class T, class INTERLACING_TAG>
+FIELD<T, INTERLACING_TAG>& FIELD<T, INTERLACING_TAG>::operator+=(const FIELD & m)
{
BEGIN_OF("FIELD<T>::operator+=(const FIELD & m)");
FIELD_::_checkFieldCompatibility(*this, m); // 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();
- const T* value1=m.getValue(mode); // get pointers to the values we are adding
+ const T* value1=m.getValue(); // get pointers to the values we are adding
// get a non const pointer to the inside array of values and perform operation
- T * value=const_cast<T *> (getValue(mode));
+ T * value=const_cast<T *> (getValue());
const int size=getNumberOfValues()*getNumberOfComponents(); // size of array
const T* endV=value+size; // pointer to the end of value
for(;value!=endV; value1++,value++)
*value += *value1;
- // if it exists, the alternate mode needs to be cleared because it is not up-to-date anymore
- this->getvalue()->clearOtherMode();
END_OF("FIELD<T>::operator+=(const FIELD & m)");
return *this;
}
* Data members are checked for compatibility and initialized.
* The user is in charge of memory deallocation.
*/
-template <class T>
-FIELD<T>* FIELD<T>::add(const FIELD& m, const FIELD& n)
+template <class T, class INTERLACING_TAG>
+FIELD<T, INTERLACING_TAG>* FIELD<T, INTERLACING_TAG>::add(const FIELD& m, const FIELD& n)
{
BEGIN_OF("FIELD<T>::add(const FIELD & m, const FIELD& n)");
FIELD_::_checkFieldCompatibility(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);
+ FIELD<T, INTERLACING_TAG>* result = new FIELD<T, INTERLACING_TAG>(m.getSupport(),
+ m.getNumberOfComponents());
result->_operationInitialize(m,n,"+"); // perform Atribute's initialization
- result->_add_in_place(m,n,mode); // perform addition
+ result->_add_in_place(m,n); // perform addition
END_OF("FIELD<T>::add(const FIELD & m, const FIELD& n)");
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)
+template <class T, class INTERLACING_TAG>
+FIELD<T, INTERLACING_TAG>* FIELD<T, INTERLACING_TAG>::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);
+ FIELD<T, INTERLACING_TAG>* result = new FIELD<T, INTERLACING_TAG>(m.getSupport(),
+ m.getNumberOfComponents());
result->_operationInitialize(m,n,"+"); // perform Atribute's initialization
- result->_add_in_place(m,n,mode); // perform addition
+ result->_add_in_place(m,n); // perform addition
END_OF("FIELD<T>::addDeep(const FIELD & m, const FIELD& n)");
return result;
no optimisation is performed : the evaluation of last expression requires the construction of
3 temporary fields.
*/
-template <class T>
-const FIELD<T> FIELD<T>::operator-(const FIELD & m) const
+template <class T, class INTERLACING_TAG>
+const FIELD<T, INTERLACING_TAG> FIELD<T, INTERLACING_TAG>::operator-(const FIELD & m) const
{
BEGIN_OF("FIELD<T>::operator-(const FIELD & m)");
FIELD_::_checkFieldCompatibility(*this, m); // may throw exception
- MED_EN::medModeSwitch mode;
- if(this->getvalue()->getMode()==m.getvalue()->getMode() || this->getvalue()->isOtherCalculated())
- mode=m.getvalue()->getMode();
- else
- mode=this->getvalue()->getMode();
-
// Creation of the result - memory is allocated by FIELD constructor
- FIELD<T> result(this->getSupport(),this->getNumberOfComponents(),mode);
+ FIELD<T, INTERLACING_TAG> result(this->getSupport(),this->getNumberOfComponents());
//result._operation(*this,m,mode,"-"); // perform Atribute's initialization & substraction
result._operationInitialize(*this,m,"-"); // perform Atribute's initialization
- result._sub_in_place(*this,m,mode); // perform substracion
+ result._sub_in_place(*this,m); // perform substracion
END_OF("FIELD<T>::operator-(const FIELD & m)");
return result;
}
-template <class T>
-const FIELD<T> FIELD<T>::operator-() const
+template <class T, class INTERLACING_TAG>
+const FIELD<T, INTERLACING_TAG> FIELD<T, INTERLACING_TAG>::operator-() const
{
BEGIN_OF("FIELD<T>::operator-()");
- MED_EN::medModeSwitch mode=this->getvalue()->getMode();
// Creation of the result - memory is allocated by FIELD constructor
- FIELD<T> result(this->getSupport(),this->getNumberOfComponents(),mode);
+ FIELD<T, INTERLACING_TAG> result(this->getSupport(),this->getNumberOfComponents());
// Atribute's initialization
result.setName("- "+getName());
result.setComponentsNames(getComponentsNames());
result.setIterationNumber(getIterationNumber());
result.setTime(getTime());
result.setOrderNumber(getOrderNumber());
- result.setValueType(getValueType());
- const T* value1=getValue(mode);
+ const T* value1=getValue();
// get a non const pointer to the inside array of values and perform operation
- T * value=const_cast<T *> (result.getValue(mode));
+ T * value=const_cast<T *> (result.getValue());
const int size=getNumberOfValues()*getNumberOfComponents(); // size of array
const T* endV=value+size; // pointer to the end of value
* Operations are directly performed in the first field's array.
* This operation is authorized only for compatible fields that have the same support.
*/
-template <class T>
-FIELD<T>& FIELD<T>::operator-=(const FIELD & m)
+template <class T, class INTERLACING_TAG>
+FIELD<T, INTERLACING_TAG>& FIELD<T, INTERLACING_TAG>::operator-=(const FIELD & m)
{
BEGIN_OF("FIELD<T>::operator-=(const FIELD & m)");
FIELD_::_checkFieldCompatibility(*this, m); // 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();
- const T* value1=m.getValue(mode); // get pointers to the values we are adding
+ const T* value1=m.getValue();
// get a non const pointer to the inside array of values and perform operation
- T * value=const_cast<T *> (getValue(mode));
+ T * value=const_cast<T *> (getValue());
const int size=getNumberOfValues()*getNumberOfComponents(); // size of array
const T* endV=value+size; // pointer to the end of value
for(;value!=endV; value1++,value++)
*value -= *value1;
- // if it exists, the alternate mode needs to be cleared because it is not up-to-date anymore
- this->getvalue()->clearOtherMode();
+
END_OF("FIELD<T>::operator-=(const FIELD & m)");
return *this;
}
* Data members are checked for compatibility and initialized.
* The user is in charge of memory deallocation.
*/
-template <class T>
-FIELD<T>* FIELD<T>::sub(const FIELD& m, const FIELD& n)
+template <class T, class INTERLACING_TAG>
+FIELD<T, INTERLACING_TAG>* FIELD<T, INTERLACING_TAG>::sub(const FIELD& m, const FIELD& n)
{
BEGIN_OF("FIELD<T>::sub(const FIELD & m, const FIELD& n)");
FIELD_::_checkFieldCompatibility(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);
+ FIELD<T, INTERLACING_TAG>* result = new FIELD<T, INTERLACING_TAG>(m.getSupport(),
+ m.getNumberOfComponents());
result->_operationInitialize(m,n,"-"); // perform Atribute's initialization
- result->_sub_in_place(m,n,mode); // perform substraction
+ result->_sub_in_place(m,n); // perform substraction
END_OF("FIELD<T>::sub(const FIELD & m, const FIELD& n)");
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)
+template <class T, class INTERLACING_TAG>
+FIELD<T, INTERLACING_TAG>* FIELD<T, INTERLACING_TAG>::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);
+ FIELD<T, INTERLACING_TAG>* result = new FIELD<T, INTERLACING_TAG>(m.getSupport(),
+ m.getNumberOfComponents());
result->_operationInitialize(m,n,"-"); // perform Atribute's initialization
- result->_sub_in_place(m,n,mode); // perform substraction
+ result->_sub_in_place(m,n); // perform substraction
END_OF("FIELD<T>::subDeep(const FIELD & m, const FIELD& n)");
return result;
no optimisation is performed : the evaluation of last expression requires the construction of
3 temporary fields.
*/
-template <class T>
-const FIELD<T> FIELD<T>::operator*(const FIELD & m) const
+template <class T, class INTERLACING_TAG>
+const FIELD<T, INTERLACING_TAG> FIELD<T, INTERLACING_TAG>::operator*(const FIELD & m) const
{
BEGIN_OF("FIELD<T>::operator*(const FIELD & m)");
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;
- if(this->getvalue()->getMode()==m.getvalue()->getMode() || this->getvalue()->isOtherCalculated())
- mode=m.getvalue()->getMode();
- else
- mode=this->getvalue()->getMode();
-
// Creation of the result - memory is allocated by FIELD constructor
- FIELD<T> result(this->getSupport(),this->getNumberOfComponents(),mode);
+ FIELD<T, INTERLACING_TAG> result(this->getSupport(),this->getNumberOfComponents());
//result._operation(*this,m,mode,"*"); // perform Atribute's initialization & multiplication
result._operationInitialize(*this,m,"*"); // perform Atribute's initialization
- result._mul_in_place(*this,m,mode); // perform multiplication
+ result._mul_in_place(*this,m); // perform multiplication
END_OF("FIELD<T>::operator*(const FIELD & m)");
return result;
* Operations are directly performed in the first field's array.
* This operation is authorized only for compatible fields that have the same support.
*/
-template <class T>
-FIELD<T>& FIELD<T>::operator*=(const FIELD & m)
+template <class T, class INTERLACING_TAG>
+FIELD<T, INTERLACING_TAG>& FIELD<T, INTERLACING_TAG>::operator*=(const FIELD & m)
{
BEGIN_OF("FIELD<T>::operator*=(const FIELD & m)");
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();
- const T* value1=m.getValue(mode); // get pointers to the values we are adding
+ const T* value1=m.getValue();
// get a non const pointer to the inside array of values and perform operation
- T * value=const_cast<T *> (getValue(mode));
+ T * value=const_cast<T *> (getValue());
const int size=getNumberOfValues()*getNumberOfComponents(); // size of array
const T* endV=value+size; // pointer to the end of value
for(;value!=endV; value1++,value++)
*value *= *value1;
- // if it exists, the alternate mode needs to be cleared because it is not up-to-date anymore
- this->getvalue()->clearOtherMode();
+
END_OF("FIELD<T>::operator*=(const FIELD & m)");
return *this;
}
* Data members are checked for compatibility and initialized.
* The user is in charge of memory deallocation.
*/
-template <class T>
-FIELD<T>* FIELD<T>::mul(const FIELD& m, const FIELD& n)
+template <class T, class INTERLACING_TAG>
+FIELD<T, INTERLACING_TAG>* FIELD<T, INTERLACING_TAG>::mul(const FIELD& m, const FIELD& n)
{
BEGIN_OF("FIELD<T>::mul(const FIELD & m, const FIELD& n)");
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;
- 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);
+ FIELD<T, INTERLACING_TAG>* result = new FIELD<T, INTERLACING_TAG>(m.getSupport(),
+ m.getNumberOfComponents());
result->_operationInitialize(m,n,"*"); // perform Atribute's initialization
- result->_mul_in_place(m,n,mode); // perform multiplication
+ result->_mul_in_place(m,n); // perform multiplication
END_OF("FIELD<T>::mul(const FIELD & m, const FIELD& n)");
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)
+template <class T, class INTERLACING_TAG>
+FIELD<T, INTERLACING_TAG>* FIELD<T, INTERLACING_TAG>::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);
+ FIELD<T, INTERLACING_TAG>* result = new FIELD<T,INTERLACING_TAG>(m.getSupport(),
+ m.getNumberOfComponents());
result->_operationInitialize(m,n,"*"); // perform Atribute's initialization
- result->_mul_in_place(m,n,mode); // perform multiplication
+ result->_mul_in_place(m,n); // perform multiplication
END_OF("FIELD<T>::mulDeep(const FIELD & m, const FIELD& n)");
return result;
no optimisation is performed : the evaluation of last expression requires the construction of
3 temporary fields.
*/
-template <class T>
-const FIELD<T> FIELD<T>::operator/(const FIELD & m) const
+template <class T, class INTERLACING_TAG>
+const FIELD<T, INTERLACING_TAG> FIELD<T, INTERLACING_TAG>::operator/(const FIELD & m) const
{
BEGIN_OF("FIELD<T>::operator/(const FIELD & m)");
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;
- if(this->getvalue()->getMode()==m.getvalue()->getMode() || this->getvalue()->isOtherCalculated())
- mode=m.getvalue()->getMode();
- else
- mode=this->getvalue()->getMode();
-
// Creation of the result - memory is allocated by FIELD constructor
- FIELD<T> result(this->getSupport(),this->getNumberOfComponents(),mode);
+ FIELD<T, INTERLACING_TAG> result(this->getSupport(),this->getNumberOfComponents());
//result._operation(*this,m,mode,"/"); // perform Atribute's initialization & division
result._operationInitialize(*this,m,"/"); // perform Atribute's initialization
- result._div_in_place(*this,m,mode); // perform division
+ result._div_in_place(*this,m); // perform division
END_OF("FIELD<T>::operator/(const FIELD & m)");
return result;
* Operations are directly performed in the first field's array.
* This operation is authorized only for compatible fields that have the same support.
*/
-template <class T>
-FIELD<T>& FIELD<T>::operator/=(const FIELD & m)
+template <class T, class INTERLACING_TAG>
+FIELD<T, INTERLACING_TAG>& FIELD<T, INTERLACING_TAG>::operator/=(const FIELD & m)
{
BEGIN_OF("FIELD<T>::operator/=(const FIELD & m)");
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();
- const T* value1=m.getValue(mode); // get pointers to the values we are adding
+ const T* value1=m.getValue(); // get pointers to the values we are adding
// get a non const pointer to the inside array of values and perform operation
- T * value=const_cast<T *> (getValue(mode));
+ T * value=const_cast<T *> (getValue());
const int size=getNumberOfValues()*getNumberOfComponents(); // size of array
const T* endV=value+size; // pointer to the end of value
for(;value!=endV; value1++,value++)
*value /= *value1;
- // if it exists, the alternate mode needs to be cleared because it is not up-to-date anymore
- this->getvalue()->clearOtherMode();
+
END_OF("FIELD<T>::operator/=(const FIELD & m)");
return *this;
}
* Data members are checked for compatibility and initialized.
* The user is in charge of memory deallocation.
*/
-template <class T>
-FIELD<T>* FIELD<T>::div(const FIELD& m, const FIELD& n)
+template <class T, class INTERLACING_TAG>
+FIELD<T, INTERLACING_TAG>* FIELD<T, INTERLACING_TAG>::div(const FIELD& m, const FIELD& n)
{
BEGIN_OF("FIELD<T>::div(const FIELD & m, const FIELD& n)");
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;
- 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);
+ FIELD<T, INTERLACING_TAG>* result = new FIELD<T, INTERLACING_TAG>(m.getSupport(),
+ m.getNumberOfComponents());
result->_operationInitialize(m,n,"/"); // perform Atribute's initialization
- result->_div_in_place(m,n,mode); // perform division
+ result->_div_in_place(m,n); // perform division
END_OF("FIELD<T>::div(const FIELD & m, const FIELD& n)");
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)
+template <class T,class INTERLACING_TAG>
+FIELD<T, INTERLACING_TAG>* FIELD<T, INTERLACING_TAG>::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);
+ FIELD<T, INTERLACING_TAG>* result = new FIELD<T, INTERLACING_TAG>(m.getSupport(),
+ m.getNumberOfComponents());
result->_operationInitialize(m,n,"/"); // perform Atribute's initialization
- result->_div_in_place(m,n,mode); // perform division
+ result->_div_in_place(m,n); // perform division
END_OF("FIELD<T>::divDeep(const FIELD & m, const FIELD& n)");
return result;
and the operator.
\endif
*/
-template <class T>
-void FIELD<T>::_operationInitialize(const FIELD& m,const FIELD& n, char* Op)
+template <class T, class INTERLACING_TAG>
+void FIELD<T, INTERLACING_TAG>::_operationInitialize(const FIELD& m,const FIELD& n, char* Op)
{
- MESSAGE("Appel methode interne _add" << Op);
+ MESSAGE("Appel methode interne " << Op);
// Atribute's initialization (copy of the first field's attributes)
// Other data members (_support, _numberOfValues) are initialized in the field's constr.
setIterationNumber(m.getIterationNumber());
setTime(m.getTime());
setOrderNumber(m.getOrderNumber());
- setValueType(m.getValueType());
}
it doesn't exist!
\endif
*/
-template <class T>
-void FIELD<T>::_add_in_place(const FIELD& m,const FIELD& n, const MED_EN::medModeSwitch mode)
+template <class T, class INTERLACING_TAG>
+void FIELD<T, INTERLACING_TAG>::_add_in_place(const FIELD& m,const FIELD& n)
{
// get pointers to the values we are adding
- const T* value1=m.getValue(mode);
- const T* value2=n.getValue(mode);
+ const T* value1=m.getValue();
+ const T* value2=n.getValue();
// get a non const pointer to the inside array of values and perform operation
- T * value=const_cast<T *> (getValue(mode));
+ T * value=const_cast<T *> (getValue());
const int size=getNumberOfValues()*getNumberOfComponents();
SCRUTE(size);
it doesn't exist!
\endif
*/
-template <class T>
-void FIELD<T>::_sub_in_place(const FIELD& m,const FIELD& n, const MED_EN::medModeSwitch mode)
+template <class T, class INTERLACING_TAG>
+void FIELD<T, INTERLACING_TAG>::_sub_in_place(const FIELD& m,const FIELD& n)
{
// get pointers to the values we are adding
- const T* value1=m.getValue(mode);
- const T* value2=n.getValue(mode);
+ const T* value1=m.getValue();
+ const T* value2=n.getValue();
// get a non const pointer to the inside array of values and perform operation
- T * value=const_cast<T *> (getValue(mode));
+ T * value=const_cast<T *> (getValue());
const int size=getNumberOfValues()*getNumberOfComponents();
SCRUTE(size);
it doesn't exist!
\endif
*/
-template <class T>
-void FIELD<T>::_mul_in_place(const FIELD& m,const FIELD& n, const MED_EN::medModeSwitch mode)
+template <class T, class INTERLACING_TAG>
+void FIELD<T, INTERLACING_TAG>::_mul_in_place(const FIELD& m,const FIELD& n)
{
// get pointers to the values we are adding
- const T* value1=m.getValue(mode);
- const T* value2=n.getValue(mode);
+ const T* value1=m.getValue();
+ const T* value2=n.getValue();
// get a non const pointer to the inside array of values and perform operation
- T * value=const_cast<T *> (getValue(mode));
+ T * value=const_cast<T *> (getValue());
const int size=getNumberOfValues()*getNumberOfComponents();
SCRUTE(size);
it doesn't exist!
\endif
*/
-template <class T>
-void FIELD<T>::_div_in_place(const FIELD& m,const FIELD& n, const MED_EN::medModeSwitch mode) throw (MEDEXCEPTION)
+template <class T, class INTERLACING_TAG>
+void FIELD<T, INTERLACING_TAG>::_div_in_place(const FIELD& m,const FIELD& n) throw (MEDEXCEPTION)
{
// get pointers to the values we are adding
- const T* value1=m.getValue(mode);
- const T* value2=n.getValue(mode);
+ const T* value1=m.getValue();
+ const T* value2=n.getValue();
// get a non const pointer to the inside array of values and perform operation
- T * value=const_cast<T *> (getValue(mode));
+ T * value=const_cast<T *> (getValue());
const int size=getNumberOfValues()*getNumberOfComponents();
SCRUTE(size);
const T* endV1=value1+size;
for(;value1!=endV1; value1++,value2++,value++){
- if ( *value2 == 0 ) {
+ if ( *value2 == 0 ) { // FAIRE PLUTOT UN TRY CATCH Rmq from EF
string diagnosis;
- diagnosis="FIELD<T>::_div_in_place(...) : Divide by zero !";
+ diagnosis="FIELD<T,INTERLACING_TAG>::_div_in_place(...) : Divide by zero !";
throw MEDEXCEPTION(diagnosis.c_str());
}
*value=(*value1)/(*value2);
/*! Return Max Norm
*/
-template <class T> double FIELD<T>::normMax() const throw (MEDEXCEPTION)
+template <class T, class INTERLACIN_TAG> double FIELD<T, INTERLACIN_TAG>::normMax() const throw (MEDEXCEPTION)
{
- const T* value=getValue(getvalue()->getMode()); // get pointer to the values
+ const T* value=getValue(); // get pointer to the values
const int size=getNumberOfValues()*getNumberOfComponents();
if (size <= 0) // Size of array has to be strictly positive
{
string diagnosis;
- diagnosis="FIELD<T>::normMax() : cannot compute the norm of "+getName()+
+ diagnosis="FIELD<T,INTERLACIN_TAG>::normMax() : cannot compute the norm of "+getName()+
" : it size is non positive!";
throw MEDEXCEPTION(diagnosis.c_str());
}
/*! Return Euclidien norm
*/
-template <class T> double FIELD<T>::norm2() const throw (MEDEXCEPTION)
+template <class T, class INTERLACIN_TAG> double FIELD<T, INTERLACIN_TAG>::norm2() const throw (MEDEXCEPTION)
{
- const T* value=this->getValue(this->getvalue()->getMode()); // get const pointer to the values
+ const T* value=this->getValue(); // get const pointer to the values
const int size=getNumberOfValues()*getNumberOfComponents(); // get size of array
if (size <= 0) // Size of array has to be strictly positive
{
string diagnosis;
- diagnosis="FIELD<T>::norm2() : cannot compute the norm of "+getName()+
+ diagnosis="FIELD<T,INTERLACIN_TAG>::norm2() : cannot compute the norm of "+getName()+
" : it size is non positive!";
throw MEDEXCEPTION(diagnosis.c_str());
}
* \code myField.applyFunc<std::sqrt>(); // apply sqare root function \endcode
* \code myField.applyFunc<myFunction>(); // apply your own created function \endcode
*/
-template <class T> template <T T_function(T)>
-void FIELD<T>::applyFunc()
+template <class T, class INTERLACIN_TAG> template <T T_function(T)>
+void FIELD<T, INTERLACIN_TAG>::applyFunc()
{
- MED_EN::medModeSwitch mode=getvalue()->getMode();
-
- // get a non const pointer to the inside array of values and perform operation
- T * value=const_cast<T *> (getValue(mode));
+ // get a non const pointer to the inside array of values and perform operation
+ T * value=const_cast<T *> (getValue());
const int size=getNumberOfValues()*getNumberOfComponents(); // size of array
if (size>0) // for a negative size, there is nothing to do
const T* lastvalue=value+size; // pointer to the end of value
for(;value!=lastvalue; ++value) // apply linear transformation
*value = T_function(*value);
- // if it exists, the alternate mode needs to be cleared because it is not up-to-date anymore
- getvalue()->clearOtherMode();
}
}
-template <class T> T FIELD<T>::pow(T x)
+template <class T, class INTERLACIN_TAG> T FIELD<T, INTERLACIN_TAG>::pow(T x)
{
- return (T)::pow(x,FIELD<T>::_scalarForPow);
+ return (T)::pow(x,FIELD<T, INTERLACIN_TAG>::_scalarForPow);
}
/*! Apply to each (scalar) field component the math function pow.
* \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)
+template <class T, class INTERLACIN_TAG> void FIELD<T, INTERLACIN_TAG>::applyPow(T scalar)
{
- FIELD<T>::_scalarForPow=scalar;
- applyFunc<FIELD<T>::pow>();
+ FIELD<T, INTERLACIN_TAG>::_scalarForPow=scalar;
+ applyFunc<FIELD<T, INTERLACIN_TAG>::pow>();
}
/*! Apply to each (scalar) field component the linear function x -> ax+b.
* calculation is done "in place".
*/
-template <class T> void FIELD<T>::applyLin(T a, T b)
+template <class T, class INTERLACIN_TAG> void FIELD<T, INTERLACIN_TAG>::applyLin(T a, T b)
{
- MED_EN::medModeSwitch mode=getvalue()->getMode();
-
// get a non const pointer to the inside array of values and perform operation in place
- T * value=const_cast<T *> (getValue(mode));
+ T * value=const_cast<T *> (getValue());
const int size=getNumberOfValues()*getNumberOfComponents(); // size of array
if (size>0) // for a negative size, there is nothing to do
const T* lastvalue=value+size; // pointer to the end of value
for(;value!=lastvalue; ++value) // apply linear transformation
*value = a*(*value)+b;
- // if it exists, the alternate mode needs to be cleared because it is not up-to-date anymore
- getvalue()->clearOtherMode();
}
}
* 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, bool deepCheck)
+template <class T, class INTERLACING_TAG>
+FIELD<T, INTERLACING_TAG>*
+FIELD<T, INTERLACING_TAG>::scalarProduct(const FIELD & m, const FIELD & n, bool deepCheck)
{
if(!deepCheck)
FIELD_::_checkFieldCompatibility( m, n, false); // may throw exception
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;
+ // result type imply INTERLACING_TAG=FullInterlace for m & n
const int numberOfElements=m.getNumberOfValues(); // strictly positive
const int NumberOfComponents=m.getNumberOfComponents(); // strictly positive
- // Creation & init of a the result field on the same suppot, with one component
- FIELD<T>* result = new FIELD<T>(m.getSupport(),1,mode);
+ // Creation & init of a the result field on the same support, with one component
+ // You have to be careful about the interlacing mode, because in the computation step,
+ // it seems to assume the the interlacing mode is the FullInterlacing
+
+ FIELD<T, INTERLACING_TAG>* result = new FIELD<T, INTERLACING_TAG>(m.getSupport(),1);
result->setName( "scalarProduct ( " + m.getName() + " , " + n.getName() + " )" );
result->setIterationNumber(m.getIterationNumber());
result->setTime(m.getTime());
result->setOrderNumber(m.getOrderNumber());
- result->setValueType(m.getValueType());
- const T* value1=m.getValue(mode); // get const pointer to the values
- const T* value2=n.getValue(mode); // get const pointer to the values
+ const T* value1=m.getValue(); // get const pointer to the values
+ const T* value2=n.getValue(); // get const pointer to the values
// get a non const pointer to the inside array of values and perform operation
- T * value=const_cast<T *> (result->getValue(mode));
+ T * value=const_cast<T *> (result->getValue());
const T* lastvalue=value+numberOfElements; // pointing just after last value of result
for ( ; value!=lastvalue ; ++value ) // loop on all elements
* Cannot be applied to a field with a support on nodes.
* If the optional p_field_volume argument is furnished, the volume is not re-calculated.
*/
-template <class T> double FIELD<T>::normL2(int component, const FIELD<double> * p_field_volume) const
+template <class T, class INTERLACING_TAG>
+double FIELD<T, INTERLACING_TAG>::normL2(int component,
+ const FIELD<double, FullInterlace> * p_field_volume) const
{
_checkNormCompatibility(p_field_volume); // may throw exception
if ( component<1 || component>getNumberOfComponents() )
throw MEDEXCEPTION(STRING("FIELD<T>::normL2() : The component argument should be between 1 and the number of components"));
- const FIELD<double> * p_field_size=p_field_volume;
+ const FIELD<double, FullInterlace> * p_field_size=p_field_volume;
if(!p_field_volume) // if the user don't supply the volume
- p_field_size=_getFieldSize(); // we calculate the volume [PROVISOIRE, en attendant l'implémentation dans mesh]
+ 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_EN::MED_FULL_INTERLACE);
- const T* value=getValueI( MED_EN::MED_NO_INTERLACE, component); // get pointer to the component's values
+ const double* vol=p_field_size->getValue();
+ // Il n'est vraiment pas optimal de mixer des champs dans des modes d'entrelacement
+ // different juste pour le calcul
+
+ const T * value = NULL;
+ ArrayNo * myArray = NULL;
+ if ( getInterlacingType() == MED_EN::MED_NO_INTERLACE )
+ value = getValue();
+ else {
+ myArray = ArrayConvert( *( dynamic_cast< ArrayFull * > ( getArrayNoGauss() ) ));
+ value = myArray->getPtr();
+ }
+
const T* lastvalue=value+getNumberOfValues(); // pointing just after the end of column
double integrale=0.0;
if(!p_field_volume) // if the user didn't supply the volume
delete p_field_size; // delete temporary volume field
+ if ( getInterlacingType() == MED_EN::MED_FULL_INTERLACE ) delete myArray;
if( totVol <= 0)
throw MEDEXCEPTION(STRING("cannot compute sobolev norm : volume is not positive!"));
* Cannot be applied to a field with a support on nodes.
* If the optional p_field_volume argument is furnished, the volume is not re-calculated.
*/
-template <class T> double FIELD<T>::normL2(const FIELD<double> * p_field_volume) const
+template <class T, class INTERLACING_TAG>
+double FIELD<T, INTERLACING_TAG>::normL2(const FIELD<double, FullInterlace> * p_field_volume) const
{
_checkNormCompatibility(p_field_volume); // may throw exception
- const FIELD<double> * p_field_size=p_field_volume;
+ const FIELD<double, FullInterlace> * p_field_size=p_field_volume;
if(!p_field_volume) // if the user don't supply the volume
- p_field_size=_getFieldSize(); // we calculate the volume [PROVISOIRE, en attendant l'implémentation dans mesh]
+ 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_EN::MED_FULL_INTERLACE);
+ const double* vol=p_field_size->getValue();
const double* lastvol=vol+getNumberOfValues(); // pointing just after the end of vol
- const T* value=getValue( MED_EN::MED_NO_INTERLACE); // get pointer to the field's values
+
+ const T * value = NULL;
+ ArrayNo * myArray = NULL;
+ if ( getInterlacingType() == MED_EN::MED_NO_INTERLACE )
+ value = getValue();
+ else {
+ myArray = ArrayConvert( *( dynamic_cast< ArrayFull * > ( getArrayNoGauss() ) ));
+ value = myArray->getPtr();
+ }
double totVol=0.0;
const double* p_vol=vol;
if(!p_field_volume) // if the user didn't supply the volume
delete p_field_size; // delete temporary volume field
+ if ( getInterlacingType() == MED_EN::MED_FULL_INTERLACE ) delete myArray;
if( totVol <= 0)
throw MEDEXCEPTION(STRING("cannot compute sobolev norm : volume is not positive!"));
* Cannot be applied to a field with a support on nodes.
* If the optional p_field_volume argument is furnished, the volume is not re-calculated.
*/
-template <class T> double FIELD<T>::normL1(int component, const FIELD<double> * p_field_volume) const
+template <class T, class INTERLACING_TAG>
+double FIELD<T, INTERLACING_TAG>::normL1(int component,
+ const FIELD<double, FullInterlace > * p_field_volume) const
{
_checkNormCompatibility(p_field_volume); // may throw exception
if ( component<1 || component>getNumberOfComponents() )
- throw MEDEXCEPTION(STRING("FIELD<T>::normL2() : The component argument should be between 1 and the number of components"));
+ throw MEDEXCEPTION(STRING("FIELD<T,INTERLACING_TAG>::normL2() : The component argument should be between 1 and the number of components"));
- const FIELD<double> * p_field_size=p_field_volume;
+ const FIELD<double,FullInterlace> * p_field_size=p_field_volume;
if(!p_field_volume) // if the user don't supply the volume
- p_field_size=_getFieldSize(); // we calculate the volume [PROVISOIRE, en attendant l'implémentation dans mesh]
+ 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_EN::MED_FULL_INTERLACE);
- const T* value=getValueI( MED_EN::MED_NO_INTERLACE, component); // get pointer to the component's values
+ const double* vol=p_field_size->getValue();
+ const T * value = NULL;
+ ArrayNo * myArray = NULL;
+ if ( getInterlacingType() == MED_EN::MED_NO_INTERLACE )
+ value = getColumn(component);
+ else {
+ myArray = ArrayConvert( *( dynamic_cast< ArrayFull * > ( getArrayNoGauss() ) ));
+ value = myArray->getColumn(component);
+ }
+
const T* lastvalue=value+getNumberOfValues(); // pointing just after the end of column
double integrale=0.0;
if(!p_field_volume) // if the user didn't supply the volume
delete p_field_size; // delete temporary volume field
+ if ( getInterlacingType() == MED_EN::MED_FULL_INTERLACE ) delete myArray;
if( totVol <= 0)
throw MEDEXCEPTION(STRING("cannot compute sobolev norm : volume is not positive!"));
* Cannot be applied to a field with a support on nodes.
* If the optional p_field_volume argument is furnished, the volume is not re-calculated.
*/
-template <class T> double FIELD<T>::normL1(const FIELD<double> * p_field_volume) const
+template <class T, class INTERLACING_TAG>
+double FIELD<T, INTERLACING_TAG>::normL1(const FIELD<double, FullInterlace> * p_field_volume) const
{
_checkNormCompatibility(p_field_volume); // may throw exception
- const FIELD<double> * p_field_size=p_field_volume;
+ const FIELD<double, FullInterlace> * p_field_size=p_field_volume;
if(!p_field_volume) // if the user don't supply the volume
- p_field_size=_getFieldSize(); // we calculate the volume [PROVISOIRE, en attendant l'implémentation dans mesh]
+ 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_EN::MED_FULL_INTERLACE);
+ const double* vol=p_field_size->getValue();
const double* lastvol=vol+getNumberOfValues(); // pointing just after the end of vol
- const T* value=getValue( MED_EN::MED_NO_INTERLACE); // get pointer to the field's values
+
+ const T * value = NULL;
+ ArrayNo * myArray = NULL;
+ if ( getInterlacingType() == MED_EN::MED_NO_INTERLACE )
+ value = getValue();
+ else {
+ myArray = ArrayConvert( *( dynamic_cast< ArrayFull * > ( getArrayNoGauss() ) ));
+ value = myArray->getPtr();
+ }
double totVol=0.0;
const double* p_vol=vol;
if(!p_field_volume) // if the user didn't supply the volume
delete p_field_size; // delete temporary volume field
+ if ( getInterlacingType() == MED_EN::MED_FULL_INTERLACE ) delete myArray;
if( totVol <= 0)
throw MEDEXCEPTION(STRING("cannot compute sobolev norm : volume is not positive!"));
/*! 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)
+template <class T, class INTERLACING_TAG>
+FIELD<T, INTERLACING_TAG>* FIELD<T, INTERLACING_TAG>::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);
+ return new FIELD<T, INTERLACING_TAG>(*this);
+
+ FIELD<T, INTERLACING_TAG> *ret = new FIELD<T, INTERLACING_TAG>(subSupport,
+ _numberOfComponents);
+
if(!ret->_value)
throw MEDEXCEPTION("FIELD<T>::extract : unvalid support detected !");
- T* valuesToSet=(T*)ret->_value->get(MED_EN::MED_FULL_INTERLACE);
+
+ T* valuesToSet=(T*)ret->getValue();
+
int nbOfEltsSub=subSupport->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS);
const int *eltsSub=subSupport->getNumber(MED_EN::MED_ALL_ELEMENTS);
T* tempVals=new T[_numberOfComponents];
valuesToSet[i*_numberOfComponents+j]=tempVals[j];
}
delete [] tempVals;
- ret->setValueType(_valueType);
+
ret->copyGlobalInfo(*this);
return ret;
}
iterationNumber and the order number orderNumber does not exist in the file
fieldDriverName; the constructor raises an exception.
*/
-template <class T> FIELD<T>::FIELD(const SUPPORT * Support,
- driverTypes driverType,
- const string & fileName/*=""*/,
- const string & fieldDriverName/*=""*/,
- const int iterationNumber,
- const int orderNumber)
- throw (MEDEXCEPTION)
+template <class T, class INTERLACING_TAG>
+FIELD<T, INTERLACING_TAG>::FIELD(const SUPPORT * Support,
+ driverTypes driverType,
+ const string & fileName/*=""*/,
+ const string & fieldDriverName/*=""*/,
+ const int iterationNumber,
+ const int orderNumber) throw (MEDEXCEPTION)
{
const char * LOC = "template <class T> FIELD<T>::FIELD(const SUPPORT * Support, driverTypes driverType, const string & fileName=\"\", const string & fieldName=\"\", const int iterationNumber=-1, const int orderNumber=-1) : ";
init();
+ //INITIALISATION DE _valueType DS LE CONSTRUCTEUR DE FIELD_
+ ASSERT(FIELD_::_valueType == MED_EN::MED_UNDEFINED_TYPE)
+ FIELD_::_valueType=SET_VALUE_TYPE<T>::_valueType;
+
+ //INITIALISATION DE _interlacingType DS LE CONSTRUCTEUR DE FIELD_
+ ASSERT(FIELD_::_interlacingType == MED_EN::MED_UNDEFINED_INTERLACE)
+ FIELD_::_interlacingType=SET_INTERLACING_TYPE<INTERLACING_TAG>::_interlacingType;
+
_support = Support;
//A.G. Addings for RC
if(_support)
_support->addReference();
- _value = (MEDARRAY<T>*)NULL;
+ _value = (MEDMEM_Array<T, INTERLACING_TAG> *) NULL;
_iterationNumber = iterationNumber;
_time = 0.0;
current = addDriver(driverType,fileName,fieldDriverName,MED_EN::MED_LECT);
-// switch(driverType)
-// {
-// case MED_DRIVER :
-// {
-// MED_FIELD_RDONLY_DRIVER<T> myDriver(fileName,this);
-// myDriver.setFieldName(fieldDriverName);
-// current = addDriver(myDriver);
-// break;
-// }
-// current = addDriver(driverType,fileName,fieldDriverName);
-// switch(_drivers[current]->getAccessMode() ) {
-// case MED_WRONLY : {
-// MESSAGE("FIELD<T>::FIELD(driverTypes driverType, .....) : driverType must have a MED_RDONLY or MED_RDWR accessMode");
-// rmDriver(current);
-// break;}
-// default : {
-// }
-// }
-// default :
-// {
-// throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Driver type unknown : can't create driver!"));
-// break;
-// }
-// }
+ _drivers[current]->open();
+ _drivers[current]->read();
+ _drivers[current]->close();
+
+ END_OF(LOC);
+}
+
+/*!
+ This constructor, at least, allows to create a FIELD without creating any
+ SUPPORT then without having to load a MESH object, a support is created. It
+ provides the meshName related mesh but doesn't not set a mesh in the created
+ support.
+*/
+template <class T, class INTERLACING_TAG>
+FIELD<T,INTERLACING_TAG>::FIELD(driverTypes driverType,
+ const string & fileName,
+ const string & fieldDriverName,
+ const int iterationNumber,
+ const int orderNumber)
+ throw (MEDEXCEPTION) :FIELD_()
+{
+ int current;
+ const char * LOC ="FIELD<T,INTERLACING_TAG>::FIELD( driverTypes driverType, const string & fileName, string & fieldDriverName, int iterationNumber, int orderNumber) : ";
+ BEGIN_OF(LOC);
+
+ init();
+
+ //INITIALISATION DE _valueType DS LE CONSTRUCTEUR DE FIELD_
+ ASSERT(FIELD_::_valueType == MED_EN::MED_UNDEFINED_TYPE)
+ FIELD_::_valueType=SET_VALUE_TYPE<T>::_valueType;
+
+ //INITIALISATION DE _interlacingType DS LE CONSTRUCTEUR DE FIELD_
+ ASSERT(FIELD_::_interlacingType == MED_EN::MED_UNDEFINED_INTERLACE)
+ FIELD_::_interlacingType=SET_INTERLACING_TYPE<INTERLACING_TAG>::_interlacingType;
+
+ _support = (SUPPORT *) NULL;
+ _value = (MEDMEM_Array<T,INTERLACING_TAG> *)NULL;
+
+ _iterationNumber = iterationNumber;
+ _time = 0.0;
+ _orderNumber = orderNumber;
+
+ current = addDriver(driverType,fileName,fieldDriverName,MED_EN::MED_LECT);
_drivers[current]->open();
_drivers[current]->read();
/*!
Destructor.
*/
-template <class T> FIELD<T>::~FIELD()
+template <class T, class INTERLACING_TAG> FIELD<T, INTERLACING_TAG>::~FIELD()
{
- BEGIN_OF(" Destructeur FIELD<T>::~FIELD()");
+ BEGIN_OF(" Destructeur FIELD<T, INTERLACING_TAG>::~FIELD()");
SCRUTE(this);
if (_value) delete _value;
- END_OF(" Destructeur FIELD<T>::~FIELD()");
+ END_OF(" Destructeur FIELD<T,INTERLACING_TAG>::~FIELD()");
}
/*!
*/
-template <class T> void FIELD<T>::allocValue(const int NumberOfComponents)
+template <class T, class INTERLACING_TAG>
+void FIELD<T, INTERLACING_TAG>::allocValue(const int NumberOfComponents)
{
- const char* LOC = "FIELD<T>::allocValue(const int NumberOfComponents)" ;
+ const char* LOC = "FIELD<T, INTERLACING_TAG>::allocValue(const int NumberOfComponents)" ;
BEGIN_OF(LOC);
_numberOfComponents = NumberOfComponents ;
}
try {
+ // becarefull about the number of gauss point
_numberOfValues = _support->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS);
MESSAGE(LOC <<" : "<<_numberOfValues <<" et "<< NumberOfComponents);
- _value = new MEDARRAY<T>(_numberOfComponents,_numberOfValues);
+ //EF : A modifier lors de l'intégration de la classe de localisation des points de gauss
+ _value = new ArrayNoGauss(_numberOfComponents,_numberOfValues);
_isRead = true ;
}
catch (MEDEXCEPTION &ex) {
MESSAGE("No value defined, problem with NumberOfComponents (and may be _support) size of MEDARRAY<T>::_value !");
- _value = (MEDARRAY<T>*)NULL ;
+ _value = (MEDMEM_Array<T, INTERLACING_TAG> *)NULL ;
}
SCRUTE(_value);
- END_OF("void FIELD<T>::allocValue(const int NumberOfComponents)");
+ END_OF("void FIELD<T, INTERLACING_TAG>::allocValue(const int NumberOfComponents)");
}
/*!
*/
-template <class T> void FIELD<T>::allocValue(const int NumberOfComponents, const int LengthValue)
+template <class T, class INTERLACING_TAG>
+void FIELD<T, INTERLACING_TAG>::allocValue(const int NumberOfComponents,
+ const int LengthValue)
{
BEGIN_OF("void FIELD<T>::allocValue(const int NumberOfComponents,const int LengthValue)");
MESSAGE("FIELD : constructeur : "<<LengthValue <<" et "<< NumberOfComponents);
_numberOfValues = LengthValue ;
- _value = new MEDARRAY<T>(_numberOfComponents,_numberOfValues);
+
+ //EF : A modifier lors de l'intégration de la classe de localisation des points de gauss
+ _value = new ArrayNoGauss(_numberOfComponents,_numberOfValues);
+
_isRead = true ;
SCRUTE(_value);
- END_OF("void FIELD<T>::allocValue(const int NumberOfComponents,const int LengthValue)");
+ END_OF("void FIELD<T, INTERLACING_TAG>::allocValue(const int NumberOfComponents,const int LengthValue)");
}
/*!
*/
-template <class T> void FIELD<T>::deallocValue()
+template <class T, class INTERLACING_TAG>
+void FIELD<T, INTERLACING_TAG>::deallocValue()
{
- BEGIN_OF("void FIELD<T>::deallocValue()");
+ BEGIN_OF("void FIELD<T, INTERLACING_TAG>::deallocValue()");
_numberOfValues = 0 ;
_numberOfComponents = 0 ;
if (_value != NULL)
delete _value;
- END_OF("void FIELD<T>::deallocValue()");
+ END_OF("void FIELD<T, INTERLACING_TAG>::deallocValue()");
}
// -----------------
read or write methods.
*/
-template <class T> int FIELD<T>::addDriver(driverTypes driverType,
- const string & fileName/*="Default File Name.med"*/,
- const string & driverName/*="Default Field Name"*/,
- MED_EN::med_mode_acces access)
+template <class T, class INTERLACING_TAG>
+int FIELD<T, INTERLACING_TAG>::addDriver(driverTypes driverType,
+ const string & fileName/*="Default File Name.med"*/,
+ const string & driverName/*="Default Field Name"*/,
+ MED_EN::med_mode_acces access)
{
//jfa tmp (as last argument has no default value):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,const string & driverName,MED_EN::med_mode_acces access) :";//jfa tmp
Duplicate the given driver and return its index reference to path to
read or write methods.
*/
-template <class T> inline int FIELD<T>::addDriver (GENDRIVER & driver )
+template <class T, class INTERLACING_TAG>
+inline int FIELD<T, INTERLACING_TAG>::addDriver (GENDRIVER & driver )
{
- const char * LOC = "FIELD<T>::addDriver(GENDRIVER &) : ";
+ const char * LOC = "FIELD<T, INTERLACING_TAG>::addDriver(GENDRIVER &) : ";
int current;
BEGIN_OF(LOC);
/*!
Remove the driver referenced by its index.
*/
-template <class T> void FIELD<T>::rmDriver (int index/*=0*/)
+template <class T, class INTERLACING_TAG>
+void FIELD<T, INTERLACING_TAG>::rmDriver (int index/*=0*/)
{
- const char * LOC = "FIELD<T>::rmDriver (int index=0): ";
+ const char * LOC = "FIELD<T, INTERLACING_TAG>::rmDriver (int index=0): ";
BEGIN_OF(LOC);
if ( _drivers[index] ) {
/*!
Read FIELD in the file specified in the driver given by its index.
*/
-template <class T> inline void FIELD<T>::read(int index/*=0*/)
+template <class T, class INTERLACING_TAG> inline void FIELD<T, INTERLACING_TAG>::read(int index/*=0*/)
{
- const char * LOC = "FIELD<T>::read(int index=0) : ";
+ const char * LOC = "FIELD<T, INTERLACING_TAG>::read(int index=0) : ";
BEGIN_OF(LOC);
if ( _drivers[index] ) {
/*!
Write FIELD in the file specified in the driver given by its index.
*/
-template <class T> inline void FIELD<T>::write(int index/*=0*/, const string & driverName /*= ""*/)
+template <class T, class INTERLACING_TAG> inline void FIELD<T, INTERLACING_TAG>::write(int index/*=0*/, const string & driverName /*= ""*/)
{
- const char * LOC = "FIELD<T>::write(int index=0, const string & driverName = \"\") : ";
+ const char * LOC = "FIELD<T,INTERLACING_TAG>::write(int index=0, const string & driverName = \"\") : ";
BEGIN_OF(LOC);
if( _drivers[index] ) {
Write FIELD in the file specified in the driver given by its index. Use this
method for ASCII drivers (e.g. VTK_DRIVER)
*/
-template <class T> inline void FIELD<T>::writeAppend(int index/*=0*/, const string & driverName /*= ""*/)
+template <class T, class INTERLACING_TAG> inline void FIELD<T, INTERLACING_TAG>::writeAppend(int index/*=0*/, const string & driverName /*= ""*/)
{
- const char * LOC = "FIELD<T>::write(int index=0, const string & driverName = \"\") : ";
+ const char * LOC = "FIELD<T,INTERLACING_TAG>::write(int index=0, const string & driverName = \"\") : ";
BEGIN_OF(LOC);
if( _drivers[index] ) {
Use by MED object.
*/
-template <class T> inline void FIELD<T>::write(const GENDRIVER & genDriver)
+template <class T, class INTERLACING_TAG> inline void FIELD<T, INTERLACING_TAG>::write(const GENDRIVER & genDriver)
{
- const char * LOC = " FIELD<T>::write(const GENDRIVER &) : ";
+ const char * LOC = " FIELD<T, INTERLACING_TAG>::write(const GENDRIVER &) : ";
BEGIN_OF(LOC);
for (unsigned int index=0; index < _drivers.size(); index++ )
Use by MED object. Use this method for ASCII drivers (e.g. VTK_DRIVER).
*/
-template <class T> inline void FIELD<T>::writeAppend(const GENDRIVER & genDriver)
+template <class T, class INTERLACING_TAG> inline void FIELD<T, INTERLACING_TAG>::writeAppend(const GENDRIVER & genDriver)
{
- const char * LOC = " FIELD<T>::write(const GENDRIVER &) : ";
+ const char * LOC = " FIELD<T, INTERLACING_TAG>::write(const GENDRIVER &) : ";
BEGIN_OF(LOC);
for (unsigned int index=0; index < _drivers.size(); index++ )
Use by MED object.
*/
-template <class T> inline void FIELD<T>::read(const GENDRIVER & genDriver)
+template <class T, class INTERLACING_TAG> inline void FIELD<T, INTERLACING_TAG>::read(const GENDRIVER & genDriver)
{
- const char * LOC = " FIELD<T>::read(const GENDRIVER &) : ";
+ const char * LOC = " FIELD<T, INTERLACING_TAG>::read(const GENDRIVER &) : ";
BEGIN_OF(LOC);
for (unsigned int index=0; index < _drivers.size(); index++ )
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
+template <class T, class INTERLACING_TAG>
+bool FIELD<T, INTERLACING_TAG>::getValueOnElement(int eltIdInSup,T* retValues)
+ const throw (MEDEXCEPTION)
{
+// retValues = getRow(eltIdInSup);
+
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);
+ const T* valsThis=getValue();
for(int j=0;j<_numberOfComponents;j++)
retValues[j]=valsThis[(eltIdInSup-1)*_numberOfComponents+j];
return true;
iThis++;
if(!found)
return false;
- const T* valsThis=getValue(MED_EN::MED_FULL_INTERLACE);
+ const T* valsThis=getValue();
for(int j=0;j<_numberOfComponents;j++)
retValues[j]=valsThis[iThis*_numberOfComponents+j];
return true;
Destroy the MEDARRAY<T> in FIELD and put the new one without copy.
\endif
*/
-template <class T> inline void FIELD<T>::setValue(MEDARRAY<T> *Value)
+template <class T, class INTERLACING_TAG>
+inline void FIELD<T, INTERLACING_TAG>::setArray(MEDMEM_Array_ * Value)
+ throw (MEDEXCEPTION)
{
if (NULL != _value) delete _value ;
_value=Value ;
/*!
\if developper
- Return a reference to the MEDARRAY<T> in FIELD.
+ Return a reference to the MEDARRAY<T, INTERLACING_TAG> in FIELD.
\endif
*/
-template <class T> inline MEDARRAY<T>* FIELD<T>::getvalue() const
+template <class T, class INTERLACING_TAG>
+inline MEDMEM_Array_ * FIELD<T, INTERLACING_TAG>::getArray() const throw (MEDEXCEPTION)
{
+ const char * LOC = "MEDMEM_Array_ * FIELD<T, INTERLACING_TAG>::getArray() : ";
+ BEGIN_OF(LOC);
+ END_OF(LOC);
return _value ;
}
+template <class T,class INTERLACING_TAG> inline
+typename MEDMEM_ArrayInterface<T,INTERLACING_TAG,Gauss>::Array *
+FIELD<T, INTERLACING_TAG>::getArrayGauss() const throw (MEDEXCEPTION)
+{
+ const char * LOC = "FIELD<T, INTERLACING_TAG>::getArrayGauss() : ";
+ BEGIN_OF(LOC);
+
+ if ( getGaussPresence() )
+ return dynamic_cast<ArrayGauss *> (_value);
+ else
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<
+ "The field has no Gauss Point"));
+
+ END_OF(LOC);
+
+}
+
+template <class T,class INTERLACING_TAG> inline
+typename MEDMEM_ArrayInterface<T,INTERLACING_TAG,NoGauss>::Array *
+FIELD<T, INTERLACING_TAG>::getArrayNoGauss() const throw (MEDEXCEPTION)
+{
+ const char * LOC = "FIELD<T, INTERLACING_TAG>::getArrayNoGauss() : ";
+ BEGIN_OF(LOC);
+
+ if ( ! getGaussPresence() )
+ return dynamic_cast < ArrayNoGauss * > (_value);
+ else
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<
+ "The field has Gauss Point"));
+
+ END_OF(LOC);
+}
+
+
+template <class T,class INTERLACING_TAG> inline bool
+FIELD<T, INTERLACING_TAG>::getGaussPresence() const throw (MEDEXCEPTION)
+{
+ const char * LOC = "FIELD<T, INTERLACING_TAG>::getGaussPresence() const :";
+ BEGIN_OF(LOC);
+
+ if (_value != NULL)
+ return _value->getGaussPresence();
+ else
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Can't call getGaussPresence on a null _value"));
+
+ END_OF(LOC);
+}
/*!
Return the actual length of the reference to values array returned by getValue.
*/
-template <class T> inline int FIELD<T>::getValueLength(MED_EN::medModeSwitch Mode) const{
+template <class T, class INTERLACING_TAG>
+inline int FIELD<T, INTERLACING_TAG>::getValueLength() const
+ throw (MEDEXCEPTION)
+{
+ // be carefull about number of gauss point
return _numberOfComponents*_numberOfValues;
}
/*!
Return a reference to values array to read them.
*/
-template <class T> inline const T* FIELD<T>::getValue(MED_EN::medModeSwitch Mode) const
+template <class T, class INTERLACIN_TAG>
+inline const T* FIELD<T, INTERLACIN_TAG>::getValue() const throw (MEDEXCEPTION)
{
- return _value->get(Mode) ;
+ const char * LOC ="FIELD<T, INTERLACING_TAG>::getValue() : ";
+ BEGIN_OF(LOC);
+ if ( getGaussPresence() )
+ return dynamic_cast<ArrayGauss *>(_value)->getPtr() ;
+ else
+ return dynamic_cast<ArrayNoGauss *>(_value)->getPtr() ;
+}
+/*!
+ Return a reference to i^{th} row
+ of FIELD values array.
+ If a faster accessor is intended you may use getArray() once,
+ then MEDMEM_Array accessors.
+ Be careful if field support is not on all elements you might
+ have to use support->getValIndFromGlobalNumber(i).
+*/
+template <class T,class INTERLACING_TAG> inline
+const T*
+FIELD<T,INTERLACING_TAG>::getRow(int i) const throw (MEDEXCEPTION)
+{
+ const char * LOC = "FIELD<T,INTERLACING_TAG>::getRow(int i) : ";
+ BEGIN_OF(LOC);
+
+ int valIndex=-1;
+ if (_support)
+ valIndex = _support->getValIndFromGlobalNumber(i);
+ else
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Support not define |" ));
+
+ if ( getGaussPresence() )
+ return dynamic_cast<ArrayGauss *>(_value)->getRow(valIndex) ;
+ else
+ return dynamic_cast<ArrayNoGauss *>(_value)->getRow(valIndex) ;
+ END_OF(LOC);
}
/*!
- Return a reference to i^{th} row or column - component - (depend on Mode value)
+ Return a reference to j^{th} column
of FIELD values array.
*/
-template <class T> inline const T* FIELD<T>::getValueI(MED_EN::medModeSwitch Mode,int i) const
+template <class T,class INTERLACING_TAG> inline const T*
+FIELD<T,INTERLACING_TAG>::getColumn(int j) const throw (MEDEXCEPTION)
{
- if ( Mode == MED_EN::MED_FULL_INTERLACE )
- {
- return _value->getRow(i) ;
- }
- ASSERT ( Mode == MED_EN::MED_NO_INTERLACE);
- return _value->getColumn(i);
+ const char * LOC ="FIELD<T,INTERLACING_TAG>::getColumn(int j) : ";
+ BEGIN_OF(LOC);
+ if ( getGaussPresence() )
+ return dynamic_cast<ArrayGauss *>(_value)->getColumn(j) ;
+ else
+ return dynamic_cast<ArrayNoGauss *>(_value)->getColumn(j) ;
}
/*!
Return the value of i^{th} element and j^{th} component.
*/
-template <class T> inline T FIELD<T>::getValueIJ(int i,int j) const
+template <class T,class INTERLACING_TAG> inline T FIELD<T,INTERLACING_TAG>::getValueIJ(int i,int j) const throw (MEDEXCEPTION)
{
- return _value->getIJ(i,j) ;
+ const char * LOC = "getValueIJ(..)";
+ BEGIN_OF(LOC);
+ int valIndex=-1;
+ if (_support)
+ valIndex = _support->getValIndFromGlobalNumber(i);
+ else
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Support not define |" ));
+
+ if ( getGaussPresence() )
+ return dynamic_cast<ArrayGauss *>(_value)->getIJ(valIndex,j) ;
+ else
+ return dynamic_cast<ArrayNoGauss *>(_value)->getIJ(valIndex,j) ;
}
/*!
Array must have right size. If not results are unpredicable.
*/
-template <class T> inline void FIELD<T>::setValue(MED_EN::medModeSwitch mode, T* value)
+template <class T,class INTERLACING_TAG> inline void FIELD<T,INTERLACING_TAG>::setValue( T* value) throw (MEDEXCEPTION)
{
- _value->set(mode,value);
+ if ( getGaussPresence() )
+ return dynamic_cast<ArrayGauss *>(_value)->setPtr(value) ;
+ else
+ return dynamic_cast<ArrayNoGauss *>(_value)->setPtr(value) ;
}
/*!
- Update values array in FIELD with the given ones according to specified mode.
+ Update values array in the j^{th} row of FIELD values array with the given ones and
+ according to specified mode.
*/
-template <class T> inline void FIELD<T>::setValueI(MED_EN::medModeSwitch mode, int i, T* value)
+template <class T,class INTERLACING_TAG>
+inline void FIELD<T,INTERLACING_TAG>::setRow( int i, T* value) throw (MEDEXCEPTION)
{
- // PROVISOIRE :
- if (MED_EN::MED_FULL_INTERLACE == mode)
- _value->setI(i,value);
- else if (MED_EN::MED_NO_INTERLACE == mode)
- _value->setJ(i,value);
+ const char * LOC = "FIELD<T,INTERLACING_TAG>::setRow(int i, T* value) : ";
+ int valIndex=i;
+// JE (NB) NE SUIS PAS SUR DE CA ????
+ if (_support)
+ valIndex = _support->getValIndFromGlobalNumber(i);
+ else
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Support not define |" ));
+
+ if ( getGaussPresence() )
+ return dynamic_cast<ArrayGauss *>(_value)->setRow(valIndex, value) ;
else
- throw MEDEXCEPTION(LOCALIZED("FIELD<T>::setValueI : bad medModeSwitch")) ;
+ return dynamic_cast<ArrayNoGauss *>(_value)->setRow(valIndex, value) ;
+}
+
+/*!
+ Update values array in the j^{th} column of FIELD values array with the given ones and
+ according to specified mode.
+*/
+template <class T,class INTERLACING_TAG>
+inline void FIELD<T,INTERLACING_TAG>::setColumn( int i, T* value) throw (MEDEXCEPTION)
+{
+ if ( getGaussPresence() )
+ return dynamic_cast<ArrayGauss *>(_value)->setColumn(i, value) ;
+ else
+ return dynamic_cast<ArrayNoGauss *>(_value)->setColumn(i, value) ;
}
/*!
Set the value of i^{th} element and j^{th} component with the given one.
*/
-template <class T> inline void FIELD<T>::setValueIJ(int i, int j, T value)
+template <class T,class INTERLACING_TAG> inline void FIELD<T,INTERLACING_TAG>::setValueIJ(int i, int j, T value) throw (MEDEXCEPTION)
{
- _value->setIJ(i,j,value);
+ const char * LOC = "FIELD<T,INTERLACING_TAG>::setValueIJ(int i, int j, T value) : ";
+ int valIndex=-1;
+ if (_support)
+ valIndex = _support->getValIndFromGlobalNumber(i);
+ else
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Support not define |" ));
+
+ if ( getGaussPresence() )
+ return dynamic_cast<ArrayGauss *>(_value)->setIJ(valIndex,j,value) ;
+ else
+ return dynamic_cast<ArrayNoGauss *>(_value)->setIJ(valIndex,j,value) ;
}
/*
/*!
Fill values array with volume values.
*/
-template <class T> void FIELD<T>::getVolume() const throw (MEDEXCEPTION)
+template <class T, class INTERLACING_TAG>
+void FIELD<T, INTERLACING_TAG>::getVolume() const throw (MEDEXCEPTION)
{
const char * LOC = "FIELD<double>::getVolume() const : ";
BEGIN_OF(LOC);
/*!
Fill values array with area values.
*/
-template <class T> void FIELD<T>::getArea() const throw (MEDEXCEPTION)
+template <class T, class INTERLACING_TAG>
+void FIELD<T, INTERLACING_TAG>::getArea() const throw (MEDEXCEPTION)
{
const char * LOC = "FIELD<double>::getArea() const : ";
BEGIN_OF(LOC);
/*!
Fill values array with length values.
*/
-template <class T> void FIELD<T>::getLength() const throw (MEDEXCEPTION)
+template <class T, class INTERLACING_TAG>
+void FIELD<T, INTERLACING_TAG>::getLength() const throw (MEDEXCEPTION)
{
const char * LOC = "FIELD<double>::getLength() const : ";
BEGIN_OF(LOC);
/*!
Fill values array with normal values.
*/
-template <class T> void FIELD<T>::getNormal() const throw (MEDEXCEPTION)
+template <class T, class INTERLACING_TAG>
+void FIELD<T, INTERLACING_TAG>::getNormal() const throw (MEDEXCEPTION)
{
const char * LOC = "FIELD<double>::getNormal() const : ";
BEGIN_OF(LOC);
/*!
Fill values array with barycenter values.
*/
-template <class T> void FIELD<T>::getBarycenter() const throw (MEDEXCEPTION)
+template <class T, class INTERLACING_TAG>
+void FIELD<T, INTERLACING_TAG>::getBarycenter() const throw (MEDEXCEPTION)
{
const char * LOC = "FIELD<double>::getBarycenter() const : ";
BEGIN_OF(LOC);
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()
+template <class T, class INTERLACING_TAG>
+void FIELD<T, INTERLACING_TAG>::fillFromAnalytic(myFuncType f) throw (MEDEXCEPTION)
{
+ const char * LOC = "void FIELD<T, INTERLACING_TAG>::fillFromAnalytic(myFuncType f) : ";
int i,j;
+ if (_support == (SUPPORT *) NULL)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"No Support defined."));
+
MESH * mesh = _support->getMesh();
int spaceDim = mesh->getSpaceDimension();
const double * coord;
- FIELD<double> * barycenterField=0;
+
+ const double * bary;
+ FIELD<double,FullInterlace> * barycenterField=0;
+
double ** xyz=new double* [spaceDim];
bool deallocateXyz=false;
if(_support->getEntity()==MED_EN::MED_NODE)
else
{
barycenterField = mesh->getBarycenter(_support);
- coord=barycenterField->getValue(MED_EN::MED_NO_INTERLACE);
+ bary=barycenterField->getValue();
for(i=0; i<spaceDim; i++)
- xyz[i]=(double *)(coord+i*_numberOfValues);
+ xyz[i]=(double *)(bary+i*_numberOfValues);
}
- T* valsToSet=(T*)getValue(MED_EN::MED_FULL_INTERLACE);
+ T* valsToSet=(T*)getValue();
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);
+ f(temp,valsToSet+i*_numberOfComponents);
}
delete [] temp;
if(barycenterField)
--- /dev/null
+#ifndef FIELD_CONVERT_HXX
+#define FIELD_CONVERT_HXX
+
+#include "MEDMEM_FieldForward.hxx"
+#include "MEDMEM_ArrayInterface.hxx"
+#include "MEDMEM_ArrayConvert.hxx"
+
+namespace MEDMEM {
+
+template <class T> FIELD<T,FullInterlace> *
+FieldConvert(const FIELD<T,NoInterlace> & field )
+{
+ typedef typename MEDMEM_ArrayInterface<T,FullInterlace,NoGauss>::Array ArrayFullNo;
+ typedef typename MEDMEM_ArrayInterface<T,FullInterlace,Gauss>::Array ArrayFullGa;
+
+ FIELD<T,FullInterlace> * myField = new FIELD<T,FullInterlace>();
+ FIELD_ * myField_ = myField;
+ FIELD_ * field_ = &(const_cast< FIELD<T,NoInterlace> &> (field));
+ *myField_ = *field_; // Opérateur d'affectation de FIELD_ OK
+ // *((FIELD_ *) myField) = (FIELD_ ) field; //Contructeur par recopie de FIELD_ Pourquoi?
+
+ if ( field.getGaussPresence() ) {
+ ArrayFullGa * myArray = ArrayConvert( *(field.getArrayGauss()) );
+ myField->setArray(myArray);
+ return myField;
+ } else {
+ ArrayFullNo * myArray = ArrayConvert( *(field.getArrayNoGauss()) );
+ myField->setArray(myArray);
+ return myField;
+ }
+}
+
+template <class T> FIELD<T,NoInterlace> *
+FieldConvert(const FIELD<T,FullInterlace> & field )
+{
+ typedef typename MEDMEM_ArrayInterface<T,NoInterlace,NoGauss>::Array ArrayNoNo;
+ typedef typename MEDMEM_ArrayInterface<T,NoInterlace,Gauss>::Array ArrayNoGa;
+
+
+ FIELD<T,NoInterlace> * myField = new FIELD<T,NoInterlace>();
+ FIELD_ * myField_ = myField;
+ FIELD_ * field_ = &(const_cast< FIELD<T,FullInterlace> &> (field));
+ *myField_ = *field_; // Opérateur d'affectation de FIELD_ OK
+ // *((FIELD_*) myField) = (FIELD_) field; //Contructeur par recopie de FIELD_ Pourquoi?
+
+ if ( field.getGaussPresence() ) {
+ ArrayNoGa * myArray = ArrayConvert( *(field.getArrayGauss()) );
+ myField->setArray(myArray);
+ return myField;
+ } else {
+ ArrayNoNo * myArray = ArrayConvert( *(field.getArrayNoGauss()) );
+ myField->setArray(myArray);
+ return myField;
+ }
+
+}
+
+}
+#endif
--- /dev/null
+#ifndef FIELD_FORWARD
+#define FIELD_FORWARD
+
+#include "MEDMEM_Tags.hxx"
+
+namespace MEDMEM {
+ template <class T,class INTERLACING_TAG=FullInterlace > class FIELD;
+
+}
+#endif
#include "MEDMEM_define.hxx"
#include "MEDMEM_DriverTools.hxx"
+class MEDMEM::FIELD_;
+
#include <stdio.h>
#include <fcntl.h>
#ifdef WNT
// (2) 0 1
// (3) FX FY FZ FZ FX FY FLX
// (4) 0 0 0 0 0 0 0
- // (5) créé par muc pri
+ // (5) cré© par muc pri
// (6)
// (7) 2
GIBI_MESH_DRIVER::GIBI_MESH_DRIVER():
GENDRIVER(),
- _ptrMesh(( MESH *)MED_NULL),
+ _ptrMesh(( MESH *) NULL),
// A VOIR _medIdt(MED_INVALID),
_meshName("")
{
void GIBI_MESH_RDONLY_DRIVER::read(void) throw (MEDEXCEPTION)
{
const char * LOC = "_GIBI_RDONLY_DRIVER::read() : " ;
+ BEGIN_OF(LOC);
if (_status!=MED_OPENED)
throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "The _idt of file " << _fileName << " is : "
{
INFOS( ex.what() );
}
-
+ END_OF(LOC);
}
//=======================================================================
//purpose :
//=======================================================================
-template< class T >
- static void writeDataSection (fstream& file,
- FIELD_* field,
- int id1,
- int id2)
+template< class T, class INTERLACING_TAG>
+static void writeDataSection (fstream& file,
+ FIELD<T, INTERLACING_TAG> * field,
+ int id1,
+ int id2) throw (MEDEXCEPTION)
{
- FIELD<T>* f = dynamic_cast<FIELD<T>*>( field );
- if (!f) return;
- MEDARRAY<T>* array = f->getvalue();
- int ld = array->getLeadingValue();
+ const char * LOC="writeDataSection (.....) :";
+ BEGIN_OF(LOC);
+
+ int ld = field->getNumberOfComponents();
+
+// 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
while ( id < id2 )
{
for ( int i = 0; id < id2 && i < 3; ++i )
- file << setw(22) << array->getIJ( id++, iComp + 1);
+ file << setw(22) << field->getValueIJ( id++, iComp + 1);
file << endl;
}
}
+ END_OF(LOC);
}
//=======================================================================
for ( ; fIt != dtit.end(); fIt++ )
{
FIELD_ * f = _med->getField( names[ iField ], fIt->dt, fIt->it );
- if ( !dynamic_cast< FIELD<double >* >( f ))
+ if ( f->getValueType() != MED_EN::MED_INT32 )
{
MESSAGE("GIBI_MED_WRONLY_DRIVER::write( FIELD< int > ) not implemented");
continue;
// Data section
int id2 = id1 + idsize->second;
- writeDataSection<double>( gibi, f, id1, id2 );
+
+ if (f->getGaussPresence() )
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << " GibiDriver don't support Field with Gauss point" ));
+
+ if ( f->getInterlacingType() == MED_NO_INTERLACE )
+ writeDataSection( gibi, dynamic_cast<FIELD<double,NoInterlace>*>(f), id1, id2 );
+ else
+ writeDataSection( gibi, dynamic_cast< FIELD<double,FullInterlace> * >(f), id1, id2 );
+
id1 = id2;
}
} // loop on fields
#include "MEDMEM_Exception.hxx"
#include "MEDMEM_Utilities.hxx"
+#include "MEDMEM_FieldForward.hxx"
+
/////
#include <sstream>
#include <iomanip>
namespace MEDMEM {
class MED;
class MESH;
-class FIELD_;
+ //class FIELD_;
class FAMILY;
class GROUP;
class SUPPORT;
using namespace MEDMEM;
using namespace MED_EN;
-GROUP::GROUP():_numberOfFamilies(0),_family()
+GROUP::GROUP():SUPPORT(),_numberOfFamilies(0),_family()
{
MESSAGE("GROUP()");
};
GROUP & GROUP::operator=(const GROUP &group)
{
MESSAGE("GROUP::operator=");
+ if ( &group == this ) return *this;
+ SUPPORT::operator=(group);
_numberOfFamilies = group._numberOfFamilies ;
_family = group._family ;
return *this;
throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "building of a GROUP object from several FAMILY, and one of them is on all entities" )) ;
_numberOfGeometricType = myFamily->getNumberOfTypes() ;
- _geometricType = new medGeometryElement[_numberOfGeometricType];
- //_geometricTypeNumber = new int[_numberOfGeometricType] ;
- _numberOfGaussPoint = new int[_numberOfGeometricType] ;
- _numberOfElements = new int[_numberOfGeometricType] ;
+
+ _geometricType.set(_numberOfGeometricType);
+ _numberOfGaussPoint.set(_numberOfGeometricType) ;
+ _numberOfElements.set(_numberOfGeometricType) ;
+
const medGeometryElement * geometricType = myFamily->getTypes() ;
//int * geometricTypeNumber = myFamily->getGeometricTypeNumber() ;
const int * numberOfGaussPoint = myFamily->getNumberOfGaussPoint() ;
GROUP::GROUP(const GROUP & m):SUPPORT(m)
{
_numberOfFamilies = m._numberOfFamilies;
- _family = m._family;
+ _family = m._family; //Copie profonde dans FAMILY Rmq from EF
};
// void GROUP::init(const list<FAMILY*> & families)
--- /dev/null
+#ifndef MEDMEM_INDEX_CHECKING_POLICY_HXX
+#define MEDMEM_INDEX_CHECKING_POLICY_HXX
+
+#include "MEDMEM_Exception.hxx"
+#include "MEDMEM_STRING.hxx"
+
+namespace MEDMEM {
+
+class IndexCheckPolicy {
+public :
+ inline void checkMoreThanZero(const std::string & classname, int index) const {
+ if (index <= 0)
+ throw MEDEXCEPTION(LOCALIZED(STRING("In ") << classname << ", index : " << index << " is less or equal to zero"));
+ }
+ inline void checkLessOrEqualThan(const std::string & classname, int max, int index) const {
+ if (index > max)
+ throw MEDEXCEPTION(LOCALIZED(STRING("In ") << classname << ", index : " << index << " is more than " << max ));
+ }
+
+ inline void checkInInclusiveRange(const std::string & classname, int min, int max, int index) const {
+ if (index < min || index > max )
+ throw MEDEXCEPTION(LOCALIZED(STRING("In ") << classname << ", index : " << index
+ << " not in rang [" << min << "," << max <<"]"));
+ }
+
+ inline void checkEquality(const std::string & classname, int a, int b) const {
+ if ( a == b )
+ throw MEDEXCEPTION(LOCALIZED(STRING("In ") << classname << ", Value shouldn't be : " << a ));
+ }
+
+};
+
+class NoIndexCheckPolicy {
+public :
+ inline void checkMoreThanZero(const string &classname, int index) const {}
+ inline void checkLessOrEqualThan(const std::string & classname, int max, int index) const {}
+ inline void checkInInclusiveRange(const std::string & classname, int min, int max, int index) const {}
+ inline void checkEquality(const std::string & classname, int a, int b) const {}
+};
+
+}// END NAMESPACE
+#endif
--- /dev/null
+#ifndef MEDMEM_INTERLACING_HXX
+#define MEDMEM_INTERLACING_HXX
+
+#include <iostream>
+#include "MEDMEM_Utilities.hxx"
+
+#include "MEDMEM_PointerOf.hxx"
+#include "MEDMEM_define.hxx"
+
+namespace MEDMEM {
+
+class InterlacingPolicy {
+protected:
+ ~InterlacingPolicy() {} //pour éviter qu'un utilisateur cast la class array en politique
+public :
+ InterlacingPolicy(void) : _dim(0), _nbelem(0),
+ _arraySize(0),
+ _interlacing(MED_EN::MED_UNDEFINED_INTERLACE),
+ _gaussPresence(false) {}
+
+ InterlacingPolicy(int nbelem, int dim, int arraySize=0, int interlacing=MED_EN::MED_UNDEFINED_INTERLACE) :
+ _dim(dim),
+ _nbelem(nbelem),
+ _arraySize(arraySize),
+ _interlacing(interlacing),
+ _gaussPresence(false) {}
+
+ // Constructeur par recopie
+ InterlacingPolicy(const InterlacingPolicy & intpol,
+ bool shallowcopy = true) :_dim(intpol._dim),
+ _nbelem(intpol._nbelem),
+ _arraySize(intpol._arraySize),
+ _interlacing(intpol._interlacing),
+ _gaussPresence(intpol._gaussPresence) {}
+
+ InterlacingPolicy & operator=(const InterlacingPolicy & intpol) {
+ if ( this == &intpol ) return *this;
+ BEGIN_OF("InterlacingPolicy operator =");
+
+ _dim = intpol._dim;
+ _nbelem = intpol._nbelem; //ne prend pas en compte les points de Gauss
+ _arraySize = intpol._arraySize;
+ _interlacing = intpol._interlacing;
+ _gaussPresence = intpol._gaussPresence;
+
+ return *this;
+ }
+
+ inline int getDim() const { return _dim; }
+ inline int getNbElem() const { return _nbelem; }
+ inline int getArraySize() const { return _arraySize; }
+ inline MED_EN::medModeSwitch getInterlacingType() const {return _interlacing;}
+ inline bool getGaussPresence() const { return _gaussPresence;}
+ virtual int getNbGauss(int i) const = 0;
+
+ int _dim;
+ int _nbelem;
+ int _arraySize;
+ MED_EN::medModeSwitch _interlacing;
+ bool _gaussPresence;
+};
+
+
+class FullInterlaceNoGaussPolicy : public InterlacingPolicy {
+
+protected:
+ ~FullInterlaceNoGaussPolicy() {} //pour éviter qu'un utilisateur cast la class array en politique
+
+public :
+ FullInterlaceNoGaussPolicy() : InterlacingPolicy() {}
+ FullInterlaceNoGaussPolicy(int nbelem, int dim) :
+ InterlacingPolicy(nbelem, dim, dim*nbelem,MED_EN::MED_FULL_INTERLACE) {}
+
+ FullInterlaceNoGaussPolicy(const FullInterlaceNoGaussPolicy & policy,
+ bool shallowcopie=true)
+ : InterlacingPolicy(policy) {};
+
+ inline int getIndex(int i,int j) const {
+ return (i-1)*_dim + j-1;
+ }
+
+ inline int getIndex(int i,int j,int k) const {
+ return (i-1)*_dim + j-1;
+ }
+
+ inline int getNbGauss(int i) const { return 1; }
+
+};
+
+class NoInterlaceNoGaussPolicy : public InterlacingPolicy {
+
+protected:
+ ~NoInterlaceNoGaussPolicy() {} //pour éviter qu'un utilisateur cast la class array en politique
+
+public :
+
+ NoInterlaceNoGaussPolicy():InterlacingPolicy() {}
+ NoInterlaceNoGaussPolicy(int nbelem, int dim) :
+ InterlacingPolicy(nbelem, dim, dim*nbelem,MED_EN::MED_NO_INTERLACE) {}
+
+ NoInterlaceNoGaussPolicy(const NoInterlaceNoGaussPolicy & policy,
+ bool shallowcopie=true)
+ : InterlacingPolicy(policy) {}
+
+ inline int getIndex(int i,int j) const {
+ return (j-1)*_nbelem + i-1;
+ }
+
+ inline int getIndex(int i,int j,int k) const {
+ return (j-1)*_nbelem + i-1;
+ }
+
+ inline int getNbGauss(int i) const { return 1; }
+
+};
+
+class FullInterlaceGaussPolicy : public InterlacingPolicy {
+protected:
+ ~FullInterlaceGaussPolicy() {} //pour éviter qu'un utilisateur cast la class array en politique
+public :
+
+ PointerOf<int> _G;
+ PointerOf<int> _S;
+ int _nbtypegeo;
+ PointerOf<int> _nbelegeoc;
+ PointerOf<int> _nbgaussgeo;
+
+ FullInterlaceGaussPolicy():InterlacingPolicy(),_nbtypegeo(-1) {
+ InterlacingPolicy::_gaussPresence=true;
+ }
+ FullInterlaceGaussPolicy(int nbelem, int dim, int nbtypegeo,
+ const int * const nbelgeoc, const int * const nbgaussgeo)
+ : InterlacingPolicy(nbelem, dim, -1, MED_EN::MED_FULL_INTERLACE),_nbtypegeo(nbtypegeo) {
+
+ InterlacingPolicy::_gaussPresence=true;
+
+ _nbelegeoc.set(_nbtypegeo+1,nbelgeoc);
+ _nbgaussgeo.set(_nbtypegeo+1,nbgaussgeo);
+ _G.set(nbelem+1);
+ // _G[0] = 1;
+ _S.set(nbelem+1);
+ _S[0] = -1;
+ int cumul = 0;
+ int elemno = 0;
+
+ // Construction of _G
+ for (int ntyp=1; ntyp <= nbtypegeo; ntyp++ ) {
+ for (int i=0; i < (nbelgeoc[ntyp]-nbelgeoc[ntyp-1]) ; i++ ) {
+ _G[ elemno ] = cumul + i*nbgaussgeo[ntyp]*dim + 1;
+ elemno++;
+ _S[ elemno ] = nbgaussgeo[ntyp];
+ };
+ cumul += (nbelgeoc[ntyp]-nbelgeoc[ntyp-1]) * nbgaussgeo[ntyp] * dim;
+#ifdef ARRAY_DEBUG
+ std::cout << "Valeur de cumul " << cumul << std::endl;
+#endif
+ };
+
+ _G[ elemno ] = cumul+1;
+ _arraySize = _G[ elemno ] -1 ;
+
+#ifdef ARRAY_DEBUG
+ for (int i =0; i< nbelem+1; i++ )
+ std::cout << "Valeur de _G["<<i<<"] = "<<_G[i] << std::endl;
+#endif
+ }
+
+ FullInterlaceGaussPolicy(const FullInterlaceGaussPolicy & policy,
+ bool shallowcopie=true)
+ : InterlacingPolicy(policy),_nbtypegeo(policy._nbtypegeo) {
+
+ //Seuls les tableaux de grande taille sont recopiés superficiellement
+ if(shallowcopie) {
+ this->_G.set(policy._G);
+ this->_S.set(policy._S);
+ } else {
+ this->_G.set(_nbelem+1,policy._G);
+ this->_S.set(_nbelem+1,policy._S);
+ }
+ // Tableaux toujours recopiés par recopie profonde
+ this->_nbelegeoc.set(_nbtypegeo+1,policy._nbelegeoc);
+ this->_nbgaussgeo.set(_nbtypegeo+1,policy._nbgaussgeo);
+ }
+
+ FullInterlaceGaussPolicy & operator=(const FullInterlaceGaussPolicy & policy) {
+ BEGIN_OF("FullInterlaceGaussPolicy operator =");
+
+ if ( this == &policy) return *this;
+
+ //Seuls les tableaux de grande taille sont recopiés superficiellement
+ InterlacingPolicy::operator=(policy);
+ this->_G.set(policy._G);
+ this->_S.set(policy._S);
+
+ // Tableaux toujours recopiés par recopie profonde
+ this->_nbtypegeo=policy._nbtypegeo;
+ this->_nbelegeoc.set(_nbtypegeo+1,policy._nbelegeoc);
+ this->_nbgaussgeo.set(_nbtypegeo+1,policy._nbgaussgeo);
+
+ return *this;
+ }
+
+ inline int getIndex(int i,int j ) const {
+ return _G[i-1]-1 + (j-1)*_dim ;
+ }
+
+ inline int getIndex(int i,int j, int k ) const {
+ //std::cout << "Index : " << _G[i-1]-1 + _dim *(k-1) + (j-1) << std::endl;
+ return _G[i-1]-1 + (k-1)*_dim + (j-1);
+ }
+
+ inline int getNbGauss(int i) const { return _S[i]; }
+
+ inline int getNbGeoType() const {return _nbtypegeo;}
+
+ inline const int * const getNbElemGeoC() const {return _nbelegeoc;}
+
+ inline const int * const getNbGaussGeo() const {return _nbgaussgeo;}
+
+
+};
+
+class NoInterlaceGaussPolicy : public InterlacingPolicy {
+
+protected:
+ ~NoInterlaceGaussPolicy() {} //pour éviter qu'un utilisateur cast la class array en politique
+
+public :
+
+ PointerOf<int> _G;
+ PointerOf<int> _S;
+ int _nbtypegeo;
+ PointerOf<int> _nbelegeoc;
+ PointerOf<int> _nbgaussgeo;
+ // _cumul is used in getIndex() to access directly to the first value
+ // of a given dimension.
+ int _cumul;
+
+ NoInterlaceGaussPolicy():InterlacingPolicy(),_nbtypegeo(-1),_cumul(0) {
+ InterlacingPolicy::_gaussPresence=true;
+ }
+
+ NoInterlaceGaussPolicy(int nbelem, int dim, int nbtypegeo,
+ const int * const nbelgeoc, const int * const nbgaussgeo)
+ : InterlacingPolicy(nbelem, dim, -1, MED_EN::MED_NO_INTERLACE),_nbtypegeo(nbtypegeo) {
+
+ InterlacingPolicy::_gaussPresence=true;
+
+ _nbelegeoc.set(_nbtypegeo+1,nbelgeoc);
+ _nbgaussgeo.set(_nbtypegeo+1,nbgaussgeo);
+ _G.set(nbelem+1);
+ //_G[0] = 1;
+ _S.set(nbelem+1);
+ _S[0] = -1;
+ int elemno = 0;
+
+ _cumul = 0;
+ for (int ntyp=1; ntyp <= nbtypegeo; ntyp++ ) {
+ for (int i=0; i < (nbelgeoc[ntyp]-nbelgeoc[ntyp-1]) ; i++ ) {
+ _G[ elemno ] = _cumul + i*nbgaussgeo[ntyp] + 1;
+ elemno++;
+ _S[ elemno ] = nbgaussgeo[ntyp];
+ };
+ _cumul += (nbelgeoc[ntyp]-nbelgeoc[ntyp-1]) * nbgaussgeo[ntyp];
+#ifdef ARRAY_DEBUG
+ std::cout << "Valeur de _cumul " << _cumul << std::endl;
+#endif
+ };
+
+ _G[ elemno ] = _cumul+1;
+ _arraySize = ( _G[ elemno ] -1 ) * dim ;
+
+#ifdef ARRAY_DEBUG
+ for (int i =0; i< nbelem+1; i++ )
+ std::cout << "Valeur de _G["<<i<<"] = "<<_G[i] << std::endl;
+#endif
+ }
+
+
+ NoInterlaceGaussPolicy(const NoInterlaceGaussPolicy & policy,
+ bool shallowcopie=true)
+ : InterlacingPolicy(policy),_cumul(policy._cumul),_nbtypegeo(policy._nbtypegeo)
+ {
+ //Seuls les tableaux de grande taille sont recopiés superficiellement
+ if(shallowcopie) {
+ this->_G.set(policy._G);
+ this->_S.set(policy._S);
+ } else {
+ this->_G.set(_nbelem+1,policy._G);
+ this->_S.set(_nbelem+1,policy._S);
+ }
+ // Tableaux toujours recopiés par recopie profonde
+ this->_nbelegeoc.set(_nbtypegeo+1,policy._nbelegeoc);
+ this->_nbgaussgeo.set(_nbtypegeo+1,policy._nbgaussgeo);
+ }
+
+ NoInterlaceGaussPolicy & operator=(const NoInterlaceGaussPolicy & policy) {
+ if ( this == &policy) return *this;
+
+ BEGIN_OF("NoInterlaceGaussPolicy operator =");
+ InterlacingPolicy::operator=(policy);
+ this->_G.set(policy._G);
+ this->_S.set(policy._S);
+
+ this->_cumul = policy._cumul;
+
+ // Tableaux toujours recopiés par recopie profonde
+ this->_nbtypegeo=policy._nbtypegeo;
+ this->_nbelegeoc.set(_nbtypegeo+1,policy._nbelegeoc);
+ this->_nbgaussgeo.set(_nbtypegeo+1,policy._nbgaussgeo);
+
+ return *this;
+ }
+
+ inline int getIndex(int i,int j ) const {
+ return _G[i-1]-1 + (j-1)*_cumul ;
+ }
+
+ inline int getIndex(int i,int j, int k ) const {
+ return _G[i-1]-1 + (j-1)*_cumul + (k-1) ;
+ }
+
+ inline int getNbGauss(int i) const { return _S[i]; }
+
+ inline int getNbGeoType() const {return _nbtypegeo;}
+
+ inline const int * const getNbElemGeoC() const {return _nbelegeoc;}
+
+ inline const int * const getNbGaussGeo() const {return _nbgaussgeo;}
+
+};
+
+} //END NAMESPACE
+
+#endif
--- /dev/null
+#ifndef MEDMEM_INTERLACING_TRAITS_HXX
+#define MEDMEM_INTERLACING_TRAITS_HXX
+
+#include "MEDMEM_Tags.hxx"
+
+namespace MEDMEM {
+
+struct __ERROR_INTERLACING_GAUSS_TRAITS_POLICY_INSTANCIATED_WITH_INCORRECT_TYPE {};
+
+template < class INTERLACE_TAG, class GAUSS_TAG>
+struct MEDMEM_InterlacingTraits
+{
+ typedef __ERROR_INTERLACING_GAUSS_TRAITS_POLICY_INSTANCIATED_WITH_INCORRECT_TYPE Type;
+};
+
+template <>
+struct MEDMEM_InterlacingTraits< FullInterlace, Gauss >
+{
+ typedef FullInterlaceGaussPolicy Type;
+};
+
+template <>
+struct MEDMEM_InterlacingTraits< FullInterlace, NoGauss >
+{
+ typedef FullInterlaceNoGaussPolicy Type;
+};
+
+template <>
+struct MEDMEM_InterlacingTraits< NoInterlace, Gauss >
+{
+ typedef NoInterlaceGaussPolicy Type;
+};
+
+template <>
+struct MEDMEM_InterlacingTraits< NoInterlace, NoGauss >
+{
+ typedef NoInterlaceNoGaussPolicy Type;
+};
+
+} // END NAMESPACE
+
+#endif
#include "MEDMEM_STRING.hxx"
#include "MEDMEM_Exception.hxx"
-#include "MEDMEM_Unit.hxx"
-#include "MEDMEM_Array.hxx"
-#include "MEDMEM_Support.hxx"
-#include "MEDMEM_Mesh.hxx"
+// #include "MEDMEM_Unit.hxx"
+// #include "MEDMEM_Array.hxx"
+// #include "MEDMEM_Support.hxx"
+// #include "MEDMEM_Mesh.hxx"
#include "MEDMEM_Compatibility21_22.hxx"
+#include "MEDMEM_FieldForward.hxx"
namespace MEDMEM {
-template <class T> class FIELD;
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:
+ // Developement plus propre :
+ // - Il faudrait soit utiliser le type FIELD_ et ajouter à cette classe
+ // les accesseurs de FIELD<> utilisés dans les drivers
+ // - Ou bien avoir des drivers à deux paramètres template (le top)
+ // - Remarquez l'affreux cast dans le second constructeur :
+ // _ptrField( (FIELD<T> *) ptrField )
+ // Cela cast toujours le ptrField en FullInterlace
+ // Cela ne pose cependant pas de pb de fonctionement aux drivers
FIELD<T> * _ptrField;
string _fieldName;
int _fieldNum;
- void search_field() ;
public :
/*!
Constructor.
*/
- MED_FIELD_DRIVER():_ptrField((FIELD<T> *) NULL),
+ MED_FIELD_DRIVER():_ptrField((FIELD<T> *) MED_NULL),
_fieldName(""),_fieldNum(MED_INVALID)
{}
/*!
Constructor.
*/
- MED_FIELD_DRIVER(const string & fileName, FIELD<T> * ptrField,
+ template <class INTERLACING_TAG>
+ MED_FIELD_DRIVER(const string & fileName, FIELD<T, INTERLACING_TAG> * ptrField,
MED_EN::med_mode_acces accessMode)
: GENDRIVER(fileName,accessMode),
_ptrField((FIELD<T> *) ptrField),
/*!
Constructor.
*/
- IMED_FIELD_RDONLY_DRIVER(const string & fileName, FIELD<T> * ptrField):
- MED_FIELD_DRIVER<T>(fileName,ptrField,MED_EN::MED_RDONLY) {
+ template <class INTERLACING_TAG>
+ IMED_FIELD_RDONLY_DRIVER(const string & fileName,
+ FIELD<T, INTERLACING_TAG> * ptrField):
+ MED_FIELD_DRIVER<T>(fileName,ptrField,MED_EN::MED_RDONLY)
+ {
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)");
}
/*!
Constructor.
*/
- IMED_FIELD_WRONLY_DRIVER(const string & fileName, FIELD<T> * ptrField):
+ template <class INTERLACING_TAG>
+ IMED_FIELD_WRONLY_DRIVER(const string & fileName,
+ FIELD<T, INTERLACING_TAG> * 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)");
*/
-template <class T> class IMED_FIELD_RDWR_DRIVER : public virtual IMED_FIELD_RDONLY_DRIVER<T>, public virtual IMED_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.
*/
- 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)
+ template <class INTERLACING_TAG>
+ IMED_FIELD_RDWR_DRIVER(const string & fileName,
+ FIELD<T, INTERLACING_TAG> * 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 ;
Copy constructor.
*/
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) {}
+ IMED_FIELD_RDONLY_DRIVER<T>(fieldDriver),
+ IMED_FIELD_WRONLY_DRIVER<T>(fieldDriver),
+ MED_FIELD_DRIVER<T>(fieldDriver)
+ {
+ }
/*!
Destructor.
public :
MED_FIELD_RDONLY_DRIVER();
- MED_FIELD_RDONLY_DRIVER(const string & fileName, FIELD<T> * ptrField);
+
+ template <class INTERLACING_TAG>
+ MED_FIELD_RDONLY_DRIVER(const string & fileName,
+ FIELD<T, INTERLACING_TAG> * 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; }
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);
+
+ template <class INTERLACING_TAG>
+ MED_FIELD_WRONLY_DRIVER(const string & fileName,
+ FIELD<T, INTERLACING_TAG> * 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;}
/*!
Constructor.
*/
- MED_FIELD_RDWR_DRIVER(const string & fileName, FIELD<T> * ptrField);
+ template <class INTERLACING_TAG>
+ MED_FIELD_RDWR_DRIVER(const string & fileName,
+ FIELD<T, INTERLACING_TAG> * ptrField);
MED_FIELD_RDWR_DRIVER(const MED_FIELD_RDWR_DRIVER & fieldDriver):
IMED_FIELD_RDWR_DRIVER<T>(fieldDriver)
_concreteFieldDrv=new MED_FIELD_RDONLY_DRIVER21<T>();
}
-template <class T> MED_FIELD_RDONLY_DRIVER<T>::MED_FIELD_RDONLY_DRIVER(const string & fileName, FIELD<T> * ptrField)
+template <class T> template < class INTERLACING_TAG >
+MED_FIELD_RDONLY_DRIVER<T>::MED_FIELD_RDONLY_DRIVER(const string & fileName,
+ FIELD<T, INTERLACING_TAG> * ptrField):
+ MED_FIELD_DRIVER<T>(fileName,ptrField,MED_EN::MED_RDONLY),
+ IMED_FIELD_RDONLY_DRIVER<T>(fileName,ptrField)
{
BEGIN_OF("MED_FIELD_RDONLY_DRIVER::MED_FIELD_RDONLY_DRIVER(const string & fileName, const FIELD<T> * ptrField)");
_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)");
+template <class T> template < class INTERLACING_TAG >
+MED_FIELD_WRONLY_DRIVER<T>::MED_FIELD_WRONLY_DRIVER(const string & fileName,
+ FIELD<T, INTERLACING_TAG> * ptrField):
+ MED_FIELD_DRIVER<T>(fileName,ptrField,MED_EN::MED_RDONLY),
+ IMED_FIELD_WRONLY_DRIVER<T>( fileName, 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);
+ _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)");
+ END_OF("MED_FIELD_RDONLY_DRIVER::MED_FIELD_RDONLY_DRIVER(const string & fileName, const FIELD<T> * ptrField)");
}
/*--------------------- RDWR PART -------------------------------*/
_concreteFieldDrv=new MED_FIELD_RDWR_DRIVER21<T>();
}
-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> template < class INTERLACING_TAG >
+MED_FIELD_RDWR_DRIVER<T>::MED_FIELD_RDWR_DRIVER(const string & fileName,
+ FIELD<T, INTERLACING_TAG> * ptrField):
+ MED_FIELD_DRIVER<T>(fileName,ptrField,MED_EN::MED_RDONLY),
+ IMED_FIELD_RDWR_DRIVER<T>(fileName,ptrField)
+{
+ BEGIN_OF("MED_FIELD_RDWR_DRIVER::MED_FIELD_RDWR_DRIVER(const string & fileName, const FIELD<T> * ptrField)");
- _concreteFieldDrv = DRIVERFACTORY::buildFieldDriverFromFile(fileName,ptrField,MED_EN::MED_REMP);
+ _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_OF("MED_FIELD_RDWR_DRIVER::MED_FIELD_RDWR_DRIVER(const string & fileName, const FIELD<T> * ptrField)");
}
#include "MEDMEM_define.hxx"
-#include "MEDMEM_GenDriver.hxx"
+#include "MEDMEM_DriversDef.hxx"
#include "MEDMEM_Utilities.hxx"
#include "MEDMEM_MedFieldDriver.hxx"
#include "MEDMEM_STRING.hxx"
#include "MEDMEM_Exception.hxx"
#include "MEDMEM_Unit.hxx"
-#include "MEDMEM_Array.hxx"
+
+#include "MEDMEM_ArrayInterface.hxx"
+#include "MEDMEM_ArrayConvert.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...
/*!
protected:
med_2_1::med_idt _medIdt;
- void search_field() ;
-public :
+ bool createFieldSupport(med_2_1::med_idt id,
+ string & fieldName,
+ med_2_1::med_int ndt,
+ med_2_1::med_int od,
+ SUPPORT & support,
+ string & meshName) const throw (MEDEXCEPTION);
+
+ void getMeshGeometricType(med_2_1::med_idt id,
+ string & meshName,
+ MED_EN::medEntityMesh entite,
+ vector<MED_EN::medGeometryElement> & geoType,
+ vector<int> &nbOfElOfType) const;
- // 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];
+public :
/*!
Constructor.
/*!
Constructor.
*/
- MED_FIELD_DRIVER21(const string & fileName, FIELD<T> * ptrField,
+ template <class INTERLACING_TAG>
+ MED_FIELD_DRIVER21(const string & fileName,
+ FIELD<T, INTERLACING_TAG> * ptrField,
MED_EN::med_mode_acces accessMode)
: MED_FIELD_DRIVER<T>(fileName,ptrField,accessMode),_medIdt(MED_INVALID)
{
//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 : MED_FIELD_DRIVER21<T>::_medIdt= " << _medIdt );
MESSAGE(" MED_FIELD_DRIVER21::close() : MEDfermer : err = " << err );
}
END_OF("MED_FIELD_DRIVER21::close()");
/*!
Constructor.
*/
- MED_FIELD_RDONLY_DRIVER21(const string & fileName, FIELD<T> * ptrField):
- IMED_FIELD_RDONLY_DRIVER<T>(fileName,ptrField),
+ template <class INTERLACING_TAG>
+ MED_FIELD_RDONLY_DRIVER21(const string & fileName,
+ FIELD<T, INTERLACING_TAG> * ptrField):
+ MED_FIELD_DRIVER<T>(fileName,ptrField,MED_EN::MED_RDONLY),
MED_FIELD_DRIVER21<T>(fileName,ptrField,MED_EN::MED_RDONLY),
- MED_FIELD_DRIVER<T>(fileName,ptrField,MED_EN::MED_RDONLY)
+ IMED_FIELD_RDONLY_DRIVER<T>(fileName,ptrField)
{
- 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)");
+ BEGIN_OF("MED_FIELD_RDONLY_DRIVER21::MED_FIELD_RDONLY_DRIVER21(const string & fileName, const FIELD<T,INTERLACING_TAG> * ptrField)");
+ END_OF("MED_FIELD_RDONLY_DRIVER21::MED_FIELD_RDONLY_DRIVER21(const string & fileName, const FIELD<T,INTERLACING_TAG> * ptrField)");
}
/*!
/*!
Constructor.
*/
- MED_FIELD_WRONLY_DRIVER21(const string & fileName, FIELD<T> * ptrField):
+ template <class INTERLACING_TAG>
+ MED_FIELD_WRONLY_DRIVER21(const string & fileName,
+ FIELD<T, INTERLACING_TAG> * 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)");
+ BEGIN_OF("MED_FIELD_WRONLY_DRIVER21::MED_FIELD_WRONLY_DRIVER21(const string & fileName, const FIELD<T,INTERLACING_TAG> * ptrField)");
+ END_OF("MED_FIELD_WRONLY_DRIVER21::MED_FIELD_WRONLY_DRIVER21(const string & fileName, const FIELD<T,INTERLACING_TAG> * ptrField)");
}
/*!
/*!
Constructor.
*/
- MED_FIELD_RDWR_DRIVER21(const string & fileName, FIELD<T> * ptrField):
+ template <class INTERLACING_TAG>
+ MED_FIELD_RDWR_DRIVER21(const string & fileName,
+ FIELD<T, INTERLACING_TAG> * ptrField):
MED_FIELD_WRONLY_DRIVER21<T>(fileName,ptrField),
MED_FIELD_RDONLY_DRIVER21<T>(fileName,ptrField),
IMED_FIELD_RDONLY_DRIVER<T>(fileName,ptrField),
/*--------------------- 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
-// }
+template <class T> bool
+MED_FIELD_DRIVER21<T>::createFieldSupport(med_2_1::med_idt id,
+ string & fieldName,
+ med_2_1::med_int ndt,
+ med_2_1::med_int od,
+ SUPPORT & support,
+ string & meshName) const throw (MEDEXCEPTION)
+{
+
+ //EF : Gérer le meshName pour le driver 2.2
+ const char * LOC="MED_FIELD_DRIVER<T>::search_field(...)";
+
+ map<int, list<MED_EN::medGeometryElement> > CellAndNodeEntities;
+ map<int, list<MED_EN::medGeometryElement> >::iterator currentEntity;
+ CellAndNodeEntities[MED_EN::MED_CELL] = MED_EN::meshEntities[MED_EN::MED_CELL];
+ CellAndNodeEntities[MED_EN::MED_NODE] = MED_EN::meshEntities[MED_EN::MED_NODE];
+ list< MED_EN::medGeometryElement >::const_iterator currentGeometry;
+
+ //med_2_1::med_entite_maillage
+ MED_EN::medEntityMesh entity;
+ bool alreadyFoundAnEntity=false, alreadyFoundPdtIt = false, anyGauss=false;
+ int numberOfElements = 0;
+ int numberOfGeometricType = 0;
+ //med_2_1::med_geometrie_element..
+ MED_EN::medGeometryElement geometricType[MED_NBR_GEOMETRIE_MAILLE];
+ int numberOfElementsOfType[MED_NBR_GEOMETRIE_MAILLE];
+ int numberOfGaussPoint[MED_NBR_GEOMETRIE_MAILLE];
+
+ med_2_1::med_int ngauss=0, numdt=-1, numo=-1, nbPdtIt=0; //nmaa=0
+ char dtunit[MED_TAILLE_PNOM21+1], maa[MED_TAILLE_NOM+1];
+ med_2_1::med_float dt=-1.0;
+ //med_2_1::med_booleen local;
+ med_2_1::med_err ret=1;
+
+ for (currentEntity = CellAndNodeEntities.begin();
+ currentEntity != CellAndNodeEntities.end(); currentEntity++) {
+ for (currentGeometry = (*currentEntity).second.begin();
+ currentGeometry != (*currentEntity).second.end(); currentGeometry++) {
+
+ if ( (numberOfElements = med_2_1::MEDnVal(id, const_cast <char*> ( fieldName.c_str() ),
+ (med_2_1::med_entite_maillage) (*currentEntity).first,
+ (med_2_1::med_geometrie_element) *currentGeometry,
+ ndt, od)) <= 0 )
+ continue;
+
+ if ( alreadyFoundAnEntity ) {
+ if (entity != (*currentEntity).first )
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Field |" << fieldName
+ << "| with (ndt,or) = (" << ndt << ","
+ << od << ") must not be defined on nodes and cells" ));
+
+ } else { entity=(*currentEntity).first; alreadyFoundAnEntity = true; };
+
+ nbPdtIt = med_2_1::MEDnPasdetemps(id, const_cast <char*> ( fieldName.c_str() ),
+ (med_2_1::med_entite_maillage) (*currentEntity).first,
+ (med_2_1::med_geometrie_element) *currentGeometry );
+ if ( nbPdtIt < 0 )
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Field |" << fieldName << "| with (ndt,or) = ("
+ << ndt << "," << od << ") should be defined for (entityType,geometricType)=("
+ << MED_EN::entNames[(*currentEntity).first] << ","
+ << MED_EN::geoNames[*currentGeometry] << ")" ));
+
+ ret = 0; alreadyFoundPdtIt = false; ngauss =0;
+ for ( med_2_1::med_int j=1; j <= nbPdtIt; j++ ) {
+
+ // Search how many <ngauss> (<fieldName>,<ndt>,<ot>) has
+ ret = med_2_1::MEDpasdetempsInfo(id, const_cast <char*> ( fieldName.c_str() ),
+ (med_2_1::med_entite_maillage) (*currentEntity).first,
+ (med_2_1::med_geometrie_element) *currentGeometry,
+ j,maa,&ngauss,&numdt,dtunit,&dt,&numo);
+
+ // ret = med_2_2::MEDpasdetempsInfo(id, const_cast <char*> ( fieldName.c_str() ),
+ // (med_2_1::med_entite_maillage) (*currentEntity).first,
+ // (med_2_1::med_geometrie_element) *currentGeometry,
+ // j, &ngauss, &numdt, &numo, &dtunit, &dt, &maa, &local, &nmaa)
+
+ if ( ndt == numdt && numo == od ) {
+ alreadyFoundPdtIt = true;
+ if ( ! meshName.empty() )
+ if ( meshName != maa ) {
+
+ // if ( nmaa > 1 )
+ {
+ //EF : Gérer le meshName pour le driver 2.2
+ // MESSAGE(STRING(LOC)<<" Field |" << fieldName << "| with (ndt,or) = (" << ndt << ","
+ // << ot << ") is defined on " << nmaa << " meshes, using mesh |"
+ // << maa << "|");
+ // }
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Field |" << fieldName << "| with (ndt,or) = ("
+ << ndt << "," << od << ") for (entityType,geometricType)=("
+ << MED_EN::entNames[(*currentEntity).first] << ","
+ << MED_EN::geoNames[*currentGeometry] << ")"
+ << "is defined on mesh |" << maa << "| not on mesh |" << meshName ));
+ }
+ }
+ break;
+ }
+ }
+
+ if ( !alreadyFoundPdtIt )
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Field |" << fieldName << "| with (ndt,or) = ("
+ << ndt << "," << od << ") should be defined for (entityType,geometricType)=("
+ << MED_EN::entNames[(*currentEntity).first] << ","
+ << MED_EN::geoNames[*currentGeometry] << ")" ));
+
+ if ( (ret != 0) || (ngauss < 1 ) )
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Error in MEDpasdetempsInfo for Field |" << fieldName
+ << "| with (ndt,or) = ("
+ << ndt << "," << od << ") for (entityType,geometricType)=("
+ << MED_EN::entNames[(*currentEntity).first] << ","
+ << MED_EN::geoNames[*currentGeometry] << ")" )); ;
+
+ //totalNumberOfElements+=numberOfElements;
+ numberOfElementsOfType[numberOfGeometricType] = numberOfElements/ngauss;
+ numberOfGaussPoint[numberOfGeometricType] = ngauss;
+ anyGauss = (anyGauss || (ngauss-1) );
+ geometricType[numberOfGeometricType]= *currentGeometry;
+ numberOfGeometricType++;
+
+ } // End Second For
+
+ } // End Premier For
+
+ if ( alreadyFoundAnEntity) {
+ support.setName(fieldName+"Support");
+ support.setMeshName(string(maa)); // Vérifier que les différents noms de maillages lus soient identiques
+ support.setEntity(entity);
+ // REM : Signification précédente erronée pour un champ qui ne repose pas sur toutes les entités géométriques
+ // du maillage mais dont le SUPPORT a été crée à partir des informations d'un maillage, comme
+ // celà fût la plupart du temps.
+ support.setNumberOfGeometricType(numberOfGeometricType);
+ support.setGeometricType(geometricType); // Utile uniquement si setAll == false
+ support.setNumberOfElements(numberOfElementsOfType); //setNumberOfElements effectue une copie
+ support.setAll(true);
+ if (anyGauss)
+ support.setNumberOfGaussPoint(numberOfGaussPoint);
+
+ return alreadyFoundAnEntity;
+ } else
+ return false;
+}
+
+template <class T> void
+MED_FIELD_DRIVER21<T>::getMeshGeometricType(med_2_1::med_idt id,
+ string & meshName,
+ MED_EN::medEntityMesh entity,
+ vector<MED_EN::medGeometryElement> & geoType,
+ vector<int> &nbOfElOfType) const
+{
+ const char LOC[] = "MED_FIELD_DRIVER<T>::getMeshGeometricType(...)";
+
+ int numberOfGeometricType=0;
+ MED_EN::medGeometryElement geometricType[MED_NBR_GEOMETRIE_MAILLE];
+ int numberOfElementsOfType[MED_NBR_GEOMETRIE_MAILLE];
+ med_2_1::med_int numberOfElements=0;
+ med_2_1::med_table quoi;
+ if (entity == MED_EN::MED_CELL) quoi=med_2_1::MED_CONN;
+ else
+ if (entity == MED_EN::MED_NODE) quoi=med_2_1::MED_COOR;
+ else
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Support Creation from Mesh |" << meshName
+ << "| on entity " << MED_EN::entNames[entity]
+ << "| is impossible, must be on MED_NODE or MED_CELL" ));
+
+ list<MED_EN::medGeometryElement>::const_iterator currentGeometry;
+ bool alreadyFoundAnEntity = false;
+
+ for (currentGeometry = (MED_EN::meshEntities[entity]).begin();
+ currentGeometry != (MED_EN::meshEntities[entity]).end(); currentGeometry++) {
+
+
+ if ( (numberOfElements =
+ med_2_1::MEDnEntMaa(id,
+ const_cast<char*> (meshName.c_str()),
+ quoi,
+ (med_2_1::med_entite_maillage) entity,
+ (med_2_1::med_geometrie_element) *currentGeometry,
+ med_2_1::MED_NOD) ) <= 0)
+ continue;
+
+ alreadyFoundAnEntity = true;
+ numberOfElementsOfType[numberOfGeometricType] = numberOfElements;
+ geometricType[numberOfGeometricType] = *currentGeometry;
+ numberOfGeometricType++;
+
+ }
+ geoType = vector<MED_EN::medGeometryElement>(geometricType,geometricType+numberOfGeometricType);
+ nbOfElOfType = vector<int> (numberOfElementsOfType,numberOfElementsOfType+numberOfGeometricType);
+
+}
+
/*--------------------- RDONLY PART -------------------------------*/
template <class T> GENDRIVER * MED_FIELD_RDONLY_DRIVER21<T>::copy(void) const
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)
+ typedef typename MEDMEM_ArrayInterface<T,NoInterlace,NoGauss>::Array ArrayNo;
+ typedef typename MEDMEM_ArrayInterface<T,FullInterlace,NoGauss>::Array ArrayFull;
+
+ if ( ( MED_FIELD_DRIVER<T>::_fieldName.empty() ) &&
+ ( MED_FIELD_DRIVER<T>::_ptrField->_name.empty() ) )
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)
+ <<" neither <fieldName> is set in driver nor in object FIELD.")) ;
+
+ // If _fieldName is not set in driver, try to use _ptrfield->_fieldName
+ if ( ( MED_FIELD_DRIVER<T>::_fieldName.empty() ) &&
+ ( !MED_FIELD_DRIVER<T>::_ptrField->_name.empty() ) )
+ MED_FIELD_DRIVER<T>::_fieldName=MED_FIELD_DRIVER<T>::_ptrField->_name;
+
+ if ( MED_FIELD_DRIVER<T>::_fieldName.size() > MED_TAILLE_NOM )
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)
+ <<" <fieldName> size in object driver FIELD is > MED_TAILLE_NOM ."));
+
+
+ MESSAGE("###### "<<LOC<<" fieldNameDRIVER : "<< MED_FIELD_DRIVER<T>::_fieldName <<
+ " fieldName : "<<MED_FIELD_DRIVER<T>::_fieldName);
+
+
+ if (MED_FIELD_DRIVER<T>::_status!=MED_OPENED)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<": Method open must be called before method read.")) ;
+
+// EF :
+// Si un support a été donnée au champ, pour des raisons de compatibilité avec
+// les versions précédentes, ce support sera utilisé pour
+// - Obtenir le nom du maillage sur lequel on veut lire le champ
+// (eventuellement on pourrait l'utiliser pour selectionner un champ qui
+// repose sur plusieurs maillages cf HOMARD-ASTER)
+// - vérifier le type d'entité (MED_NOEUD xor MED_MAILLE xor MED_FACE xor MED_ARETE ) sur lequel
+// il faut lire le champ qui est également retouvé.
+// - Si le support défini une liste d'entité ( différente de MED_ALL_ELEMENTS), celle-ci est ignorée
+// à la lecture et écrasé par les listes de profils lus s'il en existe
+
+// Si aucun support n'a été donné au champ :
+// - A la lecture : Un support est crée et le type d'entité unique est lu
+// (cf decision gt MED qu'un champ repose sur une entité unique ?),
+// l'ensemble des types géométriques est lu,
+// l'ensemble des profils par type géométrique est lu
+// Le nom du maillage associé est lu mais le pointeur SUPPORT-MESH non initialisé
+
+ char * 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 ;
+ med_2_1::med_idt id = MED_FIELD_DRIVER21<T>::_medIdt;
+
+ // we search for the field med number of <fieldName>
+ // Having found <fieldName> variables <numberOfComponents>,
+ // <componentName>, <unitname>, <type> and attribute <_fieldNum> are set.
+ if (MED_FIELD_DRIVER<T>::_fieldNum==MED_INVALID)
{
-
- // 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) ;
+ int numberOfFields = 0; //MED_INVALID
+ numberOfFields = med_2_1::MEDnChamp(id,0) ;
+ if ( numberOfFields <= 0 )
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<": No Field found !"));
+
+ for (int i=1;i<=numberOfFields;i++)
+ {
+ numberOfComponents = med_2_1::MEDnChamp(id,i) ;
if ( numberOfComponents <= 0 )
// throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
// << "Be careful there is no compound for field n°"
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) ;
-
+ err = med_2_1::MEDchampInfo(id, 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 ;
- }
+ 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;
+ 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);
+
+ if (numberOfComponents < 1)
+ {
+ delete[] componentName; delete[] unitName;
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"no component found for field "
+ << MED_FIELD_DRIVER<T>::_fieldName)) ;
+ }
+
+ // Pourquoi _ptrField est toujour null et non MED_FIELD_DRIVER<T>::_ptrField
+ switch ( (med_2_1::med_type_champ) MED_FIELD_DRIVER<T>::_ptrField->_valueType ) {
+ case med_2_1::MED_INT :
+ case med_2_1::MED_INT32 :
+ case med_2_1::MED_INT64 :
+ if ( type == ( med_2_1::MED_REEL64 ) ) {
+ delete[] componentName; delete[] unitName;
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Field Type in file (" << type
+ <<") differs from FIELD object type (" <<
+ MED_FIELD_DRIVER<T>::_ptrField->_valueType << ")" )) ;
+ }
+ break;
+ default:
+ break;
+ }
+
+
+ string meshName="";
+ bool haveSupport = false;
+ if ( MED_FIELD_DRIVER<T>::_ptrField->getSupport() ) {
+ // Verif sur la taille du meshName
+ meshName = MED_FIELD_DRIVER<T>::_ptrField->getSupport()->getMesh()->getName() ;
+ haveSupport = true;
+ }
+
+ // Cherche le type d'entité, le nombre d'entité par type géométrique sur le type d'entité
+ // (MED_MAILLE ou MED_NOEUD uniquement car MEDMEMOIRE ne gère pas la connectivité descendante).
+ // et crée le support correspondant.
+ SUPPORT * mySupport = new SUPPORT();
+ bool found = createFieldSupport(id,MED_FIELD_DRIVER<T>::_fieldName,
+ MED_FIELD_DRIVER<T>::_ptrField->_iterationNumber,
+ MED_FIELD_DRIVER<T>::_ptrField->_orderNumber,
+ *mySupport, meshName) ;
+ if ( !found ) {
+ delete mySupport; delete[] componentName; delete[] unitName;
+ MED_FIELD_DRIVER<T>::_fieldNum = MED_INVALID ;
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Can't find any entity for field |"
+ << MED_FIELD_DRIVER<T>::_fieldName
+ << "| with (it,or) = ("
+ << MED_FIELD_DRIVER<T>::_ptrField->_iterationNumber << ","
+ << MED_FIELD_DRIVER<T>::_ptrField->_orderNumber << "), on mesh "
+ << meshName << "|" ));
+ }
+
+ if (! haveSupport)
+ meshName = mySupport->getMeshName();
+ else {
+ if ( mySupport->getEntity() != MED_FIELD_DRIVER<T>::_ptrField->getSupport()->getEntity() ) {
+ MED_EN::medEntityMesh ent = mySupport->getEntity();
+ delete mySupport; delete[] componentName; delete[] unitName;
+ MED_FIELD_DRIVER<T>::_fieldNum = MED_INVALID ;
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Given entity |"
+ << MED_EN::entNames[MED_FIELD_DRIVER<T>::_ptrField->
+ getSupport()->getEntity()]
+ << "| for field |"
+ << MED_FIELD_DRIVER<T>::_fieldName
+ << "| with (it,or) = ("
+ << MED_FIELD_DRIVER<T>::_ptrField->_iterationNumber << ","
+ << MED_FIELD_DRIVER<T>::_ptrField->_orderNumber << "), on mesh "
+ << meshName << "| differs from found entity |"
+ << MED_EN::entNames[ent] << "|."
+ ));
+ }
+ mySupport->setName( MED_FIELD_DRIVER<T>::_ptrField->getSupport()->getName() );
+ mySupport->setMesh( MED_FIELD_DRIVER<T>::_ptrField->getSupport()->getMesh() );
+ mySupport->setDescription(MED_FIELD_DRIVER<T>::_ptrField->getSupport()->getDescription());
+ }
+
+ // Test si le Support du Champ repose ou non sur toutes les entités géométriques du maillage.
+ // Pour tester les profils aussi ?
+ vector< MED_EN::medGeometryElement > meshGeoType;
+ vector< int > meshNbOfElOfType;
+ getMeshGeometricType(id,meshName,mySupport->getEntity(),meshGeoType,meshNbOfElOfType);
+ vector < MED_EN::medGeometryElement > v1( mySupport->getTypes(),
+ mySupport->getTypes()+mySupport->getNumberOfTypes() );
+ vector < int > v2(mySupport->getNumberOfElements(),
+ mySupport->getNumberOfElements()+mySupport->getNumberOfTypes() );
+ if ( ( meshGeoType != v1 ) || meshNbOfElOfType != v2 ) {
+ mySupport->setAll(false);
+ }
+
+ //??support->setNumber(MEDSKYLINEARRAY * Number);
+ //??support->setNumber(const int * index, const int* value, bool shallowCopy=false);
+
+ // If an error occurs while reading the field, these allocated FIELD member will be deleted
+ MED_FIELD_DRIVER<T>::_ptrField->_name = MED_FIELD_DRIVER<T>::_fieldName;
+ 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 ;
+ 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 = mySupport->getNumberOfTypes() ;
+ const MED_EN::medGeometryElement *Types = mySupport->getTypes() ;
+ T ** myValues = new T*[NumberOfTypes] ;
+ int * NumberOfValues = new int[NumberOfTypes] ;
+ int TotalNumberOfValues = 0 ; // Profils a gerer en 2.2 Rmq from EF
+ 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 :"<< mySupport->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) ;
+
+ NumberOfValues[i] = mySupport->getNumberOfElements(Types[i])
+ * mySupport->getNumberOfGaussPoint(Types[i]);
+
+ myValues[i] = new T[ NumberOfValues[i]*numberOfComponents ] ;
+ TotalNumberOfValues+=NumberOfValues[i] ;
+ 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) mySupport->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+=mySupport->getNumberOfElements(Types[i]); // Ne doit pas prendre en compte les points de Gauss
+
+ 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()),
+ int lgth2=NumberOfValues[i]*numberOfComponents;
+ if(MED_FIELD_DRIVER<T>::_ptrField->getValueType()==MED_EN::MED_INT32)
+ {
+ med_2_1::med_int *temp=new med_2_1::med_int[lgth2];
+ ret=med_2_1::MEDchampLire(id,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_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->getOrderNumber()
- );
- for(int i2=0;i2<lgth2;i2++)
- myValues[i][i2]=(int)(temp[i2]);
- delete [] temp;
- }
- else
+ );
+ 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 ;
+ ret=med_2_1::MEDchampLire(id,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) mySupport->getEntity()
+ ,(med_2_1::med_geometrie_element)Types[i],
+ MED_FIELD_DRIVER<T>::_ptrField->getIterationNumber(),
+ MED_FIELD_DRIVER<T>::_ptrField->getOrderNumber()
+ );
+ if (ret < 0)
+ {
+ // The Field can't be read then we mustdelete all previously allocated members in FIELD
+ 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")) ;
}
- // 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++) {
+
+ delete[] ProfilName ;
+ }
+ // allocate _value
+ // probleme avec les points de gauss : voir lorsqu-il y en a (!= 1)
+ // Creer un driver spécifique pour les modes MED_FULL_INTERLACE et MED_NO_INTERLACE
+ // serait plus efficicace.
+ ArrayNo * Values = new ArrayNo(numberOfComponents,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 !!!!!!!
+ // 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] ;
Count++;
}
}
- }
+ }
- for (int j=0; j<NumberOfTypes; j++)
- delete[] myValues[j] ;
- delete[] myValues ;
- delete[] NumberOfValues ;
+ for (int j=0; j<NumberOfTypes; j++)
+ delete[] myValues[j] ;
+ delete[] myValues ;
+ delete[] NumberOfValues ;
- MED_FIELD_DRIVER<T>::_ptrField->_isRead = true ;
+ if (MED_FIELD_DRIVER<T>::_ptrField->_value != NULL)
+ delete MED_FIELD_DRIVER<T>::_ptrField->_value;
+
+ if ( MED_FIELD_DRIVER<T>::_ptrField->getInterlacingType() == MED_EN::MED_FULL_INTERLACE )
+ {
+ // dynamic_cast inutile
+ MED_FIELD_DRIVER<T>::_ptrField->_value=dynamic_cast<ArrayFull *>(ArrayConvert(*Values));
+ delete Values;
}
+ else
+ MED_FIELD_DRIVER<T>::_ptrField->_value=Values;
+
+ MED_FIELD_DRIVER<T>::_ptrField->_isRead = true ;
+ MED_FIELD_DRIVER<T>::_ptrField->_support=mySupport; //Prévenir l'utilisateur ?
+
END_OF(LOC);
}
{
const char * LOC = "MED_FIELD_WRONLY_DRIVER21::write(void) const " ;
BEGIN_OF(LOC);
+
+ typedef typename MEDMEM_ArrayInterface<T,NoInterlace,NoGauss>::Array ArrayNo;
+ typedef typename MEDMEM_ArrayInterface<T,FullInterlace,NoGauss>::Array ArrayFull;
+
if (MED_FIELD_DRIVER<T>::_status==MED_OPENED)
{
int err ;
int Index = 1 ;
const MED_EN::medGeometryElement * Types = mySupport->getTypes() ;
const int * NumberOfGaussPoint = mySupport->getNumberOfGaussPoint() ;
+
+ const T * value = NULL;
+ ArrayFull * myArray = NULL;
+ if ( MED_FIELD_DRIVER<T>::_ptrField->getInterlacingType() == MED_EN::MED_FULL_INTERLACE )
+ myArray = MED_FIELD_DRIVER<T>::_ptrField->getArrayNoGauss();
+ else {
+ // En attendant la convertion de FIELD, on utilise le ArrayConvert
+ // ( les infos _ptrField-> sont les mêmes )
+ myArray = ArrayConvert( *( dynamic_cast< ArrayNo * >
+ (MED_FIELD_DRIVER<T>::_ptrField->getArrayNoGauss()
+ ))
+ );
+ }
+
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) ;
+// const T * value = MED_FIELD_DRIVER<T>::_ptrField->getValueI(MED_EN::MED_FULL_INTERLACE,Index) ;
+
+ value = myArray->getRow(Index) ;
MESSAGE("MED_FIELD_DRIVER21<T>::_medIdt : "<<MED_FIELD_DRIVER21<T>::_medIdt);
MESSAGE("MeshName.c_str() : "<<MeshName.c_str());
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]
- )
- );
+ {
+ if ( MED_FIELD_DRIVER<T>::_ptrField->getInterlacingType() == MED_EN::MED_NO_INTERLACE ) delete myArray;
+
+ throw MEDEXCEPTION(LOCALIZED( STRING(LOC)
+ <<": Error in writing Field "<< MED_FIELD_DRIVER<T>::_ptrField->getName() <<", type "<<Types[i]
+ )
+ );
+ }
Index += NumberOfElements ;
}
+ if ( MED_FIELD_DRIVER<T>::_ptrField->getInterlacingType() == MED_EN::MED_NO_INTERLACE ) delete myArray;
+
}
END_OF(LOC);
#include "MEDMEM_define.hxx"
-#include "MEDMEM_GenDriver.hxx"
+#include "MEDMEM_DriversDef.hxx"
#include "MEDMEM_Utilities.hxx"
#include "MEDMEM_MedFieldDriver.hxx"
#include "MEDMEM_STRING.hxx"
#include "MEDMEM_Exception.hxx"
#include "MEDMEM_Unit.hxx"
-#include "MEDMEM_Array.hxx"
+
+#include "MEDMEM_ArrayInterface.hxx"
+#include "MEDMEM_ArrayConvert.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...
/*!
med_2_2::med_idt _medIdt;
- void search_field() ;
-
+ bool createFieldSupport(med_2_2::med_idt id,
+ string & fieldName,
+ med_2_2::med_int ndt,
+ med_2_2::med_int od,
+ SUPPORT & support,
+ string & meshName) const throw (MEDEXCEPTION);
+
+ void getMeshGeometricType(med_2_2::med_idt id,
+ string & meshName,
+ MED_EN::medEntityMesh entite,
+ vector<MED_EN::medGeometryElement> & geoType,
+ vector<int> &nbOfElOfType) const;
+
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.
*/
/*!
Constructor.
*/
- MED_FIELD_DRIVER22(const string & fileName, FIELD<T> * ptrField,
+ template <class INTERLACING_TAG>
+ MED_FIELD_DRIVER22(const string & fileName,
+ FIELD<T, INTERLACING_TAG> * ptrField,
MED_EN::med_mode_acces accessMode)
: MED_FIELD_DRIVER<T>(fileName,ptrField,accessMode),_medIdt(MED_INVALID)
{
);
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_DRIVER22<T>::_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 : "<< MED_FIELD_DRIVER22<T>::_medIdt );
+ if (MED_FIELD_DRIVER22<T>::_medIdt > 0)
MED_FIELD_DRIVER<T>::_status=MED_OPENED;
else {
MED_FIELD_DRIVER<T>::_status = MED_INVALID;
- _medIdt = MED_INVALID;
+ MED_FIELD_DRIVER22<T>::_medIdt = MED_INVALID;
throw MED_EXCEPTION (LOCALIZED( STRING(LOC)
<< "Can't open |" << MED_FIELD_DRIVER<T>::_fileName
- << "|, _medIdt : " << _medIdt
+ << "|, _medIdt : " << MED_FIELD_DRIVER22<T>::_medIdt
)
);
}
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);
+ err=med_2_2::MEDfermer(MED_FIELD_DRIVER22<T>::_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 );
+ MED_FIELD_DRIVER22<T>::_medIdt = MED_INVALID;
+ MESSAGE(" MED_FIELD_DRIVER22::close() : MEDfermer : _medIdt= " << MED_FIELD_DRIVER22<T>::_medIdt );
MESSAGE(" MED_FIELD_DRIVER22::close() : MEDfermer : err = " << err );
}
END_OF("MED_FIELD_DRIVER22::close()");
}
-
};
/*!
/*!
Constructor.
*/
- MED_FIELD_RDONLY_DRIVER22(const string & fileName, FIELD<T> * ptrField):
+ template <class INTERLACING_TAG>
+ MED_FIELD_RDONLY_DRIVER22(const string & fileName,
+ FIELD<T, INTERLACING_TAG> * 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)");
+ BEGIN_OF("MED_FIELD_RDONLY_DRIVER22::MED_FIELD_RDONLY_DRIVER22(const string & fileName, const FIELD<T,INTERLACING_TAG> * ptrField)");
+ END_OF("MED_FIELD_RDONLY_DRIVER22::MED_FIELD_RDONLY_DRIVER22(const string & fileName, const FIELD<T,INTERLACING_TAG> * ptrField)");
}
/*!
IMED_FIELD_RDONLY_DRIVER<T>(fieldDriver),
MED_FIELD_DRIVER22<T>(fieldDriver),
MED_FIELD_DRIVER<T>(fieldDriver)
- {};
+ {}
/*!
Destructor.
/*!
Constructor.
*/
- MED_FIELD_WRONLY_DRIVER22(const string & fileName, FIELD<T> * ptrField):
+ template <class INTERLACING_TAG>
+ MED_FIELD_WRONLY_DRIVER22(const string & fileName,
+ FIELD<T, INTERLACING_TAG> * 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)");
- };
+ BEGIN_OF("MED_FIELD_WRONLY_DRIVER22::MED_FIELD_WRONLY_DRIVER22(const string & fileName, const FIELD<T,INTERLACING_TAG> * ptrField)");
+ END_OF("MED_FIELD_WRONLY_DRIVER22::MED_FIELD_WRONLY_DRIVER22(const string & fileName, const FIELD<T,INTERLACING_TAG> * ptrField)");
+ }
/*!
Copy constructor.
IMED_FIELD_WRONLY_DRIVER<T>(fieldDriver),
MED_FIELD_DRIVER22<T>(fieldDriver),
MED_FIELD_DRIVER<T>(fieldDriver)
- {};
+ {}
/*!
Destructor.
/*!
Constructor.
*/
- MED_FIELD_RDWR_DRIVER22(const string & fileName, FIELD<T> * ptrField):
+ template <class INTERLACING_TAG>
+ MED_FIELD_RDWR_DRIVER22(const string & fileName,
+ FIELD<T, INTERLACING_TAG> * ptrField):
MED_FIELD_WRONLY_DRIVER22<T>(fileName,ptrField),
MED_FIELD_RDONLY_DRIVER22<T>(fileName,ptrField),
IMED_FIELD_RDONLY_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)");
+ BEGIN_OF("MED_FIELD_RDWR_DRIVER22::MED_FIELD_RDWR_DRIVER22(const string & fileName, const FIELD<T,INTERLACING_TAG> * ptrField)");
//_accessMode = MED_RDWR ;
- END_OF("MED_FIELD_RDWR_DRIVER22::MED_FIELD_RDWR_DRIVER22(const string & fileName, const FIELD<T> * ptrField)");
- };
+ END_OF("MED_FIELD_RDWR_DRIVER22::MED_FIELD_RDWR_DRIVER22(const string & fileName, const FIELD<T,INTERLACING_TAG> * ptrField)");
+ }
/*!
Copy constructor.
/*--------------------- 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 ;
-// }
-// }
-// }
-// }
+template <class T> bool
+MED_FIELD_DRIVER22<T>::createFieldSupport(med_2_2::med_idt id,
+ string & fieldName,
+ med_2_2::med_int ndt,
+ med_2_2::med_int od,
+ SUPPORT & support,
+ string & meshName) const throw (MEDEXCEPTION)
+{
+
+ //EF : Gérer le meshName pour le driver 2.2
+ const char * LOC="MED_FIELD_DRIVER<T>::search_field(...)";
+
+ map<int, list<MED_EN::medGeometryElement> > CellAndNodeEntities;
+ map<int, list<MED_EN::medGeometryElement> >::iterator currentEntity;
+ CellAndNodeEntities[MED_EN::MED_CELL] = MED_EN::meshEntities[MED_EN::MED_CELL];
+ CellAndNodeEntities[MED_EN::MED_NODE] = MED_EN::meshEntities[MED_EN::MED_NODE];
+ list< MED_EN::medGeometryElement >::const_iterator currentGeometry;
+
+ //med_2_2::med_entite_maillage
+ MED_EN::medEntityMesh entity;
+ bool alreadyFoundAnEntity=false, alreadyFoundPdtIt = false, anyGauss=false;
+ int numberOfElements = 0;
+ int numberOfGeometricType = 0;
+ //med_2_2::med_geometrie_element..
+ MED_EN::medGeometryElement geometricType[MED_NBR_GEOMETRIE_MAILLE];
+ int numberOfElementsOfType[MED_NBR_GEOMETRIE_MAILLE];
+ int numberOfGaussPoint[MED_NBR_GEOMETRIE_MAILLE];
+
+ med_2_2::med_int nmaa=0, ngauss=0, numdt=-1, numo=-1, nbPdtIt=0;
+ char dtunit[MED_TAILLE_PNOM22+1];
+ char maa[MED_TAILLE_NOM+1];
+ med_2_2::med_float dt=-1.0;
+ med_2_2::med_booleen local;
+ med_2_2::med_err ret=1;
+
+ for (currentEntity = CellAndNodeEntities.begin();
+ currentEntity != CellAndNodeEntities.end(); currentEntity++) {
+ for (currentGeometry = (*currentEntity).second.begin();
+ currentGeometry != (*currentEntity).second.end(); currentGeometry++) {
+
+
+ if ( (nbPdtIt = med_2_2::MEDnPasdetemps(id, const_cast <char*> ( fieldName.c_str() ),
+ (med_2_2::med_entite_maillage) (*currentEntity).first,
+ (med_2_2::med_geometrie_element) *currentGeometry )) <= 0 )
+ continue;
+
+
+
+ if ( alreadyFoundAnEntity ) {
+ if (entity != (*currentEntity).first )
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Field |" << fieldName
+ << "| with (ndt,or) = (" << ndt << ","
+ << od << ") must not be defined on nodes and cells" ));
+
+ } else { entity=(*currentEntity).first; alreadyFoundAnEntity = true; };
+
+
+ ret = 0; alreadyFoundPdtIt = false; ngauss =0;
+ for ( med_2_2::med_int j=1; j <= nbPdtIt; j++ ) {
+
+ // Search how many <ngauss> (<fieldName>,<ndt>,<ot>) has
+ ret += med_2_2::MEDpasdetempsInfo(id, const_cast <char*> ( fieldName.c_str() ),
+ (med_2_2::med_entite_maillage) (*currentEntity).first,
+ (med_2_2::med_geometrie_element) *currentGeometry,
+ j, &ngauss, &numdt, &numo, dtunit, &dt,
+ maa, &local, &nmaa);
+
+ if ( ndt == numdt && numo == od ) {
+ alreadyFoundPdtIt = true;
+
+ if ( nmaa > 1 ) {
+ MESSAGE(LOC<<" Field |" << fieldName << "| with (ndt,or) = ("
+ << ndt << "," << od << ") for (entityType,geometricType)=("
+ << MED_EN::entNames[(*currentEntity).first] << ","
+ << MED_EN::geoNames[*currentGeometry] << ")"
+ << "is defined on multiple meshes, using dafault mesh |" << maa << "|" );
+ }
+
+ if ( !local)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Field |" << fieldName << "| with (ndt,or) = ("
+ << ndt << "," << od << ") for (entityType,geometricType)=("
+ << MED_EN::entNames[(*currentEntity).first] << ","
+ << MED_EN::geoNames[*currentGeometry] << ")"
+ << "is using a mesh on a different file which is not yet supported" ));
+
+ if ( ! meshName.empty() )
+ if ( meshName != maa ) {
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Field |" << fieldName << "| with (ndt,or) = ("
+ << ndt << "," << od << ") for (entityType,geometricType)=("
+ << MED_EN::entNames[(*currentEntity).first] << ","
+ << MED_EN::geoNames[*currentGeometry] << ")"
+ << "is defined on mesh |" << maa << "| not on mesh |" << meshName ));
+ }
+ break;
+ }
+
+ }
+
+ if ( !alreadyFoundPdtIt )
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Field |" << fieldName << "| with (ndt,or) = ("
+ << ndt << "," << od << ") should be defined for (entityType,geometricType)=("
+ << MED_EN::entNames[(*currentEntity).first] << ","
+ << MED_EN::geoNames[*currentGeometry] << ")" ));
+
+ if ( (ret != 0) || (ngauss < 1 ) )
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Error in MEDpasdetempsInfo for Field |" << fieldName
+ << "| with (ndt,or) = ("
+ << ndt << "," << od << ") for (entityType,geometricType)=("
+ << MED_EN::entNames[(*currentEntity).first] << ","
+ << MED_EN::geoNames[*currentGeometry] << ")" )); ;
+
+ if ( (numberOfElements = med_2_2::MEDnVal(id, const_cast <char*> ( fieldName.c_str() ),
+ (med_2_2::med_entite_maillage) (*currentEntity).first,
+ (med_2_2::med_geometrie_element) *currentGeometry,
+ numdt, numo, maa, med_2_2::MED_COMPACT)) <= 0 )
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Error in MEDnVal for Field |" << fieldName
+ << "| with (ndt,or) = ("
+ << ndt << "," << od << ") for (entityType,geometricType)=("
+ << MED_EN::entNames[(*currentEntity).first] << ","
+ << MED_EN::geoNames[*currentGeometry] << ")" )); ;
+
+ //totalNumberOfElements+=numberOfElements;
+ numberOfElementsOfType[numberOfGeometricType] = numberOfElements/ngauss;
+ numberOfGaussPoint[numberOfGeometricType] = ngauss;
+ anyGauss = (anyGauss || (ngauss-1) );
+ geometricType[numberOfGeometricType]= *currentGeometry;
+ numberOfGeometricType++;
+
+ } // End Second For
+
+ } // End Premier For
+
+ if ( alreadyFoundAnEntity) {
+ support.setName(fieldName+"Support");
+ support.setMeshName(string(maa)); // Vérifier que les différents noms de maillages lus soient identiques
+ support.setEntity(entity);
+ // REM : Signification précédente erronée pour un champ qui ne repose pas sur toutes les entités géométriques
+ // du maillage mais dont le SUPPORT a été crée à partir des informations d'un maillage, comme
+ // celà fût la plupart du temps.
+ support.setNumberOfGeometricType(numberOfGeometricType);
+ support.setGeometricType(geometricType); // Utile uniquement si setAll == false
+ support.setNumberOfElements(numberOfElementsOfType); //setNumberOfElements effectue une copie
+ support.setAll(true);
+ if (anyGauss)
+ support.setNumberOfGaussPoint(numberOfGaussPoint);
+
+ return alreadyFoundAnEntity;
+ } else
+ return false;
+}
+
+template <class T> void
+MED_FIELD_DRIVER22<T>::getMeshGeometricType(med_2_2::med_idt id,
+ string & meshName,
+ MED_EN::medEntityMesh entity,
+ vector<MED_EN::medGeometryElement> & geoType,
+ vector<int> &nbOfElOfType) const
+{
+ const char LOC[] = "MED_FIELD_DRIVER<T>::getMeshGeometricType(...)";
+
+ int numberOfGeometricType=0;
+ MED_EN::medGeometryElement geometricType[MED_NBR_GEOMETRIE_MAILLE];
+ int numberOfElementsOfType[MED_NBR_GEOMETRIE_MAILLE];
+ med_2_2::med_int numberOfElements=0;
+ med_2_2::med_table quoi;
+ if (entity == MED_EN::MED_CELL) quoi=med_2_2::MED_CONN;
+ else
+ if (entity == MED_EN::MED_NODE) quoi=med_2_2::MED_COOR;
+ else
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Support Creation from Mesh |" << meshName
+ << "| on entity " << MED_EN::entNames[entity]
+ << "| is impossible, must be on MED_NODE or MED_CELL" ));
+
+ list<MED_EN::medGeometryElement>::const_iterator currentGeometry;
+ bool alreadyFoundAnEntity = false;
+
+ for (currentGeometry = (MED_EN::meshEntities[entity]).begin();
+ currentGeometry != (MED_EN::meshEntities[entity]).end(); currentGeometry++) {
+
+
+ if ( (numberOfElements =
+ med_2_2::MEDnEntMaa(id,
+ const_cast<char*> (meshName.c_str()),
+ quoi,
+ (med_2_2::med_entite_maillage) entity,
+ (med_2_2::med_geometrie_element) *currentGeometry,
+ med_2_2::MED_NOD) ) <= 0)
+ continue;
+
+ alreadyFoundAnEntity = true;
+ numberOfElementsOfType[numberOfGeometricType] = numberOfElements;
+ geometricType[numberOfGeometricType] = *currentGeometry;
+ numberOfGeometricType++;
+
+ }
+ geoType = vector<MED_EN::medGeometryElement>(geometricType,geometricType+numberOfGeometricType);
+ nbOfElOfType = vector<int> (numberOfElementsOfType,numberOfElementsOfType+numberOfGeometricType);
+
+}
+
/*--------------------- RDONLY PART -------------------------------*/
template <class T> GENDRIVER * MED_FIELD_RDONLY_DRIVER22<T>::copy(void) const
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)
+ typedef typename MEDMEM_ArrayInterface<T,NoInterlace,NoGauss>::Array ArrayNo;
+ typedef typename MEDMEM_ArrayInterface<T,FullInterlace,NoGauss>::Array ArrayFull;
+
+ if ( ( MED_FIELD_DRIVER<T>::_fieldName.empty() ) &&
+ ( MED_FIELD_DRIVER<T>::_ptrField->_name.empty() ) )
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)
+ <<" neither <fieldName> is set in driver nor in object FIELD.")) ;
+
+ // If _fieldName is not set in driver, try to use _ptrfield->_fieldName
+ if ( ( MED_FIELD_DRIVER<T>::_fieldName.empty() ) &&
+ ( !MED_FIELD_DRIVER<T>::_ptrField->_name.empty() ) )
+ MED_FIELD_DRIVER<T>::_fieldName=MED_FIELD_DRIVER<T>::_ptrField->_name;
+
+ if ( MED_FIELD_DRIVER<T>::_fieldName.size() > MED_TAILLE_NOM )
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)
+ <<" <fieldName> size in object driver FIELD is > MED_TAILLE_NOM ."));
+
+
+ MESSAGE("###### "<<LOC<<" fieldNameDRIVER : "<< MED_FIELD_DRIVER<T>::_fieldName <<
+ " fieldName : "<<MED_FIELD_DRIVER<T>::_fieldName);
+
+
+ if (MED_FIELD_DRIVER<T>::_status!=MED_OPENED)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<": Method open must be called before method read.")) ;
+
+// EF :
+// Si un support a été donnée au champ, pour des raisons de compatibilité avec
+// les versions précédentes, ce support sera utilisé pour
+// - Obtenir le nom du maillage sur lequel on veut lire le champ
+// (eventuellement on pourrait l'utiliser pour selectionner un champ qui
+// repose sur plusieurs maillages cf HOMARD-ASTER)
+// - vérifier le type d'entité (MED_NOEUD xor MED_MAILLE xor MED_FACE xor MED_ARETE ) sur lequel
+// il faut lire le champ qui est également retouvé.
+// - Si le support défini une liste d'entité ( différente de MED_ALL_ELEMENTS), celle-ci est ignorée
+// à la lecture et écrasé par les listes de profils lus s'il en existe
+
+// Si aucun support n'a été donné au champ :
+// - A la lecture : Un support est crée et le type d'entité unique est lu
+// (cf decision gt MED qu'un champ repose sur une entité unique ?),
+// l'ensemble des types géométriques est lu,
+// l'ensemble des profils par type géométrique est lu
+// Le nom du maillage associé est lu mais le pointeur SUPPORT-MESH non initialisé
+
+ char * 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 ;
+ med_2_2::med_idt id = MED_FIELD_DRIVER22<T>::_medIdt;
+
+ // we search for the field med number of <fieldName>
+ // Having found <fieldName> variables <numberOfComponents>,
+ // <componentName>, <unitname>, <type> and attribute <_fieldNum> are set.
+ if (MED_FIELD_DRIVER<T>::_fieldNum==MED_INVALID)
{
+ int numberOfFields = med_2_2::MEDnChamp(id,0) ;
+ if ( numberOfFields <= 0 )
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<": There is no field found in the file !"));
- // 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 ;
+ for (int i=1;i<=numberOfFields;i++)
+ {
+ numberOfComponents = med_2_2::MEDnChamp(id,i) ;
- // 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) ;
+ err = med_2_2::MEDchampInfo(id, i, fieldName, &type, componentName,
+ unitName, numberOfComponents) ;
- MESSAGE("Champ "<<i<<" : #" << fieldName <<"# et recherche #"<<MED_FIELD_DRIVER<T>::_fieldName.c_str()<<"#");
+ MESSAGE("Field "<<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 ;
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()),
+ 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);
+
+ if (numberOfComponents < 1) {
+ delete[] componentName; delete[] unitName;
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" no component found fo field "
+ << MED_FIELD_DRIVER<T>::_fieldName)) ;
+ }
+
+ switch ( (med_2_2::med_type_champ) MED_FIELD_DRIVER<T>::_ptrField->_valueType ) {
+ case med_2_2::MED_INT :
+ case med_2_2::MED_INT32 :
+ case med_2_2::MED_INT64 :
+ if ( type == ( med_2_2::MED_FLOAT64 ) ) {
+ delete[] componentName; delete[] unitName;
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Field Type in file (" << type
+ <<") differs from FIELD object type (" <<
+ MED_FIELD_DRIVER<T>::_ptrField->_valueType << ")" )) ;
+ }
+ break;
+ default:
+ break;
+ }
+
+
+ string meshName="";
+ bool haveSupport = false;
+ if ( MED_FIELD_DRIVER<T>::_ptrField->getSupport() ) {
+ // Verif sur la taille du meshName
+ meshName = MED_FIELD_DRIVER<T>::_ptrField->getSupport()->getMesh()->getName() ;
+ haveSupport = true;
+ }
+
+ // Cherche le type d'entité, le nombre d'entité par type géométrique sur le type d'entité
+ // (MED_MAILLE ou MED_NOEUD uniquement car MEDMEMOIRE ne gère pas la connectivité descendante).
+ // et crée le support correspondant.
+ SUPPORT * mySupport = new SUPPORT();
+ bool found = createFieldSupport(id,MED_FIELD_DRIVER<T>::_fieldName,
+ MED_FIELD_DRIVER<T>::_ptrField->_iterationNumber,
+ MED_FIELD_DRIVER<T>::_ptrField->_orderNumber,
+ *mySupport, meshName) ;
+ if ( !found ) {
+ delete mySupport; delete[] componentName; delete[] unitName;
+ MED_FIELD_DRIVER<T>::_fieldNum = MED_INVALID ;
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Can't find any entity for field |"
+ << MED_FIELD_DRIVER<T>::_fieldName
+ << "| with (it,or) = ("
+ << MED_FIELD_DRIVER<T>::_ptrField->_iterationNumber << ","
+ << MED_FIELD_DRIVER<T>::_ptrField->_orderNumber << "), on mesh "
+ << meshName << "|" ));
+ }
+
+ if (! haveSupport)
+ meshName = mySupport->getMeshName();
+ else {
+ if ( mySupport->getEntity() != MED_FIELD_DRIVER<T>::_ptrField->getSupport()->getEntity() ) {
+ MED_EN::medEntityMesh ent = mySupport->getEntity();
+ delete mySupport; delete[] componentName; delete[] unitName;
+ MED_FIELD_DRIVER<T>::_fieldNum = MED_INVALID ;
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Given entity |"
+ << MED_EN::entNames[MED_FIELD_DRIVER<T>::_ptrField->
+ getSupport()->getEntity()]
+ << "| for field |"
+ << MED_FIELD_DRIVER<T>::_fieldName
+ << "| with (it,or) = ("
+ << MED_FIELD_DRIVER<T>::_ptrField->_iterationNumber << ","
+ << MED_FIELD_DRIVER<T>::_ptrField->_orderNumber << "), on mesh "
+ << meshName << "| differs from found entity |"
+ << MED_EN::entNames[ent] << "|."
+ ));
+ }
+ mySupport->setName( MED_FIELD_DRIVER<T>::_ptrField->getSupport()->getName() );
+ mySupport->setMesh( MED_FIELD_DRIVER<T>::_ptrField->getSupport()->getMesh() );
+ mySupport->setDescription(MED_FIELD_DRIVER<T>::_ptrField->getSupport()->getDescription());
+ }
+
+ // Test si le Support du Champ repose ou non sur toutes les entités géométriques du maillage.
+ // Pour tester les profils aussi ?
+ vector< MED_EN::medGeometryElement > meshGeoType;
+ vector< int > meshNbOfElOfType;
+ getMeshGeometricType(id,meshName,mySupport->getEntity(),meshGeoType,meshNbOfElOfType);
+ vector < MED_EN::medGeometryElement > v1( mySupport->getTypes(),
+ mySupport->getTypes()+mySupport->getNumberOfTypes() );
+ vector < int > v2(mySupport->getNumberOfElements(),
+ mySupport->getNumberOfElements()+mySupport->getNumberOfTypes() );
+ if ( ( meshGeoType != v1 ) || meshNbOfElOfType != v2 ) {
+ mySupport->setAll(false);
+ }
+
+ //??support->setNumber(MEDSKYLINEARRAY * Number);
+ //??support->setNumber(const int * index, const int* value, bool shallowCopy=false);
+
+ // If an error occurs while reading the field, these allocated FIELD member will be deleted
+
+ MED_FIELD_DRIVER<T>::_ptrField->_name = MED_FIELD_DRIVER<T>::_fieldName;
+ 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 ;
+ 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;
+
+ int NumberOfTypes = mySupport->getNumberOfTypes() ;
+ const MED_EN::medGeometryElement *Types = mySupport->getTypes() ;
+ T ** myValues = new T*[NumberOfTypes] ;
+ int * NumberOfValues = new int[NumberOfTypes] ;
+ int TotalNumberOfValues = 0 ; //profil a gerer en 2.2
+ MESSAGE ("NumberOfTypes :"<< NumberOfTypes);
+ MED_FIELD_DRIVER<T>::_ptrField->_numberOfValues=0 ;
+ for (int i=0; i<NumberOfTypes; i++)
+ {
+ NumberOfValues[i] = mySupport->getNumberOfElements(Types[i])
+ * mySupport->getNumberOfGaussPoint(Types[i]);
+ myValues[i] = new T[ NumberOfValues[i]*numberOfComponents ] ;
+ TotalNumberOfValues+=NumberOfValues[i] ;
+ char * ProfilName = new char[MED_TAILLE_NOM+1];
+ char * LocalGaussName = new char[MED_TAILLE_NOM+1];
+
+ MESSAGE ("Type["<<i+1<<"] :"<< Types[i]);
+ MESSAGE ("Entity :"<<mySupport->getEntity());
+ 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) mySupport->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+=mySupport->getNumberOfElements(Types[i]); // Ne doit pas prendre en compte les points de Gauss
+ med_2_2::med_err ret;
+
+#if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
+ int lgth2=NumberOfValues[i]*numberOfComponents;
+ if(_ptrField->getValueType()==MED_EN::MED_INT32)
+ {
+ med_2_2::med_int *temp=new med_2_2::med_int[lgth2];
+ ret=med_2_2::MEDchampLire(id,const_cast <char*> (meshName.c_str()),
+ const_cast <char*> (MED_FIELD_DRIVER<T>::_fieldName.c_str()),
+ (unsigned char*) temp,
+ med_2_2::MED_NO_INTERLACE,
+ MED_ALL,
+ ProfilName,
+ (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->getOrderNumber()
+ );
+ for(int i2=0;i2<lgth2;i2++)
+ myValues[i][i2]=(int)(temp[i2]);
+ delete [] temp;
+ }
+ else
+#endif
+ //VERIFIER LE NBRE
+ ret=med_2_2::MEDchampLire(id,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 !!!
+ med_2_2::MED_NO_INTERLACE,
+ MED_ALL,
+ LocalGaussName,
+ ProfilName,
+ med_2_2::MED_COMPACT,
+ (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->getOrderNumber()
+ );
+ if (ret < 0)
+ {
+ // The Field can't be read then we mustdelete all previously allocated members in FIELD
for(int j=0; j<=i;j++)
delete[] myValues[j];
delete[] myValues;
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++) {
+ delete[] ProfilName ;
+ delete[] LocalGaussName ;
+ }
+
+ // allocate _value
+ // Créer un driver spécifique pour les modes MED_FULL_INTERLACE et MED_NO_INTERLACE
+ // serait plus efficicace.
+ ArrayNo * Values = new ArrayNo(numberOfComponents,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));
+// SCRUTE(Count);
+// SCRUTE(Values->getIJ(Count,i+1));
Count++;
}
- }
}
+ }
- for (int j=0; j<NumberOfTypes; j++)
- delete[] myValues[j] ;
- delete[] myValues ;
- delete[] NumberOfValues ;
+ for (int j=0; j<NumberOfTypes; j++)
+ delete[] myValues[j] ;
+ delete[] myValues ;
+ delete[] NumberOfValues ;
- MED_FIELD_DRIVER<T>::_ptrField->_isRead = true ;
+ if (MED_FIELD_DRIVER<T>::_ptrField->_value != NULL)
+ delete MED_FIELD_DRIVER<T>::_ptrField->_value;
+
+ if ( MED_FIELD_DRIVER<T>::_ptrField->getInterlacingType() == MED_EN::MED_FULL_INTERLACE )
+ {
+ // dynamic_cast inutile
+ MED_FIELD_DRIVER<T>::_ptrField->_value=dynamic_cast<ArrayFull *>(ArrayConvert(*Values));
+ delete Values;
}
+ else
+ MED_FIELD_DRIVER<T>::_ptrField->_value=Values;
+ MED_FIELD_DRIVER<T>::_ptrField->_isRead = true ;
+
+ MED_FIELD_DRIVER<T>::_ptrField->_support=mySupport; //Prévenir l'utilisateur ?
+
END_OF(LOC);
}
{
const char * LOC = "MED_FIELD_WRONLY_DRIVER22::write(void) const " ;
BEGIN_OF(LOC);
+
+ typedef typename MEDMEM_ArrayInterface<T,NoInterlace,NoGauss>::Array ArrayNo;
+ typedef typename MEDMEM_ArrayInterface<T,FullInterlace,NoGauss>::Array ArrayFull;
+
if (MED_FIELD_DRIVER<T>::_status==MED_OPENED)
{
int err ;
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());
+
+ const T * value = NULL;
+ ArrayFull * myArray = NULL;
+ if ( MED_FIELD_DRIVER<T>::_ptrField->getInterlacingType() == MED_EN::MED_FULL_INTERLACE )
+ myArray = MED_FIELD_DRIVER<T>::_ptrField->getArrayNoGauss();
+ else
+ {
+ // En attendant la convertion de FIELD, on utilise le ArrayConvert
+ // ( les infos _ptrField-> sont les mêmes )
+ myArray = ArrayConvert( *( dynamic_cast< ArrayNo * >
+ (MED_FIELD_DRIVER<T>::_ptrField->getArrayNoGauss()
+ ))
+ );
+ }
+
+ for (int i=0;i<NumberOfType;i++)
+ {
+ int NumberOfElements = mySupport->getNumberOfElements(Types[i]) ;
+
+ //value = MED_FIELD_DRIVER<T>::_ptrField->getRow(Index) ;
+ value = myArray->getRow(Index) ;
+
+ MESSAGE("MED_FIELD_DRIVER22<T>::_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];
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);
+ err=med_2_2::MEDchampInfo(MED_FIELD_DRIVER22<T>::_medIdt,1,chanom,&chatype,chacomp,chaunit,chancomp);
if (err<0)
{
);
if (err < MED_VALID )
- throw MEDEXCEPTION(LOCALIZED( STRING(LOC)
- <<": Error in writing Field "<< MED_FIELD_DRIVER<T>::_ptrField->getName() <<", type "<<Types[i]
- )
- );
+ {
+ if ( MED_FIELD_DRIVER<T>::_ptrField->getInterlacingType() == MED_EN::MED_NO_INTERLACE ) delete myArray;
+ throw MEDEXCEPTION(LOCALIZED( STRING(LOC)
+ <<": Error in writing Field "<< MED_FIELD_DRIVER<T>::_ptrField->getName() <<", type "<<Types[i]
+ )
+ );
+ }
Index += NumberOfElements ;
- }
+ }
+ if ( MED_FIELD_DRIVER<T>::_ptrField->getInterlacingType() == MED_EN::MED_NO_INTERLACE ) delete myArray;
+
}
END_OF(LOC);
END_OF("MED_FIELD_RDWR_DRIVER22::read(void)");
}
-}
+} //End namespace MEDMEM
/*-----------------------------------------------------------------*/
#endif /* MED_FIELD_DRIVER_HXX */
-
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
break ;
}
}
- ptrField->setValueType((MED_EN::med_type_champ)
- type) ;
// need to write field !
MESSAGE("timeStepNumber :"<<timeStepNumber<<
const char * LOC = "MED_MESH_RDONLY_DRIVER21::getNodalConnectivity : " ;
BEGIN_OF(LOC);
- int spaceDimension = _ptrMesh->_spaceDimension;
-
if (_status==MED_OPENED)
{
+ int spaceDimension = _ptrMesh->_spaceDimension;
+
// 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();
const_cast <char *> ( _meshName.c_str() ),
const_cast <char *> ( families[i]->getName().c_str() ),
families[i]->getIdentifier(),
- families[i]->getAttributesIdentifiers(),
- families[i]->getAttributesValues(),
+ (med_2_1::med_int*) families[i]->getAttributesIdentifiers(),
+ (med_2_1::med_int*) families[i]->getAttributesValues(),
const_cast <char *> (attributesDescriptions.c_str()),
numberOfAttributes,
const_cast <char *> (groupsNames.c_str()),
const char * LOC = "MED_MESH_RDONLY_DRIVER22::getNodalConnectivity : " ;
BEGIN_OF(LOC);
- int spaceDimension = _ptrMesh->_spaceDimension;
-
if (_status==MED_OPENED)
{
+ int spaceDimension = _ptrMesh->_spaceDimension;
+
// 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();
int meshDimension = med_2_2::MEDdimLire(_medIdt, const_cast <char *>
(_meshName.c_str()) );
- if ((spaceDimension != MED_VALID) && (meshDimension != MED_VALID))
+ SCRUTE(spaceDimension);
+ SCRUTE(meshDimension);
+ SCRUTE(_ptrMesh->_spaceDimension);
+ SCRUTE(_ptrMesh->_meshDimension);
+
+ 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)
+ if (err < MED_VALID)
throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Unable to create Mesh : |" << _meshName << "|"));
else
MESSAGE(LOC<<"Mesh "<<_meshName<<" created in file "<<_fileName<<" !");
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()+"/";
+ dataGroupFam = "/ENS_MAA/"+_meshName+"/FAS/ELEME/"+families[i]->getName()+"/";
SCRUTE("|"<<dataGroupFam<<"|");
err = med_2_2::_MEDdatagroupOuvrir(_medIdt,const_cast <char *> (dataGroupFam.c_str()) ) ;
const_cast <char *> ( _meshName.c_str() ),
const_cast <char *> ( families[i]->getName().c_str() ),
families[i]->getIdentifier(),
- families[i]->getAttributesIdentifiers(),
- families[i]->getAttributesValues(),
+ (med_2_2::med_int*)families[i]->getAttributesIdentifiers(),
+ (med_2_2::med_int*)families[i]->getAttributesValues(),
const_cast <char *> (attributesDescriptions.c_str()),
numberOfAttributes,
const_cast <char *> (groupsNames.c_str()),
return mySupport ;
}
-FIELD<double>* MESH::getVolume(const SUPPORT *Support) const throw (MEDEXCEPTION)
+FIELD<double, FullInterlace>* MESH::getVolume(const SUPPORT *Support) const throw (MEDEXCEPTION)
{
const char * LOC = "MESH::getVolume(SUPPORT*) : ";
BEGIN_OF(LOC);
length_values = Support->getNumberOfElements(MED_ALL_ELEMENTS);
types = Support->getTypes();
int index;
- FIELD<double>* Volume = new FIELD<double>(Support,1);
+ FIELD<double, FullInterlace>* Volume =
+ new FIELD<double, FullInterlace>(Support,1);
// double *volume = new double [length_values];
Volume->setName("VOLUME");
Volume->setDescription("cells volume");
Volume->setMEDComponentUnit(1,MEDComponentUnit);
- Volume->setValueType(MED_REEL64);
-
Volume->setIterationNumber(0);
Volume->setOrderNumber(0);
Volume->setTime(0.0);
- MEDARRAY<double> *volume = Volume->getvalue();
+
+ //const double *volume = Volume->getValue(MED_FULL_INTERLACE);
+ typedef MEDMEM_ArrayInterface<double,FullInterlace,NoGauss>::Array ArrayNoGauss;
+ ArrayNoGauss *volume = Volume->getArrayNoGauss();
+
index = 1;
const double * coord = getCoordinates(MED_FULL_INTERLACE);
return Volume;
}
-FIELD<double>* MESH::getArea(const SUPPORT * Support) const throw (MEDEXCEPTION)
+FIELD<double, FullInterlace>* MESH::getArea(const SUPPORT * Support) const throw (MEDEXCEPTION)
{
const char * LOC = "MESH::getArea(SUPPORT*) : ";
BEGIN_OF(LOC);
types = Support->getTypes();
int index;
- FIELD<double>* Area;
+ FIELD<double, FullInterlace>* Area;
- Area = new FIELD<double>(Support,1);
+ Area = new FIELD<double, FullInterlace>(Support,1);
Area->setName("AREA");
Area->setDescription("cells or faces area");
Area->setMEDComponentUnit(1,MEDComponentUnit);
- Area->setValueType(MED_REEL64);
-
Area->setIterationNumber(0);
Area->setOrderNumber(0);
Area->setTime(0.0);
- double *area = (double *)Area->getValue(MED_FULL_INTERLACE);
+ double *area = (double *)Area->getValue();
const double * coord = getCoordinates(MED_FULL_INTERLACE);
index = 0;
return Area;
}
-FIELD<double>* MESH::getLength(const SUPPORT * Support) const throw (MEDEXCEPTION)
+FIELD<double, FullInterlace>* MESH::getLength(const SUPPORT * Support) const throw (MEDEXCEPTION)
{
const char * LOC = "MESH::getLength(SUPPORT*) : ";
BEGIN_OF(LOC);
types = Support->getTypes();
int index;
- FIELD<double>* Length;
+ FIELD<double, FullInterlace>* Length;
- Length = new FIELD<double>(Support,1);
+ Length = new FIELD<double, FullInterlace>(Support,1);
// double *length = new double [length_values];
- Length->setValueType(MED_REEL64);
//const double *length = Length->getValue(MED_FULL_INTERLACE);
- MEDARRAY<double> * length = Length->getvalue();
+ typedef MEDMEM_ArrayInterface<double,FullInterlace,NoGauss>::Array ArrayNoGauss;
+ ArrayNoGauss * length = Length->getArrayNoGauss();
const double * coord = getCoordinates(MED_FULL_INTERLACE);
index = 1;
return Length;
}
-FIELD<double>* MESH::getNormal(const SUPPORT * Support) const throw (MEDEXCEPTION)
+FIELD<double, FullInterlace>* MESH::getNormal(const SUPPORT * Support) const throw (MEDEXCEPTION)
{
const char * LOC = "MESH::getNormal(SUPPORT*) : ";
BEGIN_OF(LOC);
int index;
- FIELD<double>* Normal = new FIELD<double>(Support,dim_space);
+ FIELD<double, FullInterlace>* Normal =
+ new FIELD<double, FullInterlace>(Support,dim_space);
Normal->setName("NORMAL");
Normal->setDescription("cells or faces normal");
for (int k=1;k<=dim_space;k++) {
Normal->setMEDComponentUnit(k,"unit");
}
- Normal->setValueType(MED_REEL64);
-
Normal->setIterationNumber(MED_NOPDT);
Normal->setOrderNumber(MED_NONOR);
Normal->setTime(0.0);
- double *normal = (double *)Normal->getValue(MED_FULL_INTERLACE);
+ double *normal = (double *)Normal->getValue();
const double * coord = getCoordinates(MED_FULL_INTERLACE);
index = 0;
return Normal;
}
-FIELD<double>* MESH::getBarycenter(const SUPPORT * Support) const throw (MEDEXCEPTION)
+FIELD<double, FullInterlace>* MESH::getBarycenter(const SUPPORT * Support) const throw (MEDEXCEPTION)
{
const char * LOC = "MESH::getBarycenter(SUPPORT*) : ";
MESH* myMesh = Support->getMesh();
length_values = Support->getNumberOfElements(MED_ALL_ELEMENTS);
types = Support->getTypes();
- FIELD<double>* Barycenter;
- Barycenter = new FIELD<double>(Support,dim_space);
+ FIELD<double, FullInterlace>* Barycenter;
+ Barycenter = new FIELD<double, FullInterlace>(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=(double *)Barycenter->getValue(MED_FULL_INTERLACE);
+ double *barycenter=(double *)Barycenter->getValue();
const double * coord = getCoordinates(MED_FULL_INTERLACE);
int index=0;
for (int i=0;i<nb_type;i++)
#include "MEDMEM_Connectivity.hxx"
#include "MEDMEM_GenDriver.hxx"
#include "MEDMEM_RCBase.hxx"
+#include "MEDMEM_FieldForward.hxx"
/*! This class contains all the informations related with a MESH :
- COORDINATES
namespace MEDMEM {
-template <class T> class FIELD;
-
class CELLMODEL;
class FAMILY;
class GROUP;
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);
+ template<class T> static
+ FIELD<T> * mergeFields(const vector< FIELD<T> * > & others, bool meshCompare=false);
/*!
*For ref counter. Only for client
*/
//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)
+FIELD<T, FullInterlace> * MESH::mergeFields(const vector< FIELD<T, FullInterlace> * > & others,
+ bool meshCompare)
{
const char * LOC = "MESH::mergeFields(const vector< FIELD<T>* >& others,bool meshCompare): ";
BEGIN_OF(LOC);
if(others.size()==0)
return 0;
vector<SUPPORT *> sup;
- typename vector< FIELD<T>* >::const_iterator iter;
+ typename vector< FIELD<T, FullInterlace>* >::const_iterator iter;
+ iter = others.begin();
+ MED_EN::med_type_champ valueType = (*iter)->getValueType();
for(iter=others.begin();iter!=others.end();iter++)
{
+ MED_EN::med_type_champ valueTypeIter = (*iter)->getValueType();
+ if (valueTypeIter != valueType)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Fields vector have not the same value type"));
+
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);
+ FIELD<T, FullInterlace> *ret=new FIELD<T, FullInterlace>(retSup, retNumberOfComponents);
+ T* valuesToSet=(T*)ret->getValue();
int nbOfEltsRetSup=retSup->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS);
T* tempValues=new T[retNumberOfComponents];
if(retSup->isOnAllElements())
PORFLOW_MESH_DRIVER::PORFLOW_MESH_DRIVER():
GENDRIVER(),
- _ptrMesh(( MESH *)MED_NULL),
+ _ptrMesh(( MESH *) NULL),
// A VOIR _medIdt(MED_INVALID),
_meshName("")
{
using namespace std;
# include <string>
-# include <strstream>
+# include <sstream>
/*!
A class to generate string from any type:
throw SALOME_EXCEPTION (LOCALIZED(msgErr)) ;
*/
namespace MEDMEM {
-class STRING : public string
-{
+ class STRING : public string
+ {
-private :
- ostrstream _s ;
+ private :
+ ostringstream _s ;
-public :
+ public :
- STRING() :string(), _s()
- {
- }
+ STRING() :string(), _s()
+ {
+ }
- ~STRING()
- {
- _s.freeze(false);
- }
+ ~STRING()
+ {
+ }
- operator const char * () const
- {
- return const_cast <const char *> (this->c_str()) ;
- }
+ operator const char * () const
+ {
+ // return const_cast <const char *> (this->c_str()) ;
+ return this->c_str();
+ }
- template <class T> STRING( const T &valeur ) : string(), _s()
- {
- _s.freeze(false);
+ template <class T> STRING( const T &valeur ) : string(), _s()
+ {
+ _s << valeur ;
- _s << valeur ;
- _s << ends;
+ this->string::operator =( _s.str());
+ }
- this->string::operator =( _s.str()); // freeze is true by now
- }
+ template <class T> STRING & operator<<( const T &valeur )
+ {
+ _s << valeur ;
- template <class T> STRING & operator<<( const T &valeur )
- {
-
- if ( _s.pcount() )
- {
- _s.seekp(-1, ios::cur); // Back up before NULL
- _s.rdbuf()->freeze(0); // Unfreeze it
- }
-
- _s << valeur ;
- _s << ends;
-
- this->string::operator = ( _s.str() ) ; // freeze is true by now
- _s.freeze( false ) ;
- return *this ;
+ this->string::operator = ( _s.str() ) ; // freeze is true by now
-
- }
-} ;
+ return *this ;
+ }
+ } ;
} ;
# endif
#include <algorithm>
#include <list>
-#include "MEDMEM_DriversDef.hxx"
#include "MEDMEM_Support.hxx"
+#include "MEDMEM_DriversDef.hxx"
#include "MEDMEM_Mesh.hxx"
using namespace std;
//--------------------------------------------------------------------------
SUPPORT::SUPPORT(): _name(""), _description("None"), _mesh((MESH*)NULL),
_entity(MED_CELL), _numberOfGeometricType(0),
- _geometricType((medGeometryElement*)NULL),
- _numberOfGaussPoint((int*)NULL),
_isOnAllElts(false),
- _numberOfElements((int*)NULL),
_totalNumberOfElements(0),
_number((MEDSKYLINEARRAY*)NULL)
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
SUPPORT::SUPPORT(MESH* Mesh, string Name/*=""*/, medEntityMesh Entity/*=MED_CELL*/):
_name(Name), _description("None"), _mesh(Mesh), _entity(Entity),
- _numberOfGeometricType(0),
- _geometricType((medGeometryElement*)NULL),
- _numberOfGaussPoint((int*)NULL),
- _isOnAllElts(true),
- _numberOfElements((int*)NULL),
- _totalNumberOfElements(0),
- _number((MEDSKYLINEARRAY*)NULL)
+ _numberOfGeometricType(0), _isOnAllElts(true),
+ _totalNumberOfElements(0), _number((MEDSKYLINEARRAY*)NULL)
//--------------------------------------------------------------------------
{
MESSAGE("SUPPORT::SUPPORT(MESH*Mesh,string Name,medEntityMesh Entity)");
const char * LOC = "SUPPORT::SUPPORT(SUPPORT & m) : " ;
BEGIN_OF(LOC) ;
- _name = m._name;
- _description = m._description;
- _mesh = m._mesh; // on recopie uniquement l'adresse
+ _name = m._name ;
+ _description = m._description ;
+ _mesh = m._mesh ; // on recopie uniquement l'adresse
_entity = m._entity;
_numberOfGeometricType = m._numberOfGeometricType;
- if (m._geometricType != NULL)
- {
- _geometricType = new medGeometryElement[m._numberOfGeometricType];
- memcpy(_geometricType,m._geometricType,m._numberOfGeometricType*sizeof(medGeometryElement));
- }
- else
- _geometricType = (medGeometryElement *) NULL;
- if (m._numberOfGaussPoint != NULL)
- {
- _numberOfGaussPoint = new int[m._numberOfGeometricType];
- memcpy(_numberOfGaussPoint,m._numberOfGaussPoint,m._numberOfGeometricType*sizeof(int));
- }
- else
- _numberOfGaussPoint = (int *) NULL;
+
+ if (m._geometricType)
+ _geometricType.set(_numberOfGeometricType,m._geometricType);
+
+ if (m._numberOfGaussPoint)
+ _numberOfGaussPoint.set(_numberOfGeometricType,m._numberOfGaussPoint);
+
_isOnAllElts = m._isOnAllElts;
- if (m._numberOfElements != NULL)
- {
- _numberOfElements = new int[_numberOfGeometricType];
- memcpy(_numberOfElements,m._numberOfElements,_numberOfGeometricType*sizeof(int));
- }
- else
- _numberOfElements = (int *) NULL;
+
+ if (m._numberOfElements)
+ _numberOfElements.set(_numberOfGeometricType,m._numberOfElements);
+
_totalNumberOfElements = m._totalNumberOfElements;
+
if (m._isOnAllElts == false)
_number = new MEDSKYLINEARRAY(* m._number);
else
END_OF(LOC) ;
};
+/*!
+ Affectation operator. operator = perform et deep copy except for attribute _mesh
+*/
+//--------------------------------------------------------------------------
+SUPPORT & SUPPORT::operator=(const SUPPORT & m)
+//--------------------------------------------------------------------------
+{
+ const char * LOC = "SUPPORT::operator=(const SUPPORT & m) : " ;
+ BEGIN_OF(LOC) ;
+
+ if ( this == &m ) return *this;
+ _name = m._name;
+ _description = m._description;
+ _mesh = m._mesh ; // on recopie uniquement l'adresse
+ _entity = m._entity;
+ _numberOfGeometricType = m._numberOfGeometricType;
+ if (m._geometricType)
+ _geometricType.set(_numberOfGeometricType,m._geometricType);
+ if (m._numberOfGaussPoint)
+ _numberOfGaussPoint.set(_numberOfGeometricType,m._numberOfGaussPoint);
+ _isOnAllElts = m._isOnAllElts;
+ if (m._numberOfElements)
+ _numberOfElements.set(_numberOfGeometricType,m._numberOfElements);
+ _totalNumberOfElements = m._totalNumberOfElements;
+ if (m._isOnAllElts == false) {
+ if (_number) delete _number;
+ _number = new MEDSKYLINEARRAY(* m._number);
+ } else
+ _number = (MEDSKYLINEARRAY *) NULL;
+
+ END_OF(LOC) ;
+ return *this;
+}
/*!
Destructor.
if (!(my._isOnAllElts)) {
int numberoftypes = my._numberOfGeometricType ;
os << "NumberOfTypes : "<<numberoftypes<<endl;
- medGeometryElement * types = my._geometricType;
+ PointerOf<medGeometryElement> types = my._geometricType;
for (int j=0;j<numberoftypes;j++) {
int numberOfElements = my._numberOfElements[j];
os << " * Type "<<types[j]<<" : there is(are) "<<numberOfElements<<" element(s) :" << endl;
const char * LOC = "SUPPORT::update() : " ;
BEGIN_OF(LOC) ;
- if (_isOnAllElts) {
- if (_entity == MED_NODE) {
- _numberOfGeometricType=1 ;
- _geometricType=new medGeometryElement[1] ;
- _geometricType[0]=MED_NONE ;
- _numberOfElements = new int[1] ;
- _numberOfElements[0]=_mesh->getNumberOfNodes();
- _totalNumberOfElements=_numberOfElements[0];
- _numberOfGaussPoint = new int[1] ;
- _numberOfGaussPoint[0]=1;
- } else { // we duplicate information from _mesh
- _numberOfGeometricType=_mesh->getNumberOfTypesWithPoly(_entity);
- if (_geometricType == (medGeometryElement *) NULL)
- _geometricType=_mesh->getTypesWithPoly(_entity);
+ if (_isOnAllElts)
+ {
+ if (_entity == MED_NODE)
+ {
+ _numberOfGeometricType=1 ;
+ _geometricType.set(1);
+ _geometricType[0]=MED_NONE;
+ _numberOfElements.set(1);
+ _numberOfElements[0]=_mesh->getNumberOfNodes();
+ _totalNumberOfElements=_numberOfElements[0];
+ _numberOfGaussPoint.set(1) ;
+ _numberOfGaussPoint[0]=1;
+ }
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->getNumberOfElementsWithPoly(_entity,_geometricType[i]) ;
- _totalNumberOfElements+=_numberOfElements[i];
- _numberOfGaussPoint[i]=1 ;
- }
+ { // we duplicate information from _mesh
+ _numberOfGeometricType=_mesh->getNumberOfTypesWithPoly(_entity);
+ SCRUTE(_numberOfGeometricType);
+ _geometricType.set(_numberOfGeometricType,_mesh->getTypesWithPoly(_entity) );
+ _numberOfElements.set(_numberOfGeometricType);
+ _numberOfGaussPoint.set(_numberOfGeometricType);
+ _totalNumberOfElements=0;
+ for (int i=0;i<_numberOfGeometricType;i++)
+ {
+ _numberOfElements[i]=_mesh->getNumberOfElementsWithPoly(_entity,_geometricType[i]) ;
+ _totalNumberOfElements+=_numberOfElements[i];
+ _numberOfGaussPoint[i]=1 ;
+ }
+ }
+
+ SCRUTE(_name);
+ SCRUTE(_numberOfGeometricType);
+ SCRUTE(_numberOfGaussPoint);
}
- }
END_OF(LOC);
};
+/*!
+ Get the field value index (in fortran mode) from the support global number.
+ Becareful, it doesn't take care of the field number of components
+*/
+//-------------------
+int SUPPORT::getValIndFromGlobalNumber(const int number) const throw (MEDEXCEPTION)
+//-------------------
+{
+ const char * LOC="getValIndFromGlobalNumber(const int number) : ";
+ BEGIN_OF(LOC);
+
+ if (_isOnAllElts) return number;
+
+ int nbOfEltsThis = getNumberOfElements(MED_ALL_ELEMENTS);
+ const int *eltsThis = _number->getValue();
+
+ int iThis;
+ bool found=false;
+
+ for(iThis=0;iThis<nbOfEltsThis && !found;)
+ if(eltsThis[iThis]==number)
+ {
+ found = true;
+ int valInd = iThis+1;
+ return valInd;
+ }
+ else
+ iThis++;
+
+ if(!found)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Can't find the global number |"
+ << number << "| in Support |"
+ << getName() << "|" ));
+
+ // It should never arrive here !!
+ return 0;
+
+ END_OF(LOC);
+}
/*!
Blend the given SUPPORT mySupport into the calling object SUPPORT.
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);
+
+ MESSAGE(LOC << " size Set " << idsSet.size() << " size List " << idsList.size());
+
if(_entity==MED_NODE)
fillFromNodeList(idsList);
else
_description=Description;
_numberOfGeometricType=NumberOfGeometricType;
-
- if (_geometricType!=NULL) delete[] _geometricType ;
- _geometricType = new medGeometryElement[NumberOfGeometricType];
- if (_numberOfElements!=NULL) delete[] _numberOfElements ;
- _numberOfElements = new int[NumberOfGeometricType];
+ _geometricType.set(NumberOfGeometricType);
+ _numberOfElements.set(NumberOfGeometricType);
_totalNumberOfElements = TotalNumberOfElements;
- if (_numberOfGaussPoint!=NULL) delete[] _numberOfGaussPoint ;
- _numberOfGaussPoint = new int[NumberOfGeometricType];
+ _numberOfGaussPoint.set(NumberOfGeometricType);
+
int * index = new int[_numberOfGeometricType+1];
index[0]=1;
int elemDim = -1;
if(idsSetMySupport.find(*iter)!=idsSetMySupport.end())
idsList.push_back(*iter);
int size=idsSet.size();
- if(size!=0)
+ int sizeList = idsList.size();
+
+ MESSAGE(LOC << " size Set " << idsSet.size() << " size List " << idsList.size());
+
+ if(size!=0 && sizeList != 0)
{
if(_entity==MED_NODE)
fillFromNodeList(idsList);
END_OF(LOC);
};
-/*!
- 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);
-
- _name=other._name;
- _description=other._description;
- _mesh=other._mesh;
- _entity=other._entity;
- _isOnAllElts=other._isOnAllElts;
- clearDataOnNumbers();
- _numberOfGeometricType=other._numberOfGeometricType;
- _totalNumberOfElements=other._totalNumberOfElements;
-
- 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;
-}
-
/*!
Method that cleans up all the fields related to _numbers. Defined for code factorization.
*/
{
_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;
/*! set the reference _mesh to Mesh */
//--------------------------------------
-void SUPPORT::setMesh(MESH *Mesh)
+void SUPPORT::setMesh(MESH *Mesh) const
//--------------------------------------
{
if(_mesh)
_mesh->removeReference();
_mesh=Mesh;
+ _meshName = "";
if(_mesh)
_mesh->addReference();
}
+/*! returns the mesh name */
+//------------------------------------
+string SUPPORT::getMeshName() const
+//------------------------------------
+{
+ if (_mesh)
+ return _mesh->getName();
+ else
+ return _meshName;
+}
+
/*!
addReference : reference counter presently disconnected in C++ -> just connected for client.
*/
*/
namespace MEDMEM {
-class MESH ;
+
+ class MESH;
class SUPPORT : public RCBASE
{
*/
string _name;
+ /*!
+ \if developper
+ Name of the associated mesh if the _mesh pointer
+ is NULL.
+ \endif
+ */
+ mutable string _meshName;
+
/*!
\if developper
Description of the support (optional).
Array of all geometric type defined in the support.
\endif
*/
- MED_EN::medGeometryElement * _geometricType;
+ PointerOf<MED_EN::medGeometryElement> _geometricType;
/*!
\if developper
(not yet implemented).
\endif
*/
- mutable int * _numberOfGaussPoint ;
-
- /*
- \if developper
- Array of size _numberOfGeometricType
- which contains number of geometric
- entity type in Mesh
- (to get corresponding CellModel).
- \endif
- */
- //int * _geometricTypeNumber;
+ mutable PointerOf<int> _numberOfGaussPoint ;
/*!
\if developper
for each geometric type, the number of elements of this type.
\endif
*/
- int * _numberOfElements;
+ PointerOf<int> _numberOfElements;
/*!
\if developper
inline void setName(string Name);
inline void setDescription(string Description);
- void setMesh(MESH *Mesh);
+ void setMesh(MESH *Mesh) const;
+ inline void setMeshName(const string & meshName);
inline void setAll(bool All);
inline void setEntity(MED_EN::medEntityMesh Entity);
inline void setNumberOfGeometricType(int NumberOfGeometricType);
inline string getName() const;
inline string getDescription() const;
virtual inline MESH * getMesh() const;
+ string getMeshName() const;
inline MED_EN::medEntityMesh getEntity() const;
inline bool isOnAllElements() const;
inline const int * getNumberOfGaussPoint() const throw (MEDEXCEPTION);
inline int getNumberOfGaussPoint(MED_EN::medGeometryElement geomElement) const throw (MEDEXCEPTION);
inline int getNumberOfElements(MED_EN::medGeometryElement GeometricType) const throw (MEDEXCEPTION);
+ inline const int * getNumberOfElements() const throw (MEDEXCEPTION);
+ // rename getnumber -> getGlobalNumberSky()
virtual inline MEDSKYLINEARRAY * getnumber() const throw (MEDEXCEPTION);
+ // rename getNumber -> getGlobalNumberPtr()
virtual inline const int * getNumber(MED_EN::medGeometryElement GeometricType) const throw (MEDEXCEPTION);
+ // rename in getGlobalNumberInd()
virtual inline const int * getNumberIndex() const throw (MEDEXCEPTION);
+ virtual int getValIndFromGlobalNumber(const int number) const throw (MEDEXCEPTION);
void blending(SUPPORT * mySupport) throw (MEDEXCEPTION) ;
return _numberOfElements[i];
throw MEDEXCEPTION("Support::getNumberOfElements : Geometric type not found !") ;
}
+//-----------------------------------------------------------------------------
+inline const int * SUPPORT::getNumberOfElements() const throw (MEDEXCEPTION) {
+//-----------------------------------------------------------------------------
+ return _numberOfElements;
+}
//---------------------------------------------------------------------
inline MEDSKYLINEARRAY * SUPPORT::getnumber() const
throw (MEDEXCEPTION)
//---------------------------------------------------------------------
{
+ const char * LOC = "Support::getNumber : " ;
if (_isOnAllElts)
- throw MEDEXCEPTION("Support::getNumber : Not defined, support is on all entity !") ;
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"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("Support::getNumber : GeometricType not found !") ;
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"GeometricType not found !")) ;
}
/*!
throw (MEDEXCEPTION)
//-------------------------------------------------
{
+ SCRUTE(_name);
+ SCRUTE(_numberOfGeometricType);
+ SCRUTE(_numberOfGaussPoint);
+
if (_numberOfGaussPoint!=NULL)
return _numberOfGaussPoint ;
else
return _numberOfGaussPoint[i] ;
throw MEDEXCEPTION("Support::getGlobalNumber : GeometricType not found !") ;
} else
- throw MEDEXCEPTION("Support::getNumberOfGaussPoint : Not defined !") ;
+ return 1;
}
/*! set the attribute _name to Name */
_description=Description;
}
+
+/*! set the meshName if there is ni reference _mesh to Mesh */
+//--------------------------------------
+inline void SUPPORT::setMeshName(const string & meshName)
+//--------------------------------------
+{
+ const char * LOC = "SUPPORT::setMeshName(const string & meshName) : ";
+
+ if (_mesh)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Setting meshName is not possible when an associated mesh is set !")) ;
+
+ _meshName=meshName;
+}
+
/*! set the attribute _isOnAllElts to All */
//------------------------------------------
inline void SUPPORT::setAll(bool All)
//---------------------------------------------------------------------
{
_numberOfGeometricType=NumberOfGeometricType;
- if (_geometricType!=NULL) {
- delete[] _geometricType ;
- _geometricType = NULL ;
- }
- if (_numberOfElements!=NULL) {
- delete[] _numberOfElements ;
- _numberOfElements = NULL ;
- }
- if (_numberOfGaussPoint!=NULL) {
- delete[] _numberOfGaussPoint ;
- _numberOfGaussPoint = NULL ;
- }
+
+ _geometricType.set(0);
+ _numberOfElements.set(0);
+ _numberOfGaussPoint.set(0) ;
}
/*! set the attribute _geometricType to geometricType */
//---------------------------------------------------------------------
{
if (NULL == _geometricType)
- _geometricType=new MED_EN::medGeometryElement[_numberOfGeometricType];
+ _geometricType.set(_numberOfGeometricType);
for (int i=0;i<_numberOfGeometricType;i++)
_geometricType[i] = GeometricType[i];
}
//-----------------------------------------------------------------
{
if (NULL == _numberOfGaussPoint)
- _numberOfGaussPoint=new int[_numberOfGeometricType];
+ _numberOfGaussPoint.set(_numberOfGeometricType);
for (int i=0;i<_numberOfGeometricType;i++)
_numberOfGaussPoint[i] = NumberOfGaussPoint[i];
}
//----------------------------------------------------------
{
if (NULL == _numberOfElements)
- _numberOfElements=new int[_numberOfGeometricType];
- memcpy(_numberOfElements,NumberOfElements,sizeof(int)*_numberOfGeometricType);
+ _numberOfElements.set(_numberOfGeometricType,NumberOfElements);
_totalNumberOfElements = 0 ;
for (int i=0;i<_numberOfGeometricType;i++)
_totalNumberOfElements+=_numberOfElements[i];
--- /dev/null
+#ifndef MEDMEM_TAGS_HXX
+#define MEDMEM_TAGS_HXX
+
+namespace MEDMEM {
+
+struct Gauss {};
+struct NoGauss {};
+struct FullInterlace{};
+struct NoInterlace{};
+
+}
+
+#endif
+
+
#include "MEDMEM_GenDriver.hxx"
#include "MEDMEM_Utilities.hxx"
+#include "MEDMEM_STRING.hxx"
#include "MEDMEM_Exception.hxx"
#include "MEDMEM_Unit.hxx"
-#include "MEDMEM_Array.hxx"
+#include "MEDMEM_nArray.hxx"
+#include "MEDMEM_ArrayConvert.hxx"
#include "MEDMEM_Support.hxx"
#include "MEDMEM_Mesh.hxx"
#include "MEDMEM_CellModel.hxx"
*/
namespace MEDMEM {
-template <class T> class FIELD;
template <class T> class VTK_FIELD_DRIVER : public GENDRIVER
{
protected:
/*!
Constructor.
*/
+ template <class INTERLACING_TAG>
VTK_FIELD_DRIVER():GENDRIVER(),
_ptrField((FIELD<T> *) 0), _fieldName(""),
_fieldNum(MED_INVALID)
/*!
Constructor.
*/
- VTK_FIELD_DRIVER(const string & fileName, FIELD<T> * ptrField)
- : GENDRIVER(fileName,MED_EN::MED_WRONLY),
- _ptrField((FIELD<T> *) ptrField),
- _fieldName(fileName),_fieldNum(MED_INVALID)
+ template <class INTERLACING_TAG>
+ VTK_FIELD_DRIVER(const string & fileName,
+ FIELD<T, INTERLACING_TAG> * ptrField):
+ GENDRIVER(fileName,MED_EN::MED_WRONLY),
+ _ptrField((FIELD<T> *) ptrField),
+ _fieldName(fileName),_fieldNum(MED_INVALID)
{
const char * LOC = "VTK_FIELD_DRIVER::VTK_FIELD_DRIVER(const string & fileName, FIELD<T> * ptrField) ";
BEGIN_OF(LOC);
MED_EN::medEntityMesh entitySupport = supportField->getEntity();
name << nameField << "_" << dt << "_" << it ;
+ if ( _ptrField->getGaussPresence() )
+ throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << "Could not write field "<<_ptrField->getName()<<" which use Gauss Points !" << entitySupport));
+
if (!(supportField->isOnAllElements()))
throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << "Could not write field "<<_ptrField->getName()<<" which is not on all entities of the mesh !" << entitySupport));
else
throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << "Could not write field "<<_ptrField->getName()<<" there are more than 4 components !"));
- const T * value = _ptrField->getValue(MED_EN::MED_NO_INTERLACE) ;
+ // IL EST POSSIBLE D'AVOIR LES DEUX BOUCLES D'ECRITURE POUR EVITER
+ // DE CONVERTIR LE CHAMP DANS LE BON TYPE D'ENTRELACEMENT
+ const T * value;
+ if ( _ptrField->getInterlacingType() == MED_EN::MED_NO_INTERLACE )
+ value = _ptrField->getValue();
+ else {
+ MEDMEM_Array_ * ptrArray = _ptrField->getArray();
+ MEDMEM_Array<T,FullInterlaceNoGaussPolicy> * temp = dynamic_cast<MEDMEM_Array<T,FullInterlaceNoGaussPolicy> * > ( ptrArray );
+ MEDMEM_Array<T,NoInterlaceNoGaussPolicy> * array = ArrayConvert( *temp );
+ value = array->getPtr();
+ }
for (int i=0; i<NomberOfValue; i++)
{
(*_vtkFile) << value[j*NomberOfValue+i] << " " ;
(*_vtkFile) << endl ;
}
+
+ if ( _ptrField->getInterlacingType() == MED_EN::MED_FULL_INTERLACE )
+ delete value;
END_OF(LOC);
}
MED_EN::medEntityMesh entitySupport = supportField->getEntity();
name << nameField << "_" << dt << "_" << it ;
+ if ( _ptrField->getGaussPresence() )
+ throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << "Could not write field "<<_ptrField->getName()<<" which use Gauss Points !" << entitySupport));
+
if (!(supportField->isOnAllElements()))
throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << "Could not write field "<<_ptrField->getName()<<" which is not on all entities of the mesh !" << entitySupport));
else
throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << "Could not write field "<<_ptrField->getName()<<" there are more than 4 components !"));
- const T * value = _ptrField->getValue(MED_EN::MED_NO_INTERLACE) ;
+ const T * value ;
+ if ( _ptrField->getInterlacingType() == MED_EN::MED_NO_INTERLACE )
+ value = _ptrField->getValue();
+ else {
+ MEDMEM_Array_ * ptrArray = _ptrField->getArray();
+ MEDMEM_Array<T,FullInterlaceNoGaussPolicy> * temp = dynamic_cast<MEDMEM_Array<T,FullInterlaceNoGaussPolicy> * > ( ptrArray );
+ MEDMEM_Array<T,NoInterlaceNoGaussPolicy> * array = ArrayConvert( *temp );
+ value = array->getPtr();
+ }
for (int i=0; i<NomberOfValue; i++)
{
(*_vtkFile) << value[j*NomberOfValue+i] << " " ;
(*_vtkFile) << endl ;
}
+
+ if ( _ptrField->getInterlacingType() == MED_EN::MED_FULL_INTERLACE )
+ delete value;
+
END_OF(LOC);
}
}//End namespace MEDMEM
const char * LOC = "VTK_MED_DRIVER::writeField() : ";
BEGIN_OF(LOC);
- int NomberOfValue = myField->getSupport()->getNumberOfElements(MED_ALL_ELEMENTS) ;
- int NomberOfComponents = myField->getNumberOfComponents() ;
+ typedef MEDMEM_ArrayInterface<int,NoInterlace,NoGauss>::Array ArrayIntNo;
+ typedef MEDMEM_ArrayInterface<double,NoInterlace,NoGauss>::Array ArrayDoubleNo;
+
+ int NumberOfValue = myField->getSupport()->getNumberOfElements(MED_ALL_ELEMENTS) ;
+ int NumberOfComponents = myField->getNumberOfComponents() ;
med_type_champ type = myField->getValueType() ;
SCRUTE(name);
{
case MED_INT32 : {
MESSAGE("MED_INT32");
- if (NomberOfComponents==3) {
+ if (NumberOfComponents==3) {
(*_vtkFile) << "VECTORS " << name << " int" << endl ;
- } else if (NomberOfComponents<=4) {
- (*_vtkFile) << "SCALARS " << name << " int " << NomberOfComponents << endl ;
+ } else if (NumberOfComponents<=4) {
+ (*_vtkFile) << "SCALARS " << name << " int " << NumberOfComponents << endl ;
(*_vtkFile) << "LOOKUP_TABLE default" << endl ;
} else {
MESSAGE(LOC << "Could not write field "<<myField->getName()<<" there are more than 4 components !");
return ;
}
-
- //const int * value = ((FIELD<int>*)myField)->getValue(MED_NO_INTERLACE) ;
- const int * value = ((FIELD<int>*)myField)->getValue(MED_NO_INTERLACE) ;
- for (int i=0; i<NomberOfValue; i++) {
- for(int j=0; j<NomberOfComponents; j++)
- (*_vtkFile) << value[j*NomberOfValue+i] << " " ;
+
+ const int * value;
+ ArrayIntNo * myArray;
+ if ( myField->getInterlacingType() == MED_FULL_INTERLACE ) {
+ myArray = ArrayConvert( *( dynamic_cast< FIELD<int,FullInterlace>* >
+ (myField)->getArrayNoGauss()
+ )
+ );
+ value = myArray->getPtr();
+ } else {
+ value = ((FIELD<int>*)myField)->getValue() ;
+ }
+
+ for (int i=0; i<NumberOfValue; i++) {
+ for(int j=0; j<NumberOfComponents; j++)
+ (*_vtkFile) << value[j*NumberOfValue+i] << " " ;
(*_vtkFile) << endl ;
}
+ if ( myField->getInterlacingType() == MED_FULL_INTERLACE )
+ delete[] myArray;
break ;
}
case MED_REEL64 : {
MESSAGE("MED_REEL64");
- if (NomberOfComponents==3) {
+ if (NumberOfComponents==3) {
(*_vtkFile) << "VECTORS " << name << " float" << endl ;
- } else if (NomberOfComponents<=4) {
- (*_vtkFile) << "SCALARS " << name << " float " << NomberOfComponents << endl ;
+ } else if (NumberOfComponents<=4) {
+ (*_vtkFile) << "SCALARS " << name << " float " << NumberOfComponents << endl ;
(*_vtkFile) << "LOOKUP_TABLE default" << endl ;
} else {
MESSAGE(LOC << "Could not write field "<<myField->getName()<<" there are more than 4 components !");
return ;
}
- const double * value = ((FIELD<double>*)myField)->getValue(MED_NO_INTERLACE) ;
- for (int i=0; i<NomberOfValue; i++) {
- for(int j=0; j<NomberOfComponents; j++)
- (*_vtkFile) << value[j*NomberOfValue+i] << " " ;
+
+ const double * value;
+ ArrayDoubleNo * myArray;
+ if ( myField->getInterlacingType() == MED_FULL_INTERLACE ) {
+ myArray = ArrayConvert( *( dynamic_cast< FIELD<double,FullInterlace>* >
+ (myField)->getArrayNoGauss()
+ )
+ );
+ value = myArray->getPtr();
+ } else {
+ value = ((FIELD<double>*)myField)->getValue() ;
+ }
+
+ for (int i=0; i<NumberOfValue; i++) {
+ for(int j=0; j<NumberOfComponents; j++)
+ (*_vtkFile) << value[j*NumberOfValue+i] << " " ;
(*_vtkFile) << endl ;
}
+ if ( myField->getInterlacingType() == MED_FULL_INTERLACE )
+ delete[] myArray;
break ;
}
default : {
typedef long medModeSwitch;
const medModeSwitch MED_FULL_INTERLACE = 0;
const medModeSwitch MED_NO_INTERLACE = 1;
-
+ const medModeSwitch MED_UNDEFINED_INTERLACE = 3;
+
typedef long medConnectivity;
const medConnectivity MED_NODAL = 0;
const medConnectivity MED_DESCENDING = 1;
typedef enum {ASCENDING=7,DESCENDING=77} med_sort_direc;
- typedef enum {MED_REEL64=6, MED_INT32=24,MED_INT64=26} med_type_champ;
+ typedef enum {MED_REEL64=6, MED_INT32=24,MED_INT64=26, MED_UNDEFINED_TYPE=0} med_type_champ;
// #define MED_NBR_GEOMETRIE_MAILLE 15
// #define MED_NBR_GEOMETRIE_FACE 4
--- /dev/null
+#ifndef MEDMEM_ARRAY_HXX
+#define MEDMEM_ARRAY_HXX
+
+#include "MEDMEM_InterlacingPolicy.hxx"
+#include "MEDMEM_IndexCheckingPolicy.hxx"
+
+#include "MEDMEM_PointerOf.hxx"
+#include "MEDMEM_define.hxx"
+
+namespace MEDMEM {
+
+class MEDMEM_Array_ {
+public:
+ //virtual void dummy() {};
+ virtual bool getGaussPresence() const { return false; }
+ virtual MED_EN::medModeSwitch getInterlacingType() const {return MED_EN::MED_UNDEFINED_INTERLACE;}
+ virtual ~MEDMEM_Array_() {}; //Indispensable pour détruire le vrai objet pointé
+};
+
+template < class ARRAY_ELEMENT_TYPE,
+ class INTERLACING_POLICY=FullInterlaceNoGaussPolicy,
+ class CHECKING_POLICY=IndexCheckPolicy >
+class MEDMEM_Array : public INTERLACING_POLICY, public CHECKING_POLICY, public MEDMEM_Array_ {
+
+public :
+
+ typedef ARRAY_ELEMENT_TYPE ElementType;
+ typedef INTERLACING_POLICY InterlacingPolicy;
+ typedef CHECKING_POLICY CheckingPolicy;
+
+public :
+ MEDMEM_Array():_array( ( ElementType *) NULL) {}; //Interdit le constructeur par défaut, peut pas à cause du FIELD
+
+ ~MEDMEM_Array() {
+ // PointerOf s'occupe de la desallocation.
+ };
+
+ // Le mot clé inline permettra d'instancier le constructeur uniquement
+ // s'il est appelé ( ...NoGaussPolicy)
+ // Rem : Le constructeur de la policy demandée est appelé
+ inline MEDMEM_Array(int dim, int nbelem) : InterlacingPolicy(nbelem,dim)
+ {
+ CHECKING_POLICY::checkMoreThanZero("MEDMEM_Array",nbelem);
+ CHECKING_POLICY::checkMoreThanZero("MEDMEM_Array",dim);
+ _array.set(INTERLACING_POLICY::_arraySize);
+ };
+
+ // Le mot clé inline permettra d'instancier le constructeur uniquement
+ // s'il est appelé ( ...NoGaussPolicy)
+ // Rem : Le constructeur de la policy demandée est appelé
+ inline MEDMEM_Array( ElementType * values, int dim, int nbelem,
+ bool shallowCopy=false,
+ bool ownershipOfValues=false) : InterlacingPolicy(nbelem,dim)
+ {
+ CHECKING_POLICY::checkMoreThanZero("MEDMEM_Array",nbelem);
+ CHECKING_POLICY::checkMoreThanZero("MEDMEM_Array",dim);
+ if(shallowCopy)
+
+ if(ownershipOfValues)
+ _array.setShallowAndOwnership((const ElementType *)values);
+ else
+ _array.set((const ElementType*)values);
+
+ else // Cas par défaut
+ _array.set(INTERLACING_POLICY::_arraySize,values);
+
+ }
+
+ // Le mot clé inline permettra d'instancier le constructeur uniquement
+ // s'il est appelé ( ...GaussPolicy)
+ // Rem : Le constructeur de la policy demandée est appelé
+ inline MEDMEM_Array(int dim, int nbelem, int nbtypegeo,
+ const int * const nbelgeoc, const int * const nbgaussgeo)
+ : InterlacingPolicy(nbelem, dim, nbtypegeo, nbelgeoc, nbgaussgeo)
+ {
+ CHECKING_POLICY::checkMoreThanZero("MEDMEM_Array",nbelem);
+ CHECKING_POLICY::checkMoreThanZero("MEDMEM_Array",dim);
+ CHECKING_POLICY::checkMoreThanZero("MEDMEM_Array",nbtypegeo);
+ _array.set(INTERLACING_POLICY::_arraySize);
+ };
+
+
+ // Le mot clé inline permettra d'instancier le constructeur uniquement
+ // s'il est appelé ( ...GaussPolicy)
+ // Rem : Le constructeur de la policy demandée est appelé
+ inline MEDMEM_Array(ElementType * values, int dim, int nbelem, int nbtypegeo,
+ const int * const nbelgeoc, const int * const nbgaussgeo,
+ bool shallowCopy=false,
+ bool ownershipOfValues=false)
+ : InterlacingPolicy(nbelem, dim, nbtypegeo, nbelgeoc, nbgaussgeo)
+ {
+ CHECKING_POLICY::checkMoreThanZero("MEDMEM_Array",nbelem);
+ CHECKING_POLICY::checkMoreThanZero("MEDMEM_Array",dim);
+ CHECKING_POLICY::checkMoreThanZero("MEDMEM_Array",nbtypegeo);
+
+ if(shallowCopy)
+
+ if(ownershipOfValues)
+ _array.setShallowAndOwnership((const ElementType *)values);
+ else
+ _array.set((const ElementType*)values);
+
+ else
+ _array.set(INTERLACING_POLICY::_arraySize,values);
+
+ };
+
+ // Constructeur de recopie pour un MEDMEM_Array avec les mêmes
+ // paramètres template qu'à la construction
+ inline MEDMEM_Array(const MEDMEM_Array & array, bool shallowCopy=false)
+ :InterlacingPolicy(array,shallowCopy)
+ {
+ if (shallowCopy)
+ this->_array.set(array._array); // Le propriétaire reste le ARRAY initial
+ else
+ this->_array.set(INTERLACING_POLICY::_arraySize,array._array);
+ }
+
+
+ // L'utilisation d'une copie superficielle pour l'opérateur d'affectation
+ // ne me parait pas être une bonne ideé : Compatibilité ancienne version MEDARRAY?
+ inline MEDMEM_Array<ElementType,InterlacingPolicy,CheckingPolicy> &
+ operator=( const MEDMEM_Array & array) {
+ if ( this == &array) return *this;
+ BEGIN_OF("MEDMEM_Array operator =");
+ InterlacingPolicy::operator=(array); //Appel des classes de base ?
+
+ this->_array.set(array._array); // Le propriétaire reste le ARRAY initial
+ // verifier l'appel des opérateurs de la policy
+
+ return *this;
+ }
+
+ MED_EN::medModeSwitch getInterlacingType() const {
+ return InterlacingPolicy::getInterlacingType();
+ }
+
+ bool getGaussPresence() const {
+ return InterlacingPolicy::getGaussPresence();
+ }
+
+ ElementType * getPtr() {
+ return _array;
+ }
+
+ void setPtr(ElementType * values, bool shallowCopy=false,
+ bool ownershipOfValues=false) {
+
+ if(shallowCopy)
+
+ if(ownershipOfValues)
+ _array.setShallowAndOwnership((const ElementType *)values);
+ else
+ _array.set((const ElementType*)values);
+
+ else
+ _array.set(INTERLACING_POLICY::_arraySize,values);
+ }
+
+ inline const ElementType * getRow(int i) const {
+ checkInInclusiveRange("MEDMEM_Array",1,INTERLACING_POLICY::_nbelem,i);
+ // Empêche l'utilisation de getRow en mode MED_NO_INTERLACE
+ // Ne devrait pas dépendre de la politique check
+ checkEquality("MEDMEM_Array (Interlace test)",
+ MED_EN::MED_NO_INTERLACE,
+ INTERLACING_POLICY::_interlacing );
+ return &(_array[ INTERLACING_POLICY::getIndex(i,1) ]);
+
+ }
+
+ void setRow(int i,const ElementType * const value) {
+ checkInInclusiveRange("MEDMEM_Array",1,INTERLACING_POLICY::_nbelem,i);
+ // setRow fonctionne
+ // dans les deux modes d'entrelacement.
+
+ for (int j =1; j <= INTERLACING_POLICY::getDim(); j++)
+ for (int k = 1 ; k <= INTERLACING_POLICY::getNbGauss(i); k++)
+ _array[INTERLACING_POLICY::getIndex(i,j,k)] = value[INTERLACING_POLICY::getIndex(1,j,k)];
+ }
+
+ inline const ElementType * getColumn(int j) const {
+ checkInInclusiveRange("MEDMEM_Array",1,INTERLACING_POLICY::_dim,j);
+ checkEquality("MEDMEM_Array (Interlace test)",
+ MED_EN::MED_FULL_INTERLACE, INTERLACING_POLICY::_interlacing );
+ return &(_array[ INTERLACING_POLICY::getIndex(1,j) ]);
+ }
+
+ void setColumn(int j, const ElementType * const value) {
+ checkInInclusiveRange("MEDMEM_Array",1,INTERLACING_POLICY::_dim,j);
+ // setColumn fonctionne
+ // dans les deux modes d'entrelacement.
+
+ for (int i=1; i <= INTERLACING_POLICY::getNbElem(); i++)
+ for (int k = 1 ; k <= INTERLACING_POLICY::getNbGauss(i); k++)
+ _array[INTERLACING_POLICY::getIndex(i,j,k)] = value[INTERLACING_POLICY::getIndex(i,1,k)];
+ }
+
+
+ inline const ElementType & getIJ(int i, int j) const {
+ checkInInclusiveRange("MEDMEM_Array",1,INTERLACING_POLICY::_nbelem,i);
+ checkInInclusiveRange("MEDMEM_Array",1,INTERLACING_POLICY::_dim,j);
+ return _array[ INTERLACING_POLICY::getIndex(i,j) ];
+ }
+
+ inline const ElementType & getIJK(int i, int j, int k ) const {
+ checkInInclusiveRange("MEDMEM_Array",1,INTERLACING_POLICY::_nbelem,i);
+ checkInInclusiveRange("MEDMEM_Array",1,INTERLACING_POLICY::_dim,j);
+ checkInInclusiveRange("MEDMEM_Array",1,INTERLACING_POLICY::getNbGauss(i),k);
+
+ return _array[ INTERLACING_POLICY::getIndex(i,j,k) ];
+ };
+
+ inline void setIJ(int i, int j, const ElementType & value) { //autre signature avec
+ checkInInclusiveRange("MEDMEM_Array",1,INTERLACING_POLICY::_nbelem,i);
+ checkInInclusiveRange("MEDMEM_Array",1,INTERLACING_POLICY::_dim,j);
+
+ _array[ INTERLACING_POLICY::getIndex(i,j) ] = value; // retour ElementType & ?
+ };
+
+ inline void setIJK(int i, int j, int k, const ElementType & value) { //autre signature avec
+ checkInInclusiveRange("MEDMEM_Array",1,INTERLACING_POLICY::_nbelem,i);
+ checkInInclusiveRange("MEDMEM_Array",1,INTERLACING_POLICY::_dim,j);
+ checkInInclusiveRange("MEDMEM_Array",1,INTERLACING_POLICY::getNbGauss(i),k);
+
+ _array[ INTERLACING_POLICY::getIndex(i,j,k) ] = value; // retour ElementType & ?
+ };
+
+
+private:
+
+ PointerOf<ElementType> _array;
+};
+
+} //END NAMESPACE
+#endif
MEDMEM_MedFieldDriver22.hxx \
MEDMEM_MedMedDriver22.hxx \
MEDMEM_MedMeshDriver22.hxx \
-MEDMEM_Utilities.hxx
+MEDMEM_Utilities.hxx \
+MEDMEM_ArrayInterface.hxx \
+MEDMEM_IndexCheckingPolicy.hxx \
+MEDMEM_InterlacingPolicy.hxx \
+MEDMEM_InterlacingTraits.hxx \
+MEDMEM_nArray.hxx \
+MEDMEM_Tags.hxx \
+MEDMEM_FieldConvert.hxx \
+MEDMEM_ArrayConvert.hxx \
+MEDMEM_FieldForward.hxx
# Libraries targets
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_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)
+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_nArray test_MEDMEM_Meshing_poly
LDFLAGS+= -L$(top_builddir)/lib/salome
LDFLAGSFORBIN+= -L$(top_builddir)/lib/salome
}
int main (int argc, char ** argv) {
- int read;
if ((argc !=3) && (argc != 4)) {
cerr << "Usage : " << argv[0]
// cout << value[j]<< " ";
// cout<<endl;
// }
- MEDARRAY<double> * myvalue = myField->getvalue();
+ MEDMEM_Array<double> * myvalue = myField->getArrayNoGauss();
const double * value ;
for (int i=1; i<NumberOf+1; i++) {
value = myvalue->getRow(i) ;
using namespace std;
using namespace MEDMEM;
using namespace MED_EN;
+using namespace DRIVERFACTORY;
int main (int argc, char ** argv) {
cerr << "Usage : " << argv[0]
<< " filenameRoot" << endl;
cerr << " where filenameRoot is a root filename, the program will produce" << endl;
- cerr << " 2 files filenameRoot.med and filenameRoot.vtk" << endl << endl;
+ cerr << " 3 files filenameRoot21.med filenameRoot22.med and filenameRoot.vtk" << endl << endl;
exit(-1);
}
// filename to save the generated MESH
string filenameRoot = argv[1] ;
- string filenameMed = filenameRoot+".med";
+ string filenameMed21 = filenameRoot+"_V21.med";
+ string filenameMed22 = filenameRoot+"_V22.med";
string filenameVtk = filenameRoot+".vtk";
MESHING myMeshing ;
myMeshing.setConnectivity(ConnectivityQua,MED_FACE,MED_QUAD4);
+ int meshDimension = SpaceDimension; // because there 3D cells in the mesh
+ myMeshing.setMeshDimension(meshDimension);
+
// edge part
// not yet implemented : if set, results are unpredictable.
myMeshing.addGroup(myGroup);
}
- // all rigtht, we save it !
+ // all rigtht, we save it in Med 2.1 2.2 and vtk !
+
+ medFileVersion version = getMedFileVersionForWriting();
+ if (version == V22)
+ setMedFileVersionForWriting(V21);
+
+ int idMed21 = myMeshing.addDriver(MED_DRIVER,filenameMed21,myMeshing.getName());
+ myMeshing.write(idMed21) ;
- int idMed = myMeshing.addDriver(MED_DRIVER,filenameMed,myMeshing.getName());
- myMeshing.write(idMed) ;
+ version = getMedFileVersionForWriting();
+ if (version == V21)
+ setMedFileVersionForWriting(V22);
+
+ int idMed22 = myMeshing.addDriver(MED_DRIVER,filenameMed22,myMeshing.getName());
+ myMeshing.write(idMed22) ;
int idVtk = myMeshing.addDriver(VTK_DRIVER,filenameVtk,myMeshing.getName());
myMeshing.write(idVtk) ;
fieldDoubleScalarOnNodes->setComponentDescription(1,"comp1");
fieldDoubleScalarOnNodes->setMEDComponentUnit(1,"unit1");
- fieldDoubleScalarOnNodes->setValueType(MED_REEL64);
-
FIELD<double> * fieldDoubleVectorOnNodes = new FIELD<double>(supportOnNodes,SpaceDimension);
fieldDoubleVectorOnNodes->setName("fieldVectorDoubleNode");
fieldDoubleVectorOnNodes->setIterationNumber(-1);
fieldDoubleVectorOnNodes->setComponentDescription(3,"comp3");
fieldDoubleVectorOnNodes->setMEDComponentUnit(3,"unit3");
- fieldDoubleVectorOnNodes->setValueType(MED_REEL64);
-
FIELD<double> * fieldDoubleScalarOnCells = new FIELD<double>(supportOnCells,1);
fieldDoubleScalarOnCells->setName("fieldScalarDoubleCell");
fieldDoubleScalarOnCells->setIterationNumber(-1);
fieldDoubleScalarOnCells->setComponentDescription(1,"comp1");
fieldDoubleScalarOnCells->setMEDComponentUnit(1,"unit1");
- fieldDoubleScalarOnCells->setValueType(MED_REEL64);
-
FIELD<double> * fieldDoubleVectorOnCells = new FIELD<double>(supportOnCells,SpaceDimension);
fieldDoubleVectorOnCells->setName("fieldVectorrDoubleCell");
fieldDoubleVectorOnCells->setIterationNumber(-1);
fieldDoubleVectorOnCells->setComponentDescription(3,"comp3");
fieldDoubleVectorOnCells->setMEDComponentUnit(3,"unit3");
- fieldDoubleVectorOnCells->setValueType(MED_REEL64);
-
FIELD<int> * fieldIntScalarOnNodes = new FIELD<int>(supportOnNodes,1);
fieldIntScalarOnNodes->setName("fieldScalarIntNode");
fieldIntScalarOnNodes->setIterationNumber(-1);
fieldIntScalarOnNodes->setComponentDescription(1,"comp1");
fieldIntScalarOnNodes->setMEDComponentUnit(1,"unit1");
- fieldIntScalarOnNodes->setValueType(MED_INT32);
-
FIELD<int> * fieldIntVectorOnNodes = new FIELD<int>(supportOnNodes,SpaceDimension);
fieldIntVectorOnNodes->setName("fieldVectorIntNode");
fieldIntVectorOnNodes->setIterationNumber(-1);
fieldIntVectorOnNodes->setComponentDescription(3,"comp3");
fieldIntVectorOnNodes->setMEDComponentUnit(3,"unit3");
- fieldIntVectorOnNodes->setValueType(MED_INT32);
-
FIELD<int> * fieldIntScalarOnCells = new FIELD<int>(supportOnCells,1);
fieldIntScalarOnCells->setName("fieldScalarIntCell");
fieldIntScalarOnCells->setIterationNumber(-1);
fieldIntScalarOnCells->setComponentDescription(1,"comp1");
fieldIntScalarOnCells->setMEDComponentUnit(1,"unit1");
- fieldIntScalarOnCells->setValueType(MED_INT32);
-
FIELD<int> * fieldIntVectorOnCells = new FIELD<int>(supportOnCells,SpaceDimension);
fieldIntVectorOnCells->setName("fieldVectorrIntCell");
fieldIntVectorOnCells->setIterationNumber(-1);
fieldIntVectorOnCells->setComponentDescription(3,"comp3");
fieldIntVectorOnCells->setMEDComponentUnit(3,"unit3");
- fieldIntVectorOnCells->setValueType(MED_INT32);
-
for (int i = 0; i<numberOfNodes; i++)
{
double valueDbl1, valueDbl2, valueDbl3;
fieldIntVectorOnCells->setValueIJ(i+1,3,valueInt3);
}
- idMed = fieldDoubleScalarOnNodes->addDriver(MED_DRIVER,filenameMed,fieldDoubleScalarOnNodes->getName());
- fieldDoubleScalarOnNodes->write(idMed) ;
+ version = getMedFileVersionForWriting();
+ if (version == V22)
+ setMedFileVersionForWriting(V21);
+
+ idMed21 = fieldDoubleScalarOnNodes->addDriver(MED_DRIVER,filenameMed21,fieldDoubleScalarOnNodes->getName());
+ fieldDoubleScalarOnNodes->write(idMed21) ;
+
+ idMed21 = fieldIntScalarOnNodes->addDriver(MED_DRIVER,filenameMed21,fieldIntScalarOnNodes->getName());
+ fieldIntScalarOnNodes->write(idMed21) ;
+
+ idMed21 = fieldDoubleVectorOnNodes->addDriver(MED_DRIVER,filenameMed21,fieldDoubleVectorOnNodes->getName());
+ fieldDoubleVectorOnNodes->write(idMed21) ;
+
+ idMed21 = fieldIntVectorOnNodes->addDriver(MED_DRIVER,filenameMed21,fieldIntVectorOnNodes->getName());
+ fieldIntVectorOnNodes->write(idMed21) ;
+
+ idMed21 = fieldDoubleScalarOnCells->addDriver(MED_DRIVER,filenameMed21,fieldDoubleScalarOnCells->getName());
+ fieldDoubleScalarOnCells->write(idMed21) ;
+
+ idMed21 = fieldIntScalarOnCells->addDriver(MED_DRIVER,filenameMed21,fieldIntScalarOnCells->getName());
+ fieldIntScalarOnCells->write(idMed21) ;
+
+ idMed21 = fieldDoubleVectorOnCells->addDriver(MED_DRIVER,filenameMed21,fieldDoubleVectorOnCells->getName());
+ fieldDoubleVectorOnCells->write(idMed21) ;
+
+ idMed21 = fieldIntVectorOnCells->addDriver(MED_DRIVER,filenameMed21,fieldIntVectorOnCells->getName());
+ fieldIntVectorOnCells->write(idMed21) ;
+
+ version = getMedFileVersionForWriting();
+ if (version == V21)
+ setMedFileVersionForWriting(V22);
+
+ idMed22 = fieldDoubleScalarOnNodes->addDriver(MED_DRIVER,filenameMed22,fieldDoubleScalarOnNodes->getName());
+ fieldDoubleScalarOnNodes->write(idMed22) ;
- idMed = fieldIntScalarOnNodes->addDriver(MED_DRIVER,filenameMed,fieldIntScalarOnNodes->getName());
- fieldIntScalarOnNodes->write(idMed) ;
+ idMed22 = fieldIntScalarOnNodes->addDriver(MED_DRIVER,filenameMed22,fieldIntScalarOnNodes->getName());
+ fieldIntScalarOnNodes->write(idMed22) ;
- idMed = fieldDoubleVectorOnNodes->addDriver(MED_DRIVER,filenameMed,fieldDoubleVectorOnNodes->getName());
- fieldDoubleVectorOnNodes->write(idMed) ;
+ idMed22 = fieldDoubleVectorOnNodes->addDriver(MED_DRIVER,filenameMed22,fieldDoubleVectorOnNodes->getName());
+ fieldDoubleVectorOnNodes->write(idMed22) ;
- idMed = fieldIntVectorOnNodes->addDriver(MED_DRIVER,filenameMed,fieldIntVectorOnNodes->getName());
- fieldIntVectorOnNodes->write(idMed) ;
+ idMed22 = fieldIntVectorOnNodes->addDriver(MED_DRIVER,filenameMed22,fieldIntVectorOnNodes->getName());
+ fieldIntVectorOnNodes->write(idMed22) ;
- idMed = fieldDoubleScalarOnCells->addDriver(MED_DRIVER,filenameMed,fieldDoubleScalarOnCells->getName());
- fieldDoubleScalarOnCells->write(idMed) ;
+ idMed22 = fieldDoubleScalarOnCells->addDriver(MED_DRIVER,filenameMed22,fieldDoubleScalarOnCells->getName());
+ fieldDoubleScalarOnCells->write(idMed22) ;
- idMed = fieldIntScalarOnCells->addDriver(MED_DRIVER,filenameMed,fieldIntScalarOnCells->getName());
- fieldIntScalarOnCells->write(idMed) ;
+ idMed22 = fieldIntScalarOnCells->addDriver(MED_DRIVER,filenameMed22,fieldIntScalarOnCells->getName());
+ fieldIntScalarOnCells->write(idMed22) ;
- idMed = fieldDoubleVectorOnCells->addDriver(MED_DRIVER,filenameMed,fieldDoubleVectorOnCells->getName());
- fieldDoubleVectorOnCells->write(idMed) ;
+ idMed22 = fieldDoubleVectorOnCells->addDriver(MED_DRIVER,filenameMed22,fieldDoubleVectorOnCells->getName());
+ fieldDoubleVectorOnCells->write(idMed22) ;
- idMed = fieldIntVectorOnCells->addDriver(MED_DRIVER,filenameMed,fieldIntVectorOnCells->getName());
- fieldIntVectorOnCells->write(idMed) ;
+ idMed22 = fieldIntVectorOnCells->addDriver(MED_DRIVER,filenameMed22,fieldIntVectorOnCells->getName());
+ fieldIntVectorOnCells->write(idMed22) ;
idVtk = fieldDoubleScalarOnNodes->addDriver(VTK_DRIVER,filenameVtk,fieldDoubleScalarOnNodes->getName());
fieldDoubleScalarOnNodes->writeAppend(idVtk) ;
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 *vals2 = areas->getValue();
const double REFAreaOfPolyg[4] ={1.5, 2, 6, 6.5};
int nbPts=0;
int i;
SUPPORT *sup = new SUPPORT(&myMeshing);
FIELD<double> *vols = myMeshing.getVolume(sup);
- const double *vals = vols->getValue(MED_FULL_INTERLACE);
+ const double *vals = vols->getValue();
const double REFVolOfPolyHedron[3] = {2.333333333333333, 11.66666666666666, 13.83224131414673};
for(i=0;i<3;i++)
if(fabs(REFVolOfPolyHedron[i]-vals[i])<1e-12)
// See http://www.salome-platform.org/
//
#include "MEDMEM_Meshing.hxx"
+#include "MEDMEM_DriverFactory.hxx"
using namespace std;
using namespace MEDMEM;
using namespace MED_EN;
+using namespace DRIVERFACTORY;
int main (int argc, char ** argv)
{
if (argc != 2)
{
cerr << "Usage : " << argv[0]
- << " medfilename" << endl << endl
- << "-> cré un maillage et le sauve dans le fichier medfilename." << endl;
+ << " filenameRoot" << endl << endl
+ << "-> creer un maillage et le sauve dans le fichier filenameRoot22.med sous le format Med Fichier V2.2 car il contient un polygon." << endl;
exit(-1);
}
- string medfilename = argv[1];
+
+ string filenameRoot = argv[1] ;
+
+ string medfilename = filenameRoot + "22.med";
// Creation maillage
//***********************************************************************************
// define coordinates
int SpaceDimension = 2;
- int MeshDimension = SpaceDimension ;
int NumberOfNodes = 11;
double Coordinates[2*11] = {
0.0, 0.0,
1.5, 1.0,
};
- myMeshing.setMeshDimension(MeshDimension) ;
-
myMeshing.setCoordinates(SpaceDimension,NumberOfNodes,Coordinates,"CARTESIAN",MED_FULL_INTERLACE);
string Names[3] = { "X","Y","Z" };
string Units[3] = { "cm","cm","cm" };
myMeshing.setCoordinatesUnits(Units);
- // define conectivities
+ // define conectivities of classic types
// cell part
- const int NumberOfTypes = 3;
- medGeometryElement Types[NumberOfTypes] = {MED_TRIA3,MED_QUAD4,MED_POLYGON};
- const int NumberOfElements[NumberOfTypes] = {1,4,1};
+ const int NumberOfTypes = 2;
+ medGeometryElement Types[NumberOfTypes] = {MED_TRIA3,MED_QUAD4};
+ const int NumberOfElements[NumberOfTypes] = {1,4};
myMeshing.setNumberOfTypes(NumberOfTypes,MED_CELL);
myMeshing.setTypes(Types,MED_CELL);
+ myMeshing.setNumberOfElements(NumberOfElements,MED_CELL);
int ConnectivityTria[1*3]=
{
7,4,1
};
+ myMeshing.setConnectivity(ConnectivityTria,MED_CELL,MED_TRIA3);
int ConnectivityQuad[4*4]=
{
8,9,6,5
};
+ myMeshing.setConnectivity(ConnectivityQuad,MED_CELL,MED_QUAD4);
+
+ int MeshDimension = SpaceDimension ;
+ // because there are 2D cells in the mesh
+
+ myMeshing.setMeshDimension(MeshDimension) ;
+
+ // then define eventuel polygonal cells
+
int ConnectivityPolygon[1*5]=
{
9,11,10,3,6
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.
- */
+ myMeshing.setPolygonsConnectivity(ConnectivityPolygonIndex,ConnectivityPolygon,1,MED_CELL);
+ // Ecriture fichier
- // Ecriture fichier
+ medFileVersion version = getMedFileVersionForWriting();
+ if (version == V21)
+ setMedFileVersionForWriting(V22);
- int idMed = myMeshing.addDriver(MED_DRIVER,medfilename,myMeshing.getName());
- myMeshing.write(idMed) ;
+ int idMed22 = myMeshing.addDriver(MED_DRIVER,medfilename,myMeshing.getName());
+ myMeshing.write(idMed22) ;
// int idVtk = myMeshing.addDriver(VTK_DRIVER,"toto.vtk",myMeshing.getName());
// myMeshing.write(idVtk) ;
--- /dev/null
+#include <stdlib.h>
+#include <iostream>
+#include <stdio.h>
+
+#include "MEDMEM_ArrayInterface.hxx"
+#include "MEDMEM_Field.hxx"
+#include "MEDMEM_IndexCheckingPolicy.hxx"
+#include "MEDMEM_ArrayConvert.hxx"
+
+using namespace MEDMEM;
+
+int main(void) {
+
+ const int mdim = 2;
+ const int nbelem1 = 20;
+
+ // TEST n° 1 FullInterlace et NoGauss
+ std::cout << std::endl;
+ std::cout << "Test de MEDMEM_Array en FullInterlace et NoGauss : " << std::endl;
+ std::cout << std::endl;
+
+ bool test1ok = true;
+ const double * myArray1Ptr = 0;
+ const double array1Ref[] = { 11 , 12 , 21 , 22 , 31 , 32 , 41 , 42 , 51 , 52 ,
+ 61 , 62 , 71 , 72 , 81 , 82 , 91 , 92 , 101 , 102 ,
+ 111 , 112 , 121 , 122 , 131 , 132 , 141 , 142 ,
+ 151 , 152 , 161 , 162 , 171 , 172 , 181 , 182 ,
+ 191 , 192 , 201 , 202 };
+
+ const double array2Ref[] = { 11 , 21 , 31 , 41 , 51 , 61 , 71 , 81 , 91 , 101
+ , 111 , 121 , 131 , 141 , 151 , 161 , 171 , 181
+ , 191 , 201 ,
+ 12 , 22 , 32 , 42 , 52 , 62 , 72 , 82 , 92 , 102
+ , 112 , 122 , 132 , 142 , 152 , 162 , 172 , 182
+ , 192 , 202 };
+
+ MEDMEM_Array<double> myArray1(mdim,nbelem1);
+
+ for (int i =1; i <= nbelem1; i++)
+ for (int j =1; j <= mdim; j++)
+ myArray1.setIJ(i,j,i*10+j);
+
+ myArray1Ptr = myArray1.getPtr();
+ for (int i =0; i < mdim*nbelem1; i++)
+ test1ok = test1ok && ( myArray1Ptr[i] == array1Ref[i] );
+
+ std::cout << "- Egualité de myArray1 et de myArray1Ref : " << test1ok << std::endl ;
+
+ test1ok = true;
+ MEDMEM_Array<double> myArray1bis(myArray1, false);
+ myArray1Ptr = myArray1bis.getPtr();
+ for (int i =0; i < mdim*nbelem1; i++)
+ test1ok = test1ok && ( myArray1Ptr[i] == array1Ref[i] );
+ std::cout << "- Constructeur par recopie en FullInterlace et NoGauss : " << test1ok << std::endl;
+
+ test1ok = true;
+ MEDMEM_Array<double> myArray1ter;
+ myArray1ter = myArray1;
+ myArray1Ptr = myArray1ter.getPtr();
+ for (int i =0; i < mdim*nbelem1; i++)
+ test1ok = test1ok && ( myArray1Ptr[i] == array1Ref[i] );
+ std::cout << "- Opérateur d'affectation en FullInterlace et NoGauss : " << test1ok << std::endl;
+
+
+ test1ok = true;
+ MEDMEM_Array<double> myArray1qua(mdim,nbelem1);
+ myArray1Ptr = myArray1qua.getPtr();
+
+ for (int i =1; i <= nbelem1; i++)
+ myArray1qua.setRow(i,&array1Ref[(i-1)*mdim]);
+
+ for (int i =0; i < mdim*nbelem1; i++)
+ test1ok = test1ok && ( myArray1Ptr[i] == array1Ref[i] );
+ std::cout << "- Méthode setRow en FullInterlace et NoGauss : " << test1ok << std::endl;
+
+ std::cout << "- Test de levée d'exception pour getColumn : ";
+ try {
+ myArray1qua.getColumn(1);
+ }
+ catch (MEDMEM::MEDEXCEPTION &m) {
+ std::cout << m.what() << endl ;
+ }
+
+ test1ok = true;
+ MEDMEM_Array<double,NoInterlaceNoGaussPolicy> * myArray1cin = ArrayConvert(myArray1);
+ myArray1Ptr = myArray1cin->getPtr();
+ int elemno = 0;
+ for (int j=1; j <= mdim; j++)
+ for (int i=1; i <= nbelem1 ; i++ ) {
+ test1ok = test1ok
+ && ( myArray1cin->getIJ(i,j) == array2Ref[elemno] )
+ && ( myArray1Ptr[elemno] == array2Ref[elemno] );
+ elemno++;
+ }
+ std::cout << "- Convertion du mode FullInterlaceNoGaussPolicy au mode NoInterlaceNoGaussPolicy : "
+ << test1ok << std::endl;
+
+
+
+ // TEST n°2 NoInterlace et NoGauss
+ std::cout << std::endl;
+ std::cout << "Test de MEDMEM_Array en NoInterlace et NoGauss : " << std::endl;
+ std::cout << std::endl;
+
+ bool test2ok = true;
+ const double * myArray2Ptr = 0;
+
+ MEDMEM_Array<double,NoInterlaceNoGaussPolicy> myArray2(mdim,nbelem1);
+
+ for (int i =1; i <= nbelem1; i++)
+ for (int j =1; j <= mdim; j++)
+ myArray2.setIJ(i,j,i*10+j);
+
+ myArray2Ptr = myArray2.getPtr();
+ for (int i =0; i < mdim*nbelem1; i++)
+ test2ok = test2ok && ( myArray2Ptr[i] == array2Ref[i] );
+
+ std::cout << "- Egualité de myArray2 et de myArray2Ref : " << test2ok << std::endl ;
+
+ test2ok = true;
+ MEDMEM_Array<double,NoInterlaceNoGaussPolicy> myArray2bis(myArray2, false);
+ myArray2Ptr = myArray2bis.getPtr();
+ for (int i =0; i < mdim*nbelem1; i++)
+ test2ok = test2ok && ( myArray2Ptr[i] == array2Ref[i] );
+ std::cout << "- Constructeur par recopie en NoInterlace et NoGauss : " << test2ok << std::endl;
+
+ test2ok = true;
+ MEDMEM_Array<double,NoInterlaceNoGaussPolicy> myArray2ter;
+ myArray2ter = myArray2;
+ myArray2Ptr = myArray2ter.getPtr();
+ for (int i =0; i < mdim*nbelem1; i++)
+ test2ok = test2ok && ( myArray2Ptr[i] == array2Ref[i] );
+ std::cout << "- Opérateur d'affectation en NoInterlace et NoGauss : " << test2ok << std::endl;
+
+ test2ok = true;
+ MEDMEM_Array<double,NoInterlaceNoGaussPolicy> myArray2qua(mdim,nbelem1);
+ myArray2Ptr = myArray2qua.getPtr();
+
+ for (int j =1; j <= mdim; j++)
+ myArray2qua.setColumn(j,&array2Ref[nbelem1*(j-1)]);
+
+ for (int i =0; i < mdim*nbelem1; i++)
+ test2ok = test2ok && ( myArray2Ptr[i] == array2Ref[i] );
+ std::cout << "- Méthode setColumn en NoInterlace et NoGauss : " << test2ok << std::endl;
+
+ std::cout << "- Test de levée d'exception pour getRow : " ;
+ try {
+ myArray2qua.getRow(1);
+ }
+ catch (MEDMEM::MEDEXCEPTION &m) {
+ std::cout << m.what() << endl ;
+ }
+
+ test2ok = true;
+ MEDMEM_Array<double,FullInterlaceNoGaussPolicy> * myArray2cin = ArrayConvert(myArray2);
+ myArray2Ptr = myArray2cin->getPtr();
+ elemno = 0;
+ for (int i=1; i <= nbelem1 ; i++ )
+ for (int j=1; j <= mdim; j++) {
+ test2ok = test2ok
+ && ( myArray2cin->getIJ(i,j) == array1Ref[elemno] )
+ && ( myArray2Ptr[elemno] == array1Ref[elemno] );
+ elemno++;
+ }
+ std::cout << "- Convertion du mode NoInterlaceNoGaussPolicy au mode FullInterlaceNoGaussPolicy : "
+ << test2ok << std::endl;
+
+
+ // TEST n°3 FullInterlace et Gauss
+ const int nbelem2 = 5;
+ const int nbtypegeo = 2;
+ const int nbelgeoc[nbtypegeo+1] = {1,3,6};
+ const int nbgaussgeo[nbtypegeo+1] = {-1,2,3};
+
+ std::cout << std::endl;
+ std::cout << "Test de MEDMEM_Array en FullInterlace et Gauss : " << std::endl;
+ std::cout << std::endl;
+
+ bool test3ok = true;
+ const double * myArray3Ptr = 0;
+ const double array3Ref[] = {1.11 , 1.12 , 1.21 , 1.22 ,
+ 2.11 , 2.12 , 2.21 , 2.22 ,
+ 13.11 , 13.12 , 13.21 , 13.22 , 13.31 , 13.32 ,
+ 14.11 , 14.12 , 14.21 , 14.22 , 14.31 , 14.32 ,
+ 15.11 , 15.12 , 15.21 , 15.22 , 15.31 , 15.32 };
+
+ const double array4Ref[] = { 1.11 , 1.21 , 2.11 , 2.21,
+ 13.11 , 13.21 , 13.31 , 14.11 , 14.21 , 14.31 ,
+ 15.11 , 15.21 , 15.31 ,
+ 1.12 , 1.22 , 2.12 , 2.22 ,
+ 13.12 , 13.22 , 13.32 , 14.12 , 14.22 , 14.32 ,
+ 15.12 , 15.22 , 15.32 };
+
+ MEDMEM_Array<double,FullInterlaceGaussPolicy> myArray3(mdim,nbelem2,nbtypegeo,nbelgeoc,nbgaussgeo);
+
+ elemno = 1;
+ for (int ntyp=1; ntyp <= nbtypegeo; ntyp++ ) {
+ for (int i=0; i < (nbelgeoc[ntyp]-nbelgeoc[ntyp-1]) ; i++ ) {
+ for (int k=1; k <= nbgaussgeo[ntyp]; k++)
+ for (int j=1; j <= mdim; j++) {
+ myArray3.setIJK(elemno,j,k,elemno+(ntyp-1)*10+0.1*k+0.01*j);
+ }
+ elemno++;
+ }
+ }
+ myArray3Ptr = myArray3.getPtr();
+ for (int i =0; i < myArray3.getArraySize(); i++)
+ test3ok = test3ok && ( myArray3Ptr[i] == array3Ref[i] );
+
+ std::cout << "- Egualité de myArray3 et de myArray3Ref : " << test3ok << std::endl ;
+
+ test3ok = true;
+ MEDMEM_Array<double,FullInterlaceGaussPolicy> myArray3bis(myArray3, false);
+ myArray3Ptr = myArray3bis.getPtr();
+
+ elemno = 0;
+ for (int i=1; i < nbelgeoc[nbtypegeo] ; i++ )
+ for (int k=1; k <= myArray3bis.getNbGauss(i); k++)
+ for (int j=1; j <= mdim; j++) {
+ test3ok = test3ok
+ && ( myArray3bis.getIJK(i,j,k) == array3Ref[elemno] )
+ && ( myArray3Ptr[elemno] == array3Ref[elemno] );
+ elemno++;
+ }
+ std::cout << "- Constructeur par recopie en FullInterlace et Gauss : " << test3ok << std::endl;
+
+ test3ok = true;
+ MEDMEM_Array<double,FullInterlaceGaussPolicy> myArray3ter;
+ myArray3ter = myArray3; //Opérateur d'affectation
+ myArray3Ptr = myArray3ter.getPtr();
+
+ elemno = 0;
+ for (int i=1; i < nbelgeoc[nbtypegeo] ; i++ )
+ for (int k=1; k <= myArray3ter.getNbGauss(i); k++)
+ for (int j=1; j <= mdim; j++) {
+ test3ok = test3ok
+ && ( myArray3ter.getIJK(i,j,k) == array3Ref[elemno] )
+ && ( myArray3Ptr[elemno] == array3Ref[elemno] );
+ elemno++;
+ }
+
+ std::cout << "- Opérateur d'affectation en FullInterlace et Gauss : " << test3ok << std::endl;
+
+
+ test3ok = true;
+ MEDMEM_Array<double,FullInterlaceGaussPolicy> myArray3qua(mdim,nbelem2,
+ nbtypegeo,nbelgeoc,nbgaussgeo);
+ myArray3Ptr = myArray3qua.getPtr();
+
+ int cumul = 0;
+ for (int i =1; i <= nbelem2; i++){
+ myArray3qua.setRow(i,&array3Ref[cumul]);
+ cumul+=myArray3qua.getNbGauss(i)*mdim;
+ };
+
+ for (int i =0; i < myArray3qua.getArraySize(); i++)
+ test3ok = test3ok && ( myArray3Ptr[i] == array3Ref[i] );
+ std::cout << "- Méthode setRow en FullInterlace et Gauss : " << test3ok << std::endl;
+
+ std::cout << "- Test de levée d'exception pour getColumn : " ;
+ try {
+ myArray3qua.getColumn(1);
+ }
+ catch (MEDMEM::MEDEXCEPTION &m) {
+ std::cout << m.what() << endl ;
+ }
+
+ test3ok = true;
+ MEDMEM_Array<double,NoInterlaceGaussPolicy> * myArray3cin = ArrayConvert(myArray3);
+ myArray3Ptr = myArray3cin->getPtr();
+ elemno = 0;
+ for (int j=1; j <= mdim; j++)
+ for (int i=1; i < nbelgeoc[nbtypegeo] ; i++ )
+ for (int k=1; k <= myArray3cin->getNbGauss(i); k++) {
+ test3ok = test3ok
+ && ( myArray3cin->getIJK(i,j,k) == array4Ref[elemno] )
+ && ( myArray3Ptr[elemno] == array4Ref[elemno] );
+ elemno++;
+ }
+ std::cout << "- Convertion du mode FullInterlaceGaussPolicy au mode NoInterlaceGaussPolicy : "
+ << test3ok << std::endl;
+
+
+ // TEST n°4 NoInterlace et Gauss
+ std::cout << std::endl;
+ std::cout << "Test de MEDMEM_Array en NoInterlace et Gauss : " << std::endl;
+ std::cout << std::endl;
+
+ bool test4ok = true;
+ const double * myArray4Ptr = 0;
+
+ MEDMEM_Array<double,NoInterlaceGaussPolicy> myArray4(mdim,nbelem2,nbtypegeo,nbelgeoc,nbgaussgeo);
+
+ elemno = 1;
+ for (int ntyp=1; ntyp <= nbtypegeo; ntyp++ ) {
+ for (int i=0; i < (nbelgeoc[ntyp]-nbelgeoc[ntyp-1]) ; i++ ) {
+ for (int k=1; k <= nbgaussgeo[ntyp]; k++)
+ for (int j=1; j <= mdim; j++) {
+ myArray4.setIJK(elemno,j,k,elemno+(ntyp-1)*10+0.1*k+0.01*j);
+ }
+ elemno++;
+ }
+ }
+ myArray4Ptr = myArray4.getPtr();
+ for (int i =0; i < myArray4.getArraySize(); i++) {
+ test4ok = test4ok && ( myArray4Ptr[i] == array4Ref[i] );
+ }
+ std::cout << "- Egualité de myArray4 et de myArray4Ref : " << test4ok << std::endl ;
+
+ test4ok = true;
+ MEDMEM_Array<double,NoInterlaceGaussPolicy> myArray4bis(myArray4, false);
+ myArray4Ptr = myArray4bis.getPtr();
+
+ elemno = 0;
+ for (int j=1; j <= mdim; j++)
+ for (int i=1; i < nbelgeoc[nbtypegeo] ; i++ )
+ for (int k=1; k <= myArray4bis.getNbGauss(i); k++) {
+ test4ok = test4ok
+ && ( myArray4bis.getIJK(i,j,k) == array4Ref[elemno] )
+ && ( myArray4Ptr[elemno] == array4Ref[elemno] );
+ elemno++;
+ }
+ std::cout << "- Constructeur par recopie en NoInterlace et Gauss : " << test4ok << std::endl;
+
+ test4ok = true;
+ MEDMEM_Array<double,NoInterlaceGaussPolicy> myArray4ter;
+ myArray4ter = myArray4; // Opérateur d'affectation
+ myArray4Ptr = myArray4ter.getPtr();
+
+ elemno = 0;
+ for (int j=1; j <= mdim; j++)
+ for (int i=1; i < nbelgeoc[nbtypegeo] ; i++ )
+ for (int k=1; k <= myArray4ter.getNbGauss(i); k++) {
+ test4ok = test4ok
+ && ( myArray4ter.getIJK(i,j,k) == array4Ref[elemno] )
+ && ( myArray4Ptr[elemno] == array4Ref[elemno] );
+ elemno++;
+ }
+
+ std::cout << "- Opérateur d'affectation en NoInterlace et Gauss : " << test4ok << std::endl;
+
+
+ test4ok = true;
+ MEDMEM_Array<double,NoInterlaceGaussPolicy> myArray4qua(mdim,nbelem2,nbtypegeo,nbelgeoc,nbgaussgeo);
+ myArray4Ptr = myArray4qua.getPtr();
+
+ for (int j =1; j <= mdim; j++)
+ myArray4qua.setColumn(j,&array4Ref[(myArray4qua.getArraySize()/mdim)*(j-1)]);
+
+ for (int i =0; i < myArray4qua.getArraySize(); i++)
+ test4ok = test4ok && ( myArray4Ptr[i] == array4Ref[i] );
+ std::cout << "- Méthode setColumn en NoInterlace et Gauss : " << test4ok << std::endl;
+
+ std::cout << "- Test de levée d'exception pour getRow : " ;
+ try {
+ myArray4qua.getRow(1);
+ }
+ catch (MEDMEM::MEDEXCEPTION &m) {
+ std::cout << m.what() << endl ;
+ }
+
+
+ test4ok = true;
+ MEDMEM_Array<double,FullInterlaceGaussPolicy> * myArray4cin = ArrayConvert(myArray4);
+ //// MEDMEM_Array<double,FullInterlaceGaussPolicy> * myArray4cin;
+ ////ArrayConvert(myArray4,myArray4cin);
+ // typedef MEDMEM_Array<double,FullInterlaceGaussPolicy> MyArray;
+ // MyArray myArray4cin MyArray(myArray4);
+ // myArray4cin.convert(myArray4);
+ // MEDMEM_Array<double,FullInterlaceGaussPolicy> myArray4cin(myArray4);
+ myArray4Ptr = myArray4cin->getPtr();
+ elemno = 0;
+ for (int i=1; i < nbelgeoc[nbtypegeo] ; i++ )
+ for (int k=1; k <= myArray4cin->getNbGauss(i); k++)
+ for (int j=1; j <= mdim; j++) {
+ test4ok = test4ok
+ && ( myArray4cin->getIJK(i,j,k) == array3Ref[elemno] )
+ && ( myArray4cin->getIJK(i,j,k) == myArray3.getIJK(i,j,k) )
+ && ( myArray4Ptr[elemno] == array3Ref[elemno] );
+ elemno++;
+ }
+
+ std::cout << "- Convertion du mode NoInterlaceGaussPolicy au mode FullInterlaceGaussPolicy : "
+ << test4ok << std::endl;
+
+
+ //TEST DES METHODES D'INTERROGATION en NoInterlace et Gauss :
+ // MEDMEM_ArrayInterface<double,NoInterlace,Gauss>::Array & myArray4bis = myField4bis.getArray();
+
+ std::cout << std::endl;
+ std::cout << "Test de la méthode getDim : " << myArray4bis.getDim() << std::endl;
+ std::cout << "Test de la méthode getNbelem : " << myArray4bis.getNbElem() << std::endl;
+ std::cout << "Test de la méthode getArraySize : " << myArray4bis.getArraySize() << std::endl;
+ std::cout << "Test de la méthode getInterlacingType : " << myArray4bis.getInterlacingType() << std::endl;
+
+
+ // Test de levée d'exception si MED_ARRAY compilée avec une politique de checking
+ std::cout << std::endl;
+ std::cout << "Test de levée d'exception pour indice incohérent " << std::endl;
+ try {
+ myArray4.getIJ(0,2); //L'exception génère des blocks perdus (A voir)
+ }
+ catch (MEDMEM::MEDEXCEPTION &m) {
+ std::cout << m.what() << endl ;
+ }
+
+
+
+ return 0;
+
+};
+
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);
+ int lgth=vol1->getValueLength();
+ const double *vals=vol1->getValue();
if(lgth==3)
nbOfPtsForTest++;
const double REFVolOfPolyHedron[3]={2.333333333333333,11.66666666666666,13.83224131414673};
nbOfPtsForTest++;
delete vol1;
FIELD<double>* bary=myMesh->getBarycenter(supOnCell);
- lgth=bary->getValueLength(MED_FULL_INTERLACE);
- vals=bary->getValue(MED_FULL_INTERLACE);
+ lgth=bary->getValueLength();
+ vals=bary->getValue();
if(lgth==9)
nbOfPtsForTest++;
const double REFBaryOfPolyHedron[9]= {5.5, 1, -1, 2, 1.5, 1.0833333333333333, 5.1, 1.6, 0.9};
delete supOnCell;
//area
vol1=myMesh->getArea(fam1);
- lgth=vol1->getValueLength(MED_FULL_INTERLACE);
- vals=vol1->getValue(MED_FULL_INTERLACE);
+ lgth=vol1->getValueLength();
+ vals=vol1->getValue();
if(lgth==3)
nbOfPtsForTest++;
const double REFAreaForPolyg[3]={6,5,6.5};
nbOfPtsForTest++;
vol1=myMesh->getArea(fam2);
- lgth=vol1->getValueLength(MED_FULL_INTERLACE);
- vals=vol1->getValue(MED_FULL_INTERLACE);
+ lgth=vol1->getValueLength();
+ vals=vol1->getValue();
if(lgth==8)
nbOfPtsForTest++;
const double REFAreaForQuad[8]={2.1213203435596424, 2.8284271247461903, 4.4721359549995796, 4.4721359549995796,
delete vol1;
vol1=myMesh->getArea(fam3);
- lgth=vol1->getValueLength(MED_FULL_INTERLACE);
- vals=vol1->getValue(MED_FULL_INTERLACE);
+ lgth=vol1->getValueLength();
+ vals=vol1->getValue();
if(lgth==6)
nbOfPtsForTest++;
const double REFAreaForTri[6]={2.9580398915498081, 1.4142135623730951, 2.2360679774997898,
#include "MEDMEM_MedFieldDriver.hxx"
#include "MEDMEM_Support.hxx"
#include "MEDMEM_Field.hxx"
+#include "MEDMEM_FieldConvert.hxx"
#include "MEDMEM_define.hxx"
using namespace std;
cout << "- Adresse support : " << mySupport << endl;
}
-void affiche_fieldT(FIELD<double> * myField, const SUPPORT * mySupport)
+template <class INTERLACING_TAG>
+void affiche_fieldT(FIELD<double, INTERLACING_TAG> * myField,
+ const SUPPORT * mySupport)
{
affiche_field_((FIELD_ *) myField, mySupport);
int NumberOf = mySupport->getNumberOfElements(MED_ALL_ELEMENTS);
int NumberOfComponents = myField->getNumberOfComponents() ;
- for (int i=1; i<NumberOf+1; i++) {
- const double * value = myField->getValueI(MED_FULL_INTERLACE,i) ;
- for (int j=0; j<NumberOfComponents; j++)
- cout << value[j]<< " ";
- cout<<endl;
+ if ( myField->getInterlacingType() == MED_EN::MED_FULL_INTERLACE ) {
+ for (int i=1; i<NumberOf+1; i++) {
+ const double * value = myField->getRow(i) ;
+ for (int j=0; j<NumberOfComponents; j++)
+ cout << value[j]<< " ";
+ cout<<endl;
+ }
+ }
+ else {
+ for (int j=1; j<NumberOfComponents+1; j++) {
+ const double * value = myField->getColumn(j) ;
+ for (int i=0; i<NumberOf; i++)
+ cout << value[i]<< " ";
+ cout<<endl;
+ }
}
}
SUPPORT * mySupport = new SUPPORT(myMesh,"On_all_cell",MED_CELL);
try {
myField = new FIELD<double>(mySupport,MED_DRIVER,filename,fieldname) ;
- myField->setValueType(MED_REEL64);
} catch (...) {
delete mySupport ;
mySupport = new SUPPORT(myMesh,"On_all_node",MED_NODE);
try {
myField = new FIELD<double>(mySupport,MED_DRIVER,filename,fieldname) ;
- myField->setValueType(MED_REEL64);
} catch (...) {
cout << "Field double " << fieldname << " not found !!!" << endl ;
exit (-1) ;
}
affiche_fieldT(myField, mySupport);
- FIELD<double> * myField2 = new FIELD<double>(* myField);
- delete myField;
+ FIELD<double> * myField2 = new FIELD<double>(* myField); // Contructeur par recopie, sauf SUPPORT
+ delete myField; // Ne détruit pas le Support
affiche_fieldT(myField2, myField2->getSupport());
+ FIELD<double,NoInterlace> * myField3 = FieldConvert( *myField2 );
delete myField2;
+ affiche_fieldT(myField3, myField3->getSupport());
+ FIELD<double,FullInterlace> * myField4 = FieldConvert( *myField3 );
+ delete myField3;
+ affiche_fieldT(myField4, myField4->getSupport());
+ delete myField4;
+
+ FIELD<double,NoInterlace> * myField5 = new FIELD<double,NoInterlace>(mySupport,MED_DRIVER,filename,fieldname) ;
+ affiche_fieldT(myField5, myField5->getSupport());
+ delete myField5;
+
delete mySupport ;
delete myMesh ;
// SUPPORT * mySupport = new SUPPORT(myMesh,"On_all_node",MED_NODE);
SUPPORT * mySupport = new SUPPORT(myMesh,"On_all_cell",MED_EN::MED_CELL);
FIELD<double> * myField = new FIELD<double>() ;
- myField->setValueType(MED_EN::MED_REEL64);
myField->setName(fieldname);
myField->setSupport(mySupport);
//
#include "MEDMEM_GibiMeshDriver.hxx"
#include "MEDMEM_Mesh.hxx"
+#include "MEDMEM_DriverFactory.hxx"
using namespace std;
using namespace MEDMEM;
+using namespace MED_EN;
+using namespace DRIVERFACTORY;
+
int main (int argc, char ** argv)
{
/* process the arguments */
{
cerr << "Usage : " << argv[0]
<< "Gibifilename" << endl << endl
- << "-> lit le fichier gibi filename ,crée 2 fichiers : MED et VTK" << endl;
+ << "-> lit le fichier gibi filename ,crée 3 fichiers : MED 2.1, 2.2 et VTK" << endl;
exit(-1);
}
const string ext=".sauve";
string::size_type pos=gibifilename.find(ext,0);
string basename (gibifilename, 0, pos); // nom sans extension
- string medfile=basename+".med"; // nom fichier med à creer
+ string medfile21=basename+"_V21.med"; // nom fichier med 2.1 à creer
+ string medfile22=basename+"_V22.med"; // nom fichier med 2.2 à creer
string vtkfile=basename+".vtk"; // nom fichier vtk à creer
string::size_type pos1=gibifilename.rfind('/');
string meshName (gibifilename,pos1+1,pos-pos1-1); // get rid of directory & extension
cout << "Impression de MESH : " << endl;
cout << *myMesh;
- // creation d'un fichier med
- cout << "creation d'un fichier med : " << endl;
- int idMed = myMesh->addDriver(MED_DRIVER, medfile, meshName);
- myMesh->write(idMed) ;
+ // creation des fichiers med 2.1 et 2.2
+ medFileVersion version = getMedFileVersionForWriting();
+ if (version == V22)
+ setMedFileVersionForWriting(V21);
+
+ cout << "creation du fichier med 21 : " << endl;
+ int idMed21 = myMesh->addDriver(MED_DRIVER, medfile21, meshName);
+ myMesh->write(idMed21) ;
+
+ version = getMedFileVersionForWriting();
+ if (version == V21)
+ setMedFileVersionForWriting(V22);
+
+ cout << "creation du fichier med 22 : " << endl;
+ int idMed22 = myMesh->addDriver(MED_DRIVER, medfile22, meshName);
+ myMesh->write(idMed22) ;
// creation d'un fichier vtk
cout << "creation d'un fichier vtk : " << endl;
myMesh->write(idVtk) ;
delete myMesh;
- // remontée mémoire du fichier med
- myMesh= new MESH(MED_DRIVER,medfile,meshName);
+ // remontée mémoire du fichier med 21
+ myMesh= new MESH(MED_DRIVER,medfile21,meshName);
//myMesh= new MESH() ;
//myMesh->setName(meshName);
//MED_MESH_RDONLY_DRIVER myMeshDriver(medfile,myMesh) ;
//cout << *myMesh;
delete myMesh;
+ // remontée mémoire du fichier med 22
+ myMesh= new MESH(MED_DRIVER,medfile22,meshName);
+ delete myMesh;
}
int NumberOfComponents = myField->getNumberOfComponents() ;
for (int i=1; i<NumberOf+1; i++) {
- const double * value = myField->getValueI(MED_FULL_INTERLACE,i) ;
+ const double * value = myField->getRow(i) ;
for (int j=0; j<NumberOfComponents; j++)
cout << value[j]<< " ";
cout<<endl;
cout << "Norme euclidienne : " << myField->norm2() << endl;
cout << "Norme max : " << myField->normMax() << endl;
try
- {
+ {
for (int i=1; i<=myField->getNumberOfComponents(); ++i)
- cout << "Norme L2 - comp=" << i << " : " << myField->normL2(i) << endl;
+ cout << "Norme L2 - comp=" << i << " : " << myField->normL2(i) << endl;
cout << "Norme L2 : " << myField->normL2() << endl;
for (int i=1; i<=myField->getNumberOfComponents(); ++i)
- cout << "Norme L1 - comp=" << i << " : " << myField->normL1(i) << endl;
+ cout << "Norme L1 - comp=" << i << " : " << myField->normL1(i) << endl;
cout << "Norme L1 : " << myField->normL1() << endl;
- }
+ }
catch (MEDEXCEPTION &ex)
- {
+ {
cout << ex.what() << endl;
- }
+ }
}
void affiche_valeur_field(const FIELD<double>& f)
{
- const int tailleMax=12;
- const int taille=f.getNumberOfValues()*f.getNumberOfComponents();
- const double * value=f.getValue(f.getvalue()->getMode());
- if(taille<=tailleMax)
- for(int i=0;i<taille;i++)
- cout << setw(3) << value[i] << " ";
- else
+ const int tailleMax=12;
+ const int taille=f.getNumberOfValues()*f.getNumberOfComponents();
+ const double * value=f.getValue();
+ if(taille<=tailleMax)
+ for(int i=0;i<taille;i++)
+ cout << setw(3) << value[i] << " ";
+ else
{
- for(int i=0; i<tailleMax/2; ++i)
- cout << setw(3) << value[i] << " ";
- cout << " ... ";
- for(int i=taille-tailleMax/2 ; i<taille; ++i)
- cout << setw(3) << value[i] << " ";
+ for(int i=0; i<tailleMax/2; ++i)
+ cout << setw(3) << value[i] << " ";
+ cout << " ... ";
+ for(int i=taille-tailleMax/2 ; i<taille; ++i)
+ cout << setw(3) << value[i] << " ";
}
}
-void checkOperation(const FIELD<double>& resOp, const FIELD<double>& f1, const FIELD<double>& f2,
- char Op, const char* intitule, int verbose)
+void checkOperation(const FIELD<double>& resOp, const FIELD<double>& f1, const FIELD<double>& f2,
+ char Op, const char* intitule, int verbose)
{
- int res=0;
-
- // get pointers to inside arrays of values
- medModeSwitch mode=resOp.getvalue()->getMode();
- const double * value=resOp.getValue(mode);
- const double * value1=f1.getValue(mode);
- const double * value2=f2.getValue(mode);
- const int size=f1.getNumberOfValues()*f1.getNumberOfComponents(); // size of field1
-
- // check size compatibility
- if(f1.getNumberOfValues()*f1.getNumberOfComponents()!=size ||
- resOp.getNumberOfValues()*resOp.getNumberOfComponents()!=size)
- res=1;
-
- if(!res)
+ int res=0;
+
+ // get pointers to inside arrays of values
+ const double * value=resOp.getValue();
+ const double * value1=f1.getValue();
+ const double * value2=f2.getValue();
+ const int size=f1.getNumberOfValues()*f1.getNumberOfComponents(); // size of field1
+
+ // check size compatibility
+ if(f1.getNumberOfValues()*f1.getNumberOfComponents()!=size ||
+ resOp.getNumberOfValues()*resOp.getNumberOfComponents()!=size)
+ res=1;
+
+ if(!res)
{
- switch(Op)
+ switch(Op)
{
- case '+':
- for(int i=0; i!=size; ++i)
- if(value[i]!=value1[i]+value2[i])
- res+=1;
- break;
- case '-':
- for(int i=0; i!=size; ++i)
- if(value[i]!=value1[i]-value2[i])
- res+=1;
- break;
- case 'n':
- for(int i=0; i!=size; ++i)
- if(value[i]!=-value1[i])
- res+=1;
- break;
- case '*':
- for(int i=0; i!=size; ++i)
- if(value[i]!=value1[i]*value2[i])
- res+=1;
- break;
- case '/':
- for(int i=0; i!=size; ++i)
- if(value2[i]!=0.0)
- if(value[i]!=value1[i]/value2[i])
- res+=1;
- break;
- case '=':
- for(int i=0; i!=size; ++i)
- if(value[i]!=value2[i])
- res+=1;
- break;
- case 'a':
- for(int i=0; i!=size; ++i)
- if(value[i]!=value1[i]+value2[i]*value2[i])
- res+=1;
- break;
+ case '+':
+ for(int i=0; i!=size; ++i)
+ if(value[i]!=value1[i]+value2[i])
+ res+=1;
+ break;
+ case '-':
+ for(int i=0; i!=size; ++i)
+ if(value[i]!=value1[i]-value2[i])
+ res+=1;
+ break;
+ case 'n':
+ for(int i=0; i!=size; ++i)
+ if(value[i]!=-value1[i])
+ res+=1;
+ break;
+ case '*':
+ for(int i=0; i!=size; ++i)
+ if(value[i]!=value1[i]*value2[i])
+ res+=1;
+ break;
+ case '/':
+ for(int i=0; i!=size; ++i)
+ if(value2[i]!=0.0)
+ if(value[i]!=value1[i]/value2[i])
+ res+=1;
+ break;
+ case '=':
+ for(int i=0; i!=size; ++i)
+ if(value[i]!=value2[i])
+ res+=1;
+ break;
+ case 'a':
+ for(int i=0; i!=size; ++i)
+ if(value[i]!=value1[i]+value2[i]*value2[i])
+ res+=1;
+ break;
}
-
+
}
- if (verbose)
- cout << endl << intitule << "[";
- cout << res;
- if (verbose)
+ if (verbose)
+ cout << endl << intitule << "[";
+ cout << res;
+ if (verbose)
{
- cout << "] : ";
- affiche_valeur_field(resOp);
+ cout << "] : ";
+ affiche_valeur_field(resOp);
}
- else
- cout << endl;
+ else
+ cout << endl;
}
int main (int argc, char ** argv)
{
- /* process the arguments */
- int verbose=0; // verbose=1 if the verbose mode is selected
- int res=0; // unit test result
- int ntest=0; // numéro du test
+ /* process the arguments */
+ int verbose=0; // verbose=1 if the verbose mode is selected
+ int res=0; // unit test result
+ int ntest=0; // numÃ\83©ro du test
- if (argc>=2 && !strcmp(argv[1],"-v"))
- verbose=1;
+ if (argc>=2 && !strcmp(argv[1],"-v"))
+ verbose=1;
- if (argc != 4+verbose)
+ if (argc != 4+verbose)
{
- cerr << "Usage : " << argv[0]
- << "[-v] filename meshname fieldname" << endl << endl
- << "-> tests field's operations on the FIELD<double> fieldname" << endl
- << "Use optional option -v to select verbose mode" << endl;
- exit(-1);
+ cerr << "Usage : " << argv[0]
+ << "[-v] filename meshname fieldname" << endl << endl
+ << "-> tests field's operations on the FIELD<double> fieldname" << endl
+ << "Use optional option -v to select verbose mode" << endl;
+ exit(-1);
}
+ string filename = argv[verbose+1];
+ string meshname = argv[verbose+2];// Maintenant plus très utile
+ string fieldname = argv[verbose+3];
- string filename = argv[verbose+1];
- string meshname = argv[verbose+2];
- string fieldname = argv[verbose+3];
+ /* read MESH, SUPPORT and FIELDS */
+ //MESH * myMesh = new MESH(MED_DRIVER,filename,meshname);
+
+ MESH * myMesh;
+ const SUPPORT * mySupport;
+ FIELD<double> * myField1;
+
+ try {
+
+ myField1 = new FIELD<double>(MED_DRIVER,filename,fieldname) ;
+ mySupport = myField1->getSupport();
+ myMesh = new MESH(MED_DRIVER,filename,mySupport->getMeshName());
+ mySupport->setMesh(myMesh);
- /* read MESH, SUPPORT and FIELDS */
- MESH * myMesh = new MESH(MED_DRIVER,filename,meshname);
- SUPPORT * mySupport;
- FIELD<double> * myField1;
- try
- {
- mySupport = new SUPPORT(myMesh,"Support on all Cells",MED_CELL);
- myField1 = new FIELD<double>(mySupport,MED_DRIVER,filename,fieldname) ;
- myField1->setValueType(MED_REEL64);
- }
- catch (MEDEXCEPTION &ex)
- {
- // field wasn't found on cells, try on nodes
- delete mySupport ;
- mySupport = new SUPPORT(myMesh,"On_all_node",MED_NODE);
- try
- {
- myField1 = new FIELD<double>(mySupport,MED_DRIVER,filename,fieldname) ;
- }
- catch (...)
- {
- cout << "Field double " << fieldname << " not found !!!" << endl ;
- exit (-1) ;
- }
- }
FIELD<double> * myField2 = new FIELD<double>(* myField1);
FIELD<double> myFieldPlus = *myField1 + *myField2;
- if(verbose)
- {
- // affichage des nprmes,des champs f1, f2, scalarProduct(f1,f2) et f1+f2
- FIELD<double>* myField1_vol=myField1->getSupport()->getMesh()->getVolume(myField1->getSupport());
- cout << "Norme L2 calculée en fournissant le volume : " << myField1->normL2(myField1_vol) << endl;
- for (int i=1; i<=myField1->getNumberOfComponents(); ++i)
- cout << "Norme L2 - comp=" << i << " : " << myField1->normL2(i,myField1_vol) << endl;
- cout << "Norme L1 calculée en fournissant le volume : " << myField1->normL1(myField1_vol) << endl;
- for (int i=1; i<=myField1->getNumberOfComponents(); ++i)
- cout << "Norme L1 - comp=" << i << " : " << myField1->normL1(i,myField1_vol) << endl;
- delete myField1_vol;
-
- affiche_fieldT(myField1, myField1->getSupport());
- cout << endl << string(60,'-') << endl;
- affiche_fieldT(myField2, myField2->getSupport());
- cout << endl << string(60,'-') << endl;
-
- FIELD<double>* myFieldDot = FIELD<double>::scalarProduct(*myField1, *myField2);
- affiche_fieldT(myFieldDot, myFieldDot->getSupport());
- delete myFieldDot;
- cout << endl << string(60,'-') << endl ;
- affiche_fieldT(&myFieldPlus, myFieldPlus.getSupport());
- cout << endl << string(60,'-') << endl << endl ;
+ if(verbose) {
+ // affichage des nprmes,des champs f1, f2, scalarProduct(f1,f2) et f1+f2
+ FIELD<double>* myField1_vol=myField1->getSupport()->getMesh()->getVolume(myField1->getSupport());
+ cout << "Norme L2 calculee en fournissant le volume : " << myField1->normL2(myField1_vol) << endl;
+ for (int i=1; i<=myField1->getNumberOfComponents(); ++i)
+ cout << "Norme L2 - comp=" << i << " : " << myField1->normL2(i,myField1_vol) << endl;
+ cout << "Norme L1 calculee en fournissant le volume : " << myField1->normL1(myField1_vol) << endl;
+ for (int i=1; i<=myField1->getNumberOfComponents(); ++i)
+ cout << "Norme L1 - comp=" << i << " : " << myField1->normL1(i,myField1_vol) << endl;
+ delete myField1_vol;
+
+ affiche_fieldT(myField1, myField1->getSupport());
+ cout << endl << string(60,'-') << endl;
+ affiche_fieldT(myField2, myField2->getSupport());
+ cout << endl << string(60,'-') << endl;
+
+ FIELD<double>* myFieldDot = FIELD<double>::scalarProduct(*myField1, *myField2);
+ affiche_fieldT(myFieldDot, myFieldDot->getSupport());
+ delete myFieldDot;
+ cout << endl << string(60,'-') << endl ;
+ affiche_fieldT(&myFieldPlus, myFieldPlus.getSupport());
+ cout << endl << string(60,'-') << endl << endl ;
}
- // Verifie plusieurs cas de non compatibilité
+ // Verifie plusieurs cas de non compatibilitÃ\83©
// test 1 : Unites non compatibles
const string unite=myField1->getMEDComponentUnit(1);
myField1->setMEDComponentUnit(1,string("UniteBidon"));
ntest++; res=1;
try
- {
+ {
FIELD<double> myFieldPlus = *myField1 + *myField2;
- if(verbose)
- {
+ if(verbose)
+ {
cout << endl << string(60,'-') << endl;
- cout<< "Test " << ntest << " : incompatibilité d'unité : " << endl << endl;
- }
- }
+ cout<< "Test " << ntest << " : incompatibilitÃ\83© d'unitÃ\83© : " << endl << endl;
+ }
+ }
catch (MEDEXCEPTION & ex)
- {
+ {
res=0;
- if(verbose)
- cout << ex.what() << endl;
+ if(verbose)
+ cout << ex.what() << endl;
myField1->setMEDComponentUnit(1,unite);
- }
+ }
cout << res << endl;
// test 2 : numberOfComponents non compatibles
myField1->setNumberOfComponents(13);
ntest++; res=1;
try
- {
- if(verbose)
- {
+ {
+ if(verbose)
+ {
cout << endl << string(60,'-') << endl;
- cout<< "Test " << ntest << " : incompatibilité nombre de composantes : " << endl << endl;
- }
+ cout<< "Test " << ntest << " : incompatibilitÃ\83© nombre de composantes : " << endl << endl;
+ }
FIELD<double> myFieldPlus = *myField1 + *myField2;
- }
+ }
catch (MEDEXCEPTION & ex)
- {
+ {
res=0;
if(verbose)
- cout << endl << ex.what() << endl << endl;
+ cout << endl << ex.what() << endl << endl;
myField1->setNumberOfComponents(numberOfComponents);
- }
+ }
cout << res << endl;
// test 3 : supports non compatibles
myField1->setSupport(&mySupport2);
ntest++; res=1;
try
- {
+ {
if(verbose)
- cout << endl << string(60,'-') << endl << "Test " << ntest << " : incompatibilité des supports" << endl << endl;
+ cout << endl << string(60,'-') << endl << "Test " << ntest << " : incompatibilitÃ\83© des supports" << endl << endl;
FIELD<double> myFieldPlus = *myField1 + *myField2;
- }
+ }
catch (MEDEXCEPTION & ex)
- {
+ {
res=0;
if(verbose)
- cout << ex.what() << endl << endl << endl;
+ cout << ex.what() << endl << endl << endl;
myField1->setSupport(mySupport);
- }
+ }
cout << res << endl;
// test 4 : champs de taille nulle
myField2->setNumberOfComponents(0);
ntest++; res=2;
try
- {
+ {
if(verbose)
- cout<< endl << string(60,'-') << endl << "Test " << ntest << " : incompatibilité taille nulle" << endl << endl;
+ cout<< endl << string(60,'-') << endl << "Test " << ntest << " : incompatibilitÃ\83© taille nulle" << endl << endl;
FIELD<double> myFieldPlus = *myField1 + *myField2;
- }
+ }
catch (MEDEXCEPTION & ex)
- {
+ {
--res;
- if(verbose)
- cout << ex.what() << endl << endl ;
- }
+ if(verbose)
+ cout << ex.what() << endl << endl ;
+ }
try
- {
+ {
double mynorm2=myField1->norm2();
- }
+ }
catch (MEDEXCEPTION & ex)
- {
+ {
--res;
- if(verbose)
- cout << ex.what() << endl << endl ;
+ if(verbose)
+ cout << ex.what() << endl << endl ;
myField1->setNumberOfComponents(numberOfComponents);
myField2->setNumberOfComponents(numberOfComponents);
- }
+ }
cout << res << endl;
- // Apres toutes ces exceptions, des opérations qui marchent!
+ // Apres toutes ces exceptions, des opÃ\83©rations qui marchent!
if(verbose)
- {
- cout<< endl << string(60,'-') << endl << "Test " << ++ntest << " : Operations arithmétiques" << endl;
+ {
+ cout<< endl << string(60,'-') << endl << "Test " << ++ntest << " : Operations arithmÃ\83©tiques" << endl;
cout << endl << " f1 : "; affiche_valeur_field(*myField1);
cout << endl << " f2 : "; affiche_valeur_field(*myField2);
cout << endl << string(140,'-');
- }
+ }
- // Test du résultats de certaines opérations et affichage si verbose
+ // Test du rÃ\83©sultats de certaines opÃ\83©rations et affichage si verbose
checkOperation(myFieldPlus, *myField1, *myField2, '+', " f1+f2 ", verbose);
FIELD<double>* myFieldadd = FIELD<double>::add(*myField1, *myField2);
checkOperation( *myFieldadd, *myField1, *myField2, '+', "add(f1,f2)", verbose);
delete myField2;
delete mySupport ;
delete myMesh ;
- return 0;
+
+ }
+ catch ( MEDEXCEPTION & ex) {
+ cout << ex.what() << endl;
+ }
+
+ return 0;
}
int NumberOfComponents = myField->getNumberOfComponents() ;
for (int i=1; i<NumberOf+1; i++) {
- const int * value = myField->getValueI(MED_FULL_INTERLACE,i) ;
+ const int * value = myField->getRow(i) ;
for (int j=0; j<NumberOfComponents; j++)
cout << value[j]<< " ";
cout<<endl;
void affiche_valeur_field(const char * intitule, const int taille, const FIELD<int>& f)
{
- const int * value=f.getValue(f.getvalue()->getMode());
+ const int * value=f.getValue();
std::cout << endl << intitule;
for(int i=0;i<taille;i++)
std::cout << setw(3) << value[i] << " ";
<< " filename meshname fieldname" << endl << endl;
exit(-1);
}
-
string filename = argv[1] ;
string meshname = argv[2] ;
string fieldname = argv[3];
/* read MESH, SUPPORT and FIELD */
mySupport = new SUPPORT(myMesh,"Support on all Cells",MED_CELL);
myField1 = new FIELD<int>(mySupport,MED_DRIVER,filename,fieldname) ;
- myField1->setValueType(MED_REEL64);
}
catch (MEDEXCEPTION &ex)
{
try
{
myField1 = new FIELD<int>(mySupport,MED_DRIVER,filename,fieldname) ;
- myField1->setValueType(MED_INT32);
myField1->setValueIJ(10,1,-9); // pour tester les normes max avec une valeur negative
}
catch (...)
std::cout << endl << string(60,'-') << endl << " - f1 :" << endl << endl;
affiche_fieldT(&myFieldNeg, myFieldNeg.getSupport());
- medModeSwitch mode=myFieldPlus.getvalue()->getMode();
int size=myFieldPlus.getNumberOfValues()*myFieldPlus.getNumberOfComponents();
std::cout << endl << string(60,'-') << endl << "Tests opérations :" << endl << endl;
-// Copyright (C) 2005 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.salome-platform.org/
-//
//=============================================================================
// File : MEDMEM_Family_i.cxx
// Project : SALOME
{
int nbAttribute=_family->getNumberOfAttributes();
myseq->length(nbAttribute);
- int * identifiers=_family->getAttributesIdentifiers();
+ const int * identifiers=_family->getAttributesIdentifiers();
for (int i=0;i<nbAttribute;i++)
{
myseq[i]=identifiers[i];
{
int nbAttribute=_family->getNumberOfAttributes();
myseq->length(nbAttribute);
- int * values=_family->getAttributesValues();
+ const int * values=_family->getAttributesValues();
for (int i=0;i<nbAttribute;i++)
{
myseq[i]=values[i];
{
int nbAttribute=_family->getNumberOfAttributes();
myseq->length(nbAttribute);
- string * descattribute=_family->getAttributesDescriptions();
+ const string * descattribute=_family->getAttributesDescriptions();
for (int i=0;i<nbAttribute;i++)
{
myseq[i]=CORBA::string_dup(descattribute[i].c_str());
{
int nbGroups=_family->getNumberOfGroups();
myseq->length(nbGroups);
- string * descGroups=_family->getGroupsNames();
+ const string * descGroups=_family->getGroupsNames();
for (int i=0;i<nbGroups;i++)
{
myseq[i]=CORBA::string_dup(descGroups[i].c_str());
+++ /dev/null
-// Copyright (C) 2005 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.salome-platform.org/
-//
-//=============================================================================
-// File : MEDMEM_Fielddouble_i.hxx
-// Project : SALOME
-// Author : EDF
-// Copyright : EDF 2002
-// $Header: /export/home/PAL/MED_SRC/src/MEDMEM_I/MEDMEM_Fielddouble_i.hxx
-//=============================================================================
-
-#include "MEDMEM_FieldDouble_i.hxx"
-#include "utilities.h"
-#include "MEDMEM_convert.hxx"
-#include "SenderFactory.hxx"
-#include "MultiCommException.hxx"
-using namespace MEDMEM;
-
-//=============================================================================
-/*!
- * Default constructor
- */
-//=============================================================================
-FIELDDOUBLE_i::FIELDDOUBLE_i(): FIELD_i()
-{
- BEGIN_OF("Default Constructor FIELDDOUBLE_i");
- END_OF("Default Constructor FIELDDOUBLE_i");
-}
-//=============================================================================
-/*!
- * Destructor
- */
-//=============================================================================
-FIELDDOUBLE_i::~FIELDDOUBLE_i()
-{
- BEGIN_OF("Default Destructor FIELDDOUBLE_i");
- END_OF("Default Destructor FIELDDOUBLE_i");
-}
-//=============================================================================
-/*!
- * Constructor par recopie
- */
-//=============================================================================
-FIELDDOUBLE_i::FIELDDOUBLE_i(FIELDDOUBLE_i & fd):
- FIELD_i(fd)
-{
- BEGIN_OF("Default Constructor FIELDDOUBLE_i");
- END_OF("Default Constructor FIELDDOUBLE_i");
-}
-//=============================================================================
-/*!
- * Default constructor
- */
-//=============================================================================
-FIELDDOUBLE_i::FIELDDOUBLE_i(::FIELD<double> * const f, bool ownCppPtr):
- FIELD_i(f,ownCppPtr)
-{
- BEGIN_OF("Constructor FIELDDOUBLE_i");
- END_OF(" Constructor FIELDDOUBLE_i");
-}
-
-//=============================================================================
-/*!
- * CORBA: Accessor for Field's values
-*/
-//=============================================================================
-
-SALOME_MED::double_array* FIELDDOUBLE_i::getValue( SALOME_MED::medModeSwitch mode )
-throw (SALOME::SALOME_Exception)
-{
- if (_fieldTptr==NULL)
- THROW_SALOME_CORBA_EXCEPTION("No associated Field", \
- SALOME::INTERNAL_ERROR);
- SALOME_MED::double_array_var myseq = new SALOME_MED::double_array;
- try
- {
- medModeSwitch modemed=convertIdlModeToMedMode(mode);
-// ::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);
- myseq->length(nbval);
- for (int i=0; i<nbval; i++)
- {
- myseq[i]=values[i];
- };
- }
- catch (MEDEXCEPTION &ex)
- {
- MESSAGE("Unable to acces Field ");
- THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
- }
- return myseq._retn();
-}
-//=============================================================================
-/*!
- * CORBA: Accessor for Field's values
-*/
-//=============================================================================
-
-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::SenderDouble_ptr ret;
- try
- {
- medModeSwitch modemed=convertIdlModeToMedMode(mode);
- // ::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);
- }
- catch (MEDEXCEPTION &ex)
- {
- MESSAGE("Unable to acces Field ");
- THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
- }
- return ret;
-}
+++ /dev/null
-// Copyright (C) 2005 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.salome-platform.org/
-//
-//=============================================================================
-// File : MEDMEM_Fielddouble_i.hxx
-// Project : SALOME
-// Author : EDF
-// Copyright : EDF 2002
-// $Header: /export/home/PAL/MED_SRC/src/MEDMEM_I/MEDMEM_Fielddouble_i.hxx
-//=============================================================================
-
-#ifndef MED_FIELDDOUBLE_I_HXX_
-#define MED_FIELDDOUBLE_I_HXX_
-
-#include <SALOMEconfig.h>
-
-#include CORBA_SERVER_HEADER(MED)
-
-#include "MEDMEM_Field_i.hxx"
-
-#include "MEDMEM_Field.hxx"
-
-namespace MEDMEM {
- class FIELDDOUBLE_i: public POA_SALOME_MED::FIELDDOUBLE,
- public FIELD_i,
- public SALOMEMultiComm
-{
-private:
-
-public:
- FIELDDOUBLE_i();
- ~FIELDDOUBLE_i();
- FIELDDOUBLE_i(MEDMEM::FIELD<double> * const f, bool ownCppPtr=false);
- FIELDDOUBLE_i(FIELDDOUBLE_i & f);
-
- SALOME_MED::double_array * getValue (SALOME_MED::medModeSwitch mode )
- throw (SALOME::SALOME_Exception);
- SALOME::SenderDouble_ptr getSenderForValue(SALOME_MED::medModeSwitch mode)
- throw (SALOME::SALOME_Exception);
-};
-}
-
-
-#endif /* MED_FIELDDOUBLE_I_HXX_ */
+++ /dev/null
-// Copyright (C) 2005 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.salome-platform.org/
-//
-//=============================================================================
-// File : MEDMEM_Fieldint_i.hxx
-// Project : SALOME
-// Author : EDF
-// Copyright : EDF 2002
-// $Header: /export/home/PAL/MED_SRC/src/MEDMEM_I/MEDMEM_Fieldint_i.hxx
-//=============================================================================
-
-#include "utilities.h"
-#include "MEDMEM_FieldInt_i.hxx"
-#include "MEDMEM_convert.hxx"
-#include "SenderFactory.hxx"
-#include "MultiCommException.hxx"
-using namespace MEDMEM;
-
-//=============================================================================
-/*!
- * Default constructor
- */
-//=============================================================================
-FIELDINT_i::FIELDINT_i(): FIELD_i()
-{
- BEGIN_OF("Default Constructor FIELDINT_i");
- END_OF("Default Constructor FIELDINT_i");
-}
-//=============================================================================
-/*!
- * Destructor
- */
-//=============================================================================
-FIELDINT_i::~FIELDINT_i()
-{
- BEGIN_OF("Default Destructor FIELDINT_i");
- END_OF("Default Destructor FIELDINT_i");
-}
-//=============================================================================
-/*!
- * Default constructor
- */
-//=============================================================================
-FIELDINT_i::FIELDINT_i(::FIELD<int> * const f, bool ownCppPtr):
- FIELD_i(f,ownCppPtr)
-{
- BEGIN_OF("Constructor FIELDINT_i");
- END_OF(" Constructor FIELDINT_i");
-}
-//=============================================================================
-/*!
- * Constructor par recopie
- */
-//=============================================================================
-FIELDINT_i::FIELDINT_i(FIELDINT_i &fi):FIELD_i(fi)
-{
- BEGIN_OF("Constructor FIELDINT_i");
- END_OF(" Constructor FIELDINT_i");
-}
-
-//=============================================================================
-/*!
- * CORBA: Accessor for Field's values
-*/
-//=============================================================================
-
-SALOME_MED::long_array* FIELDINT_i::getValue( SALOME_MED::medModeSwitch mode )
-throw (SALOME::SALOME_Exception)
-{
- if (_fieldTptr==NULL)
- THROW_SALOME_CORBA_EXCEPTION("No associated Field", \
- SALOME::INTERNAL_ERROR);
- SALOME_MED::long_array_var myseq = new SALOME_MED::long_array;
- 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 = static_cast< MEDMEM::FIELD<int>* >(_fieldTptr);
-
- const int * values =ptrI->getValue(modemed);
- int nbval=ptrI->getValueLength(modemed);
- myseq->length(nbval);
- for (int i=0; i<nbval; i++)
- {
- myseq[i]=values[i];
- };
- }
- catch(MEDEXCEPTION &ex)
- {
- MESSAGE("Unable to acces Field");
- THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
- }
- return myseq._retn();
-}
-//=============================================================================
-/*!
- * CORBA: Accessor for Field's values
-*/
-//=============================================================================
-
-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::SenderInt_ptr ret;
- 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=static_cast< MEDMEM::FIELD<int>* >(_fieldTptr);
- const int * values =ptrI->getValue(modemed);
- int nbval=ptrI->getValueLength(modemed);
- ret=SenderFactory::buildSender(*this,values,nbval);
- }
- catch(MEDEXCEPTION &ex)
- {
- MESSAGE("Unable to acces Field");
- THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
- }
- return ret;
-}
+++ /dev/null
-// Copyright (C) 2005 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.salome-platform.org/
-//
-//=============================================================================
-// File : MEDMEM_FieldInt_i.hxx
-// Project : SALOME
-// Author : EDF
-// Copyright : EDF 2002
-// $Header: /export/home/PAL/MED_SRC/src/MEDMEM_I/MEDMEM_FieldInt_i.hxx
-//=============================================================================
-
-#ifndef MED_FIELDINT_I_HXX_
-#define MED_FIELDINT_I_HXX_
-
-#include <SALOMEconfig.h>
-
-#include CORBA_SERVER_HEADER(MED)
-
-#include "MEDMEM_Field_i.hxx"
-
-#include "MEDMEM_Field.hxx"
-
-namespace MEDMEM {
- class FIELDINT_i: public POA_SALOME_MED::FIELDINT,
- public FIELD_i,
- public SALOMEMultiComm
-{
-private:
- FIELDINT_i();
-
-public:
- ~FIELDINT_i();
- FIELDINT_i(MEDMEM::FIELD<int> * const f, bool ownCppPtr=false);
- FIELDINT_i(FIELDINT_i & f);
- SALOME_MED::long_array * getValue (SALOME_MED::medModeSwitch mode )
- throw (SALOME::SALOME_Exception);
- SALOME::SenderInt_ptr getSenderForValue(SALOME_MED::medModeSwitch mode)
- throw (SALOME::SALOME_Exception);
-};
-}
-#endif /* MED_FIELDINT_I_HXX_ */
--- /dev/null
+#ifndef __MED_FIELDTEMPLATE_I_HXX__
+#define __MED_FIELDTEMPLATE_I_HXX__
+
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(MED)
+#include "MEDMEM_Field_i.hxx"
+#include "MEDMEM_Field.hxx"
+#include "SenderFactory.hxx"
+#include "MultiCommException.hxx"
+#include "MEDMEM_ArrayConvert.hxx"
+#include "MEDMEM_TraitsForFields.hxx"
+
+namespace MEDMEM
+{
+ template < class T, class INTERLACING_TAG >
+ class FIELDTEMPLATE_I : public FIELDI_TRAITS<T,INTERLACING_TAG>::InterfaceForServant,
+ public FIELD_i,
+ public SALOMEMultiComm
+ {
+ public:
+ FIELDTEMPLATE_I();
+ ~FIELDTEMPLATE_I();
+ FIELDTEMPLATE_I(MEDMEM::FIELD<T, INTERLACING_TAG> *f, bool ownCppPtr=false);
+ FIELDTEMPLATE_I(FIELDTEMPLATE_I & f);
+ typename FIELDI_TRAITS<T,INTERLACING_TAG>::SeqType* getValue (SALOME_MED::medModeSwitch mode )
+ throw (SALOME::SALOME_Exception);
+ typename FIELDI_TRAITS<T,INTERLACING_TAG>::SenderPtrType getSenderForValue(SALOME_MED::medModeSwitch mode)
+ throw (SALOME::SALOME_Exception);
+ };
+
+ //=============================================================================
+ /*!
+ * Default constructor
+ */
+ //=============================================================================
+ template < class T, class INTERLACING_TAG >
+ FIELDTEMPLATE_I<T,INTERLACING_TAG>::FIELDTEMPLATE_I(): FIELD_i()
+ {
+ BEGIN_OF("Default Constructor FIELDTEMPLATE_I");
+ END_OF("Default Constructor FIELDTEMPLATE_I");
+ }
+ //=============================================================================
+ /*!
+ * Destructor
+ */
+ //=============================================================================
+ template < class T, class INTERLACING_TAG >
+ FIELDTEMPLATE_I<T,INTERLACING_TAG>::~FIELDTEMPLATE_I()
+ {
+ BEGIN_OF("Default Destructor FIELDTEMPLATE_I");
+ END_OF("Default Destructor FIELDTEMPLATE_I");
+ }
+ //=============================================================================
+ /*!
+ * Constructor par recopie
+ */
+ //=============================================================================
+ template < class T, class INTERLACING_TAG >
+ FIELDTEMPLATE_I<T,INTERLACING_TAG>::FIELDTEMPLATE_I(FIELDTEMPLATE_I<T, INTERLACING_TAG>& fd):
+ FIELD_i(fd)
+ {
+ BEGIN_OF("Default Constructor FIELDTEMPLATE_I");
+ END_OF("Default Constructor FIELDTEMPLATE_I");
+ }
+ //=============================================================================
+ /*!
+ * Default constructor
+ */
+ //=============================================================================
+ template < class T, class INTERLACING_TAG >
+ FIELDTEMPLATE_I<T,INTERLACING_TAG>::FIELDTEMPLATE_I(MEDMEM::FIELD<T, INTERLACING_TAG> *f, bool ownCppPtr):FIELD_i(f,ownCppPtr)
+ {
+ BEGIN_OF("Constructor FIELDTEMPLATE_I");
+ END_OF(" Constructor FIELDTEMPLATE_I");
+ }
+
+ //=============================================================================
+ /*!
+ * CORBA: Accessor for Field's values
+ */
+ //=============================================================================
+ template < class T, class INTERLACING_TAG >
+ typename FIELDI_TRAITS<T,INTERLACING_TAG>::SeqType *FIELDTEMPLATE_I<T,INTERLACING_TAG>::getValue( SALOME_MED::medModeSwitch mode )
+ throw (SALOME::SALOME_Exception)
+ {
+ if (_fieldTptr==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Field", \
+ SALOME::INTERNAL_ERROR);
+ typename FIELDI_TRAITS<T,INTERLACING_TAG>::SeqVarType myseq = new typename FIELDI_TRAITS<T,INTERLACING_TAG>::SeqType;
+ try
+ {
+ medModeSwitch modemed=convertIdlModeToMedMode(mode);
+ // ::FIELD<T> *ptrD=dynamic_cast< ::FIELD<T>* >(_fieldTptr);
+ // the alternative is not safe but the dynamic_cast fails using the python API
+ MEDMEM::FIELD<T, INTERLACING_TAG> *ptrD = static_cast<MEDMEM::FIELD<T, INTERLACING_TAG>* >(_fieldTptr);
+ int nbval=ptrD->getValueLength();
+ if(ptrD->getInterlacingType()==modemed)
+ {
+ const T* values =ptrD->getValue();
+ myseq->length(nbval);
+ for (int i=0; i<nbval; i++)
+ {
+ myseq[i]=values[i];
+ }
+ }
+ else
+ {
+ T *values;
+ if ( ptrD->getGaussPresence() )
+ {
+ typename MEDMEM_ArrayInterface<T,INTERLACING_TAG,Gauss>::Array * myArray = ptrD->getArrayGauss();
+ int size=myArray->getArraySize();
+ values=new T[size];
+ delete ArrayConvert(*myArray,values);
+ }
+ else
+ {
+ typename MEDMEM_ArrayInterface<T,INTERLACING_TAG,NoGauss>::Array * myArray = ptrD->getArrayNoGauss();
+ int size=myArray->getArraySize();
+ values=new T[size];
+ delete ArrayConvert(*myArray,values);
+ }
+ for (int i=0; i<nbval; i++)
+ {
+ myseq[i]=values[i];
+ }
+ }
+ }
+ catch (MEDEXCEPTION &ex)
+ {
+ MESSAGE("Unable to acces Field ");
+ THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
+ }
+ return myseq._retn();
+ }
+ //=============================================================================
+ /*!
+ * CORBA: Accessor for Field's values
+ */
+ //=============================================================================
+ template < class T, class INTERLACING_TAG >
+ typename FIELDI_TRAITS<T,INTERLACING_TAG>::SenderPtrType FIELDTEMPLATE_I<T,INTERLACING_TAG>::getSenderForValue( SALOME_MED::medModeSwitch mode )
+ throw (SALOME::SALOME_Exception)
+ {
+ if (_fieldTptr==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Field", \
+ SALOME::INTERNAL_ERROR);
+ typename FIELDI_TRAITS<T,INTERLACING_TAG>::SenderPtrType ret;
+ try
+ {
+ medModeSwitch modemed=convertIdlModeToMedMode(mode);
+ // ::FIELD<T> *ptrD=dynamic_cast< ::FIELD<T>* >(_fieldTptr);
+ // the alternative is not safe but the dynamic_cast fails using the python API
+ MEDMEM::FIELD<T, INTERLACING_TAG> *ptrD=static_cast< MEDMEM::FIELD<T, INTERLACING_TAG>* >(_fieldTptr);
+ int nbval=ptrD->getValueLength();
+ if(ptrD->getInterlacingType()==modemed)
+ {
+ const T* values =ptrD->getValue();
+ ret=SenderFactory::buildSender(*this,values,nbval);
+ }
+ else
+ {
+ T *values;
+ if ( ptrD->getGaussPresence() )
+ {
+ typename MEDMEM_ArrayInterface<T,INTERLACING_TAG,Gauss>::Array * myArray = ptrD->getArrayGauss();
+ int size=myArray->getArraySize();
+ values=new T[size];
+ delete ArrayConvert(*myArray,values);
+
+ }
+ else
+ {
+ typename MEDMEM_ArrayInterface<T,INTERLACING_TAG,NoGauss>::Array * myArray = ptrD->getArrayNoGauss();
+ int size=myArray->getArraySize();
+ values=new T[size];
+ delete ArrayConvert(*myArray,values);
+ }
+ ret=SenderFactory::buildSender(*this,values,nbval);
+ }
+ }
+ catch (MEDEXCEPTION &ex)
+ {
+ MESSAGE("Unable to acces Field ");
+ THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
+ }
+ return ret;
+ }
+
+}
+
+#endif
-// Copyright (C) 2005 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.salome-platform.org/
-//
//=============================================================================
// File : MEDMEM_Field_i.cxx
// Created : mer fév 20 15:47:57 CET 2002
}
}
//=============================================================================
+/*!
+ * CORBA: Accessor for gauss numbers presence.
+ */
+//=============================================================================
+CORBA::Boolean FIELD_i::getGaussPresence()
+{
+ if (_fieldTptr==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Field", \
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ return _fieldTptr->getGaussPresence();
+ }
+ catch (MEDEXCEPTION &ex)
+ {
+ MESSAGE("Exception en accedant au champ");
+ THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
+ }
+}
+//=============================================================================
/*!
* CORBA: Accessor
*/
MESSAGE("Computing path to Support");
- string supportEntryPath = SUPPORT_i::getEntryPath( meshNameStudy,
- _fieldTptr->getSupport() );
+ char * supportEntryPath;
+ lenName = 28 + 15 + strlen(meshName.c_str()) + 1 +
+ strlen(supportName.c_str()) + 1;
+ supportEntryPath = new char[lenName];
+ supportEntryPath = strcpy(supportEntryPath,"/Med/MEDMESH/MEDSUPPORTS_OF_");
+ supportEntryPath = strcat(supportEntryPath,meshNameStudy.c_str());
+ supportEntryPath = strcat(supportEntryPath,"/");
+ supportEntryPath = strcat(supportEntryPath,supportName.c_str());
+
SCRUTE(supportEntryPath);
- MESSAGE("supportEntryPath in field " << supportEntryPath /*<< " length " << lenName*/);
+ MESSAGE("supportEntryPath in field " << supportEntryPath << " length " << lenName);
// SALOMEDS::SObject_var supportObject = myStudy->FindObject(supportName.c_str());
- SALOMEDS::SObject_var supportObject = myStudy->FindObjectByPath(supportEntryPath.c_str());
+ SALOMEDS::SObject_var supportObject = myStudy->FindObjectByPath(supportEntryPath);
SCRUTE(supportObject);
myBuilder->CommitCommand();
- //delete [] supportEntryPath;
+ delete [] supportEntryPath;
delete [] fieldEntryName;
// register the Corba pointer: increase the referrence count
-// Copyright (C) 2005 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.salome-platform.org/
-//
//=============================================================================
// File : MEDMEM_Field_i.hxx
// Project : SALOME
CORBA::Long getIterationNumber()
throw (SALOME::SALOME_Exception);
CORBA::Long getOrderNumber() throw (SALOME::SALOME_Exception);
+ CORBA::Boolean getGaussPresence();
CORBA::Double getTime() throw (SALOME::SALOME_Exception);
CORBA::Long getCorbaIndex() throw (SALOME::SALOME_Exception);
-// Copyright (C) 2005 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.salome-platform.org/
-//
//=============================================================================
// File : MEDMEM_Med_i.cxx
// Project : SALOME
#include "MEDMEM_Med_i.hxx"
#include "MEDMEM_Mesh_i.hxx"
-#include "MEDMEM_FieldDouble_i.hxx"
-#include "MEDMEM_FieldInt_i.hxx"
+#include "MEDMEM_FieldTemplate_i.hxx"
#include "MEDMEM_Support_i.hxx"
#include "MEDMEM_Family_i.hxx"
#include "MEDMEM_Group_i.hxx"
#include "MEDMEM_convert.hxx"
-#include "MEDMEM_Family.hxx"
-#include "MEDMEM_Group.hxx"
#include "MEDMEM_DriversDef.hxx"
#include "utilities.h"
MED_i::MED_i():_med((::MED*)NULL)
{
BEGIN_OF("Default Constructor MED_i");
- _med = new ::MED();
END_OF("Default Constructor MED_i");
}
//=============================================================================
BEGIN_OF(LOC);
// we create all IOR from _med
- if ( _med )
- delete _med;
- _med = new ::MED(driverType,fileName);
+ _med = new ::MED(driverType,fileName);
// MESHES :
deque<string> meshesNames = _med->getMeshNames();
case MED_EN::MED_INT32 :
{
((FIELD<int>*)myField)->read();
- FIELDINT_i * myFieldIntI = new FIELDINT_i((FIELD<int>*)myField);
+ FIELDTEMPLATE_I<int,FullInterlace> *myFieldIntI = new FIELDTEMPLATE_I<int,FullInterlace>((FIELD<int>*)myField);
myFieldIOR = myFieldIntI->_this();
// myFieldIntI->addInStudy(myStudy,myFieldIOR);
break;
case MED_EN::MED_REEL64:
{
((FIELD<double>*)myField)->read();
- FIELDDOUBLE_i * myFieldDoubleI = new FIELDDOUBLE_i((FIELD<double>*)myField);
+ FIELDTEMPLATE_I<double,FullInterlace> *myFieldDoubleI = new FIELDTEMPLATE_I<double,FullInterlace>((FIELD<double,FullInterlace>*)myField);
myFieldIOR = myFieldDoubleI->_this();
// myFieldDoubleI->addInStudy(myStudy,myFieldIOR);
break;
SCRUTE(driverType);
SCRUTE(fileName)
- if ( _med )
- delete _med;
- _med = new ::MED(driverType,fileName);
+ _med = new ::MED(driverType,fileName);
int numberOfMeshes = _med->getNumberOfMeshes();
SCRUTE(numberOfMeshes);
case MED_EN::MED_INT32:
{
((FIELD<int>*)myField)->read();
- FIELDINT_i * myFieldIntI = new FIELDINT_i((FIELD<int>*)myField);
+ FIELDTEMPLATE_I<int,FullInterlace> *myFieldIntI = new FIELDTEMPLATE_I<int,FullInterlace>((FIELD<int>*)myField);
SALOME_MED::FIELDINT_ptr myFieldIntIOR;
myFieldIntIOR = myFieldIntI->_this();
case MED_EN::MED_REEL64:
{
((FIELD<double>*)myField)->read();
- FIELDDOUBLE_i * myFieldDoubleI = new FIELDDOUBLE_i((FIELD<double>*)myField);
+ FIELDTEMPLATE_I<double,FullInterlace> *myFieldDoubleI = new FIELDTEMPLATE_I<double,FullInterlace>((FIELD<double>*)myField);
SALOME_MED::FIELDDOUBLE_ptr myFieldDoubleIOR;
myFieldDoubleIOR = myFieldDoubleI->_this();
//=============================================================================
MED_i::~MED_i()
{
- //delete _med;
}
-
-//=======================================================================
-//function : updateSupportIORs
-//purpose :
-//=======================================================================
-
-void MED_i::updateSupportIORs(SALOMEDS::Study_ptr myStudy, const char* meshName)
-{
- vector<FAMILY*> familyVector;
- vector<FAMILY*>::iterator familyVectorIt;
- vector<GROUP*> groupVector;
- vector<GROUP*>::iterator groupVectorIt;
- string supportEntryPath;
-
- ::MESH * ptrMesh = _med->getMesh(meshName);
-
- MED_EN::MESH_ENTITIES::const_iterator currentEntity;
-
- for (currentEntity = MED_EN::meshEntities.begin();
- currentEntity != MED_EN::meshEntities.end();
- currentEntity++)
- {
- // family :
- familyVector = ptrMesh->getFamilies((MED_EN::medEntityMesh)(*currentEntity).first);
- int nb = familyVector.size();
- for (familyVectorIt = familyVector.begin();
- familyVectorIt != familyVector.end();
- familyVectorIt++)
- {
- supportEntryPath = SUPPORT_i::getEntryPath( meshName, *familyVectorIt );
- SALOMEDS::SObject_var familyEntry = myStudy->FindObjectByPath(supportEntryPath.c_str());
- if ( !familyEntry->_is_nil() || CORBA::is_nil( familyEntry->GetObject() ))
- {
- FAMILY_i * myFamilyI = new FAMILY_i(*familyVectorIt);
- SALOME_MED::FAMILY_ptr myFamilyIOR = myFamilyI->POA_SALOME_MED::FAMILY::_this();
- myFamilyI->addInStudy(myStudy,myFamilyIOR);
- }
- }
-
- // group :
- groupVector = ptrMesh->getGroups((MED_EN::medEntityMesh)(*currentEntity).first);
- nb = groupVector.size();
- for (groupVectorIt = groupVector.begin();
- groupVectorIt != groupVector.end();
- groupVectorIt++)
- {
- supportEntryPath = SUPPORT_i::getEntryPath( meshName, *groupVectorIt );
- SALOMEDS::SObject_var groupEntry = myStudy->FindObjectByPath(supportEntryPath.c_str());
- if ( !groupEntry->_is_nil() || CORBA::is_nil( groupEntry->GetObject() ))
- {
- GROUP_i * myGroupI = new GROUP_i(*groupVectorIt);
- SALOME_MED::GROUP_ptr myGroupIOR = myGroupI->POA_SALOME_MED::GROUP::_this();
- myGroupI->addInStudy(myStudy,myGroupIOR);
- }
- }
- }
-
- _med->updateSupport();
-
- // supports
- map<MED_EN::medEntityMesh,::SUPPORT*> mySupports = _med->getSupports(meshName);
- map<MED_EN::medEntityMesh,::SUPPORT*>::const_iterator itSupport;
- map<MED_EN::medEntityMesh,SALOME_MED::SUPPORT_ptr> &
- mySupportsIOR = _supports[meshName];
- for (itSupport=mySupports.begin(); itSupport!=mySupports.end(); itSupport++ )
- {
- supportEntryPath = SUPPORT_i::getEntryPath( meshName, itSupport->second);
- SALOMEDS::SObject_var supportEntry = myStudy->FindObjectByPath(supportEntryPath.c_str());
- if ( !supportEntry->_is_nil() || CORBA::is_nil( supportEntry->GetObject() ))
- {
- SUPPORT_i * mySupportI = new SUPPORT_i((*itSupport).second);
- SALOME_MED::SUPPORT_ptr mySupportIOR = mySupportI->_this();
- mySupportsIOR[(*itSupport).first]= mySupportIOR;
- mySupportI->addInStudy(myStudy,mySupportIOR);
- }
- }
-}
-
-
//=============================================================================
/*!
* CORBA: Accessor for Number of meshes
if (_med==NULL)
THROW_SALOME_CORBA_EXCEPTION("No associated Med object",\
SALOME::INTERNAL_ERROR);
- SALOME_MED::MESH_ptr meshIOR;
try
{
- map<string,SALOME_MED::MESH_ptr>::const_iterator name_meshIOR =
- _meshes.find( meshName );
- if ( name_meshIOR == _meshes.end() ) {
MESH * mesh=_med->getMesh(meshName);
MESH_i * m1 = new MESH_i(mesh);
- meshIOR = m1->POA_SALOME_MED::MESH::_this();
- _meshes[ meshName ] = meshIOR;
- }
- else {
- meshIOR = name_meshIOR->second;
- }
+ return m1->POA_SALOME_MED::MESH::_this();
}
catch (MEDEXCEPTION &ex)
{
MESSAGE("Unable to get the specified mesh");
THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
}
- return meshIOR;
+
}
//=============================================================================
/*!
ASSERT(FIELD_i::fieldMap.find(ind)!=FIELD_i::fieldMap.end());
::FIELD<double> * fdouble = (::FIELD<double> *)FIELD_i::fieldMap[ind];
- mesh=_med->getMesh(fdouble);
+ MESH * mesh=_med->getMesh(fdouble);
}
else
{
ASSERT(FIELD_i::fieldMap.find(ind)!=FIELD_i::fieldMap.end());
::FIELD<int> * fint = (::FIELD<int> *)FIELD_i::fieldMap[ind];
- mesh=_med->getMesh(fint);
+ MESH * mesh=_med->getMesh(fint);
}
MESH_i * meshi = new MESH_i(mesh);
return meshi->POA_SALOME_MED::MESH::_this();
{
const char * LOC="MED_i::getField(const char*,CORBA::Long,CORBA::Long) ";
BEGIN_OF(LOC);
- if (_med==NULL)
- THROW_SALOME_CORBA_EXCEPTION("No associated Med object",\
- SALOME::INTERNAL_ERROR);
-
- SALOME_MED::FIELD_ptr myFieldIOR = SALOME_MED::FIELD::_nil();
DT_IT_ dtIt;
dtIt.it= (int)numOrdre;
map<string,MAP_IOR_DT_IT_>::const_iterator itFields = _fields.find(fieldName);
- if ( itFields != _fields.end() )
- {
- const MAP_IOR_DT_IT_ & map_dtIt = (*itFields).second;
- MAP_IOR_DT_IT_::const_iterator itMap_dtIt = map_dtIt.find(dtIt);
- if ( itMap_dtIt != map_dtIt.end() )
- myFieldIOR = (*itMap_dtIt).second;
- }
- if ( CORBA::is_nil( myFieldIOR ))
- {
- try
- {
- ::FIELD_* myField = _med->getField( fieldName, pasTemps, numOrdre);
-
- switch ( myField->getValueType() ) {
- case MED_EN::MED_INT32 : {
- FIELDINT_i * myFieldIntI = new FIELDINT_i((FIELD<int>*)myField);
- myFieldIOR = myFieldIntI->_this();
- break;
- }
-
- case MED_EN::MED_REEL64: {
- FIELDDOUBLE_i * myFieldDoubleI = new FIELDDOUBLE_i((FIELD<double>*)myField);
- myFieldIOR = myFieldDoubleI->_this();
- break;
- }
- default:
- THROW_SALOME_CORBA_EXCEPTION ("Wrong field type", SALOME::INTERNAL_ERROR);
- }
- }
- catch (const std::exception & ex)
- {
- MESSAGE("Exception Interceptee : ");
- SCRUTE(ex.what());
- THROW_SALOME_CORBA_EXCEPTION("Field not found !", SALOME::INTERNAL_ERROR);
- }
- _fields[fieldName][dtIt] = myFieldIOR;
- }
+ if ( itFields == _fields.end() )
+ THROW_SALOME_CORBA_EXCEPTION("Field not found !", SALOME::INTERNAL_ERROR);
+
+ const MAP_IOR_DT_IT_ & map_dtIt = (*itFields).second;
+ MAP_IOR_DT_IT_::const_iterator itMap_dtIt = map_dtIt.find(dtIt);
+
+ if ( itMap_dtIt == map_dtIt.end() )
+ THROW_SALOME_CORBA_EXCEPTION("Iteration not found !", SALOME::INTERNAL_ERROR);
+
+ END_OF(LOC);
+ return (*itMap_dtIt).second;
- END_OF(LOC);
- return myFieldIOR;
}
//=============================================================================
/*!
-// Copyright (C) 2005 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.salome-platform.org/
-//
//=============================================================================
// File : MEDMEM_Mesh_i.cxx
// Project : SALOME
#include "MEDMEM_Support_i.hxx"
#include "MEDMEM_Family_i.hxx"
#include "MEDMEM_Group_i.hxx"
-#include "MEDMEM_FieldDouble_i.hxx"
+#include "MEDMEM_FieldTemplate_i.hxx"
#include "MEDMEM_Mesh.hxx"
#include "MEDMEM_Family.hxx"
ASSERT(SUPPORT_i::supportMap.find(sup)!=SUPPORT_i::supportMap.end());
const SUPPORT * myCppSupport=SUPPORT_i::supportMap[sup];
::FIELD<double>*f=_mesh->getVolume( myCppSupport);
- FIELDDOUBLE_i * medf = new FIELDDOUBLE_i(f);
+ FIELDTEMPLATE_I<double,FullInterlace> *medf = new FIELDTEMPLATE_I<double,FullInterlace>(f);
return medf->_this();
}
catch (MEDEXCEPTION &ex)
ASSERT(SUPPORT_i::supportMap.find(sup)!=SUPPORT_i::supportMap.end());
const SUPPORT * myCppSupport=SUPPORT_i::supportMap[sup];
::FIELD<double>*f=_mesh->getArea( myCppSupport);
- FIELDDOUBLE_i * medf = new FIELDDOUBLE_i(f);
+ FIELDTEMPLATE_I<double,FullInterlace> *medf = new FIELDTEMPLATE_I<double,FullInterlace>(f);
return medf->_this();
}
catch (MEDEXCEPTION &ex)
ASSERT(SUPPORT_i::supportMap.find(sup)!=SUPPORT_i::supportMap.end());
const SUPPORT * myCppSupport=SUPPORT_i::supportMap[sup];
::FIELD<double>*f=_mesh->getLength( myCppSupport);
- FIELDDOUBLE_i * medf = new FIELDDOUBLE_i(f);
+ FIELDTEMPLATE_I<double,FullInterlace> *medf = new FIELDTEMPLATE_I<double,FullInterlace>(f);
return medf->_this();
}
catch (MEDEXCEPTION &ex)
ASSERT(SUPPORT_i::supportMap.find(sup)!=SUPPORT_i::supportMap.end());
const SUPPORT * myCppSupport=SUPPORT_i::supportMap[sup];
::FIELD<double>*f=_mesh->getNormal( myCppSupport);
- FIELDDOUBLE_i * medf = new FIELDDOUBLE_i(f);
+ FIELDTEMPLATE_I<double,FullInterlace> *medf = new FIELDTEMPLATE_I<double,FullInterlace>(f);
return medf->_this();
}
catch (MEDEXCEPTION &ex)
ASSERT(SUPPORT_i::supportMap.find(sup)!=SUPPORT_i::supportMap.end());
const SUPPORT * myCppSupport=SUPPORT_i::supportMap[sup];
::FIELD<double>*f=_mesh->getBarycenter( myCppSupport);
- FIELDDOUBLE_i * medf = new FIELDDOUBLE_i(f);
+ FIELDTEMPLATE_I<double,FullInterlace> *medf = new FIELDTEMPLATE_I<double,FullInterlace>(f);
return medf->_this();
}
catch (MEDEXCEPTION &ex)
-// Copyright (C) 2005 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.salome-platform.org/
-//
//=============================================================================
// File : MEDMEM_Support_i.cxx
// Project : SALOME
#include "MEDMEM_define.hxx"
#include "MEDMEM_Support.hxx"
-#include "MEDMEM_Mesh.hxx"
#include "MEDMEM_Support_i.hxx"
#include "MEDMEM_Mesh_i.hxx"
const int numberOfTypes = _support->getNumberOfTypes();
all->numberOfGeometricType = numberOfTypes;
all->entity = _support->getEntity();
-
+ all->isOnAllElements = _support->isOnAllElements();
all->types.length(numberOfTypes);
all->nbEltTypes.length(numberOfTypes);
const medGeometryElement * elemts = _support->getTypes();
SALOME_MED::long_array_var myseq= new SALOME_MED::long_array;
try
{
- MESSAGE ("Nombre d'elements mis de façon stupide a MED_ALL_ELEMENTS");
+ MESSAGE ("Nombre d'elements mis de façon stupide a MED_ALL_ELEMENTS");
int nbelements=_support->getNumberOfElements(::MED_ALL_ELEMENTS);
myseq->length(nbelements);
const int * numbers=_support->getNumberIndex();
SALOME::SenderInt_ptr ret;
try
{
- MESSAGE ("Nombre d'elements mis de façon stupide a MED_ALL_ELEMENTS");
+ MESSAGE ("Nombre d'elements mis de façon stupide a MED_ALL_ELEMENTS");
int nbelements=_support->getNumberOfElements(::MED_ALL_ELEMENTS);
const int * numbers=_support->getNumberIndex();
ret=SenderFactory::buildSender(*this,numbers,nbelements);
}
MESSAGE(LOC << " Find SObject MESH (represent mesh in support)");
- string meshName = _support->getMesh()->getName() ;
+ string meshName = getMesh()->getName() ;
string meshNameStudy = meshName;
for (string::size_type pos=0; pos<meshNameStudy.size();++pos)
THROW_SALOME_CORBA_EXCEPTION("SObject Mesh in Support not Found",SALOME::INTERNAL_ERROR);
// perhaps add MESH automatically ?
- MESSAGE("Add a support Object under /Med/MESH/MESHNAME");
+ MESSAGE("Add a support Object under /MED/MESH/MESHNAME");
char * medsupfatherName;
int lenName = 15 + strlen(meshName.c_str()) + 1;
//myBuilder->NewCommand();
- string supportEntryPath = getEntryPath( meshName, _support );
+ string supportName = _support->getName();
+
+ SCRUTE(supportName);
+
+ SCRUTE(meshNameStudy);
+
+ char * supportEntryPath;
+ lenName = 13 + 15 + strlen(meshName.c_str()) + 1 + strlen(supportName.c_str())+1;
+ supportEntryPath = new char[lenName];
+ supportEntryPath = strcpy(supportEntryPath,"/Med/MEDMESH/");
+ supportEntryPath = strcat(supportEntryPath,"MEDSUPPORTS_OF_");
+ supportEntryPath = strcat(supportEntryPath,meshNameStudy.c_str());
+ supportEntryPath = strcat(supportEntryPath,"/");
+ supportEntryPath = strcat(supportEntryPath,supportName.c_str());
+
//SCRUTE(supportEntryPath);
- MESSAGE("supportEntryPath in support " << supportEntryPath/* << " length " << lenName*/);
+ MESSAGE("supportEntryPath in support " << supportEntryPath << " length " << lenName);
- SALOMEDS::SObject_var supportEntry = myStudy->FindObjectByPath(supportEntryPath.c_str());
+// SALOMEDS::SObject_var supportEntry = myStudy->FindObject(_support->getName().c_str());
+ // c'est pas bon, car il faut rechercher uniquement sous le bon MESH !!!
+ SALOMEDS::SObject_var supportEntry = myStudy->FindObjectByPath(supportEntryPath);
if ( CORBA::is_nil(supportEntry) )
{
}
myBuilder->CommitCommand();
- SALOMEDS::SObject_var supportEntryBis = myStudy->FindObjectByPath(supportEntryPath.c_str());
+ SALOMEDS::SObject_var supportEntryBis = myStudy->FindObjectByPath(supportEntryPath);
MESSAGE("Just for checking, reuse of the corba pointer");
}
delete [] medsupfatherName;
+ delete [] supportEntryPath;
// register the Corba pointer: increase the referrence count
MESSAGE("Registering of the Corba Support pointer");
END_OF(LOC);
}
-
-//=======================================================================
-//function : getEntryPath
-//purpose :
-//=======================================================================
-
-string SUPPORT_i::getEntryPath(const string& aMeshName, const ::MEDMEM::SUPPORT * aSupport)
-{
- string meshNameStudy( aMeshName.c_str(), strlen( aMeshName.c_str() ));
- for (string::size_type pos=0; pos<meshNameStudy.size();++pos)
- if (isspace(meshNameStudy[pos])) meshNameStudy[pos] = '_';
-
- string supportName = aSupport->getName();
- string supportNameStudy( supportName.c_str(), strlen( supportName.c_str() ));
- string supportEntryPath =
- "/Med/MEDMESH/MEDSUPPORTS_OF_" + meshNameStudy + "/" + supportNameStudy;
- SCRUTE( supportEntryPath );
-
- return supportEntryPath;
-}
--- /dev/null
+#ifndef __MEDMEM_TRAITSFORFIELDS_HXX__
+#define __MEDMEM_TRAITSFORFIELDS_HXX__
+
+#include CORBA_SERVER_HEADER(MED)
+#include "MEDMEM_Tags.hxx"
+#include "MEDMEM_InterlacingPolicy.hxx"
+
+namespace MEDMEM
+{
+template < typename T, typename INTERLACING_TAG >
+struct FIELDI_TRAITS
+{
+ typedef typename T::InterfaceForServant InterfaceForServant;
+ typedef typename T::FieldCorbaPtrType FieldCorbaPtrType;
+ typedef typename T::SimpleFieldCorbaPtrType SimpleFieldCorbaPtrType;
+ typedef typename T::SimpleFieldGlobalType SimpleFieldGlobalType;
+ typedef typename T::SeqType SeqType;
+ typedef typename T::SeqVarType SeqVarType;
+ typedef typename T::SenderPtrType SenderPtrType;
+ typedef typename T::SenderVarType SenderVarType;
+};
+
+template < >
+struct FIELDI_TRAITS<double, FullInterlace>
+{
+ typedef POA_SALOME_MED::FIELDDOUBLEFULL InterfaceForServant;
+ typedef SALOME_MED::FIELDDOUBLEFULL_ptr FieldCorbaPtrType;
+ typedef SALOME_MED::FIELDDOUBLE_ptr SimpleFieldCorbaPtrType;
+ typedef SALOME_MED::FIELDDOUBLE SimpleFieldGlobalType;
+ typedef SALOME_MED::double_array SeqType;
+ typedef SALOME_MED::double_array_var SeqVarType;
+ typedef SALOME::SenderDouble_ptr SenderPtrType;
+ typedef SALOME::SenderDouble_var SenderVarType;
+};
+
+template < >
+struct FIELDI_TRAITS<double, NoInterlace>
+{
+ typedef POA_SALOME_MED::FIELDDOUBLENO InterfaceForServant;
+ typedef SALOME_MED::FIELDDOUBLENO_ptr FieldCorbaPtrType;
+ typedef SALOME_MED::FIELDDOUBLE_ptr SimpleFieldCorbaPtrType;
+ typedef SALOME_MED::FIELDDOUBLE SimpleFieldGlobalType;
+ typedef SALOME_MED::double_array SeqType;
+ typedef SALOME_MED::double_array_var SeqVarType;
+ typedef SALOME::SenderDouble_ptr SenderPtrType;
+ typedef SALOME::SenderDouble_var SenderVarType;
+};
+
+template < >
+struct FIELDI_TRAITS<int, FullInterlace>
+{
+ typedef POA_SALOME_MED::FIELDINTFULL InterfaceForServant;
+ typedef SALOME_MED::FIELDINTFULL_ptr FieldCorbaPtrType;
+ typedef SALOME_MED::FIELDINT_ptr SimpleFieldCorbaPtrType;
+ typedef SALOME_MED::FIELDINT SimpleFieldGlobalType;
+ typedef SALOME_MED::long_array SeqType;
+ typedef SALOME_MED::long_array_var SeqVarType;
+ typedef SALOME::SenderInt_ptr SenderPtrType;
+ typedef SALOME::SenderInt_var SenderVarType;
+};
+
+template < >
+struct FIELDI_TRAITS<int, NoInterlace>
+{
+ typedef POA_SALOME_MED::FIELDINTNO InterfaceForServant;
+ typedef SALOME_MED::FIELDINTNO_ptr FieldCorbaPtrType;
+ typedef SALOME_MED::FIELDINT_ptr SimpleFieldCorbaPtrType;
+ typedef SALOME_MED::FIELDINT SimpleFieldGlobalType;
+ typedef SALOME_MED::long_array SeqType;
+ typedef SALOME_MED::long_array_var SeqVarType;
+ typedef SALOME::SenderInt_ptr SenderPtrType;
+ typedef SALOME::SenderInt_var SenderVarType;
+};
+}
+
+#endif
MEDMEM_convert.hxx \
MEDMEM_Med_i.hxx \
MEDMEM_Family_i.hxx \
- MEDMEM_FieldDouble_i.hxx \
- MEDMEM_FieldInt_i.hxx \
+ MEDMEM_FieldTemplate_i.hxx \
+ MEDMEM_TraitsForFields.hxx \
MEDMEM_Field_i.hxx \
MEDMEM_Group_i.hxx \
MEDMEM_Mesh_i.hxx \
# Libraries targets
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_SRC = MEDMEM_Med_i.cxx MEDMEM_Family_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 SALOME_GenericObj.idl
EXPORT_HEADERS = \
libMEDMEM_Swig.i \
my_typemap.i \
- MEDMEM_SWIG_Templates.hxx
+ MEDMEM_SWIG_Templates.hxx
# MEDMEM_SWIG_MedFieldDoubleDriver.hxx \
# MEDMEM_SWIG_MedFieldIntDriver.hxx \
# MEDMEM_SWIG_AsciiFieldDoubleDriver.hxx \
med_opsupp_test.py \
test_gibi.py \
test_porflow.py \
+ testDriverAscii.py \
testMedMemGeneral.py
#############################################################################
#include "MEDMEM_Med.hxx"
#include "MEDMEM_Unit.hxx"
#include "MEDMEM_Field.hxx"
+#include "MEDMEM_FieldConvert.hxx"
#include "MEDMEM_MedMedDriver.hxx"
#include "MEDMEM_Grid.hxx"
#include "MEDMEM_Meshing.hxx"
using namespace MEDMEM;
using namespace MED_EN;
-typedef FIELD <double> FIELDDOUBLE;
-typedef FIELD <int> FIELDINT;
+ /* typedef FIELD <double, FullInterlace> FIELDDOUBLEFULLINTERLACE;*/
+ /* typedef FIELD <int, FullInterlace> FIELDINTFULLINTERLACE;*/
+ typedef FIELD <double, FullInterlace> FIELDDOUBLE;
+ typedef FIELD <int, FullInterlace> FIELDINT;
+ typedef FIELD <double, NoInterlace> FIELDDOUBLENOINTERLACE;
+ typedef FIELD <int, NoInterlace> FIELDINTNOINTERLACE;
%}
-// SWIG needs these typedefs to wrap FIELDDOUBLE*, for ex., to something like
-// <C++ FIELD<double> instance at _d0709808_p_FIELDDOUBLE>, not to
-// <SWIG Object at _d0709808_p_FIELDDOUBLE> which has no attributes
-typedef FIELD <double> FIELDDOUBLE;
-typedef FIELD <int> FIELDINT;
+/*
+ SWIG needs these typedefs to wrap FIELDDOUBLE*, for ex., to something like
+ <C++ FIELD<double> instance at _d0709808_p_FIELDDOUBLE>, not to
+ <SWIG Object at _d0709808_p_FIELDDOUBLE> which has no attributes
+*/
+
+/*typedef FIELD <double, FullInterlace> FIELDDOUBLEFULLINTERLACE;*/
+/*typedef FIELD <int, FullInterlace> FIELDINTFULLINTERLACE;*/
+typedef FIELD <double, FullInterlace> FIELDDOUBLE;
+typedef FIELD <int, FullInterlace> FIELDINT;
+typedef FIELD <double, NoInterlace> FIELDDOUBLENOINTERLACE;
+typedef FIELD <int, NoInterlace> FIELDINTNOINTERLACE;
%include "typemaps.i"
%include "my_typemap.i"
+/*
+ mapping between stl string and python string
+*/
+
+%include "std_string.i"
+
+
/*
managing C++ exception in the Python API
*/
typemap for vector<FAMILY *> C++ object
*/
-%typemap(python,in) vector<FAMILY *>, const vector<FAMILY *>
+%typemap(python,in) vector< FAMILY * >, const vector< FAMILY * >
{
/* typemap in for vector<FAMILY *> */
/* Check if is a list */
if (PyList_Check($input)) {
int size = PyList_Size($input);
- $1.resize(size);
+ $1 = vector<FAMILY *>(size);
for (int i=0; i < size; i++)
{
}
}
-%typemap(python,out) vector<FAMILY *>
+%typemap(python,out) vector< FAMILY * >
{
/* typemap out for vector<FAMILY *> */
int size = $1.size();
typemap for vector<SUPPORT *> C++ object
*/
-%typemap(python,in) vector<SUPPORT *>, const vector<SUPPORT *>
+%typemap(python,in) vector< SUPPORT * >, const vector< SUPPORT * >
{
/* typemap in for vector<SUPPORT *> */
/* Check if is a list */
if (PyList_Check($input)) {
int size = PyList_Size($input);
- $1.resize(size);
+ $1 = vector<SUPPORT *>(size);
for (int i=0; i < size; i++)
{
}
}
-%typemap(python,out) vector<SUPPORT *>
+%typemap(python,out) vector< SUPPORT * >
{
/* typemap out for vector<SUPPORT *> */
int size = $1.size();
}
}
-%typemap(python,in) vector< FIELD<double> * >, const vector< FIELD<double> * >
+
+%typemap(python,in) vector< FIELD< double > * >, const vector< FIELD< double > * >
{
/* typemap in for vector<FIELD<double> *> */
/* Check if is a list */
for (int i=0; i < size; i++)
{
PyObject * tmp = PyList_GetItem($input,i);
- FIELDDOUBLE * s;
+ FIELD<double> * s;
- int err = SWIG_ConvertPtr(tmp, (void **) &s, $descriptor(FIELDDOUBLE *),
+ int err = SWIG_ConvertPtr(tmp, (void **) &s, $descriptor(FIELD<double> *),
SWIG_POINTER_EXCEPTION);
if (err == -1)
}
}
-%typemap(python,out) vector<FIELD<double> *>
+%typemap(python,out) vector< FIELD< double > * >
{
/* typemap out for vector<FIELD<double> *> */
int size = $1.size();
}
}
-%typemap(python,in) vector<FIELD<int> *>, const vector<FIELD<int> *>
+%typemap(python,in) vector< FIELD< int > * >, const vector< FIELD< int > * >
{
/* typemap in for vector<FIELD<int> *> */
/* Check if is a list */
}
}
-%typemap(python,out) vector<FIELD<int> *>
+%typemap(python,out) vector< FIELD< int > * >
{
/* typemap out for vector<FIELD<int> *> */
int size = $1.size();
}
}
-%typemap(python,out) char *
-{
- /* typemap out for char * */
-
- $result = PyString_FromString($1);
-}
-
-%typemap(python,out) string {
- $result = PyString_FromString($1.c_str());
-}
-
-%typemap(python,in) string {
- $1=string(PyString_AsString($input));
-}
/*
typemap in for PyObject * fonction Python wrapping of a
{
PyObject *py_list = PyList_New(size);
for (int i=0; i < size; i++)
- {
- int err = PyList_SetItem(py_list, i, type_converter( arrayvar[ i ]));
- if(err)
{
- char * message = "Error in " #method;
- PyErr_SetString(PyExc_RuntimeError, message);
- return NULL;
+ int err = PyList_SetItem(py_list, i, type_converter( arrayvar[ i ]));
+ if(err)
+ {
+ char * message = "Error in " #method;
+ PyErr_SetString(PyExc_RuntimeError, message);
+ return NULL;
+ }
}
- }
+
PyObject * result = Py_BuildValue("O", py_list);
Py_DECREF(py_list);
return result;
*/
%{
- PyObject *PyString_FromStdString(const std::string &str) { return PyString_FromString(str.c_str()); }
+ PyObject *PyString_FromStdString(const std::string &str)
+ {
+ return PyString_FromString(str.c_str());
+ }
%}
return self->it;
}
}
+
+%typecheck(SWIG_TYPECHECK_POINTER) vector< SUPPORT * >, const vector< SUPPORT * >
+{
+ $1 = ($input != 0);
+}
+
/*
Class et methodes du MED++ que l'on utilise dans l'API Python
*/
int getNumberOfConstituentsType();
+ std::string getName() const;
+
~CELLMODEL();
%extend {
- %newobject getName();
- char * getName()
- {
- string tmp_str = self->getName();
- char * tmp = new char[strlen(tmp_str.c_str())+1];
- strcpy(tmp,tmp_str.c_str());
- return tmp;
- }
-
%newobject __str__();
const char* __str__()
{
MESH * getMesh() const;
- void setMesh(MESH * Mesh);
+ void setMesh(MESH * Mesh) const;
medEntityMesh getEntity() const;
bool deepCompare(const SUPPORT &support) const;
- %extend {
- SUPPORT(MESH* Mesh, char * Name="", medEntityMesh Entity=MED_CELL)
- {
- return new SUPPORT(Mesh,string(Name),Entity);
- }
+ SUPPORT(MESH* Mesh, std::string Name="", medEntityMesh Entity=MED_CELL);
+
+ void setpartial(std::string Description, int NumberOfGeometricType,
+ int TotalNumberOfElements, medGeometryElement *GeometricType,
+ int *NumberOfElements, int *NumberValue);
+
+ std::string getName() const;
+
+ void setName(std::string Name);
+ std::string getDescription();
+
+ void setDescription(std::string Description);
+
+ %extend {
%newobject __str__();
const char* __str__()
{
return returned;
}
- void setpartial(char * Description, int NumberOfGeometricType,
- int TotalNumberOfElements, medGeometryElement *GeometricType,
- int *NumberOfElements, int *NumberValue)
- {
- self->setpartial(string(Description), NumberOfGeometricType,
- TotalNumberOfElements, GeometricType,
- NumberOfElements, NumberValue);
- }
-
- void setName(char * Name)
- {
- self->setName(string(Name));
- }
-
- %newobject getName();
- const char * getName()
- {
- string tmp_str = self->getName();
- char * tmp = new char[strlen(tmp_str.c_str())+1];
- strcpy(tmp,tmp_str.c_str());
- return tmp;
- }
-
- void setDescription(char * Description)
- {
- self->setDescription(string(Description));
- }
-
- %newobject getDescription();
- const char * getDescription()
- {
- string tmp_str = self->getDescription();
- char * tmp = new char[strlen(tmp_str.c_str())+1];
- strcpy(tmp,tmp_str.c_str());
- return tmp;
- }
-
PyObject * getTypes()
{
const medGeometryElement * types = self->getTypes();
int size = self->getNumberOfTypes();
- TYPEMAP_OUTPUT_ARRAY( types, size, PyInt_FromLong, SUPPORT::getTypes );
+ TYPEMAP_OUTPUT_ARRAY(types, size, PyInt_FromLong, SUPPORT::getTypes);
}
PyObject * getNumber(medGeometryElement GeometricType)
{
const int * number = self->getNumber(GeometricType);
int size = self->getNumberOfElements(GeometricType);
- TYPEMAP_OUTPUT_ARRAY( number, size, PyInt_FromLong, SUPPORT::getNumber );
+ TYPEMAP_OUTPUT_ARRAY(number, size, PyInt_FromLong,
+ SUPPORT::getNumber);
}
PyObject * getNumberIndex()
{
const int * numberindex = self->getNumberIndex();
int size = (self->getNumberOfElements(MED_ALL_ELEMENTS))+1;
- TYPEMAP_OUTPUT_ARRAY( numberindex, size, PyInt_FromLong, SUPPORT::getNumberIndex );
+ TYPEMAP_OUTPUT_ARRAY(numberindex, size, PyInt_FromLong,
+ SUPPORT::getNumberIndex);
}
+
%newobject getComplement() const;
SUPPORT *getComplement() const
{
int getNumberOfGroups() const;
- %extend {
- FAMILY(MESH* Mesh, int Identifier, char * Name, int NumberOfAttribute,
- int *AttributeIdentifier, int *AttributeValue,
- char * AttributeDescription, int NumberOfGroup,
- char * GroupName, int * MEDArrayNodeFamily,
- int ** MEDArrayCellFamily, int ** MEDArrayFaceFamily,
- int ** MEDArrayEdgeFamily)
- {
- return new FAMILY(Mesh,Identifier,string(Name),NumberOfAttribute,
- AttributeIdentifier,AttributeValue,
- string(AttributeDescription),NumberOfGroup,
- string(GroupName), MEDArrayNodeFamily,
- MEDArrayCellFamily, MEDArrayFaceFamily,
- MEDArrayEdgeFamily);
- }
+ FAMILY(MESH* Mesh, int Identifier, std::string Name, int NumberOfAttribute,
+ int *AttributeIdentifier, int *AttributeValue,
+ std::string AttributeDescription, int NumberOfGroup,
+ std::string GroupName, int * MEDArrayNodeFamily,
+ int ** MEDArrayCellFamily, int ** MEDArrayFaceFamily,
+ int ** MEDArrayEdgeFamily);
+ std::string getAttributeDescription(int i);
+
+ std::string getGroupName(int i);
+
+ %extend {
%newobject __str__();
const char* __str__()
{
return strdup(mess.str().c_str());
}
- %newobject getAttributeDescription(int );
- const char * getAttributeDescription(int i)
- {
- string tmp_str = self->getAttributeDescription(i);
- char * tmp = new char[strlen(tmp_str.c_str())+1];
- strcpy(tmp,tmp_str.c_str());
- return tmp;
- }
-
- %newobject getGroupName(int );
- const char * getGroupName(int i)
- {
- string tmp_str = self->getGroupName(i);
- char * tmp = new char[strlen(tmp_str.c_str())+1];
- strcpy(tmp,tmp_str.c_str());
- return tmp;
- }
-
PyObject * getAttributesIdentifiers()
{
const int * attributesids = self->getAttributesIdentifiers();
int size = self->getNumberOfAttributes();
- TYPEMAP_OUTPUT_ARRAY(attributesids,size,PyInt_FromLong,FAMILY::getAttributesIdentifiers );
+ TYPEMAP_OUTPUT_ARRAY(attributesids,size,PyInt_FromLong,
+ FAMILY::getAttributesIdentifiers);
}
PyObject * getAttributesValues()
{
const int * attributesvals = self->getAttributesValues();
int size = self->getNumberOfAttributes();
- TYPEMAP_OUTPUT_ARRAY(attributesvals,size,PyInt_FromLong,FAMILY::getAttributesValues );
+ TYPEMAP_OUTPUT_ARRAY(attributesvals,size,PyInt_FromLong,
+ FAMILY::getAttributesValues);
}
}
};
-
-
-
class FIELD_
{
public:
- // FIELD_(const SUPPORT * Support, const int NumberOfComponents);
+ FIELD_(const SUPPORT * Support, const int NumberOfComponents);
~FIELD_();
void setOrderNumber (int OrderNumber);
int getOrderNumber() const;
- void setValueType(med_type_champ ValueType) ;
med_type_champ getValueType() ;
+ medModeSwitch getInterlacingType();
+
SUPPORT * getSupport();
void setSupport(SUPPORT * support);
void setNumberOfValues(int NumberOfValues);
int getNumberOfValues() const;
- string getName() const;
- string getDescription() const;
- string getComponentName(int i) const;
- string getComponentDescription(int i) const;
- string getMEDComponentUnit(int i) const;
- void setName(string Name);
- void setComponentName(int i, string ComponentName);
- void setMEDComponentUnit(int i, string MEDComponentUnit);
- void setDescription(string Description);
- void setComponentDescription(int i, string ComponentDescription);
+ std::string getName() const;
+
+ std::string getDescription() const;
+
+ std::string getComponentName(int i) const;
+
+ std::string getComponentDescription(int i) const;
+
+ std::string getMEDComponentUnit(int i) const;
+
+ void setName(std::string Name);
+
+ void setComponentName(int i, std::string ComponentName);
+
+ void setMEDComponentUnit(int i, std::string MEDComponentUnit);
+
+ void setDescription(std::string Description);
+
+ void setComponentDescription(int i, std::string ComponentDescription);
+
+ int addDriver(driverTypes driverType,
+ const std::string& fileName="Default File Name.med",
+ const std::string& driverName="Default Field Name",
+ med_mode_acces access=MED_REMP);
%extend {
- int addDriver(driverTypes driverType,
- char * fileName="Default File Name.med",
- char * driverName="Default Field Name",
- med_mode_acces access=MED_REMP)
- {
- return self->addDriver(driverType,string(fileName),
- string(driverName),access);
- }
%newobject getSupportAndOwner();
SUPPORT * getSupportAndOwner()
{
}
};
-template< class T1 >
-class FIELD : public FIELD_
+/*
+ Class FIELD has now two template parameters T1 is a double or an int
+ INTERLACING_TAG is FullInterlace or NoInterlace
+*/
+
+template<class T1, class INTERLACING_TAG> class FIELD : public FIELD_
{
public:
~FIELD();
FIELD(const SUPPORT * Support, const int NumberOfComponents);
- /*
- WARNING:
- other constructor of FIELD (C++ FIELD<T1>) object.
- Only one constructor could be wrapped and
- the others commented out when using
- SWIG with a version lesser than 1.3
- */
-
FIELD();
FIELD(const FIELD & m);
+ FIELD(const SUPPORT * Support, driverTypes driverType,
+ const std::string& fileName, const std::string& fieldName,
+ const int iterationNumber, const int orderNumber);
+
void read(int index=0);
T1 getValueIJ(int i,int j) const;
- void setValue(medModeSwitch mode, T1* value);
+ void setValue(T1* value);
+
+ void setRow( int i, T1 * value);
- void setValueI(medModeSwitch mode, int i, T1* value);
+ void setColumn( int i, T1 * value);
void setValueIJ(int i, int j, T1 value);
void applyPow(T1 scalar);
- T1 normMax();
- T1 norm2();
- T1 normL2(int component, const FIELD<double> * p_field_volume=NULL) const;
- T1 normL2(const FIELD<double> * p_field_volume=NULL) const;
- T1 normL1(int component, const FIELD<double> * p_field_volume=NULL) const;
- T1 normL1(const FIELD<double> * p_field_volume=NULL) const;
+ double normMax();
+
+ double norm2();
+
+ double normL2(int component,const FIELD<double, FullInterlace> *
+ p_field_volume=NULL) const;
+
+ double normL2(const FIELD<double, FullInterlace> *
+ p_field_volume=NULL) const;
+
+ double normL1(int component, const FIELD<double, FullInterlace> *
+ p_field_volume=NULL) const;
+ double normL1(const FIELD<double, FullInterlace> *
+ p_field_volume=NULL) const;
+
+ void write(int index=0, const std::string& driverName="");
+
+ void writeAppend(int index=0, const std::string& driverName="");
%extend {
PyObject * applyPyFunc( PyObject * func )
- {
+ {
MESSAGE("Appel de applyPyFunc");
if (!PyCallable_Check(func)) {
- PyErr_SetString(PyExc_TypeError, "FIELD.applyPyFunc prend en argument une fonction");
- return NULL;
+ PyErr_SetString(PyExc_TypeError, "FIELD.applyPyFunc prend en argument une fonction");
+ return NULL;
}
int nComp=self->getNumberOfComponents();
int nVal=self->getNumberOfValues();
for (int i=1; i!=nVal+1; ++i)
- for ( int j=1 ;j!=nComp+1 ;++j )
+ for ( int j=1 ;j!=nComp+1 ;++j )
{
self->setValueIJ(i,j, Binding<T1>::Functor( func, self->getValueIJ(i,j) ) );
}
- PyObject * result = Binding<double>::Traducer(nComp*nVal);
- return result;
- }
- %newobject __add__(const FIELD & );
- FIELD * __add__(const FIELD & m)
+ PyObject * result = Binding<double>::Traducer(nComp*nVal);
+ return result;
+ }
+
+ %newobject __add__(const FIELD<T1, INTERLACING_TAG> & );
+ FIELD<T1, INTERLACING_TAG> * __add__(const FIELD<T1, INTERLACING_TAG> & m)
{
MESSAGE("operator + : Creation of the addition of two FIELDs");
-
- FIELD<T1>* result = FIELD<T1>::add( *(FIELD<T1>*)self , (FIELD<T1>&)m );
- return (FIELD<T1>*) result;
+
+ FIELD<T1, INTERLACING_TAG>* result =
+ FIELD<T1, INTERLACING_TAG>::add( *(FIELD<T1, INTERLACING_TAG>*)self ,
+ (FIELD<T1, INTERLACING_TAG>&)m );
+ return (FIELD<T1, INTERLACING_TAG>*) result;
}
- %newobject __sub__(const FIELD & );
- FIELD * __sub__(const FIELD & m)
+ %newobject __sub__(const FIELD<T1, INTERLACING_TAG> & );
+ FIELD<T1, INTERLACING_TAG> * __sub__(const FIELD<T1, INTERLACING_TAG> & m)
{
MESSAGE("operator - : Creation of the substraction of two FIELDs");
- FIELD<T1>* result = FIELD<T1>::sub( *(FIELD<T1>*)self , (FIELD<T1>&)m );
- return (FIELD<T1>*) result;
+ FIELD<T1, INTERLACING_TAG>* result =
+ FIELD<T1, INTERLACING_TAG>::sub( *(FIELD<T1, INTERLACING_TAG>*)self ,
+ (FIELD<T1, INTERLACING_TAG>&)m );
+ return (FIELD<T1, INTERLACING_TAG>*) result;
}
- %newobject __mul__(const FIELD & );
- FIELD * __mul__(const FIELD & m)
+ %newobject __mul__(const FIELD<T1, INTERLACING_TAG> & );
+ FIELD<T1, INTERLACING_TAG> * __mul__(const FIELD<T1, INTERLACING_TAG> & m)
{
MESSAGE("operator * : Creation of the multiplication of two FIELDs");
- FIELD<T1>* result = FIELD<T1>::mul( *(FIELD<T1>*)self , (FIELD<T1>&)m );
- return (FIELD<T1>*) result;
+ FIELD<T1, INTERLACING_TAG>* result =
+ FIELD<T1, INTERLACING_TAG>::mul( *(FIELD<T1, INTERLACING_TAG>*)self ,
+ (FIELD<T1, INTERLACING_TAG>&)m );
+ return (FIELD<T1, INTERLACING_TAG>*) result;
}
- %newobject __div__(const FIELD & );
- FIELD * __div__(const FIELD & m)
+ %newobject __div__(const FIELD<T1, INTERLACING_TAG> & );
+ FIELD<T1, INTERLACING_TAG> * __div__(const FIELD<T1, INTERLACING_TAG> & m)
{
MESSAGE("operator / : Creation of the division of two FIELDs");
- FIELD<T1>* result = FIELD<T1>::div( *(FIELD<T1>*)self , (FIELD<T1>&)m );
- return (FIELD<T1>*) result;
+ FIELD<T1, INTERLACING_TAG>* result =
+ FIELD<T1, INTERLACING_TAG>::div( *(FIELD<T1, INTERLACING_TAG>*)self ,
+ (FIELD<T1, INTERLACING_TAG>&)m );
+ return (FIELD<T1, INTERLACING_TAG>*) result;
}
- %newobject addDeep(const FIELDINT & );
- FIELD * addDeep(const FIELD & m)
+ %newobject addDeep(const FIELD<T1, INTERLACING_TAG> & );
+ FIELD<T1, INTERLACING_TAG> * addDeep(const FIELD<T1, INTERLACING_TAG> & m)
{
MESSAGE("operator + : Creation of the addition of two FIELDINTs");
- FIELD<T1>* result = FIELD<T1>::addDeep( *(FIELD<T1>*)self , (FIELD<T1>&)m );
- return (FIELD<T1>*) result;
+ FIELD<T1, INTERLACING_TAG>* result =
+ FIELD<T1, INTERLACING_TAG>::addDeep( *(FIELD<T1, INTERLACING_TAG>*)self ,
+ (FIELD<T1, INTERLACING_TAG>&)m );
+ return (FIELD<T1, INTERLACING_TAG>*) result;
}
- %newobject subDeep(const FIELD & );
- FIELD * subDeep(const FIELD & m)
+ %newobject subDeep(const FIELD<T1, INTERLACING_TAG> & );
+ FIELD<T1, INTERLACING_TAG> * subDeep(const FIELD<T1, INTERLACING_TAG> & m)
{
MESSAGE("operator - : Creation of the substraction of two FIELDs");
- FIELD<T1>* result = FIELD<T1>::subDeep( *(FIELD<T1>*)self , (FIELD<T1>&)m );
- return (FIELD<T1>*) result;
+ FIELD<T1, INTERLACING_TAG>* result =
+ FIELD<T1, INTERLACING_TAG>::subDeep( *(FIELD<T1, INTERLACING_TAG>*)self ,
+ (FIELD<T1, INTERLACING_TAG>&)m );
+ return (FIELD<T1, INTERLACING_TAG>*) result;
}
- %newobject mulDeep(const FIELD & );
- FIELD * mulDeep(const FIELD & m)
+ %newobject mulDeep(const FIELD<T1, INTERLACING_TAG> & );
+ FIELD<T1, INTERLACING_TAG> * mulDeep(const FIELD<T1, INTERLACING_TAG> & m)
{
MESSAGE("operator * : Creation of the multiplication of two FIELDs");
- FIELD<T1>* result = FIELD<T1>::mulDeep( *(FIELD<T1>*)self , (FIELD<T1>&)m );
- return (FIELD<T1>*) result;
+ FIELD<T1, INTERLACING_TAG>* result =
+ FIELD<T1, INTERLACING_TAG>::mulDeep( *(FIELD<T1, INTERLACING_TAG>*)self ,
+ (FIELD<T1, INTERLACING_TAG>&)m );
+ return (FIELD<T1, INTERLACING_TAG>*) result;
}
- %newobject divDeep(const FIELD & );
- FIELD * divDeep(const FIELD & m)
+ %newobject divDeep(const FIELD<T1, INTERLACING_TAG> & );
+ FIELD<T1, INTERLACING_TAG> * divDeep(const FIELD<T1, INTERLACING_TAG> & m)
{
MESSAGE("operator / : Creation of the division of two FIELDs");
- FIELD<T1>* result = FIELD<T1>::divDeep( *(FIELD<T1>*)self , (FIELD<T1>&)m );
- return (FIELD<T1>*) result;
+ FIELD<T1, INTERLACING_TAG>* result =
+ FIELD<T1, INTERLACING_TAG>::divDeep( *(FIELD<T1, INTERLACING_TAG>*)self ,
+ (FIELD<T1, INTERLACING_TAG>&)m );
+ return (FIELD<T1, INTERLACING_TAG>*) result;
}
- FIELD (const SUPPORT * Support, driverTypes driverType,
- char * fileName, char * fieldName,
- const int iterationNumber,
- const int orderNumber)
+ PyObject * getValue()
{
- return new FIELD<T1>(Support, driverType, string(fileName),
- string(fieldName),iterationNumber,
- orderNumber);
- }
+ int size = (self->getNumberOfComponents())*
+ ((self->getSupport())->getNumberOfElements(MED_ALL_ELEMENTS));
- void write(int index=0, char * driverName="")
- {
- self->write(index, string(driverName));
+ const T1 * value = self->getValue();
+
+ TYPEMAP_OUTPUT_ARRAY(value, size, Binding< T1 >::Traducer,
+ FIELD::getValue);
}
- void writeAppend(int index=0, char * driverName="")
+ // this method replaces getValueI() in FullInterlace mode
+ /* %newobject getRow(int );*/
+ PyObject * getRow(int index)
{
- self->writeAppend(index, string(driverName));
+ int size = self->getNumberOfComponents();
+
+ const T1 * value = self->getRow(index);
+
+ TYPEMAP_OUTPUT_ARRAY(value, size, Binding< T1 >::Traducer,
+ FIELD::getRow);
}
- PyObject * getValue(medModeSwitch Mode)
+ // this method replaces getValueI() in NInterlace mode
+ /*%newobject getColum(int );*/
+ PyObject * getColumn(int index)
{
- int size = (self->getNumberOfComponents())*
- ((self->getSupport())->getNumberOfElements(MED_ALL_ELEMENTS));
+ int size = (self->getSupport())->getNumberOfElements(MED_ALL_ELEMENTS);
- const T1 * value = self->getValue(Mode);
+ const T1 * value = self->getColumn(index);
- TYPEMAP_OUTPUT_ARRAY( value, size, Binding< T1 >::Traducer, FIELD::getValue );
+ TYPEMAP_OUTPUT_ARRAY(value, size, Binding< T1 >::Traducer,
+ FIELD::getColumn);
}
- %newobject getValueI(medModeSwitch , int );
- PyObject * getValueI(medModeSwitch Mode, int index)
+ /*
+ %newobject getValueI(int );
+ PyObject * getValueI(int index)
{
int size = self->getNumberOfComponents();
+ medModeSwitch Mode = self->getInterlacingType();
+
if ( Mode == MED_NO_INTERLACE ) size = (self->getSupport())->getNumberOfElements(MED_ALL_ELEMENTS);
- const T1 * value = self->getValueI(Mode,index);
+ const T1 * value = self->getValueI(index);
- TYPEMAP_OUTPUT_ARRAY( value, size, Binding< T1 >::Traducer, FIELD::getValueI );
+ TYPEMAP_OUTPUT_ARRAY(value, size, Binding< T1 >::Traducer,
+ FIELD::getValueI);
}
+ */
void allocValue2(int NumberOfComponents, int LengthValue)
{
}
%newobject extract(const SUPPORT *subSupport);
- FIELD *extract(const SUPPORT *subSupport)
+ FIELD<T1, INTERLACING_TAG> *extract(const SUPPORT *subSupport)
{
- FIELD<T1>* result=self->extract(subSupport);
- return (FIELD<T1> *)result;
+ FIELD<T1, INTERLACING_TAG>* result=self->extract(subSupport);
+ return (FIELD<T1, INTERLACING_TAG> *)result;
}
}
};
-%template (FIELDDOUBLE) FIELD <double>;
-%template (FIELDINT) FIELD <int>;
+/*%template(FIELDDOUBLEFULLINTERLACE) FIELD<double, FullInterlace>;*/
+%template(FIELDDOUBLE) FIELD<double, FullInterlace>;
+%template(FIELDDOUBLENOINTERLACE) FIELD<double, NoInterlace>;
+/*%template(FIELDINTFULLINTERLACE) FIELD<int, FullInterlace>;*/
+%template(FIELDINT) FIELD<int, FullInterlace>;
+%template(FIELDINTNOINTERLACE) FIELD<int, NoInterlace>;
class GROUP : public SUPPORT
{
~GROUP();
void setNumberOfFamilies(int numberOfFamilies);
- void setFamilies(vector<FAMILY*> Family);
+ void setFamilies(vector< FAMILY * > Family);
int getNumberOfFamilies() const ;
- vector<FAMILY*> getFamilies() const ;
+ vector< FAMILY * > getFamilies() const ;
FAMILY * getFamily(int i) const ;
};
class MESH
{
public :
- /*
- WARNING:
- other constructor of MESH object.
- Only one constructor could be wrapped and
- the others commented out when using
- SWIG with a version lesser than 1.3
- */
-
MESH();
~MESH();
int getElementContainingPoint(const double *coord);
int getNumberOfTypesWithPoly(medEntityMesh Entity);
+
int getNumberOfPolygons();
+
int getNumberOfPolyhedronFaces();
+
int getNumberOfPolyhedron();
+
int getNumberOfElementsWithPoly(medEntityMesh Entity,
medGeometryElement Type);
+
bool existPolygonsConnectivity(medConnectivity ConnectivityType,
medEntityMesh Entity);
+
bool existPolyhedronConnectivity(medConnectivity ConnectivityType,
medEntityMesh Entity);
+
medGeometryElement getElementTypeWithPoly(medEntityMesh Entity,int Number);
+
+ std::string getName() const;
%extend {
%newobject getBoundaryElements(medEntityMesh );
return self->getSkin(Support3D);
}
- %newobject mergeSupports(const vector<SUPPORT *> );
- SUPPORT * mergeSupports(const vector<SUPPORT *> Supports)
+ %newobject mergeSupports(const vector< SUPPORT * > );
+ SUPPORT * mergeSupports(const vector< SUPPORT * > Supports)
{
return self->mergeSupports(Supports);
}
- %newobject intersectSupports(const vector<SUPPORT *> );
- SUPPORT * intersectSupports(const vector<SUPPORT *> Supports)
+ %newobject intersectSupports(const vector< SUPPORT * > );
+ SUPPORT * intersectSupports(const vector< SUPPORT * > Supports)
{
return self->intersectSupports(Supports);
}
%newobject mergeFieldsDouble(const vector< FIELD<double>* > others);
- FIELDDOUBLE * mergeFieldsDouble(const vector< FIELD<double>* > others)
+ FIELD<double, FullInterlace> * mergeFieldsDouble(const vector< FIELD<double>* > others)
{
- return (FIELDDOUBLE *)self->mergeFields<double>(others);
+ return (FIELD<double, FullInterlace> *)self->mergeFields<double>(others);
}
%newobject mergeFieldsInt(const vector< FIELD<int>* > others);
- FIELDINT * mergeFieldsInt(const vector< FIELD<int>* > others)
+ FIELD<int, FullInterlace> * mergeFieldsInt(const vector< FIELD<int>* > others)
{
- return (FIELDINT *)self->mergeFields<int>(others);
+ return (FIELD<int, FullInterlace> *)self->mergeFields<int>(others);
}
CELLMODEL getCellType(medEntityMesh Entity,int i)
self->setName(string(name));
}
- %newobject getName();
- const char * getName()
- {
- string tmp_str = self->getName();
- char * tmp = new char[strlen(tmp_str.c_str())+1];
- strcpy(tmp,tmp_str.c_str());
- return tmp;
- }
-
%newobject getCoordinatesSystem();
const char * getCoordinatesSystem()
{
{
const string * array = self->getCoordinatesNames();
int size = self->getSpaceDimension();
- TYPEMAP_OUTPUT_ARRAY( array, size, PyString_FromStdString, MESH::getCoordinatesNames );
+ TYPEMAP_OUTPUT_ARRAY(array, size, PyString_FromStdString,
+ MESH::getCoordinatesNames);
}
PyObject * getCoordinatesUnits()
{
const string * array = self->getCoordinatesUnits();
int size = self->getSpaceDimension();
- TYPEMAP_OUTPUT_ARRAY( array, size, PyString_FromStdString, MESH::getCoordinatesUnits );
+ TYPEMAP_OUTPUT_ARRAY(array, size, PyString_FromStdString,
+ MESH::getCoordinatesUnits);
}
PyObject * getCoordinates(medModeSwitch Mode)
{
const double * array = self->getCoordinates(Mode);
int size = (self->getSpaceDimension())*(self->getNumberOfNodes());
- TYPEMAP_OUTPUT_ARRAY( array, size, PyFloat_FromDouble, MESH::getCoordinates );
+ TYPEMAP_OUTPUT_ARRAY(array, size, PyFloat_FromDouble,
+ MESH::getCoordinates);
}
PyObject * getTypes(medEntityMesh Entity)
{
const medGeometryElement * types = self->getTypes(Entity);
int size = self->getNumberOfTypes(Entity);
- TYPEMAP_OUTPUT_ARRAY( types, size, PyInt_FromLong, MESH::getTypes );
+ TYPEMAP_OUTPUT_ARRAY(types, size, PyInt_FromLong, MESH::getTypes);
}
PyObject * getConnectivity(medModeSwitch Mode,
const int * connectivity = self->getConnectivity(Mode,ConnectivityType,
Entity,Type);
int size = self->getConnectivityLength(Mode,ConnectivityType,Entity,Type);
- TYPEMAP_OUTPUT_ARRAY( connectivity, size, PyInt_FromLong, MESH::getConnectivity );
+ TYPEMAP_OUTPUT_ARRAY(connectivity, size, PyInt_FromLong,
+ MESH::getConnectivity );
}
PyObject * getConnectivityIndex(medConnectivity ConnectivityType,
const int * connectivity_index =
self->getConnectivityIndex(ConnectivityType,Entity);
int size = (self->getNumberOfElements(Entity,MED_ALL_ELEMENTS))+1;
- TYPEMAP_OUTPUT_ARRAY(connectivity_index,size,PyInt_FromLong,MESH::getConnectivityIndex);
+ TYPEMAP_OUTPUT_ARRAY(connectivity_index,size,PyInt_FromLong,
+ MESH::getConnectivityIndex);
}
PyObject * getReverseConnectivity(medConnectivity ConnectivityType,
const int * reverseconnectivity =
self->getReverseConnectivity(ConnectivityType,Entity);
int size = self->getReverseConnectivityLength(ConnectivityType,Entity);
- TYPEMAP_OUTPUT_ARRAY(reverseconnectivity,size,PyInt_FromLong,MESH::getReverseConnectivity);
+ TYPEMAP_OUTPUT_ARRAY(reverseconnectivity, size, PyInt_FromLong,
+ MESH::getReverseConnectivity);
}
PyObject * getReverseConnectivityIndex(medConnectivity ConnectivityType,
const int * reverseconnectivity_index =
self->getReverseConnectivityIndex(ConnectivityType,Entity);
int size=self->getReverseConnectivityIndexLength(ConnectivityType,Entity);
- TYPEMAP_OUTPUT_ARRAY(reverseconnectivity_index,size,PyInt_FromLong,MESH::getReverseConnectivityIndex);
+ TYPEMAP_OUTPUT_ARRAY(reverseconnectivity_index,size, PyInt_FromLong,
+ MESH::getReverseConnectivityIndex);
}
PyObject * getGlobalNumberingIndex(medEntityMesh Entity)
const int * numberingIndex = self->getGlobalNumberingIndex(Entity);
int nbOfTypes = self->getNumberOfTypes(Entity);
int size = nbOfTypes+1;
- TYPEMAP_OUTPUT_ARRAY(numberingIndex,size,PyInt_FromLong,MESH::getGlobalNumberingIndex);
+ TYPEMAP_OUTPUT_ARRAY(numberingIndex, size, PyInt_FromLong,
+ MESH::getGlobalNumberingIndex);
}
-
PyObject * getPolygonsConnectivity(medConnectivity ConnectivityType,
medEntityMesh Entity)
{
const int * array = self->getPolygonsConnectivity(ConnectivityType,Entity);
int size = self->getPolygonsConnectivityLength(ConnectivityType, Entity);
- TYPEMAP_OUTPUT_ARRAY(array,size,PyInt_FromLong,MESH::getPolygonsConnectivity);
+ TYPEMAP_OUTPUT_ARRAY(array, size, PyInt_FromLong,
+ MESH::getPolygonsConnectivity);
}
+
PyObject * getPolygonsConnectivityIndex(medConnectivity ConnectivityType,
medEntityMesh Entity)
{
const int * array = self->getPolygonsConnectivityIndex(ConnectivityType,Entity);
int size = self->getNumberOfPolygons() + 1;
- TYPEMAP_OUTPUT_ARRAY(array,size,PyInt_FromLong,MESH::getPolygonsConnectivity);
+ TYPEMAP_OUTPUT_ARRAY(array, size, PyInt_FromLong,
+ MESH::getPolygonsConnectivity);
}
+
PyObject * getPolyhedronConnectivity(medConnectivity ConnectivityType)
{
const int * array = self->getPolyhedronConnectivity(ConnectivityType);
int size = self->getPolyhedronConnectivityLength(ConnectivityType);
- TYPEMAP_OUTPUT_ARRAY(array,size,PyInt_FromLong,MESH::getPolygonsConnectivity);
+ TYPEMAP_OUTPUT_ARRAY(array, size, PyInt_FromLong,
+ MESH::getPolygonsConnectivity);
}
+
PyObject * getPolyhedronIndex(medConnectivity ConnectivityType)
{
const int * array = self->getPolyhedronIndex(ConnectivityType);
int size = self->getNumberOfPolyhedron() + 1;
- TYPEMAP_OUTPUT_ARRAY(array,size,PyInt_FromLong,MESH::getPolyhedronIndex);
+ TYPEMAP_OUTPUT_ARRAY(array, size, PyInt_FromLong,
+ MESH::getPolyhedronIndex);
}
+
PyObject * getPolyhedronFacesIndex()
{
const int * array = self->getPolyhedronFacesIndex();
int size = self->getNumberOfPolyhedronFaces() + 1;
- TYPEMAP_OUTPUT_ARRAY(array,size,PyInt_FromLong,MESH::getPolyhedronFacesIndex);
+ TYPEMAP_OUTPUT_ARRAY(array, size, PyInt_FromLong,
+ MESH::getPolyhedronFacesIndex);
}
+
PyObject * getTypesWithPoly(medEntityMesh Entity)
{
medGeometryElement * array = self->getTypesWithPoly(Entity);
int size = self->getNumberOfTypesWithPoly(Entity);
- TYPEMAP_OUTPUT_ARRAY(array,size,PyInt_FromLong,MESH::getTypesWithPoly);
+ TYPEMAP_OUTPUT_ARRAY(array, size, PyInt_FromLong,
+ MESH::getTypesWithPoly);
delete [] array;
}
%newobject getVolume(const SUPPORT * );
- FIELDDOUBLE * getVolume(const SUPPORT * Support)
+ FIELD<double, FullInterlace> * getVolume(const SUPPORT * Support)
{
- return (FIELDDOUBLE *) self->getVolume(Support);
+ return (FIELD<double, FullInterlace> *) self->getVolume(Support);
}
%newobject getArea(const SUPPORT * );
- FIELDDOUBLE * getArea(const SUPPORT * Support)
+ FIELD<double, FullInterlace> * getArea(const SUPPORT * Support)
{
- return (FIELDDOUBLE *) self->getArea(Support);
+ return (FIELD<double, FullInterlace> *) self->getArea(Support);
}
%newobject getLength(const SUPPORT * );
- FIELDDOUBLE * getLength(const SUPPORT * Support)
+ FIELD<double, FullInterlace> * getLength(const SUPPORT * Support)
{
- return (FIELDDOUBLE *) self->getLength(Support);
+ return (FIELD<double, FullInterlace> *) self->getLength(Support);
}
%newobject getNormal(const SUPPORT * );
- FIELDDOUBLE * getNormal(const SUPPORT * Support)
+ FIELD<double, FullInterlace> * getNormal(const SUPPORT * Support)
{
- return (FIELDDOUBLE *) self->getNormal(Support);
+ return (FIELD<double, FullInterlace> *) self->getNormal(Support);
}
%newobject getBarycenter(const SUPPORT * );
- FIELDDOUBLE * getBarycenter(const SUPPORT * Support)
+ FIELD<double, FullInterlace> * getBarycenter(const SUPPORT * Support)
{
- return (FIELDDOUBLE *) self->getBarycenter(Support);
+ return (FIELD<double, FullInterlace> *) self->getBarycenter(Support);
}
}
} ;
void setSpaceDimension (const int SpaceDimension) ;
+ void setMeshDimension (const int MeshDimension) ;
+
void setNumberOfNodes (const int NumberOfNodes) ;
void setNumberOfTypes (const int NumberOfTypes,
void addMesh ( MESH * const ptrMesh );
%extend {
- /*
- WARNING:
- other constructor of MED object.
- Only one constructor could be wrapped and
- the others commented out when using
- SWIG with a version lesser than 1.3
- */
-
MED(driverTypes driverType, char * fileName)
{
return new MED(driverType,string(fileName));
%template (ASCII_FIELDDOUBLE_DRIVER) ASCII_FIELD_DRIVER< double >;
%template (ASCII_FIELDINT_DRIVER) ASCII_FIELD_DRIVER< int >;
-
-
%{
-template <class T> FIELD<T> * createFieldScalarProduct(FIELD<T> * field1, FIELD<T> * field2) {
- return (FIELD<T> *) FIELD<T>::scalarProduct( (FIELD<T>)*field1, (FIELD<T>)*field2);
-}
-template <class T> FIELD<T> * createFieldScalarProductDeep(FIELD<T> * field1, FIELD<T> * field2) {
- return (FIELD<T>*) FIELD<T>::scalarProduct( (FIELD<T>)*field1, (FIELD<T>)*field2, true);
-}
-template<class T> FIELD<T> * createFieldFromField(FIELD_ * field) {
- MESSAGE("createFieldFromField : Constructor (for Python API) FIELD<T> with parameter FIELD_");
- MESSAGE("Its returns a proper cast of the input pointer :: FIELD_ --> FIELD<T>");
- return (FIELD<T> *) field;
-}
-%}
-
-template<class T> FIELD<T> * createFieldFromField(FIELD_ * field);
-%template ( createFieldDoubleFromField ) createFieldFromField < double >;
-%template ( createFieldIntFromField ) createFieldFromField < int >;
-
-template <class T> FIELD<T> * createFieldScalarProduct(FIELD<T> * field1, FIELD<T> * field2);
-%newobject createFieldDoubleScalarProduct(FIELDDOUBLE * field1, FIELDDOUBLE * field2) ;
-%newobject createFieldIntScalarProduct(FIELDINT * field1, FIELDINT * field2) ;
-%template ( createFieldDoubleScalarProduct ) createFieldScalarProduct < double >;
-%template ( createFieldIntScalarProduct ) createFieldScalarProduct < int >;
+ template <class T, class INTERLACING_TAG>
+ FIELD<T, INTERLACING_TAG> * createFieldScalarProduct(FIELD<T, INTERLACING_TAG> * field1,
+ FIELD<T, INTERLACING_TAG> * field2)
+ {
+ return (FIELD<T, INTERLACING_TAG> *)
+ FIELD<T, INTERLACING_TAG>::scalarProduct((FIELD<T, INTERLACING_TAG>)*field1,
+ (FIELD<T, INTERLACING_TAG>)*field2);
+ }
-template <class T> FIELD<T> * createFieldScalarProductDeep(FIELD<T> * field1, FIELD<T> * field2);
-%newobject createFieldDoubleScalarProductDeep(FIELDDOUBLE * field1, FIELDDOUBLE * field2) ;
-%newobject createFieldIntScalarProductDeep(FIELDINT * field1, FIELDINT * field2) ;
-%template ( createFieldDoubleScalarProductDeep ) createFieldScalarProductDeep < double >;
-%template ( createFieldIntScalarProductDeep ) createFieldScalarProductDeep < int >;
+ template <class T, class INTERLACING_TAG>
+ FIELD<T, INTERLACING_TAG> * createFieldScalarProductDeep(FIELD<T, INTERLACING_TAG> * field1,
+ FIELD<T, INTERLACING_TAG> * field2)
+ {
+ return (FIELD<T, INTERLACING_TAG>*) FIELD<T, INTERLACING_TAG>::scalarProduct((FIELD<T, INTERLACING_TAG>)*field1,
+ (FIELD<T, INTERLACING_TAG>)*field2, true);
+ }
-%newobject createFieldDoubleFromAnalytic(SUPPORT * , int , PyObject *);
-%newobject createFieldIntFromAnalytic(SUPPORT * , int , PyObject *);
-FIELDDOUBLE * createFieldDoubleFromAnalytic(SUPPORT * Support,
- int NumberOfComponents,
- PyObject * double_function);
-FIELDINT * createFieldIntFromAnalytic(SUPPORT * Support,
- int NumberOfComponents,
- PyObject * integer_function);
+ template<class T, class INTERLACING_TAG>
+ FIELD<T, INTERLACING_TAG> * createTypedFieldFromField(FIELD_ * field)
+ {
+ MESSAGE("createTypedFieldFromField : Constructor (for Python API) FIELD<T> with parameter FIELD_");
+ MESSAGE("Its returns a proper cast of the input pointer :: FIELD_ --> FIELD<T>");
+ return (FIELD<T, INTERLACING_TAG> *) field;
+ }
+%}
+template<class T, class INTERLACING_TAG> FIELD<T, INTERLACING_TAG> * createTypedFieldFromField(FIELD_ * field);
+%template ( createFieldDoubleFromField ) createTypedFieldFromField < double, FullInterlace>;
+%template ( createFieldIntFromField ) createTypedFieldFromField < int, FullInterlace >;
+%template ( createFieldDoubleNoInterlaceFromField ) createTypedFieldFromField < double, NoInterlace>;
+%template ( createFieldIntNoInterlaceFromField ) createTypedFieldFromField < int, NoInterlace >;
+
+template <class T, class INTERLACING_TAG> FIELD<T, INTERLACING_TAG> * createFieldScalarProduct(FIELD<T, INTERLACING_TAG> * field1, FIELD<T, INTERLACING_TAG> * field2);
+%newobject createFieldDoubleScalarProduct ;
+%newobject createFieldIntScalarProduct ;
+%newobject createFieldDoubleNoInterlaceScalarProduct ;
+%newobject createFieldIntNoInterlaceScalarProduct ;
+%template ( createFieldDoubleScalarProduct ) createFieldScalarProduct < double, FullInterlace >;
+%template ( createFieldIntScalarProduct ) createFieldScalarProduct < int, FullInterlace >;
+%template ( createFieldDoubleNoInterlaceScalarProduct ) createFieldScalarProduct < double, NoInterlace >;
+%template ( createFieldIntNoInterlaceScalarProduct ) createFieldScalarProduct < int, NoInterlace >;
+
+template <class T, class INTERLACING_TAG> FIELD<T, INTERLACING_TAG> * createFieldScalarProductDeep(FIELD<T, INTERLACING_TAG> * field1, FIELD<T, INTERLACING_TAG> * field2);
+%newobject createFieldDoubleScalarProductDeep ;
+%newobject createFieldIntScalarProductDeep ;
+%newobject createFieldDoubleNoInterlaceScalarProductDeep ;
+%newobject createFieldIntNoInterlaceScalarProductDeep ;
+%template ( createFieldDoubleScalarProductDeep ) createFieldScalarProductDeep < double, FullInterlace >;
+%template ( createFieldIntScalarProductDeep ) createFieldScalarProductDeep < int, FullInterlace >;
+%template ( createFieldDoubleNoInterlaceScalarProductDeep ) createFieldScalarProductDeep < double, NoInterlace >;
+%template ( createFieldIntNoInterlaceScalarProductDeep ) createFieldScalarProductDeep < int, NoInterlace >;
+
+template<class T, class INTERLACING_TAG> FIELD<T, INTERLACING_TAG> * createFieldFromAnalytic(SUPPORT * Support, int NumberOfComponents, PyObject * double_function);
GRID * createGridFromMesh( MESH * aMesh );
+
%{
GRID * createGridFromMesh( MESH * aMesh )
{
return NULL;
}
- FIELDDOUBLE * createFieldDoubleFromAnalytic(SUPPORT * Support,
- int NumberOfComponents,
- PyObject * double_function)
+ template<class T, class INTERLACING_TAG>
+ FIELD<T, INTERLACING_TAG> * createFieldFromAnalytic(SUPPORT * Support,
+ int NumberOfComponents,
+ PyObject * double_function)
{
- MESSAGE("createFieldDoubleFromAnalytic : Constructor (for Python API) FIELDDOUBLE from an analytic fonction");
- FIELDDOUBLE * fieldDouble = new FIELDDOUBLE(Support,NumberOfComponents);
- MyFunction<double>::_pyFunc=double_function;
- MyFunction<double>::_nbOfComponent=NumberOfComponents;
- MyFunction<double>::_spaceDim=Support->getMesh()->getSpaceDimension();
- fieldDouble->fillFromAnalytic< MyFunction<double>::EvalPy2Cpp >();
- return fieldDouble;
- }
+ MESSAGE("createFieldFromAnalytic : Constructor (for Python API) FIELD from an analytic fonction");
- FIELDINT * createFieldIntFromAnalytic(SUPPORT * Support,
- int NumberOfComponents,
- PyObject * integer_function)
- {
- MESSAGE("createFieldIntFromAnalytic : Constructor (for Python API) FIELDINT from an analytic fonction");
- 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;
+ FIELD<T, INTERLACING_TAG> * fieldAnalytic =
+ new FIELD<T, INTERLACING_TAG>(Support, NumberOfComponents);
+
+ MyFunction<T>::_pyFunc=double_function;
+ MyFunction<T>::_nbOfComponent=NumberOfComponents;
+ MyFunction<T>::_spaceDim=Support->getMesh()->getSpaceDimension();
+ fieldAnalytic->fillFromAnalytic(MyFunction<T>::EvalPy2Cpp);
+ return fieldAnalytic;
}
%}
+
+%template (createFieldDoubleFromAnalytic) createFieldFromAnalytic<double, FullInterlace>;
+%template (createFieldIntFromAnalytic) createFieldFromAnalytic<int, FullInterlace>;
+%template (createFieldDoubleNoInterlaceFromAnalytic) createFieldFromAnalytic<double, NoInterlace>;
+%template (createFieldIntNoInterlaceFromAnalytic) createFieldFromAnalytic<int, NoInterlace>;
from libMEDMEM_Swig import *
-# file name to save the generated MESH(ING)
+# files name to save the generated MESH(ING) in different format
+# Med V2.1 Med V2.2 and vtk
-medFileName = "toto.med"
+med21FileName = "toto21.med"
+
+med22FileName = "toto22.med"
vtkFileName = "toto.vtk"
myMeshing.setConnectivity(connectivityQuad,entity,types[1])
-# edge part
+meshDimension = spaceDimension # because there 3D cells in the mesh
+myMeshing.setMeshDimension(meshDimension)
-# saving of the generated mesh in MED and VTK format
+# edge part
# adding GROUPs
# on Node
myMeshing.addGroup(myGroup)
-idMed = myMeshing.addDriver(MED_DRIVER,medFileName,myMeshing.getName())
-myMeshing.write(idMed)
+# saving of the generated mesh in MED 2.1, 2.2 and VTK format
+
+medFileVersion = getMedFileVersionForWriting()
+print "Med File Version For Writing ",medFileVersion
+
+if (medFileVersion == V22):
+ setMedFileVersionForWriting(V21)
+
+idMedV21 = myMeshing.addDriver(MED_DRIVER,med21FileName,myMeshing.getName())
+myMeshing.write(idMedV21)
+
+medFileVersion = getMedFileVersionForWriting()
+if (medFileVersion == V21):
+ setMedFileVersionForWriting(V22)
+
+idMedV22 = myMeshing.addDriver(MED_DRIVER,med22FileName,myMeshing.getName())
+myMeshing.write(idMedV22)
idVtk = myMeshing.addDriver(VTK_DRIVER,vtkFileName,myMeshing.getName())
myMeshing.write(idVtk)
fieldIntVectorOnCells.setValueIJ(i+1,2,valueInt2)
fieldIntVectorOnCells.setValueIJ(i+1,3,valueInt3)
-idMed = fieldDoubleScalarOnNodes.addDriver(MED_DRIVER,medFileName,fieldDoubleScalarOnNodes.getName())
-fieldDoubleScalarOnNodes.write(idMed)
+medFileVersion = getMedFileVersionForWriting()
+print "Med File Version For Writing ",medFileVersion
+
+if (medFileVersion == V22):
+ setMedFileVersionForWriting(V21)
+
+idMedV21 = fieldDoubleScalarOnNodes.addDriver(MED_DRIVER,med21FileName,fieldDoubleScalarOnNodes.getName())
+fieldDoubleScalarOnNodes.write(idMedV21)
+
+idMedV21 = fieldIntScalarOnNodes.addDriver(MED_DRIVER,med21FileName,fieldIntScalarOnNodes.getName())
+fieldIntScalarOnNodes.write(idMedV21)
+
+idMedV21 = fieldDoubleVectorOnNodes.addDriver(MED_DRIVER,med21FileName,fieldDoubleVectorOnNodes.getName())
+fieldDoubleVectorOnNodes.write(idMedV21)
+
+idMedV21 = fieldIntVectorOnNodes.addDriver(MED_DRIVER,med21FileName,fieldIntVectorOnNodes.getName())
+fieldIntVectorOnNodes.write(idMedV21)
+
+idMedV21 = fieldDoubleScalarOnCells.addDriver(MED_DRIVER,med21FileName,fieldDoubleScalarOnCells.getName())
+fieldDoubleScalarOnCells.write(idMedV21)
+
+idMedV21 = fieldIntScalarOnCells.addDriver(MED_DRIVER,med21FileName,fieldIntScalarOnCells.getName())
+fieldIntScalarOnCells.write(idMedV21)
+
+idMedV21 = fieldDoubleVectorOnCells.addDriver(MED_DRIVER,med21FileName,fieldDoubleVectorOnCells.getName())
+fieldDoubleVectorOnCells.write(idMedV21)
+
+idMedV21 = fieldIntVectorOnCells.addDriver(MED_DRIVER,med21FileName,fieldIntVectorOnCells.getName())
+fieldIntVectorOnCells.write(idMedV21)
+
+medFileVersion = getMedFileVersionForWriting()
+if (medFileVersion == V21):
+ setMedFileVersionForWriting(V22)
+
+idMedV22 = fieldDoubleScalarOnNodes.addDriver(MED_DRIVER,med22FileName,fieldDoubleScalarOnNodes.getName())
+fieldDoubleScalarOnNodes.write(idMedV22)
-idMed = fieldIntScalarOnNodes.addDriver(MED_DRIVER,medFileName,fieldIntScalarOnNodes.getName())
-fieldIntScalarOnNodes.write(idMed)
+idMedV22 = fieldIntScalarOnNodes.addDriver(MED_DRIVER,med22FileName,fieldIntScalarOnNodes.getName())
+fieldIntScalarOnNodes.write(idMedV22)
-idMed = fieldDoubleVectorOnNodes.addDriver(MED_DRIVER,medFileName,fieldDoubleVectorOnNodes.getName())
-fieldDoubleVectorOnNodes.write(idMed)
+idMedV22 = fieldDoubleVectorOnNodes.addDriver(MED_DRIVER,med22FileName,fieldDoubleVectorOnNodes.getName())
+fieldDoubleVectorOnNodes.write(idMedV22)
-idMed = fieldIntVectorOnNodes.addDriver(MED_DRIVER,medFileName,fieldIntVectorOnNodes.getName())
-fieldIntVectorOnNodes.write(idMed)
+idMedV22 = fieldIntVectorOnNodes.addDriver(MED_DRIVER,med22FileName,fieldIntVectorOnNodes.getName())
+fieldIntVectorOnNodes.write(idMedV22)
-idMed = fieldDoubleScalarOnCells.addDriver(MED_DRIVER,medFileName,fieldDoubleScalarOnCells.getName())
-fieldDoubleScalarOnCells.write(idMed)
+idMedV22 = fieldDoubleScalarOnCells.addDriver(MED_DRIVER,med22FileName,fieldDoubleScalarOnCells.getName())
+fieldDoubleScalarOnCells.write(idMedV22)
-idMed = fieldIntScalarOnCells.addDriver(MED_DRIVER,medFileName,fieldIntScalarOnCells.getName())
-fieldIntScalarOnCells.write(idMed)
+idMedV22 = fieldIntScalarOnCells.addDriver(MED_DRIVER,med22FileName,fieldIntScalarOnCells.getName())
+fieldIntScalarOnCells.write(idMedV22)
-idMed = fieldDoubleVectorOnCells.addDriver(MED_DRIVER,medFileName,fieldDoubleVectorOnCells.getName())
-fieldDoubleVectorOnCells.write(idMed)
+idMedV22 = fieldDoubleVectorOnCells.addDriver(MED_DRIVER,med22FileName,fieldDoubleVectorOnCells.getName())
+fieldDoubleVectorOnCells.write(idMedV22)
-idMed = fieldIntVectorOnCells.addDriver(MED_DRIVER,medFileName,fieldIntVectorOnCells.getName())
-fieldIntVectorOnCells.write(idMed)
+idMedV22 = fieldIntVectorOnCells.addDriver(MED_DRIVER,med22FileName,fieldIntVectorOnCells.getName())
+fieldIntVectorOnCells.write(idMedV22)
idVtk = fieldDoubleScalarOnNodes.addDriver(VTK_DRIVER,vtkFileName,fieldDoubleScalarOnNodes.getName())
fieldDoubleScalarOnNodes.writeAppend(idVtk)
nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
print " Values:",nbOf
for k in range(nbOf):
- valueI = fieldDoubleScalOnCell.getValueI(MED_FULL_INTERLACE,k+1)
+ valueI = fieldDoubleScalOnCell.getRow(k+1)
print " *",valueI[:nbOfComp]
print ""
nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
print " Values:",nbOf
for k in range(nbOf):
- valueI = fieldDoubleVectOnCell.getValueI(MED_FULL_INTERLACE,k+1)
+ valueI = fieldDoubleVectOnCell.getRow(k+1)
print " *",valueI[:nbOfComp]
print ""
nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
print " Values:",nbOf
for k in range(nbOf):
- valueI = fieldIntScalOnCell.getValueI(MED_FULL_INTERLACE,k+1)
+ valueI = fieldIntScalOnCell.getRow(k+1)
print " *",valueI[:nbOfComp]
print ""
nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
print " Values:",nbOf
for k in range(nbOf):
- valueI = fieldIntVectOnCell.getValueI(MED_FULL_INTERLACE,k+1)
+ valueI = fieldIntVectOnCell.getRow(k+1)
print " *",valueI[:nbOfComp]
##print ""
nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
print " Values:",nbOf
for k in range(nbOf):
- valueI = fieldDoubleScalOnNode.getValueI(MED_FULL_INTERLACE,k+1)
+ valueI = fieldDoubleScalOnNode.getRow(k+1)
print " *",valueI[:nbOfComp]
print ""
nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
print " Values:",nbOf
for k in range(nbOf):
- valueI = fieldDoubleVectOnNode.getValueI(MED_FULL_INTERLACE,k+1)
+ valueI = fieldDoubleVectOnNode.getRow(k+1)
print " *",valueI[:nbOfComp]
print ""
nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
print " Values:",nbOf
for k in range(nbOf):
- valueI = fieldIntScalOnNode.getValueI(MED_FULL_INTERLACE,k+1)
+ valueI = fieldIntScalOnNode.getRow(k+1)
print " *",valueI[:nbOfComp]
print ""
nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
print " Values:",nbOf
for k in range(nbOf):
- valueI = fieldIntVectOnNode.getValueI(MED_FULL_INTERLACE,k+1)
+ valueI = fieldIntVectOnNode.getRow(k+1)
print " *",valueI[:nbOfComp]
##print ""
nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
print " Values:",nbOf
for k in range(nbOf):
- valueI = fieldDoubleScalOnConst.getValueI(MED_FULL_INTERLACE,k+1)
+ valueI = fieldDoubleScalOnConst.getRow(k+1)
print " *",valueI[:nbOfComp]
print ""
nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
print " Values:",nbOf
for k in range(nbOf):
- valueI = fieldDoubleVectOnConst.getValueI(MED_FULL_INTERLACE,k+1)
+ valueI = fieldDoubleVectOnConst.getRow(k+1)
print " *",valueI[:nbOfComp]
print ""
nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
print " Values:",nbOf
for k in range(nbOf):
- valueI = fieldIntScalOnConst.getValueI(MED_FULL_INTERLACE,k+1)
+ valueI = fieldIntScalOnConst.getRow(k+1)
print " *",valueI[:nbOfComp]
print ""
nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
print " Values:",nbOf
for k in range(nbOf):
- valueI = fieldIntVectOnConst.getValueI(MED_FULL_INTERLACE,k+1)
+ valueI = fieldIntVectOnConst.getRow(k+1)
print " *",valueI[:nbOfComp]
print ""
if type == MED_INT32:
fieldint = createFieldIntFromField(field)
fieldint.read()
+ fieldint.getSupport().update()
name = fieldint.getName()
desc = fieldint.getDescription()
nbOfComp = fieldint.getNumberOfComponents()
nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
print " Values:",nbOf
for k in range(nbOf):
- valueI = fieldint.getValueI(MED_FULL_INTERLACE,k+1)
+ valueI = fieldint.getRow(k+1)
print " *",valueI[:nbOfComp]
fieldint2 = FIELDINT(fieldint)
print ""
nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
print " Values:",nbOf
for k in range(nbOf):
- valueI = fieldintadd.getValueI(MED_FULL_INTERLACE,k+1)
+ valueI = fieldintadd.getRow(k+1)
print " *",valueI[:nbOfComp]
print ""
fieldintsub = fieldint - fieldint2
nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
print " Values:",nbOf
for k in range(nbOf):
- valueI = fieldintsub.getValueI(MED_FULL_INTERLACE,k+1)
+ valueI = fieldintsub.getRow(k+1)
print " *",valueI[:nbOfComp]
print ""
fieldintmul = fieldint * fieldint2
nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
print " Values:",nbOf
for k in range(nbOf):
- valueI = fieldintmul.getValueI(MED_FULL_INTERLACE,k+1)
+ valueI = fieldintmul.getRow(k+1)
print " *",valueI[:nbOfComp]
print ""
- fieldintdiv = fieldint / fieldint2
- print "Test of the division of two integer fields with creation a new one"
- print ""
- name = fieldintdiv.getName()
- desc = fieldintdiv.getDescription()
- nbOfComp = fieldintdiv.getNumberOfComponents()
- print " Field",name," : ",desc
- print " Number Of Components:",nbOfComp
- iterationNb = fieldintdiv.getIterationNumber()
- orderNb = fieldintdiv.getOrderNumber()
- time = fieldintdiv.getTime()
- print " Iteration Number",iterationNb
- print " Order Number",orderNb
- print " Time",time
- for k in range(nbOfComp):
- kp1 = k+1
- compName = fieldintdiv.getComponentName(kp1)
- compDesc = fieldintdiv.getComponentDescription(kp1)
- compUnit = fieldintdiv.getMEDComponentUnit(kp1)
- print " * Component:",kp1
- print " Name:",compName
- print " Description:",compDesc
- print " Unit:",compUnit
-
- support = fieldintdiv.getSupport()
- nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
- print " Values:",nbOf
- for k in range(nbOf):
- valueI = fieldintdiv.getValueI(MED_FULL_INTERLACE,k+1)
- print " *",valueI[:nbOfComp]
+ try:
+ fieldintdiv = fieldint / fieldint2
+ print "Test of the division of two integer fields with creation a new one"
+ print ""
+ name = fieldintdiv.getName()
+ desc = fieldintdiv.getDescription()
+ nbOfComp = fieldintdiv.getNumberOfComponents()
+ print " Field",name," : ",desc
+ print " Number Of Components:",nbOfComp
+ iterationNb = fieldintdiv.getIterationNumber()
+ orderNb = fieldintdiv.getOrderNumber()
+ time = fieldintdiv.getTime()
+ print " Iteration Number",iterationNb
+ print " Order Number",orderNb
+ print " Time",time
+ for k in range(nbOfComp):
+ kp1 = k+1
+ compName = fieldintdiv.getComponentName(kp1)
+ compDesc = fieldintdiv.getComponentDescription(kp1)
+ compUnit = fieldintdiv.getMEDComponentUnit(kp1)
+ print " * Component:",kp1
+ print " Name:",compName
+ print " Description:",compDesc
+ print " Unit:",compUnit
+
+ support = fieldintdiv.getSupport()
+ nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
+ print " Values:",nbOf
+ for k in range(nbOf):
+ valueI = fieldintdiv.getRow(k+1)
+ print " *",valueI[:nbOfComp]
+
+ except:
+ print "fieldintdiv = fieldint / fieldint2 catch/except error"
elif type == MED_REEL64:
fielddouble = createFieldDoubleFromField(field)
fielddouble.read()
+ fielddouble.getSupport().update()
name = fielddouble.getName()
desc = fielddouble.getDescription()
nbOfComp = fielddouble.getNumberOfComponents()
nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
print " Values:",nbOf
for k in range(nbOf):
- valueI = fielddouble.getValueI(MED_FULL_INTERLACE,k+1)
+ valueI = fielddouble.getRow(k+1)
print " *",valueI[:nbOfComp]
fielddouble2 = FIELDDOUBLE(fielddouble)
print ""
nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
print " Values:",nbOf
for k in range(nbOf):
- valueI = fielddoubleadd.getValueI(MED_FULL_INTERLACE,k+1)
+ valueI = fielddoubleadd.getRow(k+1)
print " *",valueI[:nbOfComp]
print ""
fielddoublesub = fielddouble - fielddouble2
nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
print " Values:",nbOf
for k in range(nbOf):
- valueI = fielddoublesub.getValueI(MED_FULL_INTERLACE,k+1)
+ valueI = fielddoublesub.getRow(k+1)
print " *",valueI[:nbOfComp]
print ""
fielddoublemul = fielddouble * fielddouble2
nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
print " Values:",nbOf
for k in range(nbOf):
- valueI = fielddoublemul.getValueI(MED_FULL_INTERLACE,k+1)
+ valueI = fielddoublemul.getRow(k+1)
print " *",valueI[:nbOfComp]
print ""
- fielddoublediv = fielddouble / fielddouble2
- print "Test of the division of two double fields with creation a new one"
- print ""
- name = fielddoublediv.getName()
- desc = fielddoublediv.getDescription()
- nbOfComp = fielddoublediv.getNumberOfComponents()
- print " Field",name," : ",desc
- print " Number Of Components:",nbOfComp
- iterationNb = fielddoublediv.getIterationNumber()
- orderNb = fielddoublediv.getOrderNumber()
- time = fielddoublediv.getTime()
- print " Iteration Number",iterationNb
- print " Order Number",orderNb
- print " Time",time
- for k in range(nbOfComp):
- kp1 = k+1
- compName = fielddoublediv.getComponentName(kp1)
- compDesc = fielddoublediv.getComponentDescription(kp1)
- compUnit = fielddoublediv.getMEDComponentUnit(kp1)
- print " * Component:",kp1
- print " Name:",compName
- print " Description:",compDesc
- print " Unit:",compUnit
-
- support = fielddoublediv.getSupport()
- nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
- print " Values:",nbOf
- for k in range(nbOf):
- valueI = fielddoublediv.getValueI(MED_FULL_INTERLACE,k+1)
+ try:
+ fielddoublediv = fielddouble / fielddouble2
+ print "Test of the division of two double fields with creation a new one"
+ print ""
+ name = fielddoublediv.getName()
+ desc = fielddoublediv.getDescription()
+ nbOfComp = fielddoublediv.getNumberOfComponents()
+ print " Field",name," : ",desc
+ print " Number Of Components:",nbOfComp
+ iterationNb = fielddoublediv.getIterationNumber()
+ orderNb = fielddoublediv.getOrderNumber()
+ time = fielddoublediv.getTime()
+ print " Iteration Number",iterationNb
+ print " Order Number",orderNb
+ print " Time",time
+ for k in range(nbOfComp):
+ kp1 = k+1
+ compName = fielddoublediv.getComponentName(kp1)
+ compDesc = fielddoublediv.getComponentDescription(kp1)
+ compUnit = fielddoublediv.getMEDComponentUnit(kp1)
+ print " * Component:",kp1
+ print " Name:",compName
+ print " Description:",compDesc
+ print " Unit:",compUnit
+
+ support = fielddoublediv.getSupport()
+ nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
+ print " Values:",nbOf
+ for k in range(nbOf):
+ valueI = fielddoublediv.getRow(k+1)
print " *",valueI[:nbOfComp]
+ except:
+ print "fielddoublediv = fielddouble / fielddouble2 catch/except error"
else:
print " !!!! Bad type of Field !!!!"
fielddoublesub = fielddouble-fielddouble2
fielddoublemul = fielddouble*fielddouble2
-fielddoublediv = fielddouble/fielddouble2
+
+try:
+ fielddoublediv = fielddouble/fielddouble2
+except:
+ pass
+
fielddoubleasso = fielddouble+fielddouble2*fielddouble2
fielddoubleSP=createFieldDoubleScalarProduct(fielddouble, fielddouble2)
-print " f1 : ",fielddouble.getValue(MED_FULL_INTERLACE)
-print " f2 : ",fielddouble2.getValue(MED_FULL_INTERLACE)
+print " f1 : ",fielddouble.getValue()
+print " f2 : ",fielddouble2.getValue()
print "--------------------------------------------------------------------------------------------------------------"
-print " + : ",fielddoubleadd.getValue(MED_FULL_INTERLACE)
-print " - : ",fielddoublesub.getValue(MED_FULL_INTERLACE)
-print " * : ",fielddoublemul.getValue(MED_FULL_INTERLACE)
-print " / : ",fielddoublediv.getValue(MED_FULL_INTERLACE)
+print " + : ",fielddoubleadd.getValue()
+print " - : ",fielddoublesub.getValue()
+print " * : ",fielddoublemul.getValue()
+
+try:
+ print " / : ",fielddoublediv.getValue()
+except:
+ pass
fielddouble+=fielddouble2;
-print " += : ",fielddouble.getValue(MED_FULL_INTERLACE)
+print " += : ",fielddouble.getValue()
fielddouble-=fielddouble2;
-print " -= : ",fielddouble.getValue(MED_FULL_INTERLACE)
+print " -= : ",fielddouble.getValue()
fielddouble*=fielddouble2;
-print " *= : ",fielddouble.getValue(MED_FULL_INTERLACE)
+print " *= : ",fielddouble.getValue()
fielddouble/=fielddouble2;
-print " /= : ",fielddouble.getValue(MED_FULL_INTERLACE)
-print "f1+f2*f2: ",fielddoubleasso.getValue(MED_FULL_INTERLACE)
+print " /= : ",fielddouble.getValue()
+print "f1+f2*f2: ",fielddoubleasso.getValue()
fielddouble.applyLin(4,1);
-print " 4f1+1 : ",fielddouble.getValue(MED_FULL_INTERLACE)
-print " f1.f2 : ",fielddoubleSP.getValue(MED_FULL_INTERLACE)
+print " 4f1+1 : ",fielddouble.getValue()
+print " f1.f2 : ",fielddoubleSP.getValue()
fielddouble2.applyPyFunc(add_one)
-print " CB:f2+1: ",fielddouble2.getValue(MED_FULL_INTERLACE)
+print " CB:f2+1: ",fielddouble2.getValue()
print ""
print "TESTS OPERATIONS SUR FIELDINT : "
fieldintadd = fieldint+fieldint2
fieldintsub = fieldint-fieldint2
fieldintmul = fieldint*fieldint2
-fieldintdiv = fieldint/fieldint2
+
+try:
+ fieldintdiv = fieldint/fieldint2
+except:
+ pass
+
fieldintasso = fieldint+fieldint*fieldint
fieldintSP=createFieldIntScalarProduct(fieldint, fieldint2)
-print " f1 : ",fieldint.getValue(MED_FULL_INTERLACE)
-print " f2 : ",fieldint2.getValue(MED_FULL_INTERLACE)
+print " f1 : ",fieldint.getValue()
+print " f2 : ",fieldint2.getValue()
print "--------------------------------------------------------------------------------------------------------------"
-print " + : ",fieldintadd.getValue(MED_FULL_INTERLACE)
-print " - : ",fieldintsub.getValue(MED_FULL_INTERLACE)
-print " * : ",fieldintmul.getValue(MED_FULL_INTERLACE)
-print " / : ",fieldintdiv.getValue(MED_FULL_INTERLACE)
+print " + : ",fieldintadd.getValue()
+print " - : ",fieldintsub.getValue()
+print " * : ",fieldintmul.getValue()
+
+try:
+ print " / : ",fieldintdiv.getValue()
+except:
+ pass
+
fieldint+=fieldint2;
-print " += : ",fieldint.getValue(MED_FULL_INTERLACE)
+print " += : ",fieldint.getValue()
fieldint-=fieldint2;
-print " -= : ",fieldint.getValue(MED_FULL_INTERLACE)
+print " -= : ",fieldint.getValue()
fieldint*=fieldint2;
-print " *= : ",fieldint.getValue(MED_FULL_INTERLACE)
+print " *= : ",fieldint.getValue()
fieldint/=fieldint2;
-print " /= : ",fieldint.getValue(MED_FULL_INTERLACE)
-print "f1+f2*f2: ",fieldintasso.getValue(MED_FULL_INTERLACE)
+print " /= : ",fieldint.getValue()
+print "f1+f2*f2: ",fieldintasso.getValue()
fieldint.applyLin(4,1);
-print " 4f1+1 : ",fieldint.getValue(MED_FULL_INTERLACE)
-print " f1.f2 : ",fieldintSP.getValue(MED_FULL_INTERLACE)
+print " 4f1+1 : ",fieldint.getValue()
+print " f1.f2 : ",fieldintSP.getValue()
fieldint2.applyPyFunc(add_one)
-print " CB:f2+1: ",fieldint2.getValue(MED_FULL_INTERLACE)
+print " CB:f2+1: ",fieldint2.getValue()
myname="toto"
fieldint.setName(myname)
name = fieldint.getName()
number = family.getNumber(type)
print " * Type",type
print " * Number",number[0:nbOfElmtsOfType]
- print ""
+ print ""
+ numberFamily = family.getNumber(MED_ALL_ELEMENTS)
print " * Getting an Integer Field on the family ",familyName
fieldFamilyIntg = FIELDINT(family,spaceDim)
fieldFamilyIntg.setIterationNumber(0)
nbOf = fieldFamilyIntg.getSupport().getNumberOfElements(MED_ALL_ELEMENTS)
print " Values:",nbOf
print " Randomly set and get to check ..!"
- mode = MED_FULL_INTERLACE
for k in range(nbOf):
valueI = []
for kcomp in range(nbOfComp):
valueI.append(randint(0,100))
# print " Set Entry *",(k+1)," ",valueI[:nbOfComp]
-
- fieldFamilyIntg.setValueI(mode,k+1,valueI)
- valueIverif = fieldFamilyIntg.getValueI(mode,k+1)
+ valInd = numberFamily[k]
+ fieldFamilyIntg.setRow(valInd,valueI)
+ valueIverif = fieldFamilyIntg.getRow(valInd)
print " Set/Get Entry *",(k+1)," ",valueI[:nbOfComp]," / ",valueIverif[:nbOfComp]
print " * Getting a Real Field"
fieldFamilyDble = FIELDDOUBLE(family,spaceDim)
valueI.append(random())
# print " Set Entry *",(k+1)," ",valueI[:nbOfComp]
-
- fieldFamilyDble.setValueI(MED_FULL_INTERLACE,k+1,valueI)
- valueIverif = fieldFamilyDble.getValueI(MED_FULL_INTERLACE,k+1)
+ valInd = numberFamily[k]
+ fieldFamilyDble.setRow(valInd,valueI)
+ valueIverif = fieldFamilyDble.getRow(valInd)
print " Set/Get Entry *",(k+1)," ",valueI[:nbOfComp]," / ",valueIverif[:nbOfComp]
print ""
print ""
barycenter = mesh.getBarycenter(supportCell)
print "Getting barycenter of all Cells of the mesh"
for j in range(nbElemts):
- barycenterCell = barycenter.getValueI(MED_FULL_INTERLACE,j+1)
+ barycenterCell = barycenter.getRow(j+1)
print " * ",barycenterCell[:spaceDim]
print ""
if spaceDim == 3 :
normal = mesh.getNormal(supportFace)
area = mesh.getArea(supportFace)
for j in range(nbFace):
- normalFace = normal.getValueI(MED_FULL_INTERLACE,j+1)
- areaFace = area.getValueI(MED_FULL_INTERLACE,j+1)
+ normalFace = normal.getRow(j+1)
+ areaFace = area.getRow(j+1)
value1 = normalFace[0]
value2 = normalFace[1]
value3 = normalFace[2]
normal = mesh.getNormal(supportEdge)
length = mesh.getLength(supportEdge)
for j in range(nbEdge):
- normalEdge = normal.getValueI(MED_FULL_INTERLACE,j+1)
- lengthEdge = length.getValueI(MED_FULL_INTERLACE,j+1)
+ normalEdge = normal.getRow(j+1)
+ lengthEdge = length.getRow(j+1)
value1 = normalEdge[0]
value2 = normalEdge[1]
norm = (value1*value1 + value2*value2)**(0.5)
nbElmBound = suppBound.getNumberOfElements(MED_ALL_ELEMENTS)
print "Getting normal field on the boundary",nbElmBound
normalBound = mesh.getNormal(suppBound)
+ numberSuppBound = suppBound.getNumber(MED_ALL_ELEMENTS)
for j in range(nbElmBound):
- normalBoundJ = normalBound.getValueI(MED_FULL_INTERLACE,j+1)
+ valInd = numberSuppBound[j]
+ normalBoundJ = normalBound.getRow(valInd)
value1 = normalBoundJ[0]
value2 = normalBoundJ[1]
value3 = normalBoundJ[2]
nbElmBound = suppBound.getNumberOfElements(MED_ALL_ELEMENTS)
print "Getting normal field on the boundary",nbElmBound
normalBound = mesh.getNormal(suppBound)
+ numberSuppBound = suppBound.getNumber(MED_ALL_ELEMENTS)
for j in range(nbElmBound):
- normalBoundJ = normalBound.getValueI(MED_FULL_INTERLACE,j+1)
+ valInd = numberSuppBound[j]
+ normalBoundJ = normalBound.getRow(valInd)
value1 = normalBoundJ[0]
value2 = normalBoundJ[1]
norm = (value1*value1 + value2*value2)**(0.5)
nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
print " Values:",nbOf
for k in range(nbOf):
- valueI = fieldint.getValueI(MED_FULL_INTERLACE,k+1)
+ valueI = fieldint.getRow(k+1)
print " *",valueI[:nbOfComp]
elif type == MED_REEL64:
fielddouble = createFieldDoubleFromField(field)
nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
print " Values:",nbOf
for k in range(nbOf):
- valueI = fielddouble.getValueI(MED_FULL_INTERLACE,k+1)
+ valueI = fielddouble.getRow(k+1)
print " *",valueI[:nbOfComp]
else:
print " !!!! Bad type of Field !!!!"
#
# This Python script is parsing a MED file using MED Memory from SALOME platform:
# It analyses all meshes in the MED file (coordinates, connectivity of d-cells as
-# well as (d-1)-cells, families), it tests all fields generated ine the MESH class
-# and write them in a new file , it gives only the number of fields stored in the
-# MED file (d is the space dimension).
+# well as (d-1)-cells, families), it tests all fields generated in the MESH class
+# and write them in a 2 new med files (V2.1 and V2.2), it gives only the number of
+# fields stored in the MED file (d is the mesh/space dimension).
#
###################################################################################
print "iteration number ",itNum," order Number ",ordNum
print "It has ",nbComp," component(s) with the type ",type
- fieldValue = field.getValue(MED_FULL_INTERLACE)
+ fieldValue = field.getValue()
fieldSupport = field.getSupport()
fieldMesh = fieldSupport.getMesh()
fieldEntity = fieldSupport.getEntity()
print " * Type",type
print " * Number",number[0:nbOfElmtsOfType]
print ""
+ numberFamily = family.getNumber(MED_ALL_ELEMENTS)
print " * Getting an Integer Field on the family ",familyName
fieldFamilyIntg = FIELDINT(family,spaceDim)
fieldFamilyIntg.setIterationNumber(0)
nbOf = fieldFamilyIntg.getSupport().getNumberOfElements(MED_ALL_ELEMENTS)
print " Values:",nbOf
print " Randomly set and get to check ..!"
- mode = MED_FULL_INTERLACE
for k in range(nbOf):
valueI = []
for kcomp in range(nbOfComp):
valueI.append(randint(0,100))
# print " Set Entry *",(k+1)," ",valueI[:nbOfComp]
-
- fieldFamilyIntg.setValueI(mode,k+1,valueI)
- valueIverif = fieldFamilyIntg.getValueI(mode,k+1)
+ valInd = numberFamily[k]
+ fieldFamilyIntg.setRow(valInd,valueI)
+ valueIverif = fieldFamilyIntg.getRow(valInd)
print " Set/Get Entry *",(k+1)," ",valueI[:nbOfComp]," / ",valueIverif[:nbOfComp]
print " * Getting a Real Field"
fieldFamilyDble = FIELDDOUBLE(family,spaceDim)
valueI.append(random())
# print " Set Entry *",(k+1)," ",valueI[:nbOfComp]
-
- fieldFamilyDble.setValueI(MED_FULL_INTERLACE,k+1,valueI)
- valueIverif = fieldFamilyDble.getValueI(MED_FULL_INTERLACE,k+1)
+ valInd = numberFamily[k]
+ fieldFamilyDble.setRow(valInd,valueI)
+ valueIverif = fieldFamilyDble.getRow(valInd)
print " Set/Get Entry *",(k+1)," ",valueI[:nbOfComp]," / ",valueIverif[:nbOfComp]
if (entity != MED_NODE):
print ""
print "Getting barycenter on this family"
barycenterfamily = mesh.getBarycenter(family)
+ if (not familyBool): numberFamily = family.getNumber(MED_ALL_ELEMENTS)
nbVal = barycenterfamily.getSupport().getNumberOfElements(MED_ALL_ELEMENTS)
nbComp = barycenterfamily.getNumberOfComponents()
for j in range(nbVal):
- barycenterfamilyentity = barycenterfamily.getValueI(MED_FULL_INTERLACE,j+1)
+ valInd = j+1
+ if (not familyBool): valInd = numberFamily[j]
+ barycenterfamilyentity = barycenterfamily.getRow(valInd)
print " * ",barycenterfamilyentity[:nbComp]
print ""
print "Getting barycenter of all Cells of the mesh"
barycenter = mesh.getBarycenter(supportCell)
for j in range(nbElemts):
- barycenterCell = barycenter.getValueI(MED_FULL_INTERLACE,j+1)
+ barycenterCell = barycenter.getRow(j+1)
print " * ",barycenterCell[:spaceDim]
print "Writing on file the mesh"
-
- writeMedFile = medFile[0:(len(medFile)-4)]+"_fields.med"
+ writeMed21File = medFile[0:(len(medFile)-4)]+"_V21_fields.med"
+ writeMed22File = medFile[0:(len(medFile)-4)]+"_V22_fields.med"
fieldsMesh = barycenter.getSupport().getMesh()
fieldsMeshName = "Fields Mesh"
fieldsMesh.setName(fieldsMeshName)
- indexMesh = fieldsMesh.addDriver(MED_DRIVER,writeMedFile,fieldsMeshName)
- fieldsMesh.write(indexMesh,"")
+
+ medFileVersion = getMedFileVersionForWriting()
+ if (medFileVersion == V22):
+ setMedFileVersionForWriting(V21)
+
+ index21Mesh = fieldsMesh.addDriver(MED_DRIVER,writeMed21File,fieldsMeshName)
+ fieldsMesh.write(index21Mesh,"")
+
+ medFileVersion = getMedFileVersionForWriting()
+ if (medFileVersion == V21):
+ setMedFileVersionForWriting(V22)
+
+ index22Mesh = fieldsMesh.addDriver(MED_DRIVER,writeMed22File,fieldsMeshName)
+ fieldsMesh.write(index22Mesh,"")
AnalyzeField(barycenter)
print "Writing on file the cells barycenter field"
barycenterName = barycenter.getName()
- indexFieldBarycenter = barycenter.addDriver(MED_DRIVER,writeMedFile,barycenterName)
- barycenter.write(indexFieldBarycenter,"")
+
+ medFileVersion = getMedFileVersionForWriting()
+ if (medFileVersion == V22):
+ setMedFileVersionForWriting(V21)
+
+ index21FieldBarycenter = barycenter.addDriver(MED_DRIVER,writeMed21File,barycenterName)
+ barycenter.write(index21FieldBarycenter,"")
+
+ medFileVersion = getMedFileVersionForWriting()
+ if (medFileVersion == V21):
+ setMedFileVersionForWriting(V22)
+
+ index22FieldBarycenter = barycenter.addDriver(MED_DRIVER,writeMed22File,barycenterName)
+ barycenter.write(index22FieldBarycenter,"")
print ""
if spaceDim == 3 :
print "Writing on file the cells volume field"
volumeName = volume.getName()
- indexFieldVolume = volume.addDriver(MED_DRIVER,writeMedFile,volumeName)
- volume.write(indexFieldVolume,"")
+
+ medFileVersion = getMedFileVersionForWriting()
+ if (medFileVersion == V22):
+ setMedFileVersionForWriting(V21)
+
+ index21FieldVolume = volume.addDriver(MED_DRIVER,writeMed21File,volumeName)
+ volume.write(index21FieldVolume,"")
+
+ medFileVersion = getMedFileVersionForWriting()
+ if (medFileVersion == V21):
+ setMedFileVersionForWriting(V22)
+
+ index22FieldVolume = volume.addDriver(MED_DRIVER,writeMed22File,volumeName)
+ volume.write(index22FieldVolume,"")
print ""
print "Building of the support on all Faces of the mesh."
print "nbTypeFace:",nbTypeFace,"----",TypeFace[:nbTypeFace]
normal = mesh.getNormal(supportFace)
for j in range(nbFace):
- normalFace = normal.getValueI(MED_FULL_INTERLACE,j+1)
+ normalFace = normal.getRow(j+1)
value1 = normalFace[0]
value2 = normalFace[1]
value3 = normalFace[2]
print "Writing on file the face normal field"
normalName = normal.getName()
- indexFieldNormal = normal.addDriver(MED_DRIVER,writeMedFile,normalName)
- normal.write(indexFieldNormal,"")
+
+ medFileVersion = getMedFileVersionForWriting()
+ if (medFileVersion == V22):
+ setMedFileVersionForWriting(V21)
+
+ index21FieldNormal = normal.addDriver(MED_DRIVER,writeMed21File,normalName)
+ normal.write(index21FieldNormal,"")
+
+ medFileVersion = getMedFileVersionForWriting()
+ if (medFileVersion == V21):
+ setMedFileVersionForWriting(V22)
+
+ index22FieldNormal = normal.addDriver(MED_DRIVER,writeMed22File,normalName)
+ normal.write(index22FieldNormal,"")
elif spaceDim == 2:
print "Getting area on all Cells of the mesh:"
print "Writing on file the cells area field"
areaName = area.getName()
- indexFieldArea = area.addDriver(MED_DRIVER,writeMedFile,areaName)
- area.write(indexFieldArea,"")
+
+ medFileVersion = getMedFileVersionForWriting()
+ if (medFileVersion == V22):
+ setMedFileVersionForWriting(V21)
+
+ index21FieldArea = area.addDriver(MED_DRIVER,writeMed21File,areaName)
+ area.write(index21FieldArea,"")
+
+ medFileVersion = getMedFileVersionForWriting()
+ if (medFileVersion == V21):
+ setMedFileVersionForWriting(V22)
+
+ index22FieldArea = area.addDriver(MED_DRIVER,writeMed22File,areaName)
+ area.write(index22FieldArea,"")
+
print ""
print "Building of the support on all Edges of the mesh."
supportEdge = SUPPORT(mesh,"Support on all edges of the mesh",MED_EDGE)
print "nbTypeEdge:",nbTypeEdge,"----",TypeEdge[:nbTypeEdge]
normal = mesh.getNormal(supportEdge)
for j in range(nbEdge):
- normalEdge = normal.getValueI(MED_FULL_INTERLACE,j+1)
+ normalEdge = normal.getRow(j+1)
value1 = normalEdge[0]
value2 = normalEdge[1]
norm = (value1*value1 + value2*value2)**(0.5)
print "Writing on file the edge normal field"
normalName = normal.getName()
- indexFieldNormal = normal.addDriver(MED_DRIVER,writeMedFile,normalName)
- normal.write(indexFieldNormal,"")
+
+ medFileVersion = getMedFileVersionForWriting()
+ if (medFileVersion == V22):
+ setMedFileVersionForWriting(V21)
+
+ index21FieldNormal = normal.addDriver(MED_DRIVER,writeMed21File,normalName)
+ normal.write(index21FieldNormal,"")
+
+ medFileVersion = getMedFileVersionForWriting()
+ if (medFileVersion == V21):
+ setMedFileVersionForWriting(V22)
+
+ index22FieldNormal = normal.addDriver(MED_DRIVER,writeMed22File,normalName)
+ normal.write(index22FieldNormal,"")
print ""
+
+print "END of the Pyhton script ..... Ctrl D to exit"
+#
+# This script does not work at the moment !!!
+#
+
+
###################################################################################
#
# This Python script is parsing a MED file using MED Memory from SALOME platform:
print " * Type",type
print " * Number",number[0:nbOfElmtsOfType]
print ""
+ numberFamily = family.getNumber(MED_ALL_ELEMENTS)
print " * Getting an Integer Field on the family ",familyName
fieldFamilyIntg = FIELDINT(family,spaceDim)
fieldFamilyIntg.setIterationNumber(0)
value.append(randint(0,100))
print " the mode is full interlace"
mode = MED_FULL_INTERLACE
- fieldFamilyIntg.setValue(mode,value)
- valueverif = fieldFamilyIntg.getValue(mode)
+ fieldFamilyIntg.setValue(value)
+ valueverif = fieldFamilyIntg.getValue()
for k in range(nbOf*nbOfComp):
print " Set/Get Entry * ",value[k]," / ",valueverif[k]
print ""
value.append(randint(0,100))
print " the mode is no interlace"
mode = MED_NO_INTERLACE
- fieldFamilyIntg.setValue(mode,value)
- valueverif = fieldFamilyIntg.getValue(mode)
+ fieldFamilyIntg.setValue(value)
+ valueverif = fieldFamilyIntg.getValue()
for k in range(nbOf*nbOfComp):
print " Set/Get Entry * ",value[k]," / ",valueverif[k]
print ""
print " the mode for set is full interlace and no interlace for get"
mode_full = MED_FULL_INTERLACE
mode_no = MED_NO_INTERLACE
- fieldFamilyIntg.setValue(mode_full,value)
- valueverif = fieldFamilyIntg.getValue(mode_no)
+ fieldFamilyIntg.setValue(value)
+ valueverif = fieldFamilyIntg.getValue()
for k in range(nbOf*nbOfComp):
print " Set/Get Entry * ",value[k]," / ",valueverif[k]
print ""
for k in range(nbOf*nbOfComp):
value.append(randint(0,100))
print " the mode for set is no interlace and full interlace for get"
- fieldFamilyIntg.setValue(mode_no,value)
- valueverif = fieldFamilyIntg.getValue(mode_full)
+ fieldFamilyIntg.setValue(value)
+ valueverif = fieldFamilyIntg.getValue()
for k in range(nbOf*nbOfComp):
print " Set/Get Entry * ",value[k]," / ",valueverif[k]
print ""
print " the mode is full interlace"
mode = MED_FULL_INTERLACE
for k in range(nbOf):
- fieldFamilyIntg.setValueI(mode,(k+1),value[k*nbOfComp:(k+1)*nbOfComp])
+ fieldFamilyIntg.setRow((k+1),value[k*nbOfComp:(k+1)*nbOfComp])
valueverif = []
for k in range(nbOf):
- valueverif.extend(fieldFamilyIntg.getValueI(mode,(k+1)))
+ valueverif.extend(fieldFamilyIntg.getRow((k+1)))
for k in range(nbOf*nbOfComp):
print " Set/Get Entry * ",value[k]," / ",valueverif[k]
print ""
print " the mode is no interlace"
mode = MED_NO_INTERLACE
for k in range(nbOfComp):
- fieldFamilyIntg.setValueI(mode,(k+1),value[k*nbOf:(k+1)*nbOf])
+ fieldFamilyIntg.setColumn((k+1),value[k*nbOf:(k+1)*nbOf])
valueverif = []
for k in range(nbOfComp):
- valueverif.extend(fieldFamilyIntg.getValueI(mode,(k+1)))
+ valueverif.extend(fieldFamilyIntg.getColumn((k+1)))
for k in range(nbOf*nbOfComp):
print " Set/Get Entry * ",value[k]," / ",valueverif[k]
print ""
mode_full = MED_FULL_INTERLACE
mode_no = MED_NO_INTERLACE
for k in range(nbOf):
- fieldFamilyIntg.setValueI(mode_full,(k+1),value[k*nbOfComp:(k+1)*nbOfComp])
+ fieldFamilyIntg.setRow((k+1),value[k*nbOfComp:(k+1)*nbOfComp])
valueverif = []
for k in range(nbOfComp):
- valueverif.extend(fieldFamilyIntg.getValueI(mode_no,(k+1)))
+ valueverif.extend(fieldFamilyIntg.getColumn((k+1)))
for k in range(nbOf*nbOfComp):
print " Set/Get Entry * ",value[k]," / ",valueverif[k]
print ""
value.append(randint(0,100))
print " the mode for set is no interlace and full interlace for get"
for k in range(nbOfComp):
- fieldFamilyIntg.setValueI(mode_no,(k+1),value[k*nbOf:(k+1)*nbOf])
+ fieldFamilyIntg.setColumn((k+1),value[k*nbOf:(k+1)*nbOf])
valueverif = []
for k in range(nbOf):
- valueverif.extend(fieldFamilyIntg.getValueI(mode_full,(k+1)))
+ valueverif.extend(fieldFamilyIntg.getRow((k+1)))
for k in range(nbOf*nbOfComp):
print " Set/Get Entry * ",value[k]," / ",valueverif[k]
print ""
--- /dev/null
+from libMEDMEM_Swig import *
+
+import os
+
+#
+#before running this script, please be sure about the path the file fileName
+#
+
+filePath=os.environ["MED_ROOT_DIR"]
+filePath=filePath+"/share/salome/resources/"
+
+medFile = filePath + "test_2D.med"
+
+asciiFile = "tyst.txt"
+
+md=MED()
+dr=MED_MED_RDONLY_DRIVER(medFile,md)
+
+dr.open()
+dr.readFileStruct()
+dr.read()
+dr.close()
+
+nbMeshes = md.getNumberOfMeshes()
+
+nbFields = md.getNumberOfFields()
+
+print "The med file", medFile, "contains", nbMeshes, "mesh(es) and", nbFields, "field(s)"
+f1Name=md.getFieldName(0)
+f1It=md.getFieldNumberOfIteration(f1Name)
+it=md.getFieldIteration(f1Name,0)
+f1=md.getField(f1Name,it.dt,it.it)
+f1=createFieldDoubleFromField(f1)
+#f1.read()
+id2=f1.addDriver(ASCII_DRIVER,asciiFile,"Default Field Name",MED_ECRI)
+#dr=ASCII_FIELDDOUBLE_DRIVER(asciiFile,f1,DESCENDING)
+#dr.open()
+#dr.write()
+#dr.close()
+##print f1It
+f1.write(id2)
+
+print "END of the Pyhton script ..... Ctrl D to exit"
files.append("cube_hexa8_import22.med")
meshNameFiles.append("CUBE_EN_HEXA8")
-files.append("test19.med")
-meshNameFiles.append("CartGrid")
+##files.append("test19.med")
+##meshNameFiles.append("CartGrid")
-files.append("test19.med")
-meshNameFiles.append("bodyfitted")
+##files.append("test19.med")
+##meshNameFiles.append("bodyfitted")
##files.append("test19.med")
##meshNameFiles.append("maa1")
print "Building of the support on all Cells of the mesh."
supportCell = SUPPORT(mesh)
- supportCell.update()
print ""
barycenter = mesh.getBarycenter(supportCell)
print "Getting barycenter of all Cells of the mesh"
for j in range(nbElemts):
- barycenterCell = barycenter.getValueI(MED_FULL_INTERLACE,j+1)
+ barycenterCell = barycenter.getRow(j+1)
print " * ",barycenterCell[:spaceDim]
print ""
normal = mesh.getNormal(supportFace)
area = mesh.getArea(supportFace)
for j in range(nbFace):
- normalFace = normal.getValueI(MED_FULL_INTERLACE,j+1)
- areaFace = area.getValueI(MED_FULL_INTERLACE,j+1)
+ normalFace = normal.getRow(j+1)
+ areaFace = area.getRow(j+1)
value1 = normalFace[0]
value2 = normalFace[1]
value3 = normalFace[2]
normal = mesh.getNormal(supportEdge)
length = mesh.getLength(supportEdge)
for j in range(nbEdge):
- normalEdge = normal.getValueI(MED_FULL_INTERLACE,j+1)
- lengthEdge = length.getValueI(MED_FULL_INTERLACE,j+1)
+ normalEdge = normal.getRow(j+1)
+ lengthEdge = length.getRow(j+1)
value1 = normalEdge[0]
value2 = normalEdge[1]
norm = (value1*value1 + value2*value2)**(0.5)
nbElmBound = suppBound.getNumberOfElements(MED_ALL_ELEMENTS)
print "Getting normal field on the boundary",nbElmBound
normalBound = mesh.getNormal(suppBound)
+ numberSuppBound = suppBound.getNumber(MED_ALL_ELEMENTS)
for j in range(nbElmBound):
- normalBoundJ = normalBound.getValueI(MED_FULL_INTERLACE,j+1)
+ valInd = numberSuppBound[j]
+ normalBoundJ = normalBound.getRow(valInd)
value1 = normalBoundJ[0]
value2 = normalBoundJ[1]
value3 = normalBoundJ[2]
nbElmBound = suppBound.getNumberOfElements(MED_ALL_ELEMENTS)
print "Getting normal field on the boundary",nbElmBound
normalBound = mesh.getNormal(suppBound)
+ numberSuppBound = suppBound.getNumber(MED_ALL_ELEMENTS)
for j in range(nbElmBound):
- normalBoundJ = normalBound.getValueI(MED_FULL_INTERLACE,j+1)
+ valInd = numberSuppBound[j]
+ normalBoundJ = normalBound.getRow(valInd)
value1 = normalBoundJ[0]
value2 = normalBoundJ[1]
norm = (value1*value1 + value2*value2)**(0.5)
nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
print " Values:",nbOf
for k in range(nbOf):
- valueI = fieldint.getValueI(MED_FULL_INTERLACE,k+1)
+ valueI = fieldint.getRow(k+1)
print " *",valueI[:nbOfComp]
fieldint2 = FIELDINT(fieldint)
print ""
nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
print " Values:",nbOf
for k in range(nbOf):
- valueI = fieldintadd.getValueI(MED_FULL_INTERLACE,k+1)
+ valueI = fieldintadd.getRow(k+1)
print " *",valueI[:nbOfComp]
print ""
fieldintsub = fieldint - fieldint2
nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
print " Values:",nbOf
for k in range(nbOf):
- valueI = fieldintsub.getValueI(MED_FULL_INTERLACE,k+1)
+ valueI = fieldintsub.getRow(k+1)
print " *",valueI[:nbOfComp]
print ""
fieldintmul = fieldint * fieldint2
nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
print " Values:",nbOf
for k in range(nbOf):
- valueI = fieldintmul.getValueI(MED_FULL_INTERLACE,k+1)
+ valueI = fieldintmul.getRow(k+1)
print " *",valueI[:nbOfComp]
print ""
try:
nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
print " Values:",nbOf
for k in range(nbOf):
- valueI = fieldintdiv.getValueI(MED_FULL_INTERLACE,k+1)
+ valueI = fieldintdiv.getRow(k+1)
print " *",valueI[:nbOfComp]
print ""
print "TESTS OPERATIONS SUR FIELDINT : "
fieldintasso = fieldint+fieldint*fieldint
fieldintSP=createFieldIntScalarProduct(fieldint, fieldint2)
- print " f1 : ",fieldint.getValue(MED_FULL_INTERLACE)
- print " f2 : ",fieldint2.getValue(MED_FULL_INTERLACE)
+ print " f1 : ",fieldint.getValue()
+ print " f2 : ",fieldint2.getValue()
print "--------------------------------------------------------------------------------------------------------------"
- print " + : ",fieldintadd.getValue(MED_FULL_INTERLACE)
- print " - : ",fieldintsub.getValue(MED_FULL_INTERLACE)
- print " * : ",fieldintmul.getValue(MED_FULL_INTERLACE)
+ print " + : ",fieldintadd.getValue()
+ print " - : ",fieldintsub.getValue()
+ print " * : ",fieldintmul.getValue()
if fieldintdiv == None :
print "testMedMemGeneral / : None"
else:
- print " / : ",fieldintdiv.getValue(MED_FULL_INTERLACE)
+ print " / : ",fieldintdiv.getValue()
fieldint+=fieldint2;
- print " += : ",fieldint.getValue(MED_FULL_INTERLACE)
+ print " += : ",fieldint.getValue()
fieldint-=fieldint2;
- print " -= : ",fieldint.getValue(MED_FULL_INTERLACE)
+ print " -= : ",fieldint.getValue()
fieldint*=fieldint2;
- print " *= : ",fieldint.getValue(MED_FULL_INTERLACE)
+ print " *= : ",fieldint.getValue()
try:
fieldint/=fieldint2;
- print " /= : ",fieldint.getValue(MED_FULL_INTERLACE)
+ print " /= : ",fieldint.getValue()
except :
fieldint = None
print " /= : Catch/Except : None"
- print "f1+f2*f2: ",fieldintasso.getValue(MED_FULL_INTERLACE)
+ print "f1+f2*f2: ",fieldintasso.getValue()
if fieldint != None :
fieldint.applyLin(4,1);
- print " 4f1+1 : ",fieldint.getValue(MED_FULL_INTERLACE)
- print " f1.f2 : ",fieldintSP.getValue(MED_FULL_INTERLACE)
+ print " 4f1+1 : ",fieldint.getValue()
+ print " f1.f2 : ",fieldintSP.getValue()
fieldint2.applyPyFunc(add_one)
- print " CB:f2+1: ",fieldint2.getValue(MED_FULL_INTERLACE)
+ print " CB:f2+1: ",fieldint2.getValue()
elif type == MED_REEL64:
fielddouble = createFieldDoubleFromField(field)
fielddouble.read()
print " Time",time
print " Norme 2 : ", fielddouble.norm2()
print " Norme Max : ", fielddouble.normMax()
+ fielddouble.getSupport().update()
print "try sobolev",fielddouble.getSupport().getEntity()
if fielddouble.getSupport().getEntity()!=MED_NODE:
if (spaceDim == 3):
nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
print " Values:",nbOf
for k in range(nbOf):
- valueI = fielddouble.getValueI(MED_FULL_INTERLACE,k+1)
+ valueI = fielddouble.getRow(k+1)
print " *",valueI[:nbOfComp]
fielddouble2 = FIELDDOUBLE(fielddouble)
print ""
nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
print " Values:",nbOf
for k in range(nbOf):
- valueI = fielddoubleadd.getValueI(MED_FULL_INTERLACE,k+1)
+ valueI = fielddoubleadd.getRow(k+1)
print " *",valueI[:nbOfComp]
print ""
fielddoublesub = fielddouble - fielddouble2
nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
print " Values:",nbOf
for k in range(nbOf):
- valueI = fielddoublesub.getValueI(MED_FULL_INTERLACE,k+1)
+ valueI = fielddoublesub.getRow(k+1)
print " *",valueI[:nbOfComp]
print ""
fielddoublemul = fielddouble * fielddouble2
nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
print " Values:",nbOf
for k in range(nbOf):
- valueI = fielddoublemul.getValueI(MED_FULL_INTERLACE,k+1)
+ valueI = fielddoublemul.getRow(k+1)
print " *",valueI[:nbOfComp]
print ""
try:
nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
print " Values:",nbOf
for k in range(nbOf):
- valueI = fielddoublediv.getValueI(MED_FULL_INTERLACE,k+1)
+ valueI = fielddoublediv.getRow(k+1)
print " *",valueI[:nbOfComp]
except:
print "testMedMemGeneral fielddoublediv = fielddouble / fielddouble2 catch/except error"
fielddoublediv = None
fielddoubleasso = fielddouble+fielddouble2*fielddouble2
fielddoubleSP=createFieldDoubleScalarProduct(fielddouble, fielddouble2)
- print " f1 : ",fielddouble.getValue(MED_FULL_INTERLACE)
- print " f2 : ",fielddouble2.getValue(MED_FULL_INTERLACE)
+ print " f1 : ",fielddouble.getValue()
+ print " f2 : ",fielddouble2.getValue()
print "--------------------------------------------------------------------------------------------------------------"
- print " + : ",fielddoubleadd.getValue(MED_FULL_INTERLACE)
- print " - : ",fielddoublesub.getValue(MED_FULL_INTERLACE)
- print " * : ",fielddoublemul.getValue(MED_FULL_INTERLACE)
+ print " + : ",fielddoubleadd.getValue()
+ print " - : ",fielddoublesub.getValue()
+ print " * : ",fielddoublemul.getValue()
if fielddoublediv != None:
- print " / : ",fielddoublediv.getValue(MED_FULL_INTERLACE)
+ print " / : ",fielddoublediv.getValue()
pass
fielddouble+=fielddouble2;
- print " += : ",fielddouble.getValue(MED_FULL_INTERLACE)
+ print " += : ",fielddouble.getValue()
fielddouble-=fielddouble2;
- print " -= : ",fielddouble.getValue(MED_FULL_INTERLACE)
+ print " -= : ",fielddouble.getValue()
fielddouble*=fielddouble2;
- print " *= : ",fielddouble.getValue(MED_FULL_INTERLACE)
+ print " *= : ",fielddouble.getValue()
try:
fielddouble/=fielddouble2;
- print " /= : ",fielddouble.getValue(MED_FULL_INTERLACE)
+ print " /= : ",fielddouble.getValue()
except:
print "testMedMemGeneral /= : "
- print "f1+f2*f2: ",fielddoubleasso.getValue(MED_FULL_INTERLACE)
+ print "f1+f2*f2: ",fielddoubleasso.getValue()
fielddouble.applyLin(4,1);
- print " 4f1+1 : ",fielddouble.getValue(MED_FULL_INTERLACE)
- print " f1.f2 : ",fielddoubleSP.getValue(MED_FULL_INTERLACE)
+ print " 4f1+1 : ",fielddouble.getValue()
+ print " f1.f2 : ",fielddoubleSP.getValue()
fielddouble2.applyPyFunc(add_one)
- print " CB:f2+1: ",fielddouble2.getValue(MED_FULL_INTERLACE)
+ print " CB:f2+1: ",fielddouble2.getValue()
else:
print " !!!! Bad type of Field !!!!"
//
// See http://www.salome-platform.org/
//
-template<class T>
-FIELDClient<T>::FIELDClient(typename MapCppFieldServ<T>::FieldPtrType ptrCorba,MEDMEM::SUPPORT * S):_fieldPtr(MapCppFieldServ<T>::FieldGlobalType::_duplicate(ptrCorba)),_refCounter(1)
+template<class T, class INTERLACING_TAG>
+FIELDClient<T,INTERLACING_TAG>::FIELDClient(typename FIELDI_TRAITS<T,INTERLACING_TAG>::SimpleFieldCorbaPtrType ptrCorba,MEDMEM::SUPPORT * S):_fieldPtr(FIELDI_TRAITS<T,INTERLACING_TAG>::SimpleFieldGlobalType::_duplicate(ptrCorba)),_refCounter(1)
{
if (!S)
{
SCRUTE(_fieldPtr);
SCRUTE(_fieldPtr->getSupport());
- MEDMEM::FIELD<T>::_support=new MEDMEM::SUPPORTClient(_fieldPtr->getSupport());
+ MEDMEM::FIELD<T,INTERLACING_TAG>::_support=new MEDMEM::SUPPORTClient(_fieldPtr->getSupport());
}
else
- MEDMEM::FIELD<T>::setSupport(S);
+ MEDMEM::FIELD<T,INTERLACING_TAG>::setSupport(S);
setName(_fieldPtr->getName());
- MEDMEM::FIELD<T>::setDescription(_fieldPtr->getDescription());
+ MEDMEM::FIELD<T,INTERLACING_TAG>::setDescription(_fieldPtr->getDescription());
int nc = _fieldPtr->getNumberOfComponents();
- MEDMEM::FIELD<T>::setNumberOfComponents(nc);
+ MEDMEM::FIELD<T,INTERLACING_TAG>::setNumberOfComponents(nc);
- MEDMEM::FIELD<T>::setNumberOfValues( MEDMEM::FIELD<T>::_support->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS));
+ MEDMEM::FIELD<T,INTERLACING_TAG>::setNumberOfValues( MEDMEM::FIELD<T,INTERLACING_TAG>::_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<T>::setComponentsNames(_s);
+ MEDMEM::FIELD<T,INTERLACING_TAG>::setComponentsNames(_s);
s = _fieldPtr->getComponentsDescriptions();
for (int i=0; i<nc; i++)
_s[i] = s[i];
- MEDMEM::FIELD<T>::setComponentsDescriptions(_s);
+ MEDMEM::FIELD<T,INTERLACING_TAG>::setComponentsDescriptions(_s);
s = _fieldPtr->getComponentsUnits();
for (int i=0; i<nc; i++)
_s[i] = s[i];
- MEDMEM::FIELD<T>::setMEDComponentsUnits(_s);
+ MEDMEM::FIELD<T,INTERLACING_TAG>::setMEDComponentsUnits(_s);
delete [] _s;
-
-// s = _fieldPtr->getComponentsDescriptions();
-// for (int i=0; i<nc; i++)
-// _s[i] = s[i];
-// F->setComponentsDescriptions(_s);
setIterationNumber(_fieldPtr->getIterationNumber());
setTime(_fieldPtr->getTime());
setOrderNumber(_fieldPtr->getOrderNumber());
fillCopy();
}
-template<class T>
-void FIELDClient<T>::fillCopy()
+template<class T, class INTERLACING_TAG>
+void FIELDClient<T,INTERLACING_TAG>::fillCopy()
{
- //setValueType(typeChamps); WARNING TO DO.....
- //setValueType(_fieldPtr->getValueType());
long n;
- typename mapCppSender<T>::SenderVarType sender=_fieldPtr->getSenderForValue(MED_EN::MED_FULL_INTERLACE);
+ typename FIELDI_TRAITS<T,INTERLACING_TAG>::SenderVarType sender=_fieldPtr->getSenderForValue(MEDMEM::FIELD<T,INTERLACING_TAG>::_interlacingType);
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);
+ MEDMEM::MEDMEM_Array_ * array;
+ if(_fieldPtr->getGaussPresence())
+ array=0;
+ //array=new typename MEDMEM::MEDMEM_ArrayInterface<T,INTERLACING_TAG,Gauss>::Array
+ // (v, MEDMEM::FIELD<T,INTERLACING_TAG>::getNumberOfComponents(),MEDMEM::FIELD<T,INTERLACING_TAG>::getNumberOfValues(),true,true);
+ else
+ array=new typename MEDMEM::MEDMEM_ArrayInterface<T,INTERLACING_TAG,NoGauss>::Array
+ (v, MEDMEM::FIELD<T,INTERLACING_TAG>::getNumberOfComponents(),MEDMEM::FIELD<T,INTERLACING_TAG>::getNumberOfValues(),true,true);
+ MEDMEM::FIELD<T,INTERLACING_TAG>::setArray(array);
}
-template<class T>
-FIELDClient<T>::~FIELDClient()
+template<class T, class INTERLACING_TAG>
+FIELDClient<T,INTERLACING_TAG>::~FIELDClient()
{
_fieldPtr->Destroy();
CORBA::release(_fieldPtr);
- if(FIELD<T>::_support)
- FIELD<T>::_support->removeReference();
+ if(FIELD<T,INTERLACING_TAG>::_support)
+ FIELD<T,INTERLACING_TAG>::_support->removeReference();
}
#include "SUPPORTClient.hxx"
#include "ReceiverFactory.hxx"
#include "SenderFactory.hxx"
+#include "MEDMEM_TraitsForFields.hxx"
+#include "MEDMEM_InterlacingTraits.hxx"
#include CORBA_CLIENT_HEADER(MED)
-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>
+template<class T, class INTERLACING_TAG>
+class FIELDClient : public MEDMEM::FIELD<T,INTERLACING_TAG>
{
private:
- typename MapCppFieldServ<T>::FieldPtrType _fieldPtr;
+ typename FIELDI_TRAITS<T,INTERLACING_TAG>::SimpleFieldCorbaPtrType _fieldPtr;
int _refCounter;
public:
- FIELDClient(typename MapCppFieldServ<T>::FieldPtrType ptrCorba,MEDMEM::SUPPORT * S = NULL);
+ FIELDClient(typename FIELDI_TRAITS<T,INTERLACING_TAG>::SimpleFieldCorbaPtrType ptrCorba,MEDMEM::SUPPORT * S = NULL);
~FIELDClient();
private:
void fillCopy();
GROUPClient.hxx \
FIELDClient.hxx \
FIELDClient.cxx \
- FIELDDOUBLEClient.hxx \
- FIELDINTClient.hxx \
libMEDClient.i
ifeq (@SWIG_VERSION@, 1.3.21)
MESHClient.cxx \
SUPPORTClient.cxx \
FAMILYClient.cxx \
- GROUPClient.cxx \
- FIELDDOUBLEClient.cxx \
- FIELDINTClient.cxx
+ GROUPClient.cxx
LIB_CLIENT_IDL= \
SALOME_Component.idl \
LDFLAGS= -L$(top_builddir)/lib/salome
LDFLAGSFORBIN= -L$(top_builddir)/lib/salome
-CPPFLAGS+= $(MED2_INCLUDES) $(HDF5_INCLUDES) $(PYTHON_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome
+CPPFLAGS+= $(MED2_INCLUDES) $(HDF5_INCLUDES) $(PYTHON_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome -I$(srcdir)/../../MEDMEM_I
CXXFLAGS+=-I${KERNEL_ROOT_DIR}/include/salome
LDFLAGS+=-L${KERNEL_ROOT_DIR}/lib/salome -lOpUtil -lMedCorba_Swigcmodule -lmedmem
setEntity(all->entity);
// modifs PN
setNumberOfGeometricType(all->numberOfGeometricType);
- convertCorbaArray(_geometricType, _numberOfGeometricType,
- &all->types);
-
- //_name = IOR_Support->getName();
- //_description = IOR_Support->getDescription();
- //setAll(IOR_Support->isOnAllElements());
- //setEntity(IOR_Support->getEntity());
+ convertCorbaArray2(_geometricType, _numberOfGeometricType, all->types);
SCRUTE(_name);
SCRUTE(_description);
- //convertCorbaArray(_geometricType, _numberOfGeometricType,
- // IOR_Support->getTypes());
int *nE = new int[_numberOfGeometricType];
int i;
BEGIN_OF("SUPPORTClient::fillCopy");
if (!_complete_support) {
-
+ if(!_isOnAllElts) {
const int * index, * value;
long n_index, n_value;
SCRUTE(n_index);
SCRUTE(n_value);
setNumber(index, value,true);
-
+ }
_complete_support = true;
}
return n;
}
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+int SUPPORTClient::getValIndFromGlobalNumber(const int number) const throw (MEDEXCEPTION)
+{
+ BEGIN_OF("SUPPORTClient::getValIndFromGlobalNumber()");
+
+ if (!_complete_support) (const_cast<SUPPORTClient *>(this))->fillCopy();
+ const int n = SUPPORT::getValIndFromGlobalNumber(number);
+
+ END_OF("SUPPORTClient::getValIndFromGlobalNumber()");
+ return n;
+}
+
//=============================================================================
/*!
*
const throw (MEDEXCEPTION);
const int * getNumberIndex()
const throw (MEDEXCEPTION);
+ int getValIndFromGlobalNumber(const int number)
+ const throw (MEDEXCEPTION);
void addReference() const;
void removeReference() const;
};
#include <vector>
#include <utilities.h>
+#include "MEDMEM_PointerOf.hxx"
namespace MEDMEM {
template <typename TLocal,
}
}
+template <typename TLocal,
+ typename TCorbaSeq,
+ typename Tint>
+inline void convertCorbaArray2 (TLocal& tab, Tint &nT, const TCorbaSeq s)
+{
+ Tint i, n = s.length();
+
+ nT = n;
+ tab.set(n);
+ for (i=0; i<n; i++) {
+ tab[i] = s[i];
+ }
+}
+
template <typename TCorba,
typename TLocal,
typename TCorbaSeq>
%{
#include "MESHClient.hxx"
#include "SUPPORTClient.hxx"
-#include "FIELDDOUBLEClient.hxx"
-#include "FIELDINTClient.hxx"
+#include "FIELDClient.hxx"
#include CORBA_CLIENT_HEADER(MED)
-/* #define FIELDDOUBLEClient FIELDClient<double,SALOME_MED::FIELDDOUBLE_ptr> */
-/* #define FIELDINTClient FIELDClient<int,SALOME_MED::FIELDINT_ptr> */
using namespace MEDMEM;
using namespace MED_EN;
$1 = ($input != 0);
}
+
class MESHClient : public MESH {
public:
};
-class FIELDDOUBLEClient : public FIELDDOUBLE {
+template<class T, class INTERLACING_TAG>
+class FIELDClient : public FIELD<T,INTERLACING_TAG>
+{
public:
- FIELDDOUBLEClient(SALOME_MED::FIELDDOUBLE_ptr ptrCorba,
- MEDMEM::SUPPORT * S = NULL);
+ template<class U>
+ FIELDClient(U ptrCorba,MEDMEM::SUPPORT * S = NULL);
+ ~FIELDClient();
+};
+
+%template (FIELDDOUBLEClient) FIELDClient<double, FullInterlace>;
+%template (FIELDDOUBLENOINTERLACEClient) FIELDClient<double, NoInterlace>;
+%template (FIELDINTClient) FIELDClient<int, FullInterlace>;
+%template (FIELDINTNOINTERLACEClient) FIELDClient<int, NoInterlace>;
+
+%extend FIELDClient<double, FullInterlace>
+{
+ %template(FIELDDOUBLEClients) FIELDClient<SALOME_MED::FIELDDOUBLE_ptr>;
+};
- ~FIELDDOUBLEClient();
+%extend FIELDClient<double, NoInterlace>
+{
+ %template(FIELDDOUBLENOINTERLACEClients) FIELDClient<SALOME_MED::FIELDDOUBLE_ptr>;
};
-class FIELDINTClient : public FIELDINT {
-public:
- FIELDINTClient(SALOME_MED::FIELDINT_ptr ptrCorba,
- MEDMEM::SUPPORT * S = NULL);
+%extend FIELDClient<int, FullInterlace>
+{
+ %template(FIELDINTClients) FIELDClient<SALOME_MED::FIELDINT_ptr>;
+};
- ~FIELDINTClient();
+%extend FIELDClient<int, NoInterlace>
+{
+ %template(FIELDINTNOINTERLACEClients) FIELDClient<SALOME_MED::FIELDINT_ptr>;
};
-FIELDDOUBLE * getDoublePointer(FIELDDOUBLEClient * input);
+FIELD<double> * getDoublePointer(FIELDClient<double,FullInterlace> * input);
+
+FIELD<double,NoInterlace> *getDoubleNoInterlacePointer(FIELDClient<double,NoInterlace> * input);
-FIELDINT * getIntPointer(FIELDINTClient * input);
+FIELD<int> * getIntPointer(FIELDClient<int,FullInterlace> * input);
+
+FIELD<int,NoInterlace> * getIntNoInterlacePointer(FIELDClient<int,NoInterlace> * input);
%{
- FIELDDOUBLE * getDoublePointer(FIELDDOUBLEClient * input)
+ FIELD<double> * getDoublePointer(FIELDClient<double,FullInterlace> * input)
+ {
+ return (FIELD<double> *) input;
+ }
+
+ FIELD<double,NoInterlace> *getDoubleNoInterlacePointer(FIELDClient<double,NoInterlace> * input)
{
- return (FIELDDOUBLE *) input;
+ return (FIELD<double,NoInterlace> *) input;
}
- FIELDINT * getIntPointer(FIELDINTClient * input)
+ FIELD<int> * getIntPointer(FIELDClient<int,FullInterlace> * input)
+ {
+ return (FIELD<int> *) input;
+ }
+
+ FIELD<int,NoInterlace> * getIntNoInterlacePointer(FIELDClient<int,NoInterlace> * input)
{
- return (FIELDINT *) input;
+ return (FIELD<int,NoInterlace> *) input;
}
%}
nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
print " Values:",nbOf
for k in range(nbOf):
- valueI = fieldTyped.getValueI(MED_FULL_INTERLACE,k+1)
+ valueI = fieldTyped.getRow(k+1)
print " *",valueI[:nbOfComp]
{
BEGIN_OF("void Compo2::Calcul3(const FIELD<double> *)");
- const double *v = F.getValue(MED_FULL_INTERLACE);
+ const double *v = F.getValue();
long i, n = F.getSupport()->getNumberOfElements(MED_CELL);
int j, m = F.getNumberOfComponents();
%{
#include "MEDMEM_convert.hxx"
#include "MEDMEM_Family_i.hxx"
-#include "MEDMEM_FieldDouble_i.hxx"
#include "MEDMEM_Field_i.hxx"
-#include "MEDMEM_FieldInt_i.hxx"
+#include "MEDMEM_FieldTemplate_i.hxx"
#include "MEDMEM_Group_i.hxx"
#include "MEDMEM_Med_i.hxx"
#include "MEDMEM_Mesh_i.hxx"
#include "MEDMEM_Support_i.hxx"
-// #include "MEDMEM_SWIG_FieldDouble.hxx"
-// #include "MEDMEM_SWIG_FieldInt.hxx"
using namespace MEDMEM;
using namespace MED_EN;
field->setDescription("Got From A Local One");
- FIELDDOUBLE_i * fieldimpl = new FIELDDOUBLE_i(field, ownCppPtr);
+ FIELDTEMPLATE_I<double,FullInterlace> *fieldimpl = new FIELDTEMPLATE_I<double,FullInterlace>(field, ownCppPtr);
SALOME_MED::FIELDDOUBLE_ptr fieldcorba2 = fieldimpl->_this();
field->setDescription("Got From A Local One");
- FIELDINT_i * fieldimpl = new FIELDINT_i(field, ownCppPtr);
+ FIELDTEMPLATE_I<int,FullInterlace> * fieldimpl = new FIELDTEMPLATE_I<int,FullInterlace>(field, ownCppPtr);
SALOME_MED::FIELDINT_ptr fieldcorba2 = fieldimpl->_this();