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) :
77 _typeGeo(MED_EN::MED_NONE), _nGauss(-1),
78 _interlacingType( SET_INTERLACING_TYPE<INTERLACING_TAG>::_interlacingType)
81 template <class INTERLACING_TAG> GAUSS_LOCALIZATION<INTERLACING_TAG>::GAUSS_LOCALIZATION(const string & locName,
82 const MED_EN::medGeometryElement typeGeo,
84 const ArrayNoGauss & cooRef,
85 const ArrayNoGauss & cooGauss,
86 const vector<double> & wg) throw (MEDEXCEPTION) :
87 _locName(locName),_typeGeo(typeGeo),_nGauss(nGauss),_cooRef(cooRef),_cooGauss(cooGauss),_wg(wg),
88 _interlacingType(SET_INTERLACING_TYPE<INTERLACING_TAG>::_interlacingType)
90 const char * LOC = "GAUSS_LOCALIZATION(locName,typeGeo, nGauss, const ArrayNoGauss & cooRef,..) : ";
92 if (_cooRef.getDim() != _cooGauss.getDim() )
93 throw MEDEXCEPTION( LOCALIZED( STRING(LOC) <<"cooRef and cooGaus must have the same number of components")) ;
95 if (_cooRef.getArraySize() != (_typeGeo%100)*(_typeGeo/100) )
96 throw MEDEXCEPTION( LOCALIZED( STRING(LOC) <<"cooRef size is " << _cooRef.getArraySize()
97 << " and should be (_typeGeo%100)*(_typeGeo/100) "
98 << (_typeGeo%100)*(_typeGeo/100))) ;
100 if (_cooGauss.getArraySize() != _nGauss*(_typeGeo/100) )
101 throw MEDEXCEPTION( LOCALIZED( STRING(LOC) <<"cooGauss must be of size nGauss*(_typeGeo/100) "
102 << _nGauss*(_typeGeo/100) ));
103 if (_wg.size() != _nGauss )
104 throw MEDEXCEPTION( LOCALIZED( STRING(LOC) <<"wg must be of size nGauss "
110 template <class INTERLACING_TAG> GAUSS_LOCALIZATION<INTERLACING_TAG>::GAUSS_LOCALIZATION(const string & locName,
111 const MED_EN::medGeometryElement typeGeo,
113 const double * const cooRef,
114 const double * const cooGauss,
115 const double * const wg) throw (MEDEXCEPTION) :
116 _locName(locName),_typeGeo(typeGeo),_nGauss(nGauss),
117 _cooRef(ArrayNoGauss(const_cast<double *>(cooRef),typeGeo/100,typeGeo%100)),
118 _cooGauss(ArrayNoGauss(const_cast<double *>(cooGauss),typeGeo/100,_nGauss)),
119 _wg(vector<double>(wg,wg+nGauss)),
120 _interlacingType(SET_INTERLACING_TYPE<INTERLACING_TAG>::_interlacingType)
122 const char * LOC = "GAUSS_LOCALIZATION(locName,typeGeo, nGauss, const double * cooRef,..) :";
124 if (_cooRef.getDim() != _cooGauss.getDim() )
125 throw MEDEXCEPTION( LOCALIZED( STRING(LOC) <<"cooRef and cooGaus must have the same number of components")) ;
127 if (_cooRef.getArraySize() != (_typeGeo%100)*(_typeGeo/100) )
128 throw MEDEXCEPTION( LOCALIZED( STRING(LOC) <<"cooRef must be of size (_typeGeo%100)*(_typeGeo/100) "
129 << (_typeGeo%100)*(_typeGeo/100))) ;
131 if (_cooGauss.getArraySize() != _nGauss*(_typeGeo/100) )
132 throw MEDEXCEPTION( LOCALIZED( STRING(LOC) <<"cooGauss must be of size nGauss*(_typeGeo/100) "
133 << _nGauss*(_typeGeo/100) ));
134 if (_wg.size() != _nGauss )
135 throw MEDEXCEPTION( LOCALIZED( STRING(LOC) <<"wg must be of size nGauss "
140 template <class INTERLACING_TAG> GAUSS_LOCALIZATION<INTERLACING_TAG> &
141 GAUSS_LOCALIZATION<INTERLACING_TAG>::operator=(const GAUSS_LOCALIZATION & gaussLoc)
143 if ( this == &gaussLoc) return *this;
145 _locName = gaussLoc._locName;
146 _typeGeo = gaussLoc._typeGeo;
147 _nGauss = gaussLoc._nGauss;
148 _cooRef = ArrayNoGauss(gaussLoc._cooRef); //utilisation de la copie superficielle par défaut n'est pas une bonne idée
149 _cooGauss = ArrayNoGauss(gaussLoc._cooGauss); //dans l'opérateur = de MEDnArray
155 template <class INTERLACING_TAG> bool
156 GAUSS_LOCALIZATION<INTERLACING_TAG>::operator == (const GAUSS_LOCALIZATION & gaussLoc) const {
158 _locName == gaussLoc._locName &&
159 _typeGeo == gaussLoc._typeGeo &&
160 _nGauss == gaussLoc._nGauss &&
161 _cooRef == gaussLoc._cooRef && //utilisation de la copie superficielle par défaut n'est pas une bonne idée
162 _cooGauss == gaussLoc._cooGauss && //dans l'opérateur = de MEDnArray
168 template <class INTERLACING_TAG> ostream & operator<<(ostream &os,
169 const GAUSS_LOCALIZATION<INTERLACING_TAG> &loc) {
170 os << "Localization Name : " << loc._locName << endl;
171 os << "Geometric Type : " << MED_EN::geoNames[loc._typeGeo]<< endl;
172 os << "Number Of GaussPoints : " << loc._nGauss << endl;
173 os << "Ref. Element Coords : " << endl << loc._cooRef << endl;
174 os << "Gauss points Coords : " << endl << loc._cooGauss << endl;
175 os << "Gauss points weigth : " << endl ;
176 for(int i=0; i<loc._wg.size();++i)
177 os << "_wg[" << i << "] = " << loc._wg[i] << endl;