-
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 branch 'develop' into mg/tensor_indices
- Loading branch information
Showing
20 changed files
with
739 additions
and
588 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
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 |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
// Copyright(C) 2014 James M. Stone <[email protected]> and other code contributors | ||
// Licensed under the 3-clause BSD License, see LICENSE file for details | ||
//======================================================================================== | ||
// (C) (or copyright) 2020. Triad National Security, LLC. All rights reserved. | ||
// (C) (or copyright) 2020-2024. 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 | ||
|
@@ -23,6 +23,7 @@ | |
#include <type_traits> | ||
#include <vector> | ||
|
||
#include "basic_types.hpp" | ||
#include "defs.hpp" | ||
|
||
namespace parthenon { | ||
|
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 |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
// Copyright(C) 2014 James M. Stone <[email protected]> and other code contributors | ||
// Licensed under the 3-clause BSD License, see LICENSE file for details | ||
//======================================================================================== | ||
// (C) (or copyright) 2020-2023. Triad National Security, LLC. All rights reserved. | ||
// (C) (or copyright) 2020-2024. 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 | ||
|
@@ -156,6 +156,9 @@ Mesh::Mesh(ParameterInput *pin, ApplicationInput *app_in, Packages_t &packages, | |
if (app_in->MeshProblemGenerator != nullptr) { | ||
ProblemGenerator = app_in->MeshProblemGenerator; | ||
} | ||
if (app_in->MeshPostInitialization != nullptr) { | ||
PostInitialization = app_in->MeshPostInitialization; | ||
} | ||
if (app_in->PreStepMeshUserWorkInLoop != nullptr) { | ||
PreStepUserWorkInLoop = app_in->PreStepMeshUserWorkInLoop; | ||
} | ||
|
@@ -930,6 +933,10 @@ void Mesh::Initialize(bool init_problem, ParameterInput *pin, ApplicationInput * | |
PARTHENON_REQUIRE_THROWS( | ||
!(ProblemGenerator != nullptr && block_list[0]->ProblemGenerator != nullptr), | ||
"Mesh and MeshBlock ProblemGenerators are defined. Please use only one."); | ||
PARTHENON_REQUIRE_THROWS( | ||
!(PostInitialization != nullptr && | ||
block_list[0]->PostInitialization != nullptr), | ||
"Mesh and MeshBlock PostInitializations are defined. Please use only one."); | ||
|
||
// Call Mesh ProblemGenerator | ||
if (ProblemGenerator != nullptr) { | ||
|
@@ -946,6 +953,23 @@ void Mesh::Initialize(bool init_problem, ParameterInput *pin, ApplicationInput * | |
pmb->ProblemGenerator(pmb.get(), pin); | ||
} | ||
} | ||
|
||
// Call Mesh PostInitialization | ||
if (PostInitialization != nullptr) { | ||
PARTHENON_REQUIRE(num_partitions == 1, | ||
"Mesh PostInitialization requires parthenon/mesh/pack_size=-1 " | ||
"during first initialization."); | ||
|
||
auto &md = mesh_data.GetOrAdd("base", 0); | ||
PostInitialization(this, pin, md.get()); | ||
// Call individual MeshBlock PostInitialization | ||
} else { | ||
for (int i = 0; i < nmb; ++i) { | ||
auto &pmb = block_list[i]; | ||
pmb->PostInitialization(pmb.get(), pin); | ||
} | ||
} | ||
|
||
std::for_each(block_list.begin(), block_list.end(), | ||
[](auto &sp_block) { sp_block->SetAllVariablesToInitialized(); }); | ||
} | ||
|
@@ -1202,6 +1226,22 @@ int Mesh::GetNumberOfMeshBlockCells() const { | |
} | ||
const RegionSize &Mesh::GetBlockSize() const { return base_block_size; } | ||
|
||
const IndexShape &Mesh::GetLeafBlockCellBounds(CellLevel level) const { | ||
// TODO(JMM): Luke this is for your Metadata::fine stuff. | ||
PARTHENON_DEBUG_REQUIRE(level != CellLevel::fine, | ||
"Currently no access to finer cellbounds"); | ||
MeshBlock *pmb = block_list[0].get(); | ||
if (level == CellLevel::same) { | ||
return pmb->cellbounds; | ||
// TODO(JMM): | ||
// } else if (level == CellLevel::fine) { | ||
// return pmb->fine_cellbounds; | ||
// } | ||
} else { // if (level == CellLevel::coarse) { | ||
return pmb->c_cellbounds; | ||
} | ||
} | ||
|
||
// Functionality re-used in mesh constructor | ||
void Mesh::RegisterLoadBalancing_(ParameterInput *pin) { | ||
#ifdef MPI_PARALLEL // JMM: Not sure this ifdef is needed | ||
|
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 |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
// Copyright(C) 2014 James M. Stone <[email protected]> and other code contributors | ||
// Licensed under the 3-clause BSD License, see LICENSE file for details | ||
//======================================================================================== | ||
// (C) (or copyright) 2020-2023. Triad National Security, LLC. All rights reserved. | ||
// (C) (or copyright) 2020-2024. 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 | ||
|
@@ -98,6 +98,7 @@ class Mesh { | |
int GetNumberOfMeshBlockCells() const; | ||
const RegionSize &GetBlockSize() const; | ||
RegionSize GetBlockSize(const LogicalLocation &loc) const; | ||
const IndexShape &GetLeafBlockCellBounds(CellLevel level = CellLevel::same) const; | ||
|
||
// data | ||
bool modified; | ||
|
@@ -160,6 +161,8 @@ class Mesh { | |
// defined in either the prob file or default_pgen.cpp in ../pgen/ | ||
std::function<void(Mesh *, ParameterInput *, MeshData<Real> *)> ProblemGenerator = | ||
nullptr; | ||
std::function<void(Mesh *, ParameterInput *, MeshData<Real> *)> PostInitialization = | ||
nullptr; | ||
static void UserWorkAfterLoopDefault(Mesh *mesh, ParameterInput *pin, | ||
SimTime &tm); // called in main loop | ||
std::function<void(Mesh *, ParameterInput *, SimTime &)> UserWorkAfterLoop = | ||
|
@@ -194,6 +197,20 @@ class Mesh { | |
std::vector<int> GetNbList() const noexcept { return nblist; } | ||
std::vector<LogicalLocation> GetLocList() const noexcept { return loclist; } | ||
|
||
// TODO(JMM): Put in implementation file? | ||
auto GetLevelsAndLogicalLocationsFlat() const noexcept { | ||
std::vector<std::int64_t> levels, logicalLocations; | ||
levels.reserve(nbtotal); | ||
logicalLocations.reserve(nbtotal * 3); | ||
for (const auto &loc : loclist) { | ||
levels.push_back(loc.level() - GetRootLevel()); | ||
logicalLocations.push_back(loc.lx1()); | ||
logicalLocations.push_back(loc.lx2()); | ||
logicalLocations.push_back(loc.lx3()); | ||
} | ||
return std::make_pair(levels, logicalLocations); | ||
} | ||
|
||
void OutputMeshStructure(const int dim, const bool dump_mesh_structure = true); | ||
|
||
// Ordering here is important to prevent deallocation of pools before boundary | ||
|
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 |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
// Copyright(C) 2014 James M. Stone <[email protected]> and other code contributors | ||
// Licensed under the 3-clause BSD License, see LICENSE file for details | ||
//======================================================================================== | ||
// (C) (or copyright) 2020-2023. Triad National Security, LLC. All rights reserved. | ||
// (C) (or copyright) 2020-2024. 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 | ||
|
@@ -115,6 +115,12 @@ void MeshBlock::Initialize(int igid, int ilid, LogicalLocation iloc, | |
} else if (app_in->MeshProblemGenerator == nullptr) { | ||
ProblemGenerator = &ProblemGeneratorDefault; | ||
} | ||
if (app_in->PostInitialization != nullptr) { | ||
PostInitialization = app_in->PostInitialization; | ||
// Only set default post-init when no mesh post-init is set | ||
} else if (app_in->MeshPostInitialization == nullptr) { | ||
PostInitialization = &PostInitializationDefault; | ||
} | ||
if (app_in->MeshBlockUserWorkBeforeOutput != nullptr) { | ||
UserWorkBeforeOutput = app_in->MeshBlockUserWorkBeforeOutput; | ||
} | ||
|
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 |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
// Copyright(C) 2014 James M. Stone <[email protected]> and other code contributors | ||
// Licensed under the 3-clause BSD License, see LICENSE file for details | ||
//======================================================================================== | ||
// (C) (or copyright) 2020-2023. Triad National Security, LLC. All rights reserved. | ||
// (C) (or copyright) 2020-2024. 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 | ||
|
@@ -440,7 +440,9 @@ class MeshBlock : public std::enable_shared_from_this<MeshBlock> { | |
|
||
// defined in either the prob file or default_pgen.cpp in ../pgen/ | ||
static void ProblemGeneratorDefault(MeshBlock *pmb, ParameterInput *pin); | ||
static void PostInitializationDefault(MeshBlock *pmb, ParameterInput *pin); | ||
std::function<void(MeshBlock *, ParameterInput *)> ProblemGenerator = nullptr; | ||
std::function<void(MeshBlock *, ParameterInput *)> PostInitialization = nullptr; | ||
static pMeshBlockApplicationData_t | ||
InitApplicationMeshBlockDataDefault(MeshBlock *, ParameterInput *pin); | ||
std::function<pMeshBlockApplicationData_t(MeshBlock *, ParameterInput *)> | ||
|
Oops, something went wrong.