Advanced Multi-Physics (AMP)
On-Line Documentation
Public Member Functions | Protected Attributes | List of all members
AMP::LinearAlgebra::MultiVariable Class Referencefinal

A class for combining variables. More...

#include <MultiVariable.h>

Inheritance diagram for AMP::LinearAlgebra::MultiVariable:
Inheritance graph
[legend]

Public Member Functions

virtual void add (std::shared_ptr< Variable > newVar)
 Add a variable to the end of the variable list.
 
auto begin ()
 Get the first variable in the MultiVariable.
 
auto begin () const
 Get the first variable in the MultiVariable.
 
std::string className () const override
 A function that returns the name of a variable.
 
std::shared_ptr< Variableclone () const
 Create a variable of the same type with a new name.
 
virtual std::shared_ptr< Variableclone (const std::string &name) const override
 Create a variable of the same type with a new name.
 
std::shared_ptr< VectorSelectorcreateVectorSelector () const override
 Create a VectorSelector.
 
auto end ()
 Get end of the MultiVariable array.
 
auto end () const
 Get end of the MultiVariable array.
 
virtual uint64_t getID () const
 Get a unique id hash for the vector.
 
auto & getName () const
 A function that returns the name of a variable.
 
virtual const UnitsgetUnits () const
 Get the units of this variable.
 
virtual std::shared_ptr< VariablegetVariable (size_t which)
 Get a particular variable from the list of variables.
 
virtual std::shared_ptr< const VariablegetVariable (size_t which) const
 Get a particular variable from the list of variables.
 
 MultiVariable ()
 
 MultiVariable (const MultiVariable &)=default
 
 MultiVariable (const std::string &name, std::vector< std::shared_ptr< Variable > > vars={})
 Constructor.
 
 MultiVariable (int64_t, AMP::IO::RestartManager *manager)
 
 MultiVariable (MultiVariable &&)=default
 
 MultiVariable (std::shared_ptr< Variable > var)
 Create a multivariable from a single variable.
 
virtual size_t numVariables () const
 Returns the number of variables in the list.
 
bool operator!= (const Variable &rhs) const
 Inverse of ==.
 
MultiVariableoperator= (const MultiVariable &)=default
 
MultiVariableoperator= (MultiVariable &&)=default
 
virtual bool operator== (const Variable &rhs) const override
 Compares two variables for equality.
 
void registerChildObjects (AMP::IO::RestartManager *manager) const override
 Register any child objects.
 
void removeDuplicateVariables ()
 If there are multiple matching variables in the list, this will remove them. Note that may change the etnry order and will remove any null entries.
 
virtual void setUnits (const Units &units) override
 Set the units of this variable.
 
virtual void setVariable (size_t i, std::shared_ptr< Variable > &var)
 Set a particular variable in the list.
 
std::shared_ptr< Variableshared_from_this ()
 
std::shared_ptr< const Variableshared_from_this () const
 
void writeRestart (int64_t) const override
 Write restart data to file.
 
virtual ~MultiVariable ()=default
 

Protected Attributes

AMP::Units d_Units
 The units this variable is measured in.
 
std::string d_VariableName
 A name given to the variable.
 
std::vector< std::shared_ptr< Variable > > d_vVariables
 List of variables comprising the MultiVariable.
 
std::weak_ptr< Variableweak_ptr_
 

Detailed Description

A class for combining variables.

When physics are brought together, individual variables need to be combined to generate a composition. For instance, combining temperature and displacement into a single variable.

See also
MultiVector

Definition at line 20 of file MultiVariable.h.

Constructor & Destructor Documentation

◆ MultiVariable() [1/6]

AMP::LinearAlgebra::MultiVariable::MultiVariable ( const std::string &  name,
std::vector< std::shared_ptr< Variable > >  vars = {} 
)
explicit

Constructor.

Because a MultiVariable is a Variable, it must have a name. This does not change the names of the variables in the list of vectors.

Parameters
[in]nameThe name of the MultiVariable
[in]varsOptional list of variables in the MultiVariable

◆ MultiVariable() [2/6]

AMP::LinearAlgebra::MultiVariable::MultiVariable ( std::shared_ptr< Variable var)
explicit

Create a multivariable from a single variable.

◆ MultiVariable() [3/6]

AMP::LinearAlgebra::MultiVariable::MultiVariable ( )
inline

Definition at line 123 of file MultiVariable.h.

