167 mrProblemDefinition.Validate();
192 VecDuplicate(this->mLinearSystemRhsVector,&solution);
196 KSPCreate(PETSC_COMM_WORLD,&solver);
197#if ((PETSC_VERSION_MAJOR==3) && (PETSC_VERSION_MINOR>=5))
198 KSPSetOperators(solver, this->mSystemLhsMatrix, this->mPreconditionMatrix);
200 KSPSetOperators(solver, this->mSystemLhsMatrix, this->mPreconditionMatrix, DIFFERENT_NONZERO_PATTERN );
202 KSPSetType(solver, KSPGMRES);
204 if (mKspAbsoluteTol < 0)
206 double ksp_rel_tol = 1e-6;
207 KSPSetTolerances(solver, ksp_rel_tol, PETSC_DEFAULT, PETSC_DEFAULT, 10000 );
211 KSPSetTolerances(solver, 1e-16, mKspAbsoluteTol, PETSC_DEFAULT, 10000 );
213 unsigned num_restarts = 100;
214 KSPGMRESSetRestart(solver,num_restarts);
217 KSPGetPC(solver, &pc);
218 PCSetType(pc, PCJACOBI);
222 KSPSetFromOptions(solver);
249 KSPSolve(solver,this->mLinearSystemRhsVector,solution);
251 KSPConvergedReason reason;
252 KSPGetConvergedReason(solver,&reason);
259 KSPGetIterationNumber(solver, &num_iters);
260 std::cout <<
"[" <<
PetscTools::GetMyRank() <<
"]: Num iterations = " << num_iters <<
"\n" << std::flush;
267 for (
unsigned i=0; i<this->mNumDofs; i++)
269 this->mCurrentSolution[i] = solution_repl[i];
275 this->RemovePressureDummyValuesThroughLinearInterpolation();
280 this->WriteCurrentSpatialSolution(
"flow_solution",
"nodes");
281 this->WriteCurrentPressureSolution();
288 mpStokesFlowAssembler->SetMatrixToAssemble(this->mSystemLhsMatrix,
true);
289 mpStokesFlowAssembler->SetVectorToAssemble(this->mLinearSystemRhsVector,
true);
290 mpStokesFlowAssembler->Assemble();
292 mpStokesFlowPreconditionerAssembler->SetMatrixToAssemble(this->mPreconditionMatrix,
true);
293 mpStokesFlowPreconditionerAssembler->AssembleMatrix();
295 mpNeumannBcsAssembler->SetVectorToAssemble(this->mLinearSystemRhsVector,
false );
296 mpNeumannBcsAssembler->AssembleVector();
309 this->AddIdentityBlockForDummyPressureVariables(LINEAR_PROBLEM);
310 this->ApplyDirichletBoundaryConditions(LINEAR_PROBLEM,
true);