ug4
data_evaluator.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2017: G-CSC, Goethe University Frankfurt
3  * Author: Andreas Vogel
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 #ifndef __H__UG__LIB_DISC__SPATIAL_DISC__DATA_EVALUATOR__
34 #define __H__UG__LIB_DISC__SPATIAL_DISC__DATA_EVALUATOR__
35 
39 
40 namespace ug{
41 
43 
45 
53 template <typename TDomain, typename TElemDisc> // TElemDisc = IElemDisc<TDomain>
55 {
56  public:
58  static const int dim = TDomain::dim;
59 
60  public:
62  DataEvaluatorBase(int discPart,
63  const std::vector<TElemDisc*>& vElemDisc,
65  const bool bNonRegularGrid,
66  LocalVectorTimeSeries* locTimeSeries = NULL,
67  const std::vector<number>* vScaleMass = NULL,
68  const std::vector<number>* vScaleStiff = NULL);
69 
71  void set_time_point(const size_t timePoint);
72 
75 
77  bool use_hanging() const {return m_bUseHanging;}
78 
79 
80 
82  void prepare_err_est_elem_loop(const ReferenceObjectID id, int si);
83 
85  void prepare_err_est_elem(LocalVector& u, GridObject* elem, const MathVector<dim> vCornerCoords[],
86  const LocalIndices& ind, bool bDeriv = false);
87 
89  void compute_err_est_A_elem(LocalVector& u, GridObject* elem, const MathVector<dim> vCornerCoords[], const LocalIndices& ind,
90  const number scaleMass = (number) 1.0, const number scaleStiff = (number) 1.0);
91 
93  void compute_err_est_M_elem(LocalVector& u, GridObject* elem, const MathVector<dim> vCornerCoords[], const LocalIndices& ind,
94  const number scaleMass = (number) 1.0, const number scaleStiff = (number) 1.0);
95 
97  void compute_err_est_rhs_elem(GridObject* elem, const MathVector<dim> vCornerCoords[], const LocalIndices& ind,
98  const number scaleMass = (number) 1.0, const number scaleStiff = (number) 1.0);
99 
102 
103  protected:
106 
108  void add_data_to_eval_data(std::vector<SmartPtr<ICplUserData<dim> > >& vEvalData,
109  std::vector<SmartPtr<ICplUserData<dim> > >& vTryingToAdd);
110 
112  void extract_imports_and_userdata(int subsetIndex, int discPart);
113 
116 
117  protected:
120 
122  std::vector<TElemDisc*> m_vElemDisc[MAX_PROCESS];
123 
126 
129 
132 
135 
137  std::vector<IDataImport<dim>*> m_vImport[MAX_PROCESS][MAX_PART];
138 
141  std::vector<SmartPtr<ICplUserData<dim> > > m_vConstData; //< constant data
142  std::vector<SmartPtr<ICplUserData<dim> > > m_vPosData; //< position dependent data
143  std::vector<SmartPtr<ICplUserData<dim> > > m_vDependentData; //< dependent data
145 };
146 
147 
149 template <typename TDomain>
150 class ErrorEvaluator : public DataEvaluatorBase<TDomain, IElemError<TDomain> >
151 {
152 public:
154  ErrorEvaluator(int discPart,
155  const std::vector<IElemError<TDomain> *>& vElemDisc,
157  const bool bNonRegularGrid,
158  LocalVectorTimeSeries* locTimeSeries = NULL,
159  const std::vector<number>* vScaleMass = NULL,
160  const std::vector<number>* vScaleStiff = NULL)
161  : DataEvaluatorBase<TDomain, IElemError<TDomain> > (discPart, vElemDisc, fctPat, bNonRegularGrid, locTimeSeries, vScaleMass, vScaleStiff) {}
162 };
163 
164 
165 
167 template <typename TDomain>
168 class DataEvaluator : public DataEvaluatorBase<TDomain, IElemDisc<TDomain> >
169 {
170 
171 public:
173  using base_type::dim;
174 
176  DataEvaluator(int discPart,
177  const std::vector<IElemDisc<TDomain> *>& vElemDisc,
179  const bool bNonRegularGrid,
180  LocalVectorTimeSeries* locTimeSeries = NULL,
181  const std::vector<number>* vScaleMass = NULL,
182  const std::vector<number>* vScaleStiff = NULL)
183  : DataEvaluatorBase<TDomain, IElemDisc<TDomain> > (discPart, vElemDisc, fctPat, bNonRegularGrid, locTimeSeries, vScaleMass, vScaleStiff) {}
184 
185 
187  // Regular assembling
189 
191  void prepare_timestep(number future_time, const number time, VectorProxyBase* u, size_t algebra_id);
192 
194  void prepare_timestep_elem(const number time, LocalVector& u, GridObject* elem, const MathVector<dim> vCornerCoords[]);
195 
197  void prepare_elem_loop(const ReferenceObjectID id, int si);
198 
200  void prepare_elem(LocalVector& u, GridObject* elem, const ReferenceObjectID roid, const MathVector<dim> vCornerCoords[],
201  const LocalIndices& ind, bool bDeriv = false);
202 
204  void finish_elem_loop();
205 
207  void finish_timestep(const number time, VectorProxyBase* u, size_t algebra_id);
208 
210  void finish_timestep_elem(const number time, LocalVector& u, GridObject* elem, const MathVector<dim> vCornerCoords[]);
211 
213  void add_jac_A_elem(LocalMatrix& A, LocalVector& u, GridObject* elem, const MathVector<dim> vCornerCoords[], ProcessType type = PT_ALL);
214 
216  void add_jac_M_elem(LocalMatrix& M, LocalVector& u, GridObject* elem, const MathVector<dim> vCornerCoords[], ProcessType type = PT_ALL);
217 
219  void add_def_A_elem(LocalVector& d, LocalVector& u, GridObject* elem, const MathVector<dim> vCornerCoords[], ProcessType type = PT_ALL);
220 
222  void add_def_A_expl_elem(LocalVector& d, LocalVector& u, GridObject* elem, const MathVector<dim> vCornerCoords[], ProcessType type = PT_ALL);
223 
225  void add_def_M_elem(LocalVector& d, LocalVector& u, GridObject* elem, const MathVector<dim> vCornerCoords[], ProcessType type = PT_ALL);
226 
228  void add_rhs_elem(LocalVector& rhs, GridObject* elem, const MathVector<dim> vCornerCoords[], ProcessType type = PT_ALL);
229 
231 protected:
232 
234  using base_type::m_vImport;
237  using base_type::m_vPosData;
238  using base_type::m_discPart;
240 
243 
244 };
245 
246 
247 
248 } // end namespace ug
249 
250 #include "data_evaluator_impl.h"
251 
252 #endif /* __H__UG__LIB_DISC__SPATIAL_DISC__DATA_EVALUATOR__ */
Definition: smart_pointer.h:296
Definition: smart_pointer.h:108
helper class to evaluate data evaluation for local contributions during assembling
Definition: data_evaluator.h:55
bool m_bUseHanging
flag if hanging nodes are used
Definition: data_evaluator.h:128
void prepare_err_est_elem_loop(const ReferenceObjectID id, int si)
prepares the element loop for all IElemDiscs for the computation of the error estimator
Definition: data_evaluator_impl.h:331
bool m_bNeedLocTimeSeries
flag indicating if any elem disc needs local time series
Definition: data_evaluator.h:131
LocalVectorTimeSeries * m_pLocTimeSeries
local time series (non-const since mapping may change)
Definition: data_evaluator.h:134
std::vector< TElemDisc * > m_vElemDisc[MAX_PROCESS]
elem disc data
Definition: data_evaluator.h:122
std::vector< SmartPtr< ICplUserData< dim > > > m_vDependentData
Definition: data_evaluator.h:143
void clear_positions_in_user_data()
clears all requested positions in user data
Definition: data_evaluator_impl.h:297
static const int dim
world dimension
Definition: data_evaluator.h:58
void clear_extracted_data_and_mappings()
clears imports and user data and mappings betweem commonFctGrp and local
Definition: data_evaluator_impl.h:281
DataEvaluatorBase(int discPart, const std::vector< TElemDisc * > &vElemDisc, ConstSmartPtr< FunctionPattern > fctPat, const bool bNonRegularGrid, LocalVectorTimeSeries *locTimeSeries=NULL, const std::vector< number > *vScaleMass=NULL, const std::vector< number > *vScaleStiff=NULL)
sets the elem discs to evaluate
Definition: data_evaluator_impl.h:40
std::vector< IDataImport< dim > * > m_vImport[MAX_PROCESS][MAX_PART]
imports that must be evaluated
Definition: data_evaluator.h:137
int m_discPart
disc part needed (MASS and/or STIFF and/or RHS)
Definition: data_evaluator.h:119
void add_data_to_eval_data(std::vector< SmartPtr< ICplUserData< dim > > > &vEvalData, std::vector< SmartPtr< ICplUserData< dim > > > &vTryingToAdd)
tries to add the last entry of vTryingToAdd to the eval data
Definition: data_evaluator_impl.h:101
void prepare_err_est_elem(LocalVector &u, GridObject *elem, const MathVector< dim > vCornerCoords[], const LocalIndices &ind, bool bDeriv=false)
prepares the element for all IElemDiscs
Definition: data_evaluator_impl.h:389
bool time_series_needed() const
returns if local time series is really needed for assembling
Definition: data_evaluator.h:74
void set_time_point(const size_t timePoint)
sets the time point for data evaluation
Definition: data_evaluator_impl.h:311
void extract_imports_and_userdata(int subsetIndex, int discPart)
extracts imports and userdata from IElemDiscs
Definition: data_evaluator_impl.h:147
std::vector< SmartPtr< ICplUserData< dim > > > m_vPosData
Definition: data_evaluator.h:142
void compute_err_est_rhs_elem(GridObject *elem, const MathVector< dim > vCornerCoords[], const LocalIndices &ind, const number scaleMass=(number) 1.0, const number scaleStiff=(number) 1.0)
compute contributions of the local error indicators in one element for all IElemDiscs
Definition: data_evaluator_impl.h:464
ConstSmartPtr< FunctionPattern > m_spFctPattern
underlying function pattern
Definition: data_evaluator.h:125
bool use_hanging() const
returns if one of the element discs needs hanging dofs
Definition: data_evaluator.h:77
void compute_err_est_M_elem(LocalVector &u, GridObject *elem, const MathVector< dim > vCornerCoords[], const LocalIndices &ind, const number scaleMass=(number) 1.0, const number scaleStiff=(number) 1.0)
compute contributions of the local error indicators in one element for all IElemDiscs
Definition: data_evaluator_impl.h:445
std::vector< SmartPtr< ICplUserData< dim > > > m_vConstData
Definition: data_evaluator.h:141
void finish_err_est_elem_loop()
finishes the error estimator element loop for all IElemDiscs
Definition: data_evaluator_impl.h:374
void compute_err_est_A_elem(LocalVector &u, GridObject *elem, const MathVector< dim > vCornerCoords[], const LocalIndices &ind, const number scaleMass=(number) 1.0, const number scaleStiff=(number) 1.0)
compute contributions of the local error indicators in one element for all IElemDiscs
Definition: data_evaluator_impl.h:426
Evaluation for IElemDisc.
Definition: data_evaluator.h:169
void finish_elem_loop()
finishes the element loop for all IElemDiscs
Definition: data_evaluator.cpp:91
void finish_timestep(const number time, VectorProxyBase *u, size_t algebra_id)
finishes all time-dependent IElemDiscs
Definition: data_evaluator.cpp:220
void add_jac_A_elem(LocalMatrix &A, LocalVector &u, GridObject *elem, const MathVector< dim > vCornerCoords[], ProcessType type=PT_ALL)
compute local stiffness matrix for all IElemDiscs
Definition: data_evaluator.cpp:243
void add_def_M_elem(LocalVector &d, LocalVector &u, GridObject *elem, const MathVector< dim > vCornerCoords[], ProcessType type=PT_ALL)
compute local mass defect for all IElemDiscs
Definition: data_evaluator.cpp:336
void prepare_timestep(number future_time, const number time, VectorProxyBase *u, size_t algebra_id)
prepares all time-dependent IElemDiscs
Definition: data_evaluator.cpp:135
void add_jac_M_elem(LocalMatrix &M, LocalVector &u, GridObject *elem, const MathVector< dim > vCornerCoords[], ProcessType type=PT_ALL)
compute local mass matrix for all IElemDiscs
Definition: data_evaluator.cpp:280
void finish_timestep_elem(const number time, LocalVector &u, GridObject *elem, const MathVector< dim > vCornerCoords[])
finishes the elements of all time-dependent IElemDiscs
Definition: data_evaluator.cpp:232
void prepare_elem(LocalVector &u, GridObject *elem, const ReferenceObjectID roid, const MathVector< dim > vCornerCoords[], const LocalIndices &ind, bool bDeriv=false)
prepares the element for all IElemDiscs
Definition: data_evaluator.cpp:159
void prepare_elem_loop(const ReferenceObjectID id, int si)
prepares the element loop for all IElemDiscs
Definition: data_evaluator.cpp:48
DataEvaluator(int discPart, const std::vector< IElemDisc< TDomain > * > &vElemDisc, ConstSmartPtr< FunctionPattern > fctPat, const bool bNonRegularGrid, LocalVectorTimeSeries *locTimeSeries=NULL, const std::vector< number > *vScaleMass=NULL, const std::vector< number > *vScaleStiff=NULL)
sets the elem discs to evaluate
Definition: data_evaluator.h:176
void prepare_timestep_elem(const number time, LocalVector &u, GridObject *elem, const MathVector< dim > vCornerCoords[])
prepares the elements of all time-dependent IElemDiscs
Definition: data_evaluator.cpp:147
DataEvaluatorBase< TDomain, IElemDisc< TDomain > > base_type
Definition: data_evaluator.h:172
void add_def_A_elem(LocalVector &d, LocalVector &u, GridObject *elem, const MathVector< dim > vCornerCoords[], ProcessType type=PT_ALL)
compute local stiffness defect for all IElemDiscs
Definition: data_evaluator.cpp:310
void add_rhs_elem(LocalVector &rhs, GridObject *elem, const MathVector< dim > vCornerCoords[], ProcessType type=PT_ALL)
compute local rhs for all IElemDiscs
Definition: data_evaluator.cpp:349
void add_def_A_expl_elem(LocalVector &d, LocalVector &u, GridObject *elem, const MathVector< dim > vCornerCoords[], ProcessType type=PT_ALL)
compute local stiffness defect for all IElemDiscs explicit
Definition: data_evaluator.cpp:323
Evaluation for IElemError.
Definition: data_evaluator.h:151
ErrorEvaluator(int discPart, const std::vector< IElemError< TDomain > * > &vElemDisc, ConstSmartPtr< FunctionPattern > fctPat, const bool bNonRegularGrid, LocalVectorTimeSeries *locTimeSeries=NULL, const std::vector< number > *vScaleMass=NULL, const std::vector< number > *vScaleStiff=NULL)
sets the elem discs to evaluate
Definition: data_evaluator.h:154
The base class for all geometric objects, such as vertices, edges, faces, volumes,...
Definition: grid_base_objects.h:157
Base class for UserData.
Definition: user_data.h:260
Definition: elem_disc_interface.h:800
Definition: elem_disc_interface.h:760
Definition: local_algebra.h:50
Definition: local_algebra.h:422
Definition: local_algebra.h:198
time series of local vectors
Definition: solution_time_series.h:167
static const int dim
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
ProcessType
Definition: data_evaluator.h:42
@ MAX_PROCESS
Definition: data_evaluator.h:42
@ PT_INSTATIONARY
Definition: data_evaluator.h:42
@ PT_ALL
Definition: data_evaluator.h:42
@ PT_STATIONARY
Definition: data_evaluator.h:42
@ MAX_PART
Definition: data_import.h:49
Proxy struct for generic passing of any vector type.
Definition: elem_disc_interface.h:70