Mechanics of Defect Evolution Library
Loading...
Searching...
No Matches
LinearWeakForm.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_LinearWeakForm_H_
9#define model_LinearWeakForm_H_
10
11#include <chrono>
12#include <vector>
13
14#include <Eigen/Dense>
15
16#include <TerminalColors.h>
17#include <IntegrationDomain.h>
19#include <LinearForm.h>
20#include <LinearWeakSum.h>
21#include <LinearWeakDiff.h>
22#include <LinearWeakAssembler.h>
23
24#include <memory>
25#include <stdexcept>
26
27namespace model
28{
29
30 template <typename _LinearFormType, typename _IntegrationDomainType>
31 struct LinearWeakForm : public LinearWeakExpression<LinearWeakForm<_LinearFormType,_IntegrationDomainType> >
32 {
33
34 typedef _LinearFormType LinearFormType;
35 typedef _IntegrationDomainType IntegrationDomainType;
37
38 typedef typename LinearFormType::TrialFunctionType TrialFunctionType;
39 constexpr static int dim=IntegrationDomainType::dim;
40 static_assert(dim==TypeTraits<TrialFunctionType>::dim, "dim MUST BE THE SAME");
41 constexpr static int domainDim=IntegrationDomainType::domainDim;
42 static_assert(domainDim==dim || domainDim==dim-1, "DOMAIN DIMENSIONALITY MUST BE EITHER dim (volume integration) OR dim-1 (boundary integration)");
43
44 const std::shared_ptr<LinearFormType> linearForm;
45
47 LinearWeakForm(std::shared_ptr<LinearFormType> f,const IntegrationDomainType& dom) : linearForm(std::move(f)), domain(dom)
48 {
49 if(!linearForm)
50 {
51 throw std::invalid_argument("Null FEM form.");
52 }
53 domain.validateSpace(field().fe());
54 }
55
56
57
58
59 Eigen::Matrix<double,Eigen::Dynamic,1> globalVector() const
60 {
61 domain.validateSpace(field().fe());
62 return LinearWeakAssembler<LinearWeakFormType,dim-domainDim>(*this).assemble();
63 }
64
65 const auto& field() const
66 {
67 return linearForm->field();
68 }
69
70 };
71
72 template<class T1,class T2,class FE,int D,int Q,template<short unsigned int,size_t> class Rule>
73 auto operator*(const std::shared_ptr<LinearForm<T1,T2>>& f,const IntegrationDomain<FE,D,Q,Rule>& dom)
74 {
75 return std::make_shared<LinearWeakForm<LinearForm<T1,T2>,IntegrationDomain<FE,D,Q,Rule>>>(f,dom);
76 }
77
78}
79#endif
function int_R syms a b c u real f
Definition int_R.m:4
auto operator*(const std::shared_ptr< BilinearForm< T1, T2 > > &f, const IntegrationDomain< FE, D, Q, Rule > &dom)
_IntegrationDomainType IntegrationDomainType
_LinearFormType LinearFormType
LinearWeakForm(std::shared_ptr< LinearFormType > f, const IntegrationDomainType &dom)
Eigen::Matrix< double, Eigen::Dynamic, 1 > globalVector() const
LinearWeakForm< LinearFormType, IntegrationDomainType > LinearWeakFormType
const auto & field() const