# h-Adaptivity

- $$h$$-adaptivity is a method of automatically refining/coarsening the mesh in regions of high/low estimated solution error.
- The idea is to concentrate degrees of freedom (DOFs) where the error is highest, while reducing DOFs where the solution is already well-captured.
- This is achieved through splitting and joining elements from the original mesh based on an error `Indicator`.
- Once an error `Indicator` has been computed, a `Marker` is used to decide which cells to refine and coarsen.
- Mesh adaptivity can be employed in both `Steady` and `Transient` Executioners.

# Refinement Patterns


- MOOSE employs "self-similar", isotropic refinement patterns.
- When an element is marked for refinement, it is split into elements of the same type.
- For example, when using Quad4 elements, four "child" elements are created when the element is refined.
- Coarsening happens in reverse, children are deleted and the "parent" element is reactivated.
- The original mesh starts at refinement level 0.
- Each time an element is split, the children are assigned a refinement level one higher than their parents.




# Indicators

- `Indicators` attempt to report a relative amount of "error" for each element.
- Built-in `Indicators` include:

| `Indicator` | Description |
| `GradientJumpIndicator` | Jump in the gradient of a variable across element edges (pictured to the right). A good "curvature" indicator that works well over a wide range of problems. |
| `FluxJumpIndicator` | Similar to `GradientJump`, except that a scalar coefficient (e.g. thermal conductivity) can be provided to produce a physical "flux" quantity. |
| `LaplacianJumpIndicator` | Jump in the second derivative of a variable. Only useful for $$C^1$$ shape functions. |
| `AnalyticIndicator` | Computes the difference between the finite element solution and a user-supplied `Function` representing the analytic solution to the problem.


- In higher dimensions, the gradient jump is integrated around element edges to find contributions to each connected element.


# Markers

- After an `Indicator` has computed the error for each element, a decision to refine or coarsen elements must be made.
- The `Marker` class is used for this purpose. Built-in `Markers` include:

| `Marker` | Description |
| `ErrorFractionMarker` | Selects elements based on their contribution to the total error (see Figure). |
| `ErrorToleranceMaker` | Refine if error is greater than a specified value. Coarsen if less than. |
| `ValueThresholdMarker` | Refine if variable value is greater than a specific value. Coarsen if less than. |
| `UniformMarker` | Refine or coarsen all elements. |
| `BoxMarker` | Refine or coarsen inside or outside a given box. |
| `ComboMarker` | Combine several of the above `Markers`. |



- `Markers` produce an element field that can be viewed in your visualization utility.
- Custom `Markers` are easy to create by inheriting from the `Marker` base class.




# Input File Syntax


- To enable adaptivity, add an `Adaptivity` block to the input file.
- The `Adaptivity` block has several parameters:
    * `marker`: (Optional) Name of the `Marker` to use. *If not set, no mesh adaptivity will be done*.
    * `steps`: Number of refinement steps to do in a steady state calculation. Ignored by `Transient` executioners.
- `Adaptivity` has two sub-blocks: `Indicators` and `Markers`. Within these blocks, you can specify multiple `Indicator` and `Marker` objects that will be active in the simulation.


  marker = errorfrac
  steps = 2

      type = GradientJumpIndicator
      variable = convected

      type = ErrorFractionMarker
      refine = 0.5
      coarsen = 0
      indicator = error


# Example 5
Look at [Example 5](/wiki/MooseExamples/Example_05)