libMesh / libmesh

libMesh github repository
http://libmesh.github.io
GNU Lesser General Public License v2.1
653 stars 286 forks source link

attach_dof_maps fails #2902

Open FilLTP89 opened 3 years ago

FilLTP89 commented 3 years ago

Hi I have troubles in attaching the dof map to my PetscMatrix couplingMatrix_mediator_mediator, defined as follows:

    libMesh::System& volume_mediator_system =
        libMesh::cast_ref<libMesh::System&>(mediator_eq_system.get_system("Elasticity"));
// stuff
    libMesh_fe_addresses_3 mediator_addresses(volume_mediator_system);
    libMesh::PetscMatrix<libMesh::Number>& couplingMatrix_mediator_mediator =
        *m_couplingMatrixMap_mediator_mediator[micro_name];
// stuff
    mediator_addresses.dof_map.compute_sparsity(mesh_R_BIG);
    couplingMatrix_mediator_mediator.attach_dof_map(mediator_addresses.dof_map);

with the class libMesh_fe_addresses_3 defined as:

class libMesh_fe_addresses_3
{
private:
  // Private default constructor
  libMesh_fe_addresses_3();

public:

  // Constructor
  libMesh_fe_addresses_3(libMesh::System& input_system,
      const std::string u_var_name = "u", const std::string v_var_name =
          "v", const std::string w_var_name = "w") :
      eq_system { input_system },
      mesh { eq_system.get_mesh() },
      dim { mesh.mesh_dimension() },
      u_var { input_system.variable_number(u_var_name) },
      v_var { input_system.variable_number(v_var_name) },
      w_var { input_system.variable_number(w_var_name) },
      dof_map { input_system.get_dof_map() },
      fe_type { dof_map.variable_type(u_var) },
      fe_unique_ptr { libMesh::FEBase::build(dim, fe_type) },
      qrule { dim, fe_type.default_quadrature_order() },
      n_dofs { 0 },
      n_dofs_u { 0 },
      n_dofs_v { 0 },
      n_dofs_w { 0 }

  {
    fe_unique_ptr->attach_quadrature_rule(&qrule);
  };

  // Members set at initialization
  libMesh::System& eq_system;
  const libMesh::MeshBase& mesh;
  const unsigned int dim;
  const unsigned int u_var;
  const unsigned int v_var;
  const unsigned int w_var;
  libMesh::DofMap& dof_map;
  //const libMesh::DofMap& dof_map;
  libMesh::FEType fe_type;
  libMesh::UniquePtr<libMesh::FEBase> fe_unique_ptr;
  libMesh::QGauss qrule;
  const libMesh::Elem* elem;

  // Members set with the set_dofs method
  std::vector<libMesh::dof_id_type> dof_indices;
  std::vector<libMesh::dof_id_type> dof_indices_u;
  std::vector<libMesh::dof_id_type> dof_indices_v;
  std::vector<libMesh::dof_id_type> dof_indices_w;

  unsigned int n_dofs;
  unsigned int n_dofs_u;
  unsigned int n_dofs_v;
  unsigned int n_dofs_w;

  void set_DoFs(int idx = 0)
  {
    const libMesh::Elem* elem_dummy = mesh.elem_ptr(idx);
    elem = mesh.elem_ptr(idx);
    dof_map.dof_indices(elem_dummy, dof_indices);
    dof_map.dof_indices(elem_dummy, dof_indices_u, u_var);
    dof_map.dof_indices(elem_dummy, dof_indices_v, v_var);
    dof_map.dof_indices(elem_dummy, dof_indices_w, w_var);
    n_dofs = dof_indices.size();
    n_dofs_u = dof_indices_u.size();
    n_dofs_v = dof_indices_v.size();
    n_dofs_w = dof_indices_w.size();
  };
};

The error I get at line couplingMatrix_mediator_mediator.attach_dof_map(mediator_addresses.dof_map); is the following (arm forge ddt compiler):

Process stopped in libMesh::PetscMatrix​​::init from

/workdir/invsem01/LOCAL/libmesh/lib/libmesh​_opt.so.0 with signal SIGSEGV ​(Segmentation fault)​.

Reason/Origin: address not mapped to object ​(attempt to access invalid address)​

I suspect it has to do with #2883 and #2884 since the code was working perfectly with the libmesh version circa 2016

thanks for help!

Filippo

Here the full code: carl.zip

roystgnr commented 3 years ago

Here the full code: carl.zip

This seems to be missing files:

CArl_assemble_coupling.cpp:31:10: fatal error: CArl_assemble_coupling.h: No such file or directory
   31 | #include "CArl_assemble_coupling.h"

Or if I try renaming assemble_coupling.h -> CArl_assemble_coupling.h

CArl_assemble_coupling.h:11:10: fatal error: carl_headers.h: No such file or directory
   11 | #include "carl_headers.h"
lcs27 commented 3 years ago

Hello, I am working with Filippo and we are sorry to have missed some files. The new full code with CArl_assemble_coupling.h file is here: CArl.zip and other headers such as carl_headers.h ,if necessary, are available in this link: https://github.com/cottereau/CArl/tree/dyncoup/Cpp/src/include However, as this is a huge program it may take a long time to compile it. Thanks again for your help!

roystgnr commented 3 years ago

However, as this is a huge program it may take a long time to compile it.

I'm fine with taking a long time to compile something. I can get other work done at the same time. What I can't do is take a long time to download a missing header, then download the five missing headers that header tried to include, then make sure I have the boost dependencies that one of those five headers requires, then download and build and install the CGAL package that one of the other five headers requires ...

And by contrast the bug report here is still at the libmesh_opt.so.0 stage! Have you at least tried running with METHOD=dbg or at least METHOD=devel yet to see if any assertions have been tripped?