Line data Source code
1 : /*
2 : * Copyright (c) 2010-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__OPERATOR__LINEAR_OPERATOR__STD_INJECTION__
34 : #define __H__UG__LIB_DISC__OPERATOR__LINEAR_OPERATOR__STD_INJECTION__
35 :
36 : // extern headers
37 : #include <iostream>
38 :
39 : // other ug4 modules
40 : #include "common/common.h"
41 : #include "transfer_interface.h"
42 :
43 : #ifdef UG_PARALLEL
44 : #include "lib_disc/parallelization/parallelization_util.h"
45 : #endif
46 :
47 : namespace ug{
48 :
49 : /**
50 : * The Projection operator transfers is used to transfer vectors between two
51 : * grid levels. It implements a purely algebraic interface, just mapping
52 : * between two algebraic vectors, but given the approximation space this is indeed
53 : * a mapping between two grid functions.
54 : *
55 : * \tparam TDomain the domain
56 : * \tparam TAlgebra the algebra
57 : */
58 : template <typename TDomain, typename TAlgebra>
59 : class StdInjection :
60 : virtual public ITransferOperator<TDomain, TAlgebra>
61 : {
62 : public:
63 : /// Type of base class
64 : typedef ITransferOperator<TDomain, TAlgebra> base_type;
65 :
66 : /// Type of algebra
67 : typedef TAlgebra algebra_type;
68 :
69 : /// Type of Vector
70 : typedef typename TAlgebra::vector_type vector_type;
71 :
72 : /// Type of Vector
73 : typedef typename TAlgebra::matrix_type matrix_type;
74 :
75 : /// Type of Domain
76 : typedef TDomain domain_type;
77 :
78 : public:
79 : /// Constructor
80 0 : StdInjection() : m_bInit(false) {}
81 :
82 : /// Constructor
83 0 : StdInjection(SmartPtr<ApproximationSpace<TDomain> > approxSpace) :
84 0 : m_spApproxSpace(approxSpace), m_bInit(false)
85 0 : {}
86 :
87 : /// Set Approximation Space
88 : void set_approximation_space(SmartPtr<ApproximationSpace<TDomain> > approxSpace);
89 :
90 : /// virtual Destructor
91 0 : virtual ~StdInjection(){};
92 : public:
93 : /// Set approximation level
94 : void set_levels(GridLevel coarseLevel, GridLevel fineLevel);
95 :
96 : protected:
97 : template <typename TElem>
98 : void set_identity_on_pure_surface(matrix_type& mat,
99 : const DoFDistribution& coarseDD, const DoFDistribution& fineDD);
100 :
101 : void set_identity_on_pure_surface(matrix_type& mat,
102 : const DoFDistribution& coarseDD, const DoFDistribution& fineDD);
103 :
104 : public:
105 : /// Init operator
106 : virtual void init();
107 :
108 : /// Project uFine to uCoarse; uCoarse = P(uFine);
109 : virtual void prolongate(vector_type& uFine, const vector_type& uCoarse);
110 :
111 : /// Apply Transposed Operator u = L^T*f
112 : virtual void do_restrict(vector_type& uCoarse, const vector_type& uFine);
113 :
114 : /// clones the operator
115 : virtual SmartPtr<ITransferOperator<TDomain, TAlgebra> > clone();
116 :
117 : protected:
118 : /// matrix used for projection
119 : matrix_type m_matrix;
120 :
121 : /// the underlying approximation space
122 : SmartPtr<ApproximationSpace<TDomain> > m_spApproxSpace;
123 :
124 : /// fine level of approximation space
125 : GridLevel m_fineLevel;
126 :
127 : /// coarse level of approximation space
128 : GridLevel m_coarseLevel;
129 :
130 : /// init flag
131 : bool m_bInit;
132 : };
133 :
134 : }
135 :
136 : #include "std_injection_impl.h"
137 :
138 : #endif /* __H__UG__LIB_DISC__OPERATOR__LINEAR_OPERATOR__STD_INJECTION__ */
|