17 class LocalThreadVecStorage
21 assembler::ElementAssemblyValues
vals;
24 LocalThreadVecStorage(
const int size)
31 double dot(
const Eigen::MatrixXd &A,
const Eigen::MatrixXd &B) {
return (A.array() * B.array()).sum(); }
36 : mass_(mass), time_integrator_(time_integrator)
38 assert(mass.size() != 0);
45 const double prod = tmp.transpose() *
mass_ * tmp;
46 const double energy = 0.5 * prod;
62 const int n_geom_bases,
64 const std::vector<basis::ElementBases> &bases,
65 const std::vector<basis::ElementBases> &geom_bases,
68 const Eigen::MatrixXd &velocity,
69 const Eigen::MatrixXd &adjoint,
70 Eigen::VectorXd &term)
72 const int dim = is_volume ? 3 : 2;
73 const int n_elements = int(bases.size());
74 term.setZero(n_geom_bases * dim, 1);
81 for (
int e = start; e < end; ++e)
84 ass_vals_cache.
compute(e, is_volume, bases[e], geom_bases[e],
vals);
86 gvals.
compute(e, is_volume,
vals.quadrature.points, geom_bases[e], geom_bases[e]);
91 Eigen::MatrixXd vel, grad_vel, p, grad_p;
95 for (
int q = 0; q < local_storage.da.size(); ++q)
98 const double value = rho * dot(p.row(q), vel.row(q)) * local_storage.da(q);
99 for (
const auto &v :
gvals.basis_values)
101 local_storage.vec.block(v.global[0].index * dim, 0, dim, 1) += v.grad_t_m.row(q).transpose() *
value;
107 for (
const LocalThreadVecStorage &local_storage : storage)
108 term += local_storage.vec;
ElementAssemblyValues vals
assembler::ElementAssemblyValues gvals
Caches basis evaluation and geometric mapping at every element.
void compute(const int el_index, const bool is_volume, const basis::ElementBases &basis, const basis::ElementBases &gbasis, ElementAssemblyValues &vals) const
retrieves cached basis evaluation and geometric for the given element if it doesn't exist,...
stores per element basis values at given quadrature points and geometric mapping
void compute(const int el_index, const bool is_volume, const Eigen::MatrixXd &pts, const basis::ElementBases &basis, const basis::ElementBases &gbasis)
computes the per element values at the local (ref el) points (pts) sets basis_values,...
const Density & density() const
class that stores and compute density per point
static void interpolate_at_local_vals(const mesh::Mesh &mesh, const bool is_problem_scalar, const std::vector< basis::ElementBases > &bases, const std::vector< basis::ElementBases > &gbases, const int el_index, const Eigen::MatrixXd &local_pts, const Eigen::MatrixXd &fun, Eigen::MatrixXd &result, Eigen::MatrixXd &result_grad)
interpolate solution and gradient at element (calls interpolate_at_local_vals with sol)
Implicit time integrator of a second order ODE (equivently a system of coupled first order ODEs).
virtual Eigen::VectorXd x_tilde() const =0
Compute the predicted solution to be used in the inertia term .
auto & get_local_thread_storage(Storages &storage, int thread_id)
auto create_thread_storage(const LocalStorage &initial_local_storage)
void maybe_parallel_for(int size, const std::function< void(int, int, int)> &partial_for)
Eigen::Matrix< double, Eigen::Dynamic, 1, 0, MAX_QUAD_POINTS, 1 > QuadratureVector
Eigen::SparseMatrix< double, Eigen::ColMajor > StiffnessMatrix