typedef int PetscErrorCode
typedef int PetscInt
PetscErrorCode __libmesh_petsc_diff_solver_monitor (SNES, PetscInt its, PetscReal fnorm, void *)
PetscErrorCode __libmesh_petsc_diff_solver_residual (SNES, Vec x, Vec r, void *ctx)
PetscErrorCode __libmesh_petsc_diff_solver_jacobian (SNES, Vec x, Mat *j, Mat *pc, MatStructure *msflag, void *ctx)
Definition at line 43 of file petsc_diff_solver.C.
Definition at line 44 of file petsc_diff_solver.C.
Definition at line 105 of file petsc_diff_solver.C.
References DifferentiableSystem::assembly(), PetscMatrix< T >::close(), DofMap::enforce_constraints_exactly(), AutoPtr< Tp >::get(), System::get_dof_map(), ImplicitSystem::matrix, System::solution, PetscMatrix< T >::swap(), DiffSolver::system(), and System::update().
Referenced by PetscDiffSolver::solve().
{
libmesh_assert (x != NULL);
libmesh_assert (j != NULL);
// libmesh_assert (pc == j); // We don't use separate preconditioners yet
libmesh_assert (ctx != NULL);
PetscDiffSolver& solver =
*(static_cast<PetscDiffSolver*> (ctx));
DifferentiableSystem &sys = solver.system();
PetscVector<Number>& X_system =
*libmesh_cast_ptr<PetscVector<Number>*>(sys.solution.get());
PetscVector<Number> X_input(x);
PetscMatrix<Number> J_input(*pc);
PetscMatrix<Number>& J_system =
*libmesh_cast_ptr<PetscMatrix<Number>*>(sys.matrix);
// DiffSystem assembles from the solution and into the jacobian, so
// swap those with our input vectors before assembling. They'll
// probably already be references to the same vectors, but PETSc
// might do something tricky.
X_input.swap(X_system);
J_input.swap(J_system);
// We may need to correct a non-conforming solution
sys.get_dof_map().enforce_constraints_exactly(sys);
// We may need to localize a parallel solution
sys.update();
// Do DiffSystem assembly
sys.assembly(false, true);
J_system.close();
// Swap back
X_input.swap(X_system);
J_input.swap(J_system);
*msflag = SAME_NONZERO_PATTERN;
// No errors, we hope
return 0;
}
Definition at line 50 of file petsc_diff_solver.C.
Referenced by PetscDiffSolver::init().
{
std::cout << ' PetscDiffSolver step ' << its
<< ', |residual|_2 = ' << fnorm << std::endl;
return 0;
}
Definition at line 62 of file petsc_diff_solver.C.
References DifferentiableSystem::assembly(), DofMap::enforce_constraints_exactly(), AutoPtr< Tp >::get(), System::get_dof_map(), ExplicitSystem::rhs, System::solution, DiffSolver::system(), and System::update().
Referenced by PetscDiffSolver::solve().
{
libmesh_assert (x != NULL);
libmesh_assert (r != NULL);
libmesh_assert (ctx != NULL);
PetscDiffSolver& solver =
*(static_cast<PetscDiffSolver*> (ctx));
DifferentiableSystem &sys = solver.system();
PetscVector<Number>& X_system =
*libmesh_cast_ptr<PetscVector<Number>*>(sys.solution.get());
PetscVector<Number>& R_system =
*libmesh_cast_ptr<PetscVector<Number>*>(sys.rhs);
PetscVector<Number> X_input(x), R_input(r);
// DiffSystem assembles from the solution and into the rhs, so swap
// those with our input vectors before assembling. They'll probably
// already be references to the same vectors, but PETSc might do
// something tricky.
X_input.swap(X_system);
R_input.swap(R_system);
// We may need to correct a non-conforming solution
sys.get_dof_map().enforce_constraints_exactly(sys);
// We may need to localize a parallel solution
sys.update();
// Do DiffSystem assembly
sys.assembly(true, false);
R_system.close();
// Swap back
X_input.swap(X_system);
R_input.swap(R_system);
// No errors, we hope
return 0;
}
Generated automatically by Doxygen for libMesh from the source code.