Advanced Multi-Physics (AMP)
On-Line Documentation
VectorSelector.h
Go to the documentation of this file.
1#ifndef included_AMP_VectorSelector_h
2#define included_AMP_VectorSelector_h
3
4#include "AMP/mesh/Mesh.h"
5#include "AMP/mesh/MeshIterator.h"
6#include "AMP/vectors/Vector.h"
7
8
9namespace AMP::LinearAlgebra {
10
11
22{
23public:
25 virtual ~VectorSelector();
26
31 virtual bool isSelected( const Vector &vec ) const = 0;
32
39 virtual AMP_MPI communicator( const Vector &vec ) const;
40
45 virtual std::shared_ptr<Vector> subset( std::shared_ptr<Vector> vec ) const = 0;
46
51 std::shared_ptr<const Vector> subset( std::shared_ptr<const Vector> vec ) const;
52
53
59 static std::shared_ptr<VectorSelector>
60 create( const std::vector<std::shared_ptr<VectorSelector>> &selectors );
61};
62
63
78{
79protected:
80 std::string d_VecName;
81
82public:
86 VS_ByVariableName( std::string name );
87
88 const std::string &getName() const { return d_VecName; };
89
90public: // Functions inherited from VectorSelector
91 virtual bool isSelected( const Vector &v ) const override;
92 virtual std::shared_ptr<Vector> subset( std::shared_ptr<Vector> vec ) const override;
94};
95
96
101{
102public:
107 explicit VS_Stride( size_t offset, size_t length );
108
109public: // Functions inherited from VectorSelector
110 virtual bool isSelected( const Vector &v ) const override;
111 virtual std::shared_ptr<Vector> subset( std::shared_ptr<Vector> vec ) const override;
113
114protected:
115 size_t d_Offset; // Offset to start striding on
116 size_t d_Stride; // The stride to use
117};
118
119
124{
125public:
130
134 explicit VS_Components( std::vector<size_t> index );
135
137 inline const auto &getIndices() const { return d_index; }
138
139public: // Functions inherited from VectorSelector
140 virtual bool isSelected( const Vector &v ) const override;
141 virtual std::shared_ptr<Vector> subset( std::shared_ptr<Vector> vec ) const override;
143
144protected:
145 std::vector<size_t> d_index; // Index to select
146};
147
148
155{
156public:
160 explicit VS_Comm( const AMP_MPI &comm );
161
162public: // Functions inherited from VectorSelector
163 virtual bool isSelected( const Vector &v ) const override;
164 virtual std::shared_ptr<Vector> subset( std::shared_ptr<Vector> vec ) const override;
166 virtual AMP_MPI communicator( const Vector &vec ) const override;
167
168protected:
169 std::string d_Name; // The name of this subset
170 AMP_MPI d_comm; // The new desired comm
171};
172
173
178{
179public:
185 explicit VS_Mesh( std::shared_ptr<const AMP::Mesh::Mesh> mesh, bool useMeshComm = true );
186
187public: // Functions inherited from VectorSelector
188 virtual bool isSelected( const Vector &v ) const override;
189 virtual std::shared_ptr<Vector> subset( std::shared_ptr<Vector> vec ) const override;
191 virtual AMP_MPI communicator( const Vector &vec ) const override;
192
193protected:
194 bool d_useMeshComm; // Use the comm of the mesh
195 std::shared_ptr<const AMP::Mesh::Mesh> d_mesh; // Mesh
196};
197
198
203{
204public:
209 explicit VS_MeshIterator( const AMP::Mesh::MeshIterator &iterator, const AMP::AMP_MPI &comm );
210
211public: // Functions inherited from VectorSelector
212 virtual bool isSelected( const Vector &v ) const override;
213 virtual std::shared_ptr<Vector> subset( std::shared_ptr<Vector> vec ) const override;
215
216protected:
217 const AMP_MPI d_comm; // comm for the subset
218 const Mesh::MeshIterator d_iterator; // MeshIterator
219};
220
221
226{
227public:
228 bool isSelected( const Vector & ) const override { return true; }
229 std::shared_ptr<Vector> subset( std::shared_ptr<Vector> vec ) const override { return vec; }
230};
231
232
237{
238public:
239 MultiSelector( const std::vector<std::shared_ptr<VectorSelector>> &selectors );
240 bool isSelected( const Vector & ) const override;
241 std::shared_ptr<Vector> subset( std::shared_ptr<Vector> vec ) const override;
243
244private:
245 std::vector<std::shared_ptr<VectorSelector>> d_selectors;
246};
247
248
249} // namespace AMP::LinearAlgebra
250
251
252#endif
Provides C++ wrapper around MPI routines.
Definition AMP_MPI.h:63
MultiSelector(const std::vector< std::shared_ptr< VectorSelector > > &selectors)
std::vector< std::shared_ptr< VectorSelector > > d_selectors
std::shared_ptr< Vector > subset(std::shared_ptr< Vector > vec) const override
Subset the given vector.
bool isSelected(const Vector &) const override
Returns true if Vector grossly matches a selection condition.
bool isSelected(const Vector &) const override
Returns true if Vector grossly matches a selection condition.
std::shared_ptr< Vector > subset(std::shared_ptr< Vector > vec) const override
Subset the given vector.
Select a subvector based on the name of the variable.
virtual bool isSelected(const Vector &v) const override
Returns true if Vector grossly matches a selection condition.
virtual std::shared_ptr< Vector > subset(std::shared_ptr< Vector > vec) const override
Subset the given vector.
const std::string & getName() const
VS_ByVariableName(std::string name)
Constructor.
Create a subset based on a AMP_MPI comm.
virtual AMP_MPI communicator(const Vector &vec) const override
Returns the communicator for the subset.
virtual bool isSelected(const Vector &v) const override
Returns true if Vector grossly matches a selection condition.
virtual std::shared_ptr< Vector > subset(std::shared_ptr< Vector > vec) const override
Subset the given vector.
VS_Comm(const AMP_MPI &comm)
Constructor.
Create a subset based on the components of a vector.
VS_Components(std::vector< size_t > index)
Constructor.
virtual std::shared_ptr< Vector > subset(std::shared_ptr< Vector > vec) const override
Subset the given vector.
const auto & getIndices() const
Get the indices.
VS_Components(size_t index)
Constructor.
virtual bool isSelected(const Vector &v) const override
Returns true if Vector grossly matches a selection condition.
Create a subset based on a mesh iterator.
VS_MeshIterator(const AMP::Mesh::MeshIterator &iterator, const AMP::AMP_MPI &comm)
Constructor.
virtual bool isSelected(const Vector &v) const override
Returns true if Vector grossly matches a selection condition.
const Mesh::MeshIterator d_iterator
virtual std::shared_ptr< Vector > subset(std::shared_ptr< Vector > vec) const override
Subset the given vector.
Create a subset based on a mesh.
virtual AMP_MPI communicator(const Vector &vec) const override
Returns the communicator for the subset.
virtual bool isSelected(const Vector &v) const override
Returns true if Vector grossly matches a selection condition.
virtual std::shared_ptr< Vector > subset(std::shared_ptr< Vector > vec) const override
Subset the given vector.
std::shared_ptr< const AMP::Mesh::Mesh > d_mesh
VS_Mesh(std::shared_ptr< const AMP::Mesh::Mesh > mesh, bool useMeshComm=true)
Constructor.
Create a subset based on a stride in the vector.
virtual std::shared_ptr< Vector > subset(std::shared_ptr< Vector > vec) const override
Subset the given vector.
virtual bool isSelected(const Vector &v) const override
Returns true if Vector grossly matches a selection condition.
VS_Stride(size_t offset, size_t length)
Constructor.
A class used by Vector::select and Vector::selectInto to create vectors with particular data.
virtual std::shared_ptr< Vector > subset(std::shared_ptr< Vector > vec) const =0
Subset the given vector.
virtual AMP_MPI communicator(const Vector &vec) const
Returns the communicator for the subset.
static std::shared_ptr< VectorSelector > create(const std::vector< std::shared_ptr< VectorSelector > > &selectors)
Create a VectorSelector.
virtual ~VectorSelector()
Virtual destructor.
virtual bool isSelected(const Vector &vec) const =0
Returns true if Vector grossly matches a selection condition.
std::shared_ptr< const Vector > subset(std::shared_ptr< const Vector > vec) const
Subset the given vector.
Abstraction of a discrete Vector in a linear simulation.
Definition Vector.h:54
A class used to iterate over elements in a Mesh.



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