00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef __MATERIAL_H
00034 #define __MATERIAL_H
00035
00036
00037 #include <string>
00038
00039 #include <iostream>
00040 using std::ostream;
00041 using std::endl;
00042 using std::cerr;
00043
00044 #include <iomanip>
00045 using std::setw;
00046
00047 #include "OFELI_Config.h"
00048 #include "Point.h"
00049 #include "FFI.h"
00050 #include "fparser.h"
00051
00052 using std::string;
00053
00054 extern FunctionParser _theParser;
00055
00056 namespace OFELI {
00057
00075 enum {
00076 BY_VALUE,
00077 BY_POSITION,
00078 BY_FIELD
00079 };
00080
00081 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00082 struct Prop {
00083 bool exist;
00084 int type;
00085 double value;
00086 string fp_xyzt;
00087 };
00088 #endif
00089
00090
00091 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00092 struct ErrorInMaterial {
00093 void Message(const char *file, size_t line, int code, int p1, const string &p2);
00094 };
00095 #endif
00096
00097 class Material
00098 {
00099
00100 public:
00101
00105 Material();
00106
00108 Material(const Material &m);
00109
00111 ~Material();
00112
00116 int set(int m, const string &name, int type);
00117
00118 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00119 void scan();
00120 void scanXML();
00121 #endif
00122
00125 string getName(int m) const;
00126
00128 int getCode(size_t i) const;
00129
00131 size_t getNbMat() const;
00132
00134 void setCode(int m);
00135
00138 int check(int c);
00139
00141 double Density();
00142
00144 double Density(const Point<double> &x, double t);
00145
00147 double SpecificHeat();
00148
00150 double SpecificHeat(const Point<double> &x, double t);
00151
00153 double ThermalConductivity();
00154
00156 double ThermalConductivity(const Point<double> &x, double t);
00157
00159 double MeltingTemperature();
00160
00162 double MeltingTemperature(const Point<double> &x, double t);
00163
00165 double EvaporationTemperature();
00166
00168 double EvaporationTemperature(const Point<double> &x, double t);
00169
00171 double ThermalExpansion();
00172
00174 double ThermalExpansion(const Point<double> &x, double t);
00175
00177 double LatentHeatForMelting();
00178
00180 double LatentHeatForMelting(const Point<double> &x, double t);
00181
00183 double LatentHeatForEvaporation();
00184
00186 double LatentHeatForEvaporation(const Point<double> &x, double t);
00187
00189 double DielectricConstant();
00190
00192 double DielectricConstant(const Point<double> &x, double t);
00193
00195 double ElectricConductivity();
00196
00198 double ElectricConductivity(const Point<double> &x, double t);
00199
00201 double ElectricResistivity();
00202
00204 double ElectricResistivity(const Point<double> &x, double t);
00205
00207 double MagneticPermeability();
00208
00210 double MagneticPermeability(const Point<double> &x, double t);
00211
00213 double Viscosity();
00214
00216 double Viscosity(const Point<double> &x, double t);
00217
00219 double YoungModulus();
00220
00222 double YoungModulus(const Point<double> &x, double t);
00223
00225 double PoissonRatio();
00226
00228 double PoissonRatio(const Point<double> &x, double t);
00229
00231 double Property(int i);
00232
00234 double Property(int i, const Point<double> &x, double t);
00235
00237 Material & operator=(const Material &m)
00238 {
00239 _nb_mat = m._nb_mat;
00240 _path = m._path;
00241 for (size_t i=0; i<_nb_mat; i++) {
00242 _code[i] = m._code[i];
00243 _mat[i] = m._mat[i];
00244 }
00245 _ff = m._ff;
00246 set_kw();
00247 return *this;
00248 }
00249
00250 friend class XMLParser;
00251
00252 private:
00253
00254 int _state, _type;
00255 size_t _nb_mat, _index_mat;
00256 string _mat[MAX_NB_MATERIALS], _name, _path;
00257 int _code[MAX_NB_MATERIALS];
00258 FFI _ff;
00259 valarray<string> _kw;
00260 void getValue(size_t i);
00261 void getFunction(size_t i);
00262 void getTable() { }
00263 double _data[10];
00264 int read(size_t);
00265 ErrorInMaterial _e;
00266
00267 void set_kw();
00268 double getProperty(Prop &prop);
00269 double getProperty(Prop &prop, const Point<double> &x, const double &t);
00270 Prop _density[MAX_NB_MATERIALS];
00271 Prop _specific_heat[MAX_NB_MATERIALS];
00272 Prop _thermal_conductivity[MAX_NB_MATERIALS];
00273 Prop _melting_temperature[MAX_NB_MATERIALS];
00274 Prop _evaporation_temperature[MAX_NB_MATERIALS];
00275 Prop _thermal_expansion[MAX_NB_MATERIALS];
00276 Prop _latent_heat_melting[MAX_NB_MATERIALS];
00277 Prop _latent_heat_evaporation[MAX_NB_MATERIALS];
00278 Prop _dielectric_constant[MAX_NB_MATERIALS];
00279 Prop _electric_conductivity[MAX_NB_MATERIALS];
00280 Prop _electric_resistivity[MAX_NB_MATERIALS];
00281 Prop _magnetic_permeability[MAX_NB_MATERIALS];
00282 Prop _viscosity[MAX_NB_MATERIALS];
00283 Prop _young_modulus[MAX_NB_MATERIALS];
00284 Prop _poisson_ratio[MAX_NB_MATERIALS];
00285 Prop _prop[MAX_NB_MATERIALS][10];
00286 };
00287
00288
00292 ostream& operator<<(ostream& s, const Material &m);
00293
00294 }
00295
00296 #endif