I didn't read the code in detail, but is the fix as simple as

#include "libmesh/sparse_matrix.h"

?

--
John


On Mon, Aug 16, 2021 at 10:06 AM edgar <edgar...@cryptolab.net> wrote:

> Hello,
>
> I'm sorry to bother you. I'm getting an error, and I dont' know how to
> solve it. I am trying to restructure some examples from the
> /systems_of_equations/ directory into a single program.
>
> I am compiling in debug mode with mpicxx. The error message reads:
> =invalid use of incomplete type 'class
> libMesh::SparseMatrix<std::complex<double> >'=. The message is next, and
> the offending code is below (I think attachments are scrubbed-off).
> Thank you very much for your time and patience. If it lacks clarity or
> you need anything else, just let me know.
>
> #+caption: The compiler tells me this
> #+begin_example
>    src/main.cpp: In function 'void asm_subfun(KE&, KEV&, FE&, FEV&,
> libMesh::EquationSystems&, const string&)':
>    src/main.cpp:193:7: warning: invalid use of incomplete type 'class
> libMesh::SparseMatrix<std::complex<double> >'
>      193 |       matrix.add_matrix         (Ke, dof_indices);
>          |       ^~~~~~
>    In file included from
> src/../include/getpot_bc_2_linear_implicit_eq_sys.h:5,
>                     from src/main.cpp:1:
>    /usr/include/libmesh/dof_map.h:74:29: note: declaration of 'class
> libMesh::SparseMatrix<std::complex<double> >'
>       74 | template <typename T> class SparseMatrix;
>          |                             ^~~~~~~~~~~~
>    src/main.cpp:194:17: warning: invalid use of incomplete type 'class
> libMesh::NumericVector<std::complex<double> >'
>      194 |       system.rhs->add_vector    (Fe, dof_indices);
>          |                 ^~
>    In file included from /usr/include/libmesh/dof_object.h:25,
>                     from /usr/include/libmesh/mesh_base.h:24,
>                     from /usr/include/libmesh/elem_range.h:24,
>                     from /usr/include/libmesh/dof_map.h:30,
>                     from
> src/../include/getpot_bc_2_linear_implicit_eq_sys.h:5,
>                     from src/main.cpp:1:
>    /usr/include/libmesh/int_range.h:34:29: note: declaration of 'class
> libMesh::NumericVector<std::complex<double> >'
>       34 | template <typename T> class NumericVector;
>          |                             ^~~~~~~~~~~~~
>    src/main.cpp: In instantiation of 'void asm_subfun(KE&, KEV&, FE&,
> FEV&, libMesh::EquationSystems&, const string&) [with KE =
> libMesh::DenseMatrix<std::complex<double> >; KEV =
> libMesh::DenseSubMatrix<std::complex<double> > [1][1]; FE =
> libMesh::DenseVector<std::complex<double> >; FEV =
> libMesh::DenseSubVector<std::complex<double> > [1]; std::string =
> std::__cxx11::basic_string<char>]':
>    src/main.cpp:351:15:   required from here
>    src/main.cpp:193:14: error: invalid use of incomplete type 'class
> libMesh::SparseMatrix<std::complex<double> >'
>      193 |       matrix.add_matrix         (Ke, dof_indices);
>          |       ~~~~~~~^~~~~~~~~~
>    In file included from
> src/../include/getpot_bc_2_linear_implicit_eq_sys.h:5,
>                     from src/main.cpp:1:
>    /usr/include/libmesh/dof_map.h:74:29: note: declaration of 'class
> libMesh::SparseMatrix<std::complex<double> >'
>       74 | template <typename T> class SparseMatrix;
>          |                             ^~~~~~~~~~~~
>    src/main.cpp:194:19: error: invalid use of incomplete type 'class
> libMesh::NumericVector<std::complex<double> >'
>      194 |       system.rhs->add_vector    (Fe, dof_indices);
>          |       ~~~~~~~^~~~~~~~~~
> #+end_example
>
> #+name: asm_subfunc
> #+caption: This function is called by =assembly_elasticity=
> #+begin_src c++
>    template <typename KE, typename KEV, typename FE, typename FEV>
>    void
>    asm_subfun (KE  &Ke,
>                KEV &Ke_var,
>                FE  &Fe,
>                FEV &Fe_var,
>                libMesh::EquationSystems &es,
>                const std::string &libmesh_dbg_var (system_name)) {
>
>        libmesh_assert_equal_to (system_name,
>                                 "LinearIsotropicSystem");
>        libMesh::LinearImplicitSystem &system =
>          es.get_system<libMesh::LinearImplicitSystem> (
>            "LinearIsotropicSystem");
>
>        const libMesh::MeshBase &mesh = es.get_mesh ();
>
>        const unsigned int mesh_dim = mesh.mesh_dimension ();
>
>        const unsigned int u_var = system.variable_number ("u");
>
>        const libMesh::DofMap &dof_map = system.get_dof_map ();
>        libMesh::FEType fe_type = dof_map.variable_type (u_var);
>        std::unique_ptr<libMesh::FEBase> fe (
>          libMesh::FEBase::build (mesh_dim, fe_type));
>        libMesh::QGauss qrule (
>          mesh_dim, fe_type.default_quadrature_order ());
>        fe->attach_quadrature_rule (&qrule);
>
>        std::unique_ptr<libMesh::FEBase> fe_face (
>          libMesh::FEBase::build (mesh_dim, fe_type));
>        libMesh::QGauss qface (
>          mesh_dim - 1, fe_type.default_quadrature_order ());
>        fe_face->attach_quadrature_rule (&qface);
>
>        const std::vector<libMesh::Real> &JxW = fe->get_JxW ();
>        const std::vector<std::vector<libMesh::Real>> &phi =
>          fe->get_phi ();
>        const std::vector<std::vector<libMesh::RealGradient>>
>          &dphi = fe->get_dphi ();
>
>        std::vector<libMesh::dof_id_type>              dof_indices;
>        std::vector<std::vector<libMesh::dof_id_type>> dof_indices_var (
>          3);
>
>        libMesh::SparseMatrix<libMesh::Number> &matrix =
>          system.get_system_matrix ();
>
>        auto lame_lambda =
> es.parameters.get<libMesh::Real>("lame_lambda");
>        auto lame_mu = es.parameters.get<libMesh::Real>("lame_mu");
>
>        for (const auto &elem :
>             mesh.active_local_element_ptr_range ()) {
>            dof_map.dof_indices (elem, dof_indices);
>            for (unsigned int var = 0; var < mesh_dim; var++)
>                dof_map.dof_indices (
>                  elem, dof_indices_var[var], var);
>
>            const unsigned int n_dofs = dof_indices.size ();
>            const unsigned int n_var_dofs =
>              dof_indices_var[0].size ();
>
>            fe->reinit (elem);
>
>            Ke.resize (n_dofs, n_dofs);
>            Fe.resize (n_dofs);
>
>            for (unsigned int var_i = 0; var_i < 3; var_i++)
>                for (unsigned int var_j = 0; var_j < 3; var_j++)
>                    Ke_var[var_i][var_j].reposition (
>                      var_i * n_var_dofs,
>                      var_j * n_var_dofs,
>                      n_var_dofs,
>                      n_var_dofs);
>            for (unsigned int var = 0; var < 3; var++)
>                Fe_var[var].reposition (var * n_var_dofs, n_var_dofs);
>
>            for (unsigned int qp = 0; qp < qrule.n_points (); qp++) {
>                for (unsigned int dof_i = 0; dof_i < n_var_dofs; dof_i++)
>                    for (unsigned int dof_j = 0; dof_j < n_var_dofs;
> dof_j++)
>                        for (unsigned int i = 0; i < 3; i++)
>                            for (unsigned int j = 0; j < 3; j++)
>                                for (unsigned int k = 0; k < 3; k++)
>                                    for (unsigned int l = 0; l < 3; l++)
>                                        Ke_var[i][k](dof_i, dof_j) +=
>                                          JxW[qp] *
>                                          linear_isotropic_elasticity_comp
> (i, j, k, l) *
>                                          dphi[dof_j][qp](l) *
>                                          dphi[dof_i][qp](j);
>
>                libMesh::VectorValue<libMesh::Number> f_vec (0., 0., -1.);
>                for (unsigned int dof_i = 0; dof_i < n_var_dofs;
>                     dof_i++)
>                    for (unsigned int i = 0; i < 3; i++)
>                        Fe_var[i](dof_i) += JxW[qp] * (f_vec (i) *
> phi[dof_i][qp]);
>            } // end of quadrature point loop
>
>          dof_map.constrain_element_matrix_and_vector (Ke, Fe,
> dof_indices);
>
>          matrix.add_matrix         (Ke, dof_indices);
>          system.rhs->add_vector    (Fe, dof_indices);
>        } // end of element loop
>    }
> #+end_src
>
> #+name: assemble_elasticity
> #+caption: This is a prototype function which is not called by anything
> yet
> #+begin_src C++
>    void
>    assemble_elasticity (
>      libMesh::EquationSystems &  es,
>      const std::string &libmesh_dbg_var (system_name)) {
>
>      const libMesh::MeshBase &mesh = es.get_mesh ();
>      const unsigned int mesh_dim = mesh.mesh_dimension ();
>
>      libMesh::DenseMatrix<libMesh::Number> Ke;
>      libMesh::DenseVector<libMesh::Number> Fe;
>
>      if (mesh_dim == 1) {
>        libMesh::DenseSubMatrix<libMesh::Number> Ke_var[1][1] = {
>          { libMesh::DenseSubMatrix<libMesh::Number> (Ke) }};
>        libMesh::DenseSubVector<libMesh::Number> Fe_var[1] = {
>          libMesh::DenseSubVector<libMesh::Number> (Fe)};
>        asm_subfun(Ke, Ke_var, Fe, Fe_var, es, system_name);
>      }
>    }
> #+end_src
>
> #+name: libmesh_headers
> #+caption: These are the headers that I use which come from libMesh
> (there are more, for unrelated local functions)
> #+begin_src C++
> #include "libmesh/boundary_info.h"
> #include "libmesh/const_function.h"
> #include "libmesh/dirichlet_boundaries.h"
> #include "libmesh/quadrature_gauss.h"
> #include "libmesh/dof_map.h"
> #include "libmesh/enum_fe_family.h"
> #include "libmesh/enum_order.h"
> #include "libmesh/enum_solver_package.h"
> #include "libmesh/equation_systems.h"
> #include "libmesh/getpot.h"
> #include "libmesh/libmesh.h"
> #include "libmesh/libmesh_common.h"
> #include "libmesh/linear_implicit_system.h"
> #include "libmesh/mesh.h"
> #include <iostream>
> #+end_src
>
>
>
>

_______________________________________________
Libmesh-users mailing list
Libmesh-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libmesh-users

Reply via email to