Rythmos - Transient Integration for Differential Equations  Version of the Day
 All Classes Functions Variables Typedefs Pages
Rythmos_RKButcherTableauBuilder_def.hpp
1 //@HEADER
2 // ***********************************************************************
3 //
4 // Rythmos Package
5 // Copyright (2006) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // This library is free software; you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as
12 // published by the Free Software Foundation; either version 2.1 of the
13 // License, or (at your option) any later version.
14 //
15 // This library is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public
21 // License along with this library; if not, write to the Free Software
22 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
23 // USA
24 // Questions? Contact Todd S. Coffey (tscoffe@sandia.gov)
25 //
26 // ***********************************************************************
27 //@HEADER
28 
29 
30 #ifndef RYTHMOS_RK_BUTCHER_TABLEAU_BUILDER_DEF_HPP
31 #define RYTHMOS_RK_BUTCHER_TABLEAU_BUILDER_DEF_HPP
32 
33 #include "Rythmos_Types.hpp"
34 
35 #include "Rythmos_RKButcherTableauBuilder_decl.hpp"
36 #include "Rythmos_RKButcherTableau.hpp"
37 
38 namespace Rythmos {
39 
40 // Nonmember constructor
41 template<class Scalar>
42 RCP<RKButcherTableauBuilder<Scalar> > rKButcherTableauBuilder()
43 {
44  RCP<RKButcherTableauBuilder<Scalar> > rkbtfn = rcp(new RKButcherTableauBuilder<Scalar>() );
45  return rkbtfn;
46 }
47 // Nonmember helper function
48 template<class Scalar>
49 RCP<RKButcherTableauBase<Scalar> > createRKBT(const std::string& rkbt_name)
50 {
51  RCP<RKButcherTableauBuilder<Scalar> > rkbtfn = rKButcherTableauBuilder<Scalar>();
52  RCP<RKButcherTableauBase<Scalar> > rkbt = rkbtfn->create(rkbt_name);
53  return rkbt;
54 }
55 
56 template<class Scalar>
57 RKButcherTableauBuilder<Scalar>::RKButcherTableauBuilder()
58 {
59  this->initializeDefaults_();
60 }
61 
62 template<class Scalar>
63 void RKButcherTableauBuilder<Scalar>::setRKButcherTableauFactory(
64  const RCP<const Teuchos::AbstractFactory<RKButcherTableauBase<Scalar> > > &rkbtFactory,
65  const std::string &rkbtFactoryName
66  )
67 {
68  builder_.setObjectFactory(rkbtFactory, rkbtFactoryName);
69 }
70 
71 template<class Scalar>
72 void RKButcherTableauBuilder<Scalar>::setParameterList(
73  RCP<Teuchos::ParameterList> const& paramList
74  )
75 {
76  builder_.setParameterList(paramList);
77 }
78 
79 template<class Scalar>
80 RCP<Teuchos::ParameterList>
81 RKButcherTableauBuilder<Scalar>::getNonconstParameterList()
82 {
83  return builder_.getNonconstParameterList();
84 }
85 
86 
87 template<class Scalar>
88 RCP<Teuchos::ParameterList>
89 RKButcherTableauBuilder<Scalar>::unsetParameterList()
90 {
91  return builder_.unsetParameterList();
92 }
93 
94 
95 template<class Scalar>
96 RCP<const Teuchos::ParameterList>
97 RKButcherTableauBuilder<Scalar>::getParameterList() const
98 {
99  return builder_.getParameterList();
100 }
101 
102 
103 template<class Scalar>
104 RCP<const Teuchos::ParameterList>
105 RKButcherTableauBuilder<Scalar>::getValidParameters() const
106 {
107  return builder_.getValidParameters();
108 }
109 
110 template<class Scalar>
111 RCP<RKButcherTableauBase<Scalar> >
112 RKButcherTableauBuilder<Scalar>::create(
113  const std::string &rkbt_name
114  ) const
115 {
116  return builder_.create(rkbt_name);
117 }
118 
119 template<class Scalar>
120 void RKButcherTableauBuilder<Scalar>::initializeDefaults_()
121 {
122 
123  using Teuchos::abstractFactoryStd;
124 
125  builder_.setObjectName("Rythmos::RKButcherTableau");
126  builder_.setObjectTypeName("Runge Kutta Butcher Tableau Type");
127 
128  //
129  // RK Butcher Tableaus:
130  //
131 
132  // Explicit
133  builder_.setObjectFactory(
134  abstractFactoryStd< RKButcherTableauBase<Scalar>,
135  ForwardEuler_RKBT<Scalar> >(),
136  RKBT_ForwardEuler_name());
137 
138  builder_.setObjectFactory(
139  abstractFactoryStd< RKButcherTableauBase<Scalar>,
140  Explicit2Stage2ndOrderRunge_RKBT<Scalar> >(),
141  Explicit2Stage2ndOrderRunge_name());
142 
143  builder_.setObjectFactory(
144  abstractFactoryStd< RKButcherTableauBase<Scalar>,
145  ExplicitTrapezoidal_RKBT<Scalar> >(),
146  ExplicitTrapezoidal_name());
147 
148  builder_.setObjectFactory(
149  abstractFactoryStd< RKButcherTableauBase<Scalar>,
150  Explicit3Stage3rdOrder_RKBT<Scalar> >(),
151  Explicit3Stage3rdOrder_name());
152 
153  builder_.setObjectFactory(
154  abstractFactoryStd< RKButcherTableauBase<Scalar>,
155  Explicit3Stage3rdOrderHeun_RKBT<Scalar> >(),
156  Explicit3Stage3rdOrderHeun_name());
157 
158  builder_.setObjectFactory(
159  abstractFactoryStd< RKButcherTableauBase<Scalar>,
160  Explicit3Stage3rdOrderTVD_RKBT<Scalar> >(),
161  Explicit3Stage3rdOrderTVD_name());
162 
163  builder_.setObjectFactory(
164  abstractFactoryStd< RKButcherTableauBase<Scalar>,
165  Explicit2Stage2ndOrderTVD_RKBT<Scalar> >(),
166  Explicit2Stage2ndOrderTVD_name());
167 
168  builder_.setObjectFactory(
169  abstractFactoryStd< RKButcherTableauBase<Scalar>,
170  Explicit4Stage3rdOrderRunge_RKBT<Scalar> >(),
171  Explicit4Stage3rdOrderRunge_name());
172 
173  builder_.setObjectFactory(
174  abstractFactoryStd< RKButcherTableauBase<Scalar>,
175  Explicit5Stage3rdOrderKandG_RKBT<Scalar> >(),
176  Explicit5Stage3rdOrderKandG_name());
177 
178  builder_.setObjectFactory(
179  abstractFactoryStd< RKButcherTableauBase<Scalar>,
180  Explicit4Stage4thOrder_RKBT<Scalar> >(),
181  Explicit4Stage_name());
182 
183  builder_.setObjectFactory(
184  abstractFactoryStd< RKButcherTableauBase<Scalar>,
185  Explicit3_8Rule_RKBT<Scalar> >(),
186  Explicit3_8Rule_name());
187 
188  // Implicit
189  builder_.setObjectFactory(
190  abstractFactoryStd< RKButcherTableauBase<Scalar>,
191  BackwardEuler_RKBT<Scalar> >(),
192  RKBT_BackwardEuler_name());
193 
194  builder_.setObjectFactory(
195  abstractFactoryStd< RKButcherTableauBase<Scalar>,
196  IRK1StageTheta_RKBT<Scalar> >(),
197  IRK1StageTheta_name());
198 
199  builder_.setObjectFactory(
200  abstractFactoryStd< RKButcherTableauBase<Scalar>,
201  IRK2StageTheta_RKBT<Scalar> >(),
202  IRK2StageTheta_name());
203 
204  // SDIRK
205  builder_.setObjectFactory(
206  abstractFactoryStd< RKButcherTableauBase<Scalar>,
207  SDIRK2Stage2ndOrder_RKBT<Scalar> >(),
208  SDIRK2Stage2ndOrder_name());
209 
210  builder_.setObjectFactory(
211  abstractFactoryStd< RKButcherTableauBase<Scalar>,
212  SDIRK2Stage3rdOrder_RKBT<Scalar> >(),
213  SDIRK2Stage3rdOrder_name());
214 
215  builder_.setObjectFactory(
216  abstractFactoryStd< RKButcherTableauBase<Scalar>,
217  SDIRK3Stage4thOrder_RKBT<Scalar> >(),
218  SDIRK3Stage4thOrder_name());
219 
220  builder_.setObjectFactory(
221  abstractFactoryStd< RKButcherTableauBase<Scalar>,
222  SDIRK5Stage4thOrder_RKBT<Scalar> >(),
223  SDIRK5Stage4thOrder_name());
224 
225  builder_.setObjectFactory(
226  abstractFactoryStd< RKButcherTableauBase<Scalar>,
227  SDIRK5Stage5thOrder_RKBT<Scalar> >(),
228  SDIRK5Stage5thOrder_name());
229 
230  // DIRK
231  builder_.setObjectFactory(
232  abstractFactoryStd< RKButcherTableauBase<Scalar>,
233  DIRK2Stage3rdOrder_RKBT<Scalar> >(),
234  DIRK2Stage3rdOrder_name());
235 
236  // IRK
237  builder_.setObjectFactory(
238  abstractFactoryStd< RKButcherTableauBase<Scalar>,
239  Implicit1Stage2ndOrderGauss_RKBT<Scalar> >(),
240  Implicit1Stage2ndOrderGauss_name());
241 
242  builder_.setObjectFactory(
243  abstractFactoryStd< RKButcherTableauBase<Scalar>,
244  Implicit2Stage4thOrderGauss_RKBT<Scalar> >(),
245  Implicit2Stage4thOrderGauss_name());
246 
247  builder_.setObjectFactory(
248  abstractFactoryStd< RKButcherTableauBase<Scalar>,
249  Implicit3Stage6thOrderGauss_RKBT<Scalar> >(),
250  Implicit3Stage6thOrderGauss_name());
251 
252  builder_.setObjectFactory(
253  abstractFactoryStd< RKButcherTableauBase<Scalar>,
254  Implicit2Stage4thOrderHammerHollingsworth_RKBT<Scalar> >(),
255  Implicit2Stage4thOrderHammerHollingsworth_name());
256 
257  builder_.setObjectFactory(
258  abstractFactoryStd< RKButcherTableauBase<Scalar>,
259  Implicit3Stage6thOrderKuntzmannButcher_RKBT<Scalar> >(),
260  Implicit3Stage6thOrderKuntzmannButcher_name());
261 
262  // This RKBT does not pass convergence testing, so we're disbaling it for now.
263 // builder_.setObjectFactory(
264 // abstractFactoryStd< RKButcherTableauBase<Scalar>, Implicit4Stage8thOrderKuntzmannButcher_RKBT<Scalar> >(),
265 // Implicit4Stage8thOrderKuntzmannButcher_name());
266 
267  builder_.setObjectFactory(
268  abstractFactoryStd< RKButcherTableauBase<Scalar>,
269  Implicit1Stage1stOrderRadauA_RKBT<Scalar> >(),
270  Implicit1Stage1stOrderRadauA_name());
271 
272  builder_.setObjectFactory(
273  abstractFactoryStd< RKButcherTableauBase<Scalar>,
274  Implicit2Stage3rdOrderRadauA_RKBT<Scalar> >(),
275  Implicit2Stage3rdOrderRadauA_name());
276 
277  builder_.setObjectFactory(
278  abstractFactoryStd< RKButcherTableauBase<Scalar>,
279  Implicit3Stage5thOrderRadauA_RKBT<Scalar> >(),
280  Implicit3Stage5thOrderRadauA_name());
281 
282  builder_.setObjectFactory(
283  abstractFactoryStd< RKButcherTableauBase<Scalar>,
284  Implicit1Stage1stOrderRadauB_RKBT<Scalar> >(),
285  Implicit1Stage1stOrderRadauB_name());
286 
287  builder_.setObjectFactory(
288  abstractFactoryStd< RKButcherTableauBase<Scalar>,
289  Implicit2Stage3rdOrderRadauB_RKBT<Scalar> >(),
290  Implicit2Stage3rdOrderRadauB_name());
291 
292  builder_.setObjectFactory(
293  abstractFactoryStd< RKButcherTableauBase<Scalar>,
294  Implicit3Stage5thOrderRadauB_RKBT<Scalar> >(),
295  Implicit3Stage5thOrderRadauB_name());
296 
297  builder_.setObjectFactory(
298  abstractFactoryStd< RKButcherTableauBase<Scalar>,
299  Implicit2Stage2ndOrderLobattoA_RKBT<Scalar> >(),
300  Implicit2Stage2ndOrderLobattoA_name());
301 
302  builder_.setObjectFactory(
303  abstractFactoryStd< RKButcherTableauBase<Scalar>,
304  Implicit3Stage4thOrderLobattoA_RKBT<Scalar> >(),
305  Implicit3Stage4thOrderLobattoA_name());
306 
307  builder_.setObjectFactory(
308  abstractFactoryStd< RKButcherTableauBase<Scalar>,
309  Implicit4Stage6thOrderLobattoA_RKBT<Scalar> >(),
310  Implicit4Stage6thOrderLobattoA_name());
311 
312  builder_.setObjectFactory(
313  abstractFactoryStd< RKButcherTableauBase<Scalar>,
314  Implicit2Stage2ndOrderLobattoB_RKBT<Scalar> >(),
315  Implicit2Stage2ndOrderLobattoB_name());
316 
317  builder_.setObjectFactory(
318  abstractFactoryStd< RKButcherTableauBase<Scalar>,
319  Implicit3Stage4thOrderLobattoB_RKBT<Scalar> >(),
320  Implicit3Stage4thOrderLobattoB_name());
321 
322  builder_.setObjectFactory(
323  abstractFactoryStd< RKButcherTableauBase<Scalar>,
324  Implicit4Stage6thOrderLobattoB_RKBT<Scalar> >(),
325  Implicit4Stage6thOrderLobattoB_name());
326 
327  builder_.setObjectFactory(
328  abstractFactoryStd< RKButcherTableauBase<Scalar>,
329  Implicit2Stage2ndOrderLobattoC_RKBT<Scalar> >(),
330  Implicit2Stage2ndOrderLobattoC_name());
331 
332  builder_.setObjectFactory(
333  abstractFactoryStd< RKButcherTableauBase<Scalar>,
334  Implicit3Stage4thOrderLobattoC_RKBT<Scalar> >(),
335  Implicit3Stage4thOrderLobattoC_name());
336 
337  builder_.setObjectFactory(
338  abstractFactoryStd< RKButcherTableauBase<Scalar>,
339  Implicit4Stage6thOrderLobattoC_RKBT<Scalar> >(),
340  Implicit4Stage6thOrderLobattoC_name());
341 
342  builder_.setDefaultObject("None");
343 
344 }
345 
346 //
347 // Explicit Instantiation macro
348 //
349 // Must be expanded from within the Rythmos namespace!
350 //
351 
352 #define RYTHMOS_RK_BUTCHER_TABLEAU_BUILDER_INSTANT(SCALAR) \
353  \
354  template class RKButcherTableauBuilder< SCALAR >; \
355  \
356  template RCP<RKButcherTableauBuilder< SCALAR > > rKButcherTableauBuilder(); \
357  \
358  template RCP<RKButcherTableauBase< SCALAR > > createRKBT(const std::string& rkbt_name);
359 
360 
361 } // namespace Rythmos
362 
363 
364 #endif // RYTHMOS_RK_BUTCHER_TABLEAU_BUILDER_DEF_HPP