Example 05 : Automatic Mesh Adaptivity

MOOSE has support for mesh adaptivity that can automatically refine and coarsen the mesh in areas of higher/lower error when solving problems. This can improve the quality of your results in addition to reducing computation time. You don't need to write any C++ code to use mesh adaptivity. Instead, it can easily be enabled by filling out the Adaptivity section in an input file:

[Adaptivity<<<{"href": "../../../syntax/Adaptivity/index.html"}>>>]
  marker<<<{"description": "The name of the Marker to use to actually adapt the mesh."}>>> = errorfrac # this specifies which marker from 'Markers' subsection to use
  steps<<<{"description": "The number of adaptive steps to use when doing a Steady simulation."}>>> = 2 # run adaptivity 2 times, recomputing solution, indicators, and markers each time

  # Use an indicator to compute an error-estimate for each element:
  [./Indicators<<<{"href": "../../../syntax/Adaptivity/Indicators/index.html"}>>>]
    # create an indicator computing an error metric for the convected variable
    [./error]
      # arbitrary, use-chosen name
      type = GradientJumpIndicator<<<{"description": "Compute the jump of the solution gradient across element boundaries.", "href": "../../../source/indicators/GradientJumpIndicator.html"}>>>
      variable<<<{"description": "The name of the variable that this side indicator applies to"}>>> = convected
      outputs<<<{"description": "Vector of output names where you would like to restrict the output of variables(s) associated with this object"}>>> = none
    [../]
  [../]

  # Create a marker that determines which elements to refine/coarsen based on error estimates
  # from an indicator:
  [./Markers<<<{"href": "../../../syntax/Adaptivity/Markers/index.html"}>>>]
    [./errorfrac]
      # arbitrary, use-chosen name (must match 'marker=...' name above
      type = ErrorFractionMarker<<<{"description": "Marks elements for refinement or coarsening based on the fraction of the min/max error from the supplied indicator.", "href": "../../../source/markers/ErrorFractionMarker.html"}>>>
      indicator<<<{"description": "The name of the Indicator that this Marker uses."}>>> = error # use the 'error' indicator specified above
      refine<<<{"description": "Elements within this percentage of the max error will be refined.  Must be between 0 and 1!"}>>> = 0.5 # split/refine elements in the upper half of the indicator error range
      coarsen<<<{"description": "Elements within this percentage of the min error will be coarsened.  Must be between 0 and 1!"}>>> = 0 # don't do any coarsening
      outputs<<<{"description": "Vector of output names where you would like to restrict the output of variables(s) associated with this object"}>>> = none
    [../]
  [../]
[]
(examples/ex05_amr/ex05.i)

More details about this functionality are provided on the Adaptivity page. MOOSE includes multiple Indicators you can use to compute different error estimates in addition to a few Markers.

Results

The results shown here are created using 6 refinement steps. However, because it can take a while to run, the ex05.i input file only specifies running 2 mesh refinement steps. Mesh results from each of the 6 refinement steps are shown below:

Initial mesh

Adaptivity Step 1

Adaptivity Step 2

Adaptivity Step 3

Adaptivity Step 4

Adaptivity Step 5

Adaptivity Step 6

And here is the final solution after all refinement steps are complete:

Example 5 Output

Complete Source Files