Flow123d  DF_patch_fe_data_tables-32b3de9
Public Member Functions | Public Attributes | 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]

Public Member Functions

 ElementCacheMap ()
 Constructor. More...
 
 ~ElementCacheMap ()
 Destructor. More...
 
void init (std::shared_ptr< EvalPoints > eval_points)
 Init cache. More...
 
void create_patch ()
 Create patch of cached elements before reading data to cache. More...
 
void clear_element_eval_points_map ()
 Reset all items of elements_eval_points_map. More...
 
void start_elements_update ()
 Start update of cache. More...
 
void finish_elements_update ()
 Finish update after reading data to cache. More...
 
std::shared_ptr< EvalPointseval_points () const
 Getter of eval_points object. More...
 
void add_eval_point (unsigned int i_reg, unsigned int i_ele, unsigned int i_eval_point, unsigned int dh_loc_idx)
 
unsigned int get_simd_rounded_size ()
 Returns number of eval. points with addition of max simd duplicates due to regions. More...
 
int element_eval_point (unsigned int i_elem_in_cache, unsigned int i_eval_point) const
 
unsigned int elm_idx_on_position (unsigned pos) const
 Return mesh_idx of element stored at given position of ElementCacheMap. More...
 
const std::vector< unsigned int > & elm_idx_vec (bool bdr=false) const
 Return vector of bulk/boundary element idx. More...
 
unsigned int position_in_cache (unsigned mesh_elm_idx, bool bdr=false) const
 Return position of element stored in ElementCacheMap. More...
 
unsigned int n_regions () const
 Return number of stored regions. More...
 
unsigned int n_elements () const
 Return number of stored elements. More...
 
unsigned int element_chunk_begin (unsigned int elm_patch_idx) const
 Return begin position of element chunk in FieldValueCache. More...
 
unsigned int element_chunk_end (unsigned int elm_patch_idx) const
 Return end position of element chunk in FieldValueCache. More...
 
unsigned int region_chunk_begin (unsigned int region_patch_idx) const
 Return begin position of region chunk in FieldValueCache. More...
 
unsigned int region_chunk_end (unsigned int region_patch_idx) const
 Return end position of region chunk in FieldValueCache. More...
 
unsigned int region_chunk_by_map_index (unsigned int r_idx) const
 Return begin position of region chunk specified by position in map. More...
 
unsigned int region_idx_from_chunk_position (unsigned int chunk_pos) const
 Return begin position of region chunk specified by position in map. More...
 
const EvalPointDataeval_point_data (unsigned int point_idx) const
 Return item of eval_point_data_ specified by its position. More...
 
std::size_t n_eval_points () const
 Return number of stored items in eval_point_data_. More...
 
void make_paermanent_eval_points ()
 Mark eval_point_data_ as permanent. More...
 
template<class Value >
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 from cache. More...
 

Public Attributes

unsigned int simd_size_double
 

Static Public Attributes

static const unsigned int undef_elem_idx = std::numeric_limits<unsigned int>::max()
 Index of invalid element in cache. More...
 

Protected Member Functions

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_. More...
 

Protected Attributes

std::vector< unsigned int > elm_idx_
 Vector of bulk element indexes stored in cache. More...
 
std::vector< unsigned int > bdr_elm_idx_
 Vector of boundary element indexes stored in cache. More...
 
std::shared_ptr< EvalPointseval_points_
 Pointer to EvalPoints. 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_
 Holds data of evaluating points in patch. More...
 
RevertableList< EvalPointDataeval_point_data_
 

Static Protected Attributes

static const int unused_point = -1
 Special constant (. More...
 
static const unsigned int regions_in_chunk = 3
 Base number of stored regions in patch. More...
 
static const unsigned int elements_in_chunk = 10
 Base number of stored elements in patch. More...
 

Holds start positions and orders of region chunks and element chunks

RevertableList< unsigned int > regions_starts_
 Start positions of elements in regions (size = n_regions+1, last value is end of last region) More...
 
RevertableList< unsigned int > element_starts_
 Start positions of elements in eval_point_data_ (size = n_elements+1) More...
 
std::unordered_map< unsigned int, unsigned int > element_to_map_
 Maps bulk element_idx to element index in patch - TODO remove. More...
 
std::unordered_map< unsigned int, unsigned int > element_to_map_bdr_
 Maps boundary element_idx to element index in patch - TODO remove. More...
 
std::unordered_set< unsigned int > set_of_regions_
 Keeps set of unique region indices of added eval. points. More...
 
template<template< IntDim... > class DimAssembly>
class GenericAssembly
 
template<template< IntDim... > class DimAssembly>
class GenericAssemblyObserve
 

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).

IMPORTANT: Because there are combined bulk and boundary elements, we must use mesh_idx value to correct identification of elements.

TODO:

  1. Generic assembly pass through the patch collecting needed quadrature points. (PASS ORDER)
  2. Then we sort these points for efficient chae_upadate of the fields (CACHE ORDER)
  3. We pass through the patch again evaluating actual integrals. This second pass is currently inefficient since we can not map efficiently from the PASS ORDER to the CACHE ORDER), this leads to many complications in quad point classes. We should:
  1. have templated patch iteration mechanism, so that we can iterate through the evaluated integrals twice in consistent way performing: FIRST: collection of evaluation points SECOND: evaluation of integrals using the fields and fe_values Having a consistent implementation allows us to assign unique indices to the integral points on the patch.
  2. Sort collected points, remove duplicities, mark new indices to the original list of points.
  3. SECOND pass, use unique index to find the point in the cache.

Resulting simplifications:

Definition at line 152 of file field_value_cache.hh.

Constructor & Destructor Documentation

◆ ElementCacheMap()

ElementCacheMap::ElementCacheMap ( )

Constructor.

Definition at line 37 of file field_value_cache.cc.

◆ ~ElementCacheMap()

ElementCacheMap::~ElementCacheMap ( )

Destructor.

Definition at line 45 of file field_value_cache.cc.

Member Function Documentation

◆ add_eval_point()

void ElementCacheMap::add_eval_point ( unsigned int  i_reg,
unsigned int  i_ele,
unsigned int  i_eval_point,
unsigned int  dh_loc_idx 
)
inline

Adds EvalPointData using emplace_back. Arguments correspond to constructor of EvalPointData.

Definition at line 197 of file field_value_cache.hh.

Here is the caller graph for this function:

◆ clear_element_eval_points_map()

void ElementCacheMap::clear_element_eval_points_map ( )
inline

Reset all items of elements_eval_points_map.

Definition at line 170 of file field_value_cache.hh.

Here is the caller graph for this function:

◆ create_patch()

void ElementCacheMap::create_patch ( )

Create patch of cached elements before reading data to cache.

Definition at line 62 of file field_value_cache.cc.

Here is the caller graph for this function:

◆ element_chunk_begin()

unsigned int ElementCacheMap::element_chunk_begin ( unsigned int  elm_patch_idx) const
inline

Return begin position of element chunk in FieldValueCache.

Definition at line 258 of file field_value_cache.hh.

◆ element_chunk_end()

unsigned int ElementCacheMap::element_chunk_end ( unsigned int  elm_patch_idx) const
inline

Return end position of element chunk in FieldValueCache.

Definition at line 264 of file field_value_cache.hh.

◆ element_eval_point()

int ElementCacheMap::element_eval_point ( unsigned int  i_elem_in_cache,
unsigned int  i_eval_point 
) const
inline

Definition at line 216 of file field_value_cache.hh.

Here is the caller graph for this function:

◆ elm_idx_on_position()

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

Return mesh_idx of element stored at given position of ElementCacheMap.

Definition at line 222 of file field_value_cache.hh.

◆ elm_idx_vec()

const std::vector<unsigned int>& ElementCacheMap::elm_idx_vec ( bool  bdr = false) const
inline

Return vector of bulk/boundary element idx.

Definition at line 228 of file field_value_cache.hh.

◆ eval_point_data()

const EvalPointData& ElementCacheMap::eval_point_data ( unsigned int  point_idx) const
inline

Return item of eval_point_data_ specified by its position.

Definition at line 293 of file field_value_cache.hh.

Here is the caller graph for this function:

◆ eval_points()

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

Getter of eval_points object.

Definition at line 190 of file field_value_cache.hh.

Here is the caller graph for this function:

◆ finish_elements_update()

void ElementCacheMap::finish_elements_update ( )

Finish update after reading data to cache.

Definition at line 127 of file field_value_cache.cc.

Here is the caller graph for this function:

◆ get_simd_rounded_size()

unsigned int ElementCacheMap::get_simd_rounded_size ( )
inline

Returns number of eval. points with addition of max simd duplicates due to regions.

Definition at line 204 of file field_value_cache.hh.

Here is the caller graph for this function:

◆ get_value()

template<class Value >
Value::return_type ElementCacheMap::get_value ( const FieldValueCache< typename Value::element_type > &  field_cache,
unsigned int  elem_patch_idx,
unsigned int  eval_points_idx 
) const
inline

Return value of evaluation point given by idx of element in patch and local point idx in EvalPoints from cache.

Definition at line 309 of file field_value_cache.hh.

Here is the caller graph for this function:

◆ init()

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

Init cache.

Definition at line 52 of file field_value_cache.cc.

Here is the caller graph for this function:

◆ make_paermanent_eval_points()

void ElementCacheMap::make_paermanent_eval_points ( )
inline

Mark eval_point_data_ as permanent.

Definition at line 303 of file field_value_cache.hh.

Here is the caller graph for this function:

◆ n_elements()

unsigned int ElementCacheMap::n_elements ( ) const
inline

Return number of stored elements.

Definition at line 253 of file field_value_cache.hh.

Here is the caller graph for this function:

◆ n_eval_points()

std::size_t ElementCacheMap::n_eval_points ( ) const
inline

Return number of stored items in eval_point_data_.

Definition at line 298 of file field_value_cache.hh.

◆ n_regions()

unsigned int ElementCacheMap::n_regions ( ) const
inline

Return number of stored regions.

Definition at line 248 of file field_value_cache.hh.

Here is the caller graph for this function:

◆ position_in_cache()

unsigned int ElementCacheMap::position_in_cache ( unsigned  mesh_elm_idx,
bool  bdr = false 
) const
inline

Return position of element stored in ElementCacheMap.

Definition at line 234 of file field_value_cache.hh.

Here is the caller graph for this function:

◆ region_chunk_begin()

unsigned int ElementCacheMap::region_chunk_begin ( unsigned int  region_patch_idx) const
inline

Return begin position of region chunk in FieldValueCache.

Definition at line 270 of file field_value_cache.hh.

Here is the caller graph for this function:

◆ region_chunk_by_map_index()

unsigned int ElementCacheMap::region_chunk_by_map_index ( unsigned int  r_idx) const
inline

Return begin position of region chunk specified by position in map.

Definition at line 282 of file field_value_cache.hh.

Here is the caller graph for this function:

◆ region_chunk_end()

unsigned int ElementCacheMap::region_chunk_end ( unsigned int  region_patch_idx) const
inline

Return end position of region chunk in FieldValueCache.

Definition at line 276 of file field_value_cache.hh.

Here is the caller graph for this function:

◆ region_idx_from_chunk_position()

unsigned int ElementCacheMap::region_idx_from_chunk_position ( unsigned int  chunk_pos) const
inline

Return begin position of region chunk specified by position in map.

Definition at line 288 of file field_value_cache.hh.

Here is the caller graph for this function:

◆ set_element_eval_point()

void ElementCacheMap::set_element_eval_point ( unsigned int  i_elem_in_cache,
unsigned int  i_eval_point,
int  val 
) const
inlineprotected

Set item of element_eval_points_map_.

Definition at line 333 of file field_value_cache.hh.

Here is the caller graph for this function:

◆ start_elements_update()

void ElementCacheMap::start_elements_update ( )

Start update of cache.

Definition at line 123 of file field_value_cache.cc.

Here is the caller graph for this function:

Friends And Related Function Documentation

◆ GenericAssembly

template<template< IntDim... > class DimAssembly>
friend class GenericAssembly
friend

Definition at line 391 of file field_value_cache.hh.

◆ GenericAssemblyObserve

template<template< IntDim... > class DimAssembly>
friend class GenericAssemblyObserve
friend

Definition at line 393 of file field_value_cache.hh.

Member Data Documentation

◆ bdr_elm_idx_

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

Vector of boundary element indexes stored in cache.

Definition at line 343 of file field_value_cache.hh.

◆ element_eval_points_map_

int* ElementCacheMap::element_eval_points_map_
protected

Holds data of evaluating points in patch.

This array provides indexes to FieldValueCache.

This one dimensional array behaves like two dimensional factually. Size is set to 'n_cached_elements * n_eval_points' and items are accessible through two indices:

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

Use always and only methods element_eval_point for read and set_element_eval_point (for write) to access to items!

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

TODO improve description

Definition at line 371 of file field_value_cache.hh.

◆ element_starts_

RevertableList<unsigned int> ElementCacheMap::element_starts_
protected

Start positions of elements in eval_point_data_ (size = n_elements+1)

Definition at line 380 of file field_value_cache.hh.

◆ element_to_map_

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

Maps bulk element_idx to element index in patch - TODO remove.

Definition at line 381 of file field_value_cache.hh.

◆ element_to_map_bdr_

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

Maps boundary element_idx to element index in patch - TODO remove.

Definition at line 382 of file field_value_cache.hh.

◆ elements_in_chunk

const unsigned int ElementCacheMap::elements_in_chunk = 10
staticprotected

Base number of stored elements in patch.

Definition at line 330 of file field_value_cache.hh.

◆ elm_idx_

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

Vector of bulk element indexes stored in cache.

Definition at line 340 of file field_value_cache.hh.

◆ eval_point_data_

RevertableList<EvalPointData> ElementCacheMap::eval_point_data_
protected

Definition at line 374 of file field_value_cache.hh.

◆ eval_points_

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

Pointer to EvalPoints.

Definition at line 346 of file field_value_cache.hh.

◆ ready_to_reading_

bool ElementCacheMap::ready_to_reading_
protected

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

Definition at line 349 of file field_value_cache.hh.

◆ regions_in_chunk

const unsigned int ElementCacheMap::regions_in_chunk = 3
staticprotected

Base number of stored regions in patch.

Definition at line 327 of file field_value_cache.hh.

◆ regions_starts_

RevertableList<unsigned int> ElementCacheMap::regions_starts_
protected

Start positions of elements in regions (size = n_regions+1, last value is end of last region)

Definition at line 379 of file field_value_cache.hh.

◆ set_of_regions_

std::unordered_set<unsigned int> ElementCacheMap::set_of_regions_
protected

Keeps set of unique region indices of added eval. points.

Definition at line 387 of file field_value_cache.hh.

◆ simd_size_double

unsigned int ElementCacheMap::simd_size_double

Size of block (evaluation of FieldFormula) must be multiple of this value. TODO We should take this value from BParser and it should be dependent on processor configuration.

Definition at line 320 of file field_value_cache.hh.

◆ undef_elem_idx

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

Index of invalid element in cache.

Definition at line 155 of file field_value_cache.hh.

◆ unused_point

const int ElementCacheMap::unused_point = -1
staticprotected

Special constant (.

See also
element_eval_points_map_).

Definition at line 324 of file field_value_cache.hh.


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