netxsimdg
Loading...
Searching...
No Matches
DevGrid.hpp
Go to the documentation of this file.
1
8#ifndef DEVGRID_HPP
9#define DEVGRID_HPP
10
12
15
16#include <map>
17
18namespace Nextsim {
19
20class DevGridIO;
21
23class DevGrid : public IStructure {
24public:
25 DevGrid()
26 : pio(nullptr)
27 {
28 }
29
31 virtual ~DevGrid()
32 {
33 if (pio) {
34 delete pio;
35 }
36 }
37
38 const static int nx;
39 const static std::string structureName;
40
41 // Read/write override functions
42 ModelState getModelState(const std::string& filePath) override
43 {
44 return pio ? pio->getModelState(filePath) : ModelState();
45 }
46
48 const ModelState& state, const ModelMetadata& metadata, const std::string& filePath, bool isRestart = false) const override
49 {
50 if (pio)
51 pio->dumpModelState(state, metadata, filePath, isRestart);
52 }
53 const std::string& structureType() const override { return structureName; };
54
55 int nIceLayers() const override { return 1; };
56
58 void setIO(IDevGridIO* p) { pio = p; }
59
60 const static std::string xDimName;
61 const static std::string yDimName;
62 const static std::string nIceLayersName;
63
64private:
65 IDevGridIO* pio;
66
67 friend DevGridIO;
68};
69
70} /* namespace Nextsim */
71
72#endif /* DEVGRID_HPP */
A class to hold a grid of ElementData instances in a fixed sized square grid.
Definition DevGrid.hpp:23
int nIceLayers() const override
The number of ice layers in this data structure.
Definition DevGrid.hpp:55
void dumpModelState(const ModelState &state, const ModelMetadata &metadata, const std::string &filePath, bool isRestart=false) const override
Dumps the data to a file path.
Definition DevGrid.hpp:47
void setIO(IDevGridIO *p)
Sets the pointer to the class that will perform the IO. Should be an instance of DevGridIO.
Definition DevGrid.hpp:58
const std::string & structureType() const override
Returns the structure name that this class will process.
Definition DevGrid.hpp:53
ModelState getModelState(const std::string &filePath) override
Dumps the data to a file path.
Definition DevGrid.hpp:42
virtual ~DevGrid()
Destructor. The lifetime of pio should be the lifetime of the instance.
Definition DevGrid.hpp:31
A class to implemented the actual IO for DevGrid, isolating the NetCDF libraries from the rest of the...
Definition DevGridIO.hpp:21
A class that deals with all the netCDF related parts of DevGrid.
virtual ModelState getModelState(const std::string &filePath) const =0
Generates the ModelState based on the data in the given file.
virtual void dumpModelState(const ModelState &state, const ModelMetadata &metadata, const std::string &filePath, bool isRestart) const =0
Dumps the given ModelState to the given file path.
Interface class for the model structure.