List of tutorials
commentnote:Before you proceed
All tutorials are written assuming that you are reasonably familiar with MOOSE. If you find most of the tutorials difficult to follow, please refer to the official MOOSE website for learning resources.
Tutorial 15: Mosaic field generation (patches)
In this tutorial, we present a simpler approach to generating spatially varied perturbation fields compared to Tutorial 14.
The subapp patches.i
first assigns random initial values to the Auxvariable scale
(raw)
[ICs]
[raw]
type = RandomIC
variable = scale
max = 1
min = -2
seed = ${seed}
[]
[]
From this raw field, a material field is constructed using selected statistics (e.g., maximum, mean, minimum) within a selected range (e.g., normalized range of [0, 1] )
[Materials]
[sigma_ts]
type = ADParsedMaterial
property_name = 'sigma_ts'
constant_names = 'sigma_ts_raw'
constant_expressions = '${sigma_ts}'
coupled_variables = 'scale'
expression = 'sigma_ts_raw*(10+ceil(scale))/10'
output_properties = 'sigma_ts'
outputs = exodus
[]
[]
This coarse field, downsampled by patchref
steps
[Mesh]
[ori]
type = GeneratedMeshGenerator
dim = 2
xmin = 0
xmax = 100
ymin = 0
ymax = 100
nx = '${fparse floor(100/max(1,pow(2,patchref)))}'
ny = '${fparse floor(100/max(1,pow(2,patchref)))}'
[]
[]
is then transferred to the fine mesh of the mainapp main.i
[Transfers]
[from_patches]
type = MultiAppGeneralFieldShapeEvaluationTransfer
from_multi_app = patches
variable = 'sigma_ts_var'
source_variable = 'sigma_ts'
displaced_source_mesh = false
displaced_target_mesh = false
execute_on = 'INITIAL'
[]
[]
The resulting fields are illustrated in the figure below.

Fig. 1: Mainapp mosaic field .

Fig. 2: Subapp field .

Fig. 3: Subapp scale variable.
(tutorials/patches/main.i)
patchref=4
seed=0
sigma_ts=100
filebase=patchref${patchref}
[Problem]
type = FEProblem
solve = False
[]
[MultiApps]
[patches]
type = FullSolveMultiApp
input_files = patches.i
cli_args = 'seed=${seed};sigma_ts=${sigma_ts};patchref=${patchref}'
execute_on = 'INITIAL'
[]
[]
[Transfers]
[from_patches]
type = MultiAppGeneralFieldShapeEvaluationTransfer
from_multi_app = patches
variable = 'sigma_ts_var'
source_variable = 'sigma_ts'
displaced_source_mesh = false
displaced_target_mesh = false
execute_on = 'INITIAL'
[]
[]
[Mesh]
[ori]
type = GeneratedMeshGenerator
dim = 2
xmin = 0
xmax = 100
ymin = 0
ymax = 100
nx = 100
ny = 100
[]
[]
[Variables]
[d]
[]
[]
[AuxVariables]
[sigma_ts_var]
order = CONSTANT
family = MONOMIAL
[]
[]
[Executioner]
type = Transient
solve_type = NEWTON
petsc_options_iname = '-pc_type -pc_factor_mat_solver_package '
petsc_options_value = 'lu superlu_dist '
automatic_scaling = true
line_search = bt
compute_scaling_once = true
nl_rel_tol = 1e-8
nl_abs_tol = 1e-10
dt = 1
dtmin = 1e-5
end_time = 1
[]
[Outputs]
[exodus]
type = Exodus
[]
file_base = '${filebase}'
print_linear_residuals = false
[]
(tutorials/patches/patches.i)
[Problem]
solve = false
[]
[Mesh]
[ori]
type = GeneratedMeshGenerator
dim = 2
xmin = 0
xmax = 100
ymin = 0
ymax = 100
nx = '${fparse floor(100/max(1,pow(2,patchref)))}'
ny = '${fparse floor(100/max(1,pow(2,patchref)))}'
[]
[]
[AuxVariables]
[scale]
order = CONSTANT
family = MONOMIAL
[]
[]
[ICs]
[raw]
type = RandomIC
variable = scale
max = 1
min = -2
seed = ${seed}
[]
[]
[Materials]
[sigma_ts]
type = ADParsedMaterial
property_name = 'sigma_ts'
constant_names = 'sigma_ts_raw'
constant_expressions = '${sigma_ts}'
coupled_variables = 'scale'
expression = 'sigma_ts_raw*(10+ceil(scale))/10'
output_properties = 'sigma_ts'
outputs = exodus
[]
[]
[Executioner]
type = Transient
solve_type = NEWTON
petsc_options_iname = '-pc_type -pc_factor_mat_solver_package '
petsc_options_value = 'lu superlu_dist '
automatic_scaling = true
line_search = bt
compute_scaling_once = true
nl_rel_tol = 1e-8
nl_abs_tol = 1e-10
start_time = 0
num_steps = 1
[]
[Outputs]
[exodus]
type = Exodus
[]
[]