Line |
Branch |
Exec |
Source |
1 |
|
|
// ______ ______ _ _ _____ ______ |
2 |
|
|
// | ____| ____| | (_)/ ____| | ____| |
3 |
|
|
// | |__ | |__ | | _| (___ ___| |__ |
4 |
|
|
// | __| | __| | | | |\___ \ / __| __| |
5 |
|
|
// | | | |____| |____| |____) | (__| |____ |
6 |
|
|
// |_| |______|______|_|_____/ \___|______| |
7 |
|
|
// Finite Elements for Life Sciences and Engineering |
8 |
|
|
// |
9 |
|
|
// License: LGL2.1 License |
10 |
|
|
// FELiScE default license: LICENSE in root folder |
11 |
|
|
// |
12 |
|
|
// Main authors: Vicente Mataix Ferrandiz |
13 |
|
|
// |
14 |
|
|
|
15 |
|
|
#ifndef __FELISCE_HYPER_ELASTICITY_LAW_HPP |
16 |
|
|
# define __FELISCE_HYPER_ELASTICITY_LAW_HPP |
17 |
|
|
|
18 |
|
|
// System includes |
19 |
|
|
#include <vector> |
20 |
|
|
#include <array> |
21 |
|
|
#include <bitset> |
22 |
|
|
#include <cmath> |
23 |
|
|
#include <exception> |
24 |
|
|
#include <unordered_map> |
25 |
|
|
|
26 |
|
|
// External includes |
27 |
|
|
|
28 |
|
|
// Project includes |
29 |
|
|
#include "Core/shared_pointers.hpp" |
30 |
|
|
#include "Core/felisce_error.hpp" |
31 |
|
|
|
32 |
|
|
namespace felisce |
33 |
|
|
{ |
34 |
|
|
///@name felisce Globals |
35 |
|
|
///@{ |
36 |
|
|
|
37 |
|
|
///@} |
38 |
|
|
///@name Type Definitions |
39 |
|
|
///@{ |
40 |
|
|
|
41 |
|
|
///@} |
42 |
|
|
///@name Enum's |
43 |
|
|
///@{ |
44 |
|
|
|
45 |
|
|
///@} |
46 |
|
|
///@name Functions |
47 |
|
|
///@{ |
48 |
|
|
|
49 |
|
|
///@} |
50 |
|
|
///@name felisce Classes |
51 |
|
|
///@{ |
52 |
|
|
|
53 |
|
|
struct ErrorUninitializedHyperElasticLaw : public std::exception { |
54 |
|
|
~ErrorUninitializedHyperElasticLaw() noexcept override; |
55 |
|
|
|
56 |
|
|
// Default constructor. |
57 |
|
✗ |
ErrorUninitializedHyperElasticLaw() = default; |
58 |
|
|
|
59 |
|
|
// Copy constructor, to avoid warning due to user-declared destructor. |
60 |
|
|
ErrorUninitializedHyperElasticLaw(const ErrorUninitializedHyperElasticLaw&) = default; |
61 |
|
|
|
62 |
|
|
const char* what() const noexcept override; |
63 |
|
|
}; |
64 |
|
|
|
65 |
|
|
class ErrorInvalidParameter : public std::exception { |
66 |
|
|
|
67 |
|
|
public: |
68 |
|
|
|
69 |
|
|
/*! |
70 |
|
|
* \brief Constructor. |
71 |
|
|
* |
72 |
|
|
* \param[in] parametersStatus Specifies which parameters are not properly initialized |
73 |
|
|
* First index is true if poisson is not properly std::set |
74 |
|
|
* Second stands for young |
75 |
|
|
* Third for bulk. |
76 |
|
|
*/ |
77 |
|
|
ErrorInvalidParameter(std::bitset<3> parametersStatus); |
78 |
|
|
|
79 |
|
✗ |
~ErrorInvalidParameter() noexcept override = default; |
80 |
|
|
|
81 |
|
|
// Copy constructor, to avoid warning due to user-declared destructor. |
82 |
|
|
ErrorInvalidParameter(const ErrorInvalidParameter&) = default; |
83 |
|
|
|
84 |
|
|
// what() overload |
85 |
|
|
const char* what() const noexcept override; |
86 |
|
|
|
87 |
|
|
|
88 |
|
|
private: |
89 |
|
|
|
90 |
|
|
// Message to be displayed by what() |
91 |
|
|
std::string m_message; |
92 |
|
|
}; |
93 |
|
|
|
94 |
|
|
/** |
95 |
|
|
* \brief HyperElasticityLaw law |
96 |
|
|
*/ |
97 |
|
|
class HyperElasticLaw |
98 |
|
|
{ |
99 |
|
|
public: |
100 |
|
|
///@name Type Definitions |
101 |
|
|
///@{ |
102 |
|
|
|
103 |
|
|
/// Pointer definition of HyperElasticLaw |
104 |
|
|
FELISCE_CLASS_POINTER_DEFINITION(HyperElasticLaw); |
105 |
|
|
|
106 |
|
|
///@} |
107 |
|
|
///@name Life Cycle |
108 |
|
|
///@{ |
109 |
|
|
|
110 |
|
|
// Constructor |
111 |
|
|
explicit HyperElasticLaw(); |
112 |
|
|
|
113 |
|
|
// Destructor |
114 |
|
3412 |
virtual ~HyperElasticLaw() = default; |
115 |
|
|
|
116 |
|
|
///@} |
117 |
|
|
///@name Operators |
118 |
|
|
///@{ |
119 |
|
|
|
120 |
|
|
///@} |
121 |
|
|
///@name Operations |
122 |
|
|
///@{ |
123 |
|
|
|
124 |
|
|
/*! |
125 |
|
|
* \brief Initialise the arguments kappa1, kappa2 and bulk from the input parameter file. |
126 |
|
|
* |
127 |
|
|
* If left undefined there will be an exception when the methods are called. |
128 |
|
|
*/ |
129 |
|
|
virtual void InitParameters(); |
130 |
|
|
|
131 |
|
|
// Function W |
132 |
|
|
virtual double W() const; |
133 |
|
|
|
134 |
|
|
// Derivative of W with respect of first invariant (dWdI1) |
135 |
|
|
virtual double FirstDerivativeWFirstInvariant() const; |
136 |
|
|
|
137 |
|
|
// Derivative of W with respect of second invariant (dWdI2) |
138 |
|
|
virtual double FirstDerivativeWSecondInvariant() const; |
139 |
|
|
|
140 |
|
|
// Derivative of W with respect of third invariant (dWdI3) |
141 |
|
|
virtual double FirstDerivativeWThirdInvariant() const; |
142 |
|
|
|
143 |
|
|
// Second derivative of W with respect of first invariant (d2WdI1dI1) |
144 |
|
|
virtual double SecondDerivativeWFirstInvariant() const; |
145 |
|
|
|
146 |
|
|
// Second derivative of W with respect of second invariant (d2WdI2dI2) |
147 |
|
|
virtual double SecondDerivativeWSecondInvariant() const; |
148 |
|
|
|
149 |
|
|
// Second derivative of W with respect of third invariant (d2WdI3dI3) |
150 |
|
|
virtual double SecondDerivativeWThirdInvariant() const; |
151 |
|
|
|
152 |
|
|
// Second derivative of W with respect of first and second invariant (d2WdI1dI2) |
153 |
|
|
virtual double SecondDerivativeWFirstAndSecondInvariant() const; |
154 |
|
|
|
155 |
|
|
// Second derivative of W with respect of first and third invariant (d2WdI1dI3) |
156 |
|
|
virtual double SecondDerivativeWFirstAndThirdInvariant() const; |
157 |
|
|
|
158 |
|
|
// Second derivative of W with respect of second and third invariant (d2WdI2dI3) |
159 |
|
|
virtual double SecondDerivativeWSecondAndThirdInvariant() const; |
160 |
|
|
|
161 |
|
|
// Function Wc (for incompressible case). |
162 |
|
|
virtual double Wc(const double pressure) const; |
163 |
|
|
|
164 |
|
|
// Derivative of Wc with respect of third invariant (dWcdI3) (for incompressible case). |
165 |
|
|
virtual double FirstDerivativeWcThirdInvariant(const double pressure) const; |
166 |
|
|
|
167 |
|
|
// Second derivative of Wc with respect of third invariant (d2WcdI3dI3) (for incompressible case). |
168 |
|
|
virtual double SecondDerivativeWcThirdInvariant(const double pressure) const; |
169 |
|
|
|
170 |
|
|
///@} |
171 |
|
|
///@name Access |
172 |
|
|
///@{ |
173 |
|
|
|
174 |
|
|
/** |
175 |
|
|
* @brief Sets the invariants |
176 |
|
|
* @details An exception will be thrown if a calculation method is called before this method has been called. |
177 |
|
|
* Contrary to #InitKappasAndBulk(), this method should be called multiple times in a given problem |
178 |
|
|
* (for each dof) |
179 |
|
|
* @param I1 The first invariant |
180 |
|
|
* @param I2 The first invariant |
181 |
|
|
* @param I3 The first invariant |
182 |
|
|
*/ |
183 |
|
2314 |
virtual void SetInvariants(const double I1, const double I2, const double I3) |
184 |
|
|
{ |
185 |
|
2314 |
m_invariants[0] = I1; |
186 |
|
2314 |
m_invariants[1] = I2; |
187 |
|
2314 |
m_invariants[2] = I3; |
188 |
|
2314 |
m_isInitialised.set(static_cast<std::size_t>(index_invariants_)); |
189 |
|
2314 |
} |
190 |
|
|
|
191 |
|
|
/** |
192 |
|
|
* @brief Sets the invariants |
193 |
|
|
* @details An exception will be thrown if a calculation method is called before this method has been called. |
194 |
|
|
* Contrary to #InitKappasAndBulk(), this method should be called multiple times in a given problem |
195 |
|
|
* (for each dof) |
196 |
|
|
* @param rInvariants The invariants |
197 |
|
|
*/ |
198 |
|
1578000 |
virtual void SetInvariants(const std::array<double, 3>& rInvariants) |
199 |
|
|
{ |
200 |
|
1578000 |
m_invariants = rInvariants; |
201 |
|
1578000 |
m_isInitialised.set(static_cast<std::size_t>(index_invariants_)); |
202 |
|
1578000 |
} |
203 |
|
|
|
204 |
|
|
/** |
205 |
|
|
* @brief Gets the invariants |
206 |
|
|
* @return The invariants |
207 |
|
|
*/ |
208 |
|
|
std::array<double, 3>& GetInvariants() |
209 |
|
|
{ |
210 |
|
|
return m_invariants; |
211 |
|
|
} |
212 |
|
|
|
213 |
|
|
/** |
214 |
|
|
* @brief Sets the bulk value |
215 |
|
|
* @param Bult The bulk value |
216 |
|
|
*/ |
217 |
|
|
void SetBulk(const double Bulk) |
218 |
|
|
{ |
219 |
|
|
m_bulk = Bulk; |
220 |
|
|
} |
221 |
|
|
|
222 |
|
|
/** |
223 |
|
|
* @brief Gets the bulk value |
224 |
|
|
* @return The bulk value |
225 |
|
|
*/ |
226 |
|
|
double& GetBulk() |
227 |
|
|
{ |
228 |
|
|
return m_bulk; |
229 |
|
|
} |
230 |
|
|
|
231 |
|
|
///@} |
232 |
|
|
///@name Inquiry |
233 |
|
|
///@{ |
234 |
|
|
|
235 |
|
|
///@} |
236 |
|
|
///@name Input and output |
237 |
|
|
///@{ |
238 |
|
|
|
239 |
|
|
/** |
240 |
|
|
* @brief This returns the name of the hyperlastic law |
241 |
|
|
* @return The name of the hyperlastic law |
242 |
|
|
*/ |
243 |
|
✗ |
virtual std::string name() |
244 |
|
|
{ |
245 |
|
✗ |
return "HyperElasticLaw"; |
246 |
|
|
} |
247 |
|
|
|
248 |
|
|
///@} |
249 |
|
|
///@name Friends |
250 |
|
|
///@{ |
251 |
|
|
|
252 |
|
|
///@} |
253 |
|
|
protected: |
254 |
|
|
///@name Protected Life Cycle |
255 |
|
|
///@{ |
256 |
|
|
|
257 |
|
|
///@} |
258 |
|
|
///@name Protected static Member Variables |
259 |
|
|
///@{ |
260 |
|
|
|
261 |
|
|
///@} |
262 |
|
|
///@name Protected member Variables |
263 |
|
|
///@{ |
264 |
|
|
|
265 |
|
|
enum InitIndexes { |
266 |
|
|
index_invariants_ = 0, |
267 |
|
|
index_kappaAndBulk_ = 1, |
268 |
|
|
NinitConditions_ = 2 |
269 |
|
|
}; |
270 |
|
|
|
271 |
|
|
// Vector storing the invariants. |
272 |
|
|
std::array<double, 3> m_invariants; |
273 |
|
|
|
274 |
|
|
// Bulk |
275 |
|
|
double m_bulk; |
276 |
|
|
|
277 |
|
|
/*! |
278 |
|
|
* \brief Each bitset describes whether a quantity has been initialized or not. |
279 |
|
|
* |
280 |
|
|
* Meaning of each bitset is stored in InitIndexes. |
281 |
|
|
*/ |
282 |
|
|
std::bitset<static_cast<std::size_t>(NinitConditions_)> m_isInitialised; |
283 |
|
|
|
284 |
|
|
///@} |
285 |
|
|
///@name Protected Operators |
286 |
|
|
///@{ |
287 |
|
|
|
288 |
|
|
///@} |
289 |
|
|
///@name Protected Operations |
290 |
|
|
///@{ |
291 |
|
|
|
292 |
|
|
// Throws an exception if a method is called without initialisation properly completed. |
293 |
|
|
// \todo: At the moment it is always performed; later it should be checked only in debug mode |
294 |
|
|
void checkInitDone() const; |
295 |
|
|
|
296 |
|
|
///@} |
297 |
|
|
///@name Protected Operators |
298 |
|
|
///@{ |
299 |
|
|
|
300 |
|
|
///@} |
301 |
|
|
///@name Protected Operations |
302 |
|
|
///@{ |
303 |
|
|
|
304 |
|
|
///@} |
305 |
|
|
///@name Protected Access |
306 |
|
|
///@{ |
307 |
|
|
|
308 |
|
|
///@} |
309 |
|
|
///@name Protected Inquiry |
310 |
|
|
///@{ |
311 |
|
|
|
312 |
|
|
///@} |
313 |
|
|
///@name Protected LifeCycle |
314 |
|
|
///@{ |
315 |
|
|
|
316 |
|
|
///@} |
317 |
|
|
private: |
318 |
|
|
///@name Private Life Cycle |
319 |
|
|
///@{ |
320 |
|
|
|
321 |
|
|
// Forbid recopy, move, etc... |
322 |
|
|
HyperElasticLaw(const HyperElasticLaw&); |
323 |
|
|
|
324 |
|
|
HyperElasticLaw(HyperElasticLaw&&) noexcept ; |
325 |
|
|
|
326 |
|
|
///@} |
327 |
|
|
///@name Private Operators |
328 |
|
|
///@{ |
329 |
|
|
|
330 |
|
|
HyperElasticLaw operator=(const HyperElasticLaw); |
331 |
|
|
|
332 |
|
|
///@} |
333 |
|
|
///@name Private Operations |
334 |
|
|
///@{ |
335 |
|
|
|
336 |
|
|
///@} |
337 |
|
|
///@name Private static Member Variables |
338 |
|
|
///@{ |
339 |
|
|
|
340 |
|
|
///@} |
341 |
|
|
///@name Private member Variables |
342 |
|
|
///@{ |
343 |
|
|
|
344 |
|
|
///@} |
345 |
|
|
///@name Private Operators |
346 |
|
|
///@{ |
347 |
|
|
|
348 |
|
|
///@} |
349 |
|
|
///@name Private Operations |
350 |
|
|
///@{ |
351 |
|
|
|
352 |
|
|
///@} |
353 |
|
|
///@name Private Access |
354 |
|
|
///@{ |
355 |
|
|
|
356 |
|
|
///@} |
357 |
|
|
///@name Private Inquiry |
358 |
|
|
///@{ |
359 |
|
|
|
360 |
|
|
///@} |
361 |
|
|
///@name Private LifeCycle |
362 |
|
|
///@{ |
363 |
|
|
|
364 |
|
|
///@} |
365 |
|
|
}; |
366 |
|
|
|
367 |
|
|
/** |
368 |
|
|
* \brief HyperElasticityLaw database |
369 |
|
|
*/ |
370 |
|
|
class HyperElasticityLawDatabase |
371 |
|
|
{ |
372 |
|
|
public: |
373 |
|
|
///@name Type Definitions |
374 |
|
|
///@{ |
375 |
|
|
|
376 |
|
|
/// The database type |
377 |
|
|
typedef std::unordered_map<std::string, const HyperElasticLaw::Pointer> HyperElasticityLawDatabaseType; |
378 |
|
|
|
379 |
|
|
///@} |
380 |
|
|
///@name Life Cycle |
381 |
|
|
///@{ |
382 |
|
|
|
383 |
|
|
///@} |
384 |
|
|
///@name Operators |
385 |
|
|
///@{ |
386 |
|
|
|
387 |
|
|
///@} |
388 |
|
|
///@name Operations |
389 |
|
|
///@{ |
390 |
|
|
|
391 |
|
|
///@} |
392 |
|
|
///@name Static Member Variables |
393 |
|
|
///@{ |
394 |
|
|
|
395 |
|
|
static HyperElasticityLawDatabaseType DatabaseOfHyperelasticLaws; |
396 |
|
|
|
397 |
|
|
///@} |
398 |
|
|
}; |
399 |
|
|
|
400 |
|
|
/** |
401 |
|
|
* \brief HyperElasticityLaw manager |
402 |
|
|
*/ |
403 |
|
|
class HyperElasticityLawManager |
404 |
|
|
{ |
405 |
|
|
public: |
406 |
|
|
///@name Type Definitions |
407 |
|
|
///@{ |
408 |
|
|
|
409 |
|
|
/// Pointer definition of HyperElasticityLawManager |
410 |
|
|
FELISCE_CLASS_POINTER_DEFINITION(HyperElasticityLawManager); |
411 |
|
|
|
412 |
|
|
/// The database type |
413 |
|
|
typedef std::unordered_map<int, HyperElasticLaw::Pointer> HyperElasticityLawManagerType; |
414 |
|
|
|
415 |
|
|
///@} |
416 |
|
|
///@name Life Cycle |
417 |
|
|
///@{ |
418 |
|
|
|
419 |
|
|
/// Default constructor |
420 |
|
|
HyperElasticityLawManager(); |
421 |
|
|
|
422 |
|
|
/// Default destructor |
423 |
|
✗ |
~HyperElasticityLawManager() = default; |
424 |
|
|
|
425 |
|
|
///@} |
426 |
|
|
///@name Operators |
427 |
|
|
///@{ |
428 |
|
|
|
429 |
|
|
///@} |
430 |
|
|
///@name Operations |
431 |
|
|
///@{ |
432 |
|
|
|
433 |
|
|
/** |
434 |
|
|
* @brief Retrieves the HyperElasticLaw corresponding to the given Label |
435 |
|
|
* @param LabelElement The label corresponding to the element |
436 |
|
|
*/ |
437 |
|
|
HyperElasticLaw::Pointer GetHyperElasticLaw(const int LabelElement); |
438 |
|
|
|
439 |
|
|
/** |
440 |
|
|
* @brief Inits all the laws |
441 |
|
|
*/ |
442 |
|
|
void InitParameters(); |
443 |
|
|
|
444 |
|
|
///@} |
445 |
|
|
///@name Access |
446 |
|
|
///@{ |
447 |
|
|
|
448 |
|
|
/** |
449 |
|
|
* @brief Gets the invariants |
450 |
|
|
* @return The invariants |
451 |
|
|
*/ |
452 |
|
|
HyperElasticityLawManagerType& GetHyperElasticityLawManager() |
453 |
|
|
{ |
454 |
|
|
return mDatabaseOfHyperelasticLaws; |
455 |
|
|
} |
456 |
|
|
|
457 |
|
|
///@} |
458 |
|
|
///@name Inquiry |
459 |
|
|
///@{ |
460 |
|
|
|
461 |
|
|
///@} |
462 |
|
|
///@name Input and output |
463 |
|
|
///@{ |
464 |
|
|
|
465 |
|
|
///@} |
466 |
|
|
///@name Friends |
467 |
|
|
///@{ |
468 |
|
|
|
469 |
|
|
///@} |
470 |
|
|
protected: |
471 |
|
|
///@name Protected Life Cycle |
472 |
|
|
///@{ |
473 |
|
|
|
474 |
|
|
///@} |
475 |
|
|
///@name Protected static Member Variables |
476 |
|
|
///@{ |
477 |
|
|
|
478 |
|
|
///@} |
479 |
|
|
///@name Protected member Variables |
480 |
|
|
///@{ |
481 |
|
|
|
482 |
|
|
///@} |
483 |
|
|
///@name Protected Operators |
484 |
|
|
///@{ |
485 |
|
|
|
486 |
|
|
///@} |
487 |
|
|
///@name Protected Operations |
488 |
|
|
///@{ |
489 |
|
|
|
490 |
|
|
///@} |
491 |
|
|
///@name Protected Operators |
492 |
|
|
///@{ |
493 |
|
|
|
494 |
|
|
///@} |
495 |
|
|
///@name Protected Operations |
496 |
|
|
///@{ |
497 |
|
|
|
498 |
|
|
///@} |
499 |
|
|
///@name Protected Access |
500 |
|
|
///@{ |
501 |
|
|
|
502 |
|
|
///@} |
503 |
|
|
///@name Protected Inquiry |
504 |
|
|
///@{ |
505 |
|
|
|
506 |
|
|
///@} |
507 |
|
|
///@name Protected LifeCycle |
508 |
|
|
///@{ |
509 |
|
|
|
510 |
|
|
///@} |
511 |
|
|
private: |
512 |
|
|
///@name Private Life Cycle |
513 |
|
|
///@{ |
514 |
|
|
|
515 |
|
|
///@} |
516 |
|
|
///@name Private Operators |
517 |
|
|
///@{ |
518 |
|
|
|
519 |
|
|
///@} |
520 |
|
|
///@name Private Operations |
521 |
|
|
///@{ |
522 |
|
|
|
523 |
|
|
///@} |
524 |
|
|
///@name Private static Member Variables |
525 |
|
|
///@{ |
526 |
|
|
|
527 |
|
|
///@} |
528 |
|
|
///@name Private member Variables |
529 |
|
|
///@{ |
530 |
|
|
|
531 |
|
|
HyperElasticityLawManagerType mDatabaseOfHyperelasticLaws; /// The database of the hyperelasticlaws |
532 |
|
|
|
533 |
|
|
///@} |
534 |
|
|
///@name Private Operators |
535 |
|
|
///@{ |
536 |
|
|
|
537 |
|
|
///@} |
538 |
|
|
///@name Private Operations |
539 |
|
|
///@{ |
540 |
|
|
|
541 |
|
|
///@} |
542 |
|
|
///@name Private Access |
543 |
|
|
///@{ |
544 |
|
|
|
545 |
|
|
///@} |
546 |
|
|
///@name Private Inquiry |
547 |
|
|
///@{ |
548 |
|
|
|
549 |
|
|
///@} |
550 |
|
|
///@name Private LifeCycle |
551 |
|
|
///@{ |
552 |
|
|
|
553 |
|
|
///@} |
554 |
|
|
}; |
555 |
|
|
|
556 |
|
|
///@} |
557 |
|
|
///@name Type Definitions |
558 |
|
|
///@{ |
559 |
|
|
|
560 |
|
|
///@} |
561 |
|
|
|
562 |
|
|
} // namespace felisce |
563 |
|
|
|
564 |
|
|
#endif // __FELISCE_HYPER_ELASTICITY_LAW_HPP |
565 |
|
|
|