idaholab / moose

Multiphysics Object Oriented Simulation Environment
https://www.mooseframework.org
GNU Lesser General Public License v2.1
1.76k stars 1.05k forks source link

Opt-mode FVDiffusionInterface seg faults if sideset extends by blocks where the variable is not defined #21346

Open GiudGiud opened 2 years ago

GiudGiud commented 2 years ago

Bug Description

in opt

  * frame #0: 0x0000000101183356 libmoose-opt.0.dylib`MooseVariableFV<double>::getElemValue(libMesh::Elem const*) const + 86
    frame #1: 0x00000001014ad784 libmoose-opt.0.dylib`FVDiffusionInterface::computeQpResidual() + 932
    frame #2: 0x00000001014ad180 libmoose-opt.0.dylib`FVInterfaceKernel::computeResidual(FaceInfo const&) + 304
    frame #3: 0x000000010136f773 libmoose-opt.0.dylib`ComputeFVFluxThread<libMesh::StoredRange<std::__1::__wrap_iter<FaceInfo const* const*>, FaceInfo const*>, AttribVectorTags>::onBoundary(FaceInfo const&, short) + 675
    frame #4: 0x000000010136e8d9 libmoose-opt.0.dylib`ThreadedFaceLoop<libMesh::StoredRange<std::__1::__wrap_iter<FaceInfo const* const*>, FaceInfo const*> >::operator()(libMesh::StoredRange<std::__1::__wrap_iter<FaceInfo const* const*>, FaceInfo const*> const&, bool) + 633
    frame #5: 0x0000000101309a6a libmoose-opt.0.dylib`void libMesh::Threads::parallel_reduce<libMesh::StoredRange<std::__1::__wrap_iter<FaceInfo const* const*>, FaceInfo const*>, ComputeFVFluxResidualThread<libMesh::StoredRange<std::__1::__wrap_iter<FaceInfo const* const*>, FaceInfo const*> > >(libMesh::StoredRange<std::__1::__wrap_iter<FaceInfo const* const*>, FaceInfo const*> const&, ComputeFVFluxResidualThread<libMesh::StoredRange<std::__1::__wrap_iter<FaceInfo const* const*>, FaceInfo const*> >&) + 74

in devel: We properly catch it

Assertion `((ft1 == ft_both) && (ft2 == ft_both)) || (_elem_is_one && (ft1 == ft_elem) && (ft2 == ft_neigh)) || (!_elem_is_one && (ft1 == ft_neigh) && (ft2 == ft_elem))' failed
Face type was not recognized. Check that the specified boundaries are interfaces.
at /Users/giudgl/projects/pronghorn/moose/framework/src/fviks/FVInterfaceKernel.C, line 160

Steps to Reproduce

extend your sidesets too far, use a FVDiffusionInterface

Impact

Minor impact since workaround is easy, just be more careful with your sidesets

j-bowhay commented 2 years ago

Hi I am currently having this issue myself with the exact same error. I was hoping you could elaborate more on the work around and what you mean by "extend your sidesets too far"? My input file:

# 2d siumulation of water through a concentric tube HE

mu=1e-3 # [Nsm^-2]
rho=997.0 # [Kgm^-3]
cp_water=4182
k_water=0.598
cp_copper=385
k_copper=386
Re_inner=1000.0
Re_outer=1000.0
pipe_length=1 # [m]
inner_radius=0.05 # the radius of the inner section [m]
middle_thickness=0.005 # the thickness of the conductive interface [m]
outer_thickness=0.05 # the thickness of the annulus [m]
T_inner = 300 # [K]
T_outer = 290 # [K]
u_inner_inlet=${fparse (mu * Re_inner)/(2 * inner_radius * rho)}
u_outer_inlet=${fparse (mu * Re_outer)/(2 * inner_radius * rho)}

[GlobalParams]
  rhie_chow_user_object = 'rc'
[]

[UserObjects]
  [rc]
    type = INSFVRhieChowInterpolator
    u = u
    v = v
    pressure = pressure
    block = '0 2'
  []
[]

[Mesh]
  construct_side_list_from_node_list=true
  [inner_mesh]
    type = GeneratedMeshGenerator
    dim = 2
    xmin = 0
    xmax = ${pipe_length}
    ymin = 0
    ymax = ${fparse inner_radius}
    nx = 200
    ny = 15
    boundary_name_prefix = 'inner'
  []
  [outer_mesh]
    type = GeneratedMeshGenerator
    dim = 2
    xmin = 0
    xmax = ${pipe_length}
    ymin = ${fparse inner_radius + middle_thickness}
    ymax = ${fparse inner_radius + outer_thickness + middle_thickness}
    nx = 200
    ny = 15
    boundary_name_prefix = 'outer'
    boundary_id_offset = 4
  []
  [middle_mesh]
    type = GeneratedMeshGenerator
    dim = 2
    xmin = 0
    xmax = ${pipe_length}
    ymin = ${inner_radius}
    ymax = ${fparse inner_radius + middle_thickness}
    nx = 200
    ny = 2
    boundary_name_prefix = 'middle'
    boundary_id_offset = 8
  []
  [id_middle]
    type = ParsedSubdomainMeshGenerator
    input = middle_mesh
    combinatorial_geometry = 'y > ${inner_radius} & y < ${fparse inner_radius + middle_thickness}'
    block_id = 1
  []
  [id_outer]
    type = ParsedSubdomainMeshGenerator
    input = outer_mesh
    combinatorial_geometry = 'y > ${fparse inner_radius + middle_thickness}'
    block_id = 2
  []
  [combined_mesh]
    type = CombinerGenerator
    inputs = 'inner_mesh id_middle id_outer'
  []
[]

[Problem]
  fv_bcs_integrity_check = true
  coord_type = 'RZ'
  rz_coord_axis = x
[]

[Variables]
  [u]
    type = INSFVVelocityVariable
    initial_condition = ${u_inner_inlet} #ms^1
    block = '0 2'
  []
  [v]
    type = INSFVVelocityVariable
    initial_condition = 1e-15 #ms^-1
    block = '0 2'
  []
  [pressure]
    type = INSFVPressureVariable
    block = '0 2'
  []
  [T]
    type = INSFVEnergyVariable
    block = '0 1 2'
  []
[]

[FVKernels]
  [mass]
    type = INSFVMassAdvection
    variable = pressure
    rho = ${rho}
    block = '0 2'
  []

  [u_advection]
    type = INSFVMomentumAdvection
    variable = u
    rho = ${rho}
    momentum_component = 'x'
    block = '0 2'
  []
  [u_viscosity]
    type = INSFVMomentumDiffusion
    variable = u
    mu = ${mu}
    momentum_component = 'x'
    block = '0 2'
  []
  [u_pressure]
    type = INSFVMomentumPressure
    variable = u
    momentum_component = 'x'
    pressure = pressure
    block = '0 2'
  []

  [v_advection]
    type = INSFVMomentumAdvection
    variable = v
    rho = ${rho}
    momentum_component = 'y'
    block = '0 2'
  []
  [v_viscosity]
    type = INSFVMomentumDiffusion
    variable = v
    mu = ${mu}
    momentum_component = 'y'
    block = '0 2'
  []
  [v_pressure]
    type = INSFVMomentumPressure
    variable = v
    momentum_component = 'y'
    pressure = pressure
    block = '0 2'
  []
  [temp_advection]
    type = INSFVEnergyAdvection
    variable = T
    block = '0 2'
  []
  [temp_conduction]
    type = FVDiffusion
    coeff = 'k'
    variable = T
    block = '0 1 2'
  []
[]

[FVInterfaceKernels]
  [interface]
    type = FVDiffusionInterface
    variable1 = T
    boundary = 'inner_top'
    subdomain1 = '0'
    subdomain2 = '1'
    coeff1 = 'k'
    coeff2 = 'k'
  []
[]

[FVBCs]
  [outer-inlet-u]
    type = INSFVInletVelocityBC
    boundary = 'outer_left'
    variable = u
    function = ${u_outer_inlet}
  []
  [outer-inlet-v]
    type = INSFVInletVelocityBC
    boundary = 'outer_left'
    variable = v
    function = 0
  []
  [outer-top-no-slip-wall-u]
    type = INSFVNoSlipWallBC
    boundary = 'outer_top'
    variable = u
    function = 0
  []
  [outer-top-no-slip-wall-v]
    type = INSFVNoSlipWallBC
    boundary = 'outer_top'
    variable = v
    function = 0
  []
  [outer-outlet-p]
    type = INSFVOutletPressureBC
    boundary = 'outer_right'
    variable = pressure
    function = 1e-15
  []
  [no-slip-outer-middle-u]
    type = INSFVNoSlipWallBC
    boundary = 'outer_bottom'
    variable = u
    function = 0
  []
  [no-slip-outer-middle-v]
    type = INSFVNoSlipWallBC
    boundary = 'outer_bottom'
    variable = v
    function = 0
  [] 
  [no-slip-inner-middle-u]
    type = INSFVNoSlipWallBC
    boundary = 'inner_top'
    variable = u
    function = 0
  []
  [no-slip-inner-middle-v]
    type = INSFVNoSlipWallBC
    boundary = 'inner_top'
    variable = v
    function = 0
  [] 
  [inner-inlet-u]
    type = INSFVInletVelocityBC
    boundary = 'inner_left'
    variable = u
    function = ${u_inner_inlet}
  []
  [inner-inlet-v]
    type = INSFVInletVelocityBC
    boundary = 'inner_left'
    variable = v
    function = 0
  []
  [inner-outlet-p]
    type = INSFVOutletPressureBC
    boundary = 'inner_right'
    variable = pressure
    function = 1e-15
  []
  [axis-u]
    type = INSFVSymmetryVelocityBC
    boundary = 'inner_bottom'
    variable = u
    u = u
    v = v
    mu = ${mu}
    momentum_component = x
  []
  [axis-v]
    type = INSFVSymmetryVelocityBC
    boundary = 'inner_bottom'
    variable = v
    u = u
    v = v
    mu = ${mu}
    momentum_component = y
  []
  [axis-p]
    type = INSFVSymmetryPressureBC
    boundary = 'inner_bottom'
    variable = pressure
  []
  [T_in_inner]
    type = FVDirichletBC
    variable = T
    boundary = 'inner_left'
    value = ${T_inner}
  []
  [T_in_outer]
    type = FVDirichletBC
    variable = T
    boundary = 'outer_left'
    value = ${T_outer}
  []
[]

[Materials]
  [water]
    type = ADGenericFunctorMaterial
    prop_names = 'cp k'
    prop_values = '${cp_water} ${k_water}'
    block='0 2'
  []
  [copper]
    type = ADGenericFunctorMaterial
    prop_names = 'cp k rho'
    prop_values = '${cp_copper} ${k_copper} 4000'
    block='1'
  []
  [ins_fv]
    type = INSFVEnthalpyMaterial
    temperature = 'T'
    rho = ${rho}
    block='0 2'
  []
[]

[Executioner]
  type = Steady
  solve_type = 'NEWTON'
  petsc_options_iname = '-pc_type -ksp_gmres_restart -sub_pc_type -sub_pc_factor_shift_type'
  petsc_options_value = 'asm      100                lu           NONZERO'
  nl_max_its = 50       
  l_max_its = 50
  nl_rel_tol = 1e-12
[]

[Outputs]
  exodus = true
[]
GiudGiud commented 2 years ago

By too far I mean the sideset extends beyond the domain of definition of either variable1 or variable2. So when the code loops over the sides, it cant compute values for one or both of these variables.

What error do you get in devel mode?

j-bowhay commented 2 years ago

The error I am getting is:

Assertion `((ft1 == ft_both) && (ft2 == ft_both)) || (_elem_is_one && (ft1 == ft_elem) && (ft2 == ft_neigh)) || (!_elem_is_one && (ft1 == ft_neigh) && (ft2 == ft_elem))' failed
Face type was not recognized. Check that the specified boundaries are interfaces.
at /home/jbowhay/projects/moose/framework/src/fviks/FVInterfaceKernel.C, line 157
GiudGiud commented 2 years ago

This is a different issue. You dont need this diffusion interface here This kernel:

  [temp_conduction]
    type = FVDiffusion
    coeff = 'k'
    variable = T
    block = '0 1 2'
  []

is already propagating a diffusive flux across the inner_top boundary

j-bowhay commented 2 years ago

This is a different issue. You dont need this diffusion interface here

I have tried without the interface however I get no diffusion between blocks as per the image bellow.

 

Screenshot 2022-06-22 at 11 08 58
GiudGiud commented 2 years ago

oh there is a disjoint interface. We dont support this in finite volume yet.

We have demands inside the lab too for this so we ll work on this. after the summer probably