From: nadir Date: Fri, 30 Sep 2005 14:40:09 +0000 (+0000) Subject: updating the main trunk with the head of the OCC_V3_0_z branch. X-Git-Tag: For_V3_1_0a1~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=547b11e58dcac1c5ffac271a6722d5ba9e8070e5;p=modules%2Fmed.git updating the main trunk with the head of the OCC_V3_0_z branch. This version will be tagged For_V3_1_0a1 which will the base of the V3_1_0a1 version. --- diff --git a/src/MEDMEM/MEDMEM_DriverTools.cxx b/src/MEDMEM/MEDMEM_DriverTools.cxx index cae3f592c..26a57cc3b 100644 --- a/src/MEDMEM/MEDMEM_DriverTools.cxx +++ b/src/MEDMEM/MEDMEM_DriverTools.cxx @@ -10,7 +10,7 @@ using namespace std; using namespace MEDMEM; using namespace MED_EN; -#define DUMP_LINES_LIMIT 100 +#define DUMP_LINES_LIMIT 20 // Cet opérateur permet d'ordonner les mailles dans un set suivant l'ordre requis par MED bool _maille::operator < (const _maille& ma) const @@ -53,7 +53,7 @@ _link _maille::link(int i) const MED_EN::medEntityMesh _maille::getEntity(const int meshDimension) const throw (MEDEXCEPTION) { const char * LOC = "_maille::getEntity(const int meshDimension)" ; - BEGIN_OF(LOC); +// BEGIN_OF(LOC); int mailleDimension = this->dimension(); medEntityMesh entity; @@ -76,7 +76,7 @@ MED_EN::medEntityMesh _maille::getEntity(const int meshDimension) const throw (M } return entity; -END_OF(LOC); +//END_OF(LOC); }; std::ostream& MEDMEM::operator << (std::ostream& os, const _maille& ma) @@ -125,14 +125,19 @@ std::ostream& MEDMEM::operator << (std::ostream& os, const _noeud& no) void MEDMEM::_fieldBase::dump(std::ostream& os) const { - os << "field " << "<" << name << ">" << endl << - " nb sub: " << nb_subcomponents << endl << - " nb comp: " << nb_components << endl << - " group index: " << group_id << endl << - " type: " << type << endl; - os << " comp names: "; - for ( int i = 0; i < comp_names.size(); ++i ) - os << " |" << comp_names[ i ] << "|"; + os << "field " << "<" << _name << ">" << endl << + " nb sub: " << _sub.size() << endl << + " group index: " << _group_id << endl << + " type: " << _type << endl; + os << " subcomponents:" << endl; + vector< _sub_data >::const_iterator sub_data = _sub.begin(); + for ( int i_sub = 1; sub_data != _sub.end(); ++sub_data, i_sub ) { + os << " group index: " << sub_data->_supp_id << + ", " << sub_data->nbComponents() << " comp names: "; + for ( int i_comp = 0; i_comp < sub_data->nbComponents(); ++i_comp ) + os << " |" << sub_data->_comp_names[ i_comp ] << "|"; + os << endl; + } } std::ostream& MEDMEM::operator << (std::ostream& os, const _fieldBase * f) @@ -228,12 +233,8 @@ void _intermediateMED::treatGroupes() std::set groups2convert; std::list< _fieldBase* >::const_iterator fIt = fields.begin(); for ( ; fIt != fields.end(); ++fIt ) - { - groups2convert.insert( (*fIt)->group_id ); - _groupe& grp = groupes[ (*fIt)->group_id ]; - for( j = grp.groupes.begin(); j!=grp.groupes.end(); ++j) - groups2convert.insert( *j-1 ); - } + (*fIt)->getGroupIds( groups2convert, true ); + // keep named groups and their subgroups for (unsigned int i=0; i!=this->groupes.size(); ++i) { @@ -251,7 +252,7 @@ void _intermediateMED::treatGroupes() _groupe& grp = groupes[i]; grp.mailles.clear(); grp.groupes.clear(); - //INFOS( "Erase " << i << "-th group " << grp.nom ); + MESSAGE( "Erase " << i << "-th group " << grp.nom ); } } @@ -353,8 +354,7 @@ _intermediateMED::getCoordinate(const string & coordinateSystem) * for memory optimisation, clear the intermediate structure (the "maillage" set ) * \endif */ -CONNECTIVITY * -_intermediateMED::getConnectivity() +CONNECTIVITY * _intermediateMED::getConnectivity() { const char * LOC = "_intermediateMED::getConnectivity() : "; BEGIN_OF(LOC); @@ -365,6 +365,7 @@ _intermediateMED::getConnectivity() int * count=NULL; int * connectivity=NULL; CONNECTIVITY *Connectivity, *Constituent; + int dimension_maillage_moin_2=maillage.rbegin()->dimension() - 2; medGeometryElement type=0; // variables de travail int nbtype=0; @@ -374,10 +375,15 @@ _intermediateMED::getConnectivity() std::vector vtype; // tableau de travail : stockage des types geometriques pour UNE entite std::vector vcount; // tableau de travail : nombre d'elements pour chaque type geometrique de vtype - std::set<_maille>::const_iterator i=maillage.begin(); // iterateurs sur les mailles - std::set<_maille>::const_iterator j=maillage.begin(); + std::set<_maille>::const_iterator i, j; // iterateurs sur les mailles + + // skip nodes and elements of or less dimension + for ( i = maillage.begin(); i != maillage.end(); ++i ) + //if ( i->geometricType != MED_POINT1 && i->dimension() > dimension_maillage_moin_2 ) + break; + j = i; - // renumerote les points de 1 a n (pour le cas ou certains points ne sont pas presents dans le maillage d'origine) + // renumerote les points de 1 a n (pour le cas ou certains points ne sont pas presents dans le maillage d'origine) numerotationPoints(); do @@ -500,10 +506,15 @@ _intermediateMED::getConnectivity() * \endif */ void -_intermediateMED::getGroups(std::vector & _groupCell, std::vector & _groupFace, std::vector & _groupEdge, std::vector & _groupNode, MESH * _ptrMesh) +_intermediateMED::getGroups(vector & _groupCell, + vector & _groupFace, + vector & _groupEdge, + vector & _groupNode, MESH * _ptrMesh) { const char * LOC = "_intermediateMED::getGroups() : "; BEGIN_OF(LOC); + + medGroupes.resize( groupes.size(), 0 ); if (maillage.size() == 0) { INFOS( "Erreur : il n'y a plus de mailles"); return; @@ -513,7 +524,7 @@ _intermediateMED::getGroups(std::vector & _groupCell, std::vector support_groups; std::list< _fieldBase* >::const_iterator fIt = fields.begin(); for ( ; fIt != fields.end(); ++fIt ) - support_groups.insert( (*fIt)->group_id ); + (*fIt)->getGroupIds( support_groups, false ); numerotationMaillage(); // Renumerotation des mailles par entite @@ -522,12 +533,17 @@ _intermediateMED::getGroups(std::vector & _groupCell, std::vectorgroupes.size(); ++i) { _groupe& grp = groupes[i]; + if ( medGroupes[ i ] ) + continue; // grp already converted into a MED group + + bool isFieldSupport = ( support_groups.find( i ) != support_groups.end() ); // si le groupe est vide, ou si le groupe n'est pas nommé : on passe au suivant - if ( grp.empty() || - ( grp.nom.empty() && support_groups.find( i ) == support_groups.end() )) { - if ( !grp.nom.empty() ) - INFOS("Skip group " << grp.nom ); - medGroupes.push_back( NULL ); + if ( grp.empty() || ( grp.nom.empty() && !isFieldSupport )) { + if ( !grp.nom.empty() ) { + INFOS("Skip group " << i << grp.nom); +// } else { +// MESSAGE("Skip group " << i << " <" << grp.nom << "> " << ( grp.empty() ? ": empty" : "")); + } continue; } @@ -549,13 +565,34 @@ _intermediateMED::getGroups(std::vector & _groupCell, std::vector" + if ( nb_elem != mailleSet.size() ) { // Self intersecting compound group + INFOS("Self intersecting group: " << i << " <" << grp.nom << ">" << ", mailleSet.size = " << mailleSet.size() << ", sum nb elems = " << nb_elem); for( vector::iterator j=grp.groupes.begin(); j!=grp.groupes.end(); ++j) INFOS(" in sub-group "<< *j << " <" << groupes[*j-1].nom << "> " << groupes[*j-1].mailles.size() << " mailles of type " << groupes[*j-1].mailles[0]->geometricType); + // if a group serve as a support to a field, then the _field is to be converted + // into several MEDMEM::FIELDs, one per sub-group; if we already skipped some sub-groups, + // we roll back the loop on groups to create MED groups for skipped ones + if ( isFieldSupport ) { + if ( grp.nom.empty() ) // clear group existing for the sake of field only + grp.groupes.clear(); + std::set sub_grps; + for ( fIt = fields.begin(); fIt != fields.end(); ++fIt ) { + _fieldBase * field = (*fIt); + if ( field->_group_id == i ) { + field->_group_id = -1; // -> a field by support + field->getGroupIds( sub_grps, false ); + } + } + if ( i > *sub_grps.begin() ) { // roll back + support_groups.erase( i ); + support_groups.insert( sub_grps.begin(), sub_grps.end() ); + i = *sub_grps.begin() - 1; + continue; + } + } } } else { @@ -563,8 +600,18 @@ _intermediateMED::getGroups(std::vector & _groupCell, std::vector" - << ", mailleSet.size = " << mailleSet.size() << ", nb elems = " << grp.mailles.size()); + INFOS( "Self intersecting group: " << i << " <" << grp.nom << ">" + << ", mailleSet.size = " << mailleSet.size() + << ", nb elems = " << grp.mailles.size()); + } + // MEDMEM does not allow constituents of -2 and less dimension + // but do not skip node group + int group_min_dim = (**mailleSet.begin()).dimension(); + int group_max_dim = (**(--mailleSet.end())).dimension(); + if ( group_max_dim != 0 && group_min_dim <= dimension_maillage - 2 ) { + INFOS("Skip group: " << i << " <" << grp.nom << "> - too small dimension: " + << group_min_dim); + continue; } // 1. Build a map _maille* -> index in MEDMEM::GROUP.getNumber(MED_ALL_ELEMENTS). @@ -650,6 +697,7 @@ _intermediateMED::getGroups(std::vector & _groupCell, std::vectorsetTotalNumberOfElements(mailleSet.size()); new_group->setName(grp.nom); @@ -665,14 +713,12 @@ _intermediateMED::getGroups(std::vector & _groupCell, std::vectorsetNumberOfGaussPoint( &nbGaussPnt[0] ); vect_group->push_back(new_group); - medGroupes.push_back( new_group ); delete [] tab_types_geometriques; delete [] tab_index_types_geometriques; delete [] tab_numeros_elements; delete [] tab_nombres_elements; } - SCRUTE( medGroupes.size() ); END_OF(LOC); } @@ -825,23 +871,24 @@ void _intermediateMED::getFields(std::list< FIELD_* >& theFields) for ( ; fIt != fields.end(); fIt++ ) { const _fieldBase* fb = *fIt; - SUPPORT* sup = getGroup( fb->group_id ); - if ( !sup ) - throw MEDEXCEPTION - (LOCALIZED(STRING(LOC) <<"_intermediateMED::getFields(), NULL field support: " - << " group index: " << fb->group_id)); - int nb_elems = sup->getNumberOfElements( MED_ALL_ELEMENTS ); - - std::list< FIELD_* > ff = fb->getField(groupes); - std::list< FIELD_* >::iterator it = ff.begin(); - for (int j = 1 ; it != ff.end(); it++, ++j ) + list > ff = fb->getField(groupes); + list >::iterator f_sup = ff.begin(); + for (int j = 1 ; f_sup != ff.end(); f_sup++, ++j ) { - FIELD_* f = *it; + FIELD_* f = f_sup->first; + SUPPORT* sup = getGroup( f_sup->second ); + if ( !sup ) + throw MEDEXCEPTION + (LOCALIZED(STRING(LOC) <<"_intermediateMED::getFields(), NULL field support: " + << " group index: " << fb->_group_id)); + int nb_elems = sup->getNumberOfElements( MED_ALL_ELEMENTS ); if ( nb_elems != f->getNumberOfValues() ) throw MEDEXCEPTION (LOCALIZED(STRING("_intermediateMED::getFields(), field support size (") << nb_elems << ") != NumberOfValues (" << f->getNumberOfValues())); theFields.push_back( f ); + if ( sup->getName().empty() ) + sup->setName( "GRP_" + f->getName() ); f->setSupport( sup ); //f->setIterationNumber( j ); f->setOrderNumber( j ); @@ -858,5 +905,40 @@ _intermediateMED::~_intermediateMED() delete *fIt; } +//======================================================================= +//function : getGroupIds +//purpose : return ids of main and/or sub- groups +//======================================================================= + +void _fieldBase::getGroupIds( std::set & ids, bool all ) const +{ + if ( hasCommonSupport() ) + ids.insert( _group_id ); + if ( all || !hasCommonSupport() ) { + vector< _sub_data >::const_iterator sub = _sub.begin(); + for ( ; sub != _sub.end(); ++sub ) + ids.insert( sub->_supp_id ); + } +} + +//======================================================================= +//function : hasSameComponentsBySupport +//purpose : +//======================================================================= + +bool _fieldBase::hasSameComponentsBySupport() const +{ + vector< _sub_data >::const_iterator sub_data = _sub.begin(); + const _sub_data& first_sub_data = *sub_data; + for ( ++sub_data ; sub_data != _sub.end(); ++sub_data ) + { + if ( first_sub_data.nbComponents() != sub_data->nbComponents() ) + return false; + for ( int iComp = 0; iComp < first_sub_data.nbComponents(); ++iComp ) + if ( first_sub_data._comp_names[ iComp ] != sub_data->_comp_names[ iComp ]) + return false; + } + return true; +} ///// diff --git a/src/MEDMEM/MEDMEM_DriverTools.hxx b/src/MEDMEM/MEDMEM_DriverTools.hxx index d9d21f5a5..fc36cf4f3 100644 --- a/src/MEDMEM/MEDMEM_DriverTools.hxx +++ b/src/MEDMEM/MEDMEM_DriverTools.hxx @@ -65,23 +65,36 @@ struct _groupe typedef std::vector< std::set<_maille>::iterator>::const_iterator mailleIter; std::string nom; std::vector< std::set<_maille>::iterator > mailles; // iterateurs sur les mailles composant le groupe -// std::set< std::set<_maille>::iterator, _mailleIteratorCompare > mailles; // iterateurs sur les mailles composant le groupe std::vector groupes; // indices des sous-groupes composant le groupe std::map relocMap; // map _maille* -> index in MEDMEM::GROUP.getNumber(MED_ALL_ELEMENTS). It is built by _intermediateMED::getGroups() bool empty() const { return mailles.empty() && groupes.empty(); } }; -class _fieldBase { - public: - int nb_subcomponents; - int nb_components; - int group_id; - MED_EN::med_type_champ type; - string name; - std::vector comp_names; - _fieldBase( MED_EN::med_type_champ theType ) - : nb_subcomponents(0), nb_components(0),group_id(-1),type(theType) {} - virtual std::list getField(std::vector<_groupe>& groupes) const = 0; +struct _fieldBase { + // a field contains several subcomponents each referring to its own support and + // having several named components + struct _sub_data { + int _supp_id; // group index within _intermediateMED::groupes + std::vector _comp_names; // componenet names + void setData( int nb_comp, int supp_id ) + { _supp_id = supp_id - 1; _comp_names.resize(nb_comp); } + int nbComponents() const { return _comp_names.size(); } + std::string & compName( int i_comp ) { return _comp_names[ i_comp ]; } + }; + std::vector< _sub_data > _sub; + int _group_id; // group index within _intermediateMED::groupes + // if _group_id == -1 then each subcomponent makes a separate MEDMEM::FIELD, else all subcomponents + // are converted into one MEDMEM::FIELD. The latter is possible only if nb of components in all subs + // is the same and supports of subcomponents do not overlap + MED_EN::med_type_champ _type; + string _name; + + _fieldBase( MED_EN::med_type_champ theType, int nb_sub ) + : _group_id(-1),_type(theType) { _sub.resize( nb_sub ); } + virtual std::list > getField(std::vector<_groupe>& groupes) const = 0; + void getGroupIds( std::set & ids, bool all ) const; // return ids of main and/or sub-groups + bool hasCommonSupport() const { return _group_id >= 0; } // true if there is one support for all subs + bool hasSameComponentsBySupport() const; virtual void dump(std::ostream&) const; virtual ~_fieldBase() {} }; @@ -89,11 +102,11 @@ class _fieldBase { template< class T > class _field: public _fieldBase { std::vector< std::vector< T > > comp_values; - std::vector< int > comp_supp_ids; public: - _field< T > ( MED_EN::med_type_champ theType ): _fieldBase( theType ) {} - std::vector< T >& addComponent( int support_id, int nb_values ); - std::list getField(std::vector<_groupe>& groupes) const; + _field< T > ( MED_EN::med_type_champ theType, int nb_sub, int total_nb_comp ) + : _fieldBase( theType, nb_sub ) { comp_values.reserve( total_nb_comp ); } + std::vector< T >& addComponent( int nb_values ); // return a vector ready to fill in + std::list > getField(std::vector<_groupe>& groupes) const; virtual void dump(std::ostream&) const; }; @@ -109,10 +122,10 @@ template< class T > class _field: public _fieldBase */ struct _intermediateMED { - std::set<_maille> maillage; - std::vector<_groupe> groupes; - std::vector medGroupes; - std::map< int, _noeud > points; + std::set<_maille> maillage; + std::vector<_groupe> groupes; + std::vector medGroupes; + std::map< int, _noeud > points; std::list< _fieldBase* > fields; bool hasMixedCells; // true if there are groups with mixed entity types @@ -141,95 +154,104 @@ std::ostream& operator << (std::ostream& , const _noeud& ); std::ostream& operator << (std::ostream& , const _intermediateMED& ); std::ostream& operator << (std::ostream& , const _fieldBase* ); -}; +// =========================================================== +// field template implementation // +// =========================================================== template - std::vector< T >& MEDMEM::_field< T >::addComponent( int support_id, int nb_values ) + std::vector< T >& _field< T >::addComponent( int nb_values ) { - if ( comp_supp_ids.empty() ) { - comp_supp_ids.reserve( nb_subcomponents * nb_components ); - comp_values.reserve( nb_subcomponents * nb_components ); - } - comp_supp_ids.push_back( support_id ); comp_values.push_back( std::vector< T >() ); std::vector< T >& res = comp_values.back(); res.resize( nb_values ); return res; } +//======================================================================= +//function : getField +//purpose : return list of pairs< field, supporting_group_id > +//======================================================================= -template -std::list MEDMEM::_field< T >::getField(std::vector<_groupe> & groupes) const +template +std::list > _field< T >::getField(std::vector<_groupe> & groupes) const { - std::list res; - int i, j, i_comp, last_comp = 0; - while ( last_comp < comp_values.size() ) + std::list > res; + + _groupe* grp = 0; + if ( hasCommonSupport() ) { // several subs are combined into one field + grp = & groupes[ _group_id ]; + if ( !grp || grp->empty() ) + return res; + } + FIELD< T > * f = 0; + int i_comp_tot = 0, nb_fields = 0; + std::set supp_id_set; + // loop on subs of this field + std::vector< _sub_data >::const_iterator sub_data = _sub.begin(); + for ( int i_sub = 1; sub_data != _sub.end(); ++sub_data, ++i_sub ) { - // find the first array of the next field - last_comp - int first_comp = last_comp; - std::set id_set; - for ( i = first_comp + nb_components - 1; i < comp_values.size(); i += nb_components ) - if ( id_set.insert( comp_supp_ids[ i ] ).second ) // unique support - last_comp = i + 1; - - _groupe& grp = groupes[ group_id ]; - if ( grp.empty () ) - continue; - int nb_val = grp.relocMap.size(); - ASSERT ( nb_val ); - - //create a filed - FIELD< T > * f = new FIELD< T >; - f->setNumberOfComponents( nb_components ); - f->setComponentsNames( &comp_names[0] ); - f->setNumberOfValues ( nb_val ); - f->setName( name ); - f->setValueType( type ); - vector str( nb_components ); - f->setComponentsDescriptions( &str[0] ); - f->setMEDComponentsUnits( &str[0] ); - res.push_back( f ); - - MESSAGE(" make field <" << name << "> on group_id " << group_id << - " relocMap.size: " << nb_val << " nb mailles: " << grp.mailles.size()); + // nb values in a field + if ( !hasCommonSupport() ) + grp = & groupes[ sub_data->_supp_id ]; + int nb_val = grp->relocMap.size(); + if ( !nb_val ) { + INFOS("Skip field <" << _name << ">: invalid supporting group " + << (hasCommonSupport() ? _group_id : sub_data->_supp_id ) + << " of " << i_sub << "-th subcomponent" ); + return res; + } + + //create a field + if ( !f || !hasCommonSupport() || !supp_id_set.insert( sub_data->_supp_id ).second ) + { + supp_id_set.clear(); + ++nb_fields; + f = new FIELD< T >; + f->setNumberOfComponents( sub_data->nbComponents() ); + f->setComponentsNames( & sub_data->_comp_names[ 0 ] ); + f->setNumberOfValues ( nb_val ); + f->setName( _name ); + f->setValueType( _type ); + vector str( sub_data->nbComponents() ); + f->setComponentsDescriptions( &str[0] ); + f->setMEDComponentsUnits( &str[0] ); + res.push_back( make_pair( f , hasCommonSupport() ? _group_id : sub_data->_supp_id )); + MESSAGE(" MAKE " << nb_fields << "-th field <" << _name << "> on group_id " << _group_id ); + } // set values - MEDARRAY< T > * medarray = new MEDARRAY< T >( nb_components, nb_val, MED_EN::MED_NO_INTERLACE ); + MEDARRAY< T > * medarray = + new MEDARRAY< T >( sub_data->nbComponents(), nb_val, MED_EN::MED_NO_INTERLACE ); f->setValue( medarray ); - for ( j = 1; j <= nb_components; ++j ) { - // loop on arrays of j-th component - for ( i_comp = first_comp++; i_comp < last_comp; i_comp += nb_components ) + // loop on components of a sub + for ( int i_comp = 0; i_comp < sub_data->nbComponents(); ++i_comp ) + { + // get nb elements in a group + _groupe & sub_grp = groupes[ sub_data->_supp_id ]; + int nb_supp_elems = sub_grp.mailles.size(); + MESSAGE("insert sub data, group_id: " << sub_data->_supp_id << + ", nb values: " << comp_values[ i_comp_tot ].size() << + ", relocMap.size: " << sub_grp.relocMap.size() << + ", nb mailles: " << nb_supp_elems); + + // store values + const std::vector< T > & values = comp_values[ i_comp_tot++ ]; + bool oneValue = ( values.size() == 1 ); + ASSERT( oneValue || values.size() == nb_supp_elems ); + for ( int k = 0; k < nb_supp_elems; ++k ) { - // get nb elements in a group - int gr_id = comp_supp_ids[ i_comp ] - 1; - if ( gr_id < 0 || gr_id >= groupes.size() ) + const T& val = oneValue ? values[ 0 ] : values[ k ]; + const _maille* ma = &(*sub_grp.mailles[ k ]); + std::map::const_iterator ma_i = grp->relocMap.find( ma ); + if ( ma_i == grp->relocMap.end() ) + throw MEDEXCEPTION + (LOCALIZED(STRING("_field< T >::getField(), cant find elem index. ") + << k << "-th elem: " << ma)); + if ( ma_i->second > nb_val ) throw MEDEXCEPTION - (LOCALIZED(STRING("_field< T >::getField(), invalid group id: ") - << gr_id << ", nb groups: " << groupes.size())); - _groupe & sub_grp = groupes[ gr_id ]; - int nb_supp_elems = sub_grp.mailles.size(); - MESSAGE(" comp_group_id " << gr_id << " nb values " << comp_values[ i_comp ].size() << - " relocMap.size: " << sub_grp.relocMap.size() << " nb mailles: " << nb_supp_elems); - - // store values - const std::vector< T > & values = comp_values[ i_comp ]; - bool oneValue = ( values.size() == 1 ); - ASSERT( oneValue || values.size() == nb_supp_elems ); - for ( int k = 0; k < nb_supp_elems; ++k ) - { - const T& val = oneValue ? values[ 0 ] : values[ k ]; - const _maille* ma = &(*sub_grp.mailles[ k ]); - std::map::const_iterator ma_i = grp.relocMap.find( ma ); - if ( ma_i == grp.relocMap.end() ) - throw MEDEXCEPTION - (LOCALIZED(STRING("_field< T >::getField(), cant find elem index. ") - << k << "-th elem: " << ma)); - if ( ma_i->second > nb_val ) - throw MEDEXCEPTION - (LOCALIZED(STRING("_field< T >::getField(), wrong elem position. ") - << k << "-th elem: " << ma - << ", pos (" << ma_i->second << ") must be <= " << nb_val)); - medarray->setIJ( ma_i->second, j, val ); - } + (LOCALIZED(STRING("_field< T >::getField(), wrong elem position. ") + << k << "-th elem: " << ma + << ", pos (" << ma_i->second << ") must be <= " << nb_val)); + medarray->setIJ( ma_i->second, i_comp + 1, val ); } } } @@ -237,14 +259,16 @@ std::list MEDMEM::_field< T >::getField(std::vector<_groupe> & } -template void MEDMEM::_field< T >::dump(std::ostream& os) const +template void _field< T >::dump(std::ostream& os) const { _fieldBase::dump(os); os << endl; for ( int i = 0 ; i < comp_values.size(); ++i ) { - os << " group: " << setw(3) << comp_supp_ids[ i ] << - " nb values: " << comp_values[ i ].size() << endl; + os << " " << i+1 << "-th component, nb values: " << comp_values[ i ].size() << endl; } } + +}; // namespace MEDMEM + #endif /* DRIVERTOOLS_HXX */ diff --git a/src/MEDMEM/MEDMEM_GibiMeshDriver.cxx b/src/MEDMEM/MEDMEM_GibiMeshDriver.cxx index 50928cbf8..b97eda48d 100644 --- a/src/MEDMEM/MEDMEM_GibiMeshDriver.cxx +++ b/src/MEDMEM/MEDMEM_GibiMeshDriver.cxx @@ -32,6 +32,20 @@ using namespace MED_EN; using namespace MEDMEM; ///// +// allows to continue reading if some data not supported by MEDMEM encountered, +// e.g. non-scalar fields +//#define STOP_READING_UNSUP_DATA + +// read or not non-named fields +#define GIBI_READ_ONLY_NAMED_FIELD + +// to see full dump of RESULTATS STRUCTURE INTERMEDIAIRES +#ifdef _DEBUG_ +// #undef MESSAGE +// #define MESSAGE(txt) std::cout << txt << endl; +// #undef INFOS +// #define INFOS(txt) std::cout << txt << endl; +#endif // Every memory allocation made in the MedDriver members function are desallocated in the Mesh destructor @@ -88,13 +102,17 @@ static int getGroupId(const vector& support_ids, _intermediateMED* medi) vector::const_iterator sb = support_ids.begin(), se = support_ids.end(); if (support_ids.size() == 1 || // one or equal support ids *std::max_element( sb, se ) == *std::min_element( sb, se )) + { group_id = support_ids[0] - 1; - else { + } + else + { // try to find an existing group with the same sub-groups set sup_set; - for ( ; sb != se; sb++ ) - sup_set.insert( *sb ); - for ( group_id = 0; group_id < medi->groupes.size(); ++group_id ) { + sup_set.insert( sb, se ); + + for ( group_id = 0; group_id < medi->groupes.size(); ++group_id ) + { if (sup_set.size() == medi->groupes[ group_id ].groupes.size() && std::equal (sup_set.begin(), sup_set.end(), medi->groupes[ group_id ].groupes.begin())) @@ -116,6 +134,19 @@ static int getGroupId(const vector& support_ids, _intermediateMED* medi) return group_id; } +//======================================================================= +//function : isNamedObject +//purpose : +//======================================================================= + +#ifdef GIBI_READ_ONLY_NAMED_FIELD +static inline bool isNamedObject( int obj_index, const vector& indices_objets_nommes ) +{ + return ( std::find( indices_objets_nommes.begin(), indices_objets_nommes.end(), obj_index) + != indices_objets_nommes.end() ); +} +#endif + //======================================================================= //function : read //purpose : @@ -406,78 +437,108 @@ bool GIBI_MESH_RDONLY_DRIVER::readFile (_intermediateMED* medi, bool readFields vector< _fieldBase* > fields( nb_objets ); for (int objet=0; objet!=nb_objets; ++objet) // pour chaque field { - initIntReading( 4 ); // nb subcomponents, nb components, IFOUR, nb attributes - int i_sub, nb_sub = getInt(); next(); - int i_comp, nb_comp = getInt(); next(); next(); + bool ignoreField = false; +#ifdef GIBI_READ_ONLY_NAMED_FIELD + ignoreField = !isNamedObject( objet+1, indices_objets_nommes ); + if ( ignoreField ) + INFOS("Skip non-named field " << objet+1 << DUMP_LINE_NB); +#endif + + // EXAMPLE ( with no values ) + + // (1) 4 7 2 1 + // (2) -88 0 3 -89 0 1 -90 0 2 -91 + // (2) 0 1 + // (3) FX FY FZ FZ FX FY FLX + // (4) 0 0 0 0 0 0 0 + // (5) créé par muc pri + // (6) + // (7) 2 + + // (1): nb subcomponents, nb components(total), IFOUR, nb attributes + initIntReading( 4 ); + int i_sub, nb_sub = getInt(); next(); + int i_comp, total_nb_comp = getInt(); next(); + next(); // ignore IFOUR int nb_attr = getInt(); - if ( nb_sub < 0 || nb_comp < 0 ) { + if ( nb_sub < 0 || total_nb_comp < 0 || nb_attr < 0 ) { INFOS("Error of field reading: wrong nb of components " - << nb_sub << " " << nb_comp << DUMP_LINE_NB); + << nb_sub << " " << total_nb_comp << DUMP_LINE_NB); return false; } - _field* fdouble = 0; - if ( nb_sub > 0 && nb_comp > 0 ) { - fdouble = new _field(MED_REEL64); - medi->fields.push_back( fdouble ); - fdouble->nb_subcomponents = nb_sub; - fdouble->nb_components = nb_comp; - fdouble->comp_names.resize( nb_comp ); - } - fields[ objet ] = fdouble; - - // loop on subcomponents of a field, each of which refers to - // a certain support and has the same number of components + // (2) loop on subcomponents of a field, for each read + // (a) support, (b) number of values and (c) number of components vector support_ids( nb_sub ); - vector nb_values( nb_sub ); - vector comp_names( nb_comp ); + vector nb_values ( nb_sub ); + vector nb_comps ( nb_sub ); + int total_nb_values = 0; initIntReading( nb_sub * 3 ); for ( i_sub = 0; i_sub < nb_sub; ++i_sub ) { - support_ids[ i_sub ] = -getInt(); next(); // reference to support + support_ids[ i_sub ] = -getInt(); next(); // (a) reference to support if ( support_ids[ i_sub ] < 1 || support_ids[ i_sub ] > medi->groupes.size() ) { INFOS("Error of field reading: wrong mesh reference "<< support_ids[ i_sub ]); return false; } - nb_values[ i_sub ] = getInt(); next(); // nb points + nb_values[ i_sub ] = getInt(); next(); // (b) nb points + total_nb_values += nb_values[ i_sub ]; if ( nb_values[ i_sub ] < 0 ) { INFOS(" Wrong nb of points: " << nb_values[ i_sub ] ); return false; } - next(); // skip nb of comp names equal to nb_comp + nb_comps[ i_sub ] = getInt(); next(); // (c) nb of components in i_sub } - initNameReading( nb_sub * nb_comp, 4 ); + // create a field if there are values + _field* fdouble = 0; + if ( total_nb_values > 0 && !ignoreField ) + { + fdouble = new _field( MED_REEL64, nb_sub, total_nb_comp ); + medi->fields.push_back( fields[ objet ] = fdouble ); + } + // (3) component names + initNameReading( total_nb_comp, 4 ); for ( i_sub = 0; i_sub < nb_sub; ++i_sub ) { - for ( i_comp = 0; i_comp < nb_comp; ++i_comp, next() ) { + // store support id and nb components of a sub + if ( fdouble ) + fdouble->_sub[ i_sub ].setData( nb_comps[ i_sub ], support_ids[ i_sub ] ); + for ( i_comp = 0; i_comp < nb_comps[ i_sub ]; ++i_comp, next() ) + { ASSERT( more() ); - fdouble->comp_names[ i_comp ] = getName();// component names + // store component name + if ( fdouble ) + fdouble->_sub[ i_sub ].compName( i_comp ) = getName(); } } - - for ( initIntReading( nb_sub ); more(); next() )// nb harmonics ( ignored ) + // (4) nb harmonics ( ignored ) + for ( initIntReading( nb_sub ); more(); next() ) ; - - getNextLine( ligne ); // TYPE ( ignored ) - getNextLine( ligne ); // TITRE ( ignored ) - for ( initIntReading( nb_attr ); more(); next() ) // attributes ( ignored ) + // (5) TYPE ( ignored ) + getNextLine( ligne ); + // (6) TITRE ( ignored ) + getNextLine( ligne ); + // (7) attributes ( ignored ) + for ( initIntReading( nb_attr ); more(); next() ) ; for ( i_sub = 0; i_sub < nb_sub; ++i_sub ) { // loop on components: read values - initDoubleReading( nb_values[ i_sub ] * nb_comp ); - for ( i_comp = 0; i_comp < nb_comp; ++i_comp ) { - vector & vals = - fdouble->addComponent( support_ids[ i_sub ], nb_values[ i_sub ] ); + initDoubleReading( nb_values[ i_sub ] * nb_comps[ i_sub ] ); + for ( i_comp = 0; i_comp < nb_comps[ i_sub ]; ++i_comp ) + { + vector* vals = 0; + if ( fdouble ) vals = & fdouble->addComponent( nb_values[ i_sub ] ); for ( int i = 0; more() && i < nb_values[ i_sub ]; next(), ++i ) { - vals[ i ] = getDouble(); + if ( vals ) (*vals)[ i ] = getDouble(); } } } // loop on subcomponents of a field - // supporting group id - if ( fdouble ) - fdouble->group_id = getGroupId( support_ids, medi ); + // set id of a group including all subs supports but only + // if all subs have the same components + if ( fdouble && fdouble->hasSameComponentsBySupport() ) + fdouble->_group_id = getGroupId( support_ids, medi ); } // end loop on field objects @@ -485,7 +546,7 @@ bool GIBI_MESH_RDONLY_DRIVER::readFile (_intermediateMED* medi, bool readFields for ( i = 0; i < nb_objets_nommes; ++i ) { int fieldIndex = indices_objets_nommes[ i ]; if ( fields[ fieldIndex - 1 ] ) - fields[ fieldIndex - 1 ]->name = objets_nommes[ i ]; + fields[ fieldIndex - 1 ]->_name = objets_nommes[ i ]; } } // Fin numero_pile == PILE_NODES_FIELD @@ -496,59 +557,89 @@ bool GIBI_MESH_RDONLY_DRIVER::readFile (_intermediateMED* medi, bool readFields else if ( numero_pile == PILE_FIELD && readFields ) { - vector< _fieldBase* > fields( nb_objets, (_fieldBase*)NULL ); + // REAL EXAMPLE + + // (1) 1 2 6 16 + // (2) CARACTERISTIQUES + // (3) -15 317773 4 0 0 0 -2 0 3 + // (4) 317581 + // (5) + // (6) 317767 317761 317755 317815 + // (7) YOUN NU H SIGY + // (8) REAL*8 REAL*8 REAL*8 REAL*8 + // (9) 1 1 0 0 + // (10) 2.00000000000000E+05 + // (11) 1 1 0 0 + // (12) 3.30000000000000E-01 + // (13) 1 1 0 0 + // (14) 1.00000000000000E+04 + // (15) 6 706 0 0 + // (16) 1.00000000000000E+02 1.00000000000000E+02 1.00000000000000E+02 + // (17) 1.00000000000000E+02 1.00000000000000E+02 1.00000000000000E+02 + // (18) ... + vector< _fieldBase* > fields( nb_objets, (_fieldBase*)0 ); for (int objet=0; objet!=nb_objets; ++objet) // pour chaque field { + bool ignoreField = false; +#ifdef GIBI_READ_ONLY_NAMED_FIELD + ignoreField = !isNamedObject( objet+1, indices_objets_nommes ); + if ( ignoreField ) + INFOS("Skip non-named field " << objet+1 << DUMP_LINE_NB); +#endif initIntReading( 1 ); - int i_sub, nb_sub = getInt(); // -1 6 + int i_sub, nb_sub = getInt(); // (1) <nb_sub> 2 6 <title length> if ( nb_sub < 1 ) { INFOS("Error of field reading: wrong nb of subcomponents " << nb_sub); return false; } - getNextLine( ligne ); // title + getNextLine( ligne ); // (2) title // look for a line starting with '-' : <reference to support> do { initIntReading( nb_sub * 9 ); } while ( getInt() >= 0 ); - int i_comp, nb_comp = 0; - vector<int> support_ids( nb_sub ); + int total_nb_comp = 0; + vector<int> support_ids( nb_sub ), nb_comp( nb_sub ); for ( i_sub = 0; i_sub < nb_sub; ++i_sub ) - { + { // (3) support_ids[ i_sub ] = -getInt(); next(); // <reference to support> - next(); // skip <address> - nb_comp = getInt(); next(); // <nb of components in the field> - for ( i = 0; i < 6; ++i ) // 0 0 0 -1 0 2 + next(); // ignore <address> + nb_comp [ i_sub ] = getInt(); next(); // <nb of components in the sub> + for ( i = 0; i < 6; ++i ) // ignore 6 ints, in example 0 0 0 -2 0 3 next(); if ( support_ids[ i_sub ] < 1 || support_ids[ i_sub ] > medi->groupes.size() ) { INFOS("Error of field reading: wrong mesh reference "<< support_ids[ i_sub ]); return false; } - if ( nb_comp < 1 ) { - INFOS("Error of field reading: wrong nb of components " << nb_comp); + if ( nb_comp[ i_sub ] < 1 ) { + INFOS("Error of field reading: wrong nb of components " << nb_comp[ i_sub ]); return false; } + total_nb_comp += nb_comp[ i_sub ]; } for ( initNameReading( nb_sub, 17 ); more(); next() ) - ; // dummy strings + ; // (4) dummy strings for ( initNameReading( nb_sub ); more(); next() ) - ; // dummy strings + ; // (5) dummy strings // loop on subcomponents of a field, each of which refers to - // a certain support and has the same number of components + // a certain support and has its own number of components; + // read component values _field<double>* fdouble = 0; _field<int>* fint = 0; - vector<string> comp_names( nb_comp ), comp_type( nb_comp ); + _fieldBase * fbase = 0; for ( i_sub = 0; i_sub < nb_sub; ++ i_sub ) { - getNextLine( ligne ); // skip nb_comp addresses of MELVAL structure + vector<string> comp_names( nb_comp[ i_sub ]), comp_type( nb_comp[ i_sub ]); + for ( initIntReading( nb_comp[ i_sub ] ); more(); next() ) + ; // (6) nb_comp addresses of MELVAL structure - // component names - for ( initNameReading( nb_comp ); more(); next() ) + // (7) component names + for ( initNameReading( nb_comp[ i_sub ] ); more(); next() ) comp_names[ index() ] = getName(); - // component type - for ( initNameReading( nb_comp, 17 ); more(); next() ) { // 17 is name width + // (8) component type + for ( initNameReading( nb_comp[ i_sub ], 17 ); more(); next() ) { // 17 is name width comp_type[ index() ] = getName(); // component types must be the same if ( index() > 0 && comp_type[ index() ] != comp_type[ index() - 1] ) { @@ -557,59 +648,83 @@ bool GIBI_MESH_RDONLY_DRIVER::readFile (_intermediateMED* medi, bool readFields return false; } } - // now type is known, create a field + // now type is known, create a field, one for all subs bool isReal = ( comp_type[0] == "REAL*8" ); - if ( !fdouble && !fint ) { - _fieldBase * fbase; + if ( !ignoreField && !fbase ) { if ( !isReal ) { - fbase = fint = new _field<int>(MED_INT32); + fbase = fint = new _field<int>( MED_INT32, nb_sub, total_nb_comp ); INFOS( "Warning: read NOT REAL field, type <" << comp_type[0] << ">" << DUMP_LINE_NB); } else - fbase = fdouble = new _field<double>(MED_REEL64); - medi->fields.push_back( fbase ); // medi->fields is a std::list - fields[ objet ] = fbase; - fbase->nb_subcomponents = nb_sub; - fbase->nb_components = nb_comp; - fbase->comp_names = comp_names; - fbase->group_id = getGroupId( support_ids, medi ); + fbase = fdouble = new _field<double>( MED_REEL64, nb_sub, total_nb_comp ); + medi->fields.push_back( fields[ objet ] = fbase ); // medi->fields is a std::list } + // store support id and nb components of a sub + if ( fbase ) + fbase->_sub[ i_sub ].setData( nb_comp[ i_sub ], support_ids[ i_sub ]); // loop on components: read values - for ( i_comp = 0; i_comp < nb_comp; ++i_comp ) { - // nb of values + for ( int i_comp = 0; i_comp < nb_comp[ i_sub ]; ++i_comp ) + { + // (9) nb of values initIntReading( 2 ); int nb_val_by_elem = getInt(); next(); int nb_values = getInt(); if ( nb_val_by_elem != 1 ) { - INFOS("Error of field reading: nb of values by element " +#ifdef STOP_READING_UNSUP_DATA + INFOS("Error of reading field " << objet + 1 << ": nb of values by element " << " != 1 : " << nb_val_by_elem << DUMP_LINE_NB ); return false; +#else + if ( fbase ) { + if ( isReal ) delete fdouble; + else delete fint; + fields[ objet ] = fbase = 0; + medi->fields.pop_back(); + INFOS("Skip field " << objet + 1 << ": nb of values by element != 1 : " + << nb_val_by_elem << DUMP_LINE_NB); + } +#endif } - if ( isReal ) { - vector<double> & vals = - fdouble->addComponent( support_ids[ i_sub ], nb_values ); - for ( initDoubleReading( nb_values ); more(); next()) { - vals[ index() ] = getDouble(); + // (10) values + nb_values *= nb_val_by_elem; + if ( fbase ) { + if ( isReal ) { + vector<double> & vals = fdouble->addComponent( nb_values ); + for ( initDoubleReading( nb_values ); more(); next()) { + vals[ index() ] = getDouble(); + } + } + else { + vector<int> & vals = fint->addComponent( nb_values ); + for ( initIntReading( nb_values ); more(); next() ) { + vals[ index() ] = getInt(); + } } + // store component name + fbase->_sub[ i_sub ].compName( i_comp ) = comp_names[ i_comp ]; } else { - vector<int> & vals = - fint->addComponent( support_ids[ i_sub ], nb_values ); - for ( initIntReading( nb_values ); more(); next() ) { - vals[ index() ] = getInt(); - } + for ( isReal ? initDoubleReading( nb_values ) : initIntReading( nb_values ); + more(); + next() ) ; } } } // loop on subcomponents of a field + // set id of a group including all sub supports but only + // if all subs have the same nb of components + if ( fbase && fbase->hasSameComponentsBySupport() ) + fbase->_group_id = getGroupId( support_ids, medi ); + } // end loop on field objects // set field names for ( i = 0; i < nb_objets_nommes; ++i ) { - int fieldIndex = indices_objets_nommes[ i ]; - fields[ fieldIndex - 1 ]->name = objets_nommes[ i ]; + int fieldIndex = indices_objets_nommes[ i ] - 1; + if ( fields[ fieldIndex ]) + fields[ fieldIndex ]->_name = objets_nommes[ i ]; } } // numero_pile == PILE_FIELD && readFields @@ -1722,6 +1837,8 @@ void GIBI_MESH_WRONLY_DRIVER::writeElements (medGeometryElement geomType, // raise if not unique //======================================================================= +#define THROW_ON_BAD_NAME + void GIBI_MESH_WRONLY_DRIVER::addName(map<string,int>& nameMap, string& theName, int index, @@ -1730,30 +1847,33 @@ void GIBI_MESH_WRONLY_DRIVER::addName(map<string,int>& nameMap, string name = cleanName( theName ); if ( !name.empty() ) { int len = name.length(); +#ifdef THROW_ON_BAD_NAME if ( len > 8 ) - throw MEDEXCEPTION(STRING("Can't write too long name: ") << name ); + throw MEDEXCEPTION(STRING("Can't write name longer than 8: ") << name ); for ( int i = 0; i < len; ++i ) name[i] = toupper( name[i] ); if ( ! nameMap.insert( make_pair( name, index )).second ) throw MEDEXCEPTION(STRING("Can't write not unique name: ") << name ); -// bool ok = ( len <= 8 && len > 0 ); -// if ( ok ) { -// for ( int i = 0; i < len; ++i ) -// name[i] = toupper( name[i] ); -// ok = nameMap.insert( make_pair( name, index )).second; -// } -// if ( !ok ) { -// char *str=new char[ prefix.size() + 13 ]; -// int j = 1; -// do { -// sprintf( str, "%s_%d", prefix.c_str(), nameMap.size()+j ); -// ok = nameMap.insert( make_pair( str, index )).second; -// j++; -// } while ( !ok ); -// INFOS( "Save <" << name << "> as <" << str << ">"); -// delete [] str; -// } +#else + bool ok = ( len <= 8 && len > 0 ); + if ( ok ) { + for ( int i = 0; i < len; ++i ) + name[i] = toupper( name[i] ); + ok = nameMap.insert( make_pair( name, index )).second; + } + if ( !ok ) { + char *str=new char[ prefix.size() + 13 ]; + int j = 1; + do { + sprintf( str, "%s_%d", prefix.c_str(), nameMap.size()+j ); + ok = nameMap.insert( make_pair( str, index )).second; + j++; + } while ( !ok ); + INFOS( "Save <" << name << "> as <" << str << ">"); + delete [] str; + } +#endif } } @@ -2148,24 +2268,21 @@ void GIBI_MED_RDONLY_DRIVER::read ( void ) throw (MEDEXCEPTION) if ( !readFile( &medi, true ) ) return; - // set name of field and its support if it is empty + // set name of field if it is empty set<string> fnames; list< _fieldBase* >::iterator fIt = medi.fields.begin(); for ( ; fIt != medi.fields.end(); fIt++ ) - fnames.insert( (*fIt)->name ); + fnames.insert( (*fIt)->_name ); int i = 0; for (fIt = medi.fields.begin(); fIt != medi.fields.end(); fIt++ ) { _fieldBase* f = *fIt; - if ( f->name.empty() ) { + if ( f->_name.empty() ) { do { ostringstream name; name << "F_" << ++i; - f->name = name.str(); - } while ( !fnames.insert( f->name ).second ); + f->_name = name.str(); + } while ( !fnames.insert( f->_name ).second ); } - _groupe& g = medi.groupes[ f->group_id ]; - if ( g.nom.empty() ) - g.nom = "GRP_" + f->name; } //MESSAGE(LOC << medi ); fillMesh( &medi ); @@ -2182,8 +2299,9 @@ void GIBI_MED_RDONLY_DRIVER::read ( void ) throw (MEDEXCEPTION) _med->addMesh( _ptrMesh ); list< FIELD_* >::iterator it = fields.begin(); - for ( ; it != fields.end(); it++ ) + for ( ; it != fields.end(); it++ ) { _med->addField( *it ); + } } catch (MEDEXCEPTION &ex) { @@ -2259,34 +2377,6 @@ template< class T > } } -//======================================================================= -//function : getSupports -//purpose : -//======================================================================= - -// int GIBI_MED_WRONLY_DRIVER::getSupports(const FIELD_* field, -// list<const SUPPORT*>& supList) const -// { -// int nbSup = 0; -// const SUPPORT* sup = field->getSupport(); -// const GROUP* group = dynamic_cast<const GROUP*>( sup ); -// if ( group ) { -// int nbFam = group->getNumberOfFamilies(); -// for ( int iFam = 1; iFam <= nbFam; ++iFam ) { -// const FAMILY* fam = group->getFamily( iFam ); -// if ( getSupportIndex( fam ) >= 0 ) { -// supList.push_back( fam ); -// nbSup++; -// } -// } -// } -// else { -// supList.push_back( sup ); -// nbSup++; -// } -// return nbSup; -// } - //======================================================================= //function : write //purpose : diff --git a/src/MEDMEM_SWIG/MEDMEM_SWIG_AsciiFieldDoubleDriver.cxx b/src/MEDMEM_SWIG/MEDMEM_SWIG_AsciiFieldDoubleDriver.cxx deleted file mode 100644 index 6d21c5b43..000000000 --- a/src/MEDMEM_SWIG/MEDMEM_SWIG_AsciiFieldDoubleDriver.cxx +++ /dev/null @@ -1,21 +0,0 @@ -#include "MEDMEM_SWIG_AsciiFieldDoubleDriver.hxx" - -using namespace std; -using namespace MEDMEM; -using namespace MED_EN; - -ASCII_FIELDDOUBLE_DRIVER::ASCII_FIELDDOUBLE_DRIVER(const string & fileName, FIELDDOUBLE * ptrField, - MED_EN::med_sort_direc direction, const char *priority): - ASCII_FIELD_DRIVER<double>(fileName,(FIELD<double> *) ptrField,direction,priority) -{ - BEGIN_OF("Constructor with arguments (for Python API) ASCII_FIELDDOUBLE_DRIVER"); - - END_OF("Constructor with arguments (for Python API) ASCII_FIELDDOUBLE_DRIVER"); -} - -ASCII_FIELDDOUBLE_DRIVER::~ASCII_FIELDDOUBLE_DRIVER() -{ - BEGIN_OF("Default Destructor (for Python API) ASCII_FIELDDOUBLE_DRIVER"); - - END_OF("Default Destructor (for Python API) ASCII_FIELDDOUBLE_DRIVER"); -} diff --git a/src/MEDMEM_SWIG/MEDMEM_SWIG_AsciiFieldDoubleDriver.hxx b/src/MEDMEM_SWIG/MEDMEM_SWIG_AsciiFieldDoubleDriver.hxx deleted file mode 100644 index c307ff719..000000000 --- a/src/MEDMEM_SWIG/MEDMEM_SWIG_AsciiFieldDoubleDriver.hxx +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef MEDMEM_SWIG_ASCIIFIELDDOUBLEDRIVER_HXX_ -#define MEDMEM_SWIG_ASCIIDFIELDDOUBLEDRIVER_HXX_ - -#include "MEDMEM_AsciiFieldDriver.hxx" -#include "MEDMEM_SWIG_FieldDouble.hxx" - -class ASCII_FIELDDOUBLE_DRIVER : public MEDMEM::ASCII_FIELD_DRIVER<double> -{ -public: - - ASCII_FIELDDOUBLE_DRIVER(const string & fileName, FIELDDOUBLE * ptrField, - MED_EN::med_sort_direc direction, const char *priority); - - ~ASCII_FIELDDOUBLE_DRIVER(); -}; - -#endif diff --git a/src/MEDMEM_SWIG/MEDMEM_SWIG_AsciiFieldIntDriver.cxx b/src/MEDMEM_SWIG/MEDMEM_SWIG_AsciiFieldIntDriver.cxx deleted file mode 100644 index 3104a928b..000000000 --- a/src/MEDMEM_SWIG/MEDMEM_SWIG_AsciiFieldIntDriver.cxx +++ /dev/null @@ -1,21 +0,0 @@ -#include "MEDMEM_SWIG_AsciiFieldIntDriver.hxx" - -using namespace std; -using namespace MEDMEM; -using namespace MED_EN; - -ASCII_FIELDINT_DRIVER::ASCII_FIELDINT_DRIVER(const string & fileName, FIELDINT * ptrField, - MED_EN::med_sort_direc direction, const char *priority): - ASCII_FIELD_DRIVER<int>(fileName,(FIELD<int> *) ptrField,direction,priority) -{ - BEGIN_OF("Constructor with arguments (for Python API) ASCII_FIELDINT_DRIVER"); - - END_OF("Constructor with arguments (for Python API) ASCII_FIELDINT_DRIVER"); -} - -ASCII_FIELDINT_DRIVER::~ASCII_FIELDINT_DRIVER() -{ - BEGIN_OF("Default Destructor (for Python API) ASCII_FIELDINT_DRIVER"); - - END_OF("Default Destructor (for Python API) ASCII_FIELDINT_DRIVER"); -} diff --git a/src/MEDMEM_SWIG/MEDMEM_SWIG_AsciiFieldIntDriver.hxx b/src/MEDMEM_SWIG/MEDMEM_SWIG_AsciiFieldIntDriver.hxx deleted file mode 100644 index 5e2fe4646..000000000 --- a/src/MEDMEM_SWIG/MEDMEM_SWIG_AsciiFieldIntDriver.hxx +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef MEDMEM_SWIG_ASCIIFIELDINTDRIVER_HXX_ -#define MEDMEM_SWIG_ASCIIFIELDINTDRIVER_HXX_ - -#include "MEDMEM_AsciiFieldDriver.hxx" -#include "MEDMEM_SWIG_FieldInt.hxx" - -class ASCII_FIELDINT_DRIVER : public MEDMEM::ASCII_FIELD_DRIVER<int> -{ -public: - - ASCII_FIELDINT_DRIVER(const string & fileName, FIELDINT * ptrField, - MED_EN::med_sort_direc direction, const char *priority); - - ~ASCII_FIELDINT_DRIVER(); -}; - -#endif diff --git a/src/MEDMEM_SWIG/MEDMEM_SWIG_FieldDouble.cxx b/src/MEDMEM_SWIG/MEDMEM_SWIG_FieldDouble.cxx deleted file mode 100644 index d54e01c55..000000000 --- a/src/MEDMEM_SWIG/MEDMEM_SWIG_FieldDouble.cxx +++ /dev/null @@ -1,86 +0,0 @@ -#include "MEDMEM_SWIG_FieldDouble.hxx" - -using namespace std; -using namespace MEDMEM; -using namespace MED_EN; - -//============================================================================= -/*! - * Default constructor - */ -//============================================================================= -FIELDDOUBLE::FIELDDOUBLE() : FIELD<double>() -{ - BEGIN_OF("Default Constructor (for Python API) FIELDDOUBLE"); - - END_OF("Default Constructor (for Python API) FIELDDOUBLE"); -} -//============================================================================= -/*! - * Constructor with arguments - */ -//============================================================================= -FIELDDOUBLE::FIELDDOUBLE(const SUPPORT * Support, const int NumberOfComponents) : FIELD<double>(Support,NumberOfComponents) -{ - BEGIN_OF("Constructor with arguments (for Python API) FIELDDOUBLE"); - - med_type_champ type = MED_REEL64; - - setValueType(type); - - END_OF("Constructor with arguments (for Python API) FIELDDOUBLE"); -} -//============================================================================= -/*! - * Another constructor with arguments - */ -//============================================================================= -FIELDDOUBLE::FIELDDOUBLE(const SUPPORT * Support, driverTypes driverType, - const string & fileName, const string & fieldName, - const int iterationNumber, const int orderNumber) : - FIELD<double>(Support, driverType, fileName, fieldName, - iterationNumber, orderNumber) -{ - BEGIN_OF("Another constructor with arguments (for Python API) FIELDDOUBLE"); - - med_type_champ type = MED_REEL64; - - setValueType(type); - - END_OF("Another constructor with arguments (for Python API) FIELDDOUBLE"); -} -//============================================================================= -/*! - * Copy constructor - */ -//============================================================================= -FIELDDOUBLE::FIELDDOUBLE(const FIELDDOUBLE & m) : - FIELD<double>( (FIELD<double> &) m) -{ - BEGIN_OF("Copy constructor (for Python API) FIELDDOUBLE"); - - END_OF("Copy constructor (for Python API) FIELDDOUBLE"); -} -//============================================================================= -/*! - * Copy constructor from a FIELD<double> - */ -//============================================================================= -FIELDDOUBLE::FIELDDOUBLE(const FIELD<double> & m) : - FIELD<double>( m) -{ - BEGIN_OF("Copy constructor (for Python API) FIELDDOUBLE from a FIELD<double>"); - - END_OF("Copy constructor (for Python API) FIELDDOUBLE from a FIELD<double>"); -} -//============================================================================= -/*! - * Destructor - */ -//============================================================================= -FIELDDOUBLE::~FIELDDOUBLE() -{ - BEGIN_OF("Default Destructor (for Python API) FIELDDOUBLE"); - - END_OF("Default Destructor (for Python API) FIELDDOUBLE"); -} diff --git a/src/MEDMEM_SWIG/MEDMEM_SWIG_FieldDouble.hxx b/src/MEDMEM_SWIG/MEDMEM_SWIG_FieldDouble.hxx deleted file mode 100644 index 655cb6539..000000000 --- a/src/MEDMEM_SWIG/MEDMEM_SWIG_FieldDouble.hxx +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef MEDMEM_SWIG_FIELDDOUBLE_HXX_ -#define MEDMEM_SWIG_FIELDDOUBLE_HXX_ - -#include "MEDMEM_Field.hxx" - -class FIELDDOUBLE : public MEDMEM::FIELD<double> -{ -public: - FIELDDOUBLE(); - FIELDDOUBLE(const MEDMEM::SUPPORT * Support, const int NumberOfComponents); - FIELDDOUBLE(const MEDMEM::SUPPORT * Support, MEDMEM::driverTypes driverType, - const string & fileName="", const string & fieldName="", - const int iterationNumber=-1, const int orderNumber=-1); - FIELDDOUBLE(const FIELDDOUBLE & m); - FIELDDOUBLE(const MEDMEM::FIELD<double> & m); - ~FIELDDOUBLE(); -}; - -#endif /* MEDMEM_SWIG_FIELDDOUBLE_HXX_ */ diff --git a/src/MEDMEM_SWIG/MEDMEM_SWIG_FieldInt.cxx b/src/MEDMEM_SWIG/MEDMEM_SWIG_FieldInt.cxx deleted file mode 100644 index 354e9adbc..000000000 --- a/src/MEDMEM_SWIG/MEDMEM_SWIG_FieldInt.cxx +++ /dev/null @@ -1,85 +0,0 @@ -#include "MEDMEM_SWIG_FieldInt.hxx" - -using namespace std; -using namespace MED_EN; -using namespace MEDMEM; - -//============================================================================= -/*! - * Default constructor - */ -//============================================================================= -FIELDINT::FIELDINT() : FIELD<int>() -{ - BEGIN_OF("Default Constructor (for Python API) FIELDINT"); - - END_OF("Default Constructor (for Python API) FIELDINT"); -} -//============================================================================= -/*! - * Constructor with arguments - */ -//============================================================================= -FIELDINT::FIELDINT(const SUPPORT * Support, const int NumberOfComponents) : FIELD<int>(Support,NumberOfComponents) -{ - BEGIN_OF("Constructor with arguments (for Python API) FIELDINT"); - - med_type_champ type = MED_INT32; - - setValueType(type); - - END_OF("Constructor with arguments (for Python API) FIELDINT"); -} -//============================================================================= -/*! - * Another constructor with arguments - */ -//============================================================================= -FIELDINT::FIELDINT(const SUPPORT * Support, driverTypes driverType, - const string & fileName, const string & fieldName, - const int iterationNumber, const int orderNumber) : - FIELD<int>(Support, driverType, fileName, fieldName, - iterationNumber, orderNumber) -{ - BEGIN_OF("Another constructor with arguments (for Python API) FIELDINT"); - - med_type_champ type = MED_INT32; - - setValueType(type); - - END_OF("Another constructor with arguments (for Python API) FIELDINT"); -} -//============================================================================= -/*! - * Copy constructor - */ -//============================================================================= -FIELDINT::FIELDINT(const FIELDINT & m) : FIELD<int>( (FIELD<int> &) m) -{ - BEGIN_OF("Copy constructor (for Python API) FIELDINT"); - - END_OF("Copy constructor (for Python API) FIELDINT"); -} -//============================================================================= -/*! - * Copy constructor from a FIELD<int> - */ -//============================================================================= -FIELDINT::FIELDINT(const FIELD<int> & m) : - FIELD<int>( m) -{ - BEGIN_OF("Copy constructor (for Python API) FIELDINT from a FIELD<int>"); - - END_OF("Copy constructor (for Python API) FIELDINT from a FIELD<int>"); -} -//============================================================================= -/*! - * Destructor - */ -//============================================================================= -FIELDINT::~FIELDINT() -{ - BEGIN_OF("Default Destructor (for Python API) FIELDINT"); - - END_OF("Default Destructor (for Python API) FIELDINT"); -} diff --git a/src/MEDMEM_SWIG/MEDMEM_SWIG_FieldInt.hxx b/src/MEDMEM_SWIG/MEDMEM_SWIG_FieldInt.hxx deleted file mode 100644 index 27b37809f..000000000 --- a/src/MEDMEM_SWIG/MEDMEM_SWIG_FieldInt.hxx +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef MEDMEM_SWIG_FIELDINT_HXX_ -#define MEDMEM_SWIG_FIELDINT_HXX_ - -#include "MEDMEM_Field.hxx" - -class FIELDINT : public MEDMEM::FIELD<int> -{ -public: - FIELDINT(); - FIELDINT(const MEDMEM::SUPPORT * Support, const int NumberOfComponents); - FIELDINT(const MEDMEM::SUPPORT * Support, MEDMEM::driverTypes driverType, - const string & fileName="", const string & fieldName="", - const int iterationNumber=-1, const int orderNumber=-1); - FIELDINT(const FIELDINT & m); - FIELDINT(const MEDMEM::FIELD<int> & m); - ~FIELDINT(); -}; - -#endif /* MEDMEM_SWIG_FIELDINT_HXX_ */ diff --git a/src/MEDMEM_SWIG/MEDMEM_SWIG_MedFieldDoubleDriver.cxx b/src/MEDMEM_SWIG/MEDMEM_SWIG_MedFieldDoubleDriver.cxx deleted file mode 100644 index 5d87413bf..000000000 --- a/src/MEDMEM_SWIG/MEDMEM_SWIG_MedFieldDoubleDriver.cxx +++ /dev/null @@ -1,150 +0,0 @@ -#include "MEDMEM_SWIG_MedFieldDoubleDriver.hxx" - -using namespace std; -using namespace MEDMEM; -using namespace MED_EN; - -//============================================================================= -/*! - * Default constructor - */ -//============================================================================= -MED_FIELDDOUBLE_DRIVER::MED_FIELDDOUBLE_DRIVER() : MED_FIELD_DRIVER<double>() -{ - BEGIN_OF("Default Constructor (for Python API) MED_FIELDDOUBLE_DRIVER"); - - END_OF("Default Constructor (for Python API) MED_FIELDDOUBLE_DRIVER"); -} -//============================================================================= -/*! - * Constructor with arguments - */ -//============================================================================= -MED_FIELDDOUBLE_DRIVER::MED_FIELDDOUBLE_DRIVER(const string & fileName, - FIELDDOUBLE * ptrField, - med_mode_acces accessMode) : - MED_FIELD_DRIVER<double>(fileName,(FIELD<double> *) ptrField,accessMode) -{ - BEGIN_OF("Constructor with arguments (for Python API) MED_FIELDDOUBLE_DRIVER"); - - END_OF("Constructor with arguments (for Python API) MED_FIELDDOUBLE_DRIVER"); -} -//============================================================================= -/*! - * Destructor - */ -//============================================================================= -MED_FIELDDOUBLE_DRIVER::~MED_FIELDDOUBLE_DRIVER() -{ - BEGIN_OF("Default Destructor (for Python API) MED_FIELDDOUBLE_DRIVER"); - - END_OF("Default Destructor (for Python API) MED_FIELDDOUBLE_DRIVER"); -} -//============================================================================= -/*! - * Default constructor - */ -//============================================================================= -MED_FIELDDOUBLE_RDONLY_DRIVER::MED_FIELDDOUBLE_RDONLY_DRIVER() : - MEDMEM::MED_FIELD_RDONLY_DRIVER<double>() -{ - BEGIN_OF("Default Constructor (for Python API) MED_FIELDDOUBLE_RDONLY_DRIVER"); - - END_OF("Default Constructor (for Python API) MED_FIELDDOUBLE_RDONLY_DRIVER"); -} -//============================================================================= -/*! - * Constructor with arguments - */ -//============================================================================= -MED_FIELDDOUBLE_RDONLY_DRIVER::MED_FIELDDOUBLE_RDONLY_DRIVER(const string & fileName, - FIELDDOUBLE * ptrField) : - MEDMEM::MED_FIELD_RDONLY_DRIVER<double>(fileName,(FIELD<double> *) ptrField) -{ - BEGIN_OF("Constructor with arguments (for Python API) MED_FIELDDOUBLE_RDONLY_DRIVER"); - - END_OF("Constructor with arguments (for Python API) MED_FIELDDOUBLE_RDONLY_DRIVER"); -} -//============================================================================= -/*! - * Destructor - */ -//============================================================================= -MED_FIELDDOUBLE_RDONLY_DRIVER::~MED_FIELDDOUBLE_RDONLY_DRIVER() -{ - BEGIN_OF("Default Destructor (for Python API) MED_FIELDDOUBLE_RDONLY_DRIVER"); - - END_OF("Default Destructor (for Python API) MED_FIELDDOUBLE_RDONLY_DRIVER"); -} -//============================================================================= -/*! - * Default constructor - */ -//============================================================================= -MED_FIELDDOUBLE_WRONLY_DRIVER::MED_FIELDDOUBLE_WRONLY_DRIVER() : - MEDMEM::MED_FIELD_WRONLY_DRIVER<double>() -{ - BEGIN_OF("Default Constructor (for Python API) MED_FIELDDOUBLE_WRONLY_DRIVER"); - - END_OF("Default Constructor (for Python API) MED_FIELDDOUBLE_WRONLY_DRIVER"); -} -//============================================================================= -/*! - * Constructor with arguments - */ -//============================================================================= -MED_FIELDDOUBLE_WRONLY_DRIVER::MED_FIELDDOUBLE_WRONLY_DRIVER(const string & fileName, - FIELDDOUBLE * ptrField) : - MEDMEM::MED_FIELD_WRONLY_DRIVER<double>(fileName,(FIELD<double> *) ptrField) -{ - BEGIN_OF("Constructor with arguments (for Python API) MED_FIELDDOUBLE_WRONLY_DRIVER"); - - END_OF("Constructor with arguments (for Python API) MED_FIELDDOUBLE_WRONLY_DRIVER"); -} -//============================================================================= -/*! - * Destructor - */ -//============================================================================= -MED_FIELDDOUBLE_WRONLY_DRIVER::~MED_FIELDDOUBLE_WRONLY_DRIVER() -{ - BEGIN_OF("Default Destructor (for Python API) MED_FIELDDOUBLE_WRONLY_DRIVER"); - - END_OF("Default Destructor (for Python API) MED_FIELDDOUBLE_WRONLY_DRIVER"); -} -//============================================================================= -/*! - * Default constructor - */ -//============================================================================= -MED_FIELDDOUBLE_RDWR_DRIVER::MED_FIELDDOUBLE_RDWR_DRIVER() : - MEDMEM::MED_FIELD_RDWR_DRIVER<double>() -{ - BEGIN_OF("Default Constructor (for Python API) MED_FIELDDOUBLE_RDWR_DRIVER"); - - END_OF("Default Constructor (for Python API) MED_FIELDDOUBLE_RDWR_DRIVER"); -} -//============================================================================= -/*! - * Constructor with arguments - */ -//============================================================================= -MED_FIELDDOUBLE_RDWR_DRIVER::MED_FIELDDOUBLE_RDWR_DRIVER(const string & fileName, - FIELDDOUBLE * ptrField) : - MEDMEM::MED_FIELD_RDWR_DRIVER<double>(fileName,(FIELD<double> *) ptrField) -{ - BEGIN_OF("Constructor with arguments (for Python API) MED_FIELDDOUBLE_RDWR_DRIVER"); - - END_OF("Constructor with arguments (for Python API) MED_FIELDDOUBLE_RDWR_DRIVER"); -} -//============================================================================= -/*! - * Destructor - */ -//============================================================================= -MED_FIELDDOUBLE_RDWR_DRIVER::~MED_FIELDDOUBLE_RDWR_DRIVER() -{ - BEGIN_OF("Default Destructor (for Python API) MED_FIELDDOUBLE_RDWR_DRIVER"); - - END_OF("Default Destructor (for Python API) MED_FIELDDOUBLE_RDWR_DRIVER"); -} diff --git a/src/MEDMEM_SWIG/MEDMEM_SWIG_MedFieldDoubleDriver.hxx b/src/MEDMEM_SWIG/MEDMEM_SWIG_MedFieldDoubleDriver.hxx deleted file mode 100644 index 5d3e9620f..000000000 --- a/src/MEDMEM_SWIG/MEDMEM_SWIG_MedFieldDoubleDriver.hxx +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef MEDMEM_SWIG_MEDFIELDDOUBLEDRIVER_HXX_ -#define MEDMEM_SWIG_MEDFIELDDOUBLEDRIVER_HXX_ - -#include "MEDMEM_SWIG_FieldDouble.hxx" -#include "MEDMEM_MedFieldDriver.hxx" - -class FIELDDOUBLE; - -class MED_FIELDDOUBLE_DRIVER : public MEDMEM::MED_FIELD_DRIVER<double> -{ -public: - MED_FIELDDOUBLE_DRIVER(); - - MED_FIELDDOUBLE_DRIVER(const string & fileName, FIELDDOUBLE * ptrField, - MED_EN::med_mode_acces accessMode); - - ~MED_FIELDDOUBLE_DRIVER(); -}; - -class MED_FIELDDOUBLE_RDONLY_DRIVER : public MEDMEM::MED_FIELD_RDONLY_DRIVER<double> -{ -public: - MED_FIELDDOUBLE_RDONLY_DRIVER(); - - MED_FIELDDOUBLE_RDONLY_DRIVER(const string & fileName, - FIELDDOUBLE * ptrField); - - ~MED_FIELDDOUBLE_RDONLY_DRIVER(); -}; - -class MED_FIELDDOUBLE_WRONLY_DRIVER : public MEDMEM::MED_FIELD_WRONLY_DRIVER<double> -{ -public: - MED_FIELDDOUBLE_WRONLY_DRIVER(); - - MED_FIELDDOUBLE_WRONLY_DRIVER(const string & fileName, - FIELDDOUBLE * ptrField); - - ~MED_FIELDDOUBLE_WRONLY_DRIVER(); -}; - -class MED_FIELDDOUBLE_RDWR_DRIVER : public MEDMEM::MED_FIELD_RDWR_DRIVER<double> -{ -public: - MED_FIELDDOUBLE_RDWR_DRIVER(); - - MED_FIELDDOUBLE_RDWR_DRIVER(const string & fileName, - FIELDDOUBLE * ptrField); - - ~MED_FIELDDOUBLE_RDWR_DRIVER(); -}; - -#endif /* MEDMEM_SWIG_MEDFIELDDOUBLEDRIVER_HXX_ */ diff --git a/src/MEDMEM_SWIG/MEDMEM_SWIG_MedFieldIntDriver.cxx b/src/MEDMEM_SWIG/MEDMEM_SWIG_MedFieldIntDriver.cxx deleted file mode 100644 index 9a080f37a..000000000 --- a/src/MEDMEM_SWIG/MEDMEM_SWIG_MedFieldIntDriver.cxx +++ /dev/null @@ -1,150 +0,0 @@ -#include "MEDMEM_SWIG_MedFieldIntDriver.hxx" - -using namespace std; -using namespace MEDMEM; -using namespace MED_EN; - -//============================================================================= -/*! - * Default constructor - */ -//============================================================================= -MED_FIELDINT_DRIVER::MED_FIELDINT_DRIVER() : MED_FIELD_DRIVER<int>() -{ - BEGIN_OF("Default Constructor (for Python API) MED_FIELDINT_DRIVER"); - - END_OF("Default Constructor (for Python API) MED_FIELDINT_DRIVER"); -} -//============================================================================= -/*! - * Constructor with arguments - */ -//============================================================================= -MED_FIELDINT_DRIVER::MED_FIELDINT_DRIVER(const string & fileName, - FIELDINT * ptrField, - med_mode_acces accessMode) : - MED_FIELD_DRIVER<int>(fileName,(FIELD<int> *) ptrField,accessMode) -{ - BEGIN_OF("Constructor with arguments (for Python API) MED_FIELDINT_DRIVER"); - - END_OF("Constructor with arguments (for Python API) MED_FIELDINT_DRIVER"); -} -//============================================================================= -/*! - * Destructor - */ -//============================================================================= -MED_FIELDINT_DRIVER::~MED_FIELDINT_DRIVER() -{ - BEGIN_OF("Default Destructor (for Python API) MED_FIELDINT_DRIVER"); - - END_OF("Default Destructor (for Python API) MED_FIELDINT_DRIVER"); -} -//============================================================================= -/*! - * Default constructor - */ -//============================================================================= -MED_FIELDINT_RDONLY_DRIVER::MED_FIELDINT_RDONLY_DRIVER() : - MEDMEM::MED_FIELD_RDONLY_DRIVER<int>() -{ - BEGIN_OF("Default Constructor (for Python API) MED_FIELDINT_RDONLY_DRIVER"); - - END_OF("Default Constructor (for Python API) MED_FIELDINT_RDONLY_DRIVER"); -} -//============================================================================= -/*! - * Constructor with arguments - */ -//============================================================================= -MED_FIELDINT_RDONLY_DRIVER::MED_FIELDINT_RDONLY_DRIVER(const string & fileName, - FIELDINT * ptrField) : - MEDMEM::MED_FIELD_RDONLY_DRIVER<int>(fileName,(FIELD<int> *) ptrField) -{ - BEGIN_OF("Constructor with arguments (for Python API) MED_FIELDINT_RDONLY_DRIVER"); - - END_OF("Constructor with arguments (for Python API) MED_FIELDINT_RDONLY_DRIVER"); -} -//============================================================================= -/*! - * Destructor - */ -//============================================================================= -MED_FIELDINT_RDONLY_DRIVER::~MED_FIELDINT_RDONLY_DRIVER() -{ - BEGIN_OF("Default Destructor (for Python API) MED_FIELDINT_RDONLY_DRIVER"); - - END_OF("Default Destructor (for Python API) MED_FIELDINT_RDONLY_DRIVER"); -} -//============================================================================= -/*! - * Default constructor - */ -//============================================================================= -MED_FIELDINT_WRONLY_DRIVER::MED_FIELDINT_WRONLY_DRIVER() : - MEDMEM::MED_FIELD_WRONLY_DRIVER<int>() -{ - BEGIN_OF("Default Constructor (for Python API) MED_FIELDINT_WRONLY_DRIVER"); - - END_OF("Default Constructor (for Python API) MED_FIELDINT_WRONLY_DRIVER"); -} -//============================================================================= -/*! - * Constructor with arguments - */ -//============================================================================= -MED_FIELDINT_WRONLY_DRIVER::MED_FIELDINT_WRONLY_DRIVER(const string & fileName, - FIELDINT * ptrField) : - MEDMEM::MED_FIELD_WRONLY_DRIVER<int>(fileName,(FIELD<int> *) ptrField) -{ - BEGIN_OF("Constructor with arguments (for Python API) MED_FIELDINT_WRONLY_DRIVER"); - - END_OF("Constructor with arguments (for Python API) MED_FIELDINT_WRONLY_DRIVER"); -} -//============================================================================= -/*! - * Destructor - */ -//============================================================================= -MED_FIELDINT_WRONLY_DRIVER::~MED_FIELDINT_WRONLY_DRIVER() -{ - BEGIN_OF("Default Destructor (for Python API) MED_FIELDINT_WRONLY_DRIVER"); - - END_OF("Default Destructor (for Python API) MED_FIELDINT_WRONLY_DRIVER"); -} -//============================================================================= -/*! - * Default constructor - */ -//============================================================================= -MED_FIELDINT_RDWR_DRIVER::MED_FIELDINT_RDWR_DRIVER() : - MEDMEM::MED_FIELD_RDWR_DRIVER<int>() -{ - BEGIN_OF("Default Constructor (for Python API) MED_FIELDINT_RDWR_DRIVER"); - - END_OF("Default Constructor (for Python API) MED_FIELDINT_RDWR_DRIVER"); -} -//============================================================================= -/*! - * Constructor with arguments - */ -//============================================================================= -MED_FIELDINT_RDWR_DRIVER::MED_FIELDINT_RDWR_DRIVER(const string & fileName, - FIELDINT * ptrField) : - MEDMEM::MED_FIELD_RDWR_DRIVER<int>(fileName,(FIELD<int> *) ptrField) -{ - BEGIN_OF("Constructor with arguments (for Python API) MED_FIELDINT_RDWR_DRIVER"); - - END_OF("Constructor with arguments (for Python API) MED_FIELDINT_RDWR_DRIVER"); -} -//============================================================================= -/*! - * Destructor - */ -//============================================================================= -MED_FIELDINT_RDWR_DRIVER::~MED_FIELDINT_RDWR_DRIVER() -{ - BEGIN_OF("Default Destructor (for Python API) MED_FIELDINT_RDWR_DRIVER"); - - END_OF("Default Destructor (for Python API) MED_FIELDINT_RDWR_DRIVER"); -} diff --git a/src/MEDMEM_SWIG/MEDMEM_SWIG_MedFieldIntDriver.hxx b/src/MEDMEM_SWIG/MEDMEM_SWIG_MedFieldIntDriver.hxx deleted file mode 100644 index 28baced7a..000000000 --- a/src/MEDMEM_SWIG/MEDMEM_SWIG_MedFieldIntDriver.hxx +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef MEDMEM_SWIG_MEDFIELDINTDRIVER_HXX_ -#define MEDMEM_SWIG_MEDFIELDINTDRIVER_HXX_ - -#include "MEDMEM_SWIG_FieldInt.hxx" -#include "MEDMEM_MedFieldDriver.hxx" - -class MED_FIELDINT_DRIVER : public MEDMEM::MED_FIELD_DRIVER<int> -{ -public: - MED_FIELDINT_DRIVER(); - - MED_FIELDINT_DRIVER(const string & fileName, FIELDINT * ptrField, - MED_EN::med_mode_acces accessMode); - - ~MED_FIELDINT_DRIVER(); -}; - -class MED_FIELDINT_RDONLY_DRIVER : public MEDMEM::MED_FIELD_RDONLY_DRIVER<int> -{ -public: - MED_FIELDINT_RDONLY_DRIVER(); - - MED_FIELDINT_RDONLY_DRIVER(const string & fileName, - FIELDINT * ptrField); - - ~MED_FIELDINT_RDONLY_DRIVER(); -}; - -class MED_FIELDINT_WRONLY_DRIVER : public MEDMEM::MED_FIELD_WRONLY_DRIVER<int> -{ -public: - MED_FIELDINT_WRONLY_DRIVER(); - - MED_FIELDINT_WRONLY_DRIVER(const string & fileName, - FIELDINT * ptrField); - - ~MED_FIELDINT_WRONLY_DRIVER(); -}; - -class MED_FIELDINT_RDWR_DRIVER : public MEDMEM::MED_FIELD_RDWR_DRIVER<int> -{ -public: - MED_FIELDINT_RDWR_DRIVER(); - - MED_FIELDINT_RDWR_DRIVER(const string & fileName, - FIELDINT * ptrField); - - ~MED_FIELDINT_RDWR_DRIVER(); -}; - -#endif /* MEDMEM_SWIG_MEDFIELDINTDRIVER_HXX_ */ diff --git a/src/MEDMEM_SWIG/MEDMEM_SWIG_Templates.hxx b/src/MEDMEM_SWIG/MEDMEM_SWIG_Templates.hxx index 79b9a1bd6..d24625e1a 100644 --- a/src/MEDMEM_SWIG/MEDMEM_SWIG_Templates.hxx +++ b/src/MEDMEM_SWIG/MEDMEM_SWIG_Templates.hxx @@ -14,13 +14,19 @@ template<> //const char *TypeBuild="d"; static int Checker(PyObject *a) { return PyFloat_Check(a); } static double Traducer(PyObject *a) { return PyFloat_AsDouble(a); } + static PyObject * Traducer( double value ) { return Py_BuildValue("d", value ); } + static double Functor(PyObject *func, double value) + { return Traducer( PyObject_CallFunction( func, "f", value )); } }; template<> struct Binding<int> { - //static const char *TypeBuild="i"; + //const char *TypeBuild="i"; static int Checker(PyObject *a) { return PyInt_Check(a); } static int Traducer(PyObject *a) { return (int) PyInt_AsLong(a); } + static PyObject * Traducer( int value ) { return Py_BuildValue("i", value ); } + static int Functor(PyObject *func, int value) + { return Traducer( PyObject_CallFunction( func, "f", value )); } }; template<class T> @@ -52,7 +58,7 @@ template<class T> Py_DECREF(function_ret); throw MEDMEM::MEDEXCEPTION("Internal Error in createFieldIntFromAnalytic : the call to the user callable fonction has failed (check its API list of integer fonct (double, double), especially the size of the returned list)"); } - for(i=0;i<_spaceDim;i++) + for(i=0;i<_nbOfComponent;i++) { PyObject * tmp=PyList_GetItem(function_ret,i); err = Binding<T>::Checker(tmp); diff --git a/src/MEDMEM_SWIG/Makefile.in b/src/MEDMEM_SWIG/Makefile.in index e09c57c10..b67282ad1 100644 --- a/src/MEDMEM_SWIG/Makefile.in +++ b/src/MEDMEM_SWIG/Makefile.in @@ -35,24 +35,25 @@ VPATH=.:$(srcdir) EXPORT_HEADERS = \ libMEDMEM_Swig.i \ my_typemap.i \ - MEDMEM_SWIG_FieldDouble.hxx \ - MEDMEM_SWIG_FieldInt.hxx \ - MEDMEM_SWIG_MedFieldDoubleDriver.hxx \ - MEDMEM_SWIG_MedFieldIntDriver.hxx \ - MEDMEM_SWIG_AsciiFieldDoubleDriver.hxx \ - MEDMEM_SWIG_AsciiFieldIntDriver.hxx \ - MEDMEM_SWIG_Templates.hxx + MEDMEM_SWIG_Templates.hxx +# MEDMEM_SWIG_MedFieldDoubleDriver.hxx \ +# MEDMEM_SWIG_MedFieldIntDriver.hxx \ +# MEDMEM_SWIG_AsciiFieldDoubleDriver.hxx \ +# MEDMEM_SWIG_AsciiFieldIntDriver.hxx \ +# MEDMEM_SWIG_FieldDouble.hxx \ +# MEDMEM_SWIG_FieldInt.hxx \ # Libraries targets LIB = libMEDMEM_Swigcmodule.la -LIB_SRC = MEDMEM_SWIG_FieldDouble.cxx \ - MEDMEM_SWIG_FieldInt.cxx \ - MEDMEM_SWIG_MedFieldDoubleDriver.cxx \ - MEDMEM_SWIG_MedFieldIntDriver.cxx \ - MEDMEM_SWIG_AsciiFieldDoubleDriver.cxx \ - MEDMEM_SWIG_AsciiFieldIntDriver.cxx +# LIB_SRC = \ +# MEDMEM_SWIG_MedFieldDoubleDriver.cxx \ +# MEDMEM_SWIG_MedFieldIntDriver.cxx \ +# MEDMEM_SWIG_AsciiFieldDoubleDriver.cxx \ +# MEDMEM_SWIG_AsciiFieldIntDriver.cxx +# MEDMEM_SWIG_FieldDouble.cxx \ +# MEDMEM_SWIG_FieldInt.cxx \ ifeq (@SWIG_VERSION@, 1.3.21) SWIG_DEF = libMEDMEM_Swig.i dummy.i @@ -68,6 +69,7 @@ SWIG_DEF = libMEDMEM_Swig.i endif EXPORT_PYSCRIPTS = libMEDMEM_Swig.py \ + medmem.py \ med_test1.py \ med_test2.py \ med_test3.py \ diff --git a/src/MEDMEM_SWIG/libMEDMEM_Swig.i b/src/MEDMEM_SWIG/libMEDMEM_Swig.i index 348b3bbba..8324ee7df 100644 --- a/src/MEDMEM_SWIG/libMEDMEM_Swig.i +++ b/src/MEDMEM_SWIG/libMEDMEM_Swig.i @@ -26,20 +26,28 @@ #include "MEDMEM_Field.hxx" #include "MEDMEM_MedMedDriver.hxx" #include "MEDMEM_Grid.hxx" -#include "MEDMEM_SWIG_FieldDouble.hxx" -#include "MEDMEM_SWIG_FieldInt.hxx" -#include "MEDMEM_SWIG_MedFieldDoubleDriver.hxx" -#include "MEDMEM_SWIG_MedFieldIntDriver.hxx" -#include "MEDMEM_SWIG_AsciiFieldDoubleDriver.hxx" -#include "MEDMEM_SWIG_AsciiFieldIntDriver.hxx" #include "MEDMEM_Meshing.hxx" #include "MEDMEM_DriverFactory.hxx" #include "MEDMEM_SWIG_Templates.hxx" +#ifdef _DEBUG_ +#include "LocalTraceCollector.hxx" +#endif /* ifdef _DEBUG_*/ + using namespace MEDMEM; using namespace MED_EN; + +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> FIELDDOUBLE; +typedef FIELD <int> FIELDINT; + %include "typemaps.i" %include "my_typemap.i" @@ -60,6 +68,17 @@ } } +/* + Initialisation block in the case of the debug mode (definition of _DEBUG_ + compilation switch) and due to the LocalTraceCollector mechanism +*/ + +%init %{ +#ifdef _DEBUG_ + LocalTraceCollector::instance(); +#endif /* ifdef _DEBUG_*/ +%} + /* managing the use of operator= of any class by renaming it assign() because assignment can't be overloaded in python. @@ -744,7 +763,7 @@ class FAMILY : public SUPPORT class FIELD_ { public: - FIELD_(const SUPPORT * Support, const int NumberOfComponents); + // FIELD_(const SUPPORT * Support, const int NumberOfComponents); ~FIELD_(); @@ -799,50 +818,50 @@ public: } }; - -class FIELDDOUBLE : public FIELD_ +template< class T1 > +class FIELD : public FIELD_ { public: - ~FIELDDOUBLE(); + ~FIELD(); - FIELDDOUBLE(const SUPPORT * Support, const int NumberOfComponents); + FIELD(const SUPPORT * Support, const int NumberOfComponents); /* WARNING: - other constructor of FIELDDOUBLE (C++ FIELD<double>) object. + 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 */ - FIELDDOUBLE(); + FIELD(); - FIELDDOUBLE(const FIELDDOUBLE & m); + FIELD(const FIELD & m); void read(int index=0); - double getValueIJ(int i,int j) const; + T1 getValueIJ(int i,int j) const; - void setValue(medModeSwitch mode, double* value); + void setValue(medModeSwitch mode, T1* value); - void setValueI(medModeSwitch mode, int i, double* value); + void setValueI(medModeSwitch mode, int i, T1* value); - void setValueIJ(int i, int j, double value); + void setValueIJ(int i, int j, T1 value); void allocValue(const int NumberOfComponents); void deallocValue(); - void applyLin(double a, double n); + void applyLin(T1 a, T1 n); - void applyPow(double scalar); + void applyPow(T1 scalar); - double normMax(); - double norm2(); - double normL2(int component, const FIELDDOUBLE * p_field_volume=NULL) const; - double normL2(const FIELDDOUBLE * p_field_volume=NULL) const; - double normL1(int component, const FIELDDOUBLE * p_field_volume=NULL) const; - double normL1(const FIELDDOUBLE * p_field_volume=NULL) const; + 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; %extend { @@ -850,7 +869,7 @@ public: { MESSAGE("Appel de applyPyFunc"); if (!PyCallable_Check(func)) { - PyErr_SetString(PyExc_TypeError, "FIELDDOUBLE.applyPyFunc prend en argument une fonction"); + PyErr_SetString(PyExc_TypeError, "FIELD.applyPyFunc prend en argument une fonction"); return NULL; } @@ -859,87 +878,85 @@ public: for (int i=1; i!=nVal+1; ++i) for ( int j=1 ;j!=nComp+1 ;++j ) { - self->setValueIJ(i,j,PyFloat_AsDouble (PyObject_CallFunction( func, "f", self->getValueIJ(i,j) ) ) ); - //cout << "value(" << i << "," << j << ") = " << self->getValueIJ(i,j) << " -> "; - //cout << PyFloat_AsDouble (PyObject_CallFunction( func, "f", self->getValueIJ(i,j) ) ) << endl; + self->setValueIJ(i,j, Binding<T1>::Functor( func, self->getValueIJ(i,j) ) ); } - PyObject * result = Py_BuildValue("d", nComp*nVal); + PyObject * result = Binding<double>::Traducer(nComp*nVal); return result; } - %newobject __add__(const FIELDDOUBLE & ); - FIELDDOUBLE * __add__(const FIELDDOUBLE & m) + %newobject __add__(const FIELD & ); + FIELD * __add__(const FIELD & m) { - MESSAGE("operator + : Creation of the addition of two FIELDDOUBLEs"); + MESSAGE("operator + : Creation of the addition of two FIELDs"); - FIELD<double>* result = FIELD<double>::add( *(FIELD<double>*)self , (FIELD<double>&)m ); - return (FIELDDOUBLE*) result; + FIELD<T1>* result = FIELD<T1>::add( *(FIELD<T1>*)self , (FIELD<T1>&)m ); + return (FIELD<T1>*) result; } - %newobject __sub__(const FIELDDOUBLE & ); - FIELDDOUBLE * __sub__(const FIELDDOUBLE & m) + %newobject __sub__(const FIELD & ); + FIELD * __sub__(const FIELD & m) { - MESSAGE("operator - : Creation of the substraction of two FIELDDOUBLEs"); - FIELD<double>* result = FIELD<double>::sub( *(FIELD<double>*)self , (FIELD<double>&)m ); - return (FIELDDOUBLE*) result; + 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; } - %newobject __mul__(const FIELDDOUBLE & ); - FIELDDOUBLE * __mul__(const FIELDDOUBLE & m) + %newobject __mul__(const FIELD & ); + FIELD * __mul__(const FIELD & m) { - MESSAGE("operator * : Creation of the multiplication of two FIELDDOUBLEs"); - FIELD<double>* result = FIELD<double>::mul( *(FIELD<double>*)self , (FIELD<double>&)m ); - return (FIELDDOUBLE*) result; + 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; } - %newobject __div__(const FIELDDOUBLE & ); - FIELDDOUBLE * __div__(const FIELDDOUBLE & m) + %newobject __div__(const FIELD & ); + FIELD * __div__(const FIELD & m) { - MESSAGE("operator / : Creation of the division of two FIELDDOUBLEs"); - FIELD<double>* result = FIELD<double>::div( *(FIELD<double>*)self , (FIELD<double>&)m ); - return (FIELDDOUBLE*) result; + 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; } %newobject addDeep(const FIELDINT & ); - FIELDDOUBLE * addDeep(const FIELDDOUBLE & m) + FIELD * addDeep(const FIELD & m) { MESSAGE("operator + : Creation of the addition of two FIELDINTs"); - FIELD<double>* result = FIELD<double>::addDeep( *(FIELD<double>*)self , (FIELD<double>&)m ); - return (FIELDDOUBLE*) result; + FIELD<T1>* result = FIELD<T1>::addDeep( *(FIELD<T1>*)self , (FIELD<T1>&)m ); + return (FIELD<T1>*) result; } - %newobject subDeep(const FIELDDOUBLE & ); - FIELDDOUBLE * subDeep(const FIELDDOUBLE & m) + %newobject subDeep(const FIELD & ); + FIELD * subDeep(const FIELD & m) { - MESSAGE("operator - : Creation of the substraction of two FIELDDOUBLEs"); - FIELD<double>* result = FIELD<double>::subDeep( *(FIELD<double>*)self , (FIELD<double>&)m ); - return (FIELDDOUBLE*) result; + 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; } - %newobject mulDeep(const FIELDDOUBLE & ); - FIELDDOUBLE * mulDeep(const FIELDDOUBLE & m) + %newobject mulDeep(const FIELD & ); + FIELD * mulDeep(const FIELD & m) { - MESSAGE("operator * : Creation of the multiplication of two FIELDDOUBLEs"); - FIELD<double>* result = FIELD<double>::mulDeep( *(FIELD<double>*)self , (FIELD<double>&)m ); - return (FIELDDOUBLE*) result; + 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; } - %newobject divDeep(const FIELDDOUBLE & ); - FIELDDOUBLE * divDeep(const FIELDDOUBLE & m) + %newobject divDeep(const FIELD & ); + FIELD * divDeep(const FIELD & m) { - MESSAGE("operator / : Creation of the division of two FIELDDOUBLEs"); - FIELD<double>* result = FIELD<double>::divDeep( *(FIELD<double>*)self , (FIELD<double>&)m ); - return (FIELDDOUBLE*) result; + 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; } - FIELDDOUBLE (const SUPPORT * Support, driverTypes driverType, + FIELD (const SUPPORT * Support, driverTypes driverType, char * fileName, char * fieldName, const int iterationNumber, const int orderNumber) { - return new FIELDDOUBLE(Support, driverType, string(fileName), - string(fieldName),iterationNumber, - orderNumber); + return new FIELD<T1>(Support, driverType, string(fileName), + string(fieldName),iterationNumber, + orderNumber); } void write(int index=0, char * driverName="") @@ -959,16 +976,16 @@ public: int size = (self->getNumberOfComponents())* ((self->getSupport())->getNumberOfElements(MED_ALL_ELEMENTS)); - const double * value = self->getValue(Mode); + const T1 * value = self->getValue(Mode); py_list = PyList_New(size); for (int i=0; i < size; i++) { int err = PyList_SetItem(py_list, i, - Py_BuildValue("d", value[i])); + Binding< T1 >::Traducer(value[i])); if(err) { - char * message = "Error in FIELDDOUBLE::getValue"; + char * message = "Error in FIELD::getValue"; PyErr_SetString(PyExc_RuntimeError, message); return NULL; } @@ -987,16 +1004,16 @@ public: if ( Mode == MED_NO_INTERLACE ) size = (self->getSupport())->getNumberOfElements(MED_ALL_ELEMENTS); - const double * value = self->getValueI(Mode,index); + const T1 * value = self->getValueI(Mode,index); py_list = PyList_New(size); for (int i=0; i < size; i++) { int err = PyList_SetItem(py_list, i, - Py_BuildValue("d", value[i])); + Binding< T1 >::Traducer( value[i]) ); if(err) { - char * message = "Error in FIELDDOUBLE::getValueI"; + char * message = "Error in FIELD::getValueI"; PyErr_SetString(PyExc_RuntimeError, message); return NULL; } @@ -1012,228 +1029,16 @@ public: } %newobject extract(const SUPPORT *subSupport); - FIELDDOUBLE *extract(const SUPPORT *subSupport) + FIELD *extract(const SUPPORT *subSupport) { - FIELD<double>* result=self->extract(subSupport); - return (FIELDDOUBLE *)result; + FIELD<T1>* result=self->extract(subSupport); + return (FIELD<T1> *)result; } } }; +%template (FIELDDOUBLE) FIELD <double>; +%template (FIELDINT) FIELD <int>; -class FIELDINT : public FIELD_ -{ -public: - ~FIELDINT(); - - FIELDINT(const SUPPORT * Support, const int NumberOfComponents); - - /* - WARNING: - other constructor of FIELDINT (C++ FIELD<int>) object. - 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 - */ - - FIELDINT(); - - FIELDINT(const FIELDINT & m); - - void read(int index=0); - - int getValueIJ(int i,int j) const; - - void setValue(medModeSwitch mode, int* value); - - void setValueI(medModeSwitch mode, int i, int* value); - - void setValueIJ(int i, int j, int value); - - void allocValue(const int NumberOfComponents); - - void deallocValue(); - - void applyLin(int a, int n); - - void applyPow(int scalar); - - double normMax(); - double norm2(); - double normL2(int component, const FIELDDOUBLE * p_field_volume=NULL) const; - double normL2(const FIELDDOUBLE * p_field_volume=NULL) const; - double normL1(int component, const FIELDDOUBLE * p_field_volume=NULL) const; - double normL1(const FIELDDOUBLE * p_field_volume=NULL) const; - - - %extend { - - PyObject * applyPyFunc( PyObject * func ) - { - if (!PyCallable_Check(func)) { - PyErr_SetString(PyExc_TypeError, "FIELDDOUBLE.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 ) - self->setValueIJ(i,j,PyInt_AsLong (PyObject_CallFunction( func, "i", self->getValueIJ(i,j) ) ) ); - PyObject * result = Py_BuildValue("d", nComp*nVal); - return result; - } - - %newobject __add__(const FIELDINT & ); - FIELDINT * __add__(const FIELDINT & m) - { - MESSAGE("operator + : Creation of the addition of two FIELDINTs"); - FIELD<int>* result = FIELD<int>::add( *(FIELD<int>*)self , (FIELD<int>&)m ); - return (FIELDINT*) result; - } - - %newobject __sub__(const FIELDINT & ); - FIELDINT * __sub__(const FIELDINT & m) - { - MESSAGE("operator - : Creation of the substraction of two FIELDINTs"); - FIELD<int>* result = FIELD<int>::sub( *(FIELD<int>*)self , (FIELD<int>&)m ); - return (FIELDINT*) result; - } - - %newobject __mul__(const FIELDINT & ); - FIELDINT * __mul__(const FIELDINT & m) - { - MESSAGE("operator * : Creation of the multiplication of two FIELDINTs"); - FIELD<int>* result = FIELD<int>::mul( *(FIELD<int>*)self , (FIELD<int>&)m ); - return (FIELDINT*) result; - } - - %newobject __div__(const FIELDINT & ); - FIELDINT * __div__(const FIELDINT & m) - { - MESSAGE("operator / : Creation of the division of two FIELDINTs"); - FIELD<int>* result = FIELD<int>::div( *(FIELD<int>*)self , (FIELD<int>&)m ); - return (FIELDINT*) result; - } - - %newobject addDeep(const FIELDINT & ); - FIELDINT * addDeep(const FIELDINT & m) - { - MESSAGE("operator + : Creation of the addition of two FIELDINTs"); - FIELD<int>* result = FIELD<int>::addDeep( *(FIELD<int>*)self , (FIELD<int>&)m ); - return (FIELDINT*) result; - } - - %newobject subDeep(const FIELDINT & ); - FIELDINT * subDeep(const FIELDINT & m) - { - MESSAGE("operator - : Creation of the substraction of two FIELDINTs"); - FIELD<int>* result = FIELD<int>::subDeep( *(FIELD<int>*)self , (FIELD<int>&)m ); - return (FIELDINT*) result; - } - - %newobject mulDeep(const FIELDINT & ); - FIELDINT * mulDeep(const FIELDINT & m) - { - MESSAGE("operator * : Creation of the multiplication of two FIELDINTs"); - FIELD<int>* result = FIELD<int>::mulDeep( *(FIELD<int>*)self , (FIELD<int>&)m ); - return (FIELDINT*) result; - } - - %newobject divDeep(const FIELDINT & ); - FIELDINT * divDeep(const FIELDINT & m) - { - MESSAGE("operator / : Creation of the division of two FIELDINTs"); - FIELD<int>* result = FIELD<int>::divDeep( *(FIELD<int>*)self , (FIELD<int>&)m ); - return (FIELDINT*) result; - } - - FIELDINT(const SUPPORT * Support, driverTypes driverType, - char * fileName, char * fieldName, - const int iterationNumber, - const int orderNumber) - { - return new FIELDINT(Support, driverType, string(fileName), - string(fieldName), iterationNumber, - orderNumber); - } - - void write(int index=0, char * driverName="") - { - self->write(index, string(driverName)); - } - - void writeAppend(int index=0, char * driverName="") - { - self->writeAppend(index, string(driverName)); - } - - PyObject * getValue(medModeSwitch Mode) - { - PyObject *py_list; - - int size = (self->getNumberOfComponents())* - ((self->getSupport())->getNumberOfElements(MED_ALL_ELEMENTS)); - - const int * value = self->getValue(Mode); - - py_list = PyList_New(size); - for (int i=0; i < size; i++) - { - int err = PyList_SetItem(py_list, i, - Py_BuildValue("i", value[i])); - if(err) - { - char * message = "Error in FIELDINT::getValue"; - PyErr_SetString(PyExc_RuntimeError, message); - return NULL; - } - } - PyObject * result = Py_BuildValue("O", py_list); - Py_DECREF(py_list); - return result; - } - - PyObject * getValueI(medModeSwitch Mode, int index) - { - PyObject *py_list; - - int size = self->getNumberOfComponents(); - - if ( Mode == MED_NO_INTERLACE ) size = (self->getSupport())->getNumberOfElements(MED_ALL_ELEMENTS); - - const int * value = self->getValueI(Mode,index); - - py_list = PyList_New(size); - for (int i=0; i < size; i++) - { - int err = PyList_SetItem(py_list, i, - Py_BuildValue("i", value[i])); - if(err) - { - char * message = "Error in FIELDINT::getValueI"; - PyErr_SetString(PyExc_RuntimeError, message); - return NULL; - } - } - PyObject * result = Py_BuildValue("O", py_list); - Py_DECREF(py_list); - return result; - } - - void allocValue2(int NumberOfComponents, int LengthValue) - { - self->allocValue(NumberOfComponents, LengthValue); - } - - %newobject extract(const SUPPORT *subSupport); - FIELDINT *extract(const SUPPORT *subSupport) - { - FIELD<int>* result=self->extract(subSupport); - return (FIELDINT *)result; - } - } -}; class GROUP : public SUPPORT { @@ -2488,14 +2293,15 @@ class MED_MESH_RDWR_DRIVER : public virtual MED_MESH_RDONLY_DRIVER, }; /* - API de MED_FIELDDOUBLE_[RDONLY,WRONLY,RDWR]_DRIVER + API de MED_FIELD_[RDONLY,WRONLY,RDWR]_DRIVER */ -class MED_FIELDDOUBLE_RDONLY_DRIVER +template< class T1 > +class MED_FIELD_RDONLY_DRIVER { public: - ~MED_FIELDDOUBLE_RDONLY_DRIVER(); + ~MED_FIELD_RDONLY_DRIVER(); void open(); @@ -2506,16 +2312,16 @@ public: void read ( void ) ; %extend { - MED_FIELDDOUBLE_RDONLY_DRIVER(char * fileName, FIELDDOUBLE * ptrField) + MED_FIELD_RDONLY_DRIVER(char * fileName, FIELD< T1 > * ptrField) { - return new MED_FIELDDOUBLE_RDONLY_DRIVER(string(fileName), ptrField); + return new MED_FIELD_RDONLY_DRIVER< T1 >(string(fileName), ptrField); } %newobject __str__(); const char* __str__() { ostringstream mess; - mess << "Python Printing MED_FIELDDOUBLE_RDONLY_DRIVER : " << *self << endl; + mess << "Python Printing MED_FIELD_RDONLY_DRIVER : " << *self << endl; return strdup(mess.str().c_str()); } @@ -2534,56 +2340,16 @@ public: } } }; +%template ( MED_FIELDDOUBLE_RDONLY_DRIVER ) MED_FIELD_RDONLY_DRIVER< double >; +%template ( MED_FIELDINT_RDONLY_DRIVER ) MED_FIELD_RDONLY_DRIVER< int >; -class MED_FIELDDOUBLE_WRONLY_DRIVER -{ -public: - - ~MED_FIELDDOUBLE_WRONLY_DRIVER(); - void open(); - - void close(); - - void write( void ) const ; - - void read ( void ) ; - - %extend { - MED_FIELDDOUBLE_WRONLY_DRIVER(char * fileName, FIELDDOUBLE * ptrField) - { - return new MED_FIELDDOUBLE_WRONLY_DRIVER(string(fileName), ptrField); - } - - %newobject __str__(); - const char* __str__() - { - ostringstream mess; - mess << "Python Printing MED_FIELDDOUBLE_WRONLY_DRIVER : " << *self << endl; - return strdup(mess.str().c_str()); - } - - void setFieldName(char * fieldName) - { - self->setFieldName(string(fieldName)); - } - - %newobject getFieldName(); - char * getFieldName() - { - string tmp_str = self->getFieldName(); - char * tmp = new char[strlen(tmp_str.c_str()) + 1]; - strcpy(tmp,tmp_str.c_str()); - return tmp; - } - } -}; - -class MED_FIELDDOUBLE_RDWR_DRIVER : public virtual MED_FIELDDOUBLE_RDONLY_DRIVER, public virtual MED_FIELDDOUBLE_WRONLY_DRIVER +template < class T1 > +class MED_FIELD_WRONLY_DRIVER { public: - ~MED_FIELDDOUBLE_RDWR_DRIVER(); + ~MED_FIELD_WRONLY_DRIVER(); void open(); @@ -2594,16 +2360,16 @@ public: void read ( void ) ; %extend { - MED_FIELDDOUBLE_RDWR_DRIVER(char * fileName, FIELDDOUBLE * ptrField) + MED_FIELD_WRONLY_DRIVER(char * fileName, FIELD< T1 > * ptrField) { - return new MED_FIELDDOUBLE_RDWR_DRIVER(string(fileName), ptrField); + return new MED_FIELD_WRONLY_DRIVER< T1 >(string(fileName), ptrField); } %newobject __str__(); const char* __str__() { ostringstream mess; - mess << "Python Printing MED_FIELDDOUBLE_RDWR_DRIVER : " << *self << endl; + mess << "Python Printing MED_FIELD_WRONLY_DRIVER : " << *self << endl; return strdup(mess.str().c_str()); } @@ -2622,16 +2388,16 @@ public: } } }; +%template ( MED_FIELDDOUBLE_WRONLY_DRIVER ) MED_FIELD_WRONLY_DRIVER< double >; +%template ( MED_FIELDINT_WRONLY_DRIVER ) MED_FIELD_WRONLY_DRIVER< int >; -/* - API de MED_FIELDINT_[RDONLY,WRONLY,RDWR]_DRIVER -*/ -class MED_FIELDINT_RDONLY_DRIVER +template< class T1 > +class MED_FIELD_RDWR_DRIVER : public virtual MED_FIELD_RDONLY_DRIVER< T1 >, public virtual MED_FIELD_WRONLY_DRIVER< T1 > { public: - ~MED_FIELDINT_RDONLY_DRIVER(); + ~MED_FIELD_RDWR_DRIVER(); void open(); @@ -2642,16 +2408,16 @@ public: void read ( void ) ; %extend { - MED_FIELDINT_RDONLY_DRIVER(char * fileName, FIELDINT * ptrField) + MED_FIELD_RDWR_DRIVER(char * fileName, FIELD< T1 > * ptrField) { - return new MED_FIELDINT_RDONLY_DRIVER(string(fileName), ptrField); + return new MED_FIELD_RDWR_DRIVER< T1 >(string(fileName), ptrField); } %newobject __str__(); const char* __str__() { ostringstream mess; - mess << "Python Printing MED_FIELDINT_RDONLY_DRIVER : " << *self << endl; + mess << "Python Printing MED_FIELD_RDWR_DRIVER : " << *self << endl; return strdup(mess.str().c_str()); } @@ -2670,56 +2436,14 @@ public: } } }; +%template ( MED_FIELDDOUBLE_RDWR_DRIVER ) MED_FIELD_RDWR_DRIVER< double >; +%template ( MED_FIELDINT_RDWR_DRIVER ) MED_FIELD_RDWR_DRIVER< int >; -class MED_FIELDINT_WRONLY_DRIVER -{ -public: - - ~MED_FIELDINT_WRONLY_DRIVER(); - - void open(); - - void close(); - - void write( void ) const ; - void read ( void ) ; - - %extend { - MED_FIELDINT_WRONLY_DRIVER(char * fileName, FIELDINT * ptrField) - { - return new MED_FIELDINT_WRONLY_DRIVER(string(fileName), ptrField); - } - - %newobject __str__(); - const char* __str__() - { - ostringstream mess; - mess << "Python Printing MED_FIELDINT_WRONLY_DRIVER : " << *self << endl; - return strdup(mess.str().c_str()); - } - - void setFieldName(char * fieldName) - { - self->setFieldName(string(fieldName)); - } - - %newobject getFieldName(); - char * getFieldName() - { - string tmp_str = self->getFieldName(); - char * tmp = new char[strlen(tmp_str.c_str()) + 1]; - strcpy(tmp,tmp_str.c_str()); - return tmp; - } - } -}; - -class MED_FIELDINT_RDWR_DRIVER : public virtual MED_FIELDINT_RDONLY_DRIVER, public virtual MED_FIELDINT_WRONLY_DRIVER -{ +template< class T1 > +class ASCII_FIELD_DRIVER { public: - - ~MED_FIELDINT_RDWR_DRIVER(); + ~ASCII_FIELD_DRIVER(); void open(); @@ -2727,137 +2451,72 @@ public: void write( void ) const ; - void read ( void ) ; %extend { - MED_FIELDINT_RDWR_DRIVER(char * fileName, FIELDINT * ptrField) - { - return new MED_FIELDINT_RDWR_DRIVER(string(fileName), ptrField); - } - - %newobject __str__(); - const char* __str__() - { - ostringstream mess; - mess << "Python Printing MED_FIELDINT_RDWR_DRIVER : " << *self << endl; - return strdup(mess.str().c_str()); - } - - void setFieldName(char * fieldName) + ASCII_FIELD_DRIVER(const char *fileName, FIELD<T1> * ptrField, med_sort_direc direction, const char *priority) { - self->setFieldName(string(fieldName)); - } - - %newobject getFieldName(); - char * getFieldName() - { - string tmp_str = self->getFieldName(); - char * tmp = new char[strlen(tmp_str.c_str()) + 1]; - strcpy(tmp,tmp_str.c_str()); - return tmp; - } - } -}; - -class ASCII_FIELDDOUBLE_DRIVER { -public: - ~ASCII_FIELDDOUBLE_DRIVER(); - - void open(); - - void close(); - - void write( void ) const ; - - - %extend { - ASCII_FIELDDOUBLE_DRIVER(const char *fileName, FIELDDOUBLE * ptrField, med_sort_direc direction, const char *priority) - { - return new ASCII_FIELDDOUBLE_DRIVER(string(fileName), ptrField, (MED_EN::med_sort_direc)direction, priority); + return new ASCII_FIELD_DRIVER<T1>(string(fileName), ptrField, (MED_EN::med_sort_direc)direction, priority); } } }; +%template (ASCII_FIELDDOUBLE_DRIVER) ASCII_FIELD_DRIVER< double >; +%template (ASCII_FIELDINT_DRIVER) ASCII_FIELD_DRIVER< int >; -class ASCII_FIELDINT_DRIVER { -public: - ~ASCII_FIELDINT_DRIVER(); - - void open(); - void close(); - - void write( void ) const ; +%{ +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; +} +%} - %extend { - ASCII_FIELDINT_DRIVER(const char *fileName, FIELDINT * ptrField, med_sort_direc direction, const char *priority) - { - return new ASCII_FIELDINT_DRIVER(string(fileName), ptrField, (MED_EN::med_sort_direc)direction, priority); - } - } -}; +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) ; -FIELDDOUBLE * createFieldDoubleScalarProduct(FIELDDOUBLE * field1, FIELDDOUBLE * field2) ; - %newobject createFieldIntScalarProduct(FIELDINT * field1, FIELDINT * field2) ; -FIELDINT * createFieldIntScalarProduct(FIELDINT * field1, FIELDINT * field2) ; +%template ( createFieldDoubleScalarProduct ) createFieldScalarProduct < double >; +%template ( createFieldIntScalarProduct ) createFieldScalarProduct < int >; +template <class T> FIELD<T> * createFieldScalarProductDeep(FIELD<T> * field1, FIELD<T> * field2); %newobject createFieldDoubleScalarProductDeep(FIELDDOUBLE * field1, FIELDDOUBLE * field2) ; -FIELDDOUBLE * createFieldDoubleScalarProductDeep(FIELDDOUBLE * field1, FIELDDOUBLE * field2) ; - %newobject createFieldIntScalarProductDeep(FIELDINT * field1, FIELDINT * field2) ; -FIELDINT * createFieldIntScalarProductDeep(FIELDINT * field1, FIELDINT * field2) ; - -FIELDDOUBLE * createFieldDoubleFromField(FIELD_ * field) ; - -FIELDINT * createFieldIntFromField(FIELD_ * field) ; +%template ( createFieldDoubleScalarProductDeep ) createFieldScalarProductDeep < double >; +%template ( createFieldIntScalarProductDeep ) createFieldScalarProductDeep < int >; %newobject createFieldDoubleFromAnalytic(SUPPORT * , int , PyObject *); -FIELDDOUBLE * createFieldDoubleFromAnalytic(SUPPORT * Support, - int NumberOfComponents, - PyObject * double_function) ; - %newobject createFieldIntFromAnalytic(SUPPORT * , int , PyObject *); +FIELDDOUBLE * createFieldDoubleFromAnalytic(SUPPORT * Support, + int NumberOfComponents, + PyObject * double_function); FIELDINT * createFieldIntFromAnalytic(SUPPORT * Support, - int NumberOfComponents, - PyObject * integer_function) ; + int NumberOfComponents, + PyObject * integer_function); -GRID * createGridFromMesh( MESH * aMesh ); +GRID * createGridFromMesh( MESH * aMesh ); %{ - FIELDDOUBLE * createFieldDoubleScalarProduct(FIELDDOUBLE * field1, FIELDDOUBLE * field2) - { - return (FIELDDOUBLE *) FIELD<double>::scalarProduct( (FIELD<double>)*field1, (FIELD<double>)*field2); - } - - FIELDINT * createFieldIntScalarProduct(FIELDINT * field1, FIELDINT * field2) - { - return (FIELDINT *) FIELD<int>::scalarProduct( (FIELD<int>)*field1, (FIELD<int>)*field2); - } - - FIELDDOUBLE * createFieldDoubleScalarProductDeep(FIELDDOUBLE * field1, FIELDDOUBLE * field2) - { - return (FIELDDOUBLE *) FIELD<double>::scalarProduct( (FIELD<double>)*field1, (FIELD<double>)*field2, true); - } - - FIELDINT * createFieldIntScalarProductDeep(FIELDINT * field1, FIELDINT * field2) - { - return (FIELDINT *) FIELD<int>::scalarProduct( (FIELD<int>)*field1, (FIELD<int>)*field2, true); - } - - FIELDDOUBLE * createFieldDoubleFromField(FIELD_ * field) + GRID * createGridFromMesh( MESH * aMesh ) { - MESSAGE("createFieldDoubleFromField : Constructor (for Python API) FIELDDOUBLE with parameter FIELD_"); - MESSAGE("Its returns a proper cast of the input pointer :: FIELD_ --> FIELDDOUBLE"); - return (FIELDDOUBLE *) field; - } + MESSAGE("createGridFromMesh : Constructor (for Python API) GRID with parameter MESH *"); + MESSAGE("Its returns a proper cast of the input pointer :: MESH --> GRID"); - FIELDINT * createFieldIntFromField(FIELD_ * field) - { - MESSAGE("createFieldIntFromField : Constructor (for Python API) FIELDINT with parameter FIELD_"); - MESSAGE("Its returns a proper cast of the input pointer :: FIELD_ --> FIELDINT"); - return (FIELDINT *) field; + if (aMesh->getIsAGrid()) + return (GRID *) aMesh; + + char * message = "Error in GRID(mesh): mesh is not a grid"; + PyErr_SetString(PyExc_RuntimeError, message); + return NULL; } FIELDDOUBLE * createFieldDoubleFromAnalytic(SUPPORT * Support, @@ -2885,17 +2544,4 @@ GRID * createGridFromMesh( MESH * aMesh ); fieldInt->fillFromAnalytic< MyFunction<int>::EvalPy2Cpp >(); return fieldInt; } - - GRID * createGridFromMesh( MESH * aMesh ) - { - MESSAGE("createGridFromMesh : Constructor (for Python API) GRID with parameter MESH *"); - MESSAGE("Its returns a proper cast of the input pointer :: MESH --> GRID"); - - if (aMesh->getIsAGrid()) - return (GRID *) aMesh; - - char * message = "Error in GRID(mesh): mesh is not a grid"; - PyErr_SetString(PyExc_RuntimeError, message); - return NULL; - } %} diff --git a/src/MEDMEM_SWIG/medmem.py b/src/MEDMEM_SWIG/medmem.py new file mode 100644 index 000000000..ab60ce3cc --- /dev/null +++ b/src/MEDMEM_SWIG/medmem.py @@ -0,0 +1 @@ +from libMEDMEM_Swig import * diff --git a/src/MedCorba_Swig/libMedCorba_Swig.i b/src/MedCorba_Swig/libMedCorba_Swig.i index f8dc2033d..a793f42e9 100644 --- a/src/MedCorba_Swig/libMedCorba_Swig.i +++ b/src/MedCorba_Swig/libMedCorba_Swig.i @@ -12,8 +12,8 @@ #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" +// #include "MEDMEM_SWIG_FieldDouble.hxx" +// #include "MEDMEM_SWIG_FieldInt.hxx" using namespace MEDMEM; using namespace MED_EN;