Plugins
nedelec_transfer.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013-2014: G-CSC, Goethe University Frankfurt
3  * Author: Dmitry Logashenko
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 
37 #ifndef __H__UG__PLUGINS__ELECTROMAGNETISM__NEDELEC_TRANSFER__
38 #define __H__UG__PLUGINS__ELECTROMAGNETISM__NEDELEC_TRANSFER__
39 
40 #include "common/common.h"
42 
43 #ifdef UG_PARALLEL
45 #endif
46 
47 namespace ug{
48 namespace Electromagnetism{
49 
53 template <typename TDomain, typename TAlgebra, typename TElem>
55 {
57  typedef TDomain domain_type;
58 
60  typedef TAlgebra algebra_type;
61 
64 
66  static const int WDim = TDomain::dim;
67 
70 
72  static const int dim = ref_elem_type::dim;
73 
76 
78  static void GetRegularLocalCoordinate
79  (
80  const MultiGrid * mg,
81  Vertex * vrt,
82  TElem * base,
83  MathVector<TElem::dim> & local
84  );
85 
86 public:
87 
90  (
91  const domain_type & domain,
92  const DoFDistribution & coarseDD,
93  const DoFDistribution & fineDD,
94  matrix_type & mat,
95  std::vector<bool> & vIsRestricted
96  );
97 };
98 
102 template <typename TDomain, typename TAlgebra>
104 {
106  typedef TDomain domain_type;
107 
109  typedef TAlgebra algebra_type;
110 
113 
115  static const int WDim = TDomain::dim;
116 
117 public:
118 
120  static void assemble_prolongation_matrix
121  (
122  const domain_type & domain,
123  const DoFDistribution & coarseDD,
124  const DoFDistribution & fineDD,
125  matrix_type & mat,
126  std::vector<bool> & vIsRestricted
127  );
128 };
129 
166 template <typename TDomain, typename TAlgebra>
167 class NedelecTransfer: public ITransferOperator<TDomain, TAlgebra>
168 {
169 public:
172 
175 
177  typedef TDomain domain_type;
178 
180  typedef TAlgebra algebra_type;
181 
184 
187 
189  static const int WDim = TDomain::dim;
190 
191 public:
192 
195  : ITransferOperator<TDomain, TAlgebra>(), m_bInit (false), m_spApproxSpace (approxSpace)
196  {};
197 
199  virtual void set_levels (GridLevel coarseLevel, GridLevel fineLevel);
200 
202  void init ();
203 
205  void prolongate (vector_type & uFineOut, const vector_type & uCoarse);
206 
208  void do_restrict (vector_type & uCoarse, const vector_type & uFine);
209 
212 
213 private:
214 
217 
219  template <typename TElem>
221  (
222  matrix_type & mat,
223  std::vector<bool> & vIsRestricted,
224  const DoFDistribution & coarseDD,
225  const DoFDistribution & fineDD
226  );
227 
230  {
235 
237  (
238  this_type* pThis,
239  const DoFDistribution & coarseDD,
240  const DoFDistribution & fineDD
241  )
242  : m_pThis (pThis), m_domain (* m_pThis->m_spApproxSpace->domain().get ()),
243  m_coarseDD (coarseDD), m_fineDD (fineDD) {}
244 
245  template <typename TElem> void operator() (TElem &)
246  {
250  }
251  };
252 
253 private:
254 
256  bool m_bInit;
257 
260 
262  std::vector<bool> m_vIsRestricted;
263 
266 
269 
272 
275 };
276 
277 } // end namespace Electromagnetism
278 } // end namespace ug
279 
280 #include "nedelec_transfer_impl.h"
281 
282 #endif // __H__UG__PLUGINS__ELECTROMAGNETISM__NEDELEC_TRANSFER__
283 
284 /* End of File */
TAlgebra::matrix_type matrix_type
Type of Vector.
Definition: nedelec_transfer.h:112
TDomain domain_type
Type of Domain.
Definition: nedelec_transfer.h:106
TAlgebra algebra_type
Type of algebra.
Definition: nedelec_transfer.h:109
TDomain domain_type
Type of Domain.
Definition: nedelec_transfer.h:57
static void GetRegularLocalCoordinate(const MultiGrid *mg, Vertex *vrt, TElem *base, MathVector< TElem::dim > &local)
computes the local coordinates of a vertex according to the assumption of the regular refinement
Definition: nedelec_transfer_impl.h:57
static const int dim
dimensionality of the reference element
Definition: nedelec_transfer.h:72
reference_element_traits< TElem >::reference_element_type ref_elem_type
reference element type
Definition: nedelec_transfer.h:69
TAlgebra algebra_type
Type of algebra.
Definition: nedelec_transfer.h:60
static void assemble_prolongation_matrix(const domain_type &domain, const DoFDistribution &coarseDD, const DoFDistribution &fineDD, matrix_type &mat, std::vector< bool > &vIsRestricted)
assembles the prolongation matrix for one type of the grid elements
Definition: nedelec_transfer_impl.h:209
TDomain::position_type position_type
position type in the domain
Definition: nedelec_transfer.h:75
TAlgebra::matrix_type matrix_type
Type of Vector.
Definition: nedelec_transfer.h:63
static const int WDim
world dimention
Definition: nedelec_transfer.h:66
Class of the prolongation and the restriction of the Nedelec DoFs.
Definition: nedelec_transfer.h:168
SmartPtr< ApproximationSpace< TDomain > > m_spApproxSpace
approximation space
Definition: nedelec_transfer.h:268
GridLevel m_fineLevel
fine grid level
Definition: nedelec_transfer.h:271
matrix_type m_prolongation_matrix
matrix to store prolongation
Definition: nedelec_transfer.h:259
void prolongate(vector_type &uFineOut, const vector_type &uCoarse)
applies the prolongation
Definition: nedelec_transfer_impl.h:340
TAlgebra::matrix_type matrix_type
Type of Vector.
Definition: nedelec_transfer.h:186
NedelecTransfer(SmartPtr< ApproximationSpace< TDomain > > approxSpace)
Constructor setting approximation space.
Definition: nedelec_transfer.h:194
TAlgebra algebra_type
Type of algebra.
Definition: nedelec_transfer.h:180
TAlgebra::vector_type vector_type
Type of Vector.
Definition: nedelec_transfer.h:183
static const int WDim
world dimention
Definition: nedelec_transfer.h:189
GridLevel m_coarseLevel
coarse grid level
Definition: nedelec_transfer.h:274
void do_restrict(vector_type &uCoarse, const vector_type &uFine)
apples the restriction = transposed prolongation
Definition: nedelec_transfer_impl.h:392
ITransferOperator< TDomain, TAlgebra > base_type
Type of base class.
Definition: nedelec_transfer.h:174
NedelecTransfer< TDomain, TAlgebra > this_type
This type.
Definition: nedelec_transfer.h:171
void init()
initializes the operator (computes the prolongation matrix etc)
Definition: nedelec_transfer_impl.h:301
void check_approximation_space()
checks the approximation space
Definition: nedelec_transfer_impl.h:445
std::vector< bool > m_vIsRestricted
restriction flag
Definition: nedelec_transfer.h:262
virtual void set_levels(GridLevel coarseLevel, GridLevel fineLevel)
Set levels.
Definition: nedelec_transfer_impl.h:462
bool m_bInit
initialization flag
Definition: nedelec_transfer.h:256
void assemble_prolongation_matrix(matrix_type &mat, std::vector< bool > &vIsRestricted, const DoFDistribution &coarseDD, const DoFDistribution &fineDD)
assembles the prolongation matrix for one type of the grid elements
SmartPtr< ITransferOperator< TDomain, TAlgebra > > clone()
returns new instance with same setting
Definition: nedelec_transfer_impl.h:483
TDomain domain_type
Type of Domain.
Definition: nedelec_transfer.h:177
std::vector< SmartPtr< IConstraint< TAlgebra > > > m_vConstraint
ParallelMatrix< SparseMatrix< double > > matrix_type
ParallelVector< Vector< double > > vector_type
MathVector< dim > position_type
static const int dim
SM_edge_weight_map< typename T::value_type, ug::BidirectionalMatrix< T > > get(edge_weight_t, ug::BidirectionalMatrix< T > const &g)
a helper class to call all the type-dependent assembling functions
Definition: nedelec_transfer.h:230
AssembleProlongationMatrix(this_type *pThis, const DoFDistribution &coarseDD, const DoFDistribution &fineDD)
Definition: nedelec_transfer.h:237
const DoFDistribution & m_coarseDD
Definition: nedelec_transfer.h:233
const domain_type & m_domain
Definition: nedelec_transfer.h:232
void operator()(TElem &)
Definition: nedelec_transfer.h:245
this_type * m_pThis
Definition: nedelec_transfer.h:231
const DoFDistribution & m_fineDD
Definition: nedelec_transfer.h:234