libMesh
Loading...
Searching...
No Matches
Public Member Functions | List of all members
PetscMFFDMatrixTest Class Reference
Inheritance diagram for PetscMFFDMatrixTest:
[legend]

Public Member Functions

 LIBMESH_CPPUNIT_TEST_SUITE (PetscMFFDMatrixTest)
 
 CPPUNIT_TEST (testAssignWithContext)
 
 CPPUNIT_TEST (testAssignWithoutContext)
 
 CPPUNIT_TEST_SUITE_END ()
 
void setUp ()
 
void tearDown ()
 
void testAssignWithContext ()
 
void testAssignWithoutContext ()
 

Detailed Description

Definition at line 30 of file petsc_mffd_matrix_test.C.

Member Function Documentation

◆ CPPUNIT_TEST() [1/2]

PetscMFFDMatrixTest::CPPUNIT_TEST ( testAssignWithContext  )

◆ CPPUNIT_TEST() [2/2]

PetscMFFDMatrixTest::CPPUNIT_TEST ( testAssignWithoutContext  )

◆ CPPUNIT_TEST_SUITE_END()

PetscMFFDMatrixTest::CPPUNIT_TEST_SUITE_END ( )

◆ LIBMESH_CPPUNIT_TEST_SUITE()

PetscMFFDMatrixTest::LIBMESH_CPPUNIT_TEST_SUITE ( PetscMFFDMatrixTest  )

◆ setUp()

void PetscMFFDMatrixTest::setUp ( )
inline

Definition at line 42 of file petsc_mffd_matrix_test.C.

42{}

◆ tearDown()

void PetscMFFDMatrixTest::tearDown ( )
inline

Definition at line 43 of file petsc_mffd_matrix_test.C.

43{}

◆ testAssignWithContext()

void PetscMFFDMatrixTest::testAssignWithContext ( )
inline

Definition at line 45 of file petsc_mffd_matrix_test.C.

46 {
47 LOG_UNIT_TEST;
48
49 // A real, owned Mat for the wrapper to adopt. init() attaches its own
50 // context (pointing at owner) as a side effect.
51 PetscMatrixShellMatrix<Number> owner(*TestCommWorld);
52 owner.init(TestCommWorld->size(), TestCommWorld->size(), 1, 1);
53
54 PetscMFFDMatrix<Number> mffd(*TestCommWorld);
55 mffd.assign(owner.mat(), /*set_context=*/true);
56
57 CPPUNIT_ASSERT(mffd.mat() == owner.mat());
58 CPPUNIT_ASSERT(PetscMatrixBase<Number>::get_context(owner.mat(), *TestCommWorld) == &mffd);
59 }
This class allows to use a PETSc shell matrix as a PetscMatrix.
This class provides a nice interface to the PETSc C-based data structures for parallel,...
This class allows to use a PETSc shell matrix as a PetscMatrix.
Communicator * TestCommWorld

References libMesh::PetscMFFDMatrix< T >::assign(), libMesh::PetscMatrixShellMatrix< T >::init(), libMesh::PetscMatrixBase< T >::mat(), and TestCommWorld.

◆ testAssignWithoutContext()

void PetscMFFDMatrixTest::testAssignWithoutContext ( )
inline

Definition at line 61 of file petsc_mffd_matrix_test.C.

62 {
63 LOG_UNIT_TEST;
64
65 PetscMatrixShellMatrix<Number> owner(*TestCommWorld);
66 owner.init(TestCommWorld->size(), TestCommWorld->size(), 1, 1);
67
68 {
69 PetscMFFDMatrix<Number> mffd(*TestCommWorld);
70 mffd.assign(owner.mat(), /*set_context=*/false);
71 CPPUNIT_ASSERT(mffd.mat() == owner.mat());
72 }
73
74 // mffd is now destroyed. Since assign() above didn't attach a context,
75 // owner's own context (set by its own init()) must still be intact --
76 // this is the dangling-context scenario set_context=false exists to avoid.
77 CPPUNIT_ASSERT(PetscMatrixBase<Number>::get_context(owner.mat(), *TestCommWorld) == &owner);
78 }

References libMesh::PetscMFFDMatrix< T >::assign(), libMesh::PetscMatrixShellMatrix< T >::init(), libMesh::PetscMatrixBase< T >::mat(), and TestCommWorld.


The documentation for this class was generated from the following file: