Mechanics of Defect Evolution Library
Loading...
Searching...
No Matches
TrialDef.h
Go to the documentation of this file.
1/* This file is part of MoDELib, the Mechanics Of Defects Evolution Library.
2 *
3 *
4 * MoDELib is distributed without any warranty under the
5 * GNU General Public License (GPL) v2 <http://www.gnu.org/licenses/>.
6 */
7
8#ifndef model_TrialDef_H_
9#define model_TrialDef_H_
10
11#include <utility>
12#include <type_traits>
13#include <TypeTraits.h>
14#include <Simplex.h>
15#include <TrialBase.h>
16#include <TrialExpressionBase.h>
17#include <memory>
18#include <stdexcept>
19
20namespace model
21{
22
23 template <typename T>
24 struct TrialDef : public TrialExpressionBase<TrialDef<T> >
25 {
26
27 typedef typename T::TrialFunctionType TrialFunctionType;
28
33 constexpr static int rows=(TrialFunctionType::dim*(TrialFunctionType::dim+1))/2;
34 constexpr static int cols=T::cols;
35 typedef Eigen::Matrix<double,rows,dofPerElement> ShapeFunctionMatrixType;
36 typedef Eigen::Matrix<double,rows,1> EvalMatrixType;
37
38 static_assert(TypeTraits<TrialFunctionType>::dim==TypeTraits<TrialFunctionType>::nComponents,"SYMMETRIC GRADIENT (DEF) CAN ONLY BE COMPUTED IF nComponents==dim.");
39
40 const std::shared_ptr<T> op;
41
42 explicit TrialDef(std::shared_ptr<T> x) : op(std::move(x))
43 {
44 if(!op)
45 {
46 throw std::invalid_argument("Null FEM expression operand.");
47 }
48 }
49
50 Eigen::Matrix<double,rows,dofPerElement> sfm(const ElementType& ele,
51 const BaryType& bary) const
52 {
53 return op->sfmDef(ele,bary);
54 }
55
56 const auto& field() const
57 {
58 return op->field();
59 }
60
61 };
62
63 template<class T, std::enable_if_t<std::is_base_of_v<TrialExpressionBase<T>,T>,int> = 0>
64 auto def(const std::shared_ptr<T>& x)
65 {
66 return std::make_shared<TrialDef<T>>(x);
67 }
68}
69#endif
x
Definition int_R.m:12
auto def(const std::shared_ptr< T > &x)
Definition TrialDef.h:64
Eigen::Matrix< double, rows, dofPerElement > ShapeFunctionMatrixType
Definition TrialDef.h:35
TrialFunctionType::TrialFunctionType TrialFunctionType
Definition TrialDef.h:27
TypeTraits< TrialFunctionType >::ElementType ElementType
Definition TrialDef.h:29
const auto & field() const
Definition TrialDef.h:56
Eigen::Matrix< double, rows, dofPerElement > sfm(const ElementType &ele, const BaryType &bary) const
Definition TrialDef.h:50
static constexpr int dofPerElement
Definition TrialDef.h:32
Eigen::Matrix< double, rows, 1 > EvalMatrixType
Definition TrialDef.h:36
TypeTraits< TrialFunctionType >::BaryType BaryType
Definition TrialDef.h:30
TrialDef(std::shared_ptr< T > x)
Definition TrialDef.h:42
const std::shared_ptr< TrialFunctionType > op
Definition TrialDef.h:40