ug4
local_transfer_interface.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__FUNCTION_SPACS__LOCAL_TRANSFER_INTERFACE__
34 #define __H__UG__LIB_DISC__FUNCTION_SPACS__LOCAL_TRANSFER_INTERFACE__
35 
36 #include "lib_disc/domain.h"
38 
39 namespace ug{
40 
42 // Value Access Base class
44 
46 {
47  public:
48  virtual void access_inner(GridObject* elem) = 0;
49 
50  virtual void access_closure(GridObject* elem) = 0;
51 
53 
54  const number& operator[](size_t i) const {
55  UG_ASSERT(i < m_Val.size(), "Wrong index "<<i<<" (size: "<<m_Val.size()<<")");
56  return *m_Val[i];
57  }
58 
59  number& operator[](size_t i) {
60  UG_ASSERT(i < m_Val.size(), "Wrong index "<<i<<" (size: "<<m_Val.size()<<")");
61  return *m_Val[i];
62  }
63 
64  size_t size() const {return m_Val.size();}
65 
66  protected:
67  std::vector<number*> m_Val;
68 };
69 
71 // Element Prolongation
73 
74 template <typename TDomain>
76 {
77  public:
78  virtual void init(ConstSmartPtr<TDomain> spDomain,
81  {
82  m_spDomain = spDomain;
83  m_spGrid = m_spDomain->grid();
84  m_vValueChild = vValueChild;
85  m_vValueParent = vValueParent;
86  }
87 
89 
90  virtual void prolongate(Vertex* parent) = 0;
91  virtual void prolongate(Edge* parent) = 0;
92  virtual void prolongate(Face* parent) = 0;
93  virtual void prolongate(Volume* parent) = 0;
94 
95  virtual ~IElemProlongation() {}
96 
97  protected:
100 
103 };
104 
105 
106 template <typename TDomain, typename TImpl>
108 {
109  public:
110  virtual void prolongate(Vertex* parent){
111  this->getImpl().prolongate(parent, *this->m_vValueChild, *this->m_vValueParent);
112  }
113  virtual void prolongate(Edge* parent){
114  this->getImpl().prolongate(parent, *this->m_vValueChild, *this->m_vValueParent);
115  }
116  virtual void prolongate(Face* parent){
117  this->getImpl().prolongate(parent, *this->m_vValueChild, *this->m_vValueParent);
118  }
119  virtual void prolongate(Volume* parent){
120  this->getImpl().prolongate(parent, *this->m_vValueChild, *this->m_vValueParent);
121  }
122 
123  protected:
125  TImpl& getImpl() {return static_cast<TImpl&>(*this);}
126 
128  const TImpl& getImpl() const {return static_cast<const TImpl&>(*this);}
129 };
130 
131 
132 template <typename TDomain>
134 GetStandardElementProlongation(const LFEID& lfeid);
135 
136 
138 // Element Restriction
140 
141 template <typename TDomain>
143 {
144  public:
145  virtual void init(ConstSmartPtr<TDomain> spDomain,
147  SmartPtr<TransferValueAccessor> vValueParent)
148  {
149  m_spDomain = spDomain;
150  m_spGrid = m_spDomain->grid();
151  m_vValueChild = vValueChild;
152  m_vValueParent = vValueParent;
153  }
154 
156 
157  virtual void do_restrict(Vertex* parent) = 0;
158  virtual void do_restrict(Edge* parent) = 0;
159  virtual void do_restrict(Face* parent) = 0;
160  virtual void do_restrict(Volume* parent) = 0;
161 
162  virtual ~IElemRestriction() {}
163 
164  protected:
167 
170 };
171 
172 
173 template <typename TDomain, typename TImpl>
174 class ElemRestrictionBase : public IElemRestriction<TDomain>
175 {
176  public:
177  virtual void do_restrict(Vertex* parent){
178  this->getImpl().do_restrict(parent, *this->m_vValueChild, *this->m_vValueParent);
179  }
180  virtual void do_restrict(Edge* parent){
181  this->getImpl().do_restrict(parent, *this->m_vValueChild, *this->m_vValueParent);
182  }
183  virtual void do_restrict(Face* parent){
184  this->getImpl().do_restrict(parent, *this->m_vValueChild, *this->m_vValueParent);
185  }
186  virtual void do_restrict(Volume* parent){
187  this->getImpl().do_restrict(parent, *this->m_vValueChild, *this->m_vValueParent);
188  }
189 
190  protected:
192  TImpl& getImpl() {return static_cast<TImpl&>(*this);}
193 
195  const TImpl& getImpl() const {return static_cast<const TImpl&>(*this);}
196 };
197 
198 
199 template <typename TDomain>
201 GetStandardElementRestriction(const LFEID& lfeid);
202 
203 
204 } // end namespace ug
205 
206 #endif /* __H__UG__LIB_DISC__FUNCTION_SPACS__LOCAL_TRANSFER_INTERFACE__ */
Definition: smart_pointer.h:108
Base-class for edges.
Definition: grid_base_objects.h:397
Definition: local_transfer_interface.h:108
virtual void prolongate(Volume *parent)
Definition: local_transfer_interface.h:119
const TImpl & getImpl() const
const access to implementation
Definition: local_transfer_interface.h:128
TImpl & getImpl()
access to implementation
Definition: local_transfer_interface.h:125
virtual void prolongate(Vertex *parent)
Definition: local_transfer_interface.h:110
virtual void prolongate(Face *parent)
Definition: local_transfer_interface.h:116
virtual void prolongate(Edge *parent)
Definition: local_transfer_interface.h:113
Definition: local_transfer_interface.h:175
const TImpl & getImpl() const
const access to implementation
Definition: local_transfer_interface.h:195
virtual void do_restrict(Vertex *parent)
Definition: local_transfer_interface.h:177
virtual void do_restrict(Face *parent)
Definition: local_transfer_interface.h:183
virtual void do_restrict(Volume *parent)
Definition: local_transfer_interface.h:186
virtual void do_restrict(Edge *parent)
Definition: local_transfer_interface.h:180
TImpl & getImpl()
access to implementation
Definition: local_transfer_interface.h:192
Faces are 2-dimensional objects.
Definition: grid_base_objects.h:510
The base class for all geometric objects, such as vertices, edges, faces, volumes,...
Definition: grid_base_objects.h:157
Definition: local_transfer_interface.h:76
virtual void prolongate(Edge *parent)=0
virtual ~IElemProlongation()
Definition: local_transfer_interface.h:95
virtual void prolongate(Vertex *parent)=0
SmartPtr< TransferValueAccessor > m_vValueParent
Definition: local_transfer_interface.h:102
virtual bool perform_prolongation_on(GridBaseObjectId gbo)=0
virtual void init(ConstSmartPtr< TDomain > spDomain, SmartPtr< TransferValueAccessor > vValueChild, SmartPtr< TransferValueAccessor > vValueParent)
Definition: local_transfer_interface.h:78
ConstSmartPtr< TDomain > m_spDomain
Definition: local_transfer_interface.h:98
virtual void prolongate(Volume *parent)=0
SmartPtr< TransferValueAccessor > m_vValueChild
Definition: local_transfer_interface.h:101
ConstSmartPtr< MultiGrid > m_spGrid
Definition: local_transfer_interface.h:99
virtual void prolongate(Face *parent)=0
Definition: local_transfer_interface.h:143
virtual bool perform_restriction_on(GridBaseObjectId gbo)=0
virtual void do_restrict(Face *parent)=0
virtual void do_restrict(Vertex *parent)=0
virtual void do_restrict(Volume *parent)=0
SmartPtr< TransferValueAccessor > m_vValueParent
Definition: local_transfer_interface.h:169
SmartPtr< TransferValueAccessor > m_vValueChild
Definition: local_transfer_interface.h:168
virtual void do_restrict(Edge *parent)=0
virtual ~IElemRestriction()
Definition: local_transfer_interface.h:162
ConstSmartPtr< TDomain > m_spDomain
Definition: local_transfer_interface.h:165
virtual void init(ConstSmartPtr< TDomain > spDomain, SmartPtr< TransferValueAccessor > vValueChild, SmartPtr< TransferValueAccessor > vValueParent)
Definition: local_transfer_interface.h:145
ConstSmartPtr< MultiGrid > m_spGrid
Definition: local_transfer_interface.h:166
Definition: local_transfer_interface.h:46
virtual ~TransferValueAccessor()
Definition: local_transfer_interface.h:52
virtual void access_inner(GridObject *elem)=0
size_t size() const
Definition: local_transfer_interface.h:64
std::vector< number * > m_Val
Definition: local_transfer_interface.h:67
const number & operator[](size_t i) const
Definition: local_transfer_interface.h:54
virtual void access_closure(GridObject *elem)=0
number & operator[](size_t i)
Definition: local_transfer_interface.h:59
Base-class for all vertex-types.
Definition: grid_base_objects.h:231
Volumes are 3-dimensional objects.
Definition: grid_base_objects.h:754
#define UG_ASSERT(expr, msg)
Definition: assert.h:70
double number
Definition: types.h:124
the ug namespace
SmartPtr< IElemRestriction< TDomain > > GetStandardElementRestriction(const LFEID &lfeid)
Definition: local_transfer_interface.cpp:61
SmartPtr< IElemProlongation< TDomain > > GetStandardElementProlongation(const LFEID &lfeid)
Definition: local_transfer_interface.cpp:40
GridBaseObjectId
enumeration of the GridBaseObjects that make up a grid.
Definition: grid_base_objects.h:59