Line data Source code
1 : /*
2 : * Copyright (c) 2010-2015: G-CSC, Goethe University Frankfurt
3 : * Author: Markus Breit
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__TIME_DISC__COMBINED_TIME_DISC__
34 : #define __H__UG__LIB_DISC__TIME_DISC__COMBINED_TIME_DISC__
35 :
36 : #include <cstddef> // for size_t
37 : #include <vector> // for vector
38 :
39 : #include "lib_disc/time_disc/time_disc_interface.h" // for ITimeDiscretization
40 :
41 :
42 : namespace ug {
43 :
44 : /// \ingroup lib_disc_time_assemble
45 : /// @{
46 :
47 : /// combine several time discretizations into one
48 : template <typename TAlgebra>
49 0 : class CompositeTimeDiscretization
50 : : public IAssemble<TAlgebra>
51 : {
52 : public:
53 : typedef TAlgebra algebra_type;
54 : typedef typename algebra_type::vector_type vector_type;
55 : typedef typename algebra_type::matrix_type matrix_type;
56 :
57 : public:
58 0 : void add_time_disc(SmartPtr<ITimeDiscretization<TAlgebra> > tDisc)
59 0 : {m_vTimeDisc.push_back(tDisc);}
60 :
61 : public:
62 : /**
63 : * @note This is a hack to ensure the time disc can be used with a GMG.
64 : * As the GMG calls IAssemble::ass_tuner(), and then uses
65 : * set_force_regular_grid() on it, this call must be handed down
66 : * to the individual time discs here.
67 : */
68 0 : class CompositeAssTuner
69 : : public AssemblingTuner<TAlgebra>
70 : {
71 : public:
72 : void add_ass_tuner(SmartPtr<AssemblingTuner<TAlgebra> > assTuner)
73 0 : {m_vAssTuner.push_back(assTuner);}
74 :
75 0 : void set_force_regular_grid(bool bForce)
76 : {
77 0 : for (size_t i = 0; i < m_vAssTuner.size(); ++i)
78 0 : m_vAssTuner[i]->set_force_regular_grid(bForce);
79 0 : }
80 :
81 : protected:
82 : std::vector<SmartPtr<AssemblingTuner<TAlgebra>, FreeDelete> > m_vAssTuner;
83 : };
84 :
85 : // inherited from ITimeDiscretization
86 : public:
87 : /// @copydoc ITimeDiscretization<TAlgebra>::prepare_step()
88 : virtual void prepare_step(SmartPtr<VectorTimeSeries<vector_type> > prevSol, number dt);
89 :
90 : /// @copydoc ITimeDiscretization<TAlgebra>::prepare_step_elem()
91 : virtual void prepare_step_elem
92 : (
93 : SmartPtr<VectorTimeSeries<vector_type> > prevSol,
94 : number dt,
95 : const GridLevel& gl
96 : );
97 :
98 : /// @copydoc ITimeDiscretization<TAlgebra>::finish_step()
99 : virtual void finish_step(SmartPtr<VectorTimeSeries<vector_type> > currSol);
100 :
101 : /// @copydoc ITimeDiscretization<TAlgebra>::finish_step_elem()
102 : virtual void finish_step_elem
103 : (
104 : SmartPtr<VectorTimeSeries<vector_type> > currSol,
105 : const GridLevel& gl
106 : );
107 :
108 : /// @copydoc ITimeDiscretization<TAlgebra>::future_time()
109 : virtual number future_time() const;
110 :
111 : /// @copydoc ITimeDiscretization<TAlgebra>::num_prev_steps()
112 : virtual size_t num_prev_steps() const;
113 :
114 : /// @copydoc ITimeDiscretization<TAlgebra>::num_stages()
115 : virtual size_t num_stages() const;
116 :
117 : /// @copydoc ITimeDiscretization<TAlgebra>::set_stage()
118 : virtual void set_stage(size_t stage);
119 :
120 : // inherited from IAssemble
121 : public:
122 : /// @copydoc IAssemble::assemble_jacobian
123 : void assemble_jacobian(matrix_type& J, const vector_type& u, const GridLevel& gl);
124 :
125 : /// @copydoc IAssemble::assemble_defect
126 : void assemble_defect(vector_type& d, const vector_type& u, const GridLevel& gl);
127 :
128 : /// @copydoc IAssemble::assemble_linear
129 : void assemble_linear(matrix_type& A, vector_type& b, const GridLevel& gl);
130 :
131 : /// @copydoc IAssemble::assemble_rhs(vector_type&, vector_type&, GridLevel&)
132 : void assemble_rhs(vector_type& b, const vector_type& u, const GridLevel& gl);
133 :
134 : /// @copydoc IAssemble::assemble_rhs(vector_type&, GridLevel&)
135 : void assemble_rhs(vector_type& b, const GridLevel& gl);
136 :
137 : /// @copydoc IAssemble::adjust_solution
138 : void adjust_solution(vector_type& u, const GridLevel& gl);
139 :
140 : ///\{
141 : /// @copydoc IAssemble::ass_tuner
142 : virtual SmartPtr<AssemblingTuner<TAlgebra> > ass_tuner();
143 : virtual ConstSmartPtr<AssemblingTuner<TAlgebra> > ass_tuner() const;
144 : ///\}
145 :
146 : /// @copydoc IAssemble::num_constraints
147 : virtual size_t num_constraints() const;
148 :
149 : /// @copydoc IAssemble::constraint
150 : virtual SmartPtr<IConstraint<TAlgebra> > constraint(size_t i);
151 :
152 : protected:
153 : std::vector<SmartPtr<ITimeDiscretization<TAlgebra> > > m_vTimeDisc;
154 : };
155 :
156 : } // end namespace ug
157 :
158 :
159 : /// }
160 :
161 : // include implementation
162 : #include "composite_time_disc_impl.h"
163 :
164 : #endif // __H__UG__LIB_DISC__TIME_DISC__COMBINED_TIME_DISC__
|