Skip to content

Commit 24a5ac0

Browse files
committed
Initialize SparseMatrices in ClawSystem::init_data()
1 parent 05ef170 commit 24a5ac0

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

examples/transient/transient_ex3/claw_system.C

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,7 @@ ClawSystem::ClawSystem (EquationSystems & es,
5151
{
5252
// set assemble_before_solve flag to false
5353
// so that we control matrix assembly.
54-
assemble_before_solve = false;
55-
56-
// Allocate SparseMatrices. I could not figure out how to do
57-
// this in the initialization list, I don't think it's possible.
58-
for (unsigned int i=0; i<2; ++i)
59-
{
60-
_advection_matrices.push_back(SparseMatrix<Number>::build(es.comm()));
61-
_avg_matrices.push_back(SparseMatrix<Number>::build(es.comm()));
62-
_boundary_condition_matrices.push_back(SparseMatrix<Number>::build(es.comm()));
63-
}
54+
this->assemble_before_solve = false;
6455

6556
}
6657

@@ -950,10 +941,19 @@ void ClawSystem::write_out_discretization_matrices()
950941
_boundary_condition_matrices[i]->print_matlab("boundary_condition_matrix_" + std::to_string(i+1) + ".m");
951942
}
952943

953-
void ClawSystem::init_data ()
944+
void ClawSystem::init_data()
954945
{
955946
Parent::init_data();
956947

948+
// Allocate SparseMatrices before attaching them to the DofMap so
949+
// that they all use the same sparsity pattern.
950+
for (unsigned int i=0; i<2; ++i)
951+
{
952+
_advection_matrices.push_back(SparseMatrix<Number>::build(this->comm()));
953+
_avg_matrices.push_back(SparseMatrix<Number>::build(this->comm()));
954+
_boundary_condition_matrices.push_back(SparseMatrix<Number>::build(this->comm()));
955+
}
956+
957957
DofMap & dof_map = this->get_dof_map();
958958

959959
// Helper lambda function that attaches the input matrix to the

0 commit comments

Comments
 (0)