message: Allow reading Gmsh meshes where all elements have attribute zero
diff: @@ -1884,6 +1884,9 @@ void Mesh::ReadGmshMesh(std::istream &input, int &curved, int &read_gf)
  ho_wdg[2] = wdg18; ho_wdg[3] = wdg40;
  ho_pyr[2] = pyr14; ho_pyr[3] = pyr30;
  + bool has_nonpositive_phys_domain = false;
  + bool has_positive_phys_domain = false;
  +
  if (binary)
  {
  int n_elem_part = 0; // partial sum of elements that are read
  @@ -1934,17 +1937,19 @@ void Mesh::ReadGmshMesh(std::istream &input, int &curved, int &read_gf)
  vert_indices[vi] = it->second;
  }
  - // non-positive attributes are not allowed in MFEM
  + // Non-positive attributes are not allowed in MFEM. However,
  + // by default, Gmsh sets the physical domain of all elements
  + // to zero. In the case that all elements have physical domain
  + // zero, we will given them attribute 1. If only some elements
  + // have physical domain zero, we will throw an error.
  if (phys_domain <= 0)
  {
  - MFEM_ABORT("Non-positive element attribute in Gmsh mesh!\n"
  - "By default Gmsh sets element tags (attributes)"
  - " to '0' but MFEM requires that they be"
  - " positive integers.\n"
  - "Use \"Physical Curve\", \"Physical Surface\","
  - " or \"Physical Volume\" to set tags/attributes"
  - " for all curves, surfaces, or volumes in your"
  - " Gmsh geometry to values which are >= 1.");
  + has_nonpositive_phys_domain = true;
  + phys_domain = 1;
  + }
  + else
  + {
  + has_positive_phys_domain = true;
  }
  // initialize the mesh element
  @@ -2161,17 +2166,19 @@ void Mesh::ReadGmshMesh(std::istream &input, int &curved, int &read_gf)
  vert_indices[vi] = it->second;
  }
  - // non-positive attributes are not allowed in MFEM
  + // Non-positive attributes are not allowed in MFEM. However,
  + // by default, Gmsh sets the physical domain of all elements
  + // to zero. In the case that all elements have physical domain
  + // zero, we will given them attribute 1. If only some elements
  + // have physical domain zero, we will throw an error.
  if (phys_domain <= 0)
  {
  - MFEM_ABORT("Non-positive element attribute in Gmsh mesh!\n"
  - "By default Gmsh sets element tags (attributes)"
  - " to '0' but MFEM requires that they be"
  - " positive integers.\n"
  - "Use \"Physical Curve\", \"Physical Surface\","
  - " or \"Physical Volume\" to set tags/attributes"
  - " for all curves, surfaces, or volumes in your"
  - " Gmsh geometry to values which are >= 1.");
  + has_nonpositive_phys_domain = true;
  + phys_domain = 1;
  + }
  + else
  + {
  + has_positive_phys_domain = true;
  }
  // initialize the mesh element
  @@ -2356,6 +2363,18 @@ void Mesh::ReadGmshMesh(std::istream &input, int &curved, int &read_gf)
  } // el (all elements)
  } // if ASCII
  + if (has_positive_phys_domain && has_nonpositive_phys_domain)
  + {
  + MFEM_ABORT("Non-positive element attribute in Gmsh mesh!\n"
  + "By default Gmsh sets element tags (attributes)"
  + " to '0' but MFEM requires that they be"
  + " positive integers.\n"
  + "Use \"Physical Curve\", \"Physical Surface\","
  + " or \"Physical Volume\" to set tags/attributes"
  + " for all curves, surfaces, or volumes in your"
  + " Gmsh geometry to values which are >= 1.");
  + }
  +
  if (!elements_3D.empty())
  {
  Dim = 3;
  