Alsvinn  0.5.3
The fast FVM simulator with UQ support
NetCDFMPIWriter.hpp
Go to the documentation of this file.
1 /* Copyright (c) 2018 ETH Zurich, Kjetil Olsen Lye
2  * This program is free software: you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation, either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program. If not, see <http://www.gnu.org/licenses/>.
14  */
15 
16 #pragma once
17 #include <mpi.h>
19 namespace alsfvm {
20 namespace io {
21 
29 class NetCDFMPIWriter : public NetCDFWriter {
30 public:
51  NetCDFMPIWriter(const std::string& basefileName,
52  const std::vector<std::string>& groupNames,
53  size_t groupIndex,
54  bool newFile,
55  MPI_Comm mpiCommunicator,
56  MPI_Info mpiInfo);
57 
59  virtual ~NetCDFMPIWriter() {}
60 
61 
78  virtual void write(const volume::Volume& conservedVariables,
79  const grid::Grid& grid,
80  const simulator::TimestepInformation& timestepInformation) override;
81 
82 protected:
83  typedef std::array<netcdf_raw_ptr, 3> dimension_vector;
84 
95  virtual dimension_vector createDimensions(netcdf_raw_ptr basegroup,
96  const grid::Grid& grid,
97  bool newFile);
98 
99 
114  virtual std::vector<netcdf_raw_ptr>
115  makeDataset(netcdf_raw_ptr baseGroup, const volume::Volume& volume,
116  std::array<netcdf_raw_ptr, 3> dimensions);
117 
126  virtual void writeToFile(netcdf_raw_ptr file,
127  const volume::Volume& conservedVariables,
128  const grid::Grid& grid,
129  const simulator::TimestepInformation& timestepInformation,
130  bool newFile);
131 
132 
141  virtual void writeMemory(netcdf_raw_ptr baseGroup,
142  netcdf_raw_ptr dataset,
143  const volume::Volume& volume,
144  size_t memoryIndex,
145  const grid::Grid& grid);
146 
147 
158  virtual void writeVolume(netcdf_raw_ptr baseGroup,
159  const volume::Volume& volume,
160  std::array<netcdf_raw_ptr, 3> dimensions,
161  const std::vector<netcdf_raw_ptr>& datasets,
162  const grid::Grid& grid);
163 
164 
165 private:
166  const std::vector<std::string> groupNames;
167  const size_t groupIndex;
168  const bool newFile;
169  MPI_Comm mpiCommunicator;
170  MPI_Info mpiInfo;
171 
172 };
173 } // namespace io
174 } // namespace alsfvm
virtual dimension_vector createDimensions(netcdf_raw_ptr basegroup, const grid::Grid &grid, bool newFile)
Definition: NetCDFMPIWriter.cpp:100
int netcdf_raw_ptr
Definition: netcdf_utils.hpp:31
const std::string basefileName
Definition: NetCDFWriter.hpp:111
Definition: Grid.hpp:27
virtual void writeMemory(netcdf_raw_ptr baseGroup, netcdf_raw_ptr dataset, const volume::Volume &volume, size_t memoryIndex, const grid::Grid &grid)
Definition: NetCDFMPIWriter.cpp:179
virtual void writeVolume(netcdf_raw_ptr baseGroup, const volume::Volume &volume, std::array< netcdf_raw_ptr, 3 > dimensions, const std::vector< netcdf_raw_ptr > &datasets, const grid::Grid &grid)
Definition: NetCDFMPIWriter.cpp:220
virtual ~NetCDFMPIWriter()
We could inherit from this, hence virtual destructor.
Definition: NetCDFMPIWriter.hpp:59
The Volume class represents a volume (a collection of cells with values for each cell (eg...
Definition: Volume.hpp:30
NetCDFMPIWriter(const std::string &basefileName, const std::vector< std::string > &groupNames, size_t groupIndex, bool newFile, MPI_Comm mpiCommunicator, MPI_Info mpiInfo)
NetCDFMPIWriter constructs a new NetCDFMPIWriter.
Definition: NetCDFMPIWriter.cpp:31
Definition: NetCDFWriter.hpp:29
const grid::Grid & grid
Definition: NumericalFluxFactory.cpp:104
std::array< netcdf_raw_ptr, 3 > dimension_vector
Definition: NetCDFMPIWriter.hpp:83
virtual std::vector< netcdf_raw_ptr > makeDataset(netcdf_raw_ptr baseGroup, const volume::Volume &volume, std::array< netcdf_raw_ptr, 3 > dimensions)
Definition: NetCDFMPIWriter.cpp:126
virtual void writeToFile(netcdf_raw_ptr file, const volume::Volume &conservedVariables, const grid::Grid &grid, const simulator::TimestepInformation &timestepInformation, bool newFile)
Definition: NetCDFMPIWriter.cpp:162
Various utility functions to implement the tecno flux.
Definition: types.hpp:30
Definition: NetCDFMPIWriter.hpp:29
virtual void write(const volume::Volume &conservedVariables, const grid::Grid &grid, const simulator::TimestepInformation &timestepInformation) override
write writes the data to disk
Definition: NetCDFMPIWriter.cpp:44
Definition: TimestepInformation.hpp:22