Flow123d  JS_before_hm-1710-g489f4168f
assembly_base.hh
Go to the documentation of this file.
1 /*!
2  *
3  * Copyright (C) 2015 Technical University of Liberec. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU General Public License version 3 as published by the
7  * Free Software Foundation. (http://www.gnu.org/licenses/gpl-3.0.en.html)
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12  *
13  *
14  * @file assembly_base.hh
15  * @brief
16  */
17 
18 #ifndef ASSEMBLY_BASE_HH_
19 #define ASSEMBLY_BASE_HH_
20 
21 
24 #include "fields/eval_points.hh"
26 #include "fem/update_flags.hh"
27 
28 
29 
30 /**
31  * Base class define empty methods, these methods can be overwite in descendants.
32  */
33 template <unsigned int dim>
35 {
36 public:
37  /// Constructor
38  AssemblyBase(unsigned int quad_order) {
39  quad_ = new QGauss(dim, 2*quad_order);
40  quad_low_ = new QGauss(dim-1, 2*quad_order);
41  }
42 
43  // Destructor
44  virtual ~AssemblyBase() {
45  delete quad_;
46  delete quad_low_;
47  }
48 
49  /// Assembles the volume integrals on cell.
50  inline void cell_integral(FMT_UNUSED DHCellAccessor cell, FMT_UNUSED unsigned int element_patch_idx) {}
51 
52  /// Assembles the fluxes on the boundary.
53  inline void boundary_side_integral(FMT_UNUSED DHCellSide cell_side) {}
54 
55  /// Assembles the fluxes between sides on the edge.
57 
58  /// Assembles the fluxes between elements of different dimensions.
59  inline void dimjoin_intergral(FMT_UNUSED DHCellAccessor cell_lower_dim, FMT_UNUSED DHCellSide neighb_side) {}
60 
61  /// Method prepares object before assemblation (e.g. balance, ...).
62  virtual void begin() {}
63 
64  /// Method finishes object after assemblation (e.g. balance, ...).
65  virtual void end() {}
66 
67  /// Getter of active_integrals.
68  inline int n_active_integrals() const {
69  return active_integrals_;
70  }
71 
72  /// Create integrals according to dim of assembly object
73  void create_integrals(std::shared_ptr<EvalPoints> eval_points, AssemblyIntegrals &integrals) {
75  integrals_.bulk_ = eval_points->add_bulk<dim>(*quad_);
76  integrals.bulk_[dim-1] = integrals_.bulk_;
77  }
79  integrals_.edge_ = eval_points->add_edge<dim>(*quad_low_);
80  integrals.edge_[dim-1] = integrals_.edge_;
81  }
82  if ((dim>1) && (active_integrals_ & ActiveIntegrals::coupling)) {
83  integrals_.coupling_ = eval_points->add_coupling<dim>(*quad_low_);
84  integrals.coupling_[dim-2] = integrals_.coupling_;
85  }
87  integrals_.boundary_ = eval_points->add_boundary<dim>(*quad_low_);
88  integrals.boundary_[dim-1] = integrals_.boundary_;
89  }
90  }
91 
92  /// Return BulkPoint range of appropriate dimension
93  inline Range< BulkPoint > bulk_points(unsigned int element_patch_idx) const {
94  return integrals_.bulk_->points(element_patch_idx, element_cache_map_);
95  }
96 
97  /// Return EdgePoint range of appropriate dimension
98  inline Range< EdgePoint > edge_points(const DHCellSide &cell_side) const {
99  ASSERT_DBG( cell_side.dim() > 0 ).error("Invalid cell dimension, must be 1, 2 or 3!\n");
100  return integrals_.edge_->points(cell_side, element_cache_map_);
101  }
102 
103  /// Return CouplingPoint range of appropriate dimension
104  inline Range< CouplingPoint > coupling_points(const DHCellSide &cell_side) const {
105  ASSERT_DBG( cell_side.dim() > 1 ).error("Invalid cell dimension, must be 2 or 3!\n");
106  return integrals_.coupling_->points(cell_side, element_cache_map_);
107  }
108 
109  /// Return BoundaryPoint range of appropriate dimension
110  inline Range< BoundaryPoint > boundary_points(const DHCellSide &cell_side) const {
111  ASSERT_DBG( cell_side.dim() > 0 ).error("Invalid cell dimension, must be 1, 2 or 3!\n");
112  return integrals_.boundary_->points(cell_side, element_cache_map_);
113  }
114 
115 protected:
116  /// Set of integral of given dimension necessary in assemblation
117  struct DimIntegrals {
118  std::shared_ptr<BulkIntegral> bulk_; ///< Bulk integrals of elements
119  std::shared_ptr<EdgeIntegral> edge_; ///< Edge integrals between elements of same dimensions
120  std::shared_ptr<CouplingIntegral> coupling_; ///< Coupling integrals between elements of dimensions dim and dim-1
121  std::shared_ptr<BoundaryIntegral> boundary_; ///< Boundary integrals betwwen side and boundary element of dim-1
122  };
123 
124  /// Print update flags to string format.
125  std::string print_update_flags(UpdateFlags u) const {
126  std::stringstream s;
127  s << u;
128  return s.str();
129  }
130 
131  Quadrature *quad_; ///< Quadrature used in assembling methods.
132  Quadrature *quad_low_; ///< Quadrature used in assembling methods (dim-1).
133  int active_integrals_; ///< Holds mask of active integrals.
134  DimIntegrals integrals_; ///< Set of used integrals.
135  ElementCacheMap *element_cache_map_; ///< ElementCacheMap shared with GenericAssembly object.
136 };
137 
138 
139 #endif /* ASSEMBLY_BASE_HH_ */
AssemblyBase::DimIntegrals::boundary_
std::shared_ptr< BoundaryIntegral > boundary_
Boundary integrals betwwen side and boundary element of dim-1.
Definition: assembly_base.hh:121
AssemblyIntegrals::coupling_
std::array< std::shared_ptr< CouplingIntegral >, 2 > coupling_
Coupling integrals between elements of dimensions 1-2, 2-3.
Definition: generic_assembly.hh:43
AssemblyBase::print_update_flags
std::string print_update_flags(UpdateFlags u) const
Print update flags to string format.
Definition: assembly_base.hh:125
AssemblyBase::~AssemblyBase
virtual ~AssemblyBase()
Definition: assembly_base.hh:44
AssemblyIntegrals
Set of all used integral necessary in assemblation.
Definition: generic_assembly.hh:40
AssemblyBase::edge_points
Range< EdgePoint > edge_points(const DHCellSide &cell_side) const
Return EdgePoint range of appropriate dimension.
Definition: assembly_base.hh:98
AssemblyBase::quad_low_
Quadrature * quad_low_
Quadrature used in assembling methods (dim-1).
Definition: assembly_base.hh:132
AssemblyBase::begin
virtual void begin()
Method prepares object before assemblation (e.g. balance, ...).
Definition: assembly_base.hh:62
ElementCacheMap
Directing class of FieldValueCache.
Definition: field_value_cache.hh:141
eval_points.hh
ASSERT_DBG
#define ASSERT_DBG(expr)
Definition: include_fadbad.hh:28
AssemblyIntegrals::edge_
std::array< std::shared_ptr< EdgeIntegral >, 3 > edge_
Edge integrals between elements of dimensions 1, 2, 3.
Definition: generic_assembly.hh:42
AssemblyBase::end
virtual void end()
Method finishes object after assemblation (e.g. balance, ...).
Definition: assembly_base.hh:65
AssemblyBase::DimIntegrals::bulk_
std::shared_ptr< BulkIntegral > bulk_
Bulk integrals of elements.
Definition: assembly_base.hh:118
DHCellSide::dim
unsigned int dim() const
Return dimension of element appropriate to the side.
Definition: dh_cell_accessor.hh:214
AssemblyBase::integrals_
DimIntegrals integrals_
Set of used integrals.
Definition: assembly_base.hh:134
AssemblyBase::dimjoin_intergral
void dimjoin_intergral(FMT_UNUSED DHCellAccessor cell_lower_dim, FMT_UNUSED DHCellSide neighb_side)
Assembles the fluxes between elements of different dimensions.
Definition: assembly_base.hh:59
DHCellSide
Side accessor allows to iterate over sides of DOF handler cell.
Definition: dh_cell_accessor.hh:176
AssemblyBase::AssemblyBase
AssemblyBase(unsigned int quad_order)
Constructor.
Definition: assembly_base.hh:38
RangeConvert< DHEdgeSide, DHCellSide >
AssemblyBase::n_active_integrals
int n_active_integrals() const
Getter of active_integrals.
Definition: assembly_base.hh:68
AssemblyIntegrals::bulk_
std::array< std::shared_ptr< BulkIntegral >, 3 > bulk_
Bulk integrals of elements of dimensions 1, 2, 3.
Definition: generic_assembly.hh:41
generic_assembly.hh
quadrature_lib.hh
Definitions of particular quadrature rules on simplices.
AssemblyBase::edge_integral
void edge_integral(FMT_UNUSED RangeConvert< DHEdgeSide, DHCellSide > edge_side_range)
Assembles the fluxes between sides on the edge.
Definition: assembly_base.hh:56
coupling
@ coupling
Definition: generic_assembly.hh:34
AssemblyBase::DimIntegrals::edge_
std::shared_ptr< EdgeIntegral > edge_
Edge integrals between elements of same dimensions.
Definition: assembly_base.hh:119
QGauss
Symmetric Gauss-Legendre quadrature formulae on simplices.
Definition: quadrature_lib.hh:34
AssemblyBase::bulk_points
Range< BulkPoint > bulk_points(unsigned int element_patch_idx) const
Return BulkPoint range of appropriate dimension.
Definition: assembly_base.hh:93
bulk
@ bulk
Definition: generic_assembly.hh:32
Range
Range helper class.
Definition: range_wrapper.hh:65
DHCellAccessor
Cell accessor allow iterate over DOF handler cells.
Definition: dh_cell_accessor.hh:43
update_flags.hh
Enum type UpdateFlags indicates which quantities are to be recomputed on each finite element cell.
AssemblyBase::create_integrals
void create_integrals(std::shared_ptr< EvalPoints > eval_points, AssemblyIntegrals &integrals)
Create integrals according to dim of assembly object.
Definition: assembly_base.hh:73
field_value_cache.hh
AssemblyBase::active_integrals_
int active_integrals_
Holds mask of active integrals.
Definition: assembly_base.hh:133
AssemblyBase::DimIntegrals
Set of integral of given dimension necessary in assemblation.
Definition: assembly_base.hh:117
AssemblyBase::cell_integral
void cell_integral(FMT_UNUSED DHCellAccessor cell, FMT_UNUSED unsigned int element_patch_idx)
Assembles the volume integrals on cell.
Definition: assembly_base.hh:50
UpdateFlags
UpdateFlags
Enum type UpdateFlags indicates which quantities are to be recomputed on each finite element cell.
Definition: update_flags.hh:67
AssemblyBase
Definition: assembly_base.hh:34
edge
@ edge
Definition: generic_assembly.hh:33
boundary
@ boundary
Definition: generic_assembly.hh:35
AssemblyBase::coupling_points
Range< CouplingPoint > coupling_points(const DHCellSide &cell_side) const
Return CouplingPoint range of appropriate dimension.
Definition: assembly_base.hh:104
Quadrature
Base class for quadrature rules on simplices in arbitrary dimensions.
Definition: quadrature.hh:48
AssemblyBase::boundary_points
Range< BoundaryPoint > boundary_points(const DHCellSide &cell_side) const
Return BoundaryPoint range of appropriate dimension.
Definition: assembly_base.hh:110
AssemblyBase::DimIntegrals::coupling_
std::shared_ptr< CouplingIntegral > coupling_
Coupling integrals between elements of dimensions dim and dim-1.
Definition: assembly_base.hh:120
AssemblyBase::element_cache_map_
ElementCacheMap * element_cache_map_
ElementCacheMap shared with GenericAssembly object.
Definition: assembly_base.hh:135
AssemblyBase::quad_
Quadrature * quad_
Quadrature used in assembling methods.
Definition: assembly_base.hh:131
AssemblyBase::boundary_side_integral
void boundary_side_integral(FMT_UNUSED DHCellSide cell_side)
Assembles the fluxes on the boundary.
Definition: assembly_base.hh:53
FMT_UNUSED
#define FMT_UNUSED
Definition: posix.h:75
AssemblyIntegrals::boundary_
std::array< std::shared_ptr< BoundaryIntegral >, 3 > boundary_
Boundary integrals betwwen elements of dimensions 1, 2, 3 and boundaries.
Definition: generic_assembly.hh:44