1#ifndef included_AMP_test_PetscVectorFactory
2#define included_AMP_test_PetscVectorFactory
4#include "AMP/utils/AMP_MPI.h"
5#include "AMP/vectors/VectorBuilder.h"
6#include "AMP/vectors/petsc/NativePetscVectorData.h"
7#include "AMP/vectors/petsc/PetscHelpers.h"
8#include "AMP/vectors/testHelpers/VectorTests.h"
9#include "AMP/vectors/testHelpers/generateVectorFactories.h"
29 mutable std::shared_ptr<AMP::LinearAlgebra::PetscVector>
d_vec;
65 std::string
name()
const override {
return "PetscCloneFactory<" +
d_factory->name() +
">"; }
68 std::shared_ptr<const PetscVectorFactory>
d_factory;
88 std::string
name()
const override {
return "PetscViewFactory<" +
d_factory->name() +
">"; }
100 auto data = std::dynamic_pointer_cast<NativePetscVectorData>( vec->getVectorData() );
101 std::shared_ptr<Vec> ptr(
new Vec( data->getVec() ) );
109 PetscInt local_size = 15;
110 VecSetSizes( v, local_size, PETSC_DECIDE );
111 VecSetType( v, VECMPI );
113 VecSetFromOptions( v );
114 newVec->getVectorData()->assemble();
116 std::make_shared<AMP::LinearAlgebra::Variable>(
"Test NativePetscVector" ) );
119 std::string
name()
const override {
return "NativePetscVectorFactory"; }
Provides C++ wrapper around MPI routines.
const Comm & getCommunicator() const
std::shared_ptr< Vec > getVec(AMP::LinearAlgebra::Vector::shared_ptr vec) const override
AMP::LinearAlgebra::Vector::shared_ptr getVector() const override
std::string name() const override
PetscCloneFactory(std::shared_ptr< const PetscVectorFactory > factory)
std::shared_ptr< Vec > getVec(AMP::LinearAlgebra::Vector::shared_ptr vec) const override
PetscCloneFactory()=delete
std::shared_ptr< const PetscVectorFactory > d_factory
std::string name() const override
AMP::LinearAlgebra::Vector::shared_ptr getVector() const override
PetscVecDeleter(std::shared_ptr< AMP::LinearAlgebra::PetscVector > vec)
std::shared_ptr< AMP::LinearAlgebra::PetscVector > d_vec
void operator()(Vec *ptr) const
A helper class to generate vectors.
PetscVectorFactory(const PetscVectorFactory &)
virtual ~PetscVectorFactory()
virtual std::shared_ptr< Vec > getVec(AMP::LinearAlgebra::Vector::shared_ptr) const =0
static std::shared_ptr< PetscVector > view(Vector::shared_ptr AmpVector)
If needed, create a PETSc wrapper for AmpVector. Otherwise, return AmpVector.
PetscViewFactory(std::shared_ptr< const VectorFactory > factory)
AMP::LinearAlgebra::Vector::shared_ptr getVector() const override
std::string name() const override
std::shared_ptr< const VectorFactory > d_factory
std::shared_ptr< Vec > getVec(AMP::LinearAlgebra::Vector::shared_ptr vec) const override
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.