Commit ea620af6 authored by Marcus Mohr's avatar Marcus Mohr
Browse files

New constructor version for PETScSparseMatrix

The new variant allows to pass a function object in place of a
PrimitiveStorage object to be used for determination of DoF counts.

Testing new approach in PetscMatrixAssemblyTest.
parent 7ac9c3e5
Pipeline #34446 canceled with stages
in 82 minutes and 26 seconds
......@@ -51,7 +51,8 @@ class PETScSparseMatrix
uint_t globalSize,
const char name[] = "Mat",
const MPI_Comm& petscCommunicator = walberla::mpi::MPIManager::instance()->comm() )
: petscCommunicator_( petscCommunicator ), assembled_( false )
: petscCommunicator_( petscCommunicator )
, assembled_( false )
{
MatCreate( petscCommunicator, &mat );
MatSetType( mat, MATMPIAIJ );
......@@ -72,6 +73,16 @@ class PETScSparseMatrix
petscCommunicator )
{}
PETScSparseMatrix( const FunctionType< PetscInt >& enumerator,
const uint_t& level,
const char name[] = "Mat",
const MPI_Comm& petscCommunicator = walberla::mpi::MPIManager::instance()->comm() )
: PETScSparseMatrix( numberOfLocalDoFs( enumerator, level ),
numberOfGlobalDoFs( enumerator, level, petscCommunicator ),
name,
petscCommunicator )
{}
virtual ~PETScSparseMatrix() { MatDestroy( &mat ); }
inline void createMatrixFromOperator( const OperatorType& op,
......
......@@ -85,12 +85,12 @@ void testAssembly_newAPI( std::shared_ptr< PrimitiveStorage >& storage, uint_t l
{
WALBERLA_LOG_INFO_ON_ROOT( " * " << tag );
PETScManager petscManager;
PETScSparseMatrix< operType, operType::srcType::template FunctionType > matrix( storage, level, tag.c_str() );
typename operType::srcType::template FunctionType< PetscInt > enumerator( "enumerator", storage, level, level );
enumerator.enumerate( level );
PETScManager petscManager;
PETScSparseMatrix< operType, operType::srcType::template FunctionType > matrix( enumerator, level, tag.c_str() );
operType oper( storage, level, level );
matrix.createMatrixFromOperator_newAPI( oper, level, enumerator, All );
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment