Debian Codegraph @

src/num/aslTimeContinuations.h

raw
1 /*
2 * Advanced Simulation Library <http://asl.org.il>
3 *
4 * Copyright 2015 Avtech Scientific <http://avtechscientific.com>
5 *
6 *
7 * This file is part of Advanced Simulation Library (ASL).
8 *
9 * ASL is free software: you can redistribute it and/or modify it
10 * under the terms of the GNU Affero General Public License as
11 * published by the Free Software Foundation, version 3 of the License.
12 *
13 * ASL is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Affero General Public License for more details.
17 *
18 * You should have received a copy of the GNU Affero General Public License
19 * along with ASL. If not, see <http://www.gnu.org/licenses/>.
20 *
21 */
22
23
24 #ifndef ASLTIMECONTINUATIONS_H
25 #define ASLTIMECONTINUATIONS_H
26
27 #include "aslNumMethod.h"
28 #include <acl/aclMath/aclVectorOfElementsDef.h>
29
30 namespace acl
31 {
32 class Kernel;
33 }
34
35 namespace asl
36 {
37 class VectorTemplate;
38 template <typename V> class DataWithGhostNodes;
39 typedef DataWithGhostNodes<acl::VectorOfElementsData> DataWithGhostNodesACLData;
40 typedef std::shared_ptr<DataWithGhostNodesACLData> SPDataWithGhostNodesACLData;
41 class AbstractDataWithGhostNodes;
42 typedef std::shared_ptr<AbstractDataWithGhostNodes> SPAbstractDataWithGhostNodes;
43
44 /// Numerical method that generates temporal extrapolation of the data, Abstract class.
45 /**
46 \ingroup NumMethods
47
48 */
49 class TimeContinuations: public NumMethod
50 {
51 public:
52 typedef SPDataWithGhostNodesACLData Data;
53 protected:
54 acl::VectorOfElementsData inData;
55 double factor;
56 unsigned int nStorages;
57 TimeContinuations(Data inD, double factor);
58 TimeContinuations(acl::VectorOfElementsData & inD, double factor);
59 public:
60 void addData(Data inD);
61 void addData(acl::VectorOfElementsData & inD);
62 virtual void execute()=0;
63 virtual void init()=0;
64 /// makes reset of the contiuation (storage) cicle
65 void reset();
66 };
67
68
69 /// Numerical method that generates temporal extrapolation of the data with Lagrangian polynoms
70 /**
71 \ingroup NumMethods
72
73 The method computes Lagrange polinomial extrapolation of order \f$k\f$ in time. \p factor
74 defines extrapolation length:
75 \f[ u(t+dt*factor) = \sum_{i=0}^n y_i l_i \f]
76 where
77 \f[ l_i(x) = \prod_{j=0, j\neq i}^k \frac{x-x_j}{x_i-x_j}\f]
78 The first avalible point has \f$ t_0 = -k$. The last avalible point has \f$ t_k = 0$.
79 */
80 class TimeContinPLagrange: public TimeContinuations
81 {
82 private:
83 acl::VectorOfElements storedData;
84 std::vector<std::shared_ptr<acl::Kernel>> kernels;
85 unsigned int order;
86 std::vector<double> coefs;
87
88 public:
89 TimeContinPLagrange(Data inD, double f, unsigned int order);
90 TimeContinPLagrange(acl::VectorOfElementsData & inD, double f, unsigned int order);
91 virtual void execute();
92 virtual void init();
93 };
94
95 typedef std::shared_ptr<TimeContinPLagrange> SPTimeContinPLagrange;
96
97 /// Numerical method that generates temporal extrapolation of the data with Lagrangian polynoms of fractional argument
98 /**
99 \ingroup NumMethods
100
101 The method computes Lagrange polinomial extrapolation of order \f$k\f$ in time.
102 The time is taken in the form \f$ (t+t_s)^{-1}\f$. \p factor
103 defines extrapolation length. \f$ t_s\f$ is defined as:
104 \f[ t_s = 2 k+ factor \f]
105 The interpolation polinoms are nothing else but the Lagrange one with
106 \f$ x \f$ defined as \f$ x=(t+t_s)^{-1} \f$
107 \f[ u(t+dt*factor) = \sum_{i=0}^n y_i l_i \f]
108 where
109 \f[ l_i(x) = \prod_{j=0, j\neq i}^k \frac{x-x_j}{x_i-x_j}\f]
110
111 The first avalible point has \f$ t_0 = -k$. The last avalible point has \f$ t_k = 0$.
112
113 */
114 class TimeContinPLagrangeFraction: public TimeContinuations
115 {
116 public:
117 typedef SPDataWithGhostNodesACLData Data;
118 typedef SPAbstractDataWithGhostNodes Field;
119 private:
120 acl::VectorOfElements storedData;
121 std::vector<std::shared_ptr<acl::Kernel>> kernels;
122 unsigned int order;
123 double offset;
124 std::vector<double> coefs;
125
126 public:
127 TimeContinPLagrangeFraction(Data inD, double f, unsigned int order);
128 TimeContinPLagrangeFraction(acl::VectorOfElementsData & inD,
129 double f, unsigned int order);
130 void execute();
131 virtual void init();
132 };
133
134 typedef std::shared_ptr<TimeContinPLagrangeFraction> SPTimeContinPLagrangeFraction;
135
136
137 } // asl
138 #endif // ASLTIMECONTINUATIONS_H