Deal deal.II community,
I want to apply periodic boundary conditions to my problem. But I can't use
the make_periodicity_constraint() function due to the special nature of my
problem (or so I think). So i create the required constraint matrix by
taking the usual route of the AffineConstraints::add_entries() function.
My constraints are of the type: x_i (+ side dof) = a_ij * x_j ( - side
dof).
I need to apply these constraints after the assembly routine i.e. in the
non-linear solver's load step loop (in the problems i have attempted until
this one the contraints are applied in the setup_system() function).
With this brief, here's the code snippet i use (in the non-linear solver)
to do the job of applying the constraints on the linear system. I start
with creating an AffineConstraint object (different from the one used to
create the system_rhs and system_matrix in the assemble_system() function).
Then i simply want to apply the constraints using this object to the
system_matrix and system_rhs. However, i get an error which is given below
the code snippet.
AffineConstraints<double> constraints1;
// apply constraints
create_1d_pbc_constraints(constraints1);
// print all constraints that are obtained from the above function
constraints1.print(std::cout);
SparsityPattern sp;
sp.copy_from(system_matrix.get_sparsity_pattern());
std::ostringstream oss_4;
oss_4 << "sp.txt";
std::string filename4 = oss_4.str();
std::ofstream output_4(filename4.c_str());
sp.print(output_4);
std::cout << "closing constraint" << std::endl;
constraints1.close();
constraints1.condense(m_rod_Network->system_matrix_network,m_rod_Network->system_rhs_network);
*Output:*
60 0: 1
60 1: 0
60 2: 0
61 0: 0
61 1: 1
61 2: 0
62 0: 0
62 1: 0
62 2: 1
63 3: 1
63 4: 0
63 5: 0
64 3: 0
64 4: 1
64 5: 0
65 3: 0
65 4: 0
65 5: 1
closing constraint
--------------------------------------------------------
An error occurred in line <1934> of file
</tmp/vinayak/spack-stage/spack-stage-dealii-9.4.0-36iqlesdxyr55pceokjxk6hkwcek4m2d/spack-src/include/deal.II/lac/sparse_matrix.h>
in function
void
dealii::SparseMatrix<Number>::add(dealii::SparseMatrix<Number>::size_type,
dealii::SparseMatrix<Number>::size_type, number) [with number = double;
dealii::SparseMatrix<Number>::size_type = unsigned int]
The violated condition was:
(index != SparsityPattern::invalid_entry) || (value == number())
Additional information:
You are trying to access the matrix entry with index <54,0>, 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
/home/vinayak/spack/opt/spack/linux-ubuntu22.04-broadwell/gcc-11.3.0/dealii-9.4.0-36iqlesdxyr55pceokjxk6hkwcek4m2d/lib/libdeal_II.g.so.9.4.0:
dealii::SparseMatrix<double>::add(unsigned int, unsigned int, double)
#1
/home/vinayak/spack/opt/spack/linux-ubuntu22.04-broadwell/gcc-11.3.0/dealii-9.4.0-36iqlesdxyr55pceokjxk6hkwcek4m2d/lib/libdeal_II.g.so.9.4.0:
void dealii::AffineConstraints<double>::condense<dealii::Vector<double>
>(dealii::SparseMatrix<double>&, dealii::Vector<double>&) const
The error says "You are trying to access the matrix entry with index
<54,0>". *This seems to be inconsistent with the constraint matrix*
(printed in the output above)*. *I am also attaching the sparsity pattern
if needed.
Can someone help me with this? Also, since this procedure of applying
constraints in the solver routine is quite different from the usual, it
would help if someone could confirm that the above way of applying
constraints is correct and/or if there's anything else i need to keep in
mind.
Thanks
Vinayak
--
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see
https://groups.google.com/d/forum/dealii?hl=en
---
You received this message because you are subscribed to the Google Groups
"deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/dealii/486614cb-9400-438d-8826-be30bbcd1481n%40googlegroups.com.
[0,0,1,2,3,4,5,6,7,8,9,10,11]
[1,1,0,2,3,4,5,6,7,8,9,10,11]
[2,2,0,1,3,4,5,6,7,8,9,10,11]
[3,3,0,1,2,4,5,6,7,8,9,10,11]
[4,4,0,1,2,3,5,6,7,8,9,10,11]
[5,5,0,1,2,3,4,6,7,8,9,10,11]
[6,6,0,1,2,3,4,5,7,8,9,10,11,12,13,14,15,16,17]
[7,7,0,1,2,3,4,5,6,8,9,10,11,12,13,14,15,16,17]
[8,8,0,1,2,3,4,5,6,7,9,10,11,12,13,14,15,16,17]
[9,9,0,1,2,3,4,5,6,7,8,10,11,12,13,14,15,16,17]
[10,10,0,1,2,3,4,5,6,7,8,9,11,12,13,14,15,16,17]
[11,11,0,1,2,3,4,5,6,7,8,9,10,12,13,14,15,16,17]
[12,12,6,7,8,9,10,11,13,14,15,16,17,18,19,20,21,22,23]
[13,13,6,7,8,9,10,11,12,14,15,16,17,18,19,20,21,22,23]
[14,14,6,7,8,9,10,11,12,13,15,16,17,18,19,20,21,22,23]
[15,15,6,7,8,9,10,11,12,13,14,16,17,18,19,20,21,22,23]
[16,16,6,7,8,9,10,11,12,13,14,15,17,18,19,20,21,22,23]
[17,17,6,7,8,9,10,11,12,13,14,15,16,18,19,20,21,22,23]
[18,18,12,13,14,15,16,17,19,20,21,22,23,24,25,26,27,28,29]
[19,19,12,13,14,15,16,17,18,20,21,22,23,24,25,26,27,28,29]
[20,20,12,13,14,15,16,17,18,19,21,22,23,24,25,26,27,28,29]
[21,21,12,13,14,15,16,17,18,19,20,22,23,24,25,26,27,28,29]
[22,22,12,13,14,15,16,17,18,19,20,21,23,24,25,26,27,28,29]
[23,23,12,13,14,15,16,17,18,19,20,21,22,24,25,26,27,28,29]
[24,24,18,19,20,21,22,23,25,26,27,28,29,30,31,32,33,34,35]
[25,25,18,19,20,21,22,23,24,26,27,28,29,30,31,32,33,34,35]
[26,26,18,19,20,21,22,23,24,25,27,28,29,30,31,32,33,34,35]
[27,27,18,19,20,21,22,23,24,25,26,28,29,30,31,32,33,34,35]
[28,28,18,19,20,21,22,23,24,25,26,27,29,30,31,32,33,34,35]
[29,29,18,19,20,21,22,23,24,25,26,27,28,30,31,32,33,34,35]
[30,30,24,25,26,27,28,29,31,32,33,34,35,36,37,38,39,40,41]
[31,31,24,25,26,27,28,29,30,32,33,34,35,36,37,38,39,40,41]
[32,32,24,25,26,27,28,29,30,31,33,34,35,36,37,38,39,40,41]
[33,33,24,25,26,27,28,29,30,31,32,34,35,36,37,38,39,40,41]
[34,34,24,25,26,27,28,29,30,31,32,33,35,36,37,38,39,40,41]
[35,35,24,25,26,27,28,29,30,31,32,33,34,36,37,38,39,40,41]
[36,36,30,31,32,33,34,35,37,38,39,40,41,42,43,44,45,46,47]
[37,37,30,31,32,33,34,35,36,38,39,40,41,42,43,44,45,46,47]
[38,38,30,31,32,33,34,35,36,37,39,40,41,42,43,44,45,46,47]
[39,39,30,31,32,33,34,35,36,37,38,40,41,42,43,44,45,46,47]
[40,40,30,31,32,33,34,35,36,37,38,39,41,42,43,44,45,46,47]
[41,41,30,31,32,33,34,35,36,37,38,39,40,42,43,44,45,46,47]
[42,42,36,37,38,39,40,41,43,44,45,46,47,48,49,50,51,52,53]
[43,43,36,37,38,39,40,41,42,44,45,46,47,48,49,50,51,52,53]
[44,44,36,37,38,39,40,41,42,43,45,46,47,48,49,50,51,52,53]
[45,45,36,37,38,39,40,41,42,43,44,46,47,48,49,50,51,52,53]
[46,46,36,37,38,39,40,41,42,43,44,45,47,48,49,50,51,52,53]
[47,47,36,37,38,39,40,41,42,43,44,45,46,48,49,50,51,52,53]
[48,48,42,43,44,45,46,47,49,50,51,52,53,54,55,56,57,58,59]
[49,49,42,43,44,45,46,47,48,50,51,52,53,54,55,56,57,58,59]
[50,50,42,43,44,45,46,47,48,49,51,52,53,54,55,56,57,58,59]
[51,51,42,43,44,45,46,47,48,49,50,52,53,54,55,56,57,58,59]
[52,52,42,43,44,45,46,47,48,49,50,51,53,54,55,56,57,58,59]
[53,53,42,43,44,45,46,47,48,49,50,51,52,54,55,56,57,58,59]
[54,54,48,49,50,51,52,53,55,56,57,58,59,60,61,62,63,64,65]
[55,55,48,49,50,51,52,53,54,56,57,58,59,60,61,62,63,64,65]
[56,56,48,49,50,51,52,53,54,55,57,58,59,60,61,62,63,64,65]
[57,57,48,49,50,51,52,53,54,55,56,58,59,60,61,62,63,64,65]
[58,58,48,49,50,51,52,53,54,55,56,57,59,60,61,62,63,64,65]
[59,59,48,49,50,51,52,53,54,55,56,57,58,60,61,62,63,64,65]
[60,60,54,55,56,57,58,59,61,62,63,64,65]
[61,61,54,55,56,57,58,59,60,62,63,64,65]
[62,62,54,55,56,57,58,59,60,61,63,64,65]
[63,63,54,55,56,57,58,59,60,61,62,64,65]
[64,64,54,55,56,57,58,59,60,61,62,63,65]
[65,65,54,55,56,57,58,59,60,61,62,63,64]