gmsh-TingyuanDoc  0.1
An Open-Source Timing-driven Analytical Mixed-size FPGA Placer
elasticityTerm.h
Go to the documentation of this file.
1 // Gmsh - Copyright (C) 1997-2022 C. Geuzaine, J.-F. Remacle
2 //
3 // See the LICENSE.txt file in the Gmsh root directory for license information.
4 // Please report all issues on https://gitlab.onelab.info/gmsh/gmsh/issues.
5 
6 #ifndef ELASTICITY_TERM_H
7 #define ELASTICITY_TERM_H
8 
9 #include "femTerm.h"
10 #include "GmshGlobal.h"
11 #include "GModel.h"
12 #include "polynomialBasis.h"
13 #include "SElement.h"
14 #include "fullMatrix.h"
15 
17  std::vector<fullMatrix<double> > gradSF;
18  std::vector<double> u, v, w, weight;
19 };
20 
21 class elasticityTerm : public femTerm<double> {
22 protected:
23  double _e, _nu;
26  mutable std::map<int, elasticityDataAtGaussPoint> _data;
27  void createData(MElement *) const;
28 
29 public:
30  void setFieldC(int i) { _iFieldC = i; }
31  void setFieldR(int i) { _iFieldR = i; }
32  // element matrix size : 3 dofs per vertex
33  virtual int sizeOfR(SElement *se) const
34  {
35  return 3 * se->getMeshElement()->getNumShapeFunctions();
36  }
37  virtual int sizeOfC(SElement *se) const
38  {
39  return 3 * se->getMeshElement()->getNumShapeFunctions();
40  }
41  // order dofs in the local matrix :
42  // dx1, dx2 ... dxn, dy1, ..., dyn, dz1, ... dzn
43  Dof getLocalDofR(SElement *se, int iRow) const
44  {
45  MElement *e = se->getMeshElement();
46  int iCompR = iRow / (int)e->getNumShapeFunctions();
47  int ithLocalVertex = iRow % (int)e->getNumShapeFunctions();
48  return Dof(e->getShapeFunctionNode(ithLocalVertex)->getNum(),
50  }
51  Dof getLocalDofC(SElement *se, int iCol) const
52  {
53  MElement *e = se->getMeshElement();
54  int iCompC = iCol / (int)e->getNumShapeFunctions();
55  int ithLocalVertex = iCol % (int)e->getNumShapeFunctions();
56  return Dof(e->getShapeFunctionNode(ithLocalVertex)->getNum(),
58  }
59 
60 public:
61  elasticityTerm(GModel *gm, double E, double nu, int fieldr, int fieldc)
62  : femTerm<double>(gm), _e(E), _nu(nu), _iFieldR(fieldr), _iFieldC(fieldc)
63  {
64  }
65  elasticityTerm(GModel *gm, double E, double nu, int fieldr)
66  : femTerm<double>(gm), _e(E), _nu(nu), _iFieldR(fieldr), _iFieldC(fieldr)
67  {
68  }
69  void setVector(const SVector3 &f) { _volumeForce = f; }
70  void elementMatrix(SElement *se, fullMatrix<double> &m) const;
71  void elementVector(SElement *se, fullVector<double> &m) const;
72 };
73 
74 /*
75  Formulation of elasticity with 3 fields
76  -) displacement U
77  -) lagrange multipliers p and g
78 
79  g = trace (epsilon)
80  p = trace (epsilon)
81 
82 
83 */
84 
85 class elasticityMixedTerm : public femTerm<double> {
86 protected:
87  double _e, _nu;
89  mutable polynomialBasis *_pN, *_pM;
90  void setPolynomialBasis(SElement *se) const
91  {
94  _pN =
96  _pM =
100  }
101 
102 public:
103  void setField(int i) { _iField = i; }
104  // element matrix size : 3 dofs per vertex
105  virtual int sizeOfR(SElement *se) const
106  {
107  setPolynomialBasis(se);
108  return 3 * _sizeN + 2 * _sizeM;
109  }
110  virtual int sizeOfC(SElement *se) const { return sizeOfR(se); }
111  // order dofs in the local matrix :
112  // dx1, dx2 ... dxn, dy1, ..., dyn, dz1, ... dzn ,
113  // p1,p2,...,pm, g1,g2,...,gm
114  Dof getLocalDofR(SElement *se, int iRow) const
115  {
116  setPolynomialBasis(se);
117  MElement *e = se->getMeshElement();
118  int iComp;
119  int ithLocalVertex;
120  if(iRow < 3 * _sizeN) {
121  iComp = iRow / _sizeN;
122  ithLocalVertex = iRow % _sizeN;
123  }
124  else {
125  iRow -= 3 * _sizeN;
126  iComp = 3 + iRow / _sizeM;
127  ithLocalVertex = iRow % _sizeM;
128  }
129  return Dof(e->getShapeFunctionNode(ithLocalVertex)->getNum(),
131  }
132  Dof getLocalDofC(SElement *se, int iCol) const
133  {
134  return getLocalDofR(se, iCol);
135  }
136 
137 public:
138  elasticityMixedTerm(GModel *gm, double E, double nu, int field)
139  : femTerm<double>(gm), _e(E), _nu(nu), _iField(field)
140  {
141  }
142  void elementMatrix(SElement *se, fullMatrix<double> &m) const;
144  void setYoung(double E) { _e = E; }
145 };
146 
147 #endif
elasticityMixedTerm::elementMatrix
void elementMatrix(SElement *se, fullMatrix< double > &m) const
Definition: elasticityTerm.cpp:163
elasticityTerm::createData
void createData(MElement *) const
Definition: elasticityTerm.cpp:12
elasticityTerm::getLocalDofR
Dof getLocalDofR(SElement *se, int iRow) const
Definition: elasticityTerm.h:43
elasticityTerm::setFieldC
void setFieldC(int i)
Definition: elasticityTerm.h:30
elasticityMixedTerm::_sizeM
int _sizeM
Definition: elasticityTerm.h:88
elasticityMixedTerm::_polyOrderM
int _polyOrderM
Definition: elasticityTerm.h:88
elasticityMixedTerm::getLocalDofR
Dof getLocalDofR(SElement *se, int iRow) const
Definition: elasticityTerm.h:114
elasticityTerm::sizeOfR
virtual int sizeOfR(SElement *se) const
Definition: elasticityTerm.h:33
fullVector< double >
elasticityTerm::_iFieldR
int _iFieldR
Definition: elasticityTerm.h:24
elasticityMixedTerm::sizeOfC
virtual int sizeOfC(SElement *se) const
Definition: elasticityTerm.h:110
LegendrePolynomials::f
void f(int n, double u, double *val)
Definition: orthogonalBasis.cpp:77
MVertex::getNum
std::size_t getNum() const
Definition: MVertex.h:86
MElement::getShapeFunctionNode
virtual const MVertex * getShapeFunctionNode(int i) const
Definition: MElement.h:392
SVector3
Definition: SVector3.h:16
elasticityMixedTerm::_pN
polynomialBasis * _pN
Definition: elasticityTerm.h:89
elasticityTerm::_nu
double _nu
Definition: elasticityTerm.h:23
elasticityTerm::_volumeForce
SVector3 _volumeForce
Definition: elasticityTerm.h:25
elasticityDataAtGaussPoint::u
std::vector< double > u
Definition: elasticityTerm.h:18
elasticityDataAtGaussPoint::weight
std::vector< double > weight
Definition: elasticityTerm.h:18
fullMatrix< double >
elasticityTerm::setFieldR
void setFieldR(int i)
Definition: elasticityTerm.h:31
elasticityMixedTerm::_iField
int _iField
Definition: elasticityTerm.h:88
elasticityTerm::elementMatrix
void elementMatrix(SElement *se, fullMatrix< double > &m) const
Definition: elasticityTerm.cpp:43
elasticityDataAtGaussPoint::v
std::vector< double > v
Definition: elasticityTerm.h:18
Dof
Definition: dofManager.h:19
elasticityDataAtGaussPoint::w
std::vector< double > w
Definition: elasticityTerm.h:18
elasticityMixedTerm::_polyOrderN
int _polyOrderN
Definition: elasticityTerm.h:88
Dof::createTypeWithTwoInts
static int createTypeWithTwoInts(int i1, int i2)
Definition: dofManager.h:28
SElement.h
elasticityTerm::elasticityTerm
elasticityTerm(GModel *gm, double E, double nu, int fieldr)
Definition: elasticityTerm.h:65
GModel
Definition: GModel.h:44
elasticityMixedTerm::_sizeN
int _sizeN
Definition: elasticityTerm.h:88
MElement::getNumShapeFunctions
virtual std::size_t getNumShapeFunctions() const
Definition: MElement.h:387
elasticityTerm::elementVector
void elementVector(SElement *se, fullVector< double > &m) const
Definition: elasticityTerm.cpp:127
elasticityTerm::_e
double _e
Definition: elasticityTerm.h:23
elasticityMixedTerm::setPolynomialBasis
void setPolynomialBasis(SElement *se) const
Definition: elasticityTerm.h:90
elasticityTerm::elasticityTerm
elasticityTerm(GModel *gm, double E, double nu, int fieldr, int fieldc)
Definition: elasticityTerm.h:61
elasticityMixedTerm::getLocalDofC
Dof getLocalDofC(SElement *se, int iCol) const
Definition: elasticityTerm.h:132
SElement
Definition: SElement.h:18
polynomialBasis::coefficients
fullMatrix< double > coefficients
Definition: polynomialBasis.h:21
elasticityMixedTerm
Definition: elasticityTerm.h:85
elasticityDataAtGaussPoint
Definition: elasticityTerm.h:16
MElement
Definition: MElement.h:30
elasticityTerm::getLocalDofC
Dof getLocalDofC(SElement *se, int iCol) const
Definition: elasticityTerm.h:51
elasticityMixedTerm::setYoung
void setYoung(double E)
Definition: elasticityTerm.h:144
GmshGlobal.h
SElement::getMeshElement
MElement * getMeshElement() const
Definition: SElement.h:35
elasticityMixedTerm::_e
double _e
Definition: elasticityTerm.h:87
elasticityMixedTerm::_nu
double _nu
Definition: elasticityTerm.h:87
elasticityMixedTerm::elementVector
void elementVector(SElement *se, fullVector< double > &m) const
Definition: elasticityTerm.h:143
elasticityTerm::sizeOfC
virtual int sizeOfC(SElement *se) const
Definition: elasticityTerm.h:37
polynomialBasis.h
fullMatrix::size1
int size1() const
Definition: fullMatrix.h:274
elasticityMixedTerm::elasticityMixedTerm
elasticityMixedTerm(GModel *gm, double E, double nu, int field)
Definition: elasticityTerm.h:138
elasticityMixedTerm::_pM
polynomialBasis * _pM
Definition: elasticityTerm.h:89
elasticityTerm
Definition: elasticityTerm.h:21
polynomialBasis
Definition: polynomialBasis.h:16
elasticityTerm::_data
std::map< int, elasticityDataAtGaussPoint > _data
Definition: elasticityTerm.h:26
GModel.h
elasticityMixedTerm::setField
void setField(int i)
Definition: elasticityTerm.h:103
femTerm
Definition: femTerm.h:21
MElement::getPolynomialOrder
virtual int getPolynomialOrder() const
Definition: MElement.h:78
elasticityMixedTerm::sizeOfR
virtual int sizeOfR(SElement *se) const
Definition: elasticityTerm.h:105
MElement::getFunctionSpace
virtual const nodalBasis * getFunctionSpace(int order=-1, bool serendip=false) const
Definition: MElement.cpp:666
femTerm.h
elasticityDataAtGaussPoint::gradSF
std::vector< fullMatrix< double > > gradSF
Definition: elasticityTerm.h:17
elasticityTerm::_iFieldC
int _iFieldC
Definition: elasticityTerm.h:24
fullMatrix.h
elasticityTerm::setVector
void setVector(const SVector3 &f)
Definition: elasticityTerm.h:69