Advanced Multi-Physics (AMP)
On-Line Documentation
MultiVariable.h
Go to the documentation of this file.
1#ifndef included_AMP_MultiVariable_h
2#define included_AMP_MultiVariable_h
3
4#include "AMP/vectors/Variable.h"
5#include "AMP/vectors/VectorSelector.h"
6
7#include <vector>
8
9
10namespace AMP::LinearAlgebra {
11
12
20class MultiVariable final : public Variable
21{
22public:
26 inline auto begin() { return d_vVariables.begin(); }
27
31 inline auto end() { return d_vVariables.end(); }
32
36 inline auto begin() const { return d_vVariables.begin(); }
37
41 inline auto end() const { return d_vVariables.end(); }
42
47
55 explicit MultiVariable( const std::string &name,
56 std::vector<std::shared_ptr<Variable>> vars = {} );
57
59 explicit MultiVariable( std::shared_ptr<Variable> var );
60
61
70 virtual std::shared_ptr<Variable> getVariable( size_t which );
71
80 virtual std::shared_ptr<const Variable> getVariable( size_t which ) const;
81
89 virtual size_t numVariables() const;
90
102 virtual void add( std::shared_ptr<Variable> newVar );
103
114 virtual void setVariable( size_t i, std::shared_ptr<Variable> &var );
115
116 // These are adequately documented elsewhere.
117 virtual bool operator==( const Variable &rhs ) const override;
118 virtual std::shared_ptr<Variable> clone( const std::string &name ) const override;
119 virtual void setUnits( const Units &units ) override;
120
121
122public: // Default constructors
125 MultiVariable( const MultiVariable & ) = default;
127 MultiVariable &operator=( const MultiVariable & ) = default;
128 virtual ~MultiVariable() = default;
129
130public: // Functions inherited from Variable
131 std::string className() const override { return "MultiVariable"; }
132 std::shared_ptr<VectorSelector> createVectorSelector() const override;
133 void writeRestart( int64_t ) const override;
135 void registerChildObjects( AMP::IO::RestartManager *manager ) const override;
136
137protected:
139 std::vector<std::shared_ptr<Variable>> d_vVariables;
140};
141
142
147{
148
149public:
153 explicit VS_MultiVariable( const std::shared_ptr<MultiVariable> &var );
154
155 std::string getName() const;
156
157public: // Functions inherited from VectorSelector
158 bool isSelected( const Vector & ) const override;
160
161protected:
162 std::shared_ptr<MultiVariable> d_var;
163};
164
165
166} // namespace AMP::LinearAlgebra
167
168
169#endif
Class to manage reading/writing restart data.
A class for combining variables.
auto begin()
Get the first variable in the MultiVariable.
std::vector< std::shared_ptr< Variable > > d_vVariables
List of variables comprising the MultiVariable.
auto end() const
Get end of the MultiVariable array.
virtual bool operator==(const Variable &rhs) const override
Compares two variables for equality.
MultiVariable(std::shared_ptr< Variable > var)
Create a multivariable from a single variable.
std::shared_ptr< VectorSelector > createVectorSelector() const override
Create a VectorSelector.
auto end()
Get end of the MultiVariable array.
MultiVariable(const std::string &name, std::vector< std::shared_ptr< Variable > > vars={})
Constructor.
virtual size_t numVariables() const
Returns the number of variables in the list.
void writeRestart(int64_t) const override
Write restart data to file.
virtual void setVariable(size_t i, std::shared_ptr< Variable > &var)
Set a particular variable in the list.
std::string className() const override
A function that returns the name of a variable.
virtual std::shared_ptr< Variable > getVariable(size_t which)
Get a particular variable from the list of variables.
virtual void add(std::shared_ptr< Variable > newVar)
Add a variable to the end of the variable list.
void registerChildObjects(AMP::IO::RestartManager *manager) const override
Register any child objects.
MultiVariable(int64_t, AMP::IO::RestartManager *manager)
MultiVariable & operator=(const MultiVariable &)=default
virtual void setUnits(const Units &units) override
Set the units of this variable.
auto begin() const
Get the first variable in the MultiVariable.
MultiVariable & operator=(MultiVariable &&)=default
void removeDuplicateVariables()
If there are multiple matching variables in the list, this will remove them. Note that may change the...
virtual std::shared_ptr< Variable > clone(const std::string &name) const override
Create a variable of the same type with a new name.
virtual std::shared_ptr< const Variable > getVariable(size_t which) const
Get a particular variable from the list of variables.
MultiVariable(const MultiVariable &)=default
MultiVariable(MultiVariable &&)=default
A class for selecting multi-variables.
std::shared_ptr< MultiVariable > d_var
Vector::shared_ptr subset(Vector::shared_ptr vec) const override
bool isSelected(const Vector &) const override
Returns true if Vector grossly matches a selection condition.
VS_MultiVariable(const std::shared_ptr< MultiVariable > &var)
Constructor.
A description of the data in the vector.
Definition Variable.h:46
A class used by Vector::select and Vector::selectInto to create vectors with particular data.
Abstraction of a discrete Vector in a linear simulation.
Definition Vector.h:54
std::shared_ptr< Vector > shared_ptr
Shorthand for shared pointer to Vector.
Definition Vector.h:60
Provides a class for storing units.
Definition Units.h:101



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:41.
Comments on this page