21 #ifndef PATCH_FE_VALUES_HH_
22 #define PATCH_FE_VALUES_HH_
47 template<
unsigned int spacedim = 3>
59 for (
uint dim=1; dim<4; ++dim) {
73 uint zero_vec_size = 300;
91 for (
unsigned int i=0; i<spacedim; ++i) {
109 template<
unsigned int dim>
111 ASSERT((dim>=0) && (dim<=3))(dim).error(
"Dimension must be 0, 1, 2 or 3.");
118 template<
unsigned int dim>
124 template<
unsigned int dim>
128 return fe_sys->
fe()[component_idx];
130 ASSERT_EQ(component_idx, 0).warning(
"Non-zero component_idx can only be used for FESystem.");
136 template<
unsigned int dim>
137 std::shared_ptr<FiniteElement<dim>>
fe_dim() {
149 template <
unsigned int dim>
155 for (
auto integral_it : integrals.
bulk_) {
156 auto &patch_data = integral_it.second->patch_data();
157 for (
uint i_data=0; i_data<patch_data.permanent_size(); ++i_data) {
161 for (
auto p : integral_it.second->points(element_patch_idx) ) {
162 this->
register_bulk_point(patch_data[i_data].cell, elm_pos, p.value_cache_idx(), i_point++);
168 for (
auto integral_it : integrals.
boundary_) {
169 auto &patch_data = integral_it.second->patch_data();
170 for (
unsigned int i_data=0; i_data<patch_data.permanent_size(); ++i_data) {
173 for (
auto p : integral_it.second->points(patch_data[i_data].side) ) {
174 this->
register_side_point(patch_data[i_data].side, side_pos, p.value_cache_idx(), i_point++);
180 for (
auto integral_it : integrals.
edge_) {
181 auto &patch_data = integral_it.second->patch_data();
182 for (
unsigned int i_data=0; i_data<patch_data.permanent_size(); ++i_data) {
183 auto range = patch_data[i_data].edge_side_range;
188 for (
auto p : integral_it.second->points(edge_side) ) {
196 for (
auto integral_it : integrals.
coupling_) {
197 auto &patch_data = integral_it.second->patch_data();
198 uint side_pos, element_patch_idx, elm_pos=0;
199 uint last_element_idx = -1;
201 for (
unsigned int i_data=0; i_data<patch_data.permanent_size(); ++i_data) {
202 side_pos = this->
register_side(patch_data[i_data].side, element_cache_map);
203 if (patch_data[i_data].cell.elm_idx() != last_element_idx) {
204 element_patch_idx = element_cache_map->
position_in_cache(patch_data[i_data].cell.elm_idx());
205 elm_pos = this->
register_element(patch_data[i_data].cell, element_patch_idx);
208 uint i_bulk_point = 0, i_side_point = 0;
209 for (
auto p_high : integral_it.second->points(patch_data[i_data].side) )
211 this->
register_side_point(patch_data[i_data].side, side_pos, p_high.value_cache_idx(), i_side_point++);
212 if (patch_data[i_data].cell.elm_idx() != last_element_idx) {
213 auto p_low = p_high.lower_dim(patch_data[i_data].cell);
214 this->
register_bulk_point(patch_data[i_data].cell, elm_pos, p_low.value_cache_idx(), i_bulk_point++);
217 last_element_idx = patch_data[i_data].cell.elm_idx();
226 auto map_it =
ppv.n_elems_.insert( {cell.
elm_idx(),
ppv.i_mesh_item_} );
227 bool is_elm_added = map_it.second;
232 return map_it.first->second;
244 ppv.side_list_.push_back( cell_side.
side() );
245 return ppv.i_mesh_item_++;
256 cell_side.
side_idx(), i_point_on_side);
275 template<
class OpType,
unsigned int dim>
277 std::string op_name =
typeid(OpType).name();
284 DebugOut().fmt(
"Create new operation '{}', dim: {}, quad size: {}.\n", op_name, dim, quad->
size());
292 template<
class OpType,
unsigned int dim>
294 return this->
template get<OpType, dim>( this->
element_quad(dim) );
298 template<
class OpType,
unsigned int dim>
300 std::string op_name =
typeid(OpType).name();
307 DebugOut().fmt(
"Create new operation '{}', dim: {}, quad size: {}.\n", op_name, dim, quad->
size());
316 stream << endl <<
"Table of patch FE operations:" << endl;
317 stream << std::setfill(
'-') << setw(160) <<
"" << endl;
319 stream << std::setfill(
' ') <<
" Operation" << std::setw(51) <<
"" <<
"Type" << std::setw(5) <<
"" <<
"Shape" << std::setw(2) <<
""
320 <<
"n DOFs" << std::setw(2) <<
"" <<
"Input operations" << std::endl;
322 stream <<
" " << std::left << std::setw(60) <<
typeid(*
operations_[i]).name() <<
"";
324 stream <<
" " << std::setw(6) <<
operations_[i]->format_shape() <<
"" <<
" "
325 << std::setw(7) <<
operations_[i]->n_dofs() <<
"" <<
" ";
326 for (
auto *i_o :
operations_[i]->input_ops_) stream <<
typeid(*i_o).name() <<
" ";
330 stream << std::setfill(
'=') << setw(160) <<
"" << endl;
346 ASSERT( (dim>0) && (dim<=3) )(dim);
352 for (
uint i_dim=0; i_dim<3; ++i_dim)
353 for (
uint i_domain=0; i_domain<2; ++i_domain) {
374 ppv.elem_dim_list_->push_back( cell.
elm() );
375 return ppv.elem_dim_list_->size() - 1;
#define ASSERT_EQ(a, b)
Definition of comparative assert macro (EQual) only for debug mode.
PatchArenaResource< Resource > * get_child_arena()
Cell accessor allow iterate over DOF handler cells.
unsigned int dim() const
Return dimension of element appropriate to cell.
unsigned int elm_idx() const
Return serial idx to element of loc_ele_idx_.
ElementAccessor< 3 > elm() const
Return ElementAccessor to element of loc_ele_idx_.
Side accessor allows to iterate over sides of DOF handler cell.
unsigned int elem_idx() const
Side side() const
Return Side of given cell and side_idx.
const DHCellAccessor & cell() const
Return DHCellAccessor appropriate to the side.
unsigned int dim() const
Return dimension of element appropriate to the side.
unsigned int side_idx() const
Directing class of FieldValueCache.
unsigned int position_in_cache(unsigned mesh_elm_idx, bool bdr=false) const
Return position of element stored in ElementCacheMap.
Compound finite element on dim dimensional simplex.
const std::vector< std::shared_ptr< FiniteElement< dim > > > & fe() const
Abstract class for the description of a general finite element on a reference simplex in dim dimensio...
PatchFeData & patch_fe_data()
Getter of patch_fe_data_.
uint register_element(DHCellAccessor cell, uint element_patch_idx)
Register element to patch_point_vals_ table by dimension of element.
uint register_side_point(DHCellSide cell_side, uint patch_side_idx, uint elm_cache_map_idx, uint i_point_on_side)
Register side point to patch_point_vals_ table by dimension of side.
PatchPointValues< spacedim >::PatchFeData PatchFeData
std::vector< PatchOp< spacedim > * > operations_
std::vector< Quadrature > element_quads_
~PatchFEValues()
Destructor.
PatchPointValues< spacedim > & ppv(uint domain, uint dim)
Temporary method.
PatchOp< spacedim > * get_for_elem_quad()
Returns operation of given dim and OpType, creates it if doesn't exist.
PatchOp< spacedim > * get(const Quadrature *quad)
Returns operation of given dim and OpType, creates it if doesn't exist.
uint register_element_internal(DHCellAccessor cell, uint element_patch_idx)
Register element to patch_point_vals_ table by dimension of element.
PatchFEValues(MixedPtr< FiniteElement > fe)
void init_finalize()
Finalize initialization, creates child (patch) arena and passes it to PatchPointValue objects.
std::shared_ptr< FiniteElement< dim > > fe_dim()
Returns pointer to FiniteElement of given dimension.
OperationMap< PatchOp< spacedim > > op_dependency_
const AssemblyArena & asm_arena() const
same as previous but return constant reference
PatchArena & patch_arena() const
return reference to patch arena
uint register_bulk_point(DHCellAccessor cell, uint patch_elm_idx, uint elm_cache_map_idx, uint i_point_on_elem)
Register bulk point to patch_point_vals_ table by dimension of element.
void add_patch_points(const DimIntegrals< dim > &integrals, ElementCacheMap *element_cache_map, std::shared_ptr< EvalPoints > eval_points)
Add elements, sides and quadrature points registered on patch.
void print_operations(ostream &stream) const
Print table of all used operations - development method.
void set_used_domain(fem_domain domain)
Mark domain (bulk or side) as used in assembly class.
PatchFeData patch_fe_data_
std::vector< ElemDimList< spacedim > > elem_dim_list_vec_
Sub objects of element data of dimensions 1,2,3.
void make_permanent_ppv_data()
Marks data of last successfully added element to patch as permanent.
MixedPtr< FiniteElement > fe_
Mixed of shared pointers of FiniteElement object.
void clean_elements_map()
Clear elements_map, set values to (-1)
unsigned int n_dofs_high() const
Returns the number of shape functions og higher dim element.
std::vector< uint > elements_map_
void reinit_patch()
Reinit data.
unsigned int n_dofs() const
Returns the number of shape functions.
const Quadrature * element_quad(unsigned int dim) const
Return element quadrature (passed to element / side operations)
AssemblyArena & asm_arena()
return reference to assembly arena
bool used_domain_[2]
Pair of flags signs holds info if bulk and side quadratures are used.
uint register_side(DHCellSide cell_side, ElementCacheMap *element_cache_map)
Register side to patch_point_vals_ table by dimension of side.
PatchOp< spacedim > * get(const Quadrature *quad, std::shared_ptr< FiniteElement< dim >> fe)
Returns operation of given dim and OpType, creates it if doesn't exist.
std::vector< std::vector< PatchPointValues< spacedim > > > patch_point_vals_
Sub objects of bulk and side data of dimensions 1,2,3.
std::shared_ptr< FiniteElement< dim > > fe_comp(std::shared_ptr< FiniteElement< dim > > fe, uint component_idx)
Returnd FiniteElement of component_idx for FESystem or fe for other types.
void reset()
Reset PatchpointValues structures.
Symmetric Gauss-Legendre quadrature formulae on simplices.
Base class for quadrature rules on simplices in arbitrary dimensions.
unsigned int size() const
Returns number of quadrature points.
Class FESystem for compound finite elements.
std::unordered_map< std::tuple< std::string, uint >, Operation *, OperationTplHash > OperationMap
Alias for unordered_map of Operation pointer with custom hash.
#define DebugOut()
Macro defining 'debug' record of log.
Declares accessors to FE operations.
Base class of FE operations.
Store finite element data on the actual patch such as shape function values, gradients,...
@ patch_elem_on_domain
Index of patch element for each bulk element or side.
@ ref_side_on_sides
Ref index of side in element for each side in patch.
fem_domain
Distinguishes operations by type and size of output rows.
Definitions of particular quadrature rules on simplices.
Class RefElement defines numbering of vertices, sides, calculation of normal vectors etc.
Set of integral of given dimension necessary in assemblation.
IntegralPtrMap< BoundaryIntegralAcc< dim > > boundary_
Boundary integrals betwwen side and boundary element of dim-1.
IntegralPtrMap< EdgeIntegralAcc< dim > > edge_
Edge integrals between elements of same dimensions.
IntegralPtrMap< BulkIntegralAcc< dim > > bulk_
Bulk integrals of elements.
IntegralPtrMap< CouplingIntegralAcc< dim > > coupling_
Coupling integrals between elements of dimensions dim and dim-1.
static std::tuple< std::string, uint > op_tuple(std::string op_type, uint quad_size)
Create tuple from typeid(Operation).name and size of Quadrature.
AssemblyArena asm_arena_
Assembly arena, created and filled once during initialization.
ArenaVec< double > zero_vec_
ArenaVec of zero values of maximal length using in zero PatchPointValues construction.
PatchArena * patch_arena_
Patch arena, reseted before patch reinit.