1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 %module libMEDMEM_Swig
28 #include "MEDMEM_CellModel.hxx"
29 #include "MEDMEM_GenDriver.hxx"
30 #include "MEDMEM_MedMeshDriver.hxx"
31 #include "MEDMEM_GibiMeshDriver.hxx"
32 #include "MEDMEM_PorflowMeshDriver.hxx"
33 #include "MEDMEM_Connectivity.hxx"
34 #include "MEDMEM_Group.hxx"
35 #include "MEDMEM_SkyLineArray.hxx"
36 #include "MEDMEM_Coordinate.hxx"
37 #include "MEDMEM_Array.hxx"
38 #include "MEDMEM_Mesh.hxx"
39 #include "MEDMEM_define.hxx"
40 #include "MEDMEM_Exception.hxx"
41 #include "MEDMEM_STRING.hxx"
42 #include "MEDMEM_DriversDef.hxx"
43 #include "MEDMEM_MedFieldDriver.hxx"
44 #include "MEDMEM_Support.hxx"
45 #include "MEDMEM_Family.hxx"
46 #include "MEDMEM_Unit.hxx"
47 #include "MEDMEM_Field.hxx"
48 #include "MEDMEM_FieldConvert.hxx"
49 #include "MEDMEM_Grid.hxx"
50 #include "MEDMEM_Meshing.hxx"
51 #include "MEDMEM_DriverFactory.hxx"
52 #include "MEDMEM_GaussLocalization.hxx"
53 #include "MEDMEM_EnsightMedDriver.hxx"
54 #include "MEDMEM_EnsightMeshDriver.hxx"
55 #include "MEDMEM_EnsightFieldDriver.hxx"
56 #include "MEDMEM_ArrayInterface.hxx"
57 #include "MEDMEM_MedFileBrowser.hxx"
58 #include "PointLocator.hxx"
59 #include "MEDMEM_VtkMedDriver.hxx"
61 #include "MEDMEM_SWIG_Templates.hxx"
63 template< typename T >
64 PyObject * TYPEMAP_OUTPUT_PY_ARRAY(const T* value, int size)
66 npy_intp dim = (npy_intp) size;
67 return PyArray_SimpleNewFromData(1,&dim, Binding<T>::numpy_type(),(T*)value);
71 using namespace MEDMEM;
72 using namespace MED_EN;
73 using namespace INTERP_KERNEL;
74 typedef FIELD <double, FullInterlace> FIELDDOUBLE;
75 typedef FIELD <int , FullInterlace> FIELDINT;
76 typedef FIELD <double, NoInterlace> FIELDDOUBLENOINTERLACE;
77 typedef FIELD <int , NoInterlace> FIELDINTNOINTERLACE;
78 typedef FIELD <double, NoInterlaceByType> FIELDDOUBLENOINTERLACEBYTYPE;
79 typedef FIELD <int , NoInterlaceByType> FIELDINTNOINTERLACEBYTYPE;
81 // to keep old scripts working
82 typedef enum {MED_LECT=RDONLY, MED_ECRI=WRONLY, MED_REMP=RDWR} med_mode_acces_old;
87 SWIG needs these typedefs to wrap FIELDDOUBLE*, for ex., to something like
88 <C++ FIELD<double> instance at _d0709808_p_FIELDDOUBLE>, not to
89 <SWIG Object at _d0709808_p_FIELDDOUBLE> which has no attributes
92 typedef FIELD <double, FullInterlace> FIELDDOUBLE;
93 typedef FIELD <int , FullInterlace> FIELDINT;
94 typedef FIELD <double, NoInterlace> FIELDDOUBLENOINTERLACE;
95 typedef FIELD <int , NoInterlace> FIELDINTNOINTERLACE;
96 typedef FIELD <double, NoInterlaceByType> FIELDDOUBLENOINTERLACEBYTYPE;
97 typedef FIELD <int , NoInterlaceByType> FIELDINTNOINTERLACEBYTYPE;
100 %include "my_typemap.i"
102 %typecheck(SWIG_TYPECHECK_POINTER) double *, const double *,
103 const double * const, int *, const int *, const int * const, string *,
104 const string *, const string * const, medGeometryElement *,
105 const medGeometryElement *, const medGeometryElement * const
111 mapping between stl string and python string
114 %include "std_string.i"
118 managing C++ exception in the Python API
123 //class PyAllowThreadsGuard {
125 // PyAllowThreadsGuard() { _save = PyEval_SaveThread(); }
126 // ~PyAllowThreadsGuard() { PyEval_RestoreThread(_save); }
128 // PyThreadState *_save;
133 //PyAllowThreadsGuard guard;
136 catch(MEDEXCEPTION& exception)
138 PyErr_SetString(PyExc_RuntimeError,exception.what());
144 managing the use of operator= of any class by renaming it assign()
145 because assignment can't be overloaded in python.
147 In python, you would then use
152 %rename(assign) *::operator=;
155 typemap in for PyObject * fonction Python wrapping of a
156 double or int fonction pointeur
159 #if defined(SWIGPYTHON)
160 %typemap(in) PyObject * double_function, PyObject * integer_function
162 /* typemap in for double or integer callable fonction pointeur */
163 /* Check if it is a callable fonction pointer */
165 if(PyCallable_Check($input) == 0)
167 const char * message = "Error in typemap(python,in) for double or integer callable fonction pointeur : the argument should be a callable object";
168 PyErr_SetString(PyExc_RuntimeError, message);
177 MACRO converting C++ MEDMEM::FIELD_ pointer into a PyObject pointer rightly
178 casted following its value type (int or double) and its interlacing mode
179 (FullInterlace or NoInterlace) by calling the function SWIG_NewPointer with
180 the appropriate $descriptor(...)
183 %define TYPEMAP_OUTPUT_FIELDT(myField)
185 FIELD_ *arg1=myField;
186 PyObject *myResult=NULL;
189 FIELD<double> *try1=dynamic_cast<FIELD<double> *>(arg1);
191 myResult = SWIG_NewPointerObj((void *) try1, $descriptor(FIELD<double, FullInterlace> *), 0);
194 FIELD<int> *try2=dynamic_cast<FIELD<int> *>(arg1);
196 myResult = SWIG_NewPointerObj((void *) try2, $descriptor(FIELD<int, FullInterlace> *), 0);
199 FIELD<double, NoInterlace> *try3=dynamic_cast<FIELD<double, NoInterlace> *>(arg1);
201 myResult = SWIG_NewPointerObj((void *) try3, $descriptor(FIELD<double, NoInterlace> *), 0);
204 FIELD<int, NoInterlace> *try4=dynamic_cast<FIELD<int, NoInterlace> *>(arg1);
206 myResult = SWIG_NewPointerObj((void *) try4, $descriptor(FIELD<int, NoInterlace> *), 0);
209 myResult = SWIG_NewPointerObj((void *) arg1, $descriptor(FIELD_ *), 0);
220 MACRO converting C array <arrayvar> of length <size> into a PyList
221 by calling type_converter() for each array element.
222 It reports error in <method> in failure case
225 %define TYPEMAP_OUTPUT_ARRAY(arrayvar, size, type_converter, method)
227 PyObject *py_list = PyList_New(size);
228 for (int i=0; i < int(size); i++)
230 int err = PyList_SetItem(py_list, i, type_converter( arrayvar[ i ]));
233 const char * message = "Error in " #method;
234 PyErr_SetString(PyExc_RuntimeError, message);
239 PyObject * result = Py_BuildValue("O", py_list);
246 Helper function to be used as type_converter in TYPEMAP_OUTPUT_ARRAY
250 PyObject *PyString_FromStdString(const std::string &str)
252 return PyString_FromString(str.c_str());
256 /**************************************************
257 IN typemaps for some std::vector's
258 **************************************************/
260 /* MACRO: IN typemap for std::vector<TYPE> C++ object */
261 %define TYPEMAP_INPUT_VECTOR_BY_VALUE( TYPE )
263 /* typemap in for vector<TYPE> */
264 /* Check if is a list */
265 if (PyList_Check($input))
267 int size = PyList_Size($input);
268 vector< TYPE > tmpVec(size);
270 for (int i=0; i < size; i++)
272 PyObject * tmp = PyList_GetItem($input,i);
275 int err = SWIG_ConvertPtr(tmp, (void **) &elem, $descriptor(TYPE),
276 SWIG_POINTER_EXCEPTION);
279 const char * message = "Error in typemap(python,in) for vector<TYPE>"
280 "each component should be a TYPE";
281 PyErr_SetString(PyExc_RuntimeError, message);
290 PyErr_SetString(PyExc_TypeError,"not a list");
296 #if defined(SWIGPYTHON)
297 %typemap(in) vector< FAMILY* >, const vector< FAMILY* >
298 { TYPEMAP_INPUT_VECTOR_BY_VALUE( FAMILY * ) }
301 #if defined(SWIGPYTHON)
302 %typemap(in) vector< SUPPORT* >, const vector< SUPPORT* >
303 { TYPEMAP_INPUT_VECTOR_BY_VALUE( SUPPORT * ) }
306 #if defined(SWIGPYTHON)
307 %typemap(in) vector< FIELDDOUBLE* >, const vector< FIELDDOUBLE* >
308 { TYPEMAP_INPUT_VECTOR_BY_VALUE( FIELDDOUBLE * ) }
311 #if defined(SWIGPYTHON)
312 %typemap(in) vector< FIELD_* >, const vector< FIELD_* >
313 { TYPEMAP_INPUT_VECTOR_BY_VALUE( FIELD_ * ) }
316 #if defined(SWIGPYTHON)
317 %typemap(in) vector< const FIELD_* >, const vector< const FIELD_* >
318 { TYPEMAP_INPUT_VECTOR_BY_VALUE( const FIELD_ * ) }
321 #if defined(SWIGPYTHON)
322 %typemap(in) vector< FIELDINT* >, const vector< FIELDINT* >
323 { TYPEMAP_INPUT_VECTOR_BY_VALUE( FIELDINT * ) }
326 #if defined(SWIGPYTHON)
327 %typemap(in) vector< FIELDDOUBLENOINTERLACE* >, const vector< FIELDDOUBLENOINTERLACE* >
328 { TYPEMAP_INPUT_VECTOR_BY_VALUE( FIELDDOUBLENOINTERLACE * ) }
331 #if defined(SWIGPYTHON)
332 %typemap(in) vector< FIELDINTNOINTERLACE* >, const vector< FIELDINTNOINTERLACE* >
333 { TYPEMAP_INPUT_VECTOR_BY_VALUE( FIELDINTNOINTERLACE * ) }
336 /**************************************************
337 OUT typemaps for some std::vector's
338 **************************************************/
340 /* MACRO: OUT typemap for std::vector<TYPE> C++ object */
341 %define TYPEMAP_OUTPUT_VECTOR_BY_VALUE( TYPE )
343 /* typemap out for vector<TYPE> */
344 int size = $1.size();
345 $result = PyList_New(size);
347 for (int i=0;i<size;i++)
349 PyObject * tmp = SWIG_NewPointerObj($1.at(i),$descriptor(TYPE),0);
351 PyList_SetItem($result,i,tmp);
356 #if defined(SWIGPYTHON)
357 %typemap(out) vector< FAMILY* >
358 { TYPEMAP_OUTPUT_VECTOR_BY_VALUE( FAMILY * ) }
361 #if defined(SWIGPYTHON)
362 %typemap(out) vector< SUPPORT* >
363 { TYPEMAP_OUTPUT_VECTOR_BY_VALUE( SUPPORT * ) }
366 #if defined(SWIGPYTHON)
367 %typemap(out) vector< FIELDDOUBLE* >
368 { TYPEMAP_OUTPUT_VECTOR_BY_VALUE( FIELDDOUBLE * ) }
371 #if defined(SWIGPYTHON)
372 %typemap(out) vector< FIELDINT* >
373 { TYPEMAP_OUTPUT_VECTOR_BY_VALUE( FIELDINT * ) }
376 #if defined(SWIGPYTHON)
377 %typemap(out) vector< FIELDDOUBLENOINTERLACE* >
378 { TYPEMAP_OUTPUT_VECTOR_BY_VALUE( FIELDDOUBLENOINTERLACE * ) }
381 #if defined(SWIGPYTHON)
382 %typemap(out) vector< FIELDINTNOINTERLACE* >
383 { TYPEMAP_OUTPUT_VECTOR_BY_VALUE( FIELDINTNOINTERLACE * ) }
388 enum of the C++ MED used in the Python API
391 typedef enum {MED_CARTESIAN, MED_POLAR, MED_BODY_FITTED} med_grid_type;
393 typedef enum {MED_FULL_INTERLACE, MED_NO_INTERLACE} medModeSwitch;
395 typedef enum {RDONLY, WRONLY, RDWR} med_mode_acces;
396 typedef enum {MED_LECT, MED_ECRI, MED_REMP} med_mode_acces_old;// to keep old scripts working
398 typedef enum {ASCENDING=7,DESCENDING=77} med_sort_direc;
400 typedef enum {MED_CELL, MED_FACE, MED_EDGE, MED_NODE,
401 MED_ALL_ENTITIES} medEntityMesh;
403 typedef enum {MED_NONE=0, MED_POINT1=1, MED_SEG2=102, MED_SEG3=103,
404 MED_TRIA3=203, MED_QUAD4=204, MED_TRIA6=206, MED_QUAD8=208,
405 MED_TETRA4=304, MED_PYRA5=305, MED_PENTA6=306,
406 MED_HEXA8=308, MED_TETRA10=310, MED_PYRA13=313,
407 MED_PENTA15=315, MED_HEXA20=320, MED_POLYGON = 400, MED_POLYHEDRA = 500,
408 MED_ALL_ELEMENTS=999} medGeometryElement;
410 typedef enum {MED_NODAL, MED_DESCENDING} medConnectivity ;
412 typedef enum {MED_DRIVER=0, GIBI_DRIVER=1, PORFLOW_DRIVER = 2, VTK_DRIVER=254,
413 NO_DRIVER=255, ASCII_DRIVER = 3, ENSIGHT_DRIVER = 250 } driverTypes;
415 typedef enum {MED_REEL64=6, MED_INT32=24, MED_INT64=26} med_type_champ;
417 typedef struct { int dt; int it; } DT_IT_;
419 typedef enum {V21 = 26, V22 = 75} medFileVersion;
421 %feature("unref") SUPPORT "$this->removeReference();"
422 %feature("unref") GMESH "$this->removeReference();"
423 %feature("unref") MESH "$this->removeReference();"
424 %feature("unref") FIELDDOUBLE "$this->removeReference();"
425 %feature("unref") FIELDINT "$this->removeReference();"
426 %feature("unref") FIELDDOUBLENOINTERLACE "$this->removeReference();"
427 %feature("unref") FIELDINTNOINTERLACE "$this->removeReference();"
428 %feature("unref") FIELDDOUBLENOINTERLACEBYTYPE "$this->removeReference();"
429 %feature("unref") FIELDINTNOINTERLACEBYTYPE "$this->removeReference();"
443 %typecheck(SWIG_TYPECHECK_POINTER) vector< SUPPORT * >, const vector< SUPPORT * >, vector< const FIELD_* >
449 Class et methodes du MED++ que l'on utilise dans l'API Python
457 CELLMODEL(medGeometryElement t);
459 CELLMODEL(const CELLMODEL &m);
461 int getNumberOfVertexes();
463 int getNumberOfNodes();
467 medGeometryElement getType();
469 int getNumberOfConstituents(int dim);
471 int getNodeConstituent(int dim,int num,int nodes_index);
473 medGeometryElement getConstituentType(int dim,int num);
475 int getNumberOfConstituentsType();
477 std::string getName() const;
482 %newobject __str__();
483 const char* __str__()
486 mess << "Python Printing CELLMODEL : " << *self << endl;
487 return strdup(mess.str().c_str());
497 SUPPORT(const SUPPORT & m);
501 void update ( void );
503 MESH * getMesh() const;
505 std::string getMeshName() const;
507 void setMesh(MESH * Mesh) const;
509 medEntityMesh getEntity() const;
511 void setEntity(medEntityMesh Entity);
513 bool isOnAllElements() const;
515 void setAll(bool All);
517 int getNumberOfTypes() const;
519 void setNumberOfGeometricType(int NumberOfGeometricType);
521 int getNumberOfElements(medGeometryElement GeometricType) const;
523 void setGeometricType(medGeometryElement *GeometricType);
525 void setNumberOfElements(int *NumberOfElements);
527 void getBoundaryElements();
529 void setNumber(const int * index, const int* value);
531 bool deepCompare(const SUPPORT &support) const;
533 void setpartial(std::string Description, int NumberOfGeometricType,
534 int TotalNumberOfElements, medGeometryElement *GeometricType,
535 int *NumberOfElements, int *NumberValue);
537 std::string getName() const;
539 void setName(std::string Name);
541 std::string getDescription();
543 void setDescription(std::string Description);
547 SUPPORT* buildSupportOnNode();
550 %newobject __str__();
551 const char* __str__()
554 mess << "Python Printing SUPPORT : " << *self << endl;
555 char * tmp = const_cast <char *> (mess.str().c_str());
556 char * returned = strdup(tmp);
560 PyObject * getTypes()
562 const medGeometryElement * types = self->getTypes();
563 int size = self->getNumberOfTypes();
564 TYPEMAP_OUTPUT_ARRAY(types, size, PyInt_FromLong, SUPPORT::getTypes);
567 PyObject * getNumber(medGeometryElement GeometricType)
569 const int * number = self->getNumber(GeometricType);
570 int size = self->getNumberOfElements(GeometricType);
571 TYPEMAP_OUTPUT_ARRAY(number, size, PyInt_FromLong,
575 PyObject * getNumberIndex()
577 const int * numberindex = self->getNumberIndex();
578 int size = (self->getNumberOfTypes())+1;
579 TYPEMAP_OUTPUT_ARRAY(numberindex, size, PyInt_FromLong,
580 SUPPORT::getNumberIndex);
583 %newobject getComplement() const;
584 SUPPORT *getComplement() const
586 return self->getComplement();
589 %newobject substract(const SUPPORT& other) const;
590 SUPPORT *substract(const SUPPORT& other) const
592 return self->substract(other);
595 %newobject getBoundaryElements(medEntityMesh Entity) const;
596 SUPPORT *getBoundaryElements(medEntityMesh Entity) const
598 return self->getBoundaryElements(Entity);
603 class FAMILY : public SUPPORT
608 FAMILY(const FAMILY & m);
612 FAMILY & operator=(const FAMILY &fam);
614 void setIdentifier(int Identifier);
616 void setNumberOfAttributes(int NumberOfAttribute);
618 void setAttributesIdentifiers(int * AttributeIdentifier);
620 void setAttributesValues(int * AttributeValue);
622 void setAttributesDescriptions(std::string * AttributeDescription);
624 void setNumberOfGroups(int NumberOfGroups);
626 void setGroupsNames(std::string * GroupName);
628 int getIdentifier() const;
630 int getNumberOfAttributes() const;
632 int getNumberOfGroups() const;
634 FAMILY(MESH* Mesh, int Identifier, std::string Name, int NumberOfAttribute,
635 int *AttributeIdentifier, int *AttributeValue,
636 std::string AttributeDescription, int NumberOfGroup,
637 std::string GroupName, int * MEDArrayNodeFamily,
638 int ** MEDArrayCellFamily, int ** MEDArrayFaceFamily,
639 int ** MEDArrayEdgeFamily);
641 std::string getAttributeDescription(int i);
643 std::string getGroupName(int i);
646 %newobject __str__();
647 const char* __str__()
650 mess << "Python Printing Family : " << *self << endl;
651 return strdup(mess.str().c_str());
654 PyObject * getAttributesIdentifiers()
656 const int * attributesids = self->getAttributesIdentifiers();
657 int size = self->getNumberOfAttributes();
658 TYPEMAP_OUTPUT_ARRAY(attributesids,size,PyInt_FromLong,
659 FAMILY::getAttributesIdentifiers);
662 PyObject * getAttributesValues()
664 const int * attributesvals = self->getAttributesValues();
665 int size = self->getNumberOfAttributes();
666 TYPEMAP_OUTPUT_ARRAY(attributesvals,size,PyInt_FromLong,
667 FAMILY::getAttributesValues);
681 std::string getFileName () const;
682 void setFileName ( const std::string & fileName);
684 void setMeshName ( const std::string & meshName);
685 std::string getMeshName();
687 void setFieldName ( const std::string & fieldName);
688 std::string getFieldName() const;
695 FIELD_(const SUPPORT * Support, const int NumberOfComponents);
699 void rmDriver(int index=0);
701 void read (driverTypes driverType, const std::string & fileName);
702 void read (const GENDRIVER &);
703 void read(int index=0);
705 void write(const GENDRIVER& driver, med_mode_acces medMode=RDWR);
706 void write(driverTypes driverType, const char* filename,
707 med_mode_acces medMode=RDWR);
708 void write(int index=0);
710 void writeAppend(int index=0, const std::string& driverName="");
712 void setIterationNumber (int IterationNumber);
713 int getIterationNumber() const;
715 void setTime(double Time);
716 double getTime() const;
718 void setOrderNumber (int OrderNumber);
719 int getOrderNumber() const;
721 med_type_champ getValueType() ;
723 medModeSwitch getInterlacingType();
725 SUPPORT * getSupport();
726 void setSupport(SUPPORT * support);
728 void setNumberOfComponents(int NumberOfComponents);
729 int getNumberOfComponents() const;
731 void setNumberOfValues(int NumberOfValues);
732 int getNumberOfValues() const;
734 std::string getName() const;
736 std::string getDescription() const;
738 std::string getComponentName(int i) const;
740 std::string getComponentDescription(int i) const;
742 std::string getMEDComponentUnit(int i) const;
744 void setName(std::string Name);
746 void setComponentName(int i, std::string ComponentName);
748 void setMEDComponentUnit(int i, std::string MEDComponentUnit);
750 void setDescription(std::string Description);
752 void setComponentDescription(int i, std::string ComponentDescription);
754 int addDriver(driverTypes driverType,
755 const std::string& fileName="Default File Name.med",
756 const std::string& driverName="Default Field Name",
757 med_mode_acces access=RDWR);
760 %newobject getSupportAndOwner();
761 SUPPORT * getSupportAndOwner()
763 return (SUPPORT *)self->getSupport();
765 PyObject* castToTypedField()
767 if ( self->getValueType() == MED_REEL64 )
768 switch( self->getInterlacingType() ) {
769 case MED_FULL_INTERLACE:
770 return SWIG_NewPointerObj((void *)self, $descriptor(FIELDDOUBLE *), 0);
771 case MED_NO_INTERLACE:
772 return SWIG_NewPointerObj((void *)self, $descriptor(FIELDDOUBLENOINTERLACE *), 0);
773 case MED_NO_INTERLACE_BY_TYPE:
774 return SWIG_NewPointerObj((void *)self, $descriptor(FIELDDOUBLENOINTERLACEBYTYPE *), 0);
776 PyErr_SetString(PyExc_RuntimeError,"Invalid interlacing type of a field");
780 switch( self->getInterlacingType() ) {
781 case MED_FULL_INTERLACE:
782 return SWIG_NewPointerObj((void *)self, $descriptor(FIELD<int, FullInterlace> *), 0);
783 case MED_NO_INTERLACE:
784 return SWIG_NewPointerObj((void *)self, $descriptor(FIELD<int, NoInterlace> *), 0);
785 case MED_NO_INTERLACE_BY_TYPE:
786 return SWIG_NewPointerObj((void *)self, $descriptor(FIELD<int, NoInterlaceByType> *), 0);
788 PyErr_SetString(PyExc_RuntimeError,"Invalid interlacing type of a field");
797 Class FIELD has now two template parameters: T1 is a double or an int,
798 INTERLACING_TAG is FullInterlace or NoInterlace
801 template<class T1, class INTERLACING_TAG> class FIELD : public FIELD_
806 FIELD(const SUPPORT * Support, const int NumberOfComponents);
810 FIELD(const FIELD & m);
812 FIELD(const SUPPORT * Support, driverTypes driverType,
813 const std::string& fileName, const std::string& fieldName,
814 const int iterationNumber, const int orderNumber);
816 FIELD(driverTypes driverType, const char* fileName, const char* fieldName,
817 int iterationNumber, int orderNumber, GMESH* mesh=0);
819 T1 getValueIJ(int i,int j) const;
821 T1 getValueIJK(int i,int j, int k) const;
823 T1 getValueIJByType(int i,int j, int type) const;
825 T1 getValueIJKByType(int i,int j, int k, int type) const;
827 void setValue(T1* value);
829 void setRow( int i, T1 * value);
831 void setColumn( int i, T1 * value);
833 void setValueIJ(int i, int j, T1 value);
835 void setValueIJK(int i, int j, int k, T1 value);
837 void setValueIJByType(int i, int j, int type, T1 value);
839 void setValueIJKByType(int i, int j, int k, int type, T1 value);
841 void allocValue(const int NumberOfComponents);
845 void applyLin(T1 a, T1 n);
847 void applyPow(T1 scalar);
853 double normL2(int component,const FIELD<double, FullInterlace> *
854 p_field_volume=NULL) const;
856 double normL2(const FIELD<double, FullInterlace> *
857 p_field_volume=NULL) const;
859 double normL1(int component, const FIELD<double, FullInterlace> *
860 p_field_volume=NULL) const;
862 double normL1(const FIELD<double, FullInterlace> *
863 p_field_volume=NULL) const;
865 double integral(const SUPPORT* subSupport=0);
867 bool getGaussPresence();
869 GAUSS_LOCALIZATION<INTERLACING_TAG> * getGaussLocalizationPtr(medGeometryElement geomElement);
871 int getNbGaussI(int i);
876 * \brief create a field with default gauss localizations
878 FIELD(const SUPPORT * support, const int numberOfComponents, const int* nbGaussByType)
880 FIELD<T1,INTERLACING_TAG>* f = new FIELD<T1,INTERLACING_TAG>(support,numberOfComponents);
882 int nbtypegeo = support->getNumberOfTypes();
883 vector<int> nbelgeoc (nbtypegeo+1,0);
884 const int * nbElemByType = support->getNumberOfElements();
885 for (int iType = 0; iType < nbtypegeo; ++iType)
887 nbelgeoc [ iType+1 ] = nbelgeoc[ iType ] + nbElemByType[ iType ];
888 MED_EN::medGeometryElement type = support->getTypes()[ iType ];
889 ostringstream locname;
890 locname << nbGaussByType[iType] << "points_on" << type << "geomType";
891 f->setGaussLocalization
893 GAUSS_LOCALIZATION_::makeDefaultLocalization( locname.str(),
895 nbGaussByType[ iType ]));
897 typedef MEDMEM_ArrayInterface<T1,INTERLACING_TAG,Gauss>::Array Array;
898 Array* array = new Array(numberOfComponents,
899 support->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS),
900 support->getNumberOfTypes(),
903 f->setArray( array );
907 PyObject * getNumberOfGaussPoints()
909 int size = self->getNumberOfGeometricTypes();
911 const int * value = self->getNumberOfGaussPoints();
912 TYPEMAP_OUTPUT_ARRAY(value, size, PyInt_FromLong, FIELD::getNumberOfGaussPoints());
917 PyObject * applyPyFunc( PyObject * func )
919 MESSAGE_MED("Appel de applyPyFunc");
920 if (!PyCallable_Check(func)) {
921 PyErr_SetString(PyExc_TypeError, "FIELD.applyPyFunc prend en argument une fonction");
925 int nComp=self->getNumberOfComponents();
926 int nVal=self->getNumberOfValues();
927 for (int i=1; i!=nVal+1; ++i)
928 for ( int j=1 ;j!=nComp+1 ;++j )
930 self->setValueIJ(i,j, Binding<T1>::Functor( func, self->getValueIJ(i,j) ) );
933 PyObject * result = Binding<double>::Traducer(nComp*nVal);
937 %newobject execFunc( int nbOfCompo, PyObject * func );
938 FIELD<T1, INTERLACING_TAG> *execFunc( int nbOfCompo, PyObject *func )
940 MyFunction<T1,T1>::_pyFunc=func;
941 MyFunction<T1,T1>::_nbOfComponent=nbOfCompo;
942 MyFunction<T1,T1>::_spaceDim=self->getNumberOfComponents();
943 return self->execFunc(nbOfCompo, MyFunction<T1,T1>::EvalPy2Cpp);
946 %newobject __add__(const FIELD<T1, INTERLACING_TAG> & );
947 FIELD<T1, INTERLACING_TAG> * __add__(const FIELD<T1, INTERLACING_TAG> & m)
949 MESSAGE_MED("operator + : Creation of the addition of two FIELDs");
951 FIELD<T1, INTERLACING_TAG>* result =
952 FIELD<T1, INTERLACING_TAG>::add( *(FIELD<T1, INTERLACING_TAG>*)self ,
953 (FIELD<T1, INTERLACING_TAG>&)m );
954 return (FIELD<T1, INTERLACING_TAG>*) result;
957 %newobject __sub__(const FIELD<T1, INTERLACING_TAG> & );
958 FIELD<T1, INTERLACING_TAG> * __sub__(const FIELD<T1, INTERLACING_TAG> & m)
960 MESSAGE_MED("operator - : Creation of the substraction of two FIELDs");
961 FIELD<T1, INTERLACING_TAG>* result =
962 FIELD<T1, INTERLACING_TAG>::sub( *(FIELD<T1, INTERLACING_TAG>*)self ,
963 (FIELD<T1, INTERLACING_TAG>&)m );
964 return (FIELD<T1, INTERLACING_TAG>*) result;
967 %newobject __mul__(const FIELD<T1, INTERLACING_TAG> & );
968 FIELD<T1, INTERLACING_TAG> * __mul__(const FIELD<T1, INTERLACING_TAG> & m)
970 MESSAGE_MED("operator * : Creation of the multiplication of two FIELDs");
971 FIELD<T1, INTERLACING_TAG>* result =
972 FIELD<T1, INTERLACING_TAG>::mul( *(FIELD<T1, INTERLACING_TAG>*)self ,
973 (FIELD<T1, INTERLACING_TAG>&)m );
974 return (FIELD<T1, INTERLACING_TAG>*) result;
977 %newobject __div__(const FIELD<T1, INTERLACING_TAG> & );
978 FIELD<T1, INTERLACING_TAG> * __div__(const FIELD<T1, INTERLACING_TAG> & m)
980 MESSAGE_MED("operator / : Creation of the division of two FIELDs");
981 FIELD<T1, INTERLACING_TAG>* result =
982 FIELD<T1, INTERLACING_TAG>::div( *(FIELD<T1, INTERLACING_TAG>*)self ,
983 (FIELD<T1, INTERLACING_TAG>&)m );
984 return (FIELD<T1, INTERLACING_TAG>*) result;
987 %newobject addDeep(const FIELD<T1, INTERLACING_TAG> & );
988 FIELD<T1, INTERLACING_TAG> * addDeep(const FIELD<T1, INTERLACING_TAG> & m)
990 MESSAGE_MED("operator + : Creation of the addition of two FIELDINTs");
991 FIELD<T1, INTERLACING_TAG>* result =
992 FIELD<T1, INTERLACING_TAG>::addDeep( *(FIELD<T1, INTERLACING_TAG>*)self ,
993 (FIELD<T1, INTERLACING_TAG>&)m );
994 return (FIELD<T1, INTERLACING_TAG>*) result;
997 %newobject subDeep(const FIELD<T1, INTERLACING_TAG> & );
998 FIELD<T1, INTERLACING_TAG> * subDeep(const FIELD<T1, INTERLACING_TAG> & m)
1000 MESSAGE_MED("operator - : Creation of the substraction of two FIELDs");
1001 FIELD<T1, INTERLACING_TAG>* result =
1002 FIELD<T1, INTERLACING_TAG>::subDeep( *(FIELD<T1, INTERLACING_TAG>*)self ,
1003 (FIELD<T1, INTERLACING_TAG>&)m );
1004 return (FIELD<T1, INTERLACING_TAG>*) result;
1007 %newobject mulDeep(const FIELD<T1, INTERLACING_TAG> & );
1008 FIELD<T1, INTERLACING_TAG> * mulDeep(const FIELD<T1, INTERLACING_TAG> & m)
1010 MESSAGE_MED("operator * : Creation of the multiplication of two FIELDs");
1011 FIELD<T1, INTERLACING_TAG>* result =
1012 FIELD<T1, INTERLACING_TAG>::mulDeep( *(FIELD<T1, INTERLACING_TAG>*)self ,
1013 (FIELD<T1, INTERLACING_TAG>&)m );
1014 return (FIELD<T1, INTERLACING_TAG>*) result;
1017 %newobject divDeep(const FIELD<T1, INTERLACING_TAG> & );
1018 FIELD<T1, INTERLACING_TAG> * divDeep(const FIELD<T1, INTERLACING_TAG> & m)
1020 MESSAGE_MED("operator / : Creation of the division of two FIELDs");
1021 FIELD<T1, INTERLACING_TAG>* result =
1022 FIELD<T1, INTERLACING_TAG>::divDeep( *(FIELD<T1, INTERLACING_TAG>*)self ,
1023 (FIELD<T1, INTERLACING_TAG>&)m );
1024 return (FIELD<T1, INTERLACING_TAG>*) result;
1027 PyObject * getValue()
1029 int size = self->getValueLength();
1031 const T1 * value = self->getValue();
1034 return TYPEMAP_OUTPUT_PY_ARRAY( value, size );
1036 TYPEMAP_OUTPUT_ARRAY(value, size, Binding< T1 >::Traducer,FIELD::getValue);
1040 // returns values for geom type in NoInterlaceByType mode
1041 PyObject * getValueByType(int type)
1043 int size = self->getValueByTypeLength(type);
1045 const T1 * value = self->getValueByType(type);
1048 return TYPEMAP_OUTPUT_PY_ARRAY( value, size );
1050 TYPEMAP_OUTPUT_ARRAY(value, size, Binding< T1 >::Traducer,FIELD::getValueByType());
1054 // this method replaces getValueI() in FullInterlace mode
1055 PyObject * getRow(int index)
1057 int size = self->getNumberOfComponents() * self->getNbGaussI( index );
1059 const T1 * value = self->getRow(index);
1061 TYPEMAP_OUTPUT_ARRAY(value, size, Binding< T1 >::Traducer,
1065 // this method replaces getValueI() in NoInterlace mode
1066 PyObject * getColumn(int index)
1068 int size = (self->getSupport())->getNumberOfElements(MED_ALL_ELEMENTS);
1070 const T1 * value = self->getColumn(index);
1072 TYPEMAP_OUTPUT_ARRAY(value, size, Binding< T1 >::Traducer,
1076 void allocValue2(int NumberOfComponents, int LengthValue)
1078 self->allocValue(NumberOfComponents, LengthValue);
1081 %newobject extract(const SUPPORT *subSupport);
1082 FIELD<T1, INTERLACING_TAG> *extract(const SUPPORT *subSupport)
1084 FIELD<T1, INTERLACING_TAG>* result=self->extract(subSupport);
1085 return (FIELD<T1, INTERLACING_TAG> *)result;
1090 %template(FIELDDOUBLE) FIELD<double, FullInterlace>;
1091 %template(FIELDDOUBLENOINTERLACE) FIELD<double, NoInterlace>;
1092 %template(FIELDDOUBLENOINTERLACEBYTYPE) FIELD<double, NoInterlaceByType>;
1093 %template(FIELDINT) FIELD<int, FullInterlace>;
1094 %template(FIELDINTNOINTERLACE) FIELD<int, NoInterlace>;
1095 %template(FIELDINTNOINTERLACEBYTYPE) FIELD<int, NoInterlaceByType>;
1097 class GROUP : public SUPPORT
1104 void setNumberOfFamilies(int numberOfFamilies);
1105 void setFamilies(vector< FAMILY * > Family);
1107 int getNumberOfFamilies() const ;
1108 vector< FAMILY * > getFamilies() const ;
1109 FAMILY * getFamily(int i) const ;
1115 int addDriver(driverTypes driverType,
1116 const char * fileName="Default File Name.med",
1117 const char * driverName="Default Mesh Name",
1118 med_mode_acces access=RDWR);
1120 void rmDriver(int index=0);
1122 void read(int index=0);
1123 void read(const GENDRIVER & genDriver);
1124 void read(driverTypes driverType,
1125 const std::string& filename,
1126 const std::string& meshname);
1128 void write(int index=0);
1129 void write(const GENDRIVER & driver,
1130 med_mode_acces medMode=WRONLY);
1131 void write(driverTypes driverType,
1132 const std::string& filename,
1133 const std::string& meshname="",
1134 med_mode_acces medMode=WRONLY);
1136 void setName(char * name);
1138 int getSpaceDimension();
1140 int getMeshDimension();
1142 int getNumberOfNodes();
1146 int getNumberOfTypes(medEntityMesh Entity);
1148 int getNumberOfElements(medEntityMesh Entity,medGeometryElement Type);
1150 int getNumberOfFamilies(medEntityMesh Entity);
1152 FAMILY* getFamily(medEntityMesh Entity,int i);
1154 int getNumberOfGroups(medEntityMesh Entity);
1156 GROUP * getGroup(medEntityMesh Entity,int i);
1157 GROUP* getGroup(char* name);
1159 medGeometryElement getElementType(medEntityMesh Entity,int Number);
1161 SUPPORT * getSupportOnAll(medEntityMesh Entity);
1163 std::string getName() const;
1165 std::string getCoordinatesSystem();
1169 PyObject* convertInMESH()
1171 const MESH* mesh = self->convertInMESH();
1172 return SWIG_NewPointerObj((void *)mesh, $descriptor(MESH *), self->getIsAGrid() );
1175 %newobject getBoundaryElements(medEntityMesh );
1176 SUPPORT * getBoundaryElements(medEntityMesh Entity)
1178 return self->getBoundaryElements(Entity);
1181 %newobject getSkin(const SUPPORT * );
1182 SUPPORT * getSkin(const SUPPORT * Support3D)
1184 return self->getSkin(Support3D);
1187 %newobject mergeSupports(const vector< SUPPORT * > );
1188 SUPPORT * mergeSupports(const vector< SUPPORT * > Supports)
1190 return self->mergeSupports(Supports);
1193 %newobject intersectSupports(const vector< SUPPORT * > );
1194 SUPPORT * intersectSupports(const vector< SUPPORT * > Supports)
1196 return self->intersectSupports(Supports);
1199 %newobject mergeFieldsDouble(const vector< FIELDDOUBLE* > others);
1200 FIELD<double, FullInterlace> * mergeFieldsDouble(const vector< FIELDDOUBLE* > others)
1202 return (FIELD<double, FullInterlace> *)self->mergeFields<double>(others);
1205 %newobject mergeFieldsInt(const vector< FIELDINT* > others);
1206 FIELD<int, FullInterlace> * mergeFieldsInt(const vector< FIELDINT* > others)
1208 return (FIELD<int, FullInterlace> *)self->mergeFields<int>(others);
1211 %newobject __str__();
1212 const char* __str__()
1215 mess << "Python Printing GMESH : " << *self << endl;
1216 return strdup(mess.str().c_str());
1219 %newobject getCoordinateName(int );
1220 const char * getCoordinateName(int i)
1222 string tmp_str = self->getCoordinatesNames()[i];
1223 char * tmp = new char[strlen(tmp_str.c_str())+1];
1224 strcpy(tmp,tmp_str.c_str());
1228 %newobject getCoordinateUnit(int );
1229 const char * getCoordinateUnit(int i)
1231 string tmp_str = self->getCoordinatesUnits()[i];
1232 char * tmp = new char[strlen(tmp_str.c_str())+1];
1233 strcpy(tmp,tmp_str.c_str());
1237 PyObject * getCoordinatesNames()
1239 const string * array = self->getCoordinatesNames();
1240 int size = self->getSpaceDimension();
1241 TYPEMAP_OUTPUT_ARRAY(array, size, PyString_FromStdString,
1242 MESH::getCoordinatesNames);
1245 PyObject * getCoordinatesUnits()
1247 const string * array = self->getCoordinatesUnits();
1248 int size = self->getSpaceDimension();
1249 TYPEMAP_OUTPUT_ARRAY(array, size, PyString_FromStdString,
1250 MESH::getCoordinatesUnits);
1253 PyObject * getTypes(medEntityMesh Entity)
1255 const medGeometryElement * types = self->getTypes(Entity);
1256 int size = self->getNumberOfTypes(Entity);
1257 TYPEMAP_OUTPUT_ARRAY(types, size, PyInt_FromLong, MESH::getTypes);
1260 %newobject getVolume(const SUPPORT * , bool );
1261 FIELD<double, FullInterlace> * getVolume(const SUPPORT * Support, bool isAbs = true)
1263 return (FIELD<double, FullInterlace> *) self->getVolume(Support,isAbs);
1266 %newobject getArea(const SUPPORT * );
1267 FIELD<double, FullInterlace> * getArea(const SUPPORT * Support)
1269 return (FIELD<double, FullInterlace> *) self->getArea(Support);
1272 %newobject getLength(const SUPPORT * );
1273 FIELD<double, FullInterlace> * getLength(const SUPPORT * Support)
1275 return (FIELD<double, FullInterlace> *) self->getLength(Support);
1278 %newobject getNormal(const SUPPORT * );
1279 FIELD<double, FullInterlace> * getNormal(const SUPPORT * Support)
1281 return (FIELD<double, FullInterlace> *) self->getNormal(Support);
1284 %newobject getBarycenter(const SUPPORT * );
1285 FIELD<double, FullInterlace> * getBarycenter(const SUPPORT * Support)
1287 return (FIELD<double, FullInterlace> *) self->getBarycenter(Support);
1291 GMESH(); // prohibit SWIG to generate a default constructor
1295 class MESH : public GMESH
1300 MESH (driverTypes driverType, const char* fileName, const char* meshName);
1304 void convertToPoly();
1306 const double getCoordinate(int Number, int Axis);
1308 void calculateConnectivity(medConnectivity ConnectivityType,medEntityMesh Entity);
1310 int getElementNumber(medConnectivity ConnectivityType, medEntityMesh Entity, medGeometryElement Type, int * connectivity);
1312 CELLMODEL * getCellsTypes(medEntityMesh Entity);
1314 int getElementContainingPoint(const double *coord);
1318 CELLMODEL getCellType(medEntityMesh Entity,int i)
1320 return self->getCellsTypes(Entity)[i];
1323 %newobject __str__();
1324 const char* __str__()
1327 mess << "Python Printing MESH : " << *self << endl;
1328 return strdup(mess.str().c_str());
1331 PyObject * getCoordinates(medModeSwitch Mode)
1333 const double * array = self->getCoordinates(Mode);
1334 int size = (self->getSpaceDimension())*(self->getNumberOfNodes());
1336 return TYPEMAP_OUTPUT_PY_ARRAY( array, size );
1338 TYPEMAP_OUTPUT_ARRAY(array, size, PyFloat_FromDouble,MESH::getCoordinates);
1342 PyObject * getConnectivity(medConnectivity ConnectivityType,
1343 medEntityMesh Entity,
1344 medGeometryElement Type)
1346 const int * connectivity = self->getConnectivity(ConnectivityType, Entity,Type);
1347 int size = self->getConnectivityLength(ConnectivityType,Entity,Type);
1349 return TYPEMAP_OUTPUT_PY_ARRAY( connectivity, size );
1351 TYPEMAP_OUTPUT_ARRAY(connectivity, size, PyInt_FromLong,MESH::getConnectivity );
1355 PyObject * getConnectivityIndex(medConnectivity ConnectivityType,
1356 medEntityMesh Entity)
1358 const int * index = self->getConnectivityIndex(ConnectivityType,Entity);
1359 int size = (self->getNumberOfElements(Entity,MED_ALL_ELEMENTS))+1;
1361 return TYPEMAP_OUTPUT_PY_ARRAY( index, size );
1363 TYPEMAP_OUTPUT_ARRAY(index,size,PyInt_FromLong,MESH::getConnectivityIndex);
1367 PyObject * getReverseConnectivity(medConnectivity ConnectivityType,
1368 medEntityMesh Entity=MED_CELL)
1370 const int * conn = self->getReverseConnectivity(ConnectivityType,Entity);
1371 int size = self->getReverseConnectivityLength(ConnectivityType,Entity);
1373 return TYPEMAP_OUTPUT_PY_ARRAY( conn, size );
1375 TYPEMAP_OUTPUT_ARRAY(conn, size, PyInt_FromLong,MESH::getReverseConnectivity);
1379 PyObject * getReverseConnectivityIndex(medConnectivity ConnectivityType,
1380 medEntityMesh Entity=MED_CELL)
1382 const int * index = self->getReverseConnectivityIndex(ConnectivityType,Entity);
1383 int size=self->getReverseConnectivityIndexLength(ConnectivityType,Entity);
1385 return TYPEMAP_OUTPUT_PY_ARRAY( index, size );
1387 TYPEMAP_OUTPUT_ARRAY(index,size, PyInt_FromLong,MESH::getReverseConnectivityIndex);
1391 PyObject * getGlobalNumberingIndex(medEntityMesh Entity)
1393 const int * numberingIndex = self->getGlobalNumberingIndex(Entity);
1394 int nbOfTypes = self->getNumberOfTypes(Entity);
1395 int size = nbOfTypes+1;
1396 TYPEMAP_OUTPUT_ARRAY(numberingIndex, size, PyInt_FromLong,
1397 MESH::getGlobalNumberingIndex);
1402 class MESHING: public MESH
1408 void setCoordinates (const int SpaceDimension,
1409 const int NumberOfNodes,
1410 const double * Coordinates,
1412 const medModeSwitch Mode) ;
1413 void setCoordinatesNames (const std::string * names) ;
1414 void setCoordinateName (const std::string name, const int i) ;
1415 void setCoordinatesUnits (const std::string * units);
1416 void setCoordinateUnit (const std::string unit, const int i) ;
1418 void setNumberOfTypes (const int NumberOfTypes,
1419 const medEntityMesh Entity) ;
1421 void setTypes (const medGeometryElement * Types,
1422 const medEntityMesh Entity) ;
1424 void setNumberOfElements (const int * NumberOfElements,
1425 const medEntityMesh Entity) ;
1427 void setConnectivity (const medEntityMesh Entity,
1428 const medGeometryElement Type,
1429 const int * Connectivity,
1430 const int * ConnectivityIndex=0) ;
1432 void addGroup (const GROUP & Group) ;
1436 class GRID : public GMESH
1441 GRID(driverTypes driverType, const char * fileName, const char * meshName);
1443 GRID(const GRID &m);
1447 int getNodeNumber(const int i, const int j=0, const int k=0) const ;
1449 int getCellNumber(const int i, const int j=0, const int k=0) const ;
1451 int getEdgeNumber(const int Axis, const int i, const int j=0, const int k=0) const ;
1453 int getFaceNumber(const int Axis, const int i, const int j=0, const int k=0) const ;
1455 med_grid_type getGridType();
1457 int getArrayLength( const int Axis );
1459 const double getArrayValue (const int Axis, const int i);
1461 void setGridType(med_grid_type gridType);
1465 PyObject * getEntityPosition(const medEntityMesh Entity, const int Number)
1468 int i=0, size = self->getSpaceDimension();
1472 self->getCellPosition(Number, ijk[0], ijk[1], ijk[2]);
1475 self->getNodePosition(Number, ijk[0], ijk[1], ijk[2]);
1478 self->getFacePosition(Number, Axis, ijk[0], ijk[1], ijk[2]);
1483 self->getEdgePosition(Number, Axis, ijk[0], ijk[1], ijk[2]);
1488 const char * message = "Error in GRID::getEntityPosition: wrong Entity";
1489 PyErr_SetString(PyExc_RuntimeError, (char *)message);
1492 PyObject *py_list = PyList_New( size );
1493 for (; i < size; ++i)
1495 int err = PyList_SetItem(py_list, i,
1496 Py_BuildValue("i", ijk[j++]));
1499 const char * message = "Error in GRID::getNodePosition";
1500 PyErr_SetString(PyExc_RuntimeError, (char *)message);
1504 if (Entity == MED_FACE || Entity == MED_EDGE)
1505 PyList_SetItem(py_list, 0, Py_BuildValue("i", Axis));
1507 PyObject * result = Py_BuildValue("O", py_list);
1517 PointLocator(const MESH& mesh);
1518 virtual ~PointLocator();
1520 PyObject* locate(const double* x)
1522 std::list<int> mylist = self->locate(x);
1523 if (mylist.size()>10)
1525 const char * message = "Error in PointLocator : SWIG interface limits the number of cells to 10";
1526 PyErr_SetString(PyExc_RuntimeError, (char *)message);
1530 int array[10]; // maximum number of cells in which the point lies
1532 for (list<int>::const_iterator iter= mylist.begin();
1533 iter != mylist.end();
1535 array[index++]= *iter;
1536 TYPEMAP_OUTPUT_ARRAY(array, mylist.size(), PyInt_FromLong,
1537 PointLocator::locate);
1542 class MEDFILEBROWSER
1546 MEDFILEBROWSER (const std::string & fileName);
1547 void readFileStruct(const std::string & fileName);
1549 std::string getFileName();
1551 int getNumberOfMeshes ();
1552 int getNumberOfFields ();
1554 bool isStructuredMesh(const std::string & meshName);
1556 med_type_champ getFieldType (const std::string & fieldName);
1557 std::string getMeshName (const std::string & fieldName);
1561 std::string getMeshName(int i)
1563 return self->getMeshNames().at(i);
1566 std::string getFieldName(int i)
1568 return self->getFieldNames().at(i);
1571 PyObject *getMeshNames()
1573 std::vector< std::string > names = self->getMeshNames();
1574 std::string* array = &names[0];
1575 TYPEMAP_OUTPUT_ARRAY(array, names.size(), PyString_FromStdString,
1576 MEDFILEBROWSER::getMeshNames);
1580 PyObject *getFieldNames()
1582 std::vector< std::string > names = self->getFieldNames();
1583 std::string* array = &names[0];
1584 TYPEMAP_OUTPUT_ARRAY(array, names.size(), PyString_FromStdString,
1585 MEDFILEBROWSER::getMeshNames);
1588 PyObject* getFieldIteration (char* fieldName)
1590 VEC_DT_IT_ vec_dtit = self->getFieldIteration (fieldName);
1591 PyObject *py_list = PyList_New(vec_dtit.size());
1592 for (unsigned i=0; i < vec_dtit.size(); i++)
1594 DT_IT_* dtit = new DT_IT_(vec_dtit[i]);
1595 PyObject * pyDTIT= SWIG_NewPointerObj((void *) dtit, $descriptor(DT_IT_*), 1);
1596 int err = PyList_SetItem(py_list, i, pyDTIT);
1599 PyErr_SetString(PyExc_RuntimeError, "Error in getFieldIteration");
1604 PyObject * result = Py_BuildValue("O", py_list);
1613 API de GIBI_MESH_[RDONLY,WRONLY,RDWR]_DRIVER
1616 class GIBI_MESH_RDONLY_DRIVER : public GENDRIVER
1619 GIBI_MESH_RDONLY_DRIVER() ;
1621 GIBI_MESH_RDONLY_DRIVER(const GIBI_MESH_RDONLY_DRIVER & driver) ;
1623 GIBI_MESH_RDONLY_DRIVER(const char* fileName, MESH * ptrMesh);
1625 ~GIBI_MESH_RDONLY_DRIVER() ;
1629 %newobject __str__();
1630 const char* __str__()
1633 mess << "Python Printing GIBI_MESH_RDONLY_DRIVER : " << *self << endl;
1634 return strdup(mess.str().c_str());
1639 class GIBI_MESH_WRONLY_DRIVER : public GENDRIVER
1642 GIBI_MESH_WRONLY_DRIVER() ;
1644 GIBI_MESH_WRONLY_DRIVER(const GIBI_MESH_WRONLY_DRIVER & driver) ;
1646 GIBI_MESH_WRONLY_DRIVER(const char* fileName, GMESH * ptrMesh);
1648 ~GIBI_MESH_WRONLY_DRIVER() ;
1652 %newobject __str__();
1653 const char* __str__()
1656 mess << "Python Printing GIBI_MESH_WRONLY_DRIVER : " << *self << endl;
1657 return strdup(mess.str().c_str());
1662 class GIBI_MESH_RDWR_DRIVER : public virtual GIBI_MESH_RDONLY_DRIVER,
1663 public virtual GIBI_MESH_WRONLY_DRIVER
1666 GIBI_MESH_RDWR_DRIVER() ;
1668 GIBI_MESH_RDWR_DRIVER(const GIBI_MESH_RDWR_DRIVER & driver) ;
1670 GIBI_MESH_RDWR_DRIVER(const char* fileName, MESH * ptrMesh);
1672 ~GIBI_MESH_RDWR_DRIVER() ;
1676 %newobject __str__();
1677 const char* __str__()
1680 mess << "Python Printing GIBI_MESH_RDWR_DRIVER : " << *self << endl;
1681 return strdup(mess.str().c_str());
1686 class GIBI_MED_RDONLY_DRIVER : public GENDRIVER
1689 GIBI_MED_RDONLY_DRIVER() ;
1691 GIBI_MED_RDONLY_DRIVER(const GIBI_MED_RDONLY_DRIVER & driver) ;
1696 GIBI_MED_RDONLY_DRIVER(char * fileName)
1698 std::vector< FIELD_* > fields;
1699 return new GIBI_MED_RDONLY_DRIVER(string(fileName), fields) ;
1702 PyObject * read ( void )
1704 std::vector< FIELD_* > fields;
1705 GIBI_MED_RDONLY_DRIVER tmp( self->getFileName(), fields) ;
1712 PyObject* py_list = PyList_New(fields.size());
1714 for (unsigned i=0;i<fields.size();i++)
1716 PyObject * f = SWIG_NewPointerObj((void*)fields.at(i),$descriptor(FIELDDOUBLE*),1);
1717 PyList_SetItem(py_list,i,f);
1719 PyObject * result = Py_BuildValue("O", py_list);
1724 %newobject __str__();
1725 const char* __str__()
1728 mess << "Python Printing GIBI_MED_RDONLY_DRIVER : " << *self << endl;
1729 return strdup(mess.str().c_str());
1735 class GIBI_MED_WRONLY_DRIVER : public GENDRIVER
1738 GIBI_MED_WRONLY_DRIVER() ;
1740 GIBI_MED_WRONLY_DRIVER(const GIBI_MED_WRONLY_DRIVER & driver) ;
1742 GIBI_MED_WRONLY_DRIVER(const char* fileName,
1743 vector< const FIELD_* > fields,
1747 %newobject __str__();
1748 const char* __str__()
1751 mess << "Python Printing GIBI_MED_WRONLY_DRIVER : " << *self << endl;
1752 return strdup(mess.str().c_str());
1759 * \brief set/get format of vtk file
1761 bool getVtkBinaryFormatForWriting();
1763 void setVtkBinaryFormatForWriting(bool isBinary);
1766 bool getVtkBinaryFormatForWriting()
1768 return DRIVERFACTORY::getVtkBinaryFormatForWriting();
1770 void setVtkBinaryFormatForWriting(bool isBinary)
1772 DRIVERFACTORY::setVtkBinaryFormatForWriting(isBinary);
1776 * \brief Driver to write fields to vtk file
1778 class VTK_MED_DRIVER : public GENDRIVER
1781 VTK_MED_DRIVER(const char* fileName, vector< const FIELD_* > fields);
1785 API de PORFLOW_MESH_[RDONLY,WRONLY,RDWR]_DRIVER
1788 class PORFLOW_MESH_RDONLY_DRIVER : public GENDRIVER
1791 PORFLOW_MESH_RDONLY_DRIVER() ;
1793 PORFLOW_MESH_RDONLY_DRIVER(const PORFLOW_MESH_RDONLY_DRIVER & driver) ;
1795 PORFLOW_MESH_RDONLY_DRIVER(const char* fileName, MESH * ptrMesh);
1797 ~PORFLOW_MESH_RDONLY_DRIVER() ;
1801 %newobject __str__();
1802 const char* __str__()
1805 mess << "Python Printing PORFLOW_MESH_RDONLY_DRIVER : " << *self << endl;
1806 return strdup(mess.str().c_str());
1811 class PORFLOW_MESH_WRONLY_DRIVER : public GENDRIVER
1814 PORFLOW_MESH_WRONLY_DRIVER() ;
1816 PORFLOW_MESH_WRONLY_DRIVER(const PORFLOW_MESH_WRONLY_DRIVER & driver) ;
1818 PORFLOW_MESH_WRONLY_DRIVER(char * fileName, GMESH * ptrMesh);
1820 ~PORFLOW_MESH_WRONLY_DRIVER() ;
1824 %newobject __str__();
1825 const char* __str__()
1828 mess << "Python Printing PORFLOW_MESH_WRONLY_DRIVER : " << *self << endl;
1829 return strdup(mess.str().c_str());
1834 class PORFLOW_MESH_RDWR_DRIVER : public virtual PORFLOW_MESH_RDONLY_DRIVER,
1835 public virtual PORFLOW_MESH_WRONLY_DRIVER
1838 PORFLOW_MESH_RDWR_DRIVER() ;
1840 PORFLOW_MESH_RDWR_DRIVER(const PORFLOW_MESH_RDWR_DRIVER & driver) ;
1842 PORFLOW_MESH_RDWR_DRIVER(const char * fileName, MESH * ptrMesh);
1844 ~PORFLOW_MESH_RDWR_DRIVER() ;
1848 %newobject __str__();
1849 const char* __str__()
1852 mess << "Python Printing PORFLOW_MESH_RDWR_DRIVER : " << *self << endl;
1853 return strdup(mess.str().c_str());
1859 API de MED_MESH_[RDONLY,WRONLY,RDWR]_DRIVER
1862 class MED_MESH_RDONLY_DRIVER : public GENDRIVER
1866 MED_MESH_RDONLY_DRIVER(const char * fileName, GMESH * ptrMesh);
1868 ~MED_MESH_RDONLY_DRIVER();
1870 void desactivateFacesComputation();
1872 void activateFacesComputation();
1876 %newobject __str__();
1877 const char* __str__()
1880 mess << "Python Printing MED_MESH_RDONLY_DRIVER : " << *self << endl;
1881 return strdup(mess.str().c_str());
1886 class MED_MESH_WRONLY_DRIVER : public GENDRIVER
1889 ~MED_MESH_WRONLY_DRIVER();
1891 MED_MESH_WRONLY_DRIVER(const char * fileName, GMESH * ptrMesh);
1895 %newobject __str__();
1896 const char* __str__()
1899 mess << "Python Printing MED_MESH_WRONLY_DRIVER : " << *self << endl;
1900 return strdup(mess.str().c_str());
1905 class MED_MESH_RDWR_DRIVER : public virtual MED_MESH_RDONLY_DRIVER,
1906 public virtual MED_MESH_WRONLY_DRIVER
1910 ~MED_MESH_RDWR_DRIVER();
1912 MED_MESH_RDWR_DRIVER(const char * fileName, GMESH * ptrMesh);
1916 %newobject __str__();
1917 const char* __str__()
1920 mess << "Python Printing MED_MESH_RDWR_DRIVER : " << *self << endl;
1921 return strdup(mess.str().c_str());
1927 API de MED_FIELD_[RDONLY,WRONLY,RDWR]_DRIVER
1930 template< class T1 >
1931 class MED_FIELD_RDONLY_DRIVER : public GENDRIVER
1935 MED_FIELD_RDONLY_DRIVER(const char * fileName, FIELD<T1, FullInterlace > * ptrField);
1937 ~MED_FIELD_RDONLY_DRIVER();
1941 %newobject __str__();
1942 const char* __str__()
1945 mess << "Python Printing MED_FIELD_RDONLY_DRIVER : " << *self << endl;
1946 return strdup(mess.str().c_str());
1950 %template ( MED_FIELDDOUBLE_RDONLY_DRIVER ) MED_FIELD_RDONLY_DRIVER< double >;
1951 %template ( MED_FIELDINT_RDONLY_DRIVER ) MED_FIELD_RDONLY_DRIVER< int >;
1954 template < class T1 >
1955 class MED_FIELD_WRONLY_DRIVER : public GENDRIVER
1959 MED_FIELD_WRONLY_DRIVER(const char * fileName, FIELD<T1, FullInterlace> * ptrField);
1961 ~MED_FIELD_WRONLY_DRIVER();
1964 %newobject __str__();
1965 const char* __str__()
1968 mess << "Python Printing MED_FIELD_WRONLY_DRIVER : " << *self << endl;
1969 return strdup(mess.str().c_str());
1973 %template ( MED_FIELDDOUBLE_WRONLY_DRIVER ) MED_FIELD_WRONLY_DRIVER< double >;
1974 %template ( MED_FIELDINT_WRONLY_DRIVER ) MED_FIELD_WRONLY_DRIVER< int >;
1977 template< class T1 >
1978 class MED_FIELD_RDWR_DRIVER : public virtual MED_FIELD_RDONLY_DRIVER< T1 >, public virtual MED_FIELD_WRONLY_DRIVER< T1 >
1982 MED_FIELD_RDWR_DRIVER(const char * fileName, FIELD<T1, FullInterlace> * ptrField);
1984 ~MED_FIELD_RDWR_DRIVER();
1988 %newobject __str__();
1989 const char* __str__()
1992 mess << "Python Printing MED_FIELD_RDWR_DRIVER : " << *self << endl;
1993 return strdup(mess.str().c_str());
1997 %template ( MED_FIELDDOUBLE_RDWR_DRIVER ) MED_FIELD_RDWR_DRIVER< double >;
1998 %template ( MED_FIELDINT_RDWR_DRIVER ) MED_FIELD_RDWR_DRIVER< int >;
2001 template< class T1 >
2002 class ASCII_FIELD_DRIVER : public GENDRIVER
2005 ASCII_FIELD_DRIVER(const char *fileName, FIELD<T1, FullInterlace> * ptrField, med_sort_direc direction, const char *priority);
2006 ~ASCII_FIELD_DRIVER();
2009 %template (ASCII_FIELDDOUBLE_DRIVER) ASCII_FIELD_DRIVER< double >;
2010 %template (ASCII_FIELDINT_DRIVER) ASCII_FIELD_DRIVER< int >;
2012 //=======================================================================
2016 // ---------------------------------------------------------------
2017 //!< supported formats
2018 enum EnSightFormat { ENSIGHT_6, ENSIGHT_GOLD };
2020 // ---------------------------------------------------------------
2021 //!< set writing format
2023 void setEnSightFormatForWriting (EnSightFormat format, bool isBinary);
2025 // ---------------------------------------------------------------
2026 //!< To raise or not if MEDMEM-EnSight incompatibility encounters or suspected.
2027 // See MEDMEM_EnsightUtils.hxx for raison why
2029 void setIgnoreIncompatibility(bool toIgnore=true);
2031 // ---------------------------------------------------------------
2032 //!< EnSight reading driver reads all meshes and fields
2034 class ENSIGHT_MED_RDONLY_DRIVER : public GENDRIVER
2039 ENSIGHT_MED_RDONLY_DRIVER(const std::string & fileName)
2041 vector< FIELD_* > fields;
2042 return new ENSIGHT_MED_RDONLY_DRIVER(fileName,fields);
2047 std::vector< FIELD_* > fields;
2048 ENSIGHT_MED_RDONLY_DRIVER tmp( self->getFileName(), fields) ;
2051 PyObject* py_list = PyList_New(fields.size());
2053 for (unsigned i=0;i<fields.size();i++)
2055 PyObject * f = SWIG_NewPointerObj((void*)fields.at(i),$descriptor(FIELD_*),1);
2056 PyList_SetItem(py_list,i,f);
2058 PyObject * result = Py_BuildValue("O", py_list);
2064 // ---------------------------------------------------------------
2065 //!< EnSight writing driver
2067 class ENSIGHT_MED_WRONLY_DRIVER : public GENDRIVER
2070 ENSIGHT_MED_WRONLY_DRIVER(const std::string & fileName, const vector< const FIELD_* > fields);
2073 // ---------------------------------------------------------------
2074 //!< EnSight mesh reading driver
2076 class ENSIGHT_MESH_RDONLY_DRIVER : public GENDRIVER
2079 //!< to read mesh of index-th time step
2080 ENSIGHT_MESH_RDONLY_DRIVER(const std::string & fileName, MESH * ptrMesh, int index=1);
2083 // ---------------------------------------------------------------
2084 //!< Writing EnSight mesh driver.
2086 class ENSIGHT_MESH_WRONLY_DRIVER : public GENDRIVER
2089 ENSIGHT_MESH_WRONLY_DRIVER(const std::string & fileName, GMESH * ptrMesh, bool append=false);
2092 // ---------------------------------------------------------------
2093 //!< EnSight field reading driver
2095 class ENSIGHT_FIELD_RDONLY_DRIVER : public GENDRIVER
2098 //!< Set the name of the FIELD in EnSight file
2099 void setFieldName(const std::string & fieldName);
2100 //!< read the field of a specified name and index-th time step.
2101 ENSIGHT_FIELD_RDONLY_DRIVER(const std::string & fileName, FIELD_ * ptrField, int step=1);
2104 // ---------------------------------------------------------------
2105 //!< Writing EnSight field driver.
2107 class ENSIGHT_FIELD_WRONLY_DRIVER : public GENDRIVER
2110 //!< Set the name of the FIELD in EnSight file
2111 void setFieldName(const std::string & fieldName);
2112 ENSIGHT_FIELD_WRONLY_DRIVER(const std::string & fileName, FIELD_ * ptrField);
2113 //!< Write FIELD, the mesh is supposed to be written in this file.
2116 // end of EnSight drivers
2117 //=======================================================================
2120 template <class INTERLACING_TAG> class GAUSS_LOCALIZATION
2124 GAUSS_LOCALIZATION();
2126 ~GAUSS_LOCALIZATION();
2128 std::string getName() const ;
2130 medGeometryElement getType() const ;
2132 int getNbGauss() const ;
2134 medModeSwitch getInterlacingType() const;
2137 GAUSS_LOCALIZATION<INTERLACING_TAG>(char * locName,
2138 const medGeometryElement
2141 const double * cooRef,
2142 const double * cooGauss,
2145 return new GAUSS_LOCALIZATION<INTERLACING_TAG>(string(locName),
2146 typeGeo, nGauss, cooRef,
2150 %newobject __str__();
2151 const char* __str__()
2154 mess << "Python Printing GAUSS_LOCALIZATION : " << *self << endl;
2155 return strdup(mess.str().c_str());
2158 PyObject * getRefCoo () const
2160 typedef MEDMEM_ArrayInterface<double,INTERLACING_TAG,NoGauss>::Array ArrayNoGauss;
2162 ArrayNoGauss cooRef = self->getRefCoo();
2163 int size = cooRef.getArraySize();
2164 double * cooRefPtr = cooRef.getPtr();
2165 TYPEMAP_OUTPUT_ARRAY(cooRefPtr, size, PyFloat_FromDouble,
2166 GAUSS_LOCALIZATION::getRefCoo);
2169 PyObject * getGsCoo () const
2171 typedef MEDMEM_ArrayInterface<double,INTERLACING_TAG,NoGauss>::Array ArrayNoGauss;
2172 ArrayNoGauss cooGauss = self->getGsCoo();
2173 int size = cooGauss.getArraySize();
2174 double * cooGaussPtr = cooGauss.getPtr();
2175 TYPEMAP_OUTPUT_ARRAY(cooGaussPtr, size, PyFloat_FromDouble,
2176 GAUSS_LOCALIZATION::getGsCoo);
2179 PyObject * getWeight () const
2181 vector<double> wg = self->getWeight();
2182 double * wgPtr = &wg[0];
2183 TYPEMAP_OUTPUT_ARRAY(wgPtr, wg.size(), PyFloat_FromDouble,
2184 GAUSS_LOCALIZATION::getWeight);
2189 %template (GAUSS_LOCALIZATION_FULL) GAUSS_LOCALIZATION<FullInterlace> ;
2190 %template (GAUSS_LOCALIZATION_NO) GAUSS_LOCALIZATION<NoInterlace> ;
2193 template <class T, class INTERLACING_TAG>
2194 FIELD<T, INTERLACING_TAG> * createFieldScalarProduct(FIELD<T, INTERLACING_TAG> * field1,
2195 FIELD<T, INTERLACING_TAG> * field2)
2197 return (FIELD<T, INTERLACING_TAG> *)
2198 FIELD<T, INTERLACING_TAG>::scalarProduct((FIELD<T, INTERLACING_TAG>)*field1,
2199 (FIELD<T, INTERLACING_TAG>)*field2);
2202 template <class T, class INTERLACING_TAG>
2203 FIELD<T, INTERLACING_TAG> * createFieldScalarProductDeep(FIELD<T, INTERLACING_TAG> * field1,
2204 FIELD<T, INTERLACING_TAG> * field2)
2206 return (FIELD<T, INTERLACING_TAG>*) FIELD<T, INTERLACING_TAG>::scalarProduct((FIELD<T, INTERLACING_TAG>)*field1,
2207 (FIELD<T, INTERLACING_TAG>)*field2, true);
2210 template<class T, class INTERLACING_TAG>
2211 FIELD<T, INTERLACING_TAG> * createTypedFieldFromField(FIELD_ * field)
2213 MESSAGE_MED("createTypedFieldFromField : Constructor (for Python API) FIELD<T> with parameter FIELD_");
2214 MESSAGE_MED("Its returns a proper cast of the input pointer :: FIELD_ --> FIELD<T>");
2216 if (field->getInterlacingType() != SET_INTERLACING_TYPE<INTERLACING_TAG>::_interlacingType)
2217 throw MEDEXCEPTION("cast to wrong medModeSwitch (_interlacingType)");
2218 if (field->getValueType() != SET_VALUE_TYPE<T>::_valueType)
2219 throw MEDEXCEPTION("cast to wrong med_type_champ (_valueType)");
2221 return (FIELD<T, INTERLACING_TAG> *) field;
2224 template <class T> FIELD<T, FullInterlace> *
2225 createTypedFieldConvertFullInterlace(const FIELD<T, NoInterlace> & field )
2227 return FieldConvert(field);
2230 template <class T> FIELD<T, NoInterlace> *
2231 createTypedFieldConvertNoInterlace(const FIELD<T, FullInterlace> & field )
2233 return FieldConvert(field);
2237 template<class T, class INTERLACING_TAG> FIELD<T, INTERLACING_TAG> * createTypedFieldFromField(FIELD_ * field);
2238 %template ( createFieldDoubleFromField ) createTypedFieldFromField < double, FullInterlace>;
2239 %template ( createFieldIntFromField ) createTypedFieldFromField < int, FullInterlace >;
2240 %template ( createFieldDoubleNoInterlaceFromField ) createTypedFieldFromField < double, NoInterlace>;
2241 %template ( createFieldIntNoInterlaceFromField ) createTypedFieldFromField < int, NoInterlace >;
2242 %template ( createFieldDoubleNoInterlaceByTypeFromField ) createTypedFieldFromField < double, NoInterlaceByType>;
2243 %template ( createFieldIntNoInterlaceByTypeFromField ) createTypedFieldFromField < int, NoInterlaceByType >;
2245 template <class T, class INTERLACING_TAG> FIELD<T, INTERLACING_TAG> * createFieldScalarProduct(FIELD<T, INTERLACING_TAG> * field1, FIELD<T, INTERLACING_TAG> * field2);
2246 %newobject createFieldDoubleScalarProduct ;
2247 %newobject createFieldIntScalarProduct ;
2248 %newobject createFieldDoubleNoInterlaceScalarProduct ;
2249 %newobject createFieldIntNoInterlaceScalarProduct ;
2250 %newobject createFieldDoubleNoInterlaceByTypeScalarProduct ;
2251 %newobject createFieldIntNoInterlaceByTypeScalarProduct ;
2252 %template ( createFieldDoubleScalarProduct ) createFieldScalarProduct < double, FullInterlace >;
2253 %template ( createFieldIntScalarProduct ) createFieldScalarProduct < int, FullInterlace >;
2254 %template ( createFieldDoubleNoInterlaceScalarProduct ) createFieldScalarProduct < double, NoInterlace >;
2255 %template ( createFieldIntNoInterlaceScalarProduct ) createFieldScalarProduct < int, NoInterlace >;
2256 %template ( createFieldDoubleNoInterlaceByTypeScalarProduct ) createFieldScalarProduct < double, NoInterlaceByType >;
2257 %template ( createFieldIntNoInterlaceByTypeScalarProduct ) createFieldScalarProduct < int, NoInterlaceByType >;
2259 template <class T, class INTERLACING_TAG> FIELD<T, INTERLACING_TAG> * createFieldScalarProductDeep(FIELD<T, INTERLACING_TAG> * field1, FIELD<T, INTERLACING_TAG> * field2);
2260 %newobject createFieldDoubleScalarProductDeep ;
2261 %newobject createFieldIntScalarProductDeep ;
2262 %newobject createFieldDoubleNoInterlaceScalarProductDeep ;
2263 %newobject createFieldIntNoInterlaceScalarProductDeep ;
2264 %newobject createFieldDoubleNoInterlaceByTypeScalarProductDeep ;
2265 %newobject createFieldIntNoInterlaceByTypeScalarProductDeep ;
2266 %template ( createFieldDoubleScalarProductDeep ) createFieldScalarProductDeep < double, FullInterlace >;
2267 %template ( createFieldIntScalarProductDeep ) createFieldScalarProductDeep < int, FullInterlace >;
2268 %template ( createFieldDoubleNoInterlaceScalarProductDeep ) createFieldScalarProductDeep < double, NoInterlace >;
2269 %template ( createFieldIntNoInterlaceScalarProductDeep ) createFieldScalarProductDeep < int, NoInterlace >;
2270 %template ( createFieldDoubleNoInterlaceByTypeScalarProductDeep ) createFieldScalarProductDeep < double, NoInterlaceByType >;
2271 %template ( createFieldIntNoInterlaceByTypeScalarProductDeep ) createFieldScalarProductDeep < int, NoInterlaceByType >;
2273 template<class T, class INTERLACING_TAG> FIELD<T, INTERLACING_TAG> * createFieldFromAnalytic(SUPPORT * Support, int NumberOfComponents, PyObject * double_function);
2275 template <class T> FIELD<T, FullInterlace> * createTypedFieldConvertFullInterlace(const FIELD<T, NoInterlace> & field );
2277 %template (createFieldDoubleConvertFullInterlace) createTypedFieldConvertFullInterlace<double>;
2279 %template (createFieldIntConvertFullInterlace) createTypedFieldConvertFullInterlace<int>;
2281 template <class T> FIELD<T, NoInterlace> * createTypedFieldConvertNoInterlace(const FIELD<T, FullInterlace> & field );
2282 //template <class T> FIELD<T, NoInterlace> * createTypedFieldConvertNoInterlace(const FIELD<T, NoInterlaceByType> & field );
2284 %template (createFieldDoubleConvertNoInterlace) createTypedFieldConvertNoInterlace<double>;
2286 %template (createFieldIntConvertNoInterlace) createTypedFieldConvertNoInterlace<int>;
2288 %newobject createFieldDoubleConvertFullInterlace ;
2289 %newobject createFieldIntConvertFullInterlace ;
2291 %newobject createFieldDoubleConvertNoInterlace ;
2292 %newobject createFieldIntConvertNoInterlace ;
2294 GRID * createGridFromMesh( MESH * aMesh );
2297 GRID * createGridFromMesh( MESH * aMesh )
2299 MESSAGE_MED("createGridFromMesh : Constructor (for Python API) GRID with parameter MESH *");
2300 MESSAGE_MED("Its returns a proper cast of the input pointer :: MESH --> GRID");
2302 if (aMesh->getIsAGrid())
2303 return (GRID *) aMesh;
2305 const char * message = "Error in GRID(mesh): mesh is not a grid";
2306 PyErr_SetString(PyExc_RuntimeError, (char *)message);
2310 template<class T, class INTERLACING_TAG>
2311 FIELD<T, INTERLACING_TAG> * createFieldFromAnalytic(SUPPORT * Support,
2312 int NumberOfComponents,
2313 PyObject * double_function)
2315 MESSAGE_MED("createFieldFromAnalytic : Constructor (for Python API) FIELD from an analytic fonction");
2317 FIELD<T, INTERLACING_TAG> * fieldAnalytic =
2318 new FIELD<T, INTERLACING_TAG>(Support, NumberOfComponents);
2320 MyFunction<T,double>::_pyFunc=double_function;
2321 MyFunction<T,double>::_nbOfComponent=NumberOfComponents;
2322 MyFunction<T,double>::_spaceDim=Support->getMesh()->getSpaceDimension();
2323 fieldAnalytic->fillFromAnalytic(MyFunction<T,double>::EvalPy2Cpp);
2324 return fieldAnalytic;
2328 %template (createFieldDoubleFromAnalytic) createFieldFromAnalytic<double, FullInterlace>;
2329 %template (createFieldIntFromAnalytic) createFieldFromAnalytic<int, FullInterlace>;
2330 %template (createFieldDoubleNoInterlaceFromAnalytic) createFieldFromAnalytic<double, NoInterlace>;
2331 %template (createFieldIntNoInterlaceFromAnalytic) createFieldFromAnalytic<int, NoInterlace>;