Nikki,
I can't tell from these pieces of code what dimension is wrong. But you will
find it very useful to run your program in a debugger so that you can see
which matrix access it is that triggers the error, and why. There are a number
of video lectures about running a program in a debugger.
Best
WB
On 10/14/20 6:14 PM, Nikki Holtzer wrote:
The first error seems to be occurring at:
affine_constraints.distribute_local_to_global(cell_nodal_mass_matrix,
local_dof_indices, nodal_mass_matrix);
I have verified that cell_nodal_mass_matrix is indeed the same size as
nodal_mass_matrix.
cell_nodal_mass_matrix is initialized as:
FullMatrix<double> cell_nodal_mass_matrix(dofs_per_cell, dofs_per_cell);
and nodal_mass_matrix has the same dimensions.
local_dof_indices seem to be the problem. I see that on dealii 's website that
as long as cell_nodal_mass_matrix and local_dof_indices have the same number
of elements this should work.
I have defined local_dof_indices in the following way:
std::vector<types::global_dof_index> local_dof_indices(dofs_per_cell);
fe_values.reinit(cell);
cell->get_dof_indices(local_dof_indices);
The number of elements are:
cell_nodal_mass_matrix: 136
local_dof_indices: 24
How would I resolve this?
Thank you,
Nikki
On Wednesday, October 14, 2020 at 10:14:34 AM UTC-4 Nikki Holtzer wrote:
Ok thank you that has resolved most of the adding issue. I am still
receiving the following error. It reads to me that there's still an error
on the 'FullMatrix::add()' function. I have verified that they are all
gone however. What else should I be looking for?
An error occurred in line <1335> of file
</home/u7/nholtzer/dealii-9.1.1/include/deal.II/lac/full_matrix.h> in
function
void dealii::FullMatrix< <template-parameter-1-1>
>::add(dealii::FullMatrix< <template-parameter-1-1> >::size_type,
dealii::FullMatrix< <template-parameter-1-1> >::size_type, const
index_type*, const number2*, bool, bool) [with number2 = double;
index_type = unsigned int; number = double; dealii::FullMatrix<
<template-parameter-1-1> >::size_type = long unsigned int]
The violated condition was:
static_cast<typename ::dealii::internal::argument_type<void( typename
std::common_type<decltype(row), decltype(this->m())>::type)>:: type>(row)
< static_cast<typename ::dealii::internal::argument_type<void( typename
std::common_type<decltype(row), decltype(this->m())>::type)>::
type>(this->m())
Additional information:
Index 0 is not in the half-open range [0,0). In the current case,
this half-open range is in fact empty, suggesting that you are accessing
an element of an empty collection such as a vector that has not been set
to the correct size.
Stacktrace:
-----------
#0 /home/u7/nholtzer/dealii-9.1.1/lib/libdeal_II.g.so.9.1.1: void
dealii::FullMatrix<double>::add<double, unsigned int>(unsigned long,
unsigned long, unsigned int const*, double const*, bool, bool)
#1 /home/u7/nholtzer/dealii-9.1.1/lib/libdeal_II.g.so.9.1.1: void
dealii::AffineConstraints<double>::distribute_local_to_global<dealii::FullMatrix<double>,
dealii::Vector<double> >(dealii::FullMatrix<double> const&,
dealii::Vector<double> const&, std::vector<unsigned int,
std::allocator<unsigned int> > const&, dealii::FullMatrix<double>&,
dealii::Vector<double>&, bool, std::integral_constant<bool, false>) const
#2 ./gravwave: void
dealii::AffineConstraints<double>::distribute_local_to_global<dealii::FullMatrix<double>
>(dealii::FullMatrix<double> const&, std::vector<unsigned int,
std::allocator<unsigned int> > const&, dealii::FullMatrix<double>&) const
#3 ./gravwave: OfflineData<1>::assemble()
#4 ./gravwave: OfflineData<1>::prepare()
#5 ./gravwave: main
On Tuesday, October 13, 2020 at 3:37:03 PM UTC-4 Wolfgang Bangerth wrote:
On 10/13/20 10:28 AM, Nikki Holtzer wrote:
> The issue that I have when all matrices are FullMatrix matrices is
I can't
> seem to get the .add function to result in anything other than
error. If I
> keep ONLY both nonlinear_part and linear_part as FullMatrix
> I receive:
>
> error: no matching function for call to
> ‘dealii::FullMatrix<double>::add(double, const
dealii::SparseMatrix<double>&)’
>
> linear_part.add((1. - theta) * kappa, S_c);
>
>
> Which leads me to believe that I cannot add a SparseMatrix (S_c) to a
> FullMatrix (linear_part).
Correct -- there is no such function.
> I tried to back track and change S_c to be a
> FullMatrix instead of a SparseMatrix
>
> For instance:
>
>
> FullMatrix<double> mass_matrix_unconstrainted;
> mass_matrix_unconstrained = 0;
> FullMatrix<double> cell_mass_matrix(dofs_per_cell, dofs_per_cell);
> cell_mass_matrix = 0;
>
>
> Then I fill cell_mass_matrix.
>
> mass_matrix_unconstrained.add(local_dof_indices, cell_mass_matrix);
>
> error: no matching function for call to
> ‘dealii::FullMatrix<double>::add(std::vector<unsigned int>&,
> dealii::FullMatrix<double>&)’
>
> mass_matrix_unconstrained.add(local_dof_indices,
cell_mass_matrix);
Right, that function also doesn't exist, but you could do
for (unsigned int i=0; i<dofs_per_cell; ++i)
for (unsigned int j=0; j<dofs_per_cell; ++j)
mass_matrix_unconstrainted(local_dof_indices[i], local_dof_indices[j])
+= cell_mass_matrix(i,j);
> Alternatively if I try:
>
> mass_matrix_unconstrained = mass_matrix_unconstrained +
> local_dof_indices*cell_mass_matrix;
>
>
> I receive.
>
> error: no match for ‘operator*’ (operand types are
‘std::vector<unsigned int>’
> and ‘dealii::FullMatrix<double>’)
Right. There is also no operator* for vector<unsigned int> and
FullMatrix<double>. It's also unclear to me what exactly that would
actually
supposed to do.
Writing the double-loop above is the way to go.
Best
W.
--
------------------------------------------------------------------------
Wolfgang Bangerth email: [email protected]
www: http://www.math.colostate.edu/~bangerth/
--
The deal.II project is located at http://www.dealii.org/
<https://nam01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.dealii.org%2F&data=02%7C01%7CWolfgang.Bangerth%40colostate.edu%7C0f4b5d9bc81e4aa9984708d8709f5570%7Cafb58802ff7a4bb1ab21367ff2ecfc8b%7C0%7C0%7C637383176932210123&sdata=C2kpiS1UGPD2KcgJ6OUXv08tykRiVvHFCtyfcGgWXmE%3D&reserved=0>
For mailing list/forum options, see
https://groups.google.com/d/forum/dealii?hl=en
<https://nam01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fforum%2Fdealii%3Fhl%3Den&data=02%7C01%7CWolfgang.Bangerth%40colostate.edu%7C0f4b5d9bc81e4aa9984708d8709f5570%7Cafb58802ff7a4bb1ab21367ff2ecfc8b%7C0%7C0%7C637383176932210123&sdata=07ZJ%2FIjSK0cZXfjqTRoqRNN6HVktn%2FPCDgvP20HbdnQ%3D&reserved=0>
---
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]
<mailto:[email protected]>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/dealii/a9c2f25b-e5fc-4fe1-92e7-9641331a6143n%40googlegroups.com
<https://nam01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fdealii%2Fa9c2f25b-e5fc-4fe1-92e7-9641331a6143n%2540googlegroups.com%3Futm_medium%3Demail%26utm_source%3Dfooter&data=02%7C01%7CWolfgang.Bangerth%40colostate.edu%7C0f4b5d9bc81e4aa9984708d8709f5570%7Cafb58802ff7a4bb1ab21367ff2ecfc8b%7C0%7C0%7C637383176932220121&sdata=ICBH4g%2FL1QvA0hylXhcv6QKWzZ5OTg1YgQZckIEOHxU%3D&reserved=0>.
--
------------------------------------------------------------------------
Wolfgang Bangerth email: [email protected]
www: http://www.math.colostate.edu/~bangerth/
--
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/7aab8000-4c7f-028f-a240-ecbb82fe5a57%40colostate.edu.