Alsvinn  0.5.3
The fast FVM simulator with UQ support
NetCDFWriter.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 "alsfvm/io/Writer.hpp"
18 #include <netcdf.h>
20 
21 namespace alsfvm {
22 namespace io {
23 
29 class NetCDFWriter : public Writer {
30 public:
37  NetCDFWriter(const std::string& basefileName);
38 
41  virtual ~NetCDFWriter() {}
42 
48  virtual void write(const volume::Volume& conservedVariables,
49  const grid::Grid& grid,
50  const simulator::TimestepInformation& timestepInformation) override;
51 protected:
59  void writeToFile(netcdf_raw_ptr file,
60  const volume::Volume& conservedVariables,
61  const grid::Grid& grid,
62  const simulator::TimestepInformation& timestepInformation);
63 
70  std::array<netcdf_raw_ptr, 3> createDimensions(netcdf_raw_ptr basegroup,
71  const volume::Volume& volume);
72 
79  void writeMemory(netcdf_raw_ptr baseGroup, netcdf_raw_ptr dataset,
80  const volume::Volume& volume, size_t memoryIndex);
81 
82 
88  void writeVolume(netcdf_raw_ptr baseGroup, const volume::Volume& volume,
89  std::array<netcdf_raw_ptr, 3> dimensions);
90 
98  std::pair<netcdf_raw_ptr, netcdf_raw_ptr> makeDataset(
99  netcdf_raw_ptr baseGroup, const volume::Volume& volume,
100  size_t memoryIndex, std::array<netcdf_raw_ptr, 3> dimensions);
101 
105  std::string getFilename();
106 
109 
110  size_t snapshotNumber{0};
111  const std::string basefileName;
112 };
113 } // namespace io
114 } // namespace alsfvm
int netcdf_raw_ptr
Definition: netcdf_utils.hpp:31
const std::string basefileName
Definition: NetCDFWriter.hpp:111
Definition: Grid.hpp:27
size_t snapshotNumber
Definition: NetCDFWriter.hpp:110
The Volume class represents a volume (a collection of cells with values for each cell (eg...
Definition: Volume.hpp:30
NetCDFWriter(const std::string &basefileName)
Definition: NetCDFWriter.cpp:27
void writeToFile(netcdf_raw_ptr file, const volume::Volume &conservedVariables, const grid::Grid &grid, const simulator::TimestepInformation &timestepInformation)
Definition: NetCDFWriter.cpp:64
Definition: NetCDFWriter.hpp:29
void addFileInformation(netcdf_raw_ptr file)
Writes basic Alsvinn info to file.
void writeVolume(netcdf_raw_ptr baseGroup, const volume::Volume &volume, std::array< netcdf_raw_ptr, 3 > dimensions)
Definition: NetCDFWriter.cpp:111
const grid::Grid & grid
Definition: NumericalFluxFactory.cpp:104
virtual ~NetCDFWriter()
Definition: NetCDFWriter.hpp:41
virtual void write(const volume::Volume &conservedVariables, const grid::Grid &grid, const simulator::TimestepInformation &timestepInformation) override
Definition: NetCDFWriter.cpp:32
std::string getFilename()
Definition: NetCDFWriter.cpp:134
std::array< netcdf_raw_ptr, 3 > createDimensions(netcdf_raw_ptr basegroup, const volume::Volume &volume)
Definition: NetCDFWriter.cpp:73
The Writer class is an abstract interface to represent output writers.
Definition: Writer.hpp:28
void writeMemory(netcdf_raw_ptr baseGroup, netcdf_raw_ptr dataset, const volume::Volume &volume, size_t memoryIndex)
Definition: NetCDFWriter.cpp:95
Various utility functions to implement the tecno flux.
Definition: types.hpp:30
std::pair< netcdf_raw_ptr, netcdf_raw_ptr > makeDataset(netcdf_raw_ptr baseGroup, const volume::Volume &volume, size_t memoryIndex, std::array< netcdf_raw_ptr, 3 > dimensions)
Definition: NetCDFWriter.cpp:123
Definition: TimestepInformation.hpp:22