1#ifndef included_AMP_test_MatrixVectorFactory
2#define included_AMP_test_MatrixVectorFactory
4#include "AMP/discretization/DOF_Manager.h"
5#include "AMP/matrices/Matrix.h"
6#include "AMP/utils/UnitTest.h"
7#include "AMP/vectors/Vector.h"
8#include "AMP/vectors/VectorBuilder.h"
9#include "AMP/vectors/testHelpers/VectorFactory.h"
11#if defined( AMP_USE_PETSC )
12 #include "AMP/matrices/petsc/PetscMatrix.h"
13 #include "AMP/vectors/petsc/PetscHelpers.h"
14 #include "AMP/vectors/petsc/PetscVector.h"
15 #include "AMP/vectors/testHelpers/petsc/PetscVectorFactory.h"
19#include "ProfilerApp.h"
34 PROFILE(
"AmpInterfaceLeftVectorFactory::getVector" );
35 auto vector =
d_matrix->createOutputVector();
36 vector->setVariable( std::make_shared<AMP::LinearAlgebra::Variable>(
"left" ) );
39 std::string
name()
const override
41 return "AmpInterfaceLeftVectorFactory<" +
getVector()->type() +
">";
45 std::shared_ptr<AMP::LinearAlgebra::Matrix>
d_matrix;
58 PROFILE(
"AmpInterfaceRightVectorFactory::getVector" );
59 auto vector =
d_matrix->createInputVector();
60 vector->setVariable( std::make_shared<AMP::LinearAlgebra::Variable>(
"right" ) );
63 std::string
name()
const override
65 return "AmpInterfaceRightVectorFactory<" +
getVector()->type() +
">";
69 std::shared_ptr<AMP::LinearAlgebra::Matrix>
d_matrix;
73#if defined( AMP_USE_PETSC )
84 PROFILE(
"PETScInterfaceLeftVectorFactory::getVector" );
86 ::Mat m = view->getMat();
88 MatCreateVecs( m, &v,
nullptr );
90 vector->setVariable( std::make_shared<AMP::LinearAlgebra::Variable>(
"petsc_left" ) );
95 auto data = std::dynamic_pointer_cast<NativePetscVectorData>( vec->getVectorData() );
96 auto ptr = std::make_shared<Vec>( data->getVec() );
99 std::string
name()
const override {
return "PETScInterfaceLeftVectorFactory"; };
102 std::shared_ptr<AMP::LinearAlgebra::Matrix>
d_matrix;
115 PROFILE(
"PETScInterfaceRightVectorFactory::getVector" );
117 ::Mat m = view->getMat();
119 MatCreateVecs( m, &v,
nullptr );
121 vector->setVariable( std::make_shared<AMP::LinearAlgebra::Variable>(
"petsc_right" ) );
126 auto data = std::dynamic_pointer_cast<NativePetscVectorData>( vec->getVectorData() );
127 auto ptr = std::make_shared<Vec>( data->getVec() );
130 std::string
name()
const override {
return "PETScInterfaceRightVectorFactory"; }
133 std::shared_ptr<AMP::LinearAlgebra::Matrix>
d_matrix;
std::string name() const override
std::shared_ptr< AMP::LinearAlgebra::Matrix > d_matrix
AMP::LinearAlgebra::Vector::shared_ptr getVector() const override
AmpInterfaceLeftVectorFactory(std::shared_ptr< AMP::LinearAlgebra::Matrix > matrix)
AmpInterfaceRightVectorFactory(std::shared_ptr< AMP::LinearAlgebra::Matrix > matrix)
std::shared_ptr< AMP::LinearAlgebra::Matrix > d_matrix
AMP::LinearAlgebra::Vector::shared_ptr getVector() const override
std::string name() const override
AMP::LinearAlgebra::Vector::shared_ptr getVector() const override
std::shared_ptr< AMP::LinearAlgebra::Matrix > d_matrix
std::shared_ptr< Vec > getVec(AMP::LinearAlgebra::Vector::shared_ptr vec) const override
PETScInterfaceLeftVectorFactory(std::shared_ptr< AMP::LinearAlgebra::Matrix > matrix)
std::string name() const override
std::string name() const override
PETScInterfaceRightVectorFactory(std::shared_ptr< AMP::LinearAlgebra::Matrix > matrix)
std::shared_ptr< Vec > getVec(AMP::LinearAlgebra::Vector::shared_ptr vec) const override
std::shared_ptr< AMP::LinearAlgebra::Matrix > d_matrix
AMP::LinearAlgebra::Vector::shared_ptr getVector() const override
static std::shared_ptr< PetscMatrix > view(std::shared_ptr< Matrix > AmpMatrix)
If needed, create a PETSc wrapper for AmpMatrix. Otherwise, return AmpMatrix.
A helper class to generate vectors.
std::shared_ptr< Vector > shared_ptr
Shorthand for shared pointer to Vector.
AMP::LinearAlgebra::Vector::shared_ptr createVector(std::shared_ptr< AMP::Discretization::DOFManager > DOFs, std::shared_ptr< AMP::LinearAlgebra::Variable > variable, bool split=true)
This function will create a vector from an arbitrary DOFManager.