G+Smo  24.08.0
Geometry + Simulation Modules
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gsElTimeIntegrator.h
Go to the documentation of this file.
1 
15 #pragma once
16 
19 
20 namespace gismo
21 {
22 
23 template <class T>
24 class gsElasticityAssembler;
25 template <class T>
27 
30 template <class T>
32 {
33 public:
34  typedef gsBaseAssembler<T> Base;
38  gsMassAssembler<T> & massAssembler_);
39 
42 
44  void setDisplacementVector(const gsMatrix<T> & displacementVector)
45  {
46  GISMO_ENSURE(displacementVector.rows() == massAssembler.numDofs(),
47  "Wrong size of the displacement vector: " + util::to_string(displacementVector.rows()) +
48  ". Must be: " + util::to_string(massAssembler.numDofs()));
49  solVector.middleRows(0,massAssembler.numDofs()) = displacementVector;
50  initialized = false;
51  }
52 
53  void setVelocityVector(const gsMatrix<T> & velocityVector)
54  {
55  GISMO_ENSURE(velocityVector.rows() == massAssembler.numDofs(),
56  "Wrong size of the velocity vector: " + util::to_string(velocityVector.rows()) +
57  ". Must be: " + util::to_string(massAssembler.numDofs()));
59  initialized = false;
60  }
61 
63  void makeTimeStep(T timeStep);
64 
66  virtual bool assemble(const gsMatrix<T> & solutionVector,
67  const std::vector<gsMatrix<T> > & fixedDoFs);
68 
70  virtual int numDofs() const { return stiffAssembler.numDofs(); }
71 
73  const gsMatrix<T> & solutionVector() const { return solVector; }
74 
76  //const gsMatrix<T> & displacementVector() const { return solVector.middleRows(0,massAssembler.numDofs()); }
77 
79  const gsMatrix<T> & velocityVector() const { return velVector; }
80 
82  void saveState();
83 
85  void recoverState();
86 
88  index_t numberIterations() const { return numIters;}
89 
91  void constructSolution(gsMultiPatch<T> & displacement) const;
92 
94  void constructSolution(gsMultiPatch<T> & displacement, gsMultiPatch<T> & pressure) const;
95 
98  gsBaseAssembler<T> & assembler() { return stiffAssembler; }
99 
100 protected:
101  void initialize();
102 
104  gsMatrix<T> implicitLinear();
105  gsMatrix<T> implicitNonlinear();
106 
108  T alpha1() {return 1./m_options.getReal("Beta")/pow(tStep,2); }
109  T alpha2() {return 1./m_options.getReal("Beta")/tStep; }
110  T alpha3() {return (1-2*m_options.getReal("Beta"))/2/m_options.getReal("Beta"); }
111  T alpha4() {return m_options.getReal("Gamma")/m_options.getReal("Beta")/tStep; }
112  T alpha5() {return 1 - m_options.getReal("Gamma")/m_options.getReal("Beta"); }
113  T alpha6() {return (1-m_options.getReal("Gamma")/m_options.getReal("Beta")/2)*tStep; }
114 
115 protected:
123  T tStep;
130  using Base::m_system;
131  using Base::m_options;
132  using Base::m_ddof;
137  gsMatrix<T> solVecSaved;
138  gsMatrix<T> velVecSaved;
139  gsMatrix<T> accVecSaved;
140  std::vector<gsMatrix<T> > ddofsSaved;
142  gsMatrix<T> newSolVector, oldVelVector, dispVectorDiff;
143  gsSparseMatrix<T> tempMassBlock;
144 };
145 
146 }
147 
148 #ifndef GISMO_BUILD_LIB
149 #include GISMO_HPP_HEADER(gsElTimeIntegrator.hpp)
150 #endif
bool initialized
initialization flag
Definition: gsElTimeIntegrator.h:121
gsElasticityAssembler< T > & stiffAssembler
assembler object that generates the static system
Definition: gsElTimeIntegrator.h:117
index_t numberIterations() const
number of iterations Newton&#39;s method required at the last time step
Definition: gsElTimeIntegrator.h:88
gsOptionList m_options
Options.
Definition: gsAssembler.h:285
std::string to_string(const C &value)
Converts value to string, assuming &quot;operator&lt;&lt;&quot; defined on C.
Definition: gsUtils.h:56
void recoverState()
recover solver state from saved state
Definition: gsElTimeIntegrator.hpp:182
static gsOptionList defaultOptions()
Returns the list of default options for assembly.
Definition: gsElTimeIntegrator.hpp:44
void makeTimeStep(T timeStep)
make a time step according to a chosen scheme
Definition: gsElTimeIntegrator.hpp:65
#define index_t
Definition: gsConfig.h:32
#define GISMO_ENSURE(cond, message)
Definition: gsDebug.h:102
T tStep
time step length
Definition: gsElTimeIntegrator.h:123
const gsMatrix< T > & solutionVector() const
returns complete solution vector (displacement + possibly pressure)
Definition: gsElTimeIntegrator.h:73
Provides several simple utility and naming classes.
Assembles the stiffness matrix and the right-hand side vector for linear and nonlinear elasticity for...
Definition: gsElasticityAssembler.h:31
Assembles the mass matrix and right-hand side vector for linear and nonlinear elasticity for 2D plain...
Definition: gsElTimeIntegrator.h:26
gsMassAssembler< T > & massAssembler
assembler object that generates the mass matrix
Definition: gsElTimeIntegrator.h:119
void setDisplacementVector(const gsMatrix< T > &displacementVector)
set intial conditions
Definition: gsElTimeIntegrator.h:44
Base class for assemblers of gsElasticity.
bool hasSavedState
saved state
Definition: gsElTimeIntegrator.h:136
gsElTimeIntegrator(gsElasticityAssembler< T > &stiffAssembler_, gsMassAssembler< T > &massAssembler_)
Definition: gsElTimeIntegrator.hpp:28
Container class for a set of geometry patches and their topology, that is, the interface connections ...
Definition: gsMultiPatch.h:33
virtual int numDofs() const
return the number of free degrees of freedom
Definition: gsElTimeIntegrator.h:70
Extends the gsAssembler class by adding functionality necessary for a general nonlinear solver...
Definition: gsALE.h:26
gsSparseSystem< T > m_system
Global sparse linear system.
Definition: gsAssembler.h:290
std::vector< gsMatrix< T > > m_ddof
Definition: gsAssembler.h:295
void saveState()
save solver state
Definition: gsElTimeIntegrator.hpp:170
gsMatrix< T > implicitLinear()
time integraton schemes
Definition: gsElTimeIntegrator.hpp:83
index_t numIters
number of iterations Newton&#39;s method took to converge at the last time step
Definition: gsElTimeIntegrator.h:134
void constructSolution(gsMultiPatch< T > &displacement) const
construct displacement using the stiffness assembler
Definition: gsElTimeIntegrator.hpp:156
const gsMatrix< T > & velocityVector() const
returns vector of displacement DoFs
Definition: gsElTimeIntegrator.h:79
gsMatrix< T > solVector
vector of displacement DoFs ( + possibly pressure)
Definition: gsElTimeIntegrator.h:125
gsMatrix< T > accVector
vector of acceleration DoFs
Definition: gsElTimeIntegrator.h:129
Time integation for equations of dynamic elasticity with implicit schemes.
Definition: gsElTimeIntegrator.h:31
Class which holds a list of parameters/options, and provides easy access to them. ...
Definition: gsOptionList.h:32
gsMatrix< T > velVector
vector of velocity DoFs
Definition: gsElTimeIntegrator.h:127
T alpha1()
time integration scheme coefficients
Definition: gsElTimeIntegrator.h:108
virtual void assemble()
Main assemble routine, to be implemented in derived classes.
Definition: gsAssembler.hpp:51
gsMatrix< T > newSolVector
temporary objects for memory efficiency
Definition: gsElTimeIntegrator.h:142
gsBaseAssembler< T > & mAssembler()
assemblers&#39; accessors
Definition: gsElTimeIntegrator.h:97
Real getReal(const std::string &label) const
Reads value for option label from options.
Definition: gsOptionList.cpp:44