constraints.clear ();
make_periodicity_constraints ();
std::map<types::global_dof_index,double> boundary_values;
VectorTools::interpolate_boundary_values (dof_handler, 1,
ZeroFunction<2> (),
boundary_values);
constraints.close ();
constraints.condense (system_matrix, system_rhs);
MatrixTools::apply_boundary_values (boundary_values,
system_matrix,
solution,
system_rhs);
However, it gave me an error:
An error occurred in line <1723> of file <../include/deal.II/lac/sparse_matrix.h> in function
void dealii::SparseMatrix<double>::add(const size_type, const size_type, const number) [number = double]
The violated condition was:
(index != SparsityPattern::invalid_entry) || (value == number()).
The name and call sequence of the exception was:
ExcInvalidIndex(i, j)
Additional Information:
The entry with index <389,1> does not exist.
I revised the code in the following,
constraints.clear ();
make_periodicity_constraints ();
VectorTools::interpolate_boundary_values (dof_handler, 1,
ZeroFunction<2> (),
constraints);
constraints.close ();
constraints.condense (system_matrix, system_rhs);
which still gave me similar error.
Did I make any mistake when using constraints.condense() or should I also revise any other part of the code? Thanks!
Chenchen
Now the problem is, when I use the following codes:constraints.clear ();make_periodicity_constraints ();constraints.close ();if I put the above lines before I define "DoFTools::make_sparsity_pattern (dof_handler, dsp, constraints, true);", it works perfectly.If I put the same codes later and don't consider "constraints" in "make_sparsity_pattern" (the code is listed in previous email), it does not work. It seems that if I want to apply periodic constraints, I have to put the constraints in the definition of sparsity pattern. In other words, in order to apply periodic boundary condition, at each time step, I have to re-assemble the system_matrix... However, this is what I want to avoid.