Flow123d  JS_before_hm-1602-g5680f2c
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_ */
UpdateFlags
Enum type UpdateFlags indicates which quantities are to be recomputed on each finite element cell...
Definition: update_flags.hh:67
Quadrature * quad_low_
Quadrature used in assembling methods (dim-1).
int active_integrals_
Holds mask of active integrals.
std::shared_ptr< CouplingIntegral > coupling_
Coupling integrals between elements of dimensions dim and dim-1.
unsigned int dim() const
Return dimension of element appropriate to the side.
Range< EdgePoint > edge_points(const DHCellSide &cell_side) const
Return EdgePoint range of appropriate dimension.
std::array< std::shared_ptr< CouplingIntegral >, 2 > coupling_
Coupling integrals between elements of dimensions 1-2, 2-3.
Range helper class.
Directing class of FieldValueCache.
Cell accessor allow iterate over DOF handler cells.
virtual void begin()
Method prepares object before assemblation (e.g. balance, ...).
void dimjoin_intergral(FMT_UNUSED DHCellAccessor cell_lower_dim, FMT_UNUSED DHCellSide neighb_side)
Assembles the fluxes between elements of different dimensions.
std::shared_ptr< BulkIntegral > bulk_
Bulk integrals of elements.
void boundary_side_integral(FMT_UNUSED DHCellSide cell_side)
Assembles the fluxes on the boundary.
virtual void end()
Method finishes object after assemblation (e.g. balance, ...).
DimIntegrals integrals_
Set of used integrals.
Enum type UpdateFlags indicates which quantities are to be recomputed on each finite element cell...
Base class for quadrature rules on simplices in arbitrary dimensions.
Definition: quadrature.hh:48
Symmetric Gauss-Legendre quadrature formulae on simplices.
std::array< std::shared_ptr< EdgeIntegral >, 3 > edge_
Edge integrals between elements of dimensions 1, 2, 3.
#define FMT_UNUSED
Definition: posix.h:75
Set of integral of given dimension necessary in assemblation.
Range< BulkPoint > bulk_points(unsigned int element_patch_idx) const
Return BulkPoint range of appropriate dimension.
int n_active_integrals() const
Getter of active_integrals.
void edge_integral(FMT_UNUSED RangeConvert< DHEdgeSide, DHCellSide > edge_side_range)
Assembles the fluxes between sides on the edge.
std::array< std::shared_ptr< BulkIntegral >, 3 > bulk_
Bulk integrals of elements of dimensions 1, 2, 3.
std::shared_ptr< EdgeIntegral > edge_
Edge integrals between elements of same dimensions.
virtual ~AssemblyBase()
void create_integrals(std::shared_ptr< EvalPoints > eval_points, AssemblyIntegrals &integrals)
Create integrals according to dim of assembly object.
void cell_integral(FMT_UNUSED DHCellAccessor cell, FMT_UNUSED unsigned int element_patch_idx)
Assembles the volume integrals on cell.
std::array< std::shared_ptr< BoundaryIntegral >, 3 > boundary_
Boundary integrals betwwen elements of dimensions 1, 2, 3 and boundaries.
#define ASSERT_DBG(expr)
AssemblyBase(unsigned int quad_order)
Constructor.
Definitions of particular quadrature rules on simplices.
Range< CouplingPoint > coupling_points(const DHCellSide &cell_side) const
Return CouplingPoint range of appropriate dimension.
Range< BoundaryPoint > boundary_points(const DHCellSide &cell_side) const
Return BoundaryPoint range of appropriate dimension.
Quadrature * quad_
Quadrature used in assembling methods.
Side accessor allows to iterate over sides of DOF handler cell.
Set of all used integral necessary in assemblation.
std::string print_update_flags(UpdateFlags u) const
Print update flags to string format.
ElementCacheMap * element_cache_map_
ElementCacheMap shared with GenericAssembly object.
std::shared_ptr< BoundaryIntegral > boundary_
Boundary integrals betwwen side and boundary element of dim-1.