◆ MultiVariable() [4/6]

AMP::LinearAlgebra::MultiVariable::MultiVariable ( MultiVariable &&  )
default

◆ MultiVariable() [5/6]

AMP::LinearAlgebra::MultiVariable::MultiVariable ( const MultiVariable )
default

◆ ~MultiVariable()

virtual AMP::LinearAlgebra::MultiVariable::~MultiVariable ( )
virtualdefault

◆ MultiVariable() [6/6]

AMP::LinearAlgebra::MultiVariable::MultiVariable ( int64_t  ,
AMP::IO::RestartManager manager 
)

Member Function Documentation

◆ add()

virtual void AMP::LinearAlgebra::MultiVariable::add ( std::shared_ptr< Variable newVar)
virtual

Add a variable to the end of the variable list.

Parameters
newVara shared pointer to the new variable

This is an alias for

d_vVariables.push_back ( newVar );
std::vector< std::shared_ptr< Variable > > d_vVariables
List of variables comprising the MultiVariable.

unless newVar is a MultiVariable. In order to keep heirarchies to a minimum, the members of newVar are added instead of newVar itself.

◆ begin() [1/2]

auto AMP::LinearAlgebra::MultiVariable::begin ( )
inline

Get the first variable in the MultiVariable.

Returns
An iterator pointing to the first variable

Definition at line 26 of file MultiVariable.h.

References d_vVariables.

◆ begin() [2/2]

auto AMP::LinearAlgebra::MultiVariable::begin ( ) const
inline

Get the first variable in the MultiVariable.

Returns
An iterator pointing to the first variable

Definition at line 36 of file MultiVariable.h.

References d_vVariables.

◆ className()

std::string AMP::LinearAlgebra::MultiVariable::className ( ) const
inlineoverridevirtual

A function that returns the name of a variable.

This gives access to the name

Reimplemented from AMP::LinearAlgebra::Variable.

Definition at line 131 of file MultiVariable.h.

◆ clone() [1/2]

std::shared_ptr< Variable > AMP::LinearAlgebra::Variable::clone ( ) const
inherited

Create a variable of the same type with a new name.

This function will create a "deep" copy of this variable.

◆ clone() [2/2]

virtual std::shared_ptr< Variable > AMP::LinearAlgebra::MultiVariable::clone ( const std::string &  name) const
overridevirtual

Create a variable of the same type with a new name.

This function will create a "deep" copy of this variable.

Reimplemented from AMP::LinearAlgebra::Variable.

◆ createVectorSelector()

std::shared_ptr< VectorSelector > AMP::LinearAlgebra::MultiVariable::createVectorSelector ( ) const
overridevirtual

Create a VectorSelector.

This function will create a VectorSelector that is able to subset a vector for the variable. This is used by Vector::subsetVectorForVariable which then calls Vector::selectInto.

Reimplemented from AMP::LinearAlgebra::Variable.

◆ end() [1/2]

auto AMP::LinearAlgebra::MultiVariable::end ( )
inline

Get end of the MultiVariable array.

Returns
An iterator pointing to the end

Definition at line 31 of file MultiVariable.h.

References d_vVariables.

◆ end() [2/2]

auto AMP::LinearAlgebra::MultiVariable::end ( ) const
inline

Get end of the MultiVariable array.

Returns
An iterator pointing to the end

Definition at line 41 of file MultiVariable.h.

References d_vVariables.

◆ getID()

virtual uint64_t AMP::LinearAlgebra::Variable::getID ( ) const
virtualinherited

◆ getName()

auto & AMP::LinearAlgebra::Variable::getName ( ) const
inlineinherited

A function that returns the name of a variable.

This gives access to the name

Definition at line 74 of file Variable.h.

References AMP::LinearAlgebra::Variable::d_VariableName.

◆ getUnits()

virtual const Units & AMP::LinearAlgebra::Variable::getUnits ( ) const
virtualinherited

Get the units of this variable.

◆ getVariable() [1/2]

virtual std::shared_ptr< Variable > AMP::LinearAlgebra::MultiVariable::getVariable ( size_t  which)
virtual

Get a particular variable from the list of variables.

Parameters
whichthe index of the variable sought

This is an alias for

d_vVariables[which];

It is bounds checked in debug builds.

◆ getVariable() [2/2]

virtual std::shared_ptr< const Variable > AMP::LinearAlgebra::MultiVariable::getVariable ( size_t  which) const
virtual

Get a particular variable from the list of variables.

Parameters
whichthe index of the variable sought

This is an alias for

d_vVariables[which];

It is bounds checked in debug builds.

◆ numVariables()

virtual size_t AMP::LinearAlgebra::MultiVariable::numVariables ( ) const
virtual

Returns the number of variables in the list.

This is an alias for

d_vVariables.size();

◆ operator!=()

bool AMP::LinearAlgebra::Variable::operator!= ( const Variable rhs) const
inherited

Inverse of ==.

This function performs an equality check and negates it.

Parameters
rhsVariable to compare

◆ operator=() [1/2]

MultiVariable & AMP::LinearAlgebra::MultiVariable::operator= ( const MultiVariable )
default

◆ operator=() [2/2]

MultiVariable & AMP::LinearAlgebra::MultiVariable::operator= ( MultiVariable &&  )
default

◆ operator==()

virtual bool AMP::LinearAlgebra::MultiVariable::operator== ( const Variable rhs) const
overridevirtual

Compares two variables for equality.

This operation compares the names.

Parameters
rhsVariable to compare

Reimplemented from AMP::LinearAlgebra::Variable.

◆ registerChildObjects()

void AMP::LinearAlgebra::MultiVariable::registerChildObjects ( AMP::IO::RestartManager manager) const
overridevirtual

Register any child objects.

This function will register child objects with the manager

Parameters
managerRestart manager

Reimplemented from AMP::LinearAlgebra::Variable.

◆ removeDuplicateVariables()

void AMP::LinearAlgebra::MultiVariable::removeDuplicateVariables ( )

If there are multiple matching variables in the list, this will remove them. Note that may change the etnry order and will remove any null entries.

◆ setUnits()

virtual void AMP::LinearAlgebra::MultiVariable::setUnits ( const Units u)
overridevirtual

Set the units of this variable.

Reimplemented from AMP::LinearAlgebra::Variable.

◆ setVariable()

virtual void AMP::LinearAlgebra::MultiVariable::setVariable ( size_t  i,
std::shared_ptr< Variable > &  var 
)
virtual

Set a particular variable in the list.

Parameters
iindex into the list
vara shared pointer to the variable to be placed in the list

This is an alias for

d_vVariables[i] = var;

This is bounds checked in debug builds

◆ shared_from_this() [1/2]

std::shared_ptr< Variable > AMP::enable_shared_from_this< Variable >::shared_from_this ( )
inlineinherited

Definition at line 28 of file enable_shared_from_this.h.

◆ shared_from_this() [2/2]

std::shared_ptr< const Variable > AMP::enable_shared_from_this< Variable >::shared_from_this ( ) const
inlineinherited

Definition at line 46 of file enable_shared_from_this.h.

◆ writeRestart()

void AMP::LinearAlgebra::MultiVariable::writeRestart ( int64_t  fid) const
overridevirtual

Write restart data to file.

This function will the variable to an HDF5 file

Parameters
fidFile identifier to write

Reimplemented from AMP::LinearAlgebra::Variable.

Member Data Documentation

◆ d_Units

AMP::Units AMP::LinearAlgebra::Variable::d_Units
protectedinherited

The units this variable is measured in.

Definition at line 155 of file Variable.h.

◆ d_VariableName

std::string AMP::LinearAlgebra::Variable::d_VariableName
protectedinherited

A name given to the variable.

Variables have names for easy identification. For instance, some variables are called displacement, concentration, search direction, etc.

Definition at line 151 of file Variable.h.

Referenced by AMP::LinearAlgebra::Variable::getName().

◆ d_vVariables

std::vector<std::shared_ptr<Variable> > AMP::LinearAlgebra::MultiVariable::d_vVariables
protected

List of variables comprising the MultiVariable.

Definition at line 139 of file MultiVariable.h.

Referenced by begin(), begin(), end(), and end().

◆ weak_ptr_

std::weak_ptr<Variable > AMP::enable_shared_from_this< Variable >::weak_ptr_
mutableprotectedinherited

Definition at line 69 of file enable_shared_from_this.h.


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



Advanced Multi-Physics (AMP)
Oak Ridge National Laboratory
Idaho National Laboratory
Los Alamos National Laboratory
This page automatically produced from the
source code by doxygen
Last updated: Tue Mar 10 2026 13:06:42.
Comments on this page