Skip to content

Commit

Permalink
improvement to slices
Browse files Browse the repository at this point in the history
  • Loading branch information
glesur committed Nov 9, 2023
1 parent cf235d3 commit e3a38ea
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/output/slice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ Slice::Slice(Input &input, DataBlock & data, int nSlice, SliceType type,
if(slicePeriod> 0) {
sliceLast = data.t - slicePeriod;
}
// Register the last output in dumps so that we restart from the right slice
data.dump->RegisterVariable(&sliceLast, std::string("vtk")+prefix+std::string("Last"));
// Create the slice.
this->type = type;
this->direction = direction;
Expand All @@ -32,6 +34,16 @@ Slice::Slice(Input &input, DataBlock & data, int nSlice, SliceType type,
this->containsX0 = (data.xbeg[direction] <= x0)
&& (data.xend[direction] >= x0);

#ifdef WITH_MPI
if(type==SliceType::Average) {
// Create a communicator on which we can do the sum accross processors
int remainDims[3] = {false, false, false};
remainDims[direction] = true;
MPI_Cart_sub(subgrid->parentGrid->CartComm, remainDims, &avgComm);
}
#endif


// Initialize the vtk routines
this->vtk = std::make_unique<Vtk>(input, sliceData.get(),prefix);

Expand Down Expand Up @@ -135,7 +147,6 @@ void Slice::CheckForWrite(DataBlock &data) {
}
}
}

vtk->Write();
}
if(this->type == SliceType::Average) {
Expand Down Expand Up @@ -164,7 +175,6 @@ void Slice::CheckForWrite(DataBlock &data) {
// Create a communicator on which we can do the sum accross processors
int remainDims[3] = {false, false, false};
remainDims[direction] = true;
MPI_Comm avgComm;
MPI_Cart_sub(subgrid->parentGrid->CartComm, remainDims, &avgComm);
MPI_Allreduce(MPI_IN_PLACE, Vcout.data(),
Vcout.extent(0)*Vcout.extent(1)*Vcout.extent(2)*Vcout.extent(3),
Expand Down
3 changes: 3 additions & 0 deletions src/output/slice.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ class Slice {
UserDefVariablesContainer userDefVariableFull;
UserDefVariablesContainer userDefVariableSliced;
UserDefVariablesFunc userDefVariablesFunc{NULL};
#ifdef WITH_MPI
MPI_Comm avgComm; // Communicator for averages
#endif
};

#endif // OUTPUT_SLICE_HPP_

0 comments on commit e3a38ea

Please sign in to comment.