36 #ifndef TIMEITERATIONPOLICYNONLINEAR_HPP 37 #define TIMEITERATIONPOLICYNONLINEAR_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 );
109 template<
class mesh_Type,
class AssemblyPolicy,
class SolverPolicy >
115 M_computeResidual = list.get (
"Compute exact residual",
false );
116 M_nonLinearTolerance = list.get (
"Nonlinear tolerance", 1e-6 );
119 M_solutionMap.reset (
new map_Type ( uFESpace()->map() + pFESpace()->map() ) );
122 Teuchos::ParameterList assemblyList = list.sublist (
"Assembly: Parameter list" );
123 AssemblyPolicy::initAssembly ( assemblyList );
126 Teuchos::ParameterList solverList = list.sublist (
"Solver: Parameter list" );
127 SolverPolicy::initSolver ( solverList );
128 M_rhs.reset (
new vector_Type ( *M_solutionMap, Unique ) );
131 template<
class mesh_Type,
class AssemblyPolicy,
class SolverPolicy >
136 const Real& currentTime )
140 Real normRhs ( 0.0 );
141 Real nonLinearResidual ( 0.0 );
142 Real rhsIterNorm ( 0.0 );
149 displayer().leaderPrint (
"Updating the system... " );
151 M_systemMatrix.reset (
new matrix_Type ( *M_solutionMap ) );
152 AssemblyPolicy::assembleSystem (
M_systemMatrix,
M_rhs, solution, SolverPolicy::preconditioner() );
159 bcManage ( *M_systemMatrix, *M_rhs, *uFESpace()->mesh(), uFESpace()->dof(), *bchandler, uFESpace()->feBd(), 1.0, currentTime );
160 M_systemMatrix->globalAssemble();
166 normRhs = M_rhs->norm2();
175 M_systemMatrix->matrixPtr()->Apply ( solution->epetraVector(), Ax.epetraVector() );
177 Ax.epetraVector().Update (-1, M_rhs->epetraVector(), 1);
180 displayer().leaderPrint (
"Nonlinear residual : ", nonLinearResidual,
"\n" );
181 displayer().leaderPrint (
"Nonlinear residual (scaled) : ", nonLinearResidual / normRhs,
"\n" );
185 displayer().leaderPrint (
"---\nSubiteration [", ++subiter,
"]\n" );
190 rhsIterNorm = M_rhs->norm2();
196 displayer().leaderPrint (
"Solving the system... \n" );
206 M_systemMatrix->matrixPtr()->Apply ( solution->epetraVector(), Ax.epetraVector() );
207 res.epetraVector().Update ( -1, Ax.epetraVector(), 1 );
210 residual /= rhsIterNorm;
211 displayer().leaderPrint (
"Scaled residual: ", residual,
"\n" );
217 displayer().leaderPrint (
"Nonlinear iterations : ", subiter,
"\n" );
VectorEpetra - The Epetra Vector format Wrapper.
std::shared_ptr< bdf_Type > bdfPtr_Type
std::shared_ptr< map_Type > mapPtr_Type
virtual fespacePtr_Type pFESpace() const =0
mapPtr_Type M_solutionMap
void importFromHDF5(std::string const &fileName, std::string const &matrixName="matrix")
Read a matrix from a HDF5 (.h5) file.
MeshPartitioner< mesh_Type > meshPartitioner_Type
BCHandler - class for handling boundary conditions.
MatrixEpetra< Real > matrix_Type
void updateInverseJacobian(const UInt &iQuadPt)
Epetra_Import const & importer()
Getter for the Epetra_Import.
virtual Displayer displayer()=0
void norm2(Real *result) const
Compute and store the norm 2 in the given pointed variable.
TimeAdvanceBDF< vector_Type > bdf_Type
std::shared_ptr< fespace_Type > fespacePtr_Type
matrixPtr_Type M_systemMatrix
BCHandler bcContainer_Type
virtual fespacePtr_Type uFESpace() const =0
double Real
Generic real data.
void iterate(vectorPtr_Type solution, bcContainerPtr_Type bchandler, const Real ¤tTime)
std::shared_ptr< VectorEpetra > vectorPtr_Type
Real M_nonLinearTolerance
std::shared_ptr< bcContainer_Type > bcContainerPtr_Type
std::shared_ptr< matrix_Type > matrixPtr_Type
Displayer - This class is used to display messages in parallel simulations.
void initTimeIteration(Teuchos::ParameterList &list)
FESpace< mesh_Type, map_Type > fespace_Type
Real norm2() const
Compute and return the norm 2.