27 #ifdef LIBMESH_HAVE_PETSC 53 <<
", |residual|_2 = " << fnorm << std::endl;
58 ierr = SNESGetSolutionUpdate(snes, &petsc_delta_u);
64 ierr = SNESGetSolution(snes, &petsc_u);
70 ierr = SNESGetFunction(snes, &petsc_res,
nullptr,
nullptr);
76 delta_u, delta_u.l2_norm(),
78 res, res.l2_norm(), its);
100 *cast_ptr<PetscVector<Number> *>(sys.
solution.get());
102 *cast_ptr<PetscVector<Number> *>(sys.
rhs);
109 X_input.
swap(X_system);
110 R_input.swap(R_system);
123 X_input.swap(X_system);
124 R_input.swap(R_system);
134 #
if PETSC_RELEASE_LESS_THAN(3,5,0)
135 Mat * libmesh_dbg_var(j),
137 MatStructure * msflag,
139 Mat libmesh_dbg_var(j),
157 *cast_ptr<PetscVector<Number> *>(sys.
solution.get());
160 #if PETSC_RELEASE_LESS_THAN(3,5,0) 166 *cast_ptr<PetscMatrix<Number> *>(sys.
matrix);
172 X_input.
swap(X_system);
173 J_input.swap(J_system);
186 X_input.swap(X_system);
187 J_input.swap(J_system);
189 #if PETSC_RELEASE_LESS_THAN(3,5,0) 190 *msflag = SAME_NONZERO_PATTERN;
207 LOG_SCOPE(
"init()",
"PetscDiffSolver");
225 LOG_SCOPE(
"clear()",
"PetscDiffSolver");
228 LIBMESH_CHKERR(
ierr);
237 LOG_SCOPE(
"reinit()",
"PetscDiffSolver");
255 case SNES_CONVERGED_FNORM_ABS:
257 case SNES_CONVERGED_FNORM_RELATIVE:
259 #if PETSC_VERSION_LESS_THAN(3,2,1) 260 case SNES_CONVERGED_PNORM_RELATIVE:
262 case SNES_CONVERGED_SNORM_RELATIVE:
265 case SNES_CONVERGED_ITS:
266 case SNES_CONVERGED_TR_DELTA:
268 case SNES_DIVERGED_FUNCTION_DOMAIN:
269 case SNES_DIVERGED_FUNCTION_COUNT:
270 case SNES_DIVERGED_FNORM_NAN:
271 #if !PETSC_VERSION_LESS_THAN(3,3,0) 272 case SNES_DIVERGED_INNER:
274 case SNES_DIVERGED_LINEAR_SOLVE:
275 case SNES_DIVERGED_LOCAL_MIN:
277 case SNES_DIVERGED_MAX_IT:
279 #if PETSC_VERSION_LESS_THAN(3,2,0) 280 case SNES_DIVERGED_LS_FAILURE:
282 case SNES_DIVERGED_LINE_SEARCH:
290 case SNES_CONVERGED_ITERATING:
302 LOG_SCOPE(
"solve()",
"PetscDiffSolver");
309 *(cast_ptr<PetscVector<Number> *>(
_system.
rhs));
315 LIBMESH_CHKERR(
ierr);
319 LIBMESH_CHKERR(
ierr);
322 LIBMESH_CHKERR(
ierr);
325 LIBMESH_CHKERR(
ierr);
327 #ifdef LIBMESH_ENABLE_CONSTRAINTS 331 SNESConvergedReason reason;
332 SNESGetConvergedReason(
_snes, &reason);
342 LIBMESH_CHKERR(
ierr);
346 LIBMESH_CHKERR(
ierr);
351 LIBMESH_CHKERR(
ierr);
365 LIBMESH_CHKERR(
ierr);
369 LIBMESH_CHKERR(
ierr);
372 ierr = KSPGetPC(my_ksp, &my_pc);
373 LIBMESH_CHKERR(
ierr);
381 #endif // LIBMESH_HAVE_PETSC
void petsc_auto_fieldsplit(PC my_pc, const System &sys)
NumericVector interface to PETSc Vec.
virtual void init() override
virtual ~PetscDiffSolver()
DiffSolver::SolveResult convert_solve_result(SNESConvergedReason r)
NumericVector< Number > * rhs
const Parallel::Communicator & comm() const
virtual unsigned int solve() override
void swap(PetscMatrix< T > &)
PetscDiffSolver(sys_type &system)
virtual void swap(NumericVector< T > &v) override
PetscErrorCode __libmesh_petsc_diff_solver_jacobian(SNES, Vec x, #if PETSC_RELEASE_LESS_THAN(3, 5, 0) Mat *libmesh_dbg_var(j), Mat *pc, MatStructure *msflag, #else Mat libmesh_dbg_var(j), Mat pc, #endif void *ctx)
virtual void assembly(bool, bool, bool=false, bool=false)
std::unique_ptr< NumericVector< Number > > solution
const sys_type & system() const
PetscDMWrapper _dm_wrapper
SparseMatrix< Number > * matrix
SparseMatrix interface to PETSc Mat.
std::unique_ptr< NumericVector< Number > > current_local_solution
bool on_command_line(std::string arg)
const std::string & name() const
PetscErrorCode __libmesh_petsc_diff_solver_residual(SNES, Vec x, Vec r, void *ctx)
OStreamProxy out(std::cout)
void clear()
Destroys and clears all build DM-related data.
const DofMap & get_dof_map() const
virtual void reinit() override
void init_and_attach_petscdm(System &system, SNES &snes)
virtual void close() override
std::unique_ptr< LinearSolutionMonitor > linear_solution_monitor
void enforce_constraints_exactly(const System &system, NumericVector< Number > *v=nullptr, bool homogeneous=false) const
PetscErrorCode __libmesh_petsc_diff_solver_monitor(SNES snes, PetscInt its, PetscReal fnorm, void *ctx)
Manages consistently variables, degrees of freedom, coefficient vectors, and matrices for implicit sy...