Flow123d  JS_before_hm-929-gaeebe69
Classes | Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
ElementCacheMap Class Reference

Directing class of FieldValueCache. More...

#include <field_value_cache.hh>

Collaboration diagram for ElementCacheMap:
Collaboration graph
[legend]

Classes

struct  RegionData
 
class  UpdateCacheHelper
 

Public Member Functions

 ElementCacheMap ()
 Constructor. More...
 
 ~ElementCacheMap ()
 Destructor. More...
 
void init (std::shared_ptr< EvalPoints > eval_points)
 Init cache. More...
 
void add (const DHCellAccessor &dh_cell)
 Adds element to region_cache_indices_map_ set. More...
 
void add (const DHCellSide &cell_side)
 Same as previous but passes DHCellSide as parameter. More...
 
void prepare_elements_to_update ()
 Prepare data member before reading data to cache. More...
 
void create_elements_points_map ()
 Create map of used eval points on cached elements. More...
 
void start_elements_update ()
 Start update of cache. More...
 
void finish_elements_update ()
 Finish update after reading data to cache. More...
 
const UpdateCacheHelperupdate_cache_data () const
 Return update cache data helper. More...
 
UpdateCacheHelperupdate_cache_data ()
 Return update cache data helper. More...
 
std::shared_ptr< EvalPointseval_points () const
 Getter of eval_points object. More...
 
void mark_used_eval_points (const DHCellAccessor &dh_cell, unsigned int subset_idx, unsigned int data_size, unsigned int start_point=0)
 
int get_field_value_cache_index (unsigned int elm_idx, unsigned int loc_point_idx) const
 Return index of point in FieldValueCache. More...
 
unsigned int elm_idx_on_position (unsigned pos) const
 Return idx of element stored at given position of ElementCacheMap. More...
 
DHCellAccessoroperator() (DHCellAccessor &dh_cell) const
 Set index of cell in ElementCacheMap (or undef value if cell is not stored in cache). More...
 

Static Public Attributes

static constexpr unsigned int n_cached_elements = 20
 Number of cached elements which values are stored in cache. More...
 
static const unsigned int undef_elem_idx = std::numeric_limits<unsigned int>::max()
 Index of invalid element in cache. More...
 

Protected Member Functions

void clear_element_eval_points_map ()
 Reset all items of elements_eval_points_map. More...
 
void add_to_region (ElementAccessor< 3 > elm)
 Add element to appropriate region data of update_data_ object. More...
 

Protected Attributes

std::vector< unsigned int > elm_idx_
 
std::unordered_map< unsigned int, unsigned int > cache_idx_
 
std::shared_ptr< EvalPointseval_points_
 Pointer to EvalPoints. More...
 
UpdateCacheHelper update_data_
 Holds data used for cache update. More...
 
bool ready_to_reading_
 Flag is set down during update of cache when this can't be read. More...
 
int ** element_eval_points_map_
 
unsigned int points_in_cache_
 Number of points stored in cache. More...
 

Static Protected Attributes

