Example 1 : As Simple as it Gets
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:
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.
[Mesh] file = 'mug.e' 
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.
[Variables] [./diffused] 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
Kernelon the previously defined variable "diffused".
[Kernels] [./diff] type = Diffusion variable = diffused [../] 
Boundary Conditions (BCs)
Boundary conditions are defined in a similar manner as
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:
In the input file the two boundary conditions are applied utilizing a single C++ object as follows.
[BCs] [./bottom] type = DirichletBC variable = diffused boundary = 'bottom' value = 1 [../] [./top] 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
For this problem the type is
Steadyand the method for solving is the default, Preconditioned Jacobain Free Newton Krylov.
[Executioner] 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).
[Outputs] 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).
Complete Source Files
Diffusion kernel is the only "physics" in the MOOSE framework * A large set of physics is included in the MOOSE modules