Advanced Multi-Physics (AMP)
On-Line Documentation
VectorFactory.h
Go to the documentation of this file.
1#ifndef included_AMP_test_VectorFactory
2#define included_AMP_test_VectorFactory
3
4#include "AMP/mesh/testHelpers/meshTests.h"
5#include "AMP/utils/AMP_MPI.h"
6#include "AMP/vectors/MultiVariable.h"
7#include "AMP/vectors/MultiVector.h"
8#include "AMP/vectors/Variable.h"
9#include "AMP/vectors/VectorBuilder.hpp"
10#include "AMP/vectors/testHelpers/VectorTests.h"
11
12
13namespace AMP::LinearAlgebra {
14
15
16// Null vector factory
18{
19public:
21 std::string name() const override;
22};
23
24
25// Null vector data factory
27{
28public:
30 std::string name() const override;
31};
32
33
34// CloneFactory factory
36{
37public:
38 explicit CloneFactory( std::shared_ptr<const VectorFactory> factory );
40 std::string name() const override;
41
42private:
44 std::shared_ptr<const VectorFactory> d_factory;
45};
46
47
48// SimpleVector factory
49template<class TYPE = double,
50 typename VecOps = VectorOperationsDefault<TYPE>,
51 typename VecData = VectorDataDefault<TYPE>>
53{
54public:
55 SimpleVectorFactory( int i, bool global, std::string name = "SimpleVectorFactory" )
56 : I( i ), GLOBAL( global ), NAME( std::move( name ) )
57 {
58 }
60 {
61 auto var = std::make_shared<AMP::LinearAlgebra::Variable>( "simple" );
62 if ( GLOBAL )
63 return AMP::LinearAlgebra::createSimpleVector<TYPE, VecOps, VecData>(
64 I, var, AMP_COMM_WORLD );
65 else
66 return AMP::LinearAlgebra::createSimpleVector<TYPE, VecOps, VecData>( I, var );
67 }
68 std::string name() const override { return NAME; }
69
70private:
72 int I;
73 bool GLOBAL;
74 std::string NAME;
75};
76
77
78// ArrayVector factory
79template<class TYPE = double>
81{
82public:
83 ArrayVectorFactory( size_t d, size_t i, bool global ) : D( d ), I( i ), GLOBAL( global ) {}
85 {
86 auto var = std::make_shared<AMP::LinearAlgebra::Variable>( "array" );
87 if ( GLOBAL ) {
88 AMP_MPI comm( AMP_COMM_WORLD );
89 ArraySize index( comm.getRank(), 0, 0 );
90 return AMP::LinearAlgebra::createArrayVector<TYPE>( { D, I }, index, comm, var );
91 } else {
92 return AMP::LinearAlgebra::createArrayVector<TYPE>( { D, I }, var );
93 }
94 }
95 std::string name() const override { return "ArrayVectorFactory"; }
96
97private:
99 size_t D, I;
100 bool GLOBAL;
101};
102
103
104// MeshVector factory
106{
107public:
109 std::string name() const override { return "CubeMeshVectorFactory"; }
110 static std::shared_ptr<AMP::Mesh::Mesh> generateMesh( int N );
111
112private:
114};
115
116
117// View factory
118template<typename TYPE>
120{
121public:
122 explicit ViewFactory( std::shared_ptr<const VectorFactory> factory ) : d_factory( factory ) {}
124 {
125 auto vec = TYPE::view( d_factory->getVector() );
126 AMP_INSIST( vec != nullptr, "Failed to cast view to type" );
127 [[maybe_unused]] auto native = vec->getNativeVec();
128 return vec->getManagedVec();
129 }
130 std::string name() const override { return "ViewFactory<" + d_factory->name() + ">"; }
131
132private:
133 ViewFactory() = delete;
134 std::shared_ptr<const VectorFactory> d_factory;
135};
136
137
138// MultiVector factory
140{
141public:
142 MultiVectorFactory( std::shared_ptr<const VectorFactory> factory1,
143 int N1,
144 std::shared_ptr<const VectorFactory> factory2,
145 int N2 );
147 std::string name() const override;
148
149private:
151 int NUM1, NUM2;
152 std::shared_ptr<const VectorFactory> FACTORY1;
153 std::shared_ptr<const VectorFactory> FACTORY2;
154};
155
156
157} // namespace AMP::LinearAlgebra
158
159
160#endif
#define AMP_COMM_WORLD
Definition AMP_MPI.h:32
Provides C++ wrapper around MPI routines.
Definition AMP_MPI.h:63
int getRank() const
Simple class to store the array dimensions.
Definition ArraySize.h:138
ArrayVectorFactory(size_t d, size_t i, bool global)
std::string name() const override
AMP::LinearAlgebra::Vector::shared_ptr getVector() const override
CloneFactory(std::shared_ptr< const VectorFactory > factory)
AMP::LinearAlgebra::Vector::shared_ptr getVector() const override
std::shared_ptr< const VectorFactory > d_factory
std::string name() const override
static std::shared_ptr< AMP::Mesh::Mesh > generateMesh(int N)
std::string name() const override
AMP::LinearAlgebra::Vector::shared_ptr getVector() const override
MultiVectorFactory(std::shared_ptr< const VectorFactory > factory1, int N1, std::shared_ptr< const VectorFactory > factory2, int N2)
std::string name() const override
std::shared_ptr< const VectorFactory > FACTORY2
std::shared_ptr< const VectorFactory > FACTORY1
AMP::LinearAlgebra::Vector::shared_ptr getVector() const override
std::string name() const override
AMP::LinearAlgebra::Vector::shared_ptr getVector() const override
std::string name() const override
std::string name() const override
AMP::LinearAlgebra::Vector::shared_ptr getVector() const override
SimpleVectorFactory(int i, bool global, std::string name="SimpleVectorFactory")
A class used to hold vector data.
std::shared_ptr< Vector > shared_ptr
Shorthand for shared pointer to Vector.
Definition Vector.h:60
AMP::LinearAlgebra::Vector::shared_ptr getVector() const override
std::shared_ptr< const VectorFactory > d_factory
ViewFactory(std::shared_ptr< const VectorFactory > factory)
std::string name() const override
Factory to create a vector from a mesh.
Definition meshTests.h:273
#define AMP_INSIST(EXP, MSG)
Insist error.



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