Hi all,
I have a code that works fine for one element, but won't compile for even one level of refinement (8 elements). It solves a small deformation problem of elastic compression of a cube of side length 1. The edges of the cube are parallel to the coordinate axes and three of its faces are on the coordinate planes. The code assumes that the Young's modulus, Poisson's ratio and the speed at which the "top" surface of the cube is moving are defined in a parameters.h file.
I have attached my code to this message. When I try to refine the mesh (say 8 elements) I get the following message from the compiler
--------------------------------------------------------
An error occurred in line <2014> of file </home/skunda/built-programs/dealii-9.2.0/install/include/deal.II/lac/sparse_matrix.h> in function
number& dealii::SparseMatrix<number>::operator()(dealii::SparseMatrix<number>::size_type, dealii::SparseMatrix<number>::size_type) [with number = double; dealii::SparseMatrix<number>::size_type = unsigned int]
The violated condition was:
cols->operator()(i, j) != SparsityPattern::invalid_entry
Additional information:
You are trying to access the matrix entry with index <0,24>, but this entry does not exist in the sparsity pattern of this matrix.
The most common cause for this problem is that you used a method to build the sparsity pattern that did not (completely) take into account all of the entries you will later try to write into. An example would be building a sparsity pattern that does not include the entries you will write into due to constraints on degrees of freedom such as hanging nodes or periodic boundary conditions. In such cases, building the sparsity pattern will succeed, but you will get errors such as the current one at one point or other when trying to write into the entries of the matrix.
Stacktrace:
-----------
#0 ./main: dealii::SparseMatrix<double>::operator()(unsigned int, unsigned int)
#1 ./main: Problem<3>::assemble_system()
#2 ./main: Problem<3>::run()
#3 ./main: main
--------------------------------------------------------
I am using the following 4 lines to make the sparsity pattern and the system matrix
DynamicSparsityPattern dsp(dof_handler.n_dofs(), dof_handler.n_dofs());
DoFTools::make_sparsity_pattern(dof_handler, dsp);
sparsity_pattern.copy_from(dsp);
system_matrix.reinit(sparsity_pattern);
I cannot see the mistake I am making while building the sparsity pattern. Any help is appreciated.
Best Regards,
Sudip Kunda