14std::unordered_map<std::string, ModelComponent*> ModelComponent::registeredModules;
15MARBackingStore ModelComponent::sharedArrays(
static_cast<size_t>(SharedArray::COUNT));
16MARConstBackingStore ModelComponent::protectedArrays(
static_cast<size_t>(ProtectedArray::COUNT));
17ModelArray* ModelComponent::p_oceanMaskH =
nullptr;
18size_t ModelComponent::nOcean;
19std::vector<size_t> ModelComponent::oceanIndex;
21ModelComponent::ModelComponent() {
noLandMask(); }
23void ModelComponent::setAllModuleData(
const ModelState& stateIn)
25 for (
auto entry : registeredModules) {
26 entry.second->setData(stateIn.data);
29ModelState ModelComponent::getAllModuleState()
31 ModelState overallState;
32 for (
auto entry : registeredModules) {
33 overallState.data.merge(entry.second->getState().data);
38void ModelComponent::registerModule() { registeredModules[
getName()] =
this; }
40void ModelComponent::unregisterAllModules() { registeredModules.clear(); }
42void ModelComponent::getAllFieldNames(std::unordered_set<std::string>& uF,
43 std::unordered_set<std::string>& vF, std::unordered_set<std::string>& zF)
45 for (
auto entry : registeredModules) {
46 uF.merge(entry.second->uFields());
47 vF.merge(entry.second->vFields());
48 zF.merge(entry.second->zFields());
55 sharedArrays[
static_cast<size_t>(type)] = addr;
61 protectedArrays[
static_cast<size_t>(type)] = addr;
73 p_oceanMaskH =
new ModelArray(ModelArray::Type::H);
81 if (oceanMaskH[i] > 0)
84 oceanIndex.resize(nOcean);
85 size_t iOceanIndex = 0;
87 if (oceanMaskH[i] > 0) {
88 oceanIndex[iOceanIndex++] = i;
98 p_oceanMaskH =
new ModelArray(ModelArray::Type::H);
103 oceanIndex.resize(nOcean);
111 switch (data.getType()) {
116 case (ModelArray::Type::H):
117 case (ModelArray::Type::U):
118 case (ModelArray::Type::V): {
122 case (ModelArray::Type::Z): {
124 copy = MissingData::value;
125 size_t nZ = data.dimensions()[data.nDimensions() - 1];
126 for (
size_t iOcean = 0; iOcean < nOcean; ++iOcean) {
127 size_t i = oceanIndex[iOcean];
128 for (
size_t k = 0; k < nZ; ++k) {
A class that holds the array data for the model.
double & zIndexAndLayer(size_t hIndex, size_t layer)
Special access function for ZFields.
void resize()
Conditionally updates the size of the object data buffer to match the class specification.
size_t size() const
Returns the total number of elements of this type of ModelArray.
static const ModelArray & oceanMask()
Returns the ocean mask.
virtual std::string getName() const =0
Returns the name of the component.
static void registerProtectedArray(ProtectedArray type, const ModelArray *addr)
static ModelArray mask(const ModelArray &data)
Returns a copy of the provided ModelArray, masked according to the land-ocean mask.
static void setOceanMask(const ModelArray &mask)
Sets the model-wide land-ocean mask (for HField arrays).
static void registerSharedArray(SharedArray type, ModelArray *addr)