ug4
std_glob_pos_data.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012-2015: 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__STD_GLOB_POS_DATA__
34 #define __H__UG__LIB_DISC__SPATIAL_DISC__STD_GLOB_POS_DATA__
35 
36 #include "std_user_data.h"
37 
38 namespace ug{
39 
41 // Base class for Position-Time-UserData
43 
52 template <typename TImpl, typename TData, int dim, typename TRet = void>
54  : public StdUserData<StdGlobPosData<TImpl,TData,dim,TRet>, TData, dim, TRet>
55 {
56  public:
57  virtual TRet operator() (TData& value,
58  const MathVector<dim>& globIP,
59  number time, int si) const
60  {
61  return this->getImpl().evaluate(value, globIP, time, si);
62  }
63 
64  virtual void operator()(TData vValue[],
65  const MathVector<dim> vGlobIP[],
66  number time, int si, const size_t nip) const
67  {
68  for(size_t ip = 0; ip < nip; ++ip)
69  this->getImpl().evaluate(vValue[ip], vGlobIP[ip], time, si);
70  }
71 
72  template <int refDim>
73  inline void evaluate(TData vValue[],
74  const MathVector<dim> vGlobIP[],
75  number time, int si,
76  GridObject* elem,
77  const MathVector<dim> vCornerCoords[],
78  const MathVector<refDim> vLocIP[],
79  const size_t nip,
80  LocalVector* u,
81  const MathMatrix<refDim, dim>* vJT = NULL) const
82  {
83  for(size_t ip = 0; ip < nip; ++ip)
84  this->getImpl().evaluate(vValue[ip],vGlobIP[ip],time,si);
85  }
86 
88  virtual void compute(LocalVector* u, GridObject* elem,
89  const MathVector<dim> vCornerCoords[], bool bDeriv = false)
90  {
91  const number t = this->time();
92  const int si = this->subset();
93 
94  for(size_t s = 0; s < this->num_series(); ++s)
95  for(size_t ip = 0; ip < this->num_ip(s); ++ip)
96  this->getImpl().evaluate(this->value(s,ip), this->ip(s, ip), t, si);
97  }
98 
100  virtual void compute(LocalVectorTimeSeries* u, GridObject* elem,
101  const MathVector<dim> vCornerCoords[], bool bDeriv = false)
102  {
103  const int si = this->subset();
104 
105  for(size_t s = 0; s < this->num_series(); ++s)
106  for(size_t ip = 0; ip < this->num_ip(s); ++ip)
107  this->getImpl().evaluate(this->value(s,ip), this->ip(s, ip), this->time(s), si);
108  }
109 
111  virtual bool constant() const {return false;}
112 
114  virtual bool requires_grid_fct() const {return false;}
115 
117  virtual bool continuous() const {return true;}
118 
119  protected:
121  TImpl& getImpl() {return static_cast<TImpl&>(*this);}
122 
124  const TImpl& getImpl() const {return static_cast<const TImpl&>(*this);}
125 };
126 
127 } // namespace ug
128 
129 #endif /* __H__UG__LIB_DISC__SPATIAL_DISC__STD_GLOB_POS_DATA__ */
parameterString s
size_t num_ip(size_t s) const
returns the number of integration points
Definition: user_data.h:327
size_t num_series() const
explicitly forward some functions
Definition: user_data.h:324
const TData & value(size_t s, size_t ip) const
returns the value at ip
Definition: user_data.h:512
The base class for all geometric objects, such as vertices, edges, faces, volumes,...
Definition: grid_base_objects.h:157
const MathVector< dim > & ip(size_t s, size_t ip) const
returns global ip
Definition: user_data.h:401
int subset() const
returns the subset of evaluation
Definition: user_data.h:273
number time() const
get the current evaluation time
Definition: user_data.h:285
Definition: local_algebra.h:198
time series of local vectors
Definition: solution_time_series.h:167
A class for fixed size, dense matrices.
Definition: math_matrix.h:52
Definition: std_glob_pos_data.h:55
virtual void compute(LocalVector *u, GridObject *elem, const MathVector< dim > vCornerCoords[], bool bDeriv=false)
implement as a UserData
Definition: std_glob_pos_data.h:88
const TImpl & getImpl() const
const access to implementation
Definition: std_glob_pos_data.h:124
virtual bool requires_grid_fct() const
returns if grid function is needed for evaluation
Definition: std_glob_pos_data.h:114
virtual void operator()(TData vValue[], const MathVector< dim > vGlobIP[], number time, int si, const size_t nip) const
returns value for global positions
Definition: std_glob_pos_data.h:64
virtual bool constant() const
returns if data is constant
Definition: std_glob_pos_data.h:111
TImpl & getImpl()
access to implementation
Definition: std_glob_pos_data.h:121
virtual TRet operator()(TData &value, const MathVector< dim > &globIP, number time, int si) const
returns value for a global position
Definition: std_glob_pos_data.h:57
virtual void compute(LocalVectorTimeSeries *u, GridObject *elem, const MathVector< dim > vCornerCoords[], bool bDeriv=false)
implement as a UserData
Definition: std_glob_pos_data.h:100
virtual bool continuous() const
returns if provided data is continuous over geometric object boundaries
Definition: std_glob_pos_data.h:117
void evaluate(TData vValue[], const MathVector< dim > vGlobIP[], number time, int si, GridObject *elem, const MathVector< dim > vCornerCoords[], const MathVector< refDim > vLocIP[], const size_t nip, LocalVector *u, const MathMatrix< refDim, dim > *vJT=NULL) const
Definition: std_glob_pos_data.h:73
Definition: std_user_data.h:63
double number
Definition: types.h:124
the ug namespace