PolyFEM
Loading...
Searching...
No Matches
AssemblyValsCache.cpp
Go to the documentation of this file.
2
4
5namespace polyfem
6{
7 using namespace basis;
8
9 namespace assembler
10 {
11 void AssemblyValsCache::init(const bool is_volume, const std::vector<ElementBases> &bases, const std::vector<ElementBases> &gbases, const bool is_mass)
12 {
14 const int n_bases = bases.size();
15 cache.resize(n_bases);
16
17 // loop over elements
18 utils::maybe_parallel_for(n_bases, [&](int start, int end, int thread_id) {
19 for (int e = start; e < end; ++e)
20 {
21 if (is_mass_)
22 {
23 auto &quadrature = cache[e].quadrature;
24 bases[e].compute_mass_quadrature(quadrature);
25 cache[e].compute(e, is_volume, quadrature.points, bases[e], gbases[e]);
26 }
27 else
28 cache[e].compute(e, is_volume, bases[e], gbases[e]);
29 }
30 });
31 }
32
33 void AssemblyValsCache::compute(const int el_index, const bool is_volume, const ElementBases &basis, const ElementBases &gbasis, ElementAssemblyValues &vals) const
34 {
35 if (cache.empty())
36 {
37 if (is_mass_)
38 {
39 auto &quadrature = vals.quadrature;
41 vals.compute(el_index, is_volume, quadrature.points, basis, gbasis);
42 }
43 else
44 vals.compute(el_index, is_volume, basis, gbasis);
45 }
46 else
47 vals = cache[el_index];
48 }
49 } // namespace assembler
50
51} // namespace polyfem
ElementAssemblyValues vals
Definition Assembler.cpp:22
Quadrature quadrature
void init(const bool is_volume, const std::vector< basis::ElementBases > &bases, const std::vector< basis::ElementBases > &gbases, const bool is_mass=false)
computes the basis evaluation and geometric mapping for each of the given ElementBases in bases initi...
std::vector< ElementAssemblyValues > cache
vector of basis values and geometric mapping with one entry per 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
Stores the basis functions for a given element in a mesh (facet in 2d, cell in 3d).
void compute_mass_quadrature(quadrature::Quadrature &quadrature) const
void maybe_parallel_for(int size, const std::function< void(int, int, int)> &partial_for)