19 constexpr int BIG_N = POLYFEM_BIG_N;
52 const std::function<
DScalar2<
double, Eigen::Matrix<double, Eigen::Dynamic, 1, 0, SMALL_N, 1>, Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, 0, SMALL_N, SMALL_N>>(
const assembler::NonLinearAssemblerData &)> &funN,
56 Eigen::MatrixXd
pk1_from_cauchy(
const Eigen::MatrixXd &stress,
const Eigen::MatrixXd &
F);
57 Eigen::MatrixXd
pk2_from_cauchy(
const Eigen::MatrixXd &stress,
const Eigen::MatrixXd &
F);
63 Eigen::Matrix2d
d_lambda_mu_d_E_nu(
const bool is_volume,
const double E,
const double nu);
64 Eigen::Matrix2d
d_E_nu_d_lambda_mu(
const bool is_volume,
const double lambda,
const double mu);
65 double convert_to_E(
const bool is_volume,
const double lambda,
const double mu);
66 double convert_to_nu(
const bool is_volume,
const double lambda,
const double mu);
70 template <
typename AutoDiffVect>
76 typedef typename AutoDiffVect::Scalar T;
78 assert(data.
x.cols() == 1);
80 Eigen::Matrix<double, Eigen::Dynamic, 1> local_dispv(data.
vals.
basis_values.size() * size, 1);
81 local_dispv.setZero();
85 for (
size_t ii = 0; ii < bs.global.size(); ++ii)
87 for (
int d = 0; d < size; ++d)
89 local_dispv(i * size + d) += bs.global[ii].val * data.
x(bs.global[ii].index * size + d);
95 local_disp.resize(local_dispv.rows(), 1);
99 for (
long i = 0; i < local_dispv.rows(); ++i)
101 local_disp(i) = allocate_auto_diff_scalar(i, local_dispv(i));
105 template <
typename AutoDiffVect,
typename AutoDiffGradMat>
109 const int p,
const int size,
112 typedef typename AutoDiffVect::Scalar T;
114 for (
long k = 0; k < def_grad.size(); ++k)
120 const Eigen::Matrix<double, Eigen::Dynamic, 1, 0, 3, 1> grad = bs.grad.row(p);
121 assert(grad.size() == size);
123 for (
int d = 0; d < size; ++d)
125 for (
int c = 0; c < size; ++c)
127 def_grad(d, c) += grad(c) * local_disp(i * size + d);
133 for (
long k = 0; k < jac_it.size(); ++k)
135 def_grad = def_grad * jac_it;
139 template <
typename AutoDiffGradMat>
145 template <
typename AutoDiffGradMat>
148 return 0.5 * (B.trace() * B.trace() - (B * B).trace());
151 template <
typename AutoDiffGradMat>
ElementAssemblyValues vals
stores per element basis values at given quadrature points and geometric mapping
std::vector< AssemblyValues > basis_values
std::vector< Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic, 0, 3, 3 > > jac_it
const ElementAssemblyValues & vals
const Eigen::MatrixXd & x
Stores the basis functions for a given element in a mesh (facet in 2d, cell in 3d).
Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic, 0, 3, 3 > AutoDiffGradMat
Eigen::Matrix< T, Eigen::Dynamic, 1 > AutoDiffVect
T determinant(const Eigen::Matrix< T, rows, cols, option, maxRow, maxCol > &mat)
Eigen::MatrixXd pk2_from_cauchy(const Eigen::MatrixXd &stress, const Eigen::MatrixXd &F)
void compute_disp_grad_at_quad(const assembler::NonLinearAssemblerData &data, const AutoDiffVect &local_disp, const int p, const int size, AutoDiffGradMat &def_grad)
AutoDiffGradMat::Scalar third_invariant(const AutoDiffGradMat &B)
Eigen::MatrixXd hessian_from_energy(const int size, const int n_bases, const assembler::NonLinearAssemblerData &data, const std::function< DScalar2< double, Eigen::Matrix< double, 6, 1 >, Eigen::Matrix< double, 6, 6 > >(const assembler::NonLinearAssemblerData &)> &fun6, const std::function< DScalar2< double, Eigen::Matrix< double, 8, 1 >, Eigen::Matrix< double, 8, 8 > >(const assembler::NonLinearAssemblerData &)> &fun8, const std::function< DScalar2< double, Eigen::Matrix< double, 12, 1 >, Eigen::Matrix< double, 12, 12 > >(const assembler::NonLinearAssemblerData &)> &fun12, const std::function< DScalar2< double, Eigen::Matrix< double, 18, 1 >, Eigen::Matrix< double, 18, 18 > >(const assembler::NonLinearAssemblerData &)> &fun18, const std::function< DScalar2< double, Eigen::Matrix< double, 24, 1 >, Eigen::Matrix< double, 24, 24 > >(const assembler::NonLinearAssemblerData &)> &fun24, const std::function< DScalar2< double, Eigen::Matrix< double, 30, 1 >, Eigen::Matrix< double, 30, 30 > >(const assembler::NonLinearAssemblerData &)> &fun30, const std::function< DScalar2< double, Eigen::Matrix< double, 60, 1 >, Eigen::Matrix< double, 60, 60 > >(const assembler::NonLinearAssemblerData &)> &fun60, const std::function< DScalar2< double, Eigen::Matrix< double, 81, 1 >, Eigen::Matrix< double, 81, 81 > >(const assembler::NonLinearAssemblerData &)> &fun81, const std::function< DScalar2< double, Eigen::Matrix< double, Eigen::Dynamic, 1, 0, SMALL_N, 1 >, Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic, 0, SMALL_N, SMALL_N > >(const assembler::NonLinearAssemblerData &)> &funN, const std::function< DScalar2< double, Eigen::VectorXd, Eigen::MatrixXd >(const assembler::NonLinearAssemblerData &)> &funn)
double convert_to_E(const bool is_volume, const double lambda, const double mu)
double convert_to_mu(const double E, const double nu)
AutoDiffGradMat::Scalar second_invariant(const AutoDiffGradMat &B)
double von_mises_stress_for_stress_tensor(const Eigen::MatrixXd &stress)
double convert_to_nu(const bool is_volume, const double lambda, const double mu)
void compute_diplacement_grad(const int size, const ElementAssemblyValues &vals, const Eigen::MatrixXd &local_pts, const int p, const Eigen::MatrixXd &displacement, Eigen::MatrixXd &displacement_grad)
AutoDiffGradMat::Scalar first_invariant(const AutoDiffGradMat &B)
void get_local_disp(const assembler::NonLinearAssemblerData &data, const int size, AutoDiffVect &local_disp)
Eigen::MatrixXd pk1_from_cauchy(const Eigen::MatrixXd &stress, const Eigen::MatrixXd &F)
Eigen::VectorXd gradient_from_energy(const int size, const int n_bases, const assembler::NonLinearAssemblerData &data, const std::function< DScalar1< double, Eigen::Matrix< double, 6, 1 > >(const assembler::NonLinearAssemblerData &)> &fun6, const std::function< DScalar1< double, Eigen::Matrix< double, 8, 1 > >(const assembler::NonLinearAssemblerData &)> &fun8, const std::function< DScalar1< double, Eigen::Matrix< double, 12, 1 > >(const assembler::NonLinearAssemblerData &)> &fun12, const std::function< DScalar1< double, Eigen::Matrix< double, 18, 1 > >(const assembler::NonLinearAssemblerData &)> &fun18, const std::function< DScalar1< double, Eigen::Matrix< double, 24, 1 > >(const assembler::NonLinearAssemblerData &)> &fun24, const std::function< DScalar1< double, Eigen::Matrix< double, 30, 1 > >(const assembler::NonLinearAssemblerData &)> &fun30, const std::function< DScalar1< double, Eigen::Matrix< double, 60, 1 > >(const assembler::NonLinearAssemblerData &)> &fun60, const std::function< DScalar1< double, Eigen::Matrix< double, 81, 1 > >(const assembler::NonLinearAssemblerData &)> &fun81, const std::function< DScalar1< double, Eigen::Matrix< double, Eigen::Dynamic, 1, 0, SMALL_N, 1 > >(const assembler::NonLinearAssemblerData &)> &funN, const std::function< DScalar1< double, Eigen::Matrix< double, Eigen::Dynamic, 1, 0, BIG_N, 1 > >(const assembler::NonLinearAssemblerData &)> &funBigN, const std::function< DScalar1< double, Eigen::VectorXd >(const assembler::NonLinearAssemblerData &)> &funn)
double convert_to_lambda(const bool is_volume, const double E, const double nu)
Eigen::Matrix2d d_E_nu_d_lambda_mu(const bool is_volume, const double lambda, const double mu)
Eigen::Matrix2d d_lambda_mu_d_E_nu(const bool is_volume, const double E, const double nu)
std::array< double, 2 > DampingParameters
Automatic differentiation scalar with first-order derivatives.
Automatic differentiation scalar with first- and second-order derivatives.
static void setVariableCount(size_t value)
Set the independent variable count used by the automatic differentiation layer.