idaholab / moose

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

Dirichlet BC for Constant Monomial Variable #21044

Closed AhmedAlmetwally closed 2 years ago

AhmedAlmetwally commented 2 years ago

Bug Description

Nodal Dirichlet BC for a constant monomial variable is not working because of the absence of the nodal/quadrature points on the boundary for constant variable. It works only when we have higher order variables.

Steps to Reproduce: Example to generate the bug... A data file, failed to solve with a constant monomial variable, and the same input solved successfully with first order variable.

[Mesh]
  type = GeneratedMesh
  parallel_type = replicated # Until RayTracing.C is fixed
  dim = 2
  nx = 10
  ny = 10
[]

[Variables]
  [u]
    family = MONOMIAL
    order = CONSTANT
  []
[]

[Kernels]
  [diff]
    type = Diffusion
    variable = u
  []
[]

[BCs]
  [left]
    type = DirichletBC
    variable = u
    boundary = left
    value = 0
  []
  [right]
    type = DirichletBC
    variable = u
    boundary = right
    value = 1
  []
  [bottom]
    type = DirichletBC
    variable = u
    boundary = bottom
    value = 0
  []
  [top]
    type = DirichletBC
    variable = u
    boundary = top
    value = 1
  []
[]

[VectorPostprocessors]
  [elems]
    type = ElementsAlongLine
    start = '0.05 0 0'
    end = '0.405 0 0'
  []
[]

[Executioner]
  type = Steady
  solve_type = PJFNK
  petsc_options_iname = '-pc_type -pc_hypre_type'
  petsc_options_value = 'hypre boomeramg'
[]

[Outputs]
  exodus = true
  csv = true
[]

Linear Variable Data File:

[Mesh]
  type = GeneratedMesh
  parallel_type = replicated # Until RayTracing.C is fixed
  dim = 2
  nx = 10
  ny = 10
[]

[Variables]
  [u]
  []
[]

[Kernels]
  [diff]
    type = Diffusion
    variable = u
  []
[]

[BCs]
  [left]
    type = DirichletBC
    variable = u
    boundary = left
    value = 0
  []
  [right]
    type = DirichletBC
    variable = u
    boundary = right
    value = 1
  []
  [bottom]
    type = DirichletBC
    variable = u
    boundary = bottom
    value = 0
  []
  [top]
    type = DirichletBC
    variable = u
    boundary = top
    value = 1
  []

[]

[VectorPostprocessors]
  [elems]
    type = ElementsAlongLine
    start = '0.05 0 0'
    end = '0.405 0 0'
  []
[]

[Executioner]
  type = Steady
  solve_type = PJFNK
  petsc_options_iname = '-pc_type -pc_hypre_type'
  petsc_options_value = 'hypre boomeramg'
[]

[Outputs]
  exodus = true
  csv = true
[]

Impact

Cell-Centered Continuous/Discontinuous Galerkin is needed to enforce mass conservation for flow. Dirichlet BC should be enforced as a constant or through reflection elements as handled in the FV Dirichlet BC.

AhmedAlmetwally commented 2 years ago

@dschwen

dschwen commented 2 years ago

You can use PenaltyDirichletBC here instead. That one is integrated rather than nodal and will work for monomial variables.