WARPXM v1.10.0
Loading...
Searching...
No Matches
WmVariable Class Reference

Base class for variables that store one or more components of data. More...

#include <wmvariable.h>

Inheritance diagram for WmVariable:
WxObject WmDistributedVariable WmUnstructuredArray

Detailed Description

Base class for variables that store one or more components of data.

No assumption about data element connectivity or array properties is made.

Classes

struct  SwapImpl
 

Public Types

typedef unsigned variableComponent_t
 variableComponent serves as a sort of pointer to individual components of the variable and is the value payload for nodes in the WmNameTree.
 

Public Member Functions

virtual ~WmVariable ()
 Destroy object.
 
virtual void setup (const WxCryptSet &wxc)
 Setup object using supplied crypset.
 
virtual void copy (const WmVariable &var)
 Set the variable from supplied one.
 
virtual void fill (const std::vector< WxAny > &fillValues)
 For each component, apply a fill value throughout the domain.
 
virtual void swap (WmVariable &otherVar)
 Swap the internal data storage of this variable with otherVar leaving the outer shell the same, given both have same size and properties.
 
virtual bool checkCompatible (const WmVariable &var) const
 Compares this variable to another supplied WmVariable and report if they are swap compatible.
 
virtual void dump (WxIoBase &io, WxIoNodeType &grpNode) const
 Dump object to file.
 
virtual void load (WxIoBase &io, const WxIoNodeType &grpNode)
 Load object from file.
 
bool hasComponent (const std::string &componentName) const
 Check if this variable has a component matching the name supplied.
 
virtual const std::type_info & getElementTypeForComponent (unsigned int index) const
 Returns a type_info reference for the most primative element type stored by the variable.
 
virtual const std::type_info & getElementType () const
 Returns a type_info reference for the most primative element type stored by the variable.
 
unsigned int getNumComponents () const
 Returns number of components represented in the variable.
 
std::vector< std::string > getComponentNames () const
 Get names of all components (alphabetical order)
 
variableComponent_t getIndexForComponent (const std::string &componentName) const
 Returns the component number associated with the componentName.
 
const std::string & getComponentName (const variableComponent_t index) const
 Returns the component name for a given index.
 
virtual const WxAny min (const int componentIndex) const
 Returns the minimum value for the component identified.
 
virtual const WxAny absoluteMin (const int componentIndex) const
 Returns the absolute minimum value for the component identified Absolute min is the closest value to zero Value will be negative if any negative values were found.
 
const WmSolverBasegetParent () const
 Get the parent solver.
 
- Public Member Functions inherited from WxObject
virtual ~WxObject ()
 Dtor: destroy object.
 
void setIo (WxIoBase &io)
 Set the I/O pointer for use in object.
 
void setMsg (WxMsgBase &msg)
 Set the msg pointer for use in object.
 
WxIoBasegetIo ()
 Return reference to I/O object.
 
const WxIoBasegetIo () const
 Return constant reference to I/O object.
 
WxMsgBasegetMsg ()
 Return reference to msg object.
 
const WxMsgBasegetMsg () const
 Return const reference to msg object.
 
virtual void setup (const WxCryptSet &wxc)
 Setup object using supplied crypset.
 
virtual void init ()
 Initialize the object.
 
virtual void finishBuild ()
 Finish building the object.
 
virtual void load (WxIoBase &io, const WxIoNodeType &grpNode)
 Load object from file.
 
virtual void dump (WxIoBase &io, WxIoNodeType &grpNode) const
 Dump object to file.
 
virtual std::string name () const
 Get name of object.
 
void setName (const std::string &nm)
 Set object's name.
 

Protected Types

typedef WmNameTree< variableComponent_t >::const_iterator component_const_iterator_t
 

Protected Member Functions

 WmVariable (const WmConstOpaquePtr &parent_solver)
 Constructor sets up basic variable container, but no properties or specifics.
 
 WmVariable (const std::string &name, const std::vector< std::string > &orderedComponentNames)
 Constructor sets up basic variable container, and all properties otherwise set through setup() method in the no-argument form.
 
const std::type_info & getRealTypeID () const
 Get the type that real type aliases.
 
std::string getRealTypeStr () const
 Get the name for the type that real type aliases.
 
- Protected Member Functions inherited from WxObject
 WxObject ()
 Create object, that will be initialized subsequently.
 
 WxObject (const std::string &name)
 Create object with given name bypassing object setup phase Protected because there is no reason to have a WxObject directly, as it is meant to be a parent class.
 

Protected Attributes

WmNameTree< variableComponent_t_componentTree
 
unsigned _numComponents
 
std::vector< std::string > _orderedComponentNames
 
SwapImplp_impl
 

Member Typedef Documentation

◆ component_const_iterator_t

◆ variableComponent_t

variableComponent serves as a sort of pointer to individual components of the variable and is the value payload for nodes in the WmNameTree.

Constructor & Destructor Documentation

◆ ~WmVariable()

virtual WmVariable::~WmVariable ( )
virtual

Destroy object.

◆ WmVariable() [1/2]

WmVariable::WmVariable ( const WmConstOpaquePtr parent_solver)
protected

Constructor sets up basic variable container, but no properties or specifics.

Instead, must use setup(wxc) method. Protected because direct WmVariable is not intended to be a complete type.

Parameters
parent_solvertype opaque wrapper to parent solver

◆ WmVariable() [2/2]

WmVariable::WmVariable ( const std::string &  name,
const std::vector< std::string > &  orderedComponentNames 
)
protected

Constructor sets up basic variable container, and all properties otherwise set through setup() method in the no-argument form.

Calls to setup() for this instance will have no affect. Protected because direct WmVariable is not intended to be a complete type.

Parameters
namename of this instance
orderedComponentNamesname for each component of the variable

Member Function Documentation

◆ absoluteMin()

virtual const WxAny WmVariable::absoluteMin ( const int  componentIndex) const
inlinevirtual

Returns the absolute minimum value for the component identified Absolute min is the closest value to zero Value will be negative if any negative values were found.

Parameters
componentIndexIndex of component
Returns
Absolute minimum value of component with array

Reimplemented in WmUnstructuredArray.

◆ checkCompatible()

virtual bool WmVariable::checkCompatible ( const WmVariable var) const
virtual

Compares this variable to another supplied WmVariable and report if they are swap compatible.

Returns
Result of comparison. True for equal.

◆ copy()

virtual void WmVariable::copy ( const WmVariable var)
virtual

Set the variable from supplied one.

Parameters
sourcevariable to copy from

◆ dump()

virtual void WmVariable::dump ( WxIoBase io,
WxIoNodeType grpNode 
) const
virtual

Dump object to file.

This methods is passed a group node to which is should write its data to. Enough data should be written so that it can reconstruct itself using the load() method.

Parameters
ioI/O object to use for writing
grpNodegroup node to write to

Reimplemented from WxObject.

Reimplemented in WmUnstructuredArray.

◆ fill()

virtual void WmVariable::fill ( const std::vector< WxAny > &  fillValues)
inlinevirtual

For each component, apply a fill value throughout the domain.

Parameters
fillValuesvalues for each variable component.

Reimplemented in WmUnstructuredArray.

◆ getComponentName()

const std::string & WmVariable::getComponentName ( const variableComponent_t  index) const

Returns the component name for a given index.

Parameters
componentNamecomponent name to be checked
Returns
Index to the associated component Throws exception if component not found

◆ getComponentNames()

std::vector< std::string > WmVariable::getComponentNames ( ) const

Get names of all components (alphabetical order)

Parameters
Namesof all components

◆ getElementType()

virtual const std::type_info & WmVariable::getElementType ( ) const
virtual

Returns a type_info reference for the most primative element type stored by the variable.

Returns
type_info object reference associated with the fundemental element type stored in the variable

◆ getElementTypeForComponent()

virtual const std::type_info & WmVariable::getElementTypeForComponent ( unsigned int  index) const
virtual

Returns a type_info reference for the most primative element type stored by the variable.

i.e. The type is expected to be float, double, int, or some low-level struct

Parameters
indexComponent index of interest
Returns
type_info object reference associated with the fundemental element type stored in the variable

Reimplemented in WmUnstructuredArray.

◆ getIndexForComponent()

variableComponent_t WmVariable::getIndexForComponent ( const std::string &  componentName) const

Returns the component number associated with the componentName.

Parameters
componentNamecomponent name to be checked
Returns
Index to the associated component Throws exception if component not found

◆ getNumComponents()

unsigned int WmVariable::getNumComponents ( ) const

Returns number of components represented in the variable.

Returns
Number of components in this variable

◆ getParent()

const WmSolverBase & WmVariable::getParent ( ) const

Get the parent solver.

Returns
parent solver reference Throws WxExcept if parent solver not set.

◆ getRealTypeID()

const std::type_info & WmVariable::getRealTypeID ( ) const
protected

Get the type that real type aliases.

Should be equal to either double, float, or int.

Returns
real type

◆ getRealTypeStr()

std::string WmVariable::getRealTypeStr ( ) const
protected

Get the name for the type that real type aliases.

Should be equal to either "double", "float", or "int".

Returns
string for real type

◆ hasComponent()

bool WmVariable::hasComponent ( const std::string &  componentName) const

Check if this variable has a component matching the name supplied.

Parameters
componentNamecomponent name to be checked
Returns
Result of check. True if a component name for this variable.

◆ load()

virtual void WmVariable::load ( WxIoBase io,
const WxIoNodeType grpNode 
)
virtual

Load object from file.

This method is passed a group node from which its data should be read and then constructed.

Parameters
ioI/O object to use for writing
grpNodegroup node to read from

Reimplemented from WxObject.

Reimplemented in WmUnstructuredArray.

◆ min()

virtual const WxAny WmVariable::min ( const int  componentIndex) const
inlinevirtual

Returns the minimum value for the component identified.

Parameters
componentIndexIndex of component
Returns
Minimum value of component with array

Reimplemented in WmUnstructuredArray.

◆ setup()

virtual void WmVariable::setup ( const WxCryptSet wxc)
virtual

Setup object using supplied crypset.

This method reads in parameters needed to initialize the object. This establishes variable name and component names. The cryptset should have variables

NumComponents = int # number of components per value associated with this variable; if specified, components are named c0,c1,etc. ComponentNames = [ string, ... ] # names assigned to each component of the variable

Either ComponentNames or NumComponents can be specified, not both. If neither is specified, 1 component named to match the variable name is assumed. Subsequent calls to this function have no affect.

Component names shoud be a vector of names for each sub component like "x", "y", "z" or "E","B","J" The compents can be hierarchically named using dot '.' tokens such as "E.x", "E.y", "J.normal".

Parameters
wxcCryptset using which the object is set up.

Reimplemented from WxObject.

Reimplemented in WmUnstructuredArray, and WmDistributedVariable.

◆ swap()

virtual void WmVariable::swap ( WmVariable otherVar)
virtual

Swap the internal data storage of this variable with otherVar leaving the outer shell the same, given both have same size and properties.

Parameters
otherVaris the other variable to swap with Undefined if variables are not compatible.
See also
checkCompatible()

Member Data Documentation

◆ _componentTree

WmNameTree<variableComponent_t> WmVariable::_componentTree
protected

◆ _numComponents

unsigned WmVariable::_numComponents
protected

◆ _orderedComponentNames

std::vector<std::string> WmVariable::_orderedComponentNames
protected

◆ p_impl

SwapImpl* WmVariable::p_impl
protected

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