Mechanics of Defect Evolution Library
Loading...
Searching...
No Matches
LinearWeakList.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_LinearWeakList_H_
9#define model_LinearWeakList_H_
10
11#include <TypeTraits.h>
12#include <TerminalColors.h>
13#include <TestExpression.h>
15#include <JGNselector.h>
16#include <IntegrationList.h>
17#include <memory>
18#include <stdexcept>
19
20namespace model
21{
22
23 template <typename TestType, typename _IntegrationListType>
24 class LinearWeakList : public LinearWeakExpression<LinearWeakList<TestType,_IntegrationListType> >
25 {
26
27 public:
28
29 typedef typename TestType::TrialFunctionType TrialFunctionType;
30
31 constexpr static int dim=TrialFunctionType::dim;
32
33 private:
34 typedef typename TypeTraits<TrialFunctionType>::ElementType ElementType;
35 constexpr static int dofPerNode=TypeTraits<TrialFunctionType>::dofPerNode;
36 constexpr static int dofPerElement=TypeTraits<TrialFunctionType>::dofPerElement;
37 typedef Eigen::Matrix<double,dofPerElement,1> ElementVectorType;
38
39 public:
40
41 const std::shared_ptr<TestExpression<TestType>> testExp;
42 const _IntegrationListType list;
43 LinearWeakList(std::shared_ptr<TestExpression<TestType>> f,const _IntegrationListType& dom) : testExp(std::move(f)), list(dom)
44 {
45 if(!testExp)
46 {
47 throw std::invalid_argument("Null FEM form.");
48 }
49 }
50
51 Eigen::Matrix<double,Eigen::Dynamic,1> globalVector() const
52 {
53 Eigen::Matrix<double,Eigen::Dynamic,1> _globalVector(Eigen::Matrix<double,Eigen::Dynamic,1>::Zero(field().gSize()));
54
55 for (size_t k=0;k<list.size();++k)
56 {
57 const ElementType& ele(list[k].ele);
58 const int f(list[k].boundaryFace);
59 const Eigen::Matrix<double,dim+1,1>& bary(list[k].domainBary);
60
61 const ElementVectorType ve(testExp->sfm(ele,bary).transpose()
62 *list[k]
63 *JGNselector<3>::jGN(ele.jGN(bary,f))
64 *list[k].weight
65 );
66
67 for (int i=0;i<dofPerElement;++i)
68 {
69 const size_t nodeID_I(i/dofPerNode);
70 const size_t nodeDof_I(i%dofPerNode);
71 const size_t gI= ele.node(nodeID_I).gID*dofPerNode+nodeDof_I;
72 _globalVector(gI) += ve(i);
73 }
74 }
75
76 return _globalVector;
77 }
78
79 const auto& field() const
80 {
81 return testExp->field();
82 }
83
84 };
85
86 template<class T,int D,class P>
87 auto operator,(const std::shared_ptr<TestExpression<T>>& t,const IntegrationList<D,P>& list)
88 {
89 return std::make_shared<LinearWeakList<T,IntegrationList<D,P>>>(t,list);
90 }
91
92}
93#endif
const std::shared_ptr< TestExpression< TestType > > testExp
Eigen::Matrix< double, Eigen::Dynamic, 1 > globalVector() const
LinearWeakList(std::shared_ptr< TestExpression< TestType > > f, const _IntegrationListType &dom)
static constexpr int dim
const auto & field() const
const _IntegrationListType list
TestType::TrialFunctionType TrialFunctionType
final point of the source segment t
function int_R syms a b c u real f
Definition int_R.m:4
auto operator,(const std::shared_ptr< TestExpression< T1 > > &t, const std::shared_ptr< T2 > &e)
static Eigen::Matrix< double, dim, 1 > jGN(const Eigen::Matrix< double, dim, 1 > &jgn)
Definition JGNselector.h:19
int k
int i