Skip to content

Commit

Permalink
Merge pull request #28817 from lindsayad/petsc-update
Browse files Browse the repository at this point in the history
Update petsc to 3.22.1-ish (includes some 3.23 features)
  • Loading branch information
lindsayad authored Nov 19, 2024
2 parents 538d819 + 27b45d9 commit a4c8527
Show file tree
Hide file tree
Showing 35 changed files with 73 additions and 119 deletions.
1 change: 0 additions & 1 deletion apptainer/petsc.def
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,3 @@ From: {{ APPTAINER_FROM }}
%files
{{ MOOSE_DIR }}/scripts/configure_petsc.sh {{ ROOT_BUILD_DIR }}/scripts/configure_petsc.sh
{{ MOOSE_DIR }}/scripts/update_and_rebuild_petsc.sh {{ ROOT_BUILD_DIR }}/scripts/update_and_rebuild_petsc.sh
{{ MOOSE_DIR }}/scripts/tao_restore_viewer.patch {{ ROOT_BUILD_DIR }}/scripts/tao_restore_viewer.patch
4 changes: 2 additions & 2 deletions conda/libmesh/conda_build_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ mpi:
- openmpi

moose_petsc:
- moose-petsc 3.21.5 mpich_1
- moose-petsc 3.21.5 openmpi_1
- moose-petsc 3.22.1.193.g72c1e49ee3d mpich_0
- moose-petsc 3.22.1.193.g72c1e49ee3d openmpi_0

moose_libmesh_vtk:
- moose-libmesh-vtk 9.3.0 mpich_4
Expand Down
2 changes: 1 addition & 1 deletion conda/libmesh/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# As well as any directions pertaining to modifying those files.
# ALSO: Follow the directions in scripts/tests/versioner_hashes.yaml
{% set build = 1 %}
{% set build = 2 %}
{% set version = "2024.10.17" %}

package:
Expand Down
4 changes: 2 additions & 2 deletions conda/moose-dev/conda_build_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ mpi:
- openmpi

moose_libmesh:
- moose-libmesh 2024.10.17 mpich_1
- moose-libmesh 2024.10.17 openmpi_1
- moose-libmesh 2024.10.17 mpich_2
- moose-libmesh 2024.10.17 openmpi_2

moose_wasp:
- moose-wasp 2024.11.13
Expand Down
2 changes: 1 addition & 1 deletion conda/moose-dev/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# REMEMBER TO UPDATE the .yaml files for the following packages:
# moose/conda_build_config.yaml
# As well as any directions pertaining to modifying those files.
{% set version = "2024.11.14" %}
{% set version = "2024.11.15" %}

package:
name: moose-dev
Expand Down
2 changes: 1 addition & 1 deletion conda/moose/conda_build_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ mpi:
- openmpi

moose_dev:
- moose-dev 2024.11.14
- moose-dev 2024.11.15

#### Darwin SDK SYSROOT
CONDA_BUILD_SYSROOT: # [osx]
Expand Down
5 changes: 2 additions & 3 deletions conda/petsc/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#
# As well as any directions pertaining to modifying those files.
# ALSO: Follow the directions in scripts/tests/versioner_hashes.yaml
{% set build = 1 %}
{% set version = "3.21.5" %}
{% set build = 0 %}
{% set version = "3.22.1.193.g72c1e49ee3d" %}

package:
name: moose-petsc
Expand All @@ -20,7 +20,6 @@ source:
- path: ../functions/retry_build.sh
- patches:
- no-cppflags-in-pkgconfig-cflags.patch
- ../../scripts/tao_restore_viewer.patch

build:
number: {{ build }}
Expand Down
2 changes: 1 addition & 1 deletion framework/doc/packages_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ maximum_python: 3.11
mpich: 4.2.1
openmpi: 4.1.6
petsc_alt: 3.11.4
petsc: 3.21.5
petsc: 3.22.1.193.g72c1e49ee3d
apptainer_rockylinux: 8.8.20230518
apptainer_mpich: 3.4.3
apptainer_gcc: 12.2.1
Expand Down
4 changes: 2 additions & 2 deletions framework/include/problems/FEProblemBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -2333,9 +2333,9 @@ class FEProblemBase : public SubProblem, public Restartable
void clearCurrentResidualVectorTags();

/**
* Clear the current Jacobian vector tag data structure ... if someone creates it
* Clear the current Jacobian matrix tag data structure ... if someone creates it
*/
void clearCurrentJacobianVectorTags() {}
void clearCurrentJacobianMatrixTags() {}

using SubProblem::doingPRefinement;
virtual void doingPRefinement(bool doing_p_refinement,
Expand Down
2 changes: 1 addition & 1 deletion framework/include/systems/DumpObjectsNonlinearSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class DumpObjectsNonlinearSystem : public NonlinearSystemBase

virtual NonlinearSolver<Number> * nonlinearSolver() override { return NULL; }
virtual void solve() override {}
virtual void stopSolve(const ExecFlagType &) override {}
virtual void stopSolve(const ExecFlagType &, const std::set<TagID> &) override {}
virtual bool converged() override { return true; }
virtual NumericVector<Number> & RHS() override { return *_dummy; }
virtual SNES getSNES() override { return nullptr; }
Expand Down
3 changes: 2 additions & 1 deletion framework/include/systems/LinearSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ class LinearSystem : public SolverSystem, public PerfGraphInterface
/**
* Quit the current solve as soon as possible.
*/
virtual void stopSolve(const ExecFlagType & exec_flag) override;
virtual void stopSolve(const ExecFlagType & exec_flag,
const std::set<TagID> & vector_tags_to_close) override;

/**
* Compute the right hand side and the system matrix of the system for given tags.
Expand Down
3 changes: 2 additions & 1 deletion framework/include/systems/NonlinearEigenSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ class NonlinearEigenSystem : public NonlinearSystemBase
/**
* Quit the current solve as soon as possible.
*/
virtual void stopSolve(const ExecFlagType & exec_flag) override;
virtual void stopSolve(const ExecFlagType & exec_flag,
const std::set<TagID> & vector_tags_to_close) override;

/**
* Returns the current nonlinear iteration number. In libmesh, this is
Expand Down
3 changes: 2 additions & 1 deletion framework/include/systems/NonlinearSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ class NonlinearSystem : public NonlinearSystemBase, public NonlinearImplicitSyst
/**
* Quit the current solve as soon as possible.
*/
virtual void stopSolve(const ExecFlagType & exec_flag) override;
virtual void stopSolve(const ExecFlagType & exec_flag,
const std::set<TagID> & vector_tags_to_close) override;

/**
* Returns the current nonlinear iteration number. In libmesh, this is
Expand Down
3 changes: 2 additions & 1 deletion framework/include/systems/SolverSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ class SolverSystem : public SystemBase
/**
* Quit the current solve as soon as possible.
*/
virtual void stopSolve(const ExecFlagType & exec_flag) = 0;
virtual void stopSolve(const ExecFlagType & exec_flag,
const std::set<TagID> & vector_tags_to_close) = 0;

/**
* Set the solution to a given vector.
Expand Down
10 changes: 6 additions & 4 deletions framework/src/problems/EigenProblem.C
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,8 @@ EigenProblem::computeResidualTag(const NumericVector<Number> & soln,
// specific system tags that we need for this instance
_nl_eigen->disassociateDefaultVectorTags();

// Clear FE tags and first add the specific tag associated with the residual
_fe_vector_tags.clear();
// add the specific tag associated with the residual
mooseAssert(_fe_vector_tags.empty(), "This should be empty indicating a clean starting state");
_fe_vector_tags.insert(tag);

// Add any other user-added vector residual tags if they have associated vectors
Expand All @@ -312,6 +312,7 @@ EigenProblem::computeResidualTag(const NumericVector<Number> & soln,

setCurrentNonlinearSystem(_nl_eigen->number());
computeResidualTags(_fe_vector_tags);
_fe_vector_tags.clear();

_nl_eigen->disassociateVectorFromTag(residual, tag);
}
Expand All @@ -329,8 +330,8 @@ EigenProblem::computeResidualAB(const NumericVector<Number> & soln,
// specific system tags that we need for this instance
_nl_eigen->disassociateDefaultVectorTags();

// Clear FE tags and first add the specific tags associated with the residual
_fe_vector_tags.clear();
// add the specific tags associated with the residual
mooseAssert(_fe_vector_tags.empty(), "This should be empty indicating a clean starting state");
_fe_vector_tags.insert(tagA);
_fe_vector_tags.insert(tagB);

Expand All @@ -346,6 +347,7 @@ EigenProblem::computeResidualAB(const NumericVector<Number> & soln,
_nl_eigen->setSolution(soln);

computeResidualTags(_fe_vector_tags);
_fe_vector_tags.clear();

_nl_eigen->disassociateVectorFromTag(residualA, tagA);
_nl_eigen->disassociateVectorFromTag(residualB, tagB);
Expand Down
48 changes: 16 additions & 32 deletions framework/src/problems/FEProblemBase.C
Original file line number Diff line number Diff line change
Expand Up @@ -6265,10 +6265,10 @@ FEProblemBase::checkExceptionAndStopSolve(bool print_message)
// SNESSetFunctionDomainError() or directly inserting NaNs in the
// residual vector to let PETSc >= 3.6 return DIVERGED_NANORINF.
if (_current_nl_sys)
_current_nl_sys->stopSolve(_current_execute_on_flag);
_current_nl_sys->stopSolve(_current_execute_on_flag, _fe_vector_tags);

if (_current_linear_sys)
_current_nl_sys->stopSolve(_current_execute_on_flag);
_current_linear_sys->stopSolve(_current_execute_on_flag, _fe_vector_tags);

// and close Aux system (we MUST do this here; see #11525)
_aux->solution().close();
Expand Down Expand Up @@ -6300,8 +6300,9 @@ FEProblemBase::resetState()
ADReal::do_derivatives = true;
_current_execute_on_flag = EXEC_NONE;

// Clear the VectorTags and MatrixTags
clearCurrentResidualVectorTags();
clearCurrentJacobianVectorTags();
clearCurrentJacobianMatrixTags();

_safe_access_tagged_vectors = true;
_safe_access_tagged_matrices = true;
Expand Down Expand Up @@ -6639,54 +6640,35 @@ FEProblemBase::computeResidual(const NumericVector<Number> & soln,
_current_nl_sys->associateVectorToTag(residual, _current_nl_sys->residualVectorTag());
const auto & residual_vector_tags = getVectorTags(Moose::VECTOR_TAG_RESIDUAL);

mooseAssert(_fe_vector_tags.empty(), "This should be empty indicating a clean starting state");
// We filter out tags which do not have associated vectors in the current nonlinear
// system. This is essential to be able to use system-dependent residual tags.
selectVectorTagsFromSystem(*_current_nl_sys, residual_vector_tags, _fe_vector_tags);

computeResidualInternal(soln, residual, _fe_vector_tags);
_fe_vector_tags.clear();
}

void
FEProblemBase::computeResidualAndJacobian(const NumericVector<Number> & soln,
NumericVector<Number> & residual,
SparseMatrix<Number> & jacobian)
{
// vector tags
{
_current_nl_sys->associateVectorToTag(residual, _current_nl_sys->residualVectorTag());
const auto & residual_vector_tags = getVectorTags(Moose::VECTOR_TAG_RESIDUAL);

// We filter out tags which do not have associated vectors in the current nonlinear
// system. This is essential to be able to use system-dependent residual tags.
selectVectorTagsFromSystem(*_current_nl_sys, residual_vector_tags, _fe_vector_tags);

setCurrentResidualVectorTags(_fe_vector_tags);
}

// matrix tags
{
_fe_matrix_tags.clear();

auto & tags = getMatrixTags();
for (auto & tag : tags)
_fe_matrix_tags.insert(tag.second);
}

try
{
try
{
// vector tags
{
_current_nl_sys->associateVectorToTag(residual, _current_nl_sys->residualVectorTag());
const auto & residual_vector_tags = getVectorTags(Moose::VECTOR_TAG_RESIDUAL);
_current_nl_sys->associateVectorToTag(residual, _current_nl_sys->residualVectorTag());
const auto & residual_vector_tags = getVectorTags(Moose::VECTOR_TAG_RESIDUAL);

// We filter out tags which do not have associated vectors in the current nonlinear
// system. This is essential to be able to use system-dependent residual tags.
selectVectorTagsFromSystem(*_current_nl_sys, residual_vector_tags, _fe_vector_tags);
mooseAssert(_fe_vector_tags.empty(),
"This should be empty indicating a clean starting state");
// We filter out tags which do not have associated vectors in the current nonlinear
// system. This is essential to be able to use system-dependent residual tags.
selectVectorTagsFromSystem(*_current_nl_sys, residual_vector_tags, _fe_vector_tags);

setCurrentResidualVectorTags(_fe_vector_tags);
}
setCurrentResidualVectorTags(_fe_vector_tags);

// matrix tags
{
Expand Down Expand Up @@ -6793,6 +6775,8 @@ FEProblemBase::computeResidualAndJacobian(const NumericVector<Number> & soln,
}

resetState();
_fe_vector_tags.clear();
_fe_matrix_tags.clear();
}

void
Expand Down
9 changes: 3 additions & 6 deletions framework/src/systems/LinearSystem.C
Original file line number Diff line number Diff line change
Expand Up @@ -281,13 +281,10 @@ LinearSystem::solve()
}

void
LinearSystem::stopSolve(const ExecFlagType & /*exec_flag*/)
LinearSystem::stopSolve(const ExecFlagType & /*exec_flag*/,
const std::set<TagID> & vector_tags_to_close)
{
// We close the containers in case the solve restarts from a failed iteration
closeTaggedVectors(vector_tags_to_close);
_linear_implicit_system.matrix->close();
_linear_implicit_system.rhs->close();
if (_rhs_time)
_rhs_time->close();
if (_rhs_non_time)
_rhs_non_time->close();
}
2 changes: 1 addition & 1 deletion framework/src/systems/NonlinearEigenSystem.C
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ NonlinearEigenSystem::attachSLEPcCallbacks()
}

