netxsimdg
Loading...
Searching...
No Matches
Nextsim::ModelComponent Class Referenceabstract

#include <ModelComponent.hpp>

Inheritance diagram for Nextsim::ModelComponent:
Inheritance graph
Collaboration diagram for Nextsim::ModelComponent:
Collaboration graph

Public Types

enum class  ProtectedArray {
  H_ICE , C_ICE , H_SNOW , T_ICE ,
  T_AIR , DEW_2M , P_AIR , MIXRAT ,
  SW_IN , LW_IN , MLD , SNOW ,
  SSS , SST , EXT_SSS , EXT_SST ,
  EVAP_MINUS_PRECIP , ML_BULK_CP , TF , WIND_SPEED ,
  WIND_U , WIND_V , HTRUE_ICE , HTRUE_SNOW ,
  OCEAN_U , OCEAN_V , ICE_U , ICE_V ,
  SLAB_SST , SLAB_SSS , SLAB_QDW , SLAB_FDW ,
  COUNT
}
 
enum class  SharedArray {
  H_ICE = SharedArrayOffset , C_ICE , H_SNOW , T_ICE ,
  Q_IA , Q_IC , Q_IO , Q_OW ,
  DQIA_DT , Q_PEN_SW , HSNOW_MELT , SUBLIM ,
  DELTA_HICE , DELTA_CICE , NEW_ICE , COUNT
}
 
typedef Logged::level OutputLevel
 
typedef std::function< void(size_t, const TimestepTime &)> IteratedFn
 

Public Member Functions

virtual std::string getName () const =0
 Returns the name of the component.
 
virtual void setData (const ModelState::DataMap &state)=0
 Set the initial data of the component from the passed ModelState.
 
virtual ModelState getState () const =0
 Returns a ModelState from this component.
 
virtual ModelState getState (const OutputLevel &) const =0
 Returns a ModelState from this component at a specified level.
 
virtual ModelState getStateRecursive (const OutputSpec &os) const
 Returns the state of the ModelComponent and any ModelComponents it depends on.
 
virtual std::unordered_set< std::string > hFields () const
 Returns the names of all Type::H ModelArrays defined in this component.
 
virtual std::unordered_set< std::string > uFields () const
 Returns the names of all Type::U ModelArrays defined in this component.
 
virtual std::unordered_set< std::string > vFields () const
 Returns the names of all Type::V ModelArrays defined in this component.
 
virtual std::unordered_set< std::string > zFields () const
 Returns the names of all Type::Z ModelArrays defined in this component.
 

Static Public Member Functions

static void setAllModuleData (const ModelState &stateIn)
 
static ModelState getAllModuleState ()
 
static void unregisterAllModules ()
 
static void getAllFieldNames (std::unordered_set< std::string > &uF, std::unordered_set< std::string > &vF, std::unordered_set< std::string > &zF)
 
static void registerExternalSharedArray (SharedArray type, ModelArray *addr)
 Registers a ModelArray into a SharedArray slot from outside any ModelComponent object. Intended for testing and debugging.
 
static void registerExternalProtectedArray (ProtectedArray type, ModelArray *addr)
 Registers a ModelArray into a ProtectedArray slot from outside any ModelComponent object. Intended for testing and debugging.
 
static const MARBackingStore & getSharedArray ()
 Returns a const reference to the store for SharedArray fields.
 
static const MARConstBackingStore & getProtectedArray ()
 Returns a const reference to the store for ProtectedArray fields.
 

Static Public Attributes

static const size_t SharedArrayOffset = 0
 

Protected Member Functions

void registerModule ()
 

Static Protected Member Functions

static void registerSharedArray (SharedArray type, ModelArray *addr)
 
static void registerProtectedArray (ProtectedArray type, const ModelArray *addr)
 
static void overElements (IteratedFn fn, const TimestepTime &tst)
 
static void setOceanMask (const ModelArray &mask)
 Sets the model-wide land-ocean mask (for HField arrays).
 
static void noLandMask ()
 
static ModelArray mask (const ModelArray &data)
 Returns a copy of the provided ModelArray, masked according to the land-ocean mask.
 
static const ModelArrayoceanMask ()
 Returns the ocean mask.
 

Static Protected Attributes

static ModelArrayp_oceanMaskH = nullptr
 

Detailed Description

A class encapsulating a component of the model. It also provide a method of communicating data between ModelComponents using enums, static arrays of pointers and the ModelArrayRef class.

Definition at line 31 of file ModelComponent.hpp.

Member Typedef Documentation

