Browse files

Merge pull request #12564 from rwcarlsen/example-doc

Improve example 5 and adaptivity pages
  • Loading branch information...
moosebuild committed Dec 4, 2018
2 parents aa10866 + 3001310 commit f575b1618dbb07775d0d4edb44ed3a9ac544d444
@@ -2,6 +2,34 @@
file = cube-hole.e
# This is where mesh adaptivity magic happens:
marker = errorfrac # this specifies which marker from 'Markers' subsection to use
steps = 6 # run adaptivity 6 times, recomputing solution, indicators, and markers each time
# Use an indicator to compute an error-estimate for each element:
# create an indicator computing an error metric for the convected variable
[./error] # arbitrary, use-chosen name
type = GradientJumpIndicator
variable = convected
outputs = none
# Create a marker that determines which elements to refine/coarsen based on error estimates
# from an indicator:
[./errorfrac] # arbitrary, use-chosen name (must match 'marker=...' name above
type = ErrorFractionMarker
indicator = error # use the 'error' indicator specified above
refine = 0.5 # split/refine elements in the upper half of the indicator error range
coarsen = 0 # don't do any coarsening
outputs = none
order = FIRST
@@ -67,27 +95,6 @@
nl_abs_tol = 1e-9
marker = errorfrac
steps = 2
type = GradientJumpIndicator
variable = convected
outputs = none
type = ErrorFractionMarker
refine = 0.5
coarsen = 0
indicator = error
outputs = none
execute_on = 'timestep_end'
exodus = true
@@ -15,6 +15,7 @@
variable = diffused
# Include our time derivative here
type = ExampleTimeDerivative
variable = diffused
@@ -38,11 +39,12 @@
# Transient (time-dependent) details for simulations go here:
type = Transient # Here we use the Transient Executioner
type = Transient # Here we use the Transient Executioner (instead of steady)
solve_type = 'PJFNK'
num_steps = 75
dt = 1
num_steps = 75 # Run for 75 time steps, solving the system each step.
dt = 1 # each time step will have duration "1"
@@ -24,7 +24,6 @@ validParams<ExampleTimeDerivative>()
ExampleTimeDerivative::ExampleTimeDerivative(const InputParameters & parameters)
: TimeDerivative(parameters),
// This kernel expects an input parameter named "time_coefficient"
@@ -1,16 +1,12 @@
# Adaptivity System
## h-Adaptivity
!media media/adaptivity/element_adaptivity.png style=width:250px;float:right;padding-left:20px; caption=Self-similar refinement pattern utilized by MOOSE for adaptivity.
MOOSE employs $h$-adaptivity to automatically refine or coarsen the mesh in regions of high or low
estimated solution error, respectively. 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`](/Adaptivity/Indicators/ Once an error has been computed, a
[`Marker`](/Adaptivity/Markers/ is used to decide which elements to refine or coarsen. Mesh
adaptivity can be employed in both `Steady` and `Transient` Executioners.
adaptivity can be employed with both `Steady` and `Transient` Executioners.
## Refinement Patterns
@@ -21,4 +17,10 @@ reverse, children are deleted and the "parent" element is reactivated. The origi
refinement level 0. Each time an element is split, the children are assigned a refinement level one
higher than their parents.
!media media/adaptivity/element_adaptivity.png
caption=Self-similar refinement pattern utilized by MOOSE for adaptivity.
!syntax parameters /Adaptivity
!syntax list /Adaptivity objects=False actions=False subsystems=True
@@ -2,6 +2,10 @@
# Adaptivity System
In general, you should use the top-level `Adaptivity` block in input files rather than the
`Executioner/Adaptivity` sub-block. Documentation for this is located
!syntax list /Executioner/Adaptivity objects=True actions=False subsystems=False
!syntax list /Executioner/Adaptivity objects=False actions=False subsystems=True
@@ -5,7 +5,7 @@
This example briefly describes the creation of a basic input file and the six required sections
for utilizing MOOSE for solving a problem.
We consider the steady-state diffusion equation on the 3D domain $$\Omega$$: find $u$ such that
We consider the steady-state diffusion equation on the 3D domain $\Omega$: find $u$ such that
$-\nabla \cdot \nabla u = 0 \in \Omega$, $u = 1$ on the bottom, $u = 0$ on the top and with
$\nabla u \cdot \hat{n} = 0$ on the remaining boundaries.
@@ -1,14 +1,28 @@
# 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
!listing examples/ex05_amr/ex05.i block=Adaptivity
More details about this functionality are provided on the [Adaptivity](syntax/Adaptivity/
page. MOOSE includes multiple [Indicators](Indicators/ you can use to compute different
error estimates in addition to a few [Markers](Markers/
## Results
Mesh results from each refinement step in `ex05.i` are shown below:
!media large_media/examples/ex5-mesh-0.png
caption=Initial mesh
!media large_media/examples/ex5-mesh-1.png
caption=Adaptivity Step 1
!media large_media/examples/ex5-mesh-2.png
caption=Adaptivity Step 2
@@ -30,9 +44,12 @@
caption=Adaptivity Step 6
And here is the final solution after all refinement steps are complete:
!media large_media/examples/ex5_out.png
caption=Example 5 Output
## Complete Source Files
@@ -2,6 +2,49 @@
## Problem Statement
We consider the transient diffusion equation on the 3D domain $\Omega$: find $u$ such that
$-\nabla \cdot \nabla u = 20\frac{\partial u}{\partial t} \in \Omega$, $u = 0$ on the bottom, $u =
1$ on the top and with $\nabla u \cdot \hat{n} = 0$ on the remaining boundaries. The initial
condition is $u(t_0) = 0$ everywhere except on the top boundary where $u = 1$.
The weak form of this equation, in inner-product notation, is given by: $\nabla \phi_i, \nabla u_h
= \phi_i, 20 \frac{\partial u_h}{\partial t} \quad \forall \phi_i$, where $\phi_i$ are the
test functions and $u_h$ is the finite element solution.
## Constructing the Problem
First, we need a transient term to for our residual. We can create a time-dependent residual term
by inheriting from the [`TimeDerivative`](/ class. For this example, we create
a constant-scalable time-dependent residual along the lines of kernels created in the earlier
!listing examples/ex06_transient/src/kernels/ExampleTimeDerivative.C start=#include end=$ max-height=10000
The input file for this is very similar to the simple diffusion input file from example 1.
We need to add the time derivative residual contribution:
!listing examples/ex06_transient/ex06.i block=Kernels
And finally, we need to specify some transient related parameters:
!listing examples/ex06_transient/ex06.i block=Executioner
There are many more options available that are described in the [Transient Executioner documentation](/executioners/
It is also common to use more sophisticated ways for
time-stepping through simulations. [Example 16](examples/ goes over some of
this and details about specific time stepping schemes are provided in the
[Timestepper System documentation](syntax/Executioner/TimeStepper/
## Outputs
Here are solution snapshots from the beginning and end times from running `ex06-opt -i ex06.i`:
!media large_media/examples/ex6-1-out.png
!media large_media/examples/ex6-2-out.png
## Complete Source Files
- [examples/ex06_transient/ex06.i]
@@ -11,11 +54,3 @@
- [examples/ex06_transient/src/kernels/ExampleTimeDerivative.C]
- [examples/ex06_transient/src/base/ExampleApp.C]
## Outputs
!media large_media/examples/ex6-1-out.png
!media large_media/examples/ex6-2-out.png

0 comments on commit f575b16

Please sign in to comment.