Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MeshBlock Cleanup and Smart Backpointers. Resolves #306. #307

Merged
merged 17 commits into from
Sep 26, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/mesh/mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,9 +476,9 @@ Mesh::Mesh(ParameterInput *pin, ApplicationInput *app_in, Properties_t &properti
for (int i = nbs; i <= nbe; i++) {
SetBlockSizeAndBoundaries(loclist[i], block_size, block_bcs);
// create a block and add into the link list
block_list[i - nbs] = MeshBlock::MakeAndSetNeighbors(
i, i - nbs, loclist[i], block_size, block_bcs, this, pin, app_in, properties,
packages, gflag, tree, ranklist, nslist);
block_list[i - nbs] = MeshBlock::Make(i, i - nbs, loclist[i], block_size, block_bcs,
this, pin, app_in, properties, packages, gflag);
block_list[i - nbs]->SearchAndSetNeighbors(tree, ranklist.data(), nslist.data());
}

ResetLoadBalanceVariables();
Expand Down Expand Up @@ -737,9 +737,10 @@ Mesh::Mesh(ParameterInput *pin, ApplicationInput *app_in, RestartReader &rr,
SetBlockSizeAndBoundaries(loclist[i], block_size, block_bcs);

// create a block and add into the link list
block_list[i - nbs] = MeshBlock::MakeAndSetNeighbors(
i, i - nbs, loclist[i], block_size, block_bcs, this, pin, app_in, properties,
packages, gflag, tree, ranklist, nslist, costlist[i]);
block_list[i - nbs] =
MeshBlock::Make(i, i - nbs, loclist[i], block_size, block_bcs, this, pin, app_in,
properties, packages, gflag, costlist[i]);
block_list[i - nbs]->SearchAndSetNeighbors(tree, ranklist.data(), nslist.data());
}

ResetLoadBalanceVariables();
Expand Down
30 changes: 11 additions & 19 deletions src/mesh/mesh.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,6 @@ class MeshBlock : public std::enable_shared_from_this<MeshBlock> {
MeshBlock(const int n_side, const int ndim); // for Kokkos testing with ghost
~MeshBlock();

// Initializer to set up a meshblock called with the default constructor
// This is necessary because the back pointers can't be set up until
// the block is allocated.
void Initialize(int igid, int ilid, LogicalLocation iloc, RegionSize input_block,
BoundaryFlag *input_bcs, Mesh *pm, ParameterInput *pin,
ApplicationInput *app_in, Properties_t &properties,
Packages_t &packages, int igflag, double icost = 1.0);
// Factory method deals with initialization for you
static std::shared_ptr<MeshBlock>
Make(int igid, int ilid, LogicalLocation iloc, RegionSize input_block,
Expand All @@ -99,17 +92,6 @@ class MeshBlock : public std::enable_shared_from_this<MeshBlock> {
packages, igflag, icost);
return pmb;
}
static std::shared_ptr<MeshBlock> MakeAndSetNeighbors(
int igid, int ilid, LogicalLocation iloc, RegionSize input_block,
BoundaryFlag *input_bcs, Mesh *pm, ParameterInput *pin, ApplicationInput *app_in,
Properties_t &properties, Packages_t &packages, int igflag, MeshBlockTree &tree,
std::vector<int> &ranklist, std::vector<int> &nslist, double icost = 1.0) {
auto pmb = std::make_shared<MeshBlock>();
pmb->Initialize(igid, ilid, iloc, input_block, input_bcs, pm, pin, app_in, properties,
packages, igflag, icost);
pmb->pbval->SearchAndSetNeighbors(tree, ranklist.data(), nslist.data());
return pmb;
}

// Kokkos execution space for this MeshBlock
DevExecSpace exec_space;
Expand Down Expand Up @@ -276,7 +258,9 @@ class MeshBlock : public std::enable_shared_from_this<MeshBlock> {
int GetNumberOfMeshBlockCells() const {
return block_size.nx1 * block_size.nx2 * block_size.nx3;
}
void SearchAndSetNeighbors(MeshBlockTree &tree, int *ranklist, int *nslist);
void SearchAndSetNeighbors(MeshBlockTree &tree, int *ranklist, int *nslist) {
Yurlungur marked this conversation as resolved.
Show resolved Hide resolved
pbval->SearchAndSetNeighbors(tree,ranklist,nslist);
}
void WeightedAve(ParArrayND<Real> &u_out, ParArrayND<Real> &u_in1,
ParArrayND<Real> &u_in2, const Real wght[3]);
void WeightedAve(FaceField &b_out, FaceField &b_in1, FaceField &b_in2,
Expand Down Expand Up @@ -307,6 +291,14 @@ class MeshBlock : public std::enable_shared_from_this<MeshBlock> {
std::vector<std::shared_ptr<CellVariable<Real>>> vars_cc_;
std::vector<std::shared_ptr<FaceField>> vars_fc_;

// Initializer to set up a meshblock called with the default constructor
// This is necessary because the back pointers can't be set up until
// the block is allocated.
void Initialize(int igid, int ilid, LogicalLocation iloc, RegionSize input_block,
BoundaryFlag *input_bcs, Mesh *pm, ParameterInput *pin,
ApplicationInput *app_in, Properties_t &properties,
Packages_t &packages, int igflag, double icost = 1.0);

void InitializeIndexShapes(const int nx1, const int nx2, const int nx3);
// functions
void SetCostForLoadBalancing(double cost);
Expand Down