-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathgsNsTimeIntegrator.h
146 lines (117 loc) · 4.51 KB
/
gsNsTimeIntegrator.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/** @file gsNsTimeIntegrator.h
@brief Provides time integration for incompressible Navier-Stokes equations.
This file is part of the G+Smo library.
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
Author(s):
A.Shamanskiy (2016 - ...., TU Kaiserslautern)
*/
#pragma once
#include <gsElasticity/gsBaseAssembler.h>
#include <gsElasticity/gsBaseUtils.h>
#include <gsElasticity/gsNsAssembler.h>
#include <gsElasticity/gsMassAssembler.h>
namespace gismo
{
/** @brief Time integation for incompressible Navier-Stokes equations.
*/
template <class T>
class gsNsTimeIntegrator : public gsBaseAssembler<T>
{
public:
typedef gsBaseAssembler<T> Base;
/// constructor method. requires a gsNsAssembler for construction of the static linear system
/// and a gsMassAssembler for the mass matrix
gsNsTimeIntegrator(gsNsAssembler<T> & stiffAssembler_,
gsMassAssembler<T> & massAssembler_,
gsMultiPatch<T> * ALEvelocity = nullptr,
gsBoundaryInterface * interfaceALE2Flow = nullptr);
/// @brief Returns the list of default options for assembly
static gsOptionList defaultOptions();
/// set intial conditions
void setSolutionVector(const gsMatrix<T> & solutionVector)
{
GISMO_ENSURE(solutionVector.rows() == stiffAssembler.numDofs(),"Wrong size of the solution vector: " + util::to_string(solutionVector.rows()) +
". Must be: " + util::to_string(stiffAssembler.numDofs()));
solVector = solutionVector;
initialized = false;
}
/// set all fixed degrees of freedom
using Base::setFixedDofs;
virtual void setFixedDofs(const std::vector<gsMatrix<T> > & ddofs)
{
Base::setFixedDofs(ddofs);
initialized = false;
}
/// make a time step according to a chosen scheme
void makeTimeStep(T timeStep);
/// assemble the linear system for the nonlinear solver
using Base::assemble;
virtual bool assemble(const gsMatrix<T> & solutionVector,
const std::vector<gsMatrix<T> > & fixedDoFs);
/// returns number of degrees of freedom
virtual int numDofs() const { return stiffAssembler.numDofs(); }
/// returns solution vector
const gsMatrix<T> & solutionVector() const
{
GISMO_ENSURE(solVector.rows() == stiffAssembler.numDofs(),
"No initial conditions provided!");
return solVector;
}
/// save solver state
void saveState();
/// recover solver state from the previously saved state
void recoverState();
/// number of iterations Newton's method required at the last time step; always 1 for IMEX
index_t numberIterations() const { return numIters;}
/// construct the solution using the stiffness matrix assembler
using Base::constructSolution;
void constructSolution(gsMultiPatch<T> & velocity, gsMultiPatch<T> & pressure) const;
/// assemblers' accessors
gsBaseAssembler<T> & mAssembler();
gsBaseAssembler<T> & assembler();
/// get mapping between the flow domain patches and the ALE mapping patches (if only some patches of the flow domain are deformed)
const gsBoundaryInterface & aleInterface() const {return *interface;}
protected:
void initialize();
/// time integraton schemes
void implicitLinear();
void implicitNonlinear();
protected:
/// assembler object that generates the static system
gsNsAssembler<T> & stiffAssembler;
/// assembler object that generates the mass matrix
gsMassAssembler<T> & massAssembler;
/// initialization flag
bool initialized;
/// time step length
T tStep;
/// solution vector
gsMatrix<T> solVector;
using Base::m_system;
using Base::m_options;
using Base::m_ddof;
/// IMEX stuff
T oldTimeStep;
gsMatrix<T> oldSolVector;
/// Newton stuff
gsMatrix<T> constRHS;
index_t numIters;
/// ALE velocity
gsMultiPatch<T> * velocityALE;
/// mapping between the geometry patches and the ALE velocity patches
gsBoundaryInterface * interface;
/// saved state
bool hasSavedState;
gsMatrix<T> velVecSaved;
gsMatrix<T> oldVecSaved;
gsMatrix<T> massRhsSaved;
gsMatrix<T> stiffRhsSaved;
gsSparseMatrix<T> stiffMatrixSaved;
std::vector<gsMatrix<T> > ddofsSaved;
};
}
#ifndef GISMO_BUILD_LIB
#include GISMO_HPP_HEADER(gsNsTimeIntegrator.hpp)
#endif