◆ IteratedFn

std::function<void(size_t, const TimestepTime&)> Nextsim::ModelComponent::IteratedFn

Definition at line 103 of file ModelComponent.hpp.

◆ OutputLevel

Logged::level Nextsim::ModelComponent::OutputLevel

Definition at line 33 of file ModelComponent.hpp.

Member Enumeration Documentation

◆ ProtectedArray

enum class Nextsim::ModelComponent::ProtectedArray
strong

Definition at line 35 of file ModelComponent.hpp.

◆ SharedArray

enum class Nextsim::ModelComponent::SharedArray
strong

Definition at line 80 of file ModelComponent.hpp.

Constructor & Destructor Documentation

◆ ModelComponent()

Nextsim::ModelComponent::ModelComponent ( )

Definition at line 21 of file ModelComponent.cpp.

Member Function Documentation

◆ getAllFieldNames()

void Nextsim::ModelComponent::getAllFieldNames ( std::unordered_set< std::string > & uF,
std::unordered_set< std::string > & vF,
std::unordered_set< std::string > & zF )
static

Definition at line 42 of file ModelComponent.cpp.

◆ getAllModuleState()

ModelState Nextsim::ModelComponent::getAllModuleState ( )
static

Definition at line 29 of file ModelComponent.cpp.

◆ getName()

◆ getProtectedArray()

static const MARConstBackingStore & Nextsim::ModelComponent::getProtectedArray ( )
inlinestatic

Returns a const reference to the store for ProtectedArray fields.

Definition at line 191 of file ModelComponent.hpp.

Here is the caller graph for this function:

◆ getSharedArray()

static const MARBackingStore & Nextsim::ModelComponent::getSharedArray ( )
inlinestatic

Returns a const reference to the store for SharedArray fields.

Definition at line 186 of file ModelComponent.hpp.

Here is the caller graph for this function:

◆ getState() [1/2]

virtual ModelState Nextsim::ModelComponent::getState ( ) const
pure virtual

Returns a ModelState from this component.

The ModelState is map between field names and ModelArray data arrays. The intention is to merge together different ModelSatates to produce a combined state. The returned ModelState will include the states of any subsidiary components held by the object. This is the default level of output and should include all and only fields to be placed in the restart file.

Implemented in Nextsim::ConfigOutput, Nextsim::IDynamics, Nextsim::Module1, Nextsim::ModuleRequestAndSupply, Nextsim::ModuleSemiShared, Nextsim::ModuleShared, Nextsim::ModuleSupplyAndWait, Nextsim::PrognosticData, and Nextsim::SimpleOutput.

Here is the caller graph for this function:

◆ getState() [2/2]

virtual ModelState Nextsim::ModelComponent::getState ( const OutputLevel & ) const
pure virtual

Returns a ModelState from this component at a specified level.

See the zero argument version for more details. The output levels reuse those defined in the Logged class. The default level is NOTICE, and only levels such as INFO, DEBUG and TRACE should be used, and should provide extra diagnostic fields.

Implemented in Nextsim::ConfigOutput, Nextsim::IDynamics, Nextsim::Module1, Nextsim::ModuleRequestAndSupply, Nextsim::ModuleSemiShared, Nextsim::ModuleShared, Nextsim::ModuleSupplyAndWait, Nextsim::PrognosticData, and Nextsim::SimpleOutput.

◆ getStateRecursive()

virtual ModelState Nextsim::ModelComponent::getStateRecursive ( const OutputSpec & os) const
inlinevirtual

Returns the state of the ModelComponent and any ModelComponents it depends on.

Used to traverse the current tree of ModelComponents and return the overall model state for diagnostic output.

Reimplemented in Nextsim::ConfigOutput, and Nextsim::PrognosticData.

Definition at line 145 of file ModelComponent.hpp.

Here is the call graph for this function:

◆ hFields()

virtual std::unordered_set< std::string > Nextsim::ModelComponent::hFields ( ) const
inlinevirtual

Returns the names of all Type::H ModelArrays defined in this component.

Reimplemented in Nextsim::PrognosticData.

Definition at line 151 of file ModelComponent.hpp.

◆ mask()

ModelArray Nextsim::ModelComponent::mask ( const ModelArray & data)
staticprotected

Returns a copy of the provided ModelArray, masked according to the land-ocean mask.

Parameters
dataThe data to be masked.

Definition at line 109 of file ModelComponent.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ noLandMask()

void Nextsim::ModelComponent::noLandMask ( )
staticprotected