void
NonlinearEigenSystem::stopSolve(const ExecFlagType &)
NonlinearEigenSystem::stopSolve(const ExecFlagType &, const std::set<TagID> &)
{
mooseError("did not implement yet \n");
}
Expand Down
19 changes: 6 additions & 13 deletions framework/src/systems/NonlinearSystem.C
Original file line number Diff line number Diff line change
Expand Up @@ -231,29 +231,22 @@ NonlinearSystem::solve()
}

void
NonlinearSystem::stopSolve(const ExecFlagType & exec_flag)
NonlinearSystem::stopSolve(const ExecFlagType & exec_flag,
const std::set<TagID> & vector_tags_to_close)
{
PetscNonlinearSolver<Real> & solver =
static_cast<PetscNonlinearSolver<Real> &>(*sys().nonlinear_solver);

if (exec_flag == EXEC_LINEAR || exec_flag == EXEC_POSTCHECK)
{
auto ierr = SNESSetFunctionDomainError(solver.snes());
LIBMESH_CHKERR(ierr);
LibmeshPetscCall(SNESSetFunctionDomainError(solver.snes()));

// Clean up by getting vectors into a valid state for a
// (possible) subsequent solve. There may be more than just
// these...
_nl_implicit_sys.rhs->close();
if (_Re_time)
_Re_time->close();
_Re_non_time->close();
// (possible) subsequent solve.
closeTaggedVectors(vector_tags_to_close);
}
else if (exec_flag == EXEC_NONLINEAR)
{
auto ierr = SNESSetJacobianDomainError(solver.snes());
LIBMESH_CHKERR(ierr);
}
LibmeshPetscCall(SNESSetJacobianDomainError(solver.snes()));
else
mooseError("Unsupported execute flag: ", Moose::stringify(exec_flag));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
type = SMP
full = true
petsc_options_iname = '-ksp_type -pc_type -snes_atol -snes_rtol -snes_max_it'
petsc_options_value = 'bcgs bjacobi 1 1 10000'
petsc_options_value = 'bcgs bjacobi 1 .999 10000'
[]
[]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
type = SMP
full = true
petsc_options_iname = '-ksp_type -pc_type -snes_atol -snes_rtol -snes_max_it'
petsc_options_value = 'bcgs bjacobi 1 1 10000'
petsc_options_value = 'bcgs bjacobi 1 .999 10000'
[]
[]

Expand Down
2 changes: 1 addition & 1 deletion modules/porous_flow/test/tests/mass_conservation/mass01.i
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
type = SMP
full = true
petsc_options_iname = '-ksp_type -pc_type -snes_atol -snes_rtol -snes_max_it'
petsc_options_value = 'bcgs bjacobi 1 1 10000'
petsc_options_value = 'bcgs bjacobi 1 .999 10000'
[]
[]

Expand Down
2 changes: 1 addition & 1 deletion modules/porous_flow/test/tests/mass_conservation/mass02.i
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
type = SMP
full = true
petsc_options_iname = '-ksp_type -pc_type -snes_atol -snes_rtol -snes_max_it'
petsc_options_value = 'bcgs bjacobi 1 1 10000'
petsc_options_value = 'bcgs bjacobi 1 .999 10000'
[]
[]

Expand Down
2 changes: 1 addition & 1 deletion modules/richards/test/tests/mass/m01.i
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
type = SMP
full = true
petsc_options_iname = '-ksp_type -pc_type -snes_atol -snes_rtol -snes_max_it'
petsc_options_value = 'bcgs bjacobi 1 1 10000'
petsc_options_value = 'bcgs bjacobi 1 .999 10000'
[../]
[]

Expand Down
2 changes: 1 addition & 1 deletion modules/richards/test/tests/mass/m_fu_01.i
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
type = SMP
full = true
petsc_options_iname = '-ksp_type -pc_type -snes_atol -snes_rtol -snes_max_it'
petsc_options_value = 'bcgs bjacobi 1 1 10000'
petsc_options_value = 'bcgs bjacobi 1 .999 10000'
[../]
[]

Expand Down
Loading

0 comments on commit a4c8527

Please sign in to comment.