00001
00029 #ifndef MATERIAL
00030 #define MATERIAL
00031
00032 #include <vector>
00033 #include <string>
00034 #include <iostream>
00035 #include <algorithm>
00036
00037 #include <cmath>
00038 #include <cassert>
00039
00040 #include "Galois/Runtime/PerCPU.h"
00047 class Material {
00048 };
00049
00063 class SimpleMaterial: public Material {
00064 public:
00065
00066
00068 static const double EPS = 1.e-6;
00069 static const double PERT = 1.e-1;
00070 static const double DET_MIN = 1.e-10;
00071
00072 static const size_t MAT_SIZE = 9;
00073 static const size_t NDF = 3;
00074 static const size_t NDM = 3;
00075
00076 static const double I_MAT[MAT_SIZE];
00077
00081 enum ConstRespMode {
00082 COMPUTE_TANGENTS,
00083 SKIP_TANGENTS,
00084 };
00085
00087 inline SimpleMaterial(double rhoInput = 0) :
00088 RefRho(rhoInput) {
00089 }
00090
00091 virtual ~SimpleMaterial() {
00092 }
00093
00096 inline SimpleMaterial(const SimpleMaterial &SM) :
00097 RefRho(SM.RefRho) {
00098 }
00099
00100 virtual SimpleMaterial * clone() const = 0;
00101
00125 virtual bool getConstitutiveResponse(const std::vector<double>& strain, std::vector<double>& stress, std::vector<double>& tangents
00126 , const ConstRespMode& mode) const = 0;
00127
00129 double getDensityInReference() const {
00130 return RefRho;
00131 }
00132
00141 bool getLocalMaterialDensity(const std::vector<double> * strain, double &LocDensity) const {
00142 assert((*strain).size () == MAT_SIZE);
00143
00144
00145 double J = (*strain)[0] * ((*strain)[4] * (*strain)[8] - (*strain)[5] * (*strain)[7]) - (*strain)[1] * ((*strain)[3] * (*strain)[8]
00146 - (*strain)[5] * (*strain)[6]) + (*strain)[2] * ((*strain)[3] * (*strain)[7] - (*strain)[4] * (*strain)[6]);
00147
00148 if (fabs(J) < 1.e-10)
00149 return false;
00150 else {
00151 LocDensity = RefRho / J;
00152 return true;
00153 }
00154 }
00155
00157 virtual const std::string getMaterialName() const = 0;
00158
00162 static bool consistencyTest(const SimpleMaterial &Smat);
00163
00165 virtual double getSoundSpeed(void) const = 0;
00166 private:
00167 double RefRho;
00168 };
00169
00170
00171
00177 class NeoHookean: public SimpleMaterial {
00178
00185 struct NeoHookenTmpVec {
00186 static const size_t MAT_SIZE = SimpleMaterial::MAT_SIZE;
00187
00188 double F[MAT_SIZE];
00189 double Finv[MAT_SIZE];
00190 double C[MAT_SIZE];
00191 double Cinv[MAT_SIZE];
00192 double S[MAT_SIZE];
00193 double M[MAT_SIZE * MAT_SIZE];
00194
00195 };
00196
00200 static GaloisRuntime::PerCPU<NeoHookenTmpVec> perCPUtmpVec;
00201
00202 public:
00203 NeoHookean(double LambdaInput, double MuInput, double rhoInput = 0) :
00204 SimpleMaterial(rhoInput), Lambda(LambdaInput), Mu(MuInput) {
00205 }
00206 virtual ~NeoHookean() {
00207 }
00208 NeoHookean(const NeoHookean &NewMat) :
00209 SimpleMaterial(NewMat), Lambda(NewMat.Lambda), Mu(NewMat.Mu) {
00210 }
00211 virtual NeoHookean * clone() const {
00212 return new NeoHookean(*this);
00213 }
00214
00215 bool getConstitutiveResponse(const std::vector<double>& strain, std::vector<double>& stress, std::vector<double>& tangents
00216 , const ConstRespMode& mode) const;
00217
00218 const std::string getMaterialName() const {
00219 return "NeoHookean";
00220 }
00221
00222 double getSoundSpeed(void) const {
00223 return sqrt((Lambda + 2.0 * Mu) / getDensityInReference());
00224 }
00225 ;
00226
00227 private:
00228
00229 double Lambda;
00230 double Mu;
00231 };
00232
00242 class LinearElasticBase: public SimpleMaterial {
00243 public:
00244 LinearElasticBase(double irho = 0) :
00245 SimpleMaterial(irho) {
00246 }
00247 virtual ~LinearElasticBase() {
00248 }
00249 LinearElasticBase(const LinearElasticBase &NewMat) :
00250 SimpleMaterial(NewMat) {
00251 }
00252 virtual LinearElasticBase * clone() const = 0;
00253
00254 bool getConstitutiveResponse(const std::vector<double>& strain, std::vector<double>& stress, std::vector<double>& tangents
00255 , const ConstRespMode& mode) const;
00256
00257 const std::string getMaterialName() const {
00258 return "LinearElasticBase";
00259 }
00260
00261 protected:
00262 virtual const double getModuli(int i1, int i2, int i3, int i4) const = 0;
00263
00264 };
00265
00271 class IsotropicLinearElastic: public LinearElasticBase {
00272 public:
00273 static const int DELTA_MAT[][3];
00274
00275 IsotropicLinearElastic(double iLambda, double imu, double irho = 0) :
00276 LinearElasticBase(irho), lambda(iLambda), mu(imu) {
00277 }
00278 virtual ~IsotropicLinearElastic() {
00279 }
00280 IsotropicLinearElastic(const IsotropicLinearElastic &NewMat) :
00281 LinearElasticBase(NewMat), lambda(NewMat.lambda), mu(NewMat.mu) {
00282 }
00283 virtual IsotropicLinearElastic * clone() const {
00284 return new IsotropicLinearElastic(*this);
00285 }
00286
00287 const std::string getMaterialName() const {
00288 return "IsotropicLinearElastic";
00289 }
00290
00291 double getSoundSpeed(void) const {
00292 return sqrt((lambda + 2.0 * mu) / getDensityInReference());
00293 }
00294 ;
00295
00296 protected:
00297 const double getModuli(int i1, int i2, int i3, int i4) const {
00298 return lambda * DELTA_MAT[i1][i2] * DELTA_MAT[i3][i4] + mu * (DELTA_MAT[i1][i3] * DELTA_MAT[i2][i4] + DELTA_MAT[i1][i4] * DELTA_MAT[i2][i3]);
00299 }
00300
00301 private:
00302 double lambda;
00303 double mu;
00304 };
00305
00306
00307 #endif