netxsimdg
Loading...
Searching...
No Matches
PrognosticData.cpp
Go to the documentation of this file.
1
9
11#include "include/Module.hpp"
12
13namespace Nextsim {
14
15PrognosticData::PrognosticData()
16 : m_dt(1)
17 , m_thick(ModelArray::Type::H)
18 , m_conc(ModelArray::Type::H)
19 , m_snow(ModelArray::Type::H)
20 , m_tice(ModelArray::Type::Z)
21 , pAtmBdy(0)
22 , pOcnBdy(0)
23 , pDynamics(0)
24
25{
26 registerProtectedArray(ProtectedArray::H_ICE, &m_thick);
27 registerProtectedArray(ProtectedArray::C_ICE, &m_conc);
28 registerProtectedArray(ProtectedArray::H_SNOW, &m_snow);
29 registerProtectedArray(ProtectedArray::T_ICE, &m_tice);
30}
31
32void PrognosticData::configure()
33{
34 pAtmBdy = &Module::getImplementation<IAtmosphereBoundary>();
35 tryConfigure(pAtmBdy);
36
37 pOcnBdy = &Module::getImplementation<IOceanBoundary>();
38 tryConfigure(pOcnBdy);
39
40 pDynamics = &Module::getImplementation<IDynamics>();
41 tryConfigure(pDynamics);
42
43 tryConfigure(iceGrowth);
44}
45
46void PrognosticData::setData(const ModelState::DataMap& ms)
47{
48
49 if (ms.count("mask")) {
50 setOceanMask(ms.at("mask"));
51 } else {
52 noLandMask();
53 }
54
55 m_thick = ms.at("hice");
56 m_conc = ms.at("cice");
57 m_tice = ms.at("tice");
58 m_snow = ms.at("hsnow");
59
60 pAtmBdy->setData(ms);
61 pOcnBdy->setData(ms);
62 pDynamics->setData(ms);
63 iceGrowth.setData(ms);
64}
65
66void PrognosticData::update(const TimestepTime& tst)
67{
68 // Debugging MARs
72
73 pOcnBdy->updateBefore(tst);
74 pAtmBdy->update(tst);
75
76 // Fill the values of the true ice and snow thicknesses.
77 iceGrowth.initializeThicknesses();
78 pDynamics->update(tst);
79 updatePrognosticFields();
80
81 // Take the updated values of the true ice and snow thicknesses, and reset hice0 and hsnow0
82 // IceGrowth updates its own fields during update
83 iceGrowth.update(tst);
84 updatePrognosticFields();
85
86 pOcnBdy->updateAfter(tst);
87}
88
89void PrognosticData::updatePrognosticFields()
90{
95
96 // Calculate the cell average thicknesses
97 HField hiceUpd = hiceTrueUpd * ciceUpd;
98 HField hsnowUpd = hsnowTrueUpd * ciceUpd;
99
100 m_thick.setData(hiceUpd);
101 m_conc.setData(ciceUpd);
102 m_snow.setData(hsnowUpd);
103 m_tice.setData(ticeUpd);
104}
105
106ModelState PrognosticData::getState() const
107{
108 return { {
109 { "mask", ModelArray(oceanMask()) }, // make a copy
110 { "hice", mask(m_thick) },
111 { "cice", mask(m_conc) },
112 { "hsnow", mask(m_snow) },
113 { "tice", mask(m_tice) },
114 { "sst", mask(*getProtectedArray().at(static_cast<size_t>(ProtectedArray::SST))) },
115 { "sss", mask(*getProtectedArray().at(static_cast<size_t>(ProtectedArray::SSS))) },
116 },
117 {} };
118}
119
120ModelState PrognosticData::getStateRecursive(const OutputSpec& os) const
121{
122 ModelState state(getState());
123 state.merge(pAtmBdy->getStateRecursive(os));
124 state.merge(iceGrowth.getStateRecursive(os));
125 // Neither OceanBdoudary nor Dynamics contribute to the output model state
126 return os ? state : ModelState();
127}
128
129PrognosticData::HelpMap& PrognosticData::getHelpText(HelpMap& map, bool getAll) { return map; }
130PrognosticData::HelpMap& PrognosticData::getHelpRecursive(HelpMap& map, bool getAll)
131{
132 Module::getHelpRecursive<IAtmosphereBoundary>(map, getAll);
133 Module::getHelpRecursive<IOceanBoundary>(map, getAll);
134 Module::getHelpRecursive<IDynamics>(map, getAll);
135 IceGrowth::getHelpRecursive(map, getAll);
136 return map;
137}
138
139} /* namespace Nextsim */
void tryConfigure(T &t)
Template function for conditionally configuring references.
A class that holds the array data for the model.
A class which provides indirect access to ModelArray.