Debian Codegraph @

src/num/aslFDElasticity.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 ASLFDELASTICITY_H
25 #define ASLFDELASTICITY_H
26
27 #include "aslNumMethod.h"
28 #include "acl/aclMath/aclVectorOfElementsDef.h"
29
30 namespace acl{
31 class Kernel;
32 class VectorOfElementsData;
33 }
34
35 namespace asl
36 {
37 class VectorTemplate;
38 class TemplateVE;
39
40 template <typename V> class DataWithGhostNodes;
41 typedef DataWithGhostNodes<acl::VectorOfElementsData> DataWithGhostNodesACLData;
42 typedef std::shared_ptr<DataWithGhostNodesACLData> SPDataWithGhostNodesACLData;
43 typedef DataWithGhostNodes<acl::VectorOfElements> DataWithGhostNodesACL;
44 typedef std::shared_ptr<DataWithGhostNodesACL> SPDataWithGhostNodesACL;
45
46 namespace elasticity
47 {
48 acl::VectorOfElements strain(vector<TemplateVE> & displacment);
49 acl::VectorOfElements stressLinear(acl::VectorOfElements & strain);
50 // VectorOfElements linearEqLaplasTerm(TemplateVE displacment);
51 }
52
53 /// abstract class for elasticity solver
54 class ElasticityCommonA: public NumMethod
55 {
56 public:
57 typedef SPDataWithGhostNodesACLData Data;
58 typedef acl::VectorOfElements Param;
59 protected:
60 std::unique_ptr<acl::Kernel> kernel;
61
62 Data displacementData;
63 Data displacementInternalData;
64
65 Param bulkModulus;
66 Param shearModulus;
67 Param force;
68 public:
69 const VectorTemplate* vectorTemplate;
70
71 ElasticityCommonA();
72 /**
73 \param d is a displacement field
74 \param bM is the bulk modulus
75 \param sM is the shear modulus
76 \param vT is a vector template
77 */
78 ElasticityCommonA(Data d, Param bM, Param sM, const VectorTemplate* vT);
79 ~ElasticityCommonA();
80 void setVectorTemplate(const VectorTemplate* vT);
81 VectorTemplate getVectorTemplate();
82
83 virtual void init()=0;
84 virtual void execute()=0;
85
86 void setForce(Param f);
87 inline Data getDisplacementData() const;
88 inline Data getDisplacementInternalData() const;
89 inline const Param getBulkModulus() const;
90 inline const Param getShearModulus() const;
91 };
92
93 /// Numerical method which computes homogenious isotropic elasticity equation
94 /**
95 \ingroup Elasticity
96 \ingroup NumMethods
97 */
98 class FDElasticityIncompressibleStatic: public ElasticityCommonA
99 {
100 private:
101 Data pressure;
102 Data pressureInternalData;
103 public:
104 FDElasticityIncompressibleStatic();
105 /**
106 \param d is a displacement field
107 \param bM is the bulk modulus
108 \param sM is the shear modulus
109 \param vT is a vector template
110 */
111 FDElasticityIncompressibleStatic(Data d, Param bM, Param sM, const VectorTemplate* vT);
112 ~FDElasticityIncompressibleStatic();
113
114 virtual void init();
115 virtual void execute();
116
117 inline Data getPressureData() const;
118 };
119
120 typedef std::shared_ptr<FDElasticityIncompressibleStatic> SPFDElasticityIncompressibleStatic;
121
122 /// Numerical method which computes homogenious isotropic elasticity equation
123 /**
124 \ingroup Elasticity
125 \ingroup NumMethods
126 */
127 class FDElasticityRelaxation: public ElasticityCommonA
128 {
129 private:
130 Data pressure;
131 Data pressureInternalData;
132 Param deltat;
133 Param dumpingFactor;
134 public:
135 FDElasticityRelaxation();
136 /**
137 \param d is a displacement field
138 \param bM is the bulk modulus
139 \param sM is the shear modulus
140 \param dt is time step
141 \param vT is a vector template
142 */
143 FDElasticityRelaxation(Data d, Param bM, Param sM, Param dt, const VectorTemplate* vT);
144 ~FDElasticityRelaxation();
145
146 virtual void init();
147 virtual void execute();
148
149 inline Data getPressureData() const;
150 inline Param getDeltat() const;
151 void setDumpingFactor(Param dumpF);
152 };
153
154 typedef std::shared_ptr<FDElasticityRelaxation> SPFDElasticityRelaxation;
155
156
157 /// Numerical method which computes homogenious isotropic elasticity equation
158 /**
159 \ingroup Elasticity
160 \ingroup NumMethods
161
162 \f[ \rho\ddot u_j =(K+\mu/3)\nabla_j \nabla_k u_k+ \mu \Delta u_j + \vec F \f]
163 where \f$K\f$ is the bulk modulus, \f$\mu\f$ is the shear modulus,
164 \f$\vec u\f$ is a displacement vector field, \f$ \vec F\f$ external force
165 */
166 class FDElasticity2: public ElasticityCommonA
167 {
168 private:
169 // VData velocityData;
170 Param deltat;
171 Param dumpingFactor;
172 public:
173 FDElasticity2();
174 /**
175 \param d is a displacement field
176 \param bM is the bulk modulus
177 \param sM is the shear modulus
178 \param dt is time step
179 \param vT is a vector template
180 */
181 FDElasticity2(Data d, Param bM, Param sM,
182 Param dt, const VectorTemplate* vT);
183 ~FDElasticity2();
184
185 virtual void init();
186 virtual void execute();
187 // inline VData getVelocityData() const;
188
189 inline Param getDeltat() const;
190 void setDumpingFactor(Param dumpF);
191 };
192
193 typedef std::shared_ptr<FDElasticity2> SPFDElasticity2;
194
195 /// Number of dimensions
196 /**
197 \relates FDElasticity
198 */
199 unsigned int nD(const ElasticityCommonA & e);
200
201 SPFDElasticity2 generateFDElasticity(SPDataWithGhostNodesACLData d,
202 double bM,
203 double sM,
204 double dt,
205 const VectorTemplate* vT);
206
207 SPFDElasticityIncompressibleStatic generateFDElasticityStatic(SPDataWithGhostNodesACLData d,
208 double bM,
209 double sM,
210 const VectorTemplate* vT);
211
212 SPFDElasticityRelaxation generateFDElasticityRelax(SPDataWithGhostNodesACLData d,
213 double bM,
214 double sM,
215 double dt,
216 const VectorTemplate* vT);
217
218 //-------------------------IMPLEMENTATION------------------------
219
220 inline ElasticityCommonA::Data
221 ElasticityCommonA::getDisplacementData() const
222 {
223 return displacementData;
224 }
225
226 inline ElasticityCommonA::Data ElasticityCommonA::getDisplacementInternalData() const
227 {
228 return displacementInternalData;
229 }
230
231 inline const ElasticityCommonA::Param
232 ElasticityCommonA::getBulkModulus() const
233 {
234 return bulkModulus;
235 }
236
237 inline const ElasticityCommonA::Param
238 ElasticityCommonA::getShearModulus() const
239 {
240 return shearModulus;
241 }
242
243 inline ElasticityCommonA::Data
244 FDElasticityIncompressibleStatic::getPressureData() const
245 {
246 return pressure;
247 }
248
249 inline FDElasticityRelaxation::Data
250 FDElasticityRelaxation::getPressureData() const
251 {
252 return pressure;
253 }
254
255 inline FDElasticity2::Param FDElasticity2::getDeltat() const
256 {
257 return deltat;
258 }
259
260 } // asl
261 #endif // ASLFDELASTICITY_H