28 const int n_psi_basis,
29 const int n_phi_basis,
30 const std::vector<basis::ElementBases> &psi_bases,
31 const std::vector<basis::ElementBases> &phi_bases,
32 const std::vector<basis::ElementBases> &gbases,
38 virtual std::string
name()
const = 0;
46 virtual int rows()
const = 0;
47 virtual int cols()
const = 0;
61 virtual std::string
name()
const = 0;
71 const std::vector<basis::ElementBases> &bases,
72 const std::vector<basis::ElementBases> &gbases,
81 const std::vector<basis::ElementBases> &bases,
82 const std::vector<basis::ElementBases> &gbases,
86 const Eigen::MatrixXd &displacement,
87 const Eigen::MatrixXd &displacement_prev)
const {
log_and_throw_error(
"Assemble energy not implemented by {}!",
name()); }
91 const std::vector<basis::ElementBases> &bases,
92 const std::vector<basis::ElementBases> &gbases,
96 const Eigen::MatrixXd &displacement,
97 const Eigen::MatrixXd &displacement_prev)
const {
log_and_throw_error(
"Assemble energy not implemented by {}!",
name()); }
101 const bool is_volume,
103 const std::vector<basis::ElementBases> &bases,
104 const std::vector<basis::ElementBases> &gbases,
108 const Eigen::MatrixXd &displacement,
109 const Eigen::MatrixXd &displacement_prev,
114 const bool is_volume,
116 const bool project_to_psd,
117 const std::vector<basis::ElementBases> &bases,
118 const std::vector<basis::ElementBases> &gbases,
122 const Eigen::MatrixXd &displacement,
123 const Eigen::MatrixXd &displacement_prev,
130 std::vector<NamedMatrix> &result)
const {}
135 std::vector<NamedMatrix> &result)
const
143 const Eigen::MatrixXd &local_pts,
144 const Eigen::MatrixXd &displacement,
149 Eigen::MatrixXd &dstress_dmu,
154 const Eigen::MatrixXd &mat,
155 Eigen::MatrixXd &stress,
160 Eigen::MatrixXd &stress,
161 Eigen::MatrixXd &result)
const
163 Eigen::MatrixXd unused;
170 const Eigen::MatrixXd &vect,
171 Eigen::MatrixXd &stress,
176 const Eigen::MatrixXd &prev_grad_u_i,
177 Eigen::MatrixXd &stress,
181 const Eigen::MatrixXd &prev_grad_u_i,
184 virtual std::map<std::string, ParamFunc>
parameters()
const = 0;
221 const bool is_volume,
223 const std::vector<basis::ElementBases> &bases,
224 const std::vector<basis::ElementBases> &gbases,
228 const bool is_mass =
false)
const override;
230 virtual bool is_linear()
const override {
return true; }
245 const bool is_volume,
246 const std::vector<basis::ElementBases> &bases,
247 const std::vector<basis::ElementBases> &gbases,
251 const Eigen::MatrixXd &displacement,
252 const Eigen::MatrixXd &displacement_prev)
const override;
256 const bool is_volume,
257 const std::vector<basis::ElementBases> &bases,
258 const std::vector<basis::ElementBases> &gbases,
262 const Eigen::MatrixXd &displacement,
263 const Eigen::MatrixXd &displacement_prev)
const override;
267 const bool is_volume,
269 const std::vector<basis::ElementBases> &bases,
270 const std::vector<basis::ElementBases> &gbases,
274 const Eigen::MatrixXd &displacement,
275 const Eigen::MatrixXd &displacement_prev,
276 Eigen::MatrixXd &rhs)
const override;
280 const bool is_volume,
282 const bool project_to_psd,
283 const std::vector<basis::ElementBases> &bases,
284 const std::vector<basis::ElementBases> &gbases,
288 const Eigen::MatrixXd &displacement,
289 const Eigen::MatrixXd &displacement_prev,
293 virtual bool is_linear()
const override {
return false; }
313 std::vector<NamedMatrix> &result)
const override
318 result.emplace_back(
"von_mises", tmp);
324 std::vector<NamedMatrix> &result)
const override
327 Eigen::MatrixXd cauchy, pk1, pk2,
F;
334 result.emplace_back(
"cauchy_stess", cauchy);
335 result.emplace_back(
"pk1_stess", pk1);
336 result.emplace_back(
"pk2_stess", pk2);
337 result.emplace_back(
"F",
F);
342 Eigen::MatrixXd &stresses)
const
345 Eigen::MatrixXd tmp = stress;
346 auto a = Eigen::Map<Eigen::MatrixXd>(tmp.data(), 1,
size() *
size());
347 return Eigen::MatrixXd(a);
352 Eigen::MatrixXd &stresses)
const
355 Eigen::Matrix<double, 1, 1> res;
371 Eigen::MatrixXd &all,
372 const std::function<Eigen::MatrixXd(
const Eigen::MatrixXd &)> &fun)
const = 0;
std::unique_ptr< MatrixCache > cache
ElementAssemblyValues vals
virtual void compute_stress_grad_multiply_stress(const OptAssemblerData &data, Eigen::MatrixXd &stress, Eigen::MatrixXd &result) const
virtual void assemble(const bool is_volume, const int n_basis, const std::vector< basis::ElementBases > &bases, const std::vector< basis::ElementBases > &gbases, const AssemblyValsCache &cache, const double t, StiffnessMatrix &stiffness, const bool is_mass=false) const
void set_materials(const std::vector< int > &body_ids, const json &body_params, const Units &units)
virtual void compute_stiffness_value(const double t, const assembler::ElementAssemblyValues &vals, const Eigen::MatrixXd &local_pts, const Eigen::MatrixXd &displacement, Eigen::MatrixXd &tensor) const
std::pair< std::string, Eigen::MatrixXd > NamedMatrix
virtual ~Assembler()=default
virtual void compute_dstress_dmu_dlambda(const OptAssemblerData &data, Eigen::MatrixXd &dstress_dmu, Eigen::MatrixXd &dstress_dlambda) const
virtual void compute_stress_grad_multiply_vect(const OptAssemblerData &data, const Eigen::MatrixXd &vect, Eigen::MatrixXd &stress, Eigen::MatrixXd &result) const
virtual bool is_solution_displacement() const
virtual void update_lame_params(const Eigen::MatrixXd &lambdas, const Eigen::MatrixXd &mus)
virtual void compute_stress_grad_multiply_mat(const OptAssemblerData &data, const Eigen::MatrixXd &mat, Eigen::MatrixXd &stress, Eigen::MatrixXd &result) const
virtual Eigen::Matrix< AutodiffScalarGrad, Eigen::Dynamic, 1, 0, 3, 1 > kernel(const int dim, const AutodiffGradPt &rvect, const AutodiffScalarGrad &r) const
virtual bool is_tensor() const
std::function< double(const RowVectorNd &, const RowVectorNd &, double, int)> ParamFunc
virtual std::string name() const =0
virtual Eigen::VectorXd assemble_energy_per_element(const bool is_volume, const std::vector< basis::ElementBases > &bases, const std::vector< basis::ElementBases > &gbases, const AssemblyValsCache &cache, const double t, const double dt, const Eigen::MatrixXd &displacement, const Eigen::MatrixXd &displacement_prev) const
virtual void assemble_gradient(const bool is_volume, const int n_basis, const std::vector< basis::ElementBases > &bases, const std::vector< basis::ElementBases > &gbases, const AssemblyValsCache &cache, const double t, const double dt, const Eigen::MatrixXd &displacement, const Eigen::MatrixXd &displacement_prev, Eigen::MatrixXd &rhs) const
virtual void compute_stress_grad(const OptAssemblerData &data, const Eigen::MatrixXd &prev_grad_u_i, Eigen::MatrixXd &stress, Eigen::MatrixXd &result) const
virtual void set_size(const int size)
virtual void compute_scalar_value(const OutputData &data, std::vector< NamedMatrix > &result) const
virtual void assemble_hessian(const bool is_volume, const int n_basis, const bool project_to_psd, const std::vector< basis::ElementBases > &bases, const std::vector< basis::ElementBases > &gbases, const AssemblyValsCache &cache, const double t, const double dt, const Eigen::MatrixXd &displacement, const Eigen::MatrixXd &displacement_prev, utils::MatrixCache &mat_cache, StiffnessMatrix &grad) const
virtual std::map< std::string, ParamFunc > parameters() const =0
virtual VectorNd compute_rhs(const AutodiffHessianPt &pt) const
virtual double assemble_energy(const bool is_volume, const std::vector< basis::ElementBases > &bases, const std::vector< basis::ElementBases > &gbases, const AssemblyValsCache &cache, const double t, const double dt, const Eigen::MatrixXd &displacement, const Eigen::MatrixXd &displacement_prev) const
virtual bool is_fluid() const
virtual bool is_linear() const =0
virtual void compute_tensor_value(const OutputData &data, std::vector< NamedMatrix > &result) const
virtual void add_multimaterial(const int index, const json ¶ms, const Units &units)
virtual void compute_stress_prev_grad(const OptAssemblerData &data, const Eigen::MatrixXd &prev_grad_u_i, Eigen::MatrixXd &result) const
Caches basis evaluation and geometric mapping at every element.
bool is_tensor() const override
virtual ~ElasticityAssembler()=default
void compute_von_mises_stresses(const OutputData &data, Eigen::MatrixXd &stresses) const
void compute_scalar_value(const OutputData &data, std::vector< NamedMatrix > &result) const override
bool is_solution_displacement() const override
void compute_tensor_value(const OutputData &data, std::vector< NamedMatrix > &result) const override
void set_use_robust_jacobian()
void compute_stress_tensor(const OutputData &data, const ElasticityTensorType &type, Eigen::MatrixXd &stresses) const
virtual void assign_stress_tensor(const OutputData &data, const int all_size, const ElasticityTensorType &type, Eigen::MatrixXd &all, const std::function< Eigen::MatrixXd(const Eigen::MatrixXd &)> &fun) const =0
virtual bool allow_inversion() const =0
stores per element basis values at given quadrature points and geometric mapping
assemble matrix based on the local assembler local assembler is eg Laplace, LinearElasticity etc
virtual Eigen::Matrix< double, Eigen::Dynamic, 1, 0, 9, 1 > assemble(const LinearAssemblerData &data) const =0
local assembly function that defines the bilinear form (LHS) computes and returns a single local stif...
void assemble(const bool is_volume, const int n_basis, const std::vector< basis::ElementBases > &bases, const std::vector< basis::ElementBases > &gbases, const AssemblyValsCache &cache, const double t, StiffnessMatrix &stiffness, const bool is_mass=false) const override
assembles the stiffness matrix for the given basis the bilinear form (local assembler) is encoded by ...
virtual ~LinearAssembler()=default
virtual bool is_linear() const override
virtual int rows() const =0
virtual void set_size(const int size)
virtual Eigen::Matrix< double, Eigen::Dynamic, 1, 0, 3, 1 > assemble(const MixedAssemblerData &data) const =0
virtual ~MixedAssembler()=default
void assemble(const bool is_volume, const int n_psi_basis, const int n_phi_basis, const std::vector< basis::ElementBases > &psi_bases, const std::vector< basis::ElementBases > &phi_bases, const std::vector< basis::ElementBases > &gbases, const AssemblyValsCache &psi_cache, const AssemblyValsCache &phi_cache, const double t, StiffnessMatrix &stiffness) const
virtual int cols() const =0
virtual std::string name() const =0
virtual bool is_linear() const override
double assemble_energy(const bool is_volume, const std::vector< basis::ElementBases > &bases, const std::vector< basis::ElementBases > &gbases, const AssemblyValsCache &cache, const double t, const double dt, const Eigen::MatrixXd &displacement, const Eigen::MatrixXd &displacement_prev) const override
Eigen::VectorXd assemble_energy_per_element(const bool is_volume, const std::vector< basis::ElementBases > &bases, const std::vector< basis::ElementBases > &gbases, const AssemblyValsCache &cache, const double t, const double dt, const Eigen::MatrixXd &displacement, const Eigen::MatrixXd &displacement_prev) const override
virtual double compute_energy(const NonLinearAssemblerData &data) const =0
virtual ~NLAssembler()=default
void assemble_gradient(const bool is_volume, const int n_basis, const std::vector< basis::ElementBases > &bases, const std::vector< basis::ElementBases > &gbases, const AssemblyValsCache &cache, const double t, const double dt, const Eigen::MatrixXd &displacement, const Eigen::MatrixXd &displacement_prev, Eigen::MatrixXd &rhs) const override
void assemble_hessian(const bool is_volume, const int n_basis, const bool project_to_psd, const std::vector< basis::ElementBases > &bases, const std::vector< basis::ElementBases > &gbases, const AssemblyValsCache &cache, const double t, const double dt, const Eigen::MatrixXd &displacement, const Eigen::MatrixXd &displacement_prev, utils::MatrixCache &mat_cache, StiffnessMatrix &grad) const override
virtual Eigen::VectorXd assemble_gradient(const NonLinearAssemblerData &data) const =0
virtual Eigen::MatrixXd assemble_hessian(const NonLinearAssemblerData &data) const =0
const Eigen::MatrixXd & grad_u_i
abstract class used for caching
Eigen::Matrix< AutodiffScalarHessian, Eigen::Dynamic, 1, 0, 3, 1 > AutodiffHessianPt
Eigen::Matrix< double, Eigen::Dynamic, 1, 0, 3, 1 > VectorNd
void log_and_throw_adjoint_error(const std::string &msg)
double von_mises_stress_for_stress_tensor(const Eigen::MatrixXd &stress)
Eigen::Matrix< double, 1, Eigen::Dynamic, Eigen::RowMajor, 1, 3 > RowVectorNd
void log_and_throw_error(const std::string &msg)
Eigen::Matrix< AutodiffScalarGrad, Eigen::Dynamic, 1, 0, 3, 1 > AutodiffGradPt
Eigen::SparseMatrix< double, Eigen::ColMajor > StiffnessMatrix
Automatic differentiation scalar with first-order derivatives.