36 #ifndef TIMEITERATIONPOLICYNONLINEARINCREMENTAL_HPP 37 #define TIMEITERATIONPOLICYNONLINEARINCREMENTAL_HPP 41 #include <boost/shared_ptr.hpp> 45 #include <Epetra_MpiComm.h> 47 #include <Epetra_SerialComm.h> 50 #include <Teuchos_ParameterList.hpp> 51 #include <Teuchos_XMLParameterListHelpers.hpp> 52 #include <Teuchos_RCP.hpp> 55 #include <lifev/core/LifeV.hpp> 56 #include <lifev/core/array/MatrixEpetra.hpp> 57 #include <lifev/core/array/VectorEpetra.hpp> 58 #include <lifev/core/util/Displayer.hpp> 59 #include <lifev/core/util/LifeChrono.hpp> 60 #include <lifev/core/mesh/RegionMesh.hpp> 61 #include <lifev/core/fem/FESpace.hpp> 62 #include <lifev/core/fem/TimeAdvanceBDF.hpp> 63 #include <lifev/core/fem/BCHandler.hpp> 64 #include <lifev/navier_stokes/solver/NavierStokesSolver/SolverPolicyLinearSolver.hpp> 94 const Real& currentTime );
110 template<
class mesh_Type,
class AssemblyPolicy,
class SolverPolicy >
116 M_computeResidual = list.get (
"Compute exact residual",
false );
117 M_nonLinearTolerance = list.get (
"Nonlinear tolerance", 1e-6 );
120 M_solutionMap.reset (
new map_Type ( uFESpace()->map() + pFESpace()->map() ) );
123 Teuchos::ParameterList assemblyList = list.sublist (
"Assembly: Parameter list" );
124 AssemblyPolicy::initAssembly ( assemblyList );
127 Teuchos::ParameterList solverList = list.sublist (
"Solver: Parameter list" );
128 SolverPolicy::initSolver ( solverList );
129 M_rhs.reset (
new vector_Type ( *M_solutionMap, Unique ) );
130 M_deltaSolution.reset (
new vector_Type ( *M_solutionMap, Unique ) );
133 template<
class mesh_Type,
class AssemblyPolicy,
class SolverPolicy >
138 const Real& currentTime )
142 Real normRhs ( 0.0 );
143 Real nonLinearResidual ( 0.0 );
144 Real rhsIterNorm ( 0.0 );
151 displayer().leaderPrint (
"Updating the system... " );
153 M_systemMatrix.reset (
new matrix_Type ( *M_solutionMap ) );
154 AssemblyPolicy::assembleSystem (
M_systemMatrix,
M_rhs, solution, SolverPolicy::preconditioner() );
161 bcManage ( *M_systemMatrix, *M_rhs, *uFESpace()->mesh(), uFESpace()->dof(), *bchandler, uFESpace()->feBd(), 1.0, currentTime );
162 M_systemMatrix->globalAssemble();
168 normRhs = M_rhs->norm2();
177 M_systemMatrix->matrixPtr()->Apply ( solution->epetraVector(), Ax.epetraVector() );
179 M_rhs->epetraVector().Update ( -1, Ax.epetraVector(), 1 );
180 nonLinearResidual = M_rhs->norm2();
182 displayer().leaderPrint (
"Nonlinear residual : ", nonLinearResidual,
"\n" );
183 displayer().leaderPrint (
"Nonlinear residual (scaled) : ", nonLinearResidual / normRhs,
"\n" );
187 displayer().leaderPrint (
"---\nSubiteration [", ++subiter,
"]\n" );
192 rhsIterNorm = M_rhs->norm2();
198 displayer().leaderPrint (
"Solving the system... \n" );
199 *M_deltaSolution = 0.0;
208 M_systemMatrix->matrixPtr()->Apply ( M_deltaSolution->epetraVector(), Ax.epetraVector() );
209 res.epetraVector().Update ( -1, Ax.epetraVector(), 1 );
212 residual /= rhsIterNorm;
213 displayer().leaderPrint (
"Scaled residual: ", residual,
"\n" );
217 *solution += *M_deltaSolution;
222 displayer().leaderPrint (
"Nonlinear iterations : ", subiter,
"\n" );
VectorEpetra - The Epetra Vector format Wrapper.
void iterate(vectorPtr_Type solution, bcContainerPtr_Type bchandler, const Real ¤tTime)
void initTimeIteration(Teuchos::ParameterList &list)
std::shared_ptr< matrix_Type > matrixPtr_Type
BCHandler bcContainer_Type
std::shared_ptr< map_Type > mapPtr_Type
void importFromHDF5(std::string const &fileName, std::string const &matrixName="matrix")
Read a matrix from a HDF5 (.h5) file.
BCHandler - class for handling boundary conditions.
std::shared_ptr< fespace_Type > fespacePtr_Type
mapPtr_Type M_solutionMap
void updateInverseJacobian(const UInt &iQuadPt)
std::shared_ptr< bdf_Type > bdfPtr_Type
Epetra_Import const & importer()
Getter for the Epetra_Import.
FESpace< mesh_Type, map_Type > fespace_Type
virtual fespacePtr_Type pFESpace() const =0
virtual Displayer displayer()=0
void norm2(Real *result) const
Compute and store the norm 2 in the given pointed variable.
matrixPtr_Type M_systemMatrix
Real M_nonLinearTolerance
MeshPartitioner< mesh_Type > meshPartitioner_Type
double Real
Generic real data.
TimeAdvanceBDF< vector_Type > bdf_Type
virtual fespacePtr_Type uFESpace() const =0
std::shared_ptr< bcContainer_Type > bcContainerPtr_Type
std::shared_ptr< VectorEpetra > vectorPtr_Type
MatrixEpetra< Real > matrix_Type
Displayer - This class is used to display messages in parallel simulations.
vectorPtr_Type M_deltaSolution