From e3a38ea9807b6e21e71a923101a27da6b1ef436a Mon Sep 17 00:00:00 2001 From: Geoffroy Lesur Date: Wed, 8 Nov 2023 23:34:44 +0000 Subject: [PATCH] improvement to slices --- src/output/slice.cpp | 14 ++++++++++++-- src/output/slice.hpp | 3 +++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/output/slice.cpp b/src/output/slice.cpp index 9b1c728e..ac94e988 100644 --- a/src/output/slice.cpp +++ b/src/output/slice.cpp @@ -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; @@ -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(input, sliceData.get(),prefix); @@ -135,7 +147,6 @@ void Slice::CheckForWrite(DataBlock &data) { } } } - vtk->Write(); } if(this->type == SliceType::Average) { @@ -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), diff --git a/src/output/slice.hpp b/src/output/slice.hpp index 4ebe5601..73eb182b 100644 --- a/src/output/slice.hpp +++ b/src/output/slice.hpp @@ -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_