-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #911 from parthenon-hpc-lab/lroberts36/add-multi-grid
Geometric Multigrid
- Loading branch information
Showing
58 changed files
with
3,441 additions
and
784 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#========================================================================================= | ||
# (C) (or copyright) 2023. Triad National Security, LLC. All rights reserved. | ||
# | ||
# This program was produced under U.S. Government contract 89233218CNA000001 for Los | ||
# Alamos National Laboratory (LANL), which is operated by Triad National Security, LLC | ||
# for the U.S. Department of Energy/National Nuclear Security Administration. All rights | ||
# in the program are reserved by Triad National Security, LLC, and the U.S. Department | ||
# of Energy/National Nuclear Security Administration. The Government is granted for | ||
# itself and others acting on its behalf a nonexclusive, paid-up, irrevocable worldwide | ||
# license in this material to reproduce, prepare derivative works, distribute copies to | ||
# the public, perform publicly and display publicly, and to permit others to do so. | ||
#========================================================================================= | ||
|
||
get_property(DRIVER_LIST GLOBAL PROPERTY DRIVERS_USED_IN_TESTS) | ||
if( "poisson-gmg-example" IN_LIST DRIVER_LIST OR NOT PARTHENON_DISABLE_EXAMPLES) | ||
add_executable( | ||
poisson-gmg-example | ||
poisson_driver.cpp | ||
poisson_driver.hpp | ||
poisson_package.cpp | ||
poisson_package.hpp | ||
main.cpp | ||
parthenon_app_inputs.cpp | ||
) | ||
target_link_libraries(poisson-gmg-example PRIVATE Parthenon::parthenon) | ||
lint_target(poisson-gmg-example) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
//======================================================================================== | ||
// (C) (or copyright) 2023. Triad National Security, LLC. All rights reserved. | ||
// | ||
// This program was produced under U.S. Government contract 89233218CNA000001 for Los | ||
// Alamos National Laboratory (LANL), which is operated by Triad National Security, LLC | ||
// for the U.S. Department of Energy/National Nuclear Security Administration. All rights | ||
// in the program are reserved by Triad National Security, LLC, and the U.S. Department | ||
// of Energy/National Nuclear Security Administration. The Government is granted for | ||
// itself and others acting on its behalf a nonexclusive, paid-up, irrevocable worldwide | ||
// license in this material to reproduce, prepare derivative works, distribute copies to | ||
// the public, perform publicly and display publicly, and to permit others to do so. | ||
//======================================================================================== | ||
|
||
#include "bvals/boundary_conditions_generic.hpp" | ||
#include "parthenon_manager.hpp" | ||
|
||
#include "poisson_driver.hpp" | ||
|
||
using namespace parthenon; | ||
using namespace parthenon::BoundaryFunction; | ||
// We need to register FixedFace boundary conditions by hand since they can't | ||
// be chosen in the parameter input file. FixedFace boundary conditions assume | ||
// Dirichlet booundary conditions on the face of the domain and linearly extrapolate | ||
// into the ghosts to ensure the linear reconstruction on the block face obeys the | ||
// chosen boundary condition. Just setting the ghost zones of CC variables to a fixed | ||
// value results in poor MG convergence because the effective BC at the face | ||
// changes with MG level. | ||
template <CoordinateDirection DIR, BCSide SIDE> | ||
auto GetBoundaryCondition() { | ||
return [](std::shared_ptr<MeshBlockData<Real>> &rc, bool coarse) -> void { | ||
using namespace parthenon; | ||
using namespace parthenon::BoundaryFunction; | ||
GenericBC<DIR, SIDE, BCType::FixedFace, variable_names::any>(rc, coarse, 0.0); | ||
}; | ||
} | ||
|
||
int main(int argc, char *argv[]) { | ||
using parthenon::ParthenonManager; | ||
using parthenon::ParthenonStatus; | ||
ParthenonManager pman; | ||
|
||
// Redefine parthenon defaults | ||
pman.app_input->ProcessPackages = poisson_example::ProcessPackages; | ||
pman.app_input->MeshProblemGenerator = poisson_example::ProblemGenerator; | ||
|
||
// call ParthenonInit to initialize MPI and Kokkos, parse the input deck, and set up | ||
auto manager_status = pman.ParthenonInitEnv(argc, argv); | ||
if (manager_status == ParthenonStatus::complete) { | ||
pman.ParthenonFinalize(); | ||
return 0; | ||
} | ||
if (manager_status == ParthenonStatus::error) { | ||
pman.ParthenonFinalize(); | ||
return 1; | ||
} | ||
// Now that ParthenonInit has been called and setup succeeded, the code can now | ||
// make use of MPI and Kokkos | ||
|
||
// Set boundary conditions | ||
pman.app_input->boundary_conditions[parthenon::BoundaryFace::inner_x1] = | ||
GetBoundaryCondition<X1DIR, BCSide::Inner>(); | ||
pman.app_input->boundary_conditions[parthenon::BoundaryFace::inner_x2] = | ||
GetBoundaryCondition<X2DIR, BCSide::Inner>(); | ||
pman.app_input->boundary_conditions[parthenon::BoundaryFace::inner_x3] = | ||
GetBoundaryCondition<X3DIR, BCSide::Inner>(); | ||
pman.app_input->boundary_conditions[parthenon::BoundaryFace::outer_x1] = | ||
GetBoundaryCondition<X1DIR, BCSide::Outer>(); | ||
pman.app_input->boundary_conditions[parthenon::BoundaryFace::outer_x2] = | ||
GetBoundaryCondition<X2DIR, BCSide::Outer>(); | ||
pman.app_input->boundary_conditions[parthenon::BoundaryFace::outer_x3] = | ||
GetBoundaryCondition<X3DIR, BCSide::Outer>(); | ||
pman.ParthenonInitPackagesAndMesh(); | ||
|
||
// This needs to be scoped so that the driver object is destructed before Finalize | ||
bool success = true; | ||
{ | ||
// Initialize the driver | ||
poisson_example::PoissonDriver driver(pman.pinput.get(), pman.app_input.get(), | ||
pman.pmesh.get()); | ||
|
||
// This line actually runs the simulation | ||
auto driver_status = driver.Execute(); | ||
if (driver_status != parthenon::DriverStatus::complete || | ||
driver.final_rms_residual > 1.e-10 || driver.final_rms_error > 1.e-12) | ||
success = false; | ||
} | ||
// call MPI_Finalize and Kokkos::finalize if necessary | ||
pman.ParthenonFinalize(); | ||
if (Globals::my_rank == 0) printf("success: %i\n", success); | ||
|
||
// MPI and Kokkos can no longer be used | ||
return static_cast<int>(!success); | ||
} |
Oops, something went wrong.