19 #ifndef FIELD_VALUE_CACHE_HH_ 20 #define FIELD_VALUE_CACHE_HH_ 23 #include <unordered_map> 24 #include <unordered_set> 56 EvalPointData(
unsigned int i_reg,
unsigned int i_ele,
unsigned int i_ep,
unsigned int dh_loc_idx)
85 : i_elm_(i_elm), i_ep_(i_ep) {}
101 static unsigned int get() {
106 static void set(
unsigned int n_elem) {
107 get_instance().n_elem_ = n_elem;
157 void init(std::shared_ptr<EvalPoints> eval_points);
165 unsigned int last_element_idx = -1, i_elem_row = -1;
166 for (
unsigned int i=0; i<eval_point_data_.permanent_size(); ++i) {
167 if (eval_point_data_[i].
i_element_ != last_element_idx) {
169 last_element_idx =eval_point_data_[i].i_element_;
173 eval_point_data_.reset();
177 void start_elements_update();
180 void finish_elements_update();
196 return element_eval_points_map_[i_elem_in_cache*eval_points_->max_size()+i_eval_point];
201 return elm_idx_[pos];
206 std::unordered_map<unsigned int, unsigned int>::const_iterator
it = element_to_map_.find(mesh_elm_idx);
207 if ( it != element_to_map_.end() )
return it->second;
213 return regions_starts_.permanent_size() - 1;
218 return element_starts_.permanent_size() - 1;
224 return element_starts_[elm_patch_idx];
230 return element_starts_[elm_patch_idx+1];
236 return element_starts_[ regions_starts_[region_patch_idx] ];
242 return element_starts_[ regions_starts_[region_patch_idx+1] ];
247 if (r_idx <= n_regions())
return element_starts_[ regions_starts_[r_idx] ];
253 return eval_point_data_[ this->region_chunk_by_map_index(chunk_pos) ].i_reg_;
258 return eval_point_data_[point_idx];
262 template<
class Value>
264 unsigned int elem_patch_idx,
unsigned int eval_points_idx)
const {
267 unsigned int value_cache_idx = this->element_eval_point(elem_patch_idx, eval_points_idx);
269 return Value::get_from_array(field_cache, value_cache_idx);
274 static const int unused_point = -1;
277 static const unsigned int regions_in_chunk = 3;
280 static const unsigned int elements_in_chunk = 10;
285 element_eval_points_map_[i_elem_in_cache*eval_points_->max_size()+i_eval_point] = val;
331 template <
template<
IntDim...>
class DimAssembly>
unsigned int region_chunk_begin(unsigned int region_patch_idx) const
Return begin position of region chunk in FieldValueCache.
RevertableList< unsigned int > regions_starts_
Start positions of elements in regions (size = n_regions+1, last value is end of last region) ...
PatchCacheLoc(unsigned int i_elm, unsigned int i_ep)
Constructor sets all data members.
Declaration of class which handles the ordering of degrees of freedom (dof) and mappings between loca...
#define ASSERT_EQ_DBG(a, b)
Definition of comparative assert macro (EQual) only for debug mode.
bool operator<(const EvalPointData &other)
bool ready_to_reading_
Flag is set down during update of cache when this can't be read.
Value::return_type get_value(const FieldValueCache< typename Value::element_type > &field_cache, unsigned int elem_patch_idx, unsigned int eval_points_idx) const
Return value of evaluation point given by idx of element in patch and local point idx in EvalPoints f...
void clear_element_eval_points_map()
Reset all items of elements_eval_points_map.
unsigned int i_element_
mesh_idx of ElementAccessor appropriate to element
unsigned int dh_loc_idx_
local index of cell in DOF handler
const EvalPointData & eval_point_data(unsigned int point_idx) const
Return item of eval_point_data_ specified by its position.
static const int unused_point
Special constant (.
Directing class of FieldValueCache.
std::unordered_map< unsigned int, unsigned int > element_to_map_
Maps element_idx to element index in patch - TODO remove.
Cell accessor allow iterate over DOF handler cells.
unsigned int i_elm_
index of element in patch
unsigned int position_in_cache(unsigned mesh_elm_idx) const
Return position of element stored in ElementCacheMap.
unsigned int element_chunk_end(unsigned int elm_patch_idx) const
Return end position of element chunk in FieldValueCache.
Auxiliary data class holds number of elements in cache and allow to set this value explicitly (e...
unsigned int n_regions() const
Return number of stored regions.
unsigned int region_idx_from_chunk_position(unsigned int chunk_pos) const
Return begin position of region chunk specified by position in map.
unsigned int element_chunk_begin(unsigned int elm_patch_idx) const
Return begin position of element chunk in FieldValueCache.
int * element_eval_points_map_
Holds data of evaluating points in patch.
RevertableList< EvalPointData > eval_point_data_
EvalPointData(unsigned int i_reg, unsigned int i_ele, unsigned int i_ep, unsigned int dh_loc_idx)
Constructor sets all data members.
unsigned int i_ep_
index of eval point in patch
Holds pair of positions of point in cache (element and eval point)
void set_element_eval_point(unsigned int i_elem_in_cache, unsigned int i_eval_point, int val) const
Set item of element_eval_points_map_.
static const unsigned int undef_elem_idx
Index of invalid element in cache.
static CacheMapElementNumber & get_instance()
unsigned int i_reg_
region_idx of element
unsigned int region_chunk_end(unsigned int region_patch_idx) const
Return end position of region chunk in FieldValueCache.
int element_eval_point(unsigned int i_elem_in_cache, unsigned int i_eval_point) const
unsigned int IntDim
A dimension index type.
unsigned int i_eval_point_
index of point in EvalPoint object
unsigned int elm_idx_on_position(unsigned pos) const
Return mesh_idx of element stored at given position of ElementCacheMap.
std::vector< unsigned int > elm_idx_
Vector of element indexes stored in cache.
Class holds local coordinations of evaluating points (bulk and sides) specified by element dimension...
std::shared_ptr< EvalPoints > eval_points_
Pointer to EvalPoints.
Generic class of assemblation.
std::shared_ptr< EvalPoints > eval_points() const
Getter of eval_points object.
EvalPointData(const EvalPointData &other)
Copy constructor.
static const unsigned int simd_size_double
RevertableList< unsigned int > element_starts_
Start positions of elements in eval_point_data_ (size = n_elements+1)
unsigned int region_chunk_by_map_index(unsigned int r_idx) const
Return begin position of region chunk specified by position in map.
unsigned int n_elem_
Maximal number of elements stored in cache.
#define ASSERT_PTR_DBG(ptr)
Definition of assert macro checking non-null pointer (PTR) only for debug mode.
CacheMapElementNumber()
Forbiden default constructor.
Side accessor allows to iterate over sides of DOF handler cell.
unsigned int n_elements() const
Return number of stored elements.
#define ASSERT_LT_DBG(a, b)
Definition of comparative assert macro (Less Than) only for debug mode.