moose icon indicating copy to clipboard operation
moose copied to clipboard

New add_subdomain_names capability does not work with exodus output if subdomains are not added before output

Open GiudGiud opened this issue 1 year ago • 1 comments

Bug Description

if the subdomain is not created by the time the mesh is output

libMesh terminating:
ExodusII_IO_Helper: block id 72 not found in block_ids.
Stack frames: 17
0: 0   libmesh_devel.0.dylib               0x000000010e3e2e60 libMesh::print_trace(std::__1::basic_ostream<char, std::__1::char_traits<char>>&) + 1044
1: 1   libmesh_devel.0.dylib               0x000000010e3dfc30 libMesh::MacroFunctions::report_error(char const*, int, char const*, char const*, std::__1::basic_ostream<char, std::__1::char_traits<char>>&) + 272
2: 2   libmesh_devel.0.dylib               0x000000010e9d5670 libMesh::ExodusII_IO_Helper::initialize_element_variables(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>>, std::__1::vector<std::__1::set<unsigned short, std::__1::less<unsigned short>, std::__1::allocator<unsigned short>>, std::__1::allocator<std::__1::set<unsigned short, std::__1::less<unsigned short>, std::__1::allocator<unsigned short>>>> const&) + 1156
3: 3   libmesh_devel.0.dylib               0x000000010e9b880c libMesh::ExodusII_IO::write_element_data(libMesh::EquationSystems const&) + 668
4: 4   libmoose-devel.0.dylib              0x0000000108cf10c8 Exodus::outputElementalVariables() + 304
5: 5   libmoose-devel.0.dylib              0x0000000108ce8d34 AdvancedOutput::output() + 440
6: 6   libmoose-devel.0.dylib              0x0000000108cf075c Exodus::output() + 184
7: 7   libmoose-devel.0.dylib              0x0000000108cefc3c OversampleOutput::outputStep(MooseEnumItem const&) + 760
8: 8   libmoose-devel.0.dylib              0x0000000108d137c0 OutputWarehouse::outputStep(MooseEnumItem) + 216
9: 9   libmoose-devel.0.dylib              0x00000001083ee144 FEProblemBase::outputStep(MooseEnumItem) + 712
10: 10  libmoose-devel.0.dylib              0x0000000107cf2254 Transient::preExecute() + 156
11: 11  libmoose-devel.0.dylib              0x0000000107cf1100 Transient::execute() + 64
12: 12  libmoose-devel.0.dylib              0x0000000108ddc97c MooseApp::executeExecutioner() + 700
13: 13  libmoose-devel.0.dylib              0x0000000108dd4e34 MooseApp::run() + 4584
14: 14  pronghorn-devel                     0x000000010447bbf8 void Moose::main<PronghornTestApp>(int, char**) + 152
15: 15  pronghorn-devel                     0x000000010447bb54 main + 12
16: 16  dyld                                0x0000000181c160e0 start + 2360
[0] ../src/mesh/exodusII_io_helper.C, line 3262, compiled May 15 2024 at 10:58:09

application called MPI_Abort(MPI_COMM_WORLD, 1) - process 0
[unset]: write_line error; fd=-1 buf=:cmd=abort exitcode=1
:
system msg for write_line failure : Bad file descriptor

Steps to Reproduce

Run with

  • exodus output
  • add_subdomain_names = 'dummy' in the Mesh block

Impact

Slowing down debugging add_subdomain_names is great for changing the mesh and setting all the missing subdomains there to avoid re-writing the input

[Optional] Diagnostics

No response

GiudGiud avatar Jun 26 '24 22:06 GiudGiud

@grunerjmeier fyi

GiudGiud avatar Jun 26 '24 22:06 GiudGiud

Hello, has this issue been fixed?

PEI0214 avatar Aug 21 '25 08:08 PEI0214

no but there;s a workaround. It should work fine when adding dummy variables that are not block restricted

GiudGiud avatar Aug 21 '25 14:08 GiudGiud

I attempted to add the dummy AuxVariables, but the problem still persisted. The following is my input file.

test.i
[Problem]
  kernel_coverage_check = false
  material_coverage_check = false
  boundary_restricted_node_integrity_check = false
[]

new_domain_blocks = '1001    1002'

[Mesh]
  [box]
    type = GeneratedMeshGenerator
    dim = 3
    nx = 10
    ny = 10
    nz = 10
    xmin = 0
    xmax = 1
    ymin = 0
    ymax = 1
    zmin = 0
    zmax = 1
  []
  [box1]
    type = SubdomainBoundingBoxGenerator
    input = box
    block_id = 1
    bottom_left = '0 0.5 0'
    top_right = '1 1 1'
  []

  add_subdomain_ids = '${new_domain_blocks}'
[]

[GlobalParams]
  displacements = 'disp_x disp_y disp_z'
[]

[Variables]
  [disp_x]
    block = '${new_domain_blocks}'
  []
  [disp_y]
    block = '${new_domain_blocks}'
  []
  [disp_z]
    block = '${new_domain_blocks}'
  []
  [porepressure]
    block = '${new_domain_blocks}'
  []
[]

[AuxVariables]
  [dummy]
  []
