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

An AMP Variable that describes how to stride a vector to create a SubsetVector. More...

#include <StridedVariable.h>

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

Public Member Functions

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
 Create a variable of the same type with a new name.
 
std::shared_ptr< VectorSelectorcreateVectorSelector () const override
 Create a VectorSelector.
 
AMP::AMP_MPI getComm (const AMP::AMP_MPI &comm) const override
 Return the comm for the subset.
 
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.
 
std::shared_ptr< AMP::Discretization::DOFManagergetSubsetDOF (std::shared_ptr< AMP::Discretization::DOFManager >) const override
 Return a DOFManager that describes the subset.
 
virtual const UnitsgetUnits () const
 Get the units of this variable.
 
bool operator!= (const Variable &rhs) const
 Inverse of ==.
 
virtual bool operator== (const Variable &rhs) const
 Compares two variables for equality.
 
virtual void registerChildObjects (AMP::IO::RestartManager *manager) const
 Register any child objects.
 
virtual void setUnits (const Units &u)
 Set the units of this variable.
 
std::shared_ptr< Variableshared_from_this ()
 
std::shared_ptr< const Variableshared_from_this () const
 
 StridedVariable (const std::string &name, size_t offset, size_t stride)
 Constructor.
 
 StridedVariable (int64_t)
 
virtual Vector::const_shared_ptr view (Vector::const_shared_ptr) const
 This vector is a subset of an AMP Vector.
 
virtual Vector::shared_ptr view (Vector::shared_ptr) const
 This vector is a subset of an AMP Vector.
 
void writeRestart (int64_t) const override
 Write restart data to file.
 

Protected Attributes

AMP::Units d_Units
 The units this variable is measured in.
 
std::string d_VariableName
 A name given to the variable.
 
std::weak_ptr< Variableweak_ptr_
 

Private Member Functions

 StridedVariable ()
 

Private Attributes

size_t d_offset = 0
 
size_t d_stride = 1
 

Detailed Description

An AMP Variable that describes how to stride a vector to create a SubsetVector.

See also
SubsetVector
StridedIndexer

Definition at line 14 of file StridedVariable.h.

Constructor & Destructor Documentation

◆ StridedVariable() [1/3]

AMP::LinearAlgebra::StridedVariable::StridedVariable ( const std::string &  name,
size_t  offset,
size_t  stride 
)

Constructor.

Parameters
[in]nameThe name of the new variable
[in]offsetThe offset to start striding a vector
[in]strideThe stride of the vector

◆ StridedVariable() [2/3]

AMP::LinearAlgebra::StridedVariable::StridedVariable ( int64_t  )

◆ StridedVariable() [3/3]

AMP::LinearAlgebra::StridedVariable::StridedVariable ( )
private

Member Function Documentation

◆ className()

std::string AMP::LinearAlgebra::StridedVariable::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 31 of file StridedVariable.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::Variable::clone ( const std::string &  name) const
virtualinherited

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

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

Reimplemented in AMP::LinearAlgebra::MultiVariable.

◆ createVectorSelector()

std::shared_ptr< VectorSelector > AMP::LinearAlgebra::StridedVariable::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.

◆ getComm()

AMP::AMP_MPI AMP::LinearAlgebra::StridedVariable::getComm ( const AMP::AMP_MPI comm) const
overridevirtual

Return the comm for the subset.

Returns
The comm
Parameters
[in]commThe comm of the original vector / DOFManager

Implements AMP::LinearAlgebra::SubsetVariable.

◆ 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.

◆ getSubsetDOF()

std::shared_ptr< AMP::Discretization::DOFManager > AMP::LinearAlgebra::StridedVariable::getSubsetDOF ( std::shared_ptr< AMP::Discretization::DOFManager manager) const
overridevirtual

Return a DOFManager that describes the subset.

Returns
The DOFManager
Parameters
[in]managerThe DOF manager we want to subset

Implements AMP::LinearAlgebra::SubsetVariable.

◆ getUnits()

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

Get the units of this variable.

◆ 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==()

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

Compares two variables for equality.

This operation compares the names.

Parameters
rhsVariable to compare

Reimplemented in AMP::LinearAlgebra::MultiVariable.

◆ registerChildObjects()

virtual void AMP::LinearAlgebra::Variable::registerChildObjects ( AMP::IO::RestartManager manager) const
virtualinherited

Register any child objects.

This function will register child objects with the manager

Parameters
managerRestart manager

Reimplemented in AMP::LinearAlgebra::MultiVariable.

◆ setUnits()

virtual void AMP::LinearAlgebra::Variable::setUnits ( const Units u)
virtualinherited

Set the units of this variable.

Reimplemented in AMP::LinearAlgebra::MultiVariable.

◆ 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.

◆ view() [1/2]

virtual Vector::const_shared_ptr AMP::LinearAlgebra::SubsetVariable::view ( Vector::const_shared_ptr  ) const
virtualinherited

This vector is a subset of an AMP Vector.

Given an AMP Vector, this will create a view of a subset of the vector. For instance, if \(\mathbf{a} = \{ a_0 a_1 a_2 \ldots a_n\}\), and \(S\) is a set of non-negative integers \(( s_0 s_1 \ldots s_m )\) such that \(0 \le s_i \le n\), then the SubsetVector will be the vector \(\mathbf{a}_S = \{ a_{s_0} a_{s_1} a_{s_2} \ldots a_{s_m}\} \).

Since this is a view, any change to vec2 will be reflected on vec1 and vice versa. vec2 is a sparse vector, with a mapping of new index to old. vec3, on the other hand, is a dense vector without an index. If a lot of computation is necessary on the sparse vector, the data can be copied in and out:

// Subset the vector to make a sparse vector.
vec2 = AMP::SubsetVector( vec1 , subsetVar )
// Copy the sparse vector data to a dense vector
vec3.copyVector( vec2 );
// Perform whatever math
performComputation( vec3 );
// Copy data back to vec2, and, consequently, vec1
vec2.copyVector( vec3 );

Reimplemented in AMP::LinearAlgebra::CommSelfVariable.

◆ view() [2/2]

virtual Vector::shared_ptr AMP::LinearAlgebra::SubsetVariable::view ( Vector::shared_ptr  ) const
virtualinherited

This vector is a subset of an AMP Vector.

Given an AMP Vector, this will create a view of a subset of the vector. For instance, if \(\mathbf{a} = \{ a_0 a_1 a_2 \ldots a_n\}\), and \(S\) is a set of non-negative integers \(( s_0 s_1 \ldots s_m )\) such that \(0 \le s_i \le n\), then the SubsetVector will be the vector \(\mathbf{a}_S = \{ a_{s_0} a_{s_1} a_{s_2} \ldots a_{s_m}\} \).

Since this is a view, any change to vec2 will be reflected on vec1 and vice versa. vec2 is a sparse vector, with a mapping of new index to old. vec3, on the other hand, is a dense vector without an index. If a lot of computation is necessary on the sparse vector, the data can be copied in and out:

// Subset the vector to make a sparse vector.
vec2 = AMP::SubsetVector( vec1 , subsetVar )
// Copy the sparse vector data to a dense vector
vec3.copyVector( vec2 );
// Perform whatever math
performComputation( vec3 );
// Copy data back to vec2, and, consequently, vec1
vec2.copyVector( vec3 );

Reimplemented in AMP::LinearAlgebra::CommSelfVariable, and AMP::LinearAlgebra::CommSelfVariable.

◆ writeRestart()

void AMP::LinearAlgebra::StridedVariable::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_offset

size_t AMP::LinearAlgebra::StridedVariable::d_offset = 0
private

Definition at line 38 of file StridedVariable.h.

◆ d_stride

size_t AMP::LinearAlgebra::StridedVariable::d_stride = 1
private

Definition at line 39 of file StridedVariable.h.

◆ 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().

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