00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef GAUSS_LOCALIZATION_HXX
00024 #define GAUSS_LOCALIZATION_HXX
00025
00026 #include <vector>
00027 #include <MEDMEM.hxx>
00028 #include "MEDMEM_define.hxx"
00029 #include "MEDMEM_Exception.hxx"
00030 #include "MEDMEM_ArrayInterface.hxx"
00031 #include "MEDMEM_nArray.hxx"
00032 #include "MEDMEM_DriversDef.hxx"
00033 #include "MEDMEM_SetInterlacingType.hxx"
00034
00035 using namespace std;
00036 using namespace MEDMEM;
00037 using namespace MED_EN;
00038
00039 namespace MEDMEM {
00040
00041 class MEDMEM_EXPORT GAUSS_LOCALIZATION_ {
00042 public:
00043 virtual MED_EN::medModeSwitch getInterlacingType() const {return MED_EN::MED_UNDEFINED_INTERLACE;}
00044 virtual ~GAUSS_LOCALIZATION_() {};
00045
00049 static GAUSS_LOCALIZATION_* makeDefaultLocalization(const string & locName,
00050 medGeometryElement typeGeo,
00051 int nGauss) throw (MEDEXCEPTION);
00052 };
00053
00054 template <class INTERLACING_TAG=FullInterlace> class GAUSS_LOCALIZATION;
00055
00056 template <class INTERLACING_TAG> ostream & operator<< (ostream &os,
00057 const GAUSS_LOCALIZATION<INTERLACING_TAG> &loc);
00058
00059 template <class INTERLACING_TAG> class GAUSS_LOCALIZATION : public GAUSS_LOCALIZATION_{
00060 public:
00061 typedef typename MEDMEM_ArrayInterface<double,INTERLACING_TAG,NoGauss>::Array ArrayNoGauss;
00062
00063 protected:
00064
00065 string _locName;
00066 MED_EN::medGeometryElement _typeGeo;
00067 int _nGauss;
00068 ArrayNoGauss _cooRef;
00069 ArrayNoGauss _cooGauss;
00070 vector<double> _wg;
00071 MED_EN::medModeSwitch _interlacingType;
00072
00073 public:
00074 friend ostream & operator<< <INTERLACING_TAG>(ostream &os,
00075 const GAUSS_LOCALIZATION<INTERLACING_TAG> &loc);
00076
00077 GAUSS_LOCALIZATION() throw (MEDEXCEPTION);
00078 GAUSS_LOCALIZATION(const string & locName,
00079 const MED_EN::medGeometryElement typeGeo,
00080 const int nGauss,
00081 const ArrayNoGauss & cooRef,
00082 const ArrayNoGauss & cooGauss,
00083 const vector<double> & wg) throw (MEDEXCEPTION);
00084
00085 GAUSS_LOCALIZATION(const string & locName,
00086 const MED_EN::medGeometryElement typeGeo,
00087 const int nGauss,
00088 const double * const cooRef,
00089 const double * const cooGauss,
00090 const double * const wg) throw (MEDEXCEPTION);
00091
00092
00093 virtual ~GAUSS_LOCALIZATION() {};
00094 GAUSS_LOCALIZATION & operator=(const GAUSS_LOCALIZATION & gaussLoc);
00095 bool operator == (const GAUSS_LOCALIZATION &loc) const;
00096
00097 string getName() const {return _locName;}
00098 MED_EN::medGeometryElement getType() const {return _typeGeo;}
00099 int getNbGauss() const {return _nGauss;}
00100 const ArrayNoGauss& getRefCoo () const {return _cooRef;}
00101 const ArrayNoGauss& getGsCoo () const {return _cooGauss;}
00102 vector <double> getWeight () const {return _wg;}
00103 inline MED_EN::medModeSwitch getInterlacingType() const { return _interlacingType;}
00104
00105 };
00106 template <class INTERLACING_TAG> GAUSS_LOCALIZATION<INTERLACING_TAG>::GAUSS_LOCALIZATION() throw (MEDEXCEPTION) :
00107 _typeGeo(MED_EN::MED_NONE), _nGauss(-1),
00108 _interlacingType( SET_INTERLACING_TYPE<INTERLACING_TAG>::_interlacingType)
00109 {}
00110
00111 template <class INTERLACING_TAG> GAUSS_LOCALIZATION<INTERLACING_TAG>::GAUSS_LOCALIZATION(const string & locName,
00112 const MED_EN::medGeometryElement typeGeo,
00113 const int nGauss,
00114 const ArrayNoGauss & cooRef,
00115 const ArrayNoGauss & cooGauss,
00116 const vector<double> & wg) throw (MEDEXCEPTION) :
00117 _locName(locName),_typeGeo(typeGeo),_nGauss(nGauss),_cooRef(cooRef),_cooGauss(cooGauss),_wg(wg),
00118 _interlacingType(SET_INTERLACING_TYPE<INTERLACING_TAG>::_interlacingType)
00119 {
00120 const char * LOC = "GAUSS_LOCALIZATION(locName,typeGeo, nGauss, const ArrayNoGauss & cooRef,..) : ";
00121 BEGIN_OF_MED(LOC);
00122 if (_cooRef.getDim() != _cooGauss.getDim() )
00123 throw MEDEXCEPTION( LOCALIZED( STRING(LOC) <<"cooRef and cooGaus must have the same number of components")) ;
00124
00125 if (_cooRef.getArraySize() != (_typeGeo%100)*(_typeGeo/100) )
00126 throw MEDEXCEPTION( LOCALIZED( STRING(LOC) <<"cooRef size is " << _cooRef.getArraySize()
00127 << " and should be (_typeGeo%100)*(_typeGeo/100) "
00128 << (_typeGeo%100)*(_typeGeo/100))) ;
00129
00130 if (_cooGauss.getArraySize() != _nGauss*(_typeGeo/100) )
00131 throw MEDEXCEPTION( LOCALIZED( STRING(LOC) <<"cooGauss must be of size nGauss*(_typeGeo/100) "
00132 << _nGauss*(_typeGeo/100) ));
00133 if ((int)_wg.size() != _nGauss )
00134 throw MEDEXCEPTION( LOCALIZED( STRING(LOC) <<"wg must be of size nGauss "
00135 << _nGauss ));
00136
00137 END_OF_MED(LOC);
00138 }
00139
00140 template <class INTERLACING_TAG> GAUSS_LOCALIZATION<INTERLACING_TAG>::GAUSS_LOCALIZATION
00141 (const string & locName,
00142 const MED_EN::medGeometryElement typeGeo,
00143 const int nGauss,
00144 const double * const cooRef,
00145 const double * const cooGauss,
00146 const double * const wg) throw (MEDEXCEPTION) :
00147 _locName(locName),_typeGeo(typeGeo),_nGauss(nGauss),
00148 _cooRef(ArrayNoGauss(const_cast<double *>(cooRef),typeGeo/100,typeGeo%100)),
00149 _cooGauss(ArrayNoGauss(const_cast<double *>(cooGauss),typeGeo/100,_nGauss)),
00150 _wg(vector<double>(wg,wg+nGauss)),
00151 _interlacingType(SET_INTERLACING_TYPE<INTERLACING_TAG>::_interlacingType)
00152 {
00153 const char * LOC = "GAUSS_LOCALIZATION(locName,typeGeo, nGauss, const double * cooRef,..) :";
00154 BEGIN_OF_MED(LOC);
00155 if (_cooRef.getDim() != _cooGauss.getDim() )
00156 throw MEDEXCEPTION( LOCALIZED( STRING(LOC) <<"cooRef and cooGaus must have the same number of components")) ;
00157
00158 if (_cooRef.getArraySize() != (_typeGeo%100)*(_typeGeo/100) )
00159 throw MEDEXCEPTION( LOCALIZED( STRING(LOC) <<"cooRef must be of size (_typeGeo%100)*(_typeGeo/100) "
00160 << (_typeGeo%100)*(_typeGeo/100))) ;
00161
00162 if (_cooGauss.getArraySize() != _nGauss*(_typeGeo/100) )
00163 throw MEDEXCEPTION( LOCALIZED( STRING(LOC) <<"cooGauss must be of size nGauss*(_typeGeo/100) "
00164 << _nGauss*(_typeGeo/100) ));
00165 if ((int)_wg.size() != _nGauss )
00166 throw MEDEXCEPTION( LOCALIZED( STRING(LOC) <<"wg must be of size nGauss "
00167 << _nGauss ));
00168 END_OF_MED(LOC);
00169 }
00170
00171 template <class INTERLACING_TAG> GAUSS_LOCALIZATION<INTERLACING_TAG> &
00172 GAUSS_LOCALIZATION<INTERLACING_TAG>::operator=(const GAUSS_LOCALIZATION & gaussLoc)
00173 {
00174 if ( this == &gaussLoc) return *this;
00175
00176 _locName = gaussLoc._locName;
00177 _typeGeo = gaussLoc._typeGeo;
00178 _nGauss = gaussLoc._nGauss;
00179
00180
00181 _cooRef = gaussLoc._cooRef;
00182 _cooGauss = gaussLoc._cooGauss;
00183 _wg = gaussLoc._wg;
00184
00185 return *this;
00186 }
00187
00188 template <class INTERLACING_TAG> bool
00189 GAUSS_LOCALIZATION<INTERLACING_TAG>::operator == (const GAUSS_LOCALIZATION & gaussLoc) const {
00190 return (
00191 _locName == gaussLoc._locName &&
00192 _typeGeo == gaussLoc._typeGeo &&
00193 _nGauss == gaussLoc._nGauss &&
00194 _cooRef == gaussLoc._cooRef &&
00195 _cooGauss == gaussLoc._cooGauss &&
00196 _wg == gaussLoc._wg
00197 );
00198 }
00199
00200
00201 template <class INTERLACING_TAG> ostream & operator<<(ostream &os,
00202 const GAUSS_LOCALIZATION<INTERLACING_TAG> &loc) {
00203 os << "Localization Name : " << loc._locName << endl;
00204 os << "Geometric Type : " << MED_EN::geoNames[loc._typeGeo]<< endl;
00205 os << "Number Of GaussPoints : " << loc._nGauss << endl;
00206 os << "Ref. Element Coords : " << endl << loc._cooRef << endl;
00207 os << "Gauss points Coords : " << endl << loc._cooGauss << endl;
00208 os << "Gauss points weigth : " << endl ;
00209 for(unsigned i=0; i<loc._wg.size();++i)
00210 os << "_wg[" << i << "] = " << loc._wg[i] << endl;
00211 return os;
00212 }
00213
00214 }
00215
00216 #endif