waves
Basic FE playground
wCompiledFct.h
Go to the documentation of this file.
1 /*
2  * Copyright 2022 University of Liège
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef WCOMPILEDFCT_H
18 #define WCOMPILEDFCT_H
19 
20 #include "heat.h"
21 #include "wFct0.h"
22 #include "wFct1.h"
23 #include "wFct2.h"
24 
25 using namespace tbox;
26 
27 namespace heat
28 {
29 
34 class HEAT_API CompiledFct1a : public Fct0XYZ
35 {
36  double k1, k2;
37 
38 public:
39  CompiledFct1a(double _k1, double _k2) : k1(_k1), k2(_k2) {}
40 
41  virtual double eval(Eigen::Vector3d const &pos) const override
42  {
43  double x = pos(0);
44  double y = pos(1);
45  double L = 1;
46  return (k1 + k2) / 2 + fabs(k2 - k1) / 2 * sin(2 * M_PI / L * 4 * (x + y / 2));
47  }
48 };
49 
54 class HEAT_API CompiledFct1b : public Fct2XYZ
55 {
56  double k1, k2;
57 
58 public:
59  CompiledFct1b(double _k1, double _k2) : k1(_k1), k2(_k2) {}
60 
61  virtual void eval(Eigen::Vector3d const &pos, Eigen::MatrixXd &out, bool fake) const override
62  {
63  double x = pos(0);
64  double y = pos(1);
65  double L = 1;
66  out.resize(2, 2);
67  out(1, 1) = out(0, 0) = (k1 + k2) / 2 + fabs(k2 - k1) / 2 * sin(2 * M_PI / L * 4 * (x + y / 2));
68  out(0, 1) = out(1, 0) = 0.0;
69  }
70 };
71 
75 class HEAT_API CompiledFct2a : public Fct0U
76 {
77 public:
79 
80  virtual double eval(double u) const override
81  {
82  return 10 + u * u;
83  }
84 };
85 
89 class HEAT_API CompiledFct2b : public Fct2U
90 {
91 public:
93 
94  virtual void eval(double u, Eigen::MatrixXd &out, bool fake) const override
95  {
96  out.resize(2, 2);
97  out(0, 0) = out(1, 1) = 10 + u * u;
98  out(0, 1) = out(1, 0) = u * u;
99  }
100 };
101 
102 }; // namespace heat
103 
104 #endif //WCOMPILEDFCT_H
heat::CompiledFct1a::k2
double k2
Definition: wCompiledFct.h:36
HEAT_API
#define HEAT_API
Definition: heat.h:29
heat::CompiledFct2a::CompiledFct2a
CompiledFct2a()
Definition: wCompiledFct.h:78
heat::CompiledFct1b
cfr heat_vark.py (version matricielle)
Definition: wCompiledFct.h:54
heat
this namespace avoids conflicts with similar names in 'waves'
Definition: heat.h:38
heat::CompiledFct1a::eval
virtual double eval(Eigen::Vector3d const &pos) const override
Definition: wCompiledFct.h:41
heat::CompiledFct1b::k2
double k2
Definition: wCompiledFct.h:56
heat::CompiledFct1a
cfr heat_vark.py (version scalaire)
Definition: wCompiledFct.h:34
heat::CompiledFct2b::CompiledFct2b
CompiledFct2b()
Definition: wCompiledFct.h:92
heat::CompiledFct2a
cfr heat_nl.py (version scalaire)
Definition: wCompiledFct.h:75
heat.h
heat::CompiledFct2b
cfr heat_nl.py (version matricielle)
Definition: wCompiledFct.h:89
heat::CompiledFct1b::eval
virtual void eval(Eigen::Vector3d const &pos, Eigen::MatrixXd &out, bool fake) const override
Definition: wCompiledFct.h:61
heat::CompiledFct1a::CompiledFct1a
CompiledFct1a(double _k1, double _k2)
Definition: wCompiledFct.h:39
heat::CompiledFct2b::eval
virtual void eval(double u, Eigen::MatrixXd &out, bool fake) const override
Definition: wCompiledFct.h:94
heat::CompiledFct1b::CompiledFct1b
CompiledFct1b(double _k1, double _k2)
Definition: wCompiledFct.h:59
heat::CompiledFct2a::eval
virtual double eval(double u) const override
Definition: wCompiledFct.h:80