[]

# ===== Tensor mechanics for all active domain blocks =====
[Physics]
  [SolidMechanics]
    [QuasiStatic]
      [all]
        strain = SMALL
        incremental = true
        block = '${new_domain_blocks}'
        add_variables = false
      []
    []
  []
[]

[FluidProperties]
  [the_simple_fluid]
    type = SimpleFluidProperties
    thermal_expansion = 0.0
    bulk_modulus = 2e9
    viscosity = 1e-3
    density0 = 1000
  []
[]

[PorousFlowFullySaturated]
  coupling_type = HydroMechanical
  displacements = 'disp_x disp_y disp_z'
  porepressure = porepressure
  biot_coefficient = 1.0
  gravity = '0 -9.8 0'
  fp = the_simple_fluid
  block = '${new_domain_blocks}'
  add_darcy_aux = false
[]

# ===== Boundary Conditions =====
[BCs]
  [archor_x]
    type = DirichletBC
    boundary = 'bottom'
    variable = disp_x
    value = 0
  []

  [archor_y]
    type = DirichletBC
    boundary = 'bottom'
    variable = disp_y
    value = 0
  []

  [archor_z]
    type = DirichletBC
    boundary = 'bottom'
    variable = disp_z
    value = 0
  []
[]

# ===== Materials (linear-elastic to keep it simple) =====
[Materials]
  [elasticity_tensor1]
    type = ComputeIsotropicElasticityTensor
    youngs_modulus = 50E6 # 50 MPa
    poissons_ratio = 0.3
    block = '${new_domain_blocks}'
  []

  [stress]
    type = ComputeFiniteStrainElasticStress
    block = '${new_domain_blocks}'
  []

  [density1]
    type = GenericConstantMaterial
    prop_names = density
    prop_values = 2000
    block = '${new_domain_blocks}'
  []

  [porosity_soil]
    type = PorousFlowPorosityConst # only the initial value of this is used
    porosity = 0.2
    PorousFlowDictator = dictator
    block = '${new_domain_blocks}'
  []

  [biot_modulus]
    type = PorousFlowConstantBiotModulus
    PorousFlowDictator = dictator
    biot_coefficient = 1.0
    block = '${new_domain_blocks}'
  []

  [permeability_soil]
    type = PorousFlowPermeabilityConst
    permeability = '1e-14 0 0   0 1e-14 0   0 0 1e-14'
    PorousFlowDictator = dictator
    block = '${new_domain_blocks}'
  []
[]

[MeshModifiers]
  [m1]
    type = TimedSubdomainModifier
    times = '200 300'
    blocks_from = '0 1'
    blocks_to = '1001    1002'
  []
[]

# ===== Executioner =====
[Executioner]
  type = Transient

  end_time = 500
  dt = 100

  solve_type = 'PJFNK'

  nl_abs_tol = 1E-5
  nl_max_its = 400

  l_tol = 1E-8
  l_max_its = 200
[]

[Outputs]
  exodus = true
[]

libMesh terminating:
ExodusII_IO_Helper: block id 1001 not found in block_ids.
Stack frames: 17
0: libMesh::print_trace(std::ostream&)
1: libMesh::MacroFunctions::report_error(char const*, int, char const*, char const*, std::ostream&)
2: libMesh::ExodusII_IO_Helper::initialize_element_variables(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, std::vector<std::set<unsigned short, std::less<unsigned short>, std::allocator<unsigned short> >, std::allocator<std::set<unsigned short, std::less<unsigned short>, std::allocator<unsigned short> > > > const&)
3: libMesh::ExodusII_IO::write_element_data(libMesh::EquationSystems const&)
4: Exodus::outputElementalVariables()
5: AdvancedOutput::output()
6: Exodus::output()
7: OversampleOutput::outputStep(MooseEnumItem const&)
8: OutputWarehouse::outputStep(MooseEnumItem)
9: FEProblemBase::outputStep(MooseEnumItem)
10: TransientBase::preExecute()
11: TransientBase::execute()
12: MooseApp::executeExecutioner()
13: MooseApp::run()
14: ../../porous_flow-opt(+0x40e8) [0x559442e7b0e8]
15: __libc_start_main
16: ../../porous_flow-opt(+0x438a) [0x559442e7b38a]
[0] ../src/mesh/exodusII_io_helper.C, line 3273, compiled Jan  4 2025 at 01:18:42

Abort(1) on node 0 (rank 0 in comm 0): application called MPI_Abort(MPI_COMM_WORLD, 1) - process 0

PEI0214 avatar Aug 25 '25 12:08 PEI0214

In your model, all the physics is acting on the blocks added via add_subdomain_ids; the same with the (regular) variables. You could try to swap this (using the new and empty blocks without physics) and then the AuxVariables-trick should work.

jmeier avatar Aug 25 '25 12:08 jmeier

Thank you for your answer. Could you please give an example?

PEI0214 avatar Aug 25 '25 14:08 PEI0214

The example given in https://github.com/idaholab/moose/discussions/26941 uses the blocks created via add_subdomain_ids without physics.

jmeier avatar Aug 25 '25 16:08 jmeier