ug4
lagrange_dirac_source.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019-2020: G-CSC, Goethe University Frankfurt
3  * Author: Arne Naegel
4  *
5  * This file is part of UG4.
6  *
7  * UG4 is free software: you can redistribute it and/or modify it under the
8  * terms of the GNU Lesser General Public License version 3 (as published by the
9  * Free Software Foundation) with the following additional attribution
10  * requirements (according to LGPL/GPL v3 §7):
11  *
12  * (1) The following notice must be displayed in the Appropriate Legal Notices
13  * of covered and combined works: "Based on UG4 (www.ug4.org/license)".
14  *
15  * (2) The following notice must be displayed at a prominent place in the
16  * terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
17  *
18  * (3) The following bibliography is recommended for citation and must be
19  * preserved in all covered files:
20  * "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
21  * parallel geometric multigrid solver on hierarchically distributed grids.
22  * Computing and visualization in science 16, 4 (2013), 151-164"
23  * "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
24  * flexible software system for simulating pde based models on high performance
25  * computers. Computing and visualization in science 16, 4 (2013), 165-179"
26  *
27  * This program is distributed in the hope that it will be useful,
28  * but WITHOUT ANY WARRANTY; without even the implied warranty of
29  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30  * GNU Lesser General Public License for more details.
31  */
32 
33 /*
34  * Finite Volume Element Discretization for an inner BndCond that depends on the unknowns (on the bnd)
35  *
36  * This class implements the IElemDisc interface to provide element local
37  * assemblings for the unknown-dependent Neumann-flux over an inner boundary.
38  * The equation of this flux and its derivative should be given
39  * in a concretization of this class.
40  *
41  * \tparam TDomain Domain
42  * \tparam TAlgebra Algebra
43  */
44 
45 #ifndef __H__UG__LIB_DISC__SPACIAL_DISCRETIZATION__ELEM_DISC__DIRAC_SOURCE__LAGRANGE_DIRAC_SOURCE_H__
46 #define __H__UG__LIB_DISC__SPACIAL_DISCRETIZATION__ELEM_DISC__DIRAC_SOURCE__LAGRANGE_DIRAC_SOURCE_H__
47 
48 #include <boost/function.hpp>
49 #include <vector>
50 #include <string>
51 #include <utility> // std::pair
52 
53 // other ug4 modules
54 #include "common/common.h"
55 
56 // library intern headers
61 
62 
63 
64 
65 namespace ug
66 {
67 
68 
69 
70 template<typename TDomain>
72 : public IElemDisc<TDomain>
73 {
74 
75  public:
78 
81 
83  static const int dim = base_type::dim;
84 
85  static const int _C_ = 0;
86 
89 
90  private:
93 
94 
95  public:
96 
98  DiracSourceDisc(const char* functions = "", const char* subsets = "")
99  : IElemDisc<TDomain>(functions, subsets), m_bNonRegularGrid(false) /*, m_bCurrElemIsHSlave(false)*/
100  {
102  }
103 
105  DiracSourceDisc(const std::vector<std::string>& functions, const std::vector<std::string>& subsets)
106  : IElemDisc<TDomain>(functions, subsets), m_bNonRegularGrid(false) /*, m_bCurrElemIsHSlave(false)*/
107  {
109  }
110 
112  virtual ~DiracSourceDisc() {};
113 
114 
115 
117  void add_source(number scale, MathVector<dim> &srcCoord);
118  void add_source(SmartPtr<UserData<number, dim> > srcData, MathVector<dim> &srcCoord);
119 #ifdef UG_FOR_LUA
120  void add_source(const char* luaScaleFctName, MathVector<dim> &srcCoord);
121 #endif
122 
125  void add_transport_sink(number snk);
126 
127 #ifdef UG_FOR_LUA
128  void add_transport_sink(const char* luaScaleFctName);
129 #endif
130 
131  public: // inherited from IElemDisc
133  virtual void prepare_setting(const std::vector<LFEID>& vLfeID, bool bNonRegularGrid);
134 
136  virtual bool use_hanging() const;
137 
138  protected:
139 
140 
142 
147  template<typename TElem, typename TFVGeom>
148  void prep_elem_loop(const ReferenceObjectID roid, const int si)
149  {}
150 
152 
157  template<typename TElem, typename TFVGeom>
158  void prep_elem(const LocalVector& u, GridObject* elem, const ReferenceObjectID roid, const MathVector<dim> vCornerCoords[])
159  {}
160 
162  template<typename TElem, typename TFVGeom>
164  {}
165 
167  template<typename TElem, typename TFVGeom>
168  void add_jac_A_elem(LocalMatrix& J, const LocalVector& u, GridObject* elem, const MathVector<dim> vCornerCoords[]);
169 
171  template<typename TElem, typename TFVGeom>
172  void add_jac_M_elem(LocalMatrix& J, const LocalVector& u, GridObject* elem, const MathVector<dim> vCornerCoords[])
173  {}
174 
176  template<typename TElem, typename TFVGeom>
177  void add_def_A_elem(LocalVector& d, const LocalVector& u, GridObject* elem, const MathVector<dim> vCornerCoords[]);
178 
180  template<typename TElem, typename TFVGeom>
181  void add_def_M_elem(LocalVector& d, const LocalVector& u, GridObject* elem, const MathVector<dim> vCornerCoords[])
182  {}
183 
185  template<typename TElem, typename TFVGeom>
186  void add_rhs_elem(LocalVector& rhs, GridObject* elem, const MathVector<dim> vCornerCoords[]);
187 
188 
189 
191  template <typename TElem, typename TFVGeom>
192  void prep_err_est_elem_loop(const ReferenceObjectID roid, const int si)
193  { UG_THROW("Not Implemented!"); }
194 
196  template <typename TElem, typename TFVGeom>
197  void prep_err_est_elem(const LocalVector& u, GridObject* elem, const MathVector<dim> vCornerCoords[])
198  { UG_THROW("Not Implemented!"); }
199 
201  template <typename TElem, typename TFVGeom>
202  void compute_err_est_A_elem(const LocalVector& u, GridObject* elem, const MathVector<dim> vCornerCoords[], const number& scale)
203  { UG_THROW("Not Implemented!"); }
204 
206  template <typename TElem, typename TFVGeom>
208  { UG_THROW("Not Implemented!"); }
209 
210  private:
211  SmartPtr<UserData<number, dim> > m_srcData; // source/sink: adding 'source' to rhs
212  SmartPtr<UserData<number, dim> > m_snkTransportData; // transport sink: subtracting u*sink
214 
215  private:
216  void register_all_funcs();
217 
218  template <typename TElem, typename TFVGeom>
219  void register_func();
220  public:
222 
223  protected:
226 
227  private:
229  // bool m_bCurrElemIsHSlave;
230 };
231 
232 } // namespace ug
233 
235 
236 
237 #endif /*__H__UG__LIB_DISC__SPACIAL_DISCRETIZATION__ELEM_DISC__DIRAC_SOURCE__LAGRANGE_DIRAC_SOURCE__*/
Definition: smart_pointer.h:108
Definition: lagrange_dirac_source.h:73
void compute_err_est_A_elem(const LocalVector &u, GridObject *elem, const MathVector< dim > vCornerCoords[], const number &scale)
computes the error estimator contribution for one element
Definition: lagrange_dirac_source.h:202
void add_jac_M_elem(LocalMatrix &J, const LocalVector &u, GridObject *elem, const MathVector< dim > vCornerCoords[])
assembles the local mass matrix using a finite volume scheme
Definition: lagrange_dirac_source.h:172
SmartPtr< UserData< number, dim > > m_snkTransportData
Definition: lagrange_dirac_source.h:212
void add_def_M_elem(LocalVector &d, const LocalVector &u, GridObject *elem, const MathVector< dim > vCornerCoords[])
assembles the mass part of the local defect
Definition: lagrange_dirac_source.h:181
void prep_elem(const LocalVector &u, GridObject *elem, const ReferenceObjectID roid, const MathVector< dim > vCornerCoords[])
prepares the element for assembling
Definition: lagrange_dirac_source.h:158
virtual ~DiracSourceDisc()
Destructor.
Definition: lagrange_dirac_source.h:112
void prep_err_est_elem_loop(const ReferenceObjectID roid, const int si)
prepares the loop over all elements of one type for the computation of the error estimator
Definition: lagrange_dirac_source.h:192
void prep_elem_loop(const ReferenceObjectID roid, const int si)
prepares the loop over all elements
Definition: lagrange_dirac_source.h:148
virtual void prepare_setting(const std::vector< LFEID > &vLfeID, bool bNonRegularGrid)
type of trial space for each function used
Definition: lagrange_dirac_source_impl.h:94
static const int dim
World dimension.
Definition: lagrange_dirac_source.h:83
void add_jac_A_elem(LocalMatrix &J, const LocalVector &u, GridObject *elem, const MathVector< dim > vCornerCoords[])
assembles the local stiffness matrix using a finite volume scheme
Definition: lagrange_dirac_source_impl.h:117
static const int _C_
Definition: lagrange_dirac_source.h:85
void add_source(number scale, MathVector< dim > &srcCoord)
Setting a scaling factor for the flux.
Definition: lagrange_dirac_source_impl.h:47
MathVector< dim > m_srcCoord
Definition: lagrange_dirac_source.h:213
virtual bool use_hanging() const
returns if hanging nodes are used
Definition: lagrange_dirac_source_impl.h:108
SmartPtr< UserData< number, dim > > m_srcData
Definition: lagrange_dirac_source.h:211
void register_func()
Definition: lagrange_dirac_source_impl.h:187
base_type::domain_type domain_type
Domain type.
Definition: lagrange_dirac_source.h:80
DiracSourceDisc< TDomain > this_type
own type
Definition: lagrange_dirac_source.h:92
IElemDisc< TDomain > base_type
Base class type.
Definition: lagrange_dirac_source.h:77
void fsh_err_est_elem_loop()
postprocesses the loop over all elements of one type in the computation of the error estimator
Definition: lagrange_dirac_source.h:207
DiracSourceDisc(const char *functions="", const char *subsets="")
Constructor with c-strings.
Definition: lagrange_dirac_source.h:98
void add_transport_sink(SmartPtr< UserData< number, dim > > snkData)
Setting a scaling factor for the flux.
Definition: lagrange_dirac_source_impl.h:74
SmartPtr< DataExport< number, dim > > m_exRate
Export for the concentration.
Definition: lagrange_dirac_source.h:225
SmartPtr< CplUserData< number, dim > > NumberExport
Definition: lagrange_dirac_source.h:221
void prep_err_est_elem(const LocalVector &u, GridObject *elem, const MathVector< dim > vCornerCoords[])
prepares the element for assembling the error estimator
Definition: lagrange_dirac_source.h:197
void register_all_funcs()
Definition: lagrange_dirac_source_impl.h:175
void add_def_A_elem(LocalVector &d, const LocalVector &u, GridObject *elem, const MathVector< dim > vCornerCoords[])
assembles the stiffness part of the local defect
Definition: lagrange_dirac_source_impl.h:133
DiracSourceDisc(const std::vector< std::string > &functions, const std::vector< std::string > &subsets)
Constructor with functions.
Definition: lagrange_dirac_source.h:105
base_type::position_type position_type
Position type.
Definition: lagrange_dirac_source.h:88
void fsh_elem_loop()
finishes the loop over all elements
Definition: lagrange_dirac_source.h:163
void add_rhs_elem(LocalVector &rhs, GridObject *elem, const MathVector< dim > vCornerCoords[])
assembles the local right hand side
Definition: lagrange_dirac_source_impl.h:147
bool m_bNonRegularGrid
Definition: lagrange_dirac_source.h:228
The base class for all geometric objects, such as vertices, edges, faces, volumes,...
Definition: grid_base_objects.h:157
TDomain::position_type position_type
Position type.
Definition: elem_disc_interface.h:479
Definition: elem_disc_interface.h:800
static const int dim
Definition: elem_disc_interface.h:803
TDomain domain_type
Definition: elem_disc_interface.h:802
Definition: local_algebra.h:422
Definition: local_algebra.h:198
Type based UserData.
Definition: user_data.h:117
#define UG_THROW(msg)
Definition: error.h:57
double number
Definition: types.h:124
the ug namespace
ReferenceObjectID
these ids are used to identify the shape of a geometric object.
Definition: grid_base_objects.h:74