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::update(const int e, const bool is_volume, const basis::ElementBases &basis, const basis::ElementBases &gbasis)
34 {
35 if (is_mass_)
36 {
37 auto &quadrature = cache[e].quadrature;
39 cache[e].compute(e, is_volume, quadrature.points, basis, gbasis);
40 }
41 else
42 cache[e].compute(e, is_volume, basis, gbasis);
43 }
44
45 void AssemblyValsCache::compute(const int el_index, const bool is_volume, const ElementBases &basis, const ElementBases &gbasis, ElementAssemblyValues &vals) const
46 {
47 if (cache.empty())
48 {
49 if (is_mass_)
50 {
51 auto &quadrature = vals.quadrature;
53 vals.compute(el_index, is_volume, quadrature.points, basis, gbasis);
54 }
55 else
56 vals.compute(el_index, is_volume, basis, gbasis);
57 }
58 else
59 vals = cache[el_index];
60 }
61 } // namespace assembler
62
63} // 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 update(const int el_index, const bool is_volume, const basis::ElementBases &basis, const basis::ElementBases &gbasis)
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)