19 #ifndef FIELD_VALUE_CACHE_HH_ 20 #define FIELD_VALUE_CACHE_HH_ 23 #include <unordered_map> 24 #include <unordered_set> 42 template<
class elm_type>
52 void init(std::shared_ptr<EvalPoints> eval_points,
unsigned int n_cache_elements);
55 inline unsigned int size()
const {
72 template<u
int nr, u
int nc = 1>
73 typename arma::Mat<elm_type>::template fixed<nr, nc> &
get(
uint i) {
74 return data_.template mat<nr, nc>(i);
116 static constexpr
unsigned int n_cached_elements = 20;
137 if (std::find(elm_indices_.begin(), elm_indices_.begin()+n_elements_, elm.
idx()) == elm_indices_.begin()+n_elements_) {
138 elm_indices_[n_elements_] = elm.
idx();
146 std::array<unsigned int, ElementCacheMap::n_cached_elements>
elm_indices_;
191 void init(std::shared_ptr<EvalPoints> eval_points);
200 void prepare_elements_to_update();
203 void create_elements_points_map();
206 void start_elements_update();
209 void finish_elements_update();
234 void mark_used_eval_points(
const DHCellAccessor &dh_cell,
unsigned int subset_idx,
unsigned int data_size,
unsigned int start_point=0);
239 return element_eval_points_map_[elm_idx][loc_point_idx];
244 return elm_idx_[pos];
252 static const int unused_point = -2;
255 static const int point_in_proggress = -1;
258 void clear_element_eval_points_map();
UpdateCacheHelper update_data_
Holds data used for cache update.
unsigned int n_elements_
Number of element indices.
unsigned int size() const
bool ready_to_reading_
Flag is set down during update of cache when this can't be read.
Value::return_type get_value(const ElementCacheMap &map, const DHCellAccessor &dh_cell, unsigned int eval_points_idx)
Return value of evaluation point given by DHCell and local point idx in EvalPoints.
const UpdateCacheHelper & update_cache_data() const
Return update cache data helper.
FieldValueCache(unsigned int n_rows, unsigned int n_cols)
Constructor.
Directing class of FieldValueCache.
Cell accessor allow iterate over DOF handler cells.
bool add(ElementAccessor< 3 > elm)
Add element if does not exist.
Armor::Array< elm_type > & data()
Class holds precomputed field values of selected element set.
std::array< unsigned int, ElementCacheMap::n_cached_elements+1 > region_value_cache_range_
Maps of begin and end positions of different regions data in FieldValueCache.
unsigned int size() const
Return size of data cache (number of stored field values)
unsigned int n_elements_
Number of elements in all regions holds in cache.
const Armor::Array< elm_type > & data() const
Return data vector.
static const unsigned int undef_elem_idx
Index of invalid element in cache.
std::unordered_map< unsigned int, unsigned int > region_cache_indices_range_
int ** element_eval_points_map_
Armor::Array< elm_type > data_
std::unordered_map< unsigned int, unsigned int > cache_idx_
unsigned int elm_idx_on_position(unsigned pos) const
Return idx of element stored at given position of ElementCacheMap.
int get_field_value_cache_index(unsigned int elm_idx, unsigned int loc_point_idx) const
Return index of point in FieldValueCache.
~FieldValueCache()
Destructor.
unsigned int n_cache_points_
Maximal number of points stored in cache.
std::array< unsigned int, ElementCacheMap::n_cached_elements+1 > region_element_cache_range_
Maps of begin and end positions of elements of different regions in ElementCacheMap.
std::vector< unsigned int > elm_idx_
Class holds local coordinations of evaluating points (bulk and sides) specified by element dimension...
unsigned int points_in_cache_
Number of points stored in cache.
unsigned int n_cache_points() const
Return number of elements that data is stored in cache.
std::shared_ptr< EvalPoints > eval_points_
Pointer to EvalPoints.
std::shared_ptr< EvalPoints > eval_points() const
Getter of eval_points object.
UpdateCacheHelper & update_cache_data()
Return update cache data helper.
std::array< unsigned int, ElementCacheMap::n_cached_elements > elm_indices_
Array of elements idx, ensures element uniqueness.
#define ASSERT_PTR_DBG(ptr)
Definition of assert macro checking non-null pointer (PTR) only for debug mode.
unsigned int idx() const
Return local idx of element in boundary / bulk part of element vector.
std::unordered_map< unsigned int, RegionData > region_cache_indices_map_
void init(std::shared_ptr< EvalPoints > eval_points, unsigned int n_cache_elements)
Initialize cache.
Side accessor allows to iterate over sides of DOF handler cell.