12 return (E * nu) / ((1.0 + nu) * (1.0 - 2.0 * nu));
14 return (nu * E) / (1.0 - nu * nu);
19 return E / (2.0 * (1.0 + nu));
24 : param_name_(param_name)
30 for (
int i =
param_.size(); i <= index; ++i)
38 param_[index].set_unit_type(unit_type);
44 const double x = p(0);
45 const double y = p(1);
46 const double z = p.size() == 3 ? p(2) : 0;
48 return (*
this)(
x,
y,
z, t, index);
57 return tmp_param(
x,
y,
z, t, index);
61 : param_name_(param_name)
74 for (
int i = 0; i < params_array.size(); ++i)
77 for (
int i = 0; i <
params_.size(); ++i)
79 for (
int j =
params_.at(i).param_.size(); j <= index; ++j)
81 params_.at(i).param_.emplace_back();
84 params_.at(i).param_[index].init(params_array[i]);
85 params_.at(i).param_[index].set_unit_type(unit_type);
201 (*this)(0, 0) = 2 * mu + lambda;
202 (*this)(0, 1) = lambda;
205 (*this)(1, 1) = 2 * mu + lambda;
212 (*this)(0, 0) = 2 * mu + lambda;
213 (*this)(0, 1) = lambda;
214 (*this)(0, 2) = lambda;
219 (*this)(1, 1) = 2 * mu + lambda;
220 (*this)(1, 2) = lambda;
225 (*this)(2, 2) = 2 * mu + lambda;
247 0.0, 0.0, (1.0 - nu) / 2.0;
255 v, 1. - v, v, 0, 0, 0,
256 v, v, 1. - v, 0, 0, 0,
257 0, 0, 0, (1. - 2. * v) / 2., 0, 0,
258 0, 0, 0, 0, (1. - 2. * v) / 2., 0,
259 0, 0, 0, 0, 0, (1. - 2. * v) / 2.;
265 double Ex,
double Ey,
double Ez,
266 double nuXY,
double nuXZ,
double nuYZ,
267 double muYZ,
double muZX,
double muXY,
const std::string &stress_units)
272 double nuYX = nuXY * Ey / Ex;
273 double nuZX = nuXZ * Ez / Ex;
274 double nuZY = nuYZ * Ez / Ey;
276 Eigen::MatrixXd compliance;
277 compliance.setZero(6, 6);
278 compliance << 1 / Ex, -nuYX / Ey, -nuZX / Ez, 0, 0, 0,
279 -nuXY / Ex, 1 / Ey, -nuZY / Ez, 0, 0, 0,
280 -nuXZ / Ex, -nuYZ / Ey, 1 / Ez, 0, 0, 0,
281 0, 0, 0, 1 / (2 * muYZ), 0, 0,
282 0, 0, 0, 0, 1 / (2 * muZX), 0,
283 0, 0, 0, 0, 0, 1 / (2 * muXY);
292 double nuYX = nuXY * Ey / Ex;
294 Eigen::MatrixXd compliance;
295 compliance.setZero(3, 3);
296 compliance << 1.0 / Ex, -nuYX / Ey, 0.0,
297 -nuXY / Ex, 1.0 / Ey, 0.0,
298 0.0, 0.0, 1.0 / (2 * muXY);
307 for (
int k = 0; k < DIM; ++k)
308 res += (*
this)(j, k) * strain[k];
333 double llambda = tmp1(
x,
y,
z, t, el_id);
334 double mmu = tmp2(
x,
y,
z, t, el_id);
353 assert(!std::isnan(lambda));
354 assert(!std::isnan(mu));
355 assert(!std::isinf(lambda));
356 assert(!std::isinf(mu));
361 const int size = is_volume ? 3 : 2;
371 if (params.count(
"young"))
373 set_e_nu(index, params[
"young"], params[
"nu"], stress_unit);
375 else if (params.count(
"E"))
377 set_e_nu(index, params[
"E"], params[
"nu"], stress_unit);
379 else if (params.count(
"lambda"))
385 mu_or_nu_[index].set_unit_type(stress_unit);
405 rho_.back().init(1.0);
410 assert(
rho_.size() == 1 || el_id <
rho_.size());
412 const auto &tmp =
rho_.size() == 1 ?
rho_[0] :
rho_[el_id];
413 const double res = tmp(
x,
y,
z, t, el_id);
414 assert(!std::isnan(res));
415 assert(!std::isinf(res));
421 for (
int i =
rho_.size(); i <= index; ++i)
426 if (params.count(
"rho"))
428 rho_[index].init(params[
"rho"]);
430 else if (params.count(
"density"))
432 rho_[index].init(params[
"density"]);
435 rho_[index].set_unit_type(density_unit);
439 template double ElasticityTensor::compute_stress<3>(
const std::array<double, 3> &strain,
const int j)
const;
440 template double ElasticityTensor::compute_stress<6>(
const std::array<double, 6> &strain,
const int j)
const;
std::vector< Eigen::Triplet< double > > entries
std::vector< utils::ExpressionValue > rho_
virtual void add_multimaterial(const int index, const json ¶ms, const std::string &density_unit)
virtual double operator()(double px, double py, double pz, double x, double y, double z, double t, int el_id) const
double operator()(int i, int j) const
void resize(const int size)
void set_from_entries(const std::vector< double > &entries, const std::string &stress_unit)
void set_from_young_poisson(const double young, const double poisson, const std::string &stress_unit)
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic, 0, 6, 6 > stifness_tensor_
void set_orthotropic(double Ex, double Ey, double Ez, double nuXY, double nuXZ, double nuYZ, double muYZ, double muZX, double muXY, const std::string &stress_unit)
double compute_stress(const std::array< double, DIM > &strain, const int j) const
void set_from_lambda_mu(const double lambda, const double mu, const std::string &stress_unit)
void add_multimaterial(const int index, const json ¶ms, const std::string &unit_type)
double operator()(const RowVectorNd &p, double t, int index) const
GenericMatParam(const std::string ¶m_name)
std::vector< utils::ExpressionValue > param_
const std::string param_name_
void add_multimaterial(const int index, const json ¶ms, const std::string &unit_type)
std::vector< GenericMatParam > params_
GenericMatParams(const std::string ¶m_name)
const std::string param_name_
std::vector< utils::ExpressionValue > mu_or_nu_
void lambda_mu(double px, double py, double pz, double x, double y, double z, double t, int el_id, double &lambda, double &mu) const
void set_e_nu(const int index, const json &E, const json &nu, const std::string &stress_unit)
std::vector< utils::ExpressionValue > lambda_or_E_
void add_multimaterial(const int index, const json ¶ms, const bool is_volume, const std::string &stress_unit)
Eigen::MatrixXd lambda_mat_
std::vector< T > json_as_array(const json &j)
Return the value of a json object as an array.
double convert_to_mu(const double E, const double nu)
Eigen::Matrix< double, 1, Eigen::Dynamic, Eigen::RowMajor, 1, 3 > RowVectorNd
double convert_to_lambda(const bool is_volume, const double E, const double nu)