static const int unused_point = -2
 Special constant (. More...
 
static const int point_in_proggress = -1
 Special constant (. More...
 

Detailed Description

Directing class of FieldValueCache.

Manage storing and updating element data (elements of same dimension) to cache. We need only one shared instance of this class for all fields in equation (but typically for dim = 1,2,3).

TODO: The logic of creating and updating this class is quite complex, describe in which order the methods are supposed to be called and which internal structures are updated when.

Definition at line 113 of file field_value_cache.hh.

Constructor & Destructor Documentation

ElementCacheMap::ElementCacheMap ( )

Constructor.

Definition at line 56 of file field_value_cache.cc.

ElementCacheMap::~ElementCacheMap ( )

Destructor.

Definition at line 64 of file field_value_cache.cc.

Member Function Documentation

void ElementCacheMap::add ( const DHCellAccessor dh_cell)

Adds element to region_cache_indices_map_ set.

Definition at line 83 of file field_value_cache.cc.

void ElementCacheMap::add ( const DHCellSide cell_side)

Same as previous but passes DHCellSide as parameter.

Definition at line 90 of file field_value_cache.cc.

void ElementCacheMap::add_to_region ( ElementAccessor< 3 >  elm)
protected

Add element to appropriate region data of update_data_ object.

Definition at line 170 of file field_value_cache.cc.

Here is the caller graph for this function:

void ElementCacheMap::clear_element_eval_points_map ( )
protected

Reset all items of elements_eval_points_map.

Definition at line 161 of file field_value_cache.cc.

Here is the caller graph for this function:

void ElementCacheMap::create_elements_points_map ( )

Create map of used eval points on cached elements.

Definition at line 120 of file field_value_cache.cc.

unsigned int ElementCacheMap::elm_idx_on_position ( unsigned  pos) const
inline

Return idx of element stored at given position of ElementCacheMap.

Definition at line 243 of file field_value_cache.hh.

Here is the caller graph for this function:

std::shared_ptr<EvalPoints> ElementCacheMap::eval_points ( ) const
inline

Getter of eval_points object.

Definition at line 222 of file field_value_cache.hh.

Here is the caller graph for this function:

void ElementCacheMap::finish_elements_update ( )

Finish update after reading data to cache.

Definition at line 147 of file field_value_cache.cc.

int ElementCacheMap::get_field_value_cache_index ( unsigned int  elm_idx,
unsigned int  loc_point_idx 
) const
inline

Return index of point in FieldValueCache.

Definition at line 237 of file field_value_cache.hh.

Here is the caller graph for this function:

void ElementCacheMap::init ( std::shared_ptr< EvalPoints eval_points)

Init cache.

Definition at line 73 of file field_value_cache.cc.

void ElementCacheMap::mark_used_eval_points ( const DHCellAccessor dh_cell,
unsigned int  subset_idx,
unsigned int  data_size,
unsigned int  start_point = 0 
)

Set used element eval points to value ElementCacheMap::point_in_proggress

Parameters
dh_cellSpecified element
subset_idxIndex of subset
data_sizeNumber of points
start_pointIndex of first used point in subset (e.g. subset holds eval points of all sides but EdgeIntegral represents only one of them)

Definition at line 153 of file field_value_cache.cc.

DHCellAccessor & ElementCacheMap::operator() ( DHCellAccessor dh_cell) const

Set index of cell in ElementCacheMap (or undef value if cell is not stored in cache).

Definition at line 186 of file field_value_cache.cc.

void ElementCacheMap::prepare_elements_to_update ( )

Prepare data member before reading data to cache.

Definition at line 97 of file field_value_cache.cc.

void ElementCacheMap::start_elements_update ( )

Start update of cache.

Definition at line 142 of file field_value_cache.cc.

const UpdateCacheHelper& ElementCacheMap::update_cache_data ( ) const
inline

Return update cache data helper.

Definition at line 212 of file field_value_cache.hh.

Here is the caller graph for this function:

UpdateCacheHelper& ElementCacheMap::update_cache_data ( )
inline

Return update cache data helper.

Definition at line 217 of file field_value_cache.hh.

Member Data Documentation

std::unordered_map<unsigned int, unsigned int> ElementCacheMap::cache_idx_
protected

Map of element indices stored in cache, allows reverse search to previous vector. TODO: could be moved to UpdateCacheHelper structure

Definition at line 269 of file field_value_cache.hh.

int** ElementCacheMap::element_eval_points_map_
protected

Two dimensional array provides indexes to FieldValueCache.

1: Over elements holds in ElementCacheMap 2: Over EvalPoints for each element

Array is filled in those three steps: a. Reset - all items are set to ElementCacheMap::unused_point b. Used eval points are set to ElementCacheMap::point_in_proggress c. Eval points marked in previous step are sequentially numbered

Definition at line 296 of file field_value_cache.hh.

std::vector<unsigned int> ElementCacheMap::elm_idx_
protected

Vector of element indexes stored in cache. TODO: could be moved to UpdateCacheHelper structure

Definition at line 265 of file field_value_cache.hh.

std::shared_ptr<EvalPoints> ElementCacheMap::eval_points_
protected

Pointer to EvalPoints.

Definition at line 272 of file field_value_cache.hh.

constexpr unsigned int ElementCacheMap::n_cached_elements = 20
static

Number of cached elements which values are stored in cache.

Definition at line 116 of file field_value_cache.hh.

const int ElementCacheMap::point_in_proggress = -1
staticprotected

Special constant (.

See also
element_eval_points_map_).

Definition at line 255 of file field_value_cache.hh.

unsigned int ElementCacheMap::points_in_cache_
protected

Number of points stored in cache.

Definition at line 300 of file field_value_cache.hh.

bool ElementCacheMap::ready_to_reading_
protected

Flag is set down during update of cache when this can't be read.

Definition at line 278 of file field_value_cache.hh.

const unsigned int ElementCacheMap::undef_elem_idx = std::numeric_limits<unsigned int>::max()
static

Index of invalid element in cache.

Definition at line 119 of file field_value_cache.hh.

const int ElementCacheMap::unused_point = -2
staticprotected

Special constant (.

See also
element_eval_points_map_).

Definition at line 252 of file field_value_cache.hh.

UpdateCacheHelper ElementCacheMap::update_data_
protected

Holds data used for cache update.

Definition at line 275 of file field_value_cache.hh.


The documentation for this class was generated from the following files: