Dear Prof. Bangerth,
Thank you for your
reply. I have changed the required data structures using PETSc wrappers.
I have another doubt regarding this. Since I am running on a single
machine, how should I use the reinit() function for PETSc Sparse Matrix.
I was thinking to use the
(3/5th) reinit() function.
How should I initialize the "index set" that is required for this function? In
step-17,
it uses the locally_owned_dofs to initialize the index set, however,
that program was for multiple machines which is not the case with me.
Below is my system_setup() function currently -
template <int dim,typename NumberType>
void Solid<dim,NumberType>::system_setup()
{
timer.enter_subsection("Setup system");
//std::vector<unsigned int> block_component(n_components, u_dof); // Displacement
// The DOF handler is then initialised and we renumber the grid in an
// efficient manner. We also record the number of DOFs per block.
dof_handler_ref.distribute_dofs(fe);
DoFRenumbering::Cuthill_McKee(dof_handler_ref);
//DoFRenumbering::component_wise(dof_handler_ref, block_component);
//DoFTools::count_dofs_per_block(dof_handler_ref, dofs_per_block,
// block_component);
std::cout << "Triangulation:"
<< "\n\t Number of active cells: " << triangulation.n_active_cells()
<< "\n\t Number of degrees of freedom: " << dof_handler_ref.n_dofs()
<< std::endl;
// Setup the sparsity pattern and tangent matrix
tangent_matrix.clear();
{
//const types::global_dof_index n_dofs_u = dofs_per_block[u_dof];
DynamicSparsityPattern csp(dof_handler_ref.n_dofs());
//csp.block(u_dof, u_dof).reinit(n_dofs_u, n_dofs_u);
//csp.collect_sizes();
Table<2, DoFTools::Coupling> coupling(n_components, n_components);
for (unsigned int ii = 0; ii < n_components; ++ii)
for (unsigned int jj = 0; jj < n_components; ++jj)
coupling[ii][jj] = DoFTools::always;
DoFTools::make_sparsity_pattern(dof_handler_ref,
coupling,
csp,
constraints,
false);
sparsity_pattern.copy_from(csp);
}
tangent_matrix.reinit(<Index_Set Required>, <Index_Set_Required>, sparsity_pattern,mpi_communicator);
system_rhs.reinit(mpi_communicator,dof_handler_ref.n_dofs(),dof_handler_ref.n_dofs());
//system_rhs.collect_sizes();
solution_n.reinit(mpi_communicator,dof_handler_ref.n_dofs(),dof_handler_ref.n_dofs());
//solution_n.collect_sizes();
setup_qph();
timer.leave_subsection();
}
Thanks!
Animesh