Flow123d  JS_before_hm-1804-gf2ad740aa
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]

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...
 
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...
 
unsigned int position_in_cache (unsigned mesh_elm_idx) 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...
 
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...
 

Static Public Attributes

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

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 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 element_idx to element index in patch - TODO remove. More...
 
template<template< IntDim... > class DimAssembly>
class GenericAssembly
 

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 151 of file field_value_cache.hh.

Constructor & Destructor Documentation

◆ ElementCacheMap()

ElementCacheMap::ElementCacheMap ( )

Constructor.

Definition at line 36 of file field_value_cache.cc.

◆ ~ElementCacheMap()

ElementCacheMap::~ElementCacheMap ( )

Destructor.

Definition at line 43 of file field_value_cache.cc.

Member Function Documentation

◆ clear_element_eval_points_map()

void ElementCacheMap::clear_element_eval_points_map ( )
inline

Reset all items of elements_eval_points_map.

Definition at line 173 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 60 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 232 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 238 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 204 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 210 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 267 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 193 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 114 of file field_value_cache.cc.

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 273 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 50 of file field_value_cache.cc.

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 227 of file field_value_cache.hh.

Here is the caller graph for this function:

◆ n_regions()

unsigned int ElementCacheMap::n_regions ( ) const
inline

Return number of stored regions.

Definition at line 222 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) const
inline

Return position of element stored in ElementCacheMap.

Definition at line 215 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 244 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 256 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 250 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 262 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 293 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 110 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 343 of file field_value_cache.hh.

Member Data Documentation

◆ 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 327 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 336 of file field_value_cache.hh.

◆ element_to_map_

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

Maps element_idx to element index in patch - TODO remove.

Definition at line 337 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 290 of file field_value_cache.hh.

◆ elm_idx_

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

Vector of element indexes stored in cache.

Definition at line 299 of file field_value_cache.hh.

◆ eval_point_data_

RevertableList<EvalPointData> ElementCacheMap::eval_point_data_
protected

Definition at line 330 of file field_value_cache.hh.

◆ eval_points_

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

Pointer to EvalPoints.

Definition at line 302 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 305 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 287 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 335 of file field_value_cache.hh.

◆ simd_size_double

const unsigned int ElementCacheMap::simd_size_double = 4
static

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 158 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 154 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 284 of file field_value_cache.hh.


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