If there is no valid land mask, assume all points are ocean and initialize accordingly.

Definition at line 94 of file ModelComponent.cpp.

Here is the call graph for this function:

◆ oceanMask()

const ModelArray & Nextsim::ModelComponent::oceanMask ( )
staticprotected

Returns the ocean mask.

Definition at line 138 of file ModelComponent.cpp.

Here is the caller graph for this function:

◆ overElements()

static void Nextsim::ModelComponent::overElements ( IteratedFn fn,
const TimestepTime & tst )
inlinestaticprotected

Definition at line 212 of file ModelComponent.hpp.

◆ registerExternalProtectedArray()

static void Nextsim::ModelComponent::registerExternalProtectedArray ( ProtectedArray type,
ModelArray * addr )
inlinestatic

Registers a ModelArray into a ProtectedArray slot from outside any ModelComponent object. Intended for testing and debugging.

Definition at line 178 of file ModelComponent.hpp.

Here is the call graph for this function:

◆ registerExternalSharedArray()

static void Nextsim::ModelComponent::registerExternalSharedArray ( SharedArray type,
ModelArray * addr )
inlinestatic

Registers a ModelArray into a SharedArray slot from outside any ModelComponent object. Intended for testing and debugging.

Definition at line 170 of file ModelComponent.hpp.

Here is the call graph for this function:

◆ registerModule()

void Nextsim::ModelComponent::registerModule ( )
protected

Definition at line 38 of file ModelComponent.cpp.

◆ registerProtectedArray()

void Nextsim::ModelComponent::registerProtectedArray ( ProtectedArray type,
const ModelArray * addr )
staticprotected

Adds a pointer to a slot into the ProtectedArray array.

Parameters
typeThe ProtectedArray slot to add the ModelArray into.
addrThe address of the ModelArray to be shared (read only).

Definition at line 58 of file ModelComponent.cpp.

Here is the caller graph for this function:

◆ registerSharedArray()

void Nextsim::ModelComponent::registerSharedArray ( SharedArray type,
ModelArray * addr )
staticprotected

Adds a pointer to a slot into the SharedArray array.

Parameters
typeThe SharedArray slot to add the ModelArray into.
addrThe address of the ModelArray to be shared.

Definition at line 52 of file ModelComponent.cpp.

Here is the caller graph for this function:

◆ setAllModuleData()

void Nextsim::ModelComponent::setAllModuleData ( const ModelState & stateIn)
static

Definition at line 23 of file ModelComponent.cpp.

◆ setData()

virtual void Nextsim::ModelComponent::setData ( const ModelState::DataMap & state)
pure virtual

◆ setOceanMask()

void Nextsim::ModelComponent::setOceanMask ( const ModelArray & mask)
staticprotected

Sets the model-wide land-ocean mask (for HField arrays).

Parameters
maskThe HField ModelArray containing the mask data. 0/false is land, >0 is sea.

Definition at line 69 of file ModelComponent.cpp.

Here is the call graph for this function:

◆ uFields()

virtual std::unordered_set< std::string > Nextsim::ModelComponent::uFields ( ) const
inlinevirtual

Returns the names of all Type::U ModelArrays defined in this component.

Reimplemented in Nextsim::Module1, and Nextsim::PrognosticData.

Definition at line 153 of file ModelComponent.hpp.

◆ unregisterAllModules()

void Nextsim::ModelComponent::unregisterAllModules ( )
static

Definition at line 40 of file ModelComponent.cpp.

◆ vFields()

virtual std::unordered_set< std::string > Nextsim::ModelComponent::vFields ( ) const
inlinevirtual

Returns the names of all Type::V ModelArrays defined in this component.

Reimplemented in Nextsim::Module1, and Nextsim::PrognosticData.

Definition at line 155 of file ModelComponent.hpp.

◆ zFields()

virtual std::unordered_set< std::string > Nextsim::ModelComponent::zFields ( ) const
inlinevirtual

Returns the names of all Type::Z ModelArrays defined in this component.

Reimplemented in Nextsim::Module1, and Nextsim::PrognosticData.

Definition at line 157 of file ModelComponent.hpp.

Member Data Documentation

◆ p_oceanMaskH

ModelArray * Nextsim::ModelComponent::p_oceanMaskH = nullptr
staticprotected

Definition at line 244 of file ModelComponent.hpp.

◆ SharedArrayOffset

const size_t Nextsim::ModelComponent::SharedArrayOffset = 0
static

Definition at line 78 of file ModelComponent.hpp.


The documentation for this class was generated from the following files: