1 #ifndef GAUSS_LOCALIZATION_HXX
2 #define GAUSS_LOCALIZATION_HXX
5 #include "MEDMEM_define.hxx"
6 #include "MEDMEM_Exception.hxx"
7 #include "MEDMEM_ArrayInterface.hxx"
8 #include "MEDMEM_nArray.hxx"
9 #include "MEDMEM_DriversDef.hxx"
10 #include "MEDMEM_SetInterlacingType.hxx"
13 using namespace MEDMEM;
14 using namespace MED_EN;
18 class GAUSS_LOCALIZATION_ {
20 virtual MED_EN::medModeSwitch getInterlacingType() const {return MED_EN::MED_UNDEFINED_INTERLACE;}
21 virtual ~GAUSS_LOCALIZATION_() {}; //Indispensable pour détruire le vrai objet pointé
24 template <class INTERLACING_TAG=FullInterlace> class GAUSS_LOCALIZATION;
26 template <class INTERLACING_TAG> ostream & operator<< (ostream &os,
27 const GAUSS_LOCALIZATION<INTERLACING_TAG> &loc);
29 template <class INTERLACING_TAG> class GAUSS_LOCALIZATION : public GAUSS_LOCALIZATION_{
31 typedef typename MEDMEM_ArrayInterface<double,INTERLACING_TAG,NoGauss>::Array ArrayNoGauss;
36 MED_EN::medGeometryElement _typeGeo;
39 ArrayNoGauss _cooGauss;
41 MED_EN::medModeSwitch _interlacingType;
44 friend ostream & operator<< <INTERLACING_TAG>(ostream &os,
45 const GAUSS_LOCALIZATION<INTERLACING_TAG> &loc);
47 GAUSS_LOCALIZATION() throw (MEDEXCEPTION);
48 GAUSS_LOCALIZATION(const string & locName,
49 const MED_EN::medGeometryElement typeGeo,
51 const ArrayNoGauss & cooRef,
52 const ArrayNoGauss & cooGauss,
53 const vector<double> & wg) throw (MEDEXCEPTION);
55 GAUSS_LOCALIZATION(const string & locName,
56 const MED_EN::medGeometryElement typeGeo,
58 const double * const cooRef,
59 const double * const cooGauss,
60 const double * const wg) throw (MEDEXCEPTION);
62 //GAUSS_LOCALIZATION(const GAUSS_LOCALIZATION & loc); constructeur de recopie par défaut correct
63 virtual ~GAUSS_LOCALIZATION() {};
64 GAUSS_LOCALIZATION & operator=(const GAUSS_LOCALIZATION & gaussLoc);
65 bool operator == (const GAUSS_LOCALIZATION &loc) const;
67 string getName() const {return _locName;}
68 MED_EN::medGeometryElement getType() const {return _typeGeo;}
69 int getNbGauss() const {return _nGauss;}
70 ArrayNoGauss getRefCoo () const {return _cooRef;} //Ces tableaux sont petits
71 ArrayNoGauss getGsCoo () const {return _cooGauss;} //Ces tableaux sont petits
72 vector <double> getWeight () const {return _wg;} //Ces tableaux sont petits
73 inline MED_EN::medModeSwitch getInterlacingType() const { return _interlacingType;}
76 template <class INTERLACING_TAG> GAUSS_LOCALIZATION<INTERLACING_TAG>::GAUSS_LOCALIZATION() throw (MEDEXCEPTION) : _typeGeo(MED_EN::MED_NONE), _nGauss(-1),
77 _interlacingType(_interlacingType( SET_INTERLACING_TYPE<INTERLACING_TAG>::_interlacingType)) {};
78 template <class INTERLACING_TAG> GAUSS_LOCALIZATION<INTERLACING_TAG>::GAUSS_LOCALIZATION(const string & locName,
79 const MED_EN::medGeometryElement typeGeo,
81 const ArrayNoGauss & cooRef,
82 const ArrayNoGauss & cooGauss,
83 const vector<double> & wg) throw (MEDEXCEPTION) :
84 _locName(locName),_typeGeo(typeGeo),_nGauss(nGauss),_cooRef(cooRef),_cooGauss(cooGauss),_wg(wg),
85 _interlacingType(SET_INTERLACING_TYPE<INTERLACING_TAG>::_interlacingType)
87 const char * LOC = "GAUSS_LOCALIZATION(locName,typeGeo, nGauss, const ArrayNoGauss & cooRef,..) : ";
89 if (_cooRef.getDim() != _cooGauss.getDim() )
90 throw MEDEXCEPTION( LOCALIZED( STRING(LOC) <<"cooRef and cooGaus must have the same number of components")) ;
92 if (_cooRef.getArraySize() != (_typeGeo%100)*(_typeGeo/100) )
93 throw MEDEXCEPTION( LOCALIZED( STRING(LOC) <<"cooRef size is " << _cooRef.getArraySize()
94 << " and should be (_typeGeo%100)*(_typeGeo/100) "
95 << (_typeGeo%100)*(_typeGeo/100))) ;
97 if (_cooGauss.getArraySize() != _nGauss*(_typeGeo/100) )
98 throw MEDEXCEPTION( LOCALIZED( STRING(LOC) <<"cooGauss must be of size nGauss*(_typeGeo/100) "
99 << _nGauss*(_typeGeo/100) ));
100 if (_wg.size() != _nGauss )
101 throw MEDEXCEPTION( LOCALIZED( STRING(LOC) <<"wg must be of size nGauss "
107 template <class INTERLACING_TAG> GAUSS_LOCALIZATION<INTERLACING_TAG>::GAUSS_LOCALIZATION(const string & locName,
108 const MED_EN::medGeometryElement typeGeo,
110 const double * const cooRef,
111 const double * const cooGauss,
112 const double * const wg) throw (MEDEXCEPTION) :
113 _locName(locName),_typeGeo(typeGeo),_nGauss(nGauss),
114 _cooRef(ArrayNoGauss(const_cast<double *>(cooRef),typeGeo/100,typeGeo%100)),
115 _cooGauss(ArrayNoGauss(const_cast<double *>(cooGauss),typeGeo/100,_nGauss)),
116 _wg(vector<double>(wg,wg+nGauss)),
117 _interlacingType(SET_INTERLACING_TYPE<INTERLACING_TAG>::_interlacingType)
119 const char * LOC = "GAUSS_LOCALIZATION(locName,typeGeo, nGauss, const double * cooRef,..) :";
121 if (_cooRef.getDim() != _cooGauss.getDim() )
122 throw MEDEXCEPTION( LOCALIZED( STRING(LOC) <<"cooRef and cooGaus must have the same number of components")) ;
124 if (_cooRef.getArraySize() != (_typeGeo%100)*(_typeGeo/100) )
125 throw MEDEXCEPTION( LOCALIZED( STRING(LOC) <<"cooRef must be of size (_typeGeo%100)*(_typeGeo/100) "
126 << (_typeGeo%100)*(_typeGeo/100))) ;
128 if (_cooGauss.getArraySize() != _nGauss*(_typeGeo/100) )
129 throw MEDEXCEPTION( LOCALIZED( STRING(LOC) <<"cooGauss must be of size nGauss*(_typeGeo/100) "
130 << _nGauss*(_typeGeo/100) ));
131 if (_wg.size() != _nGauss )
132 throw MEDEXCEPTION( LOCALIZED( STRING(LOC) <<"wg must be of size nGauss "
137 template <class INTERLACING_TAG> GAUSS_LOCALIZATION<INTERLACING_TAG> &
138 GAUSS_LOCALIZATION<INTERLACING_TAG>::operator=(const GAUSS_LOCALIZATION & gaussLoc)
140 if ( this == &gaussLoc) return *this;
142 _locName = gaussLoc._locName;
143 _typeGeo = gaussLoc._typeGeo;
144 _nGauss = gaussLoc._nGauss;
145 _cooRef = ArrayNoGauss(gaussLoc._cooRef); //utilisation de la copie superficielle par défaut n'est pas une bonne idée
146 _cooGauss = ArrayNoGauss(gaussLoc._cooGauss); //dans l'opérateur = de MEDnArray
152 template <class INTERLACING_TAG> bool
153 GAUSS_LOCALIZATION<INTERLACING_TAG>::operator == (const GAUSS_LOCALIZATION & gaussLoc) const {
155 _locName == gaussLoc._locName &&
156 _typeGeo == gaussLoc._typeGeo &&
157 _nGauss == gaussLoc._nGauss &&
158 _cooRef == gaussLoc._cooRef && //utilisation de la copie superficielle par défaut n'est pas une bonne idée
159 _cooGauss == gaussLoc._cooGauss && //dans l'opérateur = de MEDnArray
165 template <class INTERLACING_TAG> ostream & operator<<(ostream &os,
166 const GAUSS_LOCALIZATION<INTERLACING_TAG> &loc) {
167 os << "Localization Name : " << loc._locName << endl;
168 os << "Geometric Type : " << MED_EN::geoNames[loc._typeGeo]<< endl;
169 os << "Number Of GaussPoints : " << loc._nGauss << endl;
170 os << "Ref. Element Coords : " << endl << loc._cooRef << endl;
171 os << "Gauss points Coords : " << endl << loc._cooGauss << endl;
172 os << "Gauss points weigth : " << endl ;
173 for(int i=0; i<loc._wg.size();++i)
174 os << "_wg[" << i << "] = " << loc._wg[i] << endl;