Line data Source code
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 :
40 : ///////////////////////////////////////////////////////////////////////////////
41 : // Base class for Position-Time-UserData
42 : ///////////////////////////////////////////////////////////////////////////////
43 :
44 : /**
45 : * This class is a base class for all position and time dependent user data.
46 : * The data thus does not depend on the a computed solution.
47 : * In order to use the interface, the deriving class must implement the method:
48 : *
49 : * inline TRet evaluate(TData& D, const MathVector<dim>& x, number time, int si) const
50 : *
51 : */
52 : template <typename TImpl, typename TData, int dim, typename TRet = void>
53 : class StdGlobPosData
54 : : public StdUserData<StdGlobPosData<TImpl,TData,dim,TRet>, TData, dim, TRet>
55 : {
56 : public:
57 0 : virtual TRet operator() (TData& value,
58 : const MathVector<dim>& globIP,
59 : number time, int si) const
60 : {
61 0 : return this->getImpl().evaluate(value, globIP, time, si);
62 : }
63 :
64 0 : virtual void operator()(TData vValue[],
65 : const MathVector<dim> vGlobIP[],
66 : number time, int si, const size_t nip) const
67 : {
68 0 : for(size_t ip = 0; ip < nip; ++ip)
69 0 : this->getImpl().evaluate(vValue[ip], vGlobIP[ip], time, si);
70 0 : }
71 :
72 : template <int refDim>
73 0 : 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 0 : for(size_t ip = 0; ip < nip; ++ip)
84 0 : this->getImpl().evaluate(vValue[ip],vGlobIP[ip],time,si);
85 0 : }
86 :
87 : /// implement as a UserData
88 0 : 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 0 : for(size_t s = 0; s < this->num_series(); ++s)
95 0 : for(size_t ip = 0; ip < this->num_ip(s); ++ip)
96 0 : this->getImpl().evaluate(this->value(s,ip), this->ip(s, ip), t, si);
97 0 : }
98 :
99 : /// implement as a UserData
100 0 : virtual void compute(LocalVectorTimeSeries* u, GridObject* elem,
101 : const MathVector<dim> vCornerCoords[], bool bDeriv = false)
102 : {
103 : const int si = this->subset();
104 :
105 0 : for(size_t s = 0; s < this->num_series(); ++s)
106 0 : for(size_t ip = 0; ip < this->num_ip(s); ++ip)
107 0 : this->getImpl().evaluate(this->value(s,ip), this->ip(s, ip), this->time(s), si);
108 0 : }
109 :
110 : /// returns if data is constant
111 0 : virtual bool constant() const {return false;}
112 :
113 : /// returns if grid function is needed for evaluation
114 0 : virtual bool requires_grid_fct() const {return false;}
115 :
116 : /// returns if provided data is continuous over geometric object boundaries
117 0 : virtual bool continuous() const {return true;}
118 :
119 : protected:
120 : /// access to implementation
121 : TImpl& getImpl() {return static_cast<TImpl&>(*this);}
122 :
123 : /// const access to implementation
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__ */
|