Mechanics of Defect Evolution Library
Loading...
Searching...
No Matches
LinearForm.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_LinearForm_H_
9#define model_LinearForm_H_
10
11#include <Eigen/Dense>
12#include <EvalExpression.h>
13#include <EvalFunction.h>
14#include <TestExpression.h>
15#include <memory>
16#include <stdexcept>
17
18namespace model
19{
20
21 template <typename TestType,typename EvalType>
22 struct LinearForm : public LinearWeakExpression<LinearForm<TestType,EvalType>>
23 {
24
25 static_assert(TestType::rows==EvalType::rows,"YOU ARE CREATING A LinearForm BETWEEN EXPRESSIONS WITH DIFFERENT NUMBER OF ROWS");
26
27 typedef typename TestType::TrialFunctionType TrialFunctionType;
28 constexpr static int evalCols=EvalType::cols;
29
33
37
38 const std::shared_ptr<TestExpression<TestType>> testExp;
39 const std::shared_ptr<EvalType> evalExp;
40 LinearForm(std::shared_ptr<TestExpression<TestType>> x, std::shared_ptr<EvalType> y) :
41 testExp(std::move(x)), evalExp(std::move(y))
42 {
43 if(!testExp || !evalExp)
44 {
45 throw std::invalid_argument("Null FEM expression operand.");
46 }
47 }
48
49 Eigen::Matrix<double,dofPerElement,evalCols> operator()(const ElementType& ele,
50 const BaryType& bary) const
51 {
52 return testExp->sfm(ele,bary).transpose()*(*evalExp)(ele,bary);
53 }
54
55 const auto& field() const
56 {
57 return testExp->field();
58 }
59
60 };
61
62 template<class T1,class T2, std::enable_if_t<std::is_base_of_v<EvalFunction<T2>,T2>,int> = 0>
63 auto operator,(const std::shared_ptr<TestExpression<T1>>& t,const std::shared_ptr<T2>& e)
64 {
65 return std::make_shared<LinearForm<T1,T2>>(t,e);
66 }
67
68
69}
70#endif
final point of the source segment t
x
Definition int_R.m:12
auto operator,(const std::shared_ptr< TestExpression< T1 > > &t, const std::shared_ptr< T2 > &e)
TypeTraits< TrialFunctionType >::BaryType BaryType
Definition LinearForm.h:32
static constexpr int dofPerNode
Definition LinearForm.h:35
Eigen::Matrix< double, dofPerElement, evalCols > operator()(const ElementType &ele, const BaryType &bary) const
Definition LinearForm.h:49
static constexpr int dim
Definition LinearForm.h:34
LinearForm< TestType, EvalType > LinearFormType
Definition LinearForm.h:30
const auto & field() const
Definition LinearForm.h:55
TestType::TrialFunctionType TrialFunctionType
Definition LinearForm.h:27
TypeTraits< TrialFunctionType >::ElementType ElementType
Definition LinearForm.h:31
static constexpr int evalCols
Definition LinearForm.h:28
static constexpr int dofPerElement
Definition LinearForm.h:36
const std::shared_ptr< EvalType > evalExp
Definition LinearForm.h:39
const std::shared_ptr< TestExpression< TestType > > testExp
Definition LinearForm.h:38
LinearForm(std::shared_ptr< TestExpression< TestType > > x, std::shared_ptr< EvalType > y)
Definition LinearForm.h:40
int e