KratosMultiphysics
KRATOS Multiphysics (Kratos) is a framework for building parallel, multi-disciplinary simulation software, aiming at modularity, extensibility, and high performance. Kratos is written in C++, and counts with an extensive Python interface.
real_functions.h
Go to the documentation of this file.
1 #ifndef KRATOS_REAL_FUNCTIONS_H
2 #define KRATOS_REAL_FUNCTIONS_H
3 // /* External includes */
4 
5 // System includes
6 
7 // Project includes
8 #include "includes/variables.h"
9 
10 /* System includes */
11 #include <limits>
12 #include <iostream>
13 #include <iomanip>
14 
15 /* External includes */
16 #ifdef _OPENMP
17 #include <omp.h>
18 #endif
19 
20 /* Project includes */
21 #include "includes/define.h"
22 #include "utilities/openmp_utils.h"
23 
24 namespace Kratos
25 {
27 {
28 public:
29 
31 
33 
34 RealFunction(const double param1, const double param2):mA(param1), mB(param2){}
35 
37 
38 virtual ~RealFunction(){}
39 
40 
41 //***************************************************************************************************************
42 //***************************************************************************************************************
43 
44 virtual double Evaluate(const double x)
45 {
46  return 0.0;
47 }
48 
49 //***************************************************************************************************************
50 //***************************************************************************************************************
51 
52 virtual double CalculateDerivative(const double x)
53 {
54  return 0.0;
55 }
56 
57 //***************************************************************************************************************
58 //***************************************************************************************************************
59 
60 virtual double CalculateSecondDerivative(const double x)
61 {
62  return 0.0;
63 }
64 
65 //***************************************************************************************************************
66 //***************************************************************************************************************
67 
71 
72 
76 
78 
79 virtual std::string Info() const
80 {
81 return "";
82 }
83 
85 
86 virtual void PrintInfo(std::ostream& rOStream) const
87 {
88 }
89 
91 
92 virtual void PrintData(std::ostream& rOStream) const
93 {
94 }
95 
96 
100 
102 
103 protected:
106 double mA;
107 double mB;
108 
112 
113 
117 
118 
122 
123 
127 
131 
132 
136 
137 
139 
140 private:
141 
144 
145 
149 
153 
157 
158 
162 
163 
167 
168 
172 
174 RealFunction & operator=(RealFunction const& rOther);
175 
177 
178 }; // Class RealFunction
179 
180 
181 //***************************************************************************************************************
182 //***************************************************************************************************************
183 
185 {
186 public:
187 
188 LinearFunction(const double a, const double b): RealFunction(a, b){}
189 
191 
192 double Evaluate(const double x) override
193 {
194  return mA * x + mB;
195 }
196 
197 double CalculateDerivative(const double x) override
198 {
199  return mA;
200 }
201 
202 double CalculateSecondDerivative(const double x) override
203 {
204  return 0.0;
205 }
206 
207 };
208 
209 //***************************************************************************************************************
210 //***************************************************************************************************************
211 
213 {
214 public:
215 
216 PowerFunction(const double a, const double b, const double c):RealFunction(a, b), mC(c){}
217 
219 
220 double Evaluate(const double x) override
221 {
222  return mA * pow(x, mB) + mC;
223 }
224 
225 double CalculateDerivative(const double x) override
226 {
227  return mA * mB * pow(x, mB - 1.0);
228 }
229 
230 double CalculateSecondDerivative(const double x) override
231 {
232  return mA * mB * (mB - 1.0) * pow(x, mB - 2.0);
233 }
234 
235 private:
236 
237 double mC;
238 
239 };
240 //***************************************************************************************************************
241 //***************************************************************************************************************
242 
244 {
245 public:
246 
247 AdditionFunction(const double a, RealFunction& f, RealFunction& g):RealFunction(a, 1.0), mF(f), mG(g){}
248 
250 
251 double Evaluate(const double x) override
252 {
253  return mA * (mF.Evaluate(x) + mG.Evaluate(x));
254 }
255 
256 double CalculateDerivative(const double x) override
257 {
258  return mA * (mF.CalculateDerivative(x) + mG.CalculateDerivative(x));
259 }
260 
261 double CalculateSecondDerivative(const double x) override
262 {
264 }
265 
266 private:
267 
268 RealFunction& mF;
269 RealFunction& mG;
270 };
271 
272 //***************************************************************************************************************
273 //***************************************************************************************************************
274 
276 {
277 public:
278 
279 ProductFunction(const double a, RealFunction& f, RealFunction& g):RealFunction(a, 1.0), mF(f), mG(g){}
280 
282 
283 double Evaluate(const double x) override
284 {
285  return mA * mF.Evaluate(x) * mG.Evaluate(x);
286 }
287 
288 double CalculateDerivative(const double x) override
289 {
290  return mA * (mG.Evaluate(x) * mF.CalculateDerivative(x) + mF.Evaluate(x) * mG.CalculateDerivative(x));
291 }
292 
293 double CalculateSecondDerivative(const double x) override
294 {
296 }
297 
298 private:
299 
300 RealFunction& mF;
301 RealFunction& mG;
302 };
303 
304 //***************************************************************************************************************
305 //***************************************************************************************************************
306 
308 {
309 public:
310 
311 CompositionFunction(const double a, RealFunction& f, RealFunction& g):RealFunction(a, 1.0), mF(f), mG(g){}
312 
314 
315 double Evaluate(const double x) override
316 {
317  return mA * mF.Evaluate(mG.Evaluate(x));
318 }
319 
320 double CalculateDerivative(const double x) override
321 {
322  return mA * mF.CalculateDerivative(mG.Evaluate(x)) * mG.CalculateDerivative(x);
323 }
324 
325 double CalculateSecondDerivative(const double x) override
326 {
328 }
329 
330 private:
331 
332 RealFunction& mF;
333 RealFunction& mG;
334 };
335 
336 //***************************************************************************************************************
337 //***************************************************************************************************************
338 
340 
343 
344 
348 
349 } // namespace Kratos.
350 #endif // KRATOS_REAL_FUNCTIONS_H
Definition: real_functions.h:244
AdditionFunction(const double a, RealFunction &f, RealFunction &g)
Definition: real_functions.h:247
double CalculateDerivative(const double x) override
Definition: real_functions.h:256
~AdditionFunction()
Definition: real_functions.h:249
double CalculateSecondDerivative(const double x) override
Definition: real_functions.h:261
double Evaluate(const double x) override
Definition: real_functions.h:251
Definition: real_functions.h:308
double CalculateSecondDerivative(const double x) override
Definition: real_functions.h:325
CompositionFunction(const double a, RealFunction &f, RealFunction &g)
Definition: real_functions.h:311
double CalculateDerivative(const double x) override
Definition: real_functions.h:320
double Evaluate(const double x) override
Definition: real_functions.h:315
~CompositionFunction()
Definition: real_functions.h:313
Definition: real_functions.h:185
double CalculateDerivative(const double x) override
Definition: real_functions.h:197
double CalculateSecondDerivative(const double x) override
Definition: real_functions.h:202
double Evaluate(const double x) override
Definition: real_functions.h:192
LinearFunction(const double a, const double b)
Definition: real_functions.h:188
~LinearFunction()
Definition: real_functions.h:190
Definition: real_functions.h:213
double Evaluate(const double x) override
Definition: real_functions.h:220
double CalculateDerivative(const double x) override
Definition: real_functions.h:225
PowerFunction(const double a, const double b, const double c)
Definition: real_functions.h:216
~PowerFunction()
Definition: real_functions.h:218
double CalculateSecondDerivative(const double x) override
Definition: real_functions.h:230
Definition: real_functions.h:276
double CalculateDerivative(const double x) override
Definition: real_functions.h:288
double Evaluate(const double x) override
Definition: real_functions.h:283
~ProductFunction()
Definition: real_functions.h:281
ProductFunction(const double a, RealFunction &f, RealFunction &g)
Definition: real_functions.h:279
double CalculateSecondDerivative(const double x) override
Definition: real_functions.h:293
Definition: real_functions.h:27
virtual ~RealFunction()
Destructor.
Definition: real_functions.h:38
KRATOS_CLASS_POINTER_DEFINITION(RealFunction)
virtual double CalculateDerivative(const double x)
Definition: real_functions.h:52
virtual double Evaluate(const double x)
Definition: real_functions.h:44
virtual double CalculateSecondDerivative(const double x)
Definition: real_functions.h:60
RealFunction(const double param1, const double param2)
Default constructor.
Definition: real_functions.h:34
virtual void PrintInfo(std::ostream &rOStream) const
Print information about this object.
Definition: real_functions.h:86
virtual void PrintData(std::ostream &rOStream) const
Print object's data.
Definition: real_functions.h:92
virtual std::string Info() const
Turn back information as a stemplate<class T, std::size_t dim> tring.
Definition: real_functions.h:79
double mB
Definition: real_functions.h:107
double mA
Definition: real_functions.h:106
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
f
Definition: generate_convection_diffusion_explicit_element.py:112
a
Definition: generate_stokes_twofluid_element.py:77
b
Definition: generate_total_lagrangian_mixed_volumetric_strain_element.py:31
c
Definition: generate_weakly_compressible_navier_stokes_element.py:108
x
Definition: sensitivityMatrix.py:49