gmsh-TingyuanDoc  0.1
An Open-Source Timing-driven Analytical Mixed-size FPGA Placer
elasticitySolver.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_SOLVER_H
7 #define ELASTICITY_SOLVER_H
8 
9 #include <map>
10 #include <string>
11 #include "GmshConfig.h"
12 #include "SVector3.h"
13 #include "dofManager.h"
14 #include "functionSpace.h"
15 
16 template <class scalar> class simpleFunction;
17 class GModel;
18 class PView;
19 class groupOfElements;
20 class gLevelset;
21 
23  int _tag;
25  double _tau;
28  LagrangeMultiplierField() : _tag(0), g(nullptr) {}
29 };
30 
31 struct elasticField {
32  int _tag; // tag for the dofManager
33  groupOfElements *g; // support for this field
34  double _e, _nu; // specific elastic datas (should be somewhere else)
35  elasticField() : _tag(0), g(nullptr) {}
36 };
37 
39  int _tag; // tag for the dofManager
41  location onWhat; // on vertices or elements
42  groupOfElements *g; // support for this BC
43  BoundaryCondition() : _tag(0), onWhat(UNDEF), g(nullptr) {}
44 };
45 
46 struct dirichletBC : public BoundaryCondition {
47  int _comp; // component
49  dirichletBC() : BoundaryCondition(), _comp(0), _f(nullptr) {}
50 };
51 
52 struct neumannBC : public BoundaryCondition {
54  neumannBC() : BoundaryCondition(), _f(nullptr) {}
55 };
56 // an elastic solver ...
58 public:
60  int _dim, _tag;
63  std::vector<FunctionSpace<double> *> LagrangeMultiplierSpaces;
64 
65  // young modulus and poisson coefficient per physical
66  std::vector<elasticField> elasticFields;
67 
68  std::vector<LagrangeMultiplierField> LagrangeMultiplierFields;
69  // neumann BC
70  std::vector<neumannBC> allNeumann;
71  // dirichlet BC
72  std::vector<dirichletBC> allDirichlet;
73 
74 public:
75  elasticitySolver(int tag) : _tag(tag), pAssembler(nullptr), LagSpace(nullptr) {}
76 
77  elasticitySolver(GModel *model, int tag);
78 
79  void addDirichletBC(int dim, int entityId, int component, double value);
80  void addDirichletBC(int dim, std::string phys, int component, double value);
81  void addNeumannBC(int dim, int entityId, const std::vector<double> value);
82  void addNeumannBC(int dim, std::string phys, const std::vector<double> value);
83  void addElasticDomain(int tag, double e, double nu);
84  void addElasticDomain(std::string phys, double e, double nu);
85 
87  {
88  if(LagSpace) delete LagSpace;
89  for(std::size_t i = 0; i < LagrangeMultiplierSpaces.size(); i++)
92  if(pAssembler) delete pAssembler;
93  }
94  void assemble(linearSystem<double> *lsys);
95  void readInputFile(const std::string &meshFileName);
96  void read(const std::string s) { readInputFile(s.c_str()); }
97  virtual void setMesh(const std::string &meshFileName, int dim = 0);
98  void cutMesh(gLevelset *ls);
99  void setElasticDomain(int phys, double E, double nu);
100  void setLagrangeMultipliers(int phys, double tau, const SVector3 &d, int tag,
102  void changeLMTau(int tag, double tau);
103  void setEdgeDisp(int edge, int comp, simpleFunction<double> *f);
104  void solve();
105  void postSolve();
106  void exportKb();
107  void computeEffectiveStiffness(std::vector<double> stiff);
108  void computeEffectiveStrain(std::vector<double> strain);
114  double computeLagNorm(int tag, simpleFunction<double> *f);
115 
116 #if defined(HAVE_POST)
117  virtual PView *buildDisplacementView(const std::string postFileName);
118  virtual PView *buildStrainView(const std::string postFileName);
119  virtual PView *buildStressesView(const std::string postFileName);
120  virtual PView *buildLagrangeMultiplierView(const std::string &posFileName,
121  int tag = -1);
122  virtual PView *buildElasticEnergyView(const std::string postFileName);
123  virtual PView *buildVonMisesView(const std::string postFileName);
124  virtual PView *buildVolumeView(const std::string postFileName);
125  virtual PView *buildErrorView(const std::string postFileName,
129 #endif
130 };
131 
132 #endif
elasticitySolver::LagrangeMultiplierFields
std::vector< LagrangeMultiplierField > LagrangeMultiplierFields
Definition: elasticitySolver.h:68
elasticitySolver::allDirichlet
std::vector< dirichletBC > allDirichlet
Definition: elasticitySolver.h:72
elasticitySolver::read
void read(const std::string s)
Definition: elasticitySolver.h:96
elasticitySolver::changeLMTau
void changeLMTau(int tag, double tau)
Definition: elasticitySolver.cpp:402
LagrangeMultiplierField::_tau
double _tau
Definition: elasticitySolver.h:25
PView
Definition: PView.h:27
elasticitySolver::computeEffectiveStrain
void computeEffectiveStrain(std::vector< double > strain)
Definition: elasticitySolver.cpp:647
elasticitySolver::_tag
int _tag
Definition: elasticitySolver.h:60
BoundaryCondition::location
location
Definition: elasticitySolver.h:40
LagrangeMultiplierField::LagrangeMultiplierField
LagrangeMultiplierField()
Definition: elasticitySolver.h:28
neumannBC::_f
simpleFunction< SVector3 > * _f
Definition: elasticitySolver.h:53
LagrangeMultiplierField::_tag
int _tag
Definition: elasticitySolver.h:23
elasticitySolver
Definition: elasticitySolver.h:57
elasticitySolver::assemble
void assemble(linearSystem< double > *lsys)
Definition: elasticitySolver.cpp:495
BoundaryCondition::_tag
int _tag
Definition: elasticitySolver.h:39
dirichletBC::_f
simpleFunction< double > * _f
Definition: elasticitySolver.h:48
LagrangeMultiplierField
Definition: elasticitySolver.h:22
LegendrePolynomials::f
void f(int n, double u, double *val)
Definition: orthogonalBasis.cpp:77
elasticitySolver::readInputFile
void readInputFile(const std::string &meshFileName)
Definition: elasticitySolver.cpp:162
SVector3
Definition: SVector3.h:16
elasticField::_nu
double _nu
Definition: elasticitySolver.h:34
SVector3.h
elasticField::_e
double _e
Definition: elasticitySolver.h:34
groupOfElements
Definition: groupOfElements.h:24
elasticField::_tag
int _tag
Definition: elasticitySolver.h:32
elasticitySolver::addElasticDomain
void addElasticDomain(int tag, double e, double nu)
Definition: elasticitySolver.cpp:479
LagrangeMultiplierField::_d
SVector3 _d
Definition: elasticitySolver.h:26
elasticitySolver::_dim
int _dim
Definition: elasticitySolver.h:60
BoundaryCondition::ON_EDGE
@ ON_EDGE
Definition: elasticitySolver.h:40
elasticField::g
groupOfElements * g
Definition: elasticitySolver.h:33
elasticitySolver::LagrangeMultiplierSpaces
std::vector< FunctionSpace< double > * > LagrangeMultiplierSpaces
Definition: elasticitySolver.h:63
elasticitySolver::computeDisplacementError
double computeDisplacementError(simpleFunction< double > *f0, simpleFunction< double > *f1, simpleFunction< double > *f2)
Definition: elasticitySolver.cpp:694
simpleFunction
Definition: GModel.h:30
elasticitySolver::setLagrangeMultipliers
void setLagrangeMultipliers(int phys, double tau, const SVector3 &d, int tag, simpleFunction< double > *f)
Definition: elasticitySolver.cpp:386
BoundaryCondition::onWhat
location onWhat
Definition: elasticitySolver.h:41
gLevelset
Definition: gmshLevelset.h:64
BoundaryCondition::g
groupOfElements * g
Definition: elasticitySolver.h:42
elasticitySolver::allNeumann
std::vector< neumannBC > allNeumann
Definition: elasticitySolver.h:70
elasticField::elasticField
elasticField()
Definition: elasticitySolver.h:35
elasticField
Definition: elasticitySolver.h:31
elasticitySolver::cutMesh
void cutMesh(gLevelset *ls)
Definition: elasticitySolver.cpp:370
GModel
Definition: GModel.h:44
LagrangeMultiplierField::g
groupOfElements * g
Definition: elasticitySolver.h:24
elasticitySolver::postSolve
void postSolve()
Definition: elasticitySolver.cpp:146
elasticitySolver::addNeumannBC
void addNeumannBC(int dim, int entityId, const std::vector< double > value)
Definition: elasticitySolver.cpp:451
elasticitySolver::LagSpace
FunctionSpace< SVector3 > * LagSpace
Definition: elasticitySolver.h:62
dofManager< double >
elasticitySolver::elasticitySolver
elasticitySolver(int tag)
Definition: elasticitySolver.h:75
elasticitySolver::computeL2Norm
double computeL2Norm(simpleFunction< double > *f0, simpleFunction< double > *f1, simpleFunction< double > *f2)
Definition: elasticitySolver.cpp:747
LagrangeMultiplierField::_f
simpleFunction< double > * _f
Definition: elasticitySolver.h:27
dofManager.h
elasticitySolver::pModel
GModel * pModel
Definition: elasticitySolver.h:59
BoundaryCondition::ON_VERTEX
@ ON_VERTEX
Definition: elasticitySolver.h:40
elasticitySolver::setMesh
virtual void setMesh(const std::string &meshFileName, int dim=0)
Definition: elasticitySolver.cpp:67
BoundaryCondition::ON_FACE
@ ON_FACE
Definition: elasticitySolver.h:40
elasticitySolver::setElasticDomain
void setElasticDomain(int phys, double E, double nu)
Definition: elasticitySolver.cpp:376
dirichletBC::_comp
int _comp
Definition: elasticitySolver.h:47
dirichletBC
Definition: elasticitySolver.h:46
elasticitySolver::pAssembler
dofManager< double > * pAssembler
Definition: elasticitySolver.h:61
BoundaryCondition::ON_VOLUME
@ ON_VOLUME
Definition: elasticitySolver.h:40
neumannBC::neumannBC
neumannBC()
Definition: elasticitySolver.h:54
elasticitySolver::elasticFields
std::vector< elasticField > elasticFields
Definition: elasticitySolver.h:66
elasticitySolver::computeEffectiveStiffness
void computeEffectiveStiffness(std::vector< double > stiff)
Definition: elasticitySolver.cpp:588
FunctionSpace< SVector3 >
elasticitySolver::setEdgeDisp
void setEdgeDisp(int edge, int comp, simpleFunction< double > *f)
Definition: elasticitySolver.cpp:411
neumannBC
Definition: elasticitySolver.h:52
elasticitySolver::addDirichletBC
void addDirichletBC(int dim, int entityId, int component, double value)
Definition: elasticitySolver.cpp:423
elasticitySolver::exportKb
void exportKb()
Definition: elasticitySolver.cpp:86
dirichletBC::dirichletBC
dirichletBC()
Definition: elasticitySolver.h:49
elasticitySolver::~elasticitySolver
virtual ~elasticitySolver()
Definition: elasticitySolver.h:86
elasticitySolver::computeLagNorm
double computeLagNorm(int tag, simpleFunction< double > *f)
Definition: elasticitySolver.cpp:784
functionSpace.h
linearSystem
Definition: linearSystem.h:38
elasticitySolver::solve
void solve()
Definition: elasticitySolver.cpp:114
BoundaryCondition
Definition: elasticitySolver.h:38
BoundaryCondition::UNDEF
@ UNDEF
Definition: elasticitySolver.h:40
BoundaryCondition::BoundaryCondition
BoundaryCondition()
Definition: elasticitySolver.h:43