Example 1 : As Simple as it Gets

Problem Statement

This example briefly describes the creation of a basic input file and the six required components for utilizing MOOSE for solving a problem.

We consider the steady-state diffusion equation on the 3D domain \Omega: find such that , on the bottom, on the top and with on the remaining boundaries.

The weak form (see Finite Elements Principles) of this equation, in inner-product notation, is given by: , where are the test functions and is the finite element solution.

Input File Syntax

A basic moose input file requires six parts:

  • Mesh

  • Variables

  • Kernels

  • BCs

  • Executioner

  • Outputs


  • The domain for the problem is created with the "Mesh" block in the input file.

  • Here the mesh, the mesh is read from the file mug.e.

  file = 'mug.e'

mug.e mesh file


  • In this simple problem, a single variable, 'diffused,' is defined, which represents u from the continuous problem.

  • The 'diffused' variable is approximated with linear Lagrange shape functions.

    order = FIRST
    family = LAGRANGE


  • The weak form of problem statement is represented by a Diffusion` Kernel` object.

  • In general, users write their own Kernels and store them in their own MOOSE-based application, but in this case the Diffusion Kernel is already defined in MOOSE.

  • Within the input file, to invoke the use of this object a sub-block is defined, named "diff", that utilizes the Diffusion Kernel on the previously defined variable "diffused".

    type = Diffusion
    variable = diffused

Boundary Conditions (BCs)

  • Boundary conditions are defined in a similar manner as Kernels.

  • For the current problem two Dirichlet boundary conditions are required, again an object for this type of boundary is already defined in a C++ object within MOOSE: DirichletBC.

  • In the input file the two boundary conditions are applied utilizing a single C++ object as follows.

    type = DirichletBC
    variable = diffused
    boundary = 'bottom'
    value = 1
    type = DirichletBC
    variable = diffused
    boundary = 'top'
    value = 0
  • Within each of the two sub-blocks, named "top" and "bottom" by the user, the boundary conditions are linked to the associated variable ("variable = diffused") and boundary.

  • The supplied mesh file, mug.e, prescribes and labels the boundaries "top" and "bottom", these are often numbers depending on how your mesh file was generated.

  • Note, the Neumann boundary condition for this problem is automatically satisfied, thus there is no need to define it. However, non-zero Neumann conditions as well as many others may be defined using existing MOOSE objects (e.g., NeumannBC) or using custom boundary conditions derived from the existing objects within MOOSE.


  • The type of problem to solve and the method for solving is defined within the Executioner block.

  • For this problem the type is Steady and the method for solving is the default, Preconditioned Jacobain Free Newton Krylov.

  type = Steady
  solve_type = 'PJFNK'


  • Here two types of outputs are enabled: output to the screen (console) and output to an Exodus II file (exodus).

  • Setting the "file_base" parameter is optional, in this example it forces the output file to be named "out.e" ("e" is the extension used for the Exodus II format).

  file_base = out
  screen = true
  exodus = true

Running the Problem

  • This example may be run using Peacock or by running the following commands form the command line.

cd ~/projects/moose/examples/ex01_inputfile
make -j8
./ex01-opt -i ex01.i
  • This will generate the results file, out.e, as shown in Figure 2. This file may be viewed using Peacock or an external application that supports the Exodus II format (e.g., Paraview).

Example 1 Results

Complete Source Files







Next Steps

  • Diffusion kernel is the only "physics" in the MOOSE framework * A large set of physics is included in the MOOSE modules

  • In order to implement your own physics, you must understand three things: * Finite Element Methods and the generation of a "weak" form * C++ and object-oriented design * The Anatomy of a MOOSE Object