- bufferThe buffer this compute is writing to
C++ Type:std::string
Controllable:No
Description:The buffer this compute is writing to
- expressionParsed expression
C++ Type:std::string
Controllable:No
Description:Parsed expression
ParsedCompute
ParsedCompute object.
Overview
Evaluates a user-provided algebraic expression to compute the target buffer from named inputs and coordinates. Specify the expression via "expression" and list input buffers with "inputs". Enabling "extra_symbols" adds symbols like x, y, z.
Example Input File Syntax
[TensorBuffers<<<{"href": "../../syntax/TensorBuffers/index.html"}>>>]
[diff]
[]
[](test/tests/gradient/gradient_square.i)Input Parameters
- constant_expressionsVector of values for the constants in constant_names (can be an FParser expression)
C++ Type:std::vector<std::string>
Controllable:No
Description:Vector of values for the constants in constant_names (can be an FParser expression)
- constant_namesVector of constants used in the parsed function (use this for kB etc.)
C++ Type:std::vector<std::string>
Controllable:No
Description:Vector of constants used in the parsed function (use this for kB etc.)
- derivativesList of inputs to take the derivative w.r.t. (or none)
C++ Type:std::vector<std::string>
Controllable:No
Description:List of inputs to take the derivative w.r.t. (or none)
- enable_fpoptimizerTrueUse algebraic optimizer
Default:True
C++ Type:bool
Controllable:No
Description:Use algebraic optimizer
- expandNONEExpand the tensor to full size.
Default:NONE
C++ Type:MooseEnum
Options:REAL, RECIPROCAL, NONE
Controllable:No
Description:Expand the tensor to full size.
- extra_symbolsFalseProvide i (imaginary unit), kx,ky,kz (reciprocal space frequency), k2 (square of the k-vector), x,y,z (real space coordinates), time t, pi, and e.
Default:False
C++ Type:bool
Controllable:No
Description:Provide i (imaginary unit), kx,ky,kz (reciprocal space frequency), k2 (square of the k-vector), x,y,z (real space coordinates), time t, pi, and e.
- inputsBuffer names used in the expression
C++ Type:std::vector<std::string>
Controllable:No
Description:Buffer names used in the expression
- is_integerFalseTurn the function result into an integer tensor
Default:False
C++ Type:bool
Controllable:No
Description:Turn the function result into an integer tensor
Optional Parameters
- control_tagsAdds user-defined labels for accessing object parameters via control logic.
C++ Type:std::vector<std::string>
Controllable:No
Description:Adds user-defined labels for accessing object parameters via control logic.
- enableTrueSet the enabled status of the MooseObject.
Default:True
C++ Type:bool
Controllable:No
Description:Set the enabled status of the MooseObject.
Advanced Parameters
Input Files
- (test/tests/mechanics/mech.i)
- (test/tests/real_space/robin_steady_state.i)
- (test/tests/cahnhilliard/cahnhilliard_explicit_smooth.i)
- (test/tests/postprocessors/postprocessors.i)
- (examples/lbm/Rayleigh-Benard/rayleigh-benard.i)
- (examples/swift_hohenberg/swifthohenberg.i)
- (test/tests/anisotropic_grain_growth/analytic_hull.i)
- (examples/anisotropic_grain_growth/five_grains_2D.i)
- (test/tests/tensor_compute/parallel_roundtrip_3d.i)
- (test/tests/cahnhilliard/cahnhilliard_explicit.i)
- (test/tests/implicit_fd/crank_thin_slab.i)
- (benchmarks/02_oswald_ripening/simple.i)
- (test/tests/solvers/etdrk4_diffusion.i)
- (test/tests/implicit_fd/cutback.i)
- (test/tests/tensor_compute/backandforth.i)
- (benchmarks/01_spinodal_decomposition/1a_secant.i)
- (benchmarks/02_oswald_ripening/2a.i)
- (test/tests/parsed_tensor/local_vars_derivative.i)
- (test/tests/typed_tensors/gradient_vector.i)
- (examples/anisotropic_grain_growth/isotropic_five_grain.i)
- (test/tests/implicit_fd/bc_mms.i)
- (benchmarks/01_spinodal_decomposition/1a_implicit_fd.i)
- (test/tests/real_space/laplacian3d.i)
- (examples/lbm/Phase-field/droplet_impact.i)
- (test/tests/tensor_compute/rotating_grain_secant.i)
- (test/tests/real_space/semi_infinite_diffusion.i)
- (test/tests/kks/KKS_no_flux_bc.i)
- (test/tests/anisotropic_grain_growth/sigma3_circular_grain.i)
- (test/tests/implicit_fd/crank_semi_infinite.i)
- (examples/degeus_mechanics/mech.i)
- (test/tests/real_space/deep_ghost_faces.i)
- (test/tests/solvers/coupled.i)
- (examples/lbm/Phase-field/spinodal_decomposition.i)
- (examples/libtorch_kks/KKS_libtorch.i)
- (test/tests/typed_tensors/gradient.i)
- (test/tests/gradient/gradient.i)
- (benchmarks/01_spinodal_decomposition/1a.i)
- (test/tests/implicit_fd/be_mode3d.i)
- (test/tests/tensor_compute/parallel.i)
- (examples/cahn_hilliard/cahnhilliard4.i)
- (test/tests/solvers/diagonal.i)
- (test/tests/lbm/phase.i)
- (test/tests/implicit_fd/biharmonic_mode.i)
- (examples/lbm/Phase-field/static_bubble_3d.i)
- (examples/anisotropic_grain_growth/spherical_grain_Ni.i)
- (test/tests/postprocessors/interface_velocity.i)
- (test/tests/lbm/phase_3D.i)
- (test/tests/tensor_compute/parallel_roundtrip.i)
- (test/tests/real_space/diffusion.i)
- (test/tests/real_space/thin_slab_diffusion.i)
- (examples/lbm/Phase-field/layered_poiseuille.i)
- (test/tests/tensor_compute/coupled_pf_mech.i)
- (benchmarks/02_oswald_ripening/2a_secant.i)
- (examples/lbm/Phase-field/static_bubble.i)
- (test/tests/real_space/deep_ghost_periodic.i)
- (examples/swift_hohenberg/rotating_grain.i)
- (test/tests/cahnhilliard/cahnhilliard.i)
- (test/tests/implicit_fd/biharmonic_mode3d.i)
- (examples/cahn_hilliard/cahnhilliard.i)
- (benchmarks/01_spinodal_decomposition/1b.i)
- (examples/cahn_hilliard/cahnhilliard3.i)
- (test/tests/solvers/nl_coupled.i)
- (test/tests/real_space/neumann_linear.i)
- (test/tests/histogram/test.i)
- (test/tests/real_space/neumann_conservation.i)
- (test/tests/gradient/gradient_square.i)
- (test/tests/tensor_compute/test.i)
- (test/tests/kks/KKS_libtorch.i)
- (benchmarks/02_oswald_ripening/2a_broyden.i)
- (test/tests/implicit_fd/poisson_mms.i)
- (test/tests/real_space/laplacian.i)
- (test/tests/tensor_compute/coupled_pf_mech_secant.i)
- (test/tests/mechanics/mech3d.i)
- (examples/cahn_hilliard/cahnhilliard2.i)
- (test/tests/lbm/stacking.i)
- (test/tests/tensor_compute/group.i)
- (test/tests/implicit_fd/be_mode.i)
- (benchmarks/01_spinodal_decomposition/1a_solver.i)
expression
C++ Type:std::string
Controllable:No
Description:Parsed expression
inputs
C++ Type:std::vector<std::string>
Controllable:No
Description:Buffer names used in the expression
extra_symbols
Default:False
C++ Type:bool
Controllable:No
Description:Provide i (imaginary unit), kx,ky,kz (reciprocal space frequency), k2 (square of the k-vector), x,y,z (real space coordinates), time t, pi, and e.
(test/tests/gradient/gradient_square.i)
[Domain]
dim = 3
nx = 40
ny = 40
nz = 40
xmax = ${fparse pi*2}
ymax = ${fparse pi*4}
zmax = ${fparse pi*6}
mesh_mode = DUMMY
device_names = cpu
[]
[TensorBuffers]
[s]
[]
[grad_sq]
[]
[c2]
[]
[diff]
[]
[]
[TensorComputes]
[Initialize]
[sin]
type = ParsedCompute
buffer = s
extra_symbols = true
expression = 'sin(x)+sin(y)+sin(z)'
[]
[cos2]
type = ParsedCompute
buffer = c2
extra_symbols = true
expression = 'cos(x)^2+cos(y)^2+cos(z)^2'
[]
[grad_sq]
type = FFTGradientSquare
buffer = grad_sq
input = s
[]
[diff]
type = ParsedCompute
buffer = diff
inputs = 'grad_sq c2'
expression = 'abs(grad_sq - c2)'
[]
[]
[]
[Postprocessors]
[diff]
type = TensorIntegralPostprocessor
buffer = diff
[]
[]
[Problem]
type = TensorProblem
[]
[Executioner]
type = Transient
num_steps = 1
[]
[Outputs]
csv = true
[]
(test/tests/mechanics/mech.i)
[Domain]
dim = 2
nx = 32
ny = 32
xmax = ${fparse 2*pi}
ymax = ${fparse 2*pi}
zmax = ${fparse 2*pi}
mesh_mode = DUMMY
parallel_mode = FFT_AUTO
[]
[TensorComputes]
[Initialize]
[phase]
type = ParsedCompute
expression = '(cos(x)/2+0.5)^1*(cos(y)/2+0.5)^1*(cos(z)/2+0.5)^1'
extra_symbols = true
buffer = phase
[]
[K]
type = ParsedCompute
buffer = K
expression = '(1-phase)*Ka + phase*Kb'
inputs = phase
constant_names = 'Ka Kb'
constant_expressions = '1 10'
[]
[mu]
type = ParsedCompute
buffer = mu
expression = '(1-phase)*mua + phase*mub'
inputs = phase
constant_names = 'mua mub'
constant_expressions = '0.5 5'
[]
[Finit]
type = RankTwoIdentity
buffer = F
[]
[]
[Solve]
[hyper_elasticity]
type = HyperElasticIsotropic
buffer = stress
F = Fnew
K = K
mu = mu
[]
[root]
[applied_strain]
type = MacroscopicShearTensor
buffer = applied_strain
[]
[mech]
type = FFTMechanics
buffer = Fnew
F = F
K = K
mu = mu
l_max_its = 40
l_tol = 1e-5
nl_rel_tol = 2e-4
nl_abs_tol = 2e-3
constitutive_model = hyper_elasticity
stress = stress
applied_macroscopic_strain = applied_strain
[]
[]
[]
[Postprocess]
[displacements]
type = ComputeDisplacements
buffer = disp
F = F
[]
[vonmises]
type = ComputeVonMisesStress
buffer = sV
[]
[]
[]
[TensorSolver]
# no variables are integrated by this solver (FFTMechanics performs a steady state mechanics solve)
type = ForwardEulerSolver
root_compute = root
# deformation tensor is just forwarded Fnew -> F
forward_buffer = F
forward_buffer_new = Fnew
substeps = 3
[]
[TensorOutputs]
active = 'parallel' # serial
[serial]
type = XDMFTensorOutput
file_base = mech_serial
buffer = 'disp sV F phase'
output_mode = 'OVERSIZED_NODAL CELL CELL NODE'
enable_hdf5 = true
execute_on = 'TIMESTEP_END'
[]
[parallel]
# NODE and OVERSIZED_NODAL are not yet available in parallel output
type = XDMFTensorOutput
file_base = mech_parallel
buffer = 'sV F phase'
output_mode = 'CELL CELL CELL'
enable_hdf5 = true
execute_on = 'TIMESTEP_END'
[]
[]
[Executioner]
type = Transient
num_steps = 3
dt = 0.02
[]
(test/tests/real_space/robin_steady_state.i)
# Verification against an independent analytic solution: the steady 1D elliptic
# Robin-BC benchmark from OpenGeoSys's documentation,
# https://www.opengeosys.org/6.5.7/docs/benchmarks/elliptic/elliptic-robin/
# ("second benchmark": Dirichlet at x=0, Robin at x=1). The governing equation is
# k*Laplacian(h) = 0 on [0,1] with k=1, boundary conditions
# h(0) = g_D, dh/dn|_{x=1} = alpha*(h0 - h(1)),
# and exact linear solution
# h(x) = [alpha*(h0 - g_D)/(1 + alpha)] * x + g_D.
# TensorRobinBC's convention is a*u + b*du/dn = c; the OGS Robin condition
# du/dn = alpha*(h0 - u) rearranges to alpha*u + du/dn = alpha*h0, i.e.
# a = alpha, b = 1, c = alpha*h0.
#
# Uses alpha = +2 rather than OGS's alpha = -2: the ghost coefficient on u0,
# -(a/2 - b/dx)/(a/2 + b/dx), has magnitude > 1 for a < 0, so explicit relaxation to
# the steady state diverges (OGS solves the steady system directly). With alpha = 2,
# h0 = 1.5 and g_D = 1 the exact solution is h(x) = x/3 + 1.
#
# Y is periodic, and the IC matches neither the steady profile nor the BCs.
[Domain]
dim = 2
nx = 20
ny = 8
parallel_mode = REAL_SPACE
periodic_directions = 'Y'
xmin = 0
xmax = 1
ymin = -1
ymax = 1
[]
[Functions]
[u_ic_func]
type = ParsedFunction
expression = '0.5'
[]
[u_exact_func]
type = ParsedFunction
expression = '1 + x / 3'
[]
[]
[TensorComputes]
[Initialize]
[u_ic]
type = MooseFunctionTensor
buffer = u
function = u_ic_func
[]
[]
[BCs]
[left]
type = TensorDirichletBC
variable = u
boundary = left
value = 1
[]
[right]
# alpha*u + du/dn = alpha*h0, with alpha = 2, h0 = 1.5.
type = TensorRobinBC
variable = u
boundary = right
a = 2
b = 1
c = 3
[]
[]
[Solve]
[dt]
type = FiniteDifferenceLaplacian
input = u
buffer = dudt
[]
[u_exact]
type = MooseFunctionTensor
buffer = u_exact
function = u_exact_func
[]
[diff]
type = ParsedCompute
buffer = diff
expression = 'abs(u - u_exact)'
inputs = 'u u_exact'
[]
[]
[]
[TensorSolver]
type = RealSpaceForwardEuler
buffer = u
time_derivative = dudt
substeps = 1000
[]
[Postprocessors]
[max_error]
type = TensorExtremeValuePostprocessor
buffer = diff
value_type = MAX
execute_on = 'TIMESTEP_END'
[]
[]
[Executioner]
type = Transient
# same grid and CFL margin as dirichlet_linear.i
dt = 1
num_steps = 4
[]
[Outputs]
[out]
type = CSV
[]
[]
(test/tests/cahnhilliard/cahnhilliard_explicit_smooth.i)
#
# Simple Cahn-Hilliard solve on a 2D grid. We create a matching (conforming)
# MOOSE mesh (with one element per FFT grid cell) and project the solution onto
# the MOOSE mesh to utilize the exodus output object.
#
[Domain]
dim = 2
nx = 50
ny = 50
xmax = 3
ymax = 3
mesh_mode = DOMAIN
device_names = cpu
[]
[TensorBuffers]
[c]
map_to_aux_variable = c
[]
[cbar]
[]
[mu]
map_to_aux_variable = mu
[]
[]
[TensorComputes]
[Initialize]
[c]
# Random initial condition around a concentration of 1/2
type = RandomTensor
buffer = c
min = 0.44
max = 0.56
seed = 0
[]
[mu_init]
type = ConstantTensor
buffer = mu
[]
# precompute fixed factors for the solve
[Mbar]
type = ReciprocalLaplacianFactor
factor = 0.2 # Mobility
buffer = Mbar
[]
[Mkappabarbar]
type = ReciprocalLaplacianSquareFactor
factor = '${fparse 0.2 * 1e-4}' # M * kappa
buffer = Mkappabarbar
[]
[dc_dt_bar_IC]
type = ConstantReciprocalTensor
buffer = dc_dt_bar
[]
[smooth]
type = DeAliasingTensor
buffer = smooth
[]
[]
[Solve]
[cahn_hilliard]
[mu]
type = ParsedCompute
buffer = mu
expression = '0.1*c^2*(c-1)^2'
derivatives = c
inputs = c
[]
[mubar]
type = ForwardFFT
buffer = mubar
input = mu
[]
[dc_dt_bar]
type = ParsedCompute
buffer = dc_dt_bar
expression = 'smooth * (Mbar*mubar - Mkappabarbar*cbar)'
# expression = '(Mbar*mubar - Mkappabarbar*cbar)'
inputs = 'Mbar mubar Mkappabarbar cbar smooth'
[]
[cbar]
type = ForwardFFT
buffer = cbar
input = c
[]
[]
[]
[]
[TensorSolver]
type = ForwardEulerSolver
time_derivative_reciprocal = dc_dt_bar
root_compute = cahn_hilliard
buffer = c
reciprocal_buffer = cbar
substeps = 50
[]
[AuxVariables]
[mu]
# the mu tensor is projected onto this elemental variable
family = MONOMIAL
order = CONSTANT
[]
[c]
# the c tensor is projected onto this nodal variable
[]
[]
[Postprocessors]
[C]
type = TensorIntegralPostprocessor
buffer = c
[]
[]
[Problem]
type = TensorProblem
[]
[Executioner]
type = Transient
num_steps = 20
dt = 0.5
[]
[Outputs]
exodus = true
csv = true
[]
(test/tests/postprocessors/postprocessors.i)
[Domain]
dim = 2
nx = 40
ny = 40
xmax = 2
ymax = 3
mesh_mode = DUMMY
[]
[TensorBuffers]
[c]
[]
[c_bar]
[]
[]
[TensorComputes]
[Initialize]
[c]
type = ParsedCompute
buffer = c
extra_symbols = true
expression = -x+y+0.3
[]
[c_bar]
type = ForwardFFT
buffer = c_bar
input = c
[]
[u]
type = ConstantTensor
buffer = u
real = 0
[]
[]
[Solve]
[root]
[test]
type = ForwardFFT
buffer = u_bar
input = u
[]
[]
[]
[]
[TensorSolver]
type = ForwardEulerSolver
time_derivative_reciprocal = c_bar
buffer = u
reciprocal_buffer = u_bar
substeps = 10
[]
[Postprocessors]
[min_c]
type = TensorExtremeValuePostprocessor
buffer = c
value_type = MIN
execute_on = 'INITIAL TIMESTEP_END'
[]
[max_c]
type = TensorExtremeValuePostprocessor
buffer = c
value_type = MAX
execute_on = 'INITIAL TIMESTEP_END'
[]
[avg_c]
type = TensorAveragePostprocessor
buffer = c
execute_on = 'INITIAL TIMESTEP_END'
[]
[int_c]
type = TensorIntegralPostprocessor
buffer = c
execute_on = 'INITIAL TIMESTEP_END'
[]
[int_c_bar]
type = ReciprocalIntegral
buffer = c_bar
execute_on = 'INITIAL TIMESTEP_END'
[]
[count]
type = ComputeGroupExecutionCount
[]
[]
[Problem]
type = TensorProblem
[]
[Executioner]
type = Transient
num_steps = 0
[]
[Outputs]
csv = true
[]
(examples/lbm/Rayleigh-Benard/rayleigh-benard.i)
Nx = 400
Ny = 200
TH = 1.1
TC = 1.0
frequency = '${Nx}/10.0'
amplitude = '${Ny}/100.0'
[Domain]
dim = 2
nx = '${Nx}'
ny = '${Ny}'
xmax = '${Nx}'
ymax = '${Ny}'
device_names='cpu'
mesh_mode=DUMMY
parallel_mode = REAL_SPACE
periodic_directions = 'X Y'
[]
[Stencil]
[d2q9]
type = LBMD2Q9
[]
[]
!include buffers.i
[TensorComputes]
#### Initialzie ####
[Initialize]
[density]
type = LBMConstantTensor
buffer = density
constants = 'rho0'
[]
[velocity]
type = LBMConstantTensor
buffer = velocity
constants = '0.0 0.0'
[]
[temperature]
type = ParsedCompute
buffer = T
expression = 'a:=abs(y - sin(x / (${frequency} * pi)) * ${amplitude}) + y - sin(x / (${frequency} * pi)) * ${amplitude};
b:= a / (a + 1.0e-14);
${TC} * b - b *${TH} + ${TH}'
extra_symbols = true
[]
[equilibrium_fluid]
type = LBMEquilibrium
buffer = feq
bulk = density
velocity = velocity
[]
[equilibrium_fluid_total]
type = LBMEquilibrium
buffer = f
bulk = density
velocity = velocity
[]
[equilibrium_fluid_pc]
type = LBMEquilibrium
buffer = fpc
bulk = density
velocity = velocity
[]
[equilibrium_temperature]
type = LBMEquilibrium
buffer = geq
bulk = T
velocity = velocity
[]
[equilibrium_temperature_total]
type = LBMEquilibrium
buffer = g
bulk = T
velocity = velocity
[]
[equilibrium_temperature_pc]
type = LBMEquilibrium
buffer = gpc
bulk = T
velocity = velocity
[]
[]
!include solve.i
!include boundary.i
[]
[TensorSolver]
type = LBMStream
buffer = 'f g'
f_old = 'fpc gpc'
[]
[TensorOutputs]
[xdmf]
type = XDMFTensorOutput
buffer = 'T velocity density'
output_mode = 'Cell Cell Cell'
enable_hdf5 = true
[]
[]
[Problem]
type = LatticeBoltzmannProblem
scalar_constant_names = 'rho0 T_0 T_C T_H tau_f tau_T g'
scalar_constant_values = '1.0 1.05 1.0 1.1 0.7 0.7 0.0001'
substeps = 100
print_debug_output = true
residual_tensor = speed
[]
[Executioner]
type = Transient
num_steps = 10000
[]
(examples/swift_hohenberg/swifthohenberg.i)
#
# Solve a simple Swift-Hohenberg crystal phase field problem. The initial condition is
# a random melt, which crystalizes out.
#
[Domain]
dim = 2
nx = 400
ny = 400
xmax = ${fparse pi*2*30}
ymax = ${fparse pi*2*30}
device_names = 'cuda'
mesh_mode = DOMAIN
[]
[TensorBuffers]
[psi]
map_to_aux_variable = psi
[]
[psibar]
[]
[psi3]
[]
[psi3bar]
[]
# constant tensors
[linear]
[]
# output
[filter]
map_to_aux_variable = filter
[]
[filterbar]
[]
[]
[AuxVariables]
[psi]
[]
[filter]
[]
[]
[TensorComputes]
[Initialize]
[psi]
type = RandomTensor
buffer = psi
min = 0
max = 0.07
[]
[linear]
type = SwiftHohenbergLinear
buffer = linear
alpha = 1
r = 0.025
[]
[]
[Solve]
[psi3]
type = ParsedCompute
buffer = psi3
expression = "0.20*psi^2-psi^3"
inputs = psi
[]
[psibar]
type = ForwardFFT
buffer = psibar
input = psi
[]
[psi3bar]
type = ForwardFFT
buffer = psi3bar
input = psi3
[]
[]
[Postprocess]
[low_pass]
type = ParsedCompute
buffer = filterbar
extra_symbols = true
expression = 'psibar * exp(-k2*10)'
inputs = psibar
[]
[filter]
type = InverseFFT
buffer = filter
input = filterbar
[]
[]
[]
[TensorTimeIntegrators]
[c]
type = FFTSemiImplicit
buffer = psi
reciprocal_buffer = psibar
linear_reciprocal = linear
nonlinear_reciprocal = psi3bar
[]
[]
[Problem]
type = TensorProblem
spectral_solve_substeps = 1000
[]
[Executioner]
type = Transient
num_steps = 300
[TimeStepper]
type = IterationAdaptiveDT
growth_factor = 1.2
dt = 10
[]
dtmax = 1000
[]
[Postprocessors]
[min_psi]
type = TensorExtremeValuePostprocessor
buffer = psi
value_type = MIN
execute_on = 'TIMESTEP_END'
[]
[max_psi]
type = TensorExtremeValuePostprocessor
buffer = psi
value_type = MAX
execute_on = 'TIMESTEP_END'
[]
[Psi]
type = TensorIntegralPostprocessor
buffer = psi
[]
[]
[TensorOutputs]
[xdmf]
type = XDMFTensorOutput
buffer = 'psi'
output_mode = 'Node'
enable_hdf5 = true
[]
[]
[Outputs]
exodus = true
perf_graph = true
execute_on = 'TIMESTEP_END'
[]
(test/tests/anisotropic_grain_growth/analytic_hull.i)
interface_width = 0.8
r0 = 4
gbe_max = ${units 0.8 J/m^2}
kappa = ${fparse 0.75 * gbe_max * interface_width}
L = 1
g_eta_expr = '(eta^2*(1-eta^2)^2)'
[Domain]
dim = 2
nx = 32
ny = 32
xmax = 16
ymax = 16
mesh_mode = DUMMY
floating_precision = SINGLE
[]
[TensorComputes]
[Initialize]
[eta]
type = ParsedCompute
buffer = 'eta'
extra_symbols = 'true'
expression = 'radius:=sqrt((x-${Domain/xmax}/2)^2+(y-${Domain/ymax}/2)^2);0.5 - 0.5*tanh(2*(radius-${r0})/${interface_width})'
[]
[kappa_linear_term]
type = ReciprocalLaplacianFactor
buffer = kappa_linear_term
factor = ${fparse ${L} * ${kappa}}
[]
[smooth]
type = DeAliasingTensor
method = HOULI
buffer = smooth
[]
[]
[Solve]
[grad_eta_vector]
type = GradientVector
buffer = grad_eta
input = eta
[]
[gb_energy]
type = AnisotropicGBEnergy
buffer = gb_energy
gb_gradient_buffer = grad_eta
dsigma_dn = dsigma_dn
libtorch_model_file = 'marlin:anisotropic_gb_energy/analytic_sigma.pt'
interface_width = ${interface_width}
chunk_size = 256
[]
[bulk_driving_force]
type = ParsedCompute
buffer = 'bulk_driving_force'
expression = '6 * gb_energy * ${g_eta_expr} / ${interface_width}'
inputs = 'mu eta gb_energy'
derivatives = 'eta'
[]
[dmu_dn]
type = ParsedCompute
buffer = 'dmu_dn'
expression = '6 * dsigma_dn / ${interface_width}'
inputs = 'dsigma_dn'
[]
[g]
type = ParsedCompute
buffer = 'g'
expression = '${g_eta_expr}'
inputs = 'eta'
[]
[anisotropy_torque]
type = AnisotropyTorque
buffer = anisotropy_torque
dmu_dn = dmu_dn
g = g
[]
[total_mu_driving_force]
type = ParsedCompute
buffer = 'total_mu_driving_force'
expression = '-${L}*(bulk_driving_force - anisotropy_torque)'
inputs = 'bulk_driving_force anisotropy_torque'
[]
[nonlinear]
type = ForwardFFT
buffer = 'NL'
input = 'total_mu_driving_force'
[]
[smooth_nonlinear]
type = ParsedCompute
buffer = 'smooth_NL'
expression = 'smooth * NL'
inputs = 'smooth NL'
[]
[etabar]
type = ForwardFFT
buffer = etabar
input = eta
[]
[gradient_energy]
type = GradientEnergyDensity
buffer = gradient_energy
gradient_buffers = 'grad_eta'
kappa = ${kappa}
[]
[interface_energy]
type = ParsedCompute
buffer = interface_energy
expression = 'g * 6 * gb_energy / ${interface_width} + gradient_energy'
inputs = 'g gb_energy gradient_energy'
[]
[]
[]
[TensorSolver]
type = AdamsBashforthMoulton
buffer = 'eta'
reciprocal_buffer = 'etabar'
linear_reciprocal = 'kappa_linear_term'
nonlinear_reciprocal = 'smooth_NL'
substeps = 1e2
predictor_order = 1
corrector_order = 1
corrector_steps = 1
[]
[Postprocessors]
[total_gb_energy]
type = TensorIntegralPostprocessor
buffer = interface_energy
[]
[]
[TensorOutputs]
active = ''
[xdmf]
type = XDMFTensorOutput
buffer = 'eta gb_energy'
output_mode = 'NODE NODE'
enable_hdf5 = true
transpose = false
[]
[]
[Executioner]
type = Transient
dt = 0.1
num_steps = 2
[]
[Outputs]
csv = true
execute_on = 'INITIAL TIMESTEP_END'
[]
(examples/anisotropic_grain_growth/five_grains_2D.i)
interface_width = 1.6
side = 80
gbe_max = '${units 1.24 J/m^2}'
L = '${fparse 1.0 * 1.6 / ${interface_width} }'
# ------------------------------------------------------------------
# Periodic Voronoi-like IC for 5 grains.
#
# Each grain is seeded at a point (xi, yi). We use a smooth *periodic*
# distance metric based on sine functions,
# d_i^2 = (side/pi)^2 * [ sin(pi*(x-xi)/side)^2 + sin(pi*(y-yi)/side)^2 ]
# which reduces to the Euclidean distance near the seed and wraps
# correctly across the periodic boundaries.
#
# The order parameters are then a softmax over the negative distances,
# gr_i = exp(-a*d_i) / sum_j exp(-a*d_j), a = 4/interface_width
# For any two competing grains this reduces exactly to the usual
# 0.5*(1 - tanh(2*(d_i - d_j)/interface_width)) profile, so the
# interfaces come out with the correct width, the partition of unity
# sum_i gr_i = 1 holds identically, and the cell structure is the
# (diffuse) Voronoi tessellation of the seeds under the periodic metric.
# ------------------------------------------------------------------
aexp = '${fparse 4.0 / ${interface_width} }'
lp = '${fparse ${side} / pi }'
kp = '${fparse pi / ${side} }'
# seed points (spread out over the periodic 40x40 domain)
d0 = 'sqrt((${lp}*sin(${kp}*(x-8)))^2 + (${lp}*sin(${kp}*(y-6)))^2)'
d1 = 'sqrt((${lp}*sin(${kp}*(x-28)))^2 + (${lp}*sin(${kp}*(y-10)))^2)'
d2 = 'sqrt((${lp}*sin(${kp}*(x-20)))^2 + (${lp}*sin(${kp}*(y-24)))^2)'
d3 = 'sqrt((${lp}*sin(${kp}*(x-4)))^2 + (${lp}*sin(${kp}*(y-28)))^2)'
d4 = 'sqrt((${lp}*sin(${kp}*(x-34)))^2 + (${lp}*sin(${kp}*(y-33)))^2)'
g_gamma0 = '${fparse sqrt(2) / 3 }' # g(gamma=1.5)
f0_gamma0 = ${fparse 1/8}
kappa = '${fparse gbe_max * interface_width * sqrt(f0_gamma0) / g_gamma0 }'
mu = '${fparse gbe_max / (g_gamma0 * interface_width * sqrt(f0_gamma0) ) }'
g_to_gamma_func = '(1.0/(-3.0944 * g^8 -1.8169*g^6 + 10.323 * g^4 - 8.1819*g^2 + 2.0033))'
dgamma_dsigma = '(g * (24.7552*g^6 + 10.9014*g^4 - 41.292*g^2 + 16.3638) / (-3.0944*g^8 - 1.8169*g^6 + 10.323*g^4 - 8.1819*g^2 + 2.0033)^2 / sqrt(${kappa} * ${mu}) )'
f0 = '((gr0^4/4 - gr0^2/2) + (gr1^4/4 - gr1^2/2) + (gr2^4/4 - gr2^2/2) + (gr3^4/4 - gr3^2/2) + (gr4^4/4 - gr4^2/2) + gamma_01*gr0^2*gr1^2 + gamma_02*gr0^2*gr2^2 + gamma_03*gr0^2*gr3^2 + gamma_04*gr0^2*gr4^2 + gamma_12*gr1^2*gr2^2 + gamma_13*gr1^2*gr3^2 + gamma_14*gr1^2*gr4^2 + gamma_23*gr2^2*gr3^2 + gamma_24*gr2^2*gr4^2 + gamma_34*gr3^2*gr4^2 + 0.25)'
[Domain]
dim = 2
nx = 200
ny = 200
xmax = ${side}
ymax = ${side}
mesh_mode = DUMMY
[]
[TensorComputes]
[Initialize]
# unnormalized softmax weights
[c0]
type = ParsedCompute
buffer = c0
expression = 'exp(-${aexp}*${d0})'
extra_symbols = true
[]
[c1]
type = ParsedCompute
buffer = c1
expression = 'exp(-${aexp}*${d1})'
extra_symbols = true
[]
[c2]
type = ParsedCompute
buffer = c2
expression = 'exp(-${aexp}*${d2})'
extra_symbols = true
[]
[c3]
type = ParsedCompute
buffer = c3
expression = 'exp(-${aexp}*${d3})'
extra_symbols = true
[]
[c4]
type = ParsedCompute
buffer = c4
expression = 'exp(-${aexp}*${d4})'
extra_symbols = true
[]
# normalized order parameters (partition of unity by construction)
[gr0]
type = ParsedCompute
buffer = gr0
expression = 'c0/(c0+c1+c2+c3+c4)'
inputs = 'c0 c1 c2 c3 c4'
[]
[gr1]
type = ParsedCompute
buffer = gr1
expression = 'c1/(c0+c1+c2+c3+c4)'
inputs = 'c0 c1 c2 c3 c4'
[]
[gr2]
type = ParsedCompute
buffer = gr2
expression = 'c2/(c0+c1+c2+c3+c4)'
inputs = 'c0 c1 c2 c3 c4'
[]
[gr3]
type = ParsedCompute
buffer = gr3
expression = 'c3/(c0+c1+c2+c3+c4)'
inputs = 'c0 c1 c2 c3 c4'
[]
[gr4]
type = ParsedCompute
buffer = gr4
expression = '1 - gr0 - gr1 - gr2 - gr3'
inputs = 'gr0 gr1 gr2 gr3'
[]
[L_kappa_laplacian]
type = ReciprocalLaplacianFactor
buffer = 'L_kappa_laplacian'
factor = '${fparse ${L} * ${kappa}}'
[]
[kappa_laplacian]
type = ReciprocalLaplacianFactor
buffer = kappa_laplacian
factor = '${kappa}'
[]
[smooth]
type = DeAliasingTensor
method = HOULI
buffer = smooth
[]
[]
[Solve]
[bnds]
type = ParsedCompute
buffer = 'bnds'
inputs = 'gr0 gr1 gr2 gr3 gr4'
expression = 'gr0^2 + gr1^2 + gr2^2 + gr3^2 + gr4^2'
[]
## FFT
[gr0_bar]
type = ForwardFFT
buffer = gr0_bar
input = gr0
[]
[gr1_bar]
type = ForwardFFT
buffer = gr1_bar
input = gr1
[]
[gr2_bar]
type = ForwardFFT
buffer = gr2_bar
input = gr2
[]
[gr3_bar]
type = ForwardFFT
buffer = gr3_bar
input = gr3
[]
[gr4_bar]
type = ForwardFFT
buffer = gr4_bar
input = gr4
[]
[grad_gr0]
type = GradientVector
buffer = grad_gr0
input = gr0
[]
[grad_gr1]
type = GradientVector
buffer = grad_gr1
input = gr1
[]
[grad_gr2]
type = GradientVector
buffer = grad_gr2
input = gr2
[]
[grad_gr3]
type = GradientVector
buffer = grad_gr3
input = gr3
[]
[grad_gr4]
type = GradientVector
buffer = grad_gr4
input = gr4
[]
## Pairwise anisotropic GB energies (10 pairs)
# NOTE: the per-pair libtorch misorientation models (Ri_Rj.pt) will be
# developed separately; placeholder file names below follow the
# existing convention and location.
[sigma_gr0_gr1]
type = PairwiseAnisotropicGBEnergy
buffer = 'sigma_gr0_gr1'
dsigma_dgrad_grain1 = 'dsigma_gr0_gr1_dgrad_gr0'
dsigma_dgrad_grain2 = 'dsigma_gr0_gr1_dgrad_gr1'
grad_grain1_buffer = 'grad_gr0'
grad_grain2_buffer = 'grad_gr1'
interface_width = '${interface_width}'
libtorch_model_file = 'marlin:anisotropic_gb_energy/Ni_R1_R2.pt'
chunk_size = 1e5
[]
[sigma_gr0_gr2]
type = PairwiseAnisotropicGBEnergy
buffer = 'sigma_gr0_gr2'
dsigma_dgrad_grain1 = 'dsigma_gr0_gr2_dgrad_gr0'
dsigma_dgrad_grain2 = 'dsigma_gr0_gr2_dgrad_gr2'
grad_grain1_buffer = 'grad_gr0'
grad_grain2_buffer = 'grad_gr2'
interface_width = '${interface_width}'
libtorch_model_file = 'marlin:anisotropic_gb_energy/Ni_R1_R3.pt'
chunk_size = 1e5
[]
[sigma_gr0_gr3]
type = PairwiseAnisotropicGBEnergy
buffer = 'sigma_gr0_gr3'
dsigma_dgrad_grain1 = 'dsigma_gr0_gr3_dgrad_gr0'
dsigma_dgrad_grain2 = 'dsigma_gr0_gr3_dgrad_gr3'
grad_grain1_buffer = 'grad_gr0'
grad_grain2_buffer = 'grad_gr3'
interface_width = '${interface_width}'
libtorch_model_file = 'marlin:anisotropic_gb_energy/Ni_R1_R4.pt'
chunk_size = 1e5
[]
[sigma_gr0_gr4]
type = PairwiseAnisotropicGBEnergy
buffer = 'sigma_gr0_gr4'
dsigma_dgrad_grain1 = 'dsigma_gr0_gr4_dgrad_gr0'
dsigma_dgrad_grain2 = 'dsigma_gr0_gr4_dgrad_gr4'
grad_grain1_buffer = 'grad_gr0'
grad_grain2_buffer = 'grad_gr4'
interface_width = '${interface_width}'
libtorch_model_file = 'marlin:anisotropic_gb_energy/Ni_R1_R5.pt'
chunk_size = 1e5
[]
[sigma_gr1_gr2]
type = PairwiseAnisotropicGBEnergy
buffer = 'sigma_gr1_gr2'
dsigma_dgrad_grain1 = 'dsigma_gr1_gr2_dgrad_gr1'
dsigma_dgrad_grain2 = 'dsigma_gr1_gr2_dgrad_gr2'
grad_grain1_buffer = 'grad_gr1'
grad_grain2_buffer = 'grad_gr2'
interface_width = '${interface_width}'
libtorch_model_file = 'marlin:anisotropic_gb_energy/Ni_R2_R3.pt'
chunk_size = 1e5
[]
[sigma_gr1_gr3]
type = PairwiseAnisotropicGBEnergy
buffer = 'sigma_gr1_gr3'
dsigma_dgrad_grain1 = 'dsigma_gr1_gr3_dgrad_gr1'
dsigma_dgrad_grain2 = 'dsigma_gr1_gr3_dgrad_gr3'
grad_grain1_buffer = 'grad_gr1'
grad_grain2_buffer = 'grad_gr3'
interface_width = '${interface_width}'
libtorch_model_file = 'marlin:anisotropic_gb_energy/Ni_R2_R4.pt'
chunk_size = 1e5
[]
[sigma_gr1_gr4]
type = PairwiseAnisotropicGBEnergy
buffer = 'sigma_gr1_gr4'
dsigma_dgrad_grain1 = 'dsigma_gr1_gr4_dgrad_gr1'
dsigma_dgrad_grain2 = 'dsigma_gr1_gr4_dgrad_gr4'
grad_grain1_buffer = 'grad_gr1'
grad_grain2_buffer = 'grad_gr4'
interface_width = '${interface_width}'
libtorch_model_file = 'marlin:anisotropic_gb_energy/Ni_R2_R5.pt'
chunk_size = 1e5
[]
[sigma_gr2_gr3]
type = PairwiseAnisotropicGBEnergy
buffer = 'sigma_gr2_gr3'
dsigma_dgrad_grain1 = 'dsigma_gr2_gr3_dgrad_gr2'
dsigma_dgrad_grain2 = 'dsigma_gr2_gr3_dgrad_gr3'
grad_grain1_buffer = 'grad_gr2'
grad_grain2_buffer = 'grad_gr3'
interface_width = '${interface_width}'
libtorch_model_file = 'marlin:anisotropic_gb_energy/Ni_R3_R4.pt'
chunk_size = 1e5
[]
[sigma_gr2_gr4]
type = PairwiseAnisotropicGBEnergy
buffer = 'sigma_gr2_gr4'
dsigma_dgrad_grain1 = 'dsigma_gr2_gr4_dgrad_gr2'
dsigma_dgrad_grain2 = 'dsigma_gr2_gr4_dgrad_gr4'
grad_grain1_buffer = 'grad_gr2'
grad_grain2_buffer = 'grad_gr4'
interface_width = '${interface_width}'
libtorch_model_file = 'marlin:anisotropic_gb_energy/Ni_R3_R5.pt'
chunk_size = 1e5
[]
[sigma_gr3_gr4]
type = PairwiseAnisotropicGBEnergy
buffer = 'sigma_gr3_gr4'
dsigma_dgrad_grain1 = 'dsigma_gr3_gr4_dgrad_gr3'
dsigma_dgrad_grain2 = 'dsigma_gr3_gr4_dgrad_gr4'
grad_grain1_buffer = 'grad_gr3'
grad_grain2_buffer = 'grad_gr4'
interface_width = '${interface_width}'
libtorch_model_file = 'marlin:anisotropic_gb_energy/Ni_R4_R5.pt'
chunk_size = 1e5
[]
## gamma_ij(sigma_ij)
[gamma_01]
type = ParsedCompute
buffer = 'gamma_01'
expression = 'g:=sigma_gr0_gr1/sqrt(${kappa}*${mu});${g_to_gamma_func}'
inputs = 'sigma_gr0_gr1'
[]
[gamma_02]
type = ParsedCompute
buffer = 'gamma_02'
expression = 'g:=sigma_gr0_gr2/sqrt(${kappa}*${mu});${g_to_gamma_func}'
inputs = 'sigma_gr0_gr2'
[]
[gamma_03]
type = ParsedCompute
buffer = 'gamma_03'
expression = 'g:=sigma_gr0_gr3/sqrt(${kappa}*${mu});${g_to_gamma_func}'
inputs = 'sigma_gr0_gr3'
[]
[gamma_04]
type = ParsedCompute
buffer = 'gamma_04'
expression = 'g:=sigma_gr0_gr4/sqrt(${kappa}*${mu});${g_to_gamma_func}'
inputs = 'sigma_gr0_gr4'
[]
[gamma_12]
type = ParsedCompute
buffer = 'gamma_12'
expression = 'g:=sigma_gr1_gr2/sqrt(${kappa}*${mu});${g_to_gamma_func}'
inputs = 'sigma_gr1_gr2'
[]
[gamma_13]
type = ParsedCompute
buffer = 'gamma_13'
expression = 'g:=sigma_gr1_gr3/sqrt(${kappa}*${mu});${g_to_gamma_func}'
inputs = 'sigma_gr1_gr3'
[]
[gamma_14]
type = ParsedCompute
buffer = 'gamma_14'
expression = 'g:=sigma_gr1_gr4/sqrt(${kappa}*${mu});${g_to_gamma_func}'
inputs = 'sigma_gr1_gr4'
[]
[gamma_23]
type = ParsedCompute
buffer = 'gamma_23'
expression = 'g:=sigma_gr2_gr3/sqrt(${kappa}*${mu});${g_to_gamma_func}'
inputs = 'sigma_gr2_gr3'
[]
[gamma_24]
type = ParsedCompute
buffer = 'gamma_24'
expression = 'g:=sigma_gr2_gr4/sqrt(${kappa}*${mu});${g_to_gamma_func}'
inputs = 'sigma_gr2_gr4'
[]
[gamma_34]
type = ParsedCompute
buffer = 'gamma_34'
expression = 'g:=sigma_gr3_gr4/sqrt(${kappa}*${mu});${g_to_gamma_func}'
inputs = 'sigma_gr3_gr4'
[]
## torque prefactors dgamma/dsigma * gr_i^2 * gr_j^2
[coeff_01]
type = ParsedCompute
buffer = 'coeff_01'
expression = 'g:=sigma_gr0_gr1/sqrt(${kappa}*${mu});${dgamma_dsigma} * gr0^2 *gr1^2'
inputs = 'sigma_gr0_gr1 gr0 gr1'
[]
[coeff_02]
type = ParsedCompute
buffer = 'coeff_02'
expression = 'g:=sigma_gr0_gr2/sqrt(${kappa}*${mu});${dgamma_dsigma} * gr0^2 *gr2^2'
inputs = 'sigma_gr0_gr2 gr0 gr2'
[]
[coeff_03]
type = ParsedCompute
buffer = 'coeff_03'
expression = 'g:=sigma_gr0_gr3/sqrt(${kappa}*${mu});${dgamma_dsigma} * gr0^2 *gr3^2'
inputs = 'sigma_gr0_gr3 gr0 gr3'
[]
[coeff_04]
type = ParsedCompute
buffer = 'coeff_04'
expression = 'g:=sigma_gr0_gr4/sqrt(${kappa}*${mu});${dgamma_dsigma} * gr0^2 *gr4^2'
inputs = 'sigma_gr0_gr4 gr0 gr4'
[]
[coeff_12]
type = ParsedCompute
buffer = 'coeff_12'
expression = 'g:=sigma_gr1_gr2/sqrt(${kappa}*${mu});${dgamma_dsigma} * gr1^2 *gr2^2'
inputs = 'sigma_gr1_gr2 gr1 gr2'
[]
[coeff_13]
type = ParsedCompute
buffer = 'coeff_13'
expression = 'g:=sigma_gr1_gr3/sqrt(${kappa}*${mu});${dgamma_dsigma} * gr1^2 *gr3^2'
inputs = 'sigma_gr1_gr3 gr1 gr3'
[]
[coeff_14]
type = ParsedCompute
buffer = 'coeff_14'
expression = 'g:=sigma_gr1_gr4/sqrt(${kappa}*${mu});${dgamma_dsigma} * gr1^2 *gr4^2'
inputs = 'sigma_gr1_gr4 gr1 gr4'
[]
[coeff_23]
type = ParsedCompute
buffer = 'coeff_23'
expression = 'g:=sigma_gr2_gr3/sqrt(${kappa}*${mu});${dgamma_dsigma} * gr2^2 *gr3^2'
inputs = 'sigma_gr2_gr3 gr2 gr3'
[]
[coeff_24]
type = ParsedCompute
buffer = 'coeff_24'
expression = 'g:=sigma_gr2_gr4/sqrt(${kappa}*${mu});${dgamma_dsigma} * gr2^2 *gr4^2'
inputs = 'sigma_gr2_gr4 gr2 gr4'
[]
[coeff_34]
type = ParsedCompute
buffer = 'coeff_34'
expression = 'g:=sigma_gr3_gr4/sqrt(${kappa}*${mu});${dgamma_dsigma} * gr3^2 *gr4^2'
inputs = 'sigma_gr3_gr4 gr3 gr4'
[]
## anisotropy torques (2 per pair)
[torque_01_gr0]
type = AnisotropyTorque
buffer = torque_01_gr0
dmu_dn = dsigma_gr0_gr1_dgrad_gr0
g = 'coeff_01'
[]
[torque_01_gr1]
type = AnisotropyTorque
buffer = torque_01_gr1
dmu_dn = dsigma_gr0_gr1_dgrad_gr1
g = 'coeff_01'
[]
[torque_02_gr0]
type = AnisotropyTorque
buffer = torque_02_gr0
dmu_dn = dsigma_gr0_gr2_dgrad_gr0
g = 'coeff_02'
[]
[torque_02_gr2]
type = AnisotropyTorque
buffer = torque_02_gr2
dmu_dn = dsigma_gr0_gr2_dgrad_gr2
g = 'coeff_02'
[]
[torque_03_gr0]
type = AnisotropyTorque
buffer = torque_03_gr0
dmu_dn = dsigma_gr0_gr3_dgrad_gr0
g = 'coeff_03'
[]
[torque_03_gr3]
type = AnisotropyTorque
buffer = torque_03_gr3
dmu_dn = dsigma_gr0_gr3_dgrad_gr3
g = 'coeff_03'
[]
[torque_04_gr0]
type = AnisotropyTorque
buffer = torque_04_gr0
dmu_dn = dsigma_gr0_gr4_dgrad_gr0
g = 'coeff_04'
[]
[torque_04_gr4]
type = AnisotropyTorque
buffer = torque_04_gr4
dmu_dn = dsigma_gr0_gr4_dgrad_gr4
g = 'coeff_04'
[]
[torque_12_gr1]
type = AnisotropyTorque
buffer = torque_12_gr1
dmu_dn = dsigma_gr1_gr2_dgrad_gr1
g = 'coeff_12'
[]
[torque_12_gr2]
type = AnisotropyTorque
buffer = torque_12_gr2
dmu_dn = dsigma_gr1_gr2_dgrad_gr2
g = 'coeff_12'
[]
[torque_13_gr1]
type = AnisotropyTorque
buffer = torque_13_gr1
dmu_dn = dsigma_gr1_gr3_dgrad_gr1
g = 'coeff_13'
[]
[torque_13_gr3]
type = AnisotropyTorque
buffer = torque_13_gr3
dmu_dn = dsigma_gr1_gr3_dgrad_gr3
g = 'coeff_13'
[]
[torque_14_gr1]
type = AnisotropyTorque
buffer = torque_14_gr1
dmu_dn = dsigma_gr1_gr4_dgrad_gr1
g = 'coeff_14'
[]
[torque_14_gr4]
type = AnisotropyTorque
buffer = torque_14_gr4
dmu_dn = dsigma_gr1_gr4_dgrad_gr4
g = 'coeff_14'
[]
[torque_23_gr2]
type = AnisotropyTorque
buffer = torque_23_gr2
dmu_dn = dsigma_gr2_gr3_dgrad_gr2
g = 'coeff_23'
[]
[torque_23_gr3]
type = AnisotropyTorque
buffer = torque_23_gr3
dmu_dn = dsigma_gr2_gr3_dgrad_gr3
g = 'coeff_23'
[]
[torque_24_gr2]
type = AnisotropyTorque
buffer = torque_24_gr2
dmu_dn = dsigma_gr2_gr4_dgrad_gr2
g = 'coeff_24'
[]
[torque_24_gr4]
type = AnisotropyTorque
buffer = torque_24_gr4
dmu_dn = dsigma_gr2_gr4_dgrad_gr4
g = 'coeff_24'
[]
[torque_34_gr3]
type = AnisotropyTorque
buffer = torque_34_gr3
dmu_dn = dsigma_gr3_gr4_dgrad_gr3
g = 'coeff_34'
[]
[torque_34_gr4]
type = AnisotropyTorque
buffer = torque_34_gr4
dmu_dn = dsigma_gr3_gr4_dgrad_gr4
g = 'coeff_34'
[]
## interpolated local GB energy and nonlinear mobility
[sigma]
type = ParsedCompute
buffer = 'sigma'
expression = '(gr0^2*gr1^2*sigma_gr0_gr1 + gr0^2*gr2^2*sigma_gr0_gr2 + gr0^2*gr3^2*sigma_gr0_gr3 + gr0^2*gr4^2*sigma_gr0_gr4 + gr1^2*gr2^2*sigma_gr1_gr2 + gr1^2*gr3^2*sigma_gr1_gr3 + gr1^2*gr4^2*sigma_gr1_gr4 + gr2^2*gr3^2*sigma_gr2_gr3 + gr2^2*gr4^2*sigma_gr2_gr4 + gr3^2*gr4^2*sigma_gr3_gr4)/(gr0^2*gr1^2 + gr0^2*gr2^2 + gr0^2*gr3^2 + gr0^2*gr4^2 + gr1^2*gr2^2 + gr1^2*gr3^2 + gr1^2*gr4^2 + gr2^2*gr3^2 + gr2^2*gr4^2 + gr3^2*gr4^2 + 1e-4)'
inputs = 'sigma_gr0_gr1 sigma_gr0_gr2 sigma_gr0_gr3 sigma_gr0_gr4 sigma_gr1_gr2 sigma_gr1_gr3 sigma_gr1_gr4 sigma_gr2_gr3 sigma_gr2_gr4 sigma_gr3_gr4 gr0 gr1 gr2 gr3 gr4'
[]
[L_NL]
type = ParsedCompute
buffer = 'L_NL'
expression = '${L} * sigma / ${gbe_max}'
inputs = 'sigma'
[]
## kappa * laplacian(gr_i) in real space (for the mobility-split correction)
[kappa_laplacian_gr0_hat]
type = ParsedCompute
buffer = kappa_laplacian_gr0_hat
inputs = 'gr0_bar kappa_laplacian'
expression = 'gr0_bar * kappa_laplacian'
[]
[kappa_laplacian_gr1_hat]
type = ParsedCompute
buffer = kappa_laplacian_gr1_hat
inputs = 'gr1_bar kappa_laplacian'
expression = 'gr1_bar * kappa_laplacian'
[]
[kappa_laplacian_gr2_hat]
type = ParsedCompute
buffer = kappa_laplacian_gr2_hat
inputs = 'gr2_bar kappa_laplacian'
expression = 'gr2_bar * kappa_laplacian'
[]
[kappa_laplacian_gr3_hat]
type = ParsedCompute
buffer = kappa_laplacian_gr3_hat
inputs = 'gr3_bar kappa_laplacian'
expression = 'gr3_bar * kappa_laplacian'
[]
[kappa_laplacian_gr4_hat]
type = ParsedCompute
buffer = kappa_laplacian_gr4_hat
inputs = 'gr4_bar kappa_laplacian'
expression = 'gr4_bar * kappa_laplacian'
[]
[kappa_laplacian_gr0]
type = InverseFFT
buffer = kappa_laplacian_gr0
input = kappa_laplacian_gr0_hat
[]
[kappa_laplacian_gr1]
type = InverseFFT
buffer = kappa_laplacian_gr1
input = kappa_laplacian_gr1_hat
[]
[kappa_laplacian_gr2]
type = InverseFFT
buffer = kappa_laplacian_gr2
input = kappa_laplacian_gr2_hat
[]
[kappa_laplacian_gr3]
type = InverseFFT
buffer = kappa_laplacian_gr3
input = kappa_laplacian_gr3_hat
[]
[kappa_laplacian_gr4]
type = InverseFFT
buffer = kappa_laplacian_gr4
input = kappa_laplacian_gr4_hat
[]
## bulk driving forces
[gr0_bulk_term]
type = ParsedCompute
buffer = 'gr0_bulk_term'
expression = '-L_NL*${mu} * (gr0^3 - gr0 + 2*gr0*(gamma_01*gr1^2 + gamma_02*gr2^2 + gamma_03*gr3^2 + gamma_04*gr4^2) - torque_01_gr0 - torque_02_gr0 - torque_03_gr0 - torque_04_gr0) + (L_NL - ${L}) * kappa_laplacian_gr0'
inputs = 'gr0 gr1 gr2 gr3 gr4 gamma_01 gamma_02 gamma_03 gamma_04 torque_01_gr0 torque_02_gr0 torque_03_gr0 torque_04_gr0 L_NL kappa_laplacian_gr0'
[]
[gr1_bulk_term]
type = ParsedCompute
buffer = 'gr1_bulk_term'
expression = '-L_NL*${mu} * (gr1^3 - gr1 + 2*gr1*(gamma_01*gr0^2 + gamma_12*gr2^2 + gamma_13*gr3^2 + gamma_14*gr4^2) - torque_01_gr1 - torque_12_gr1 - torque_13_gr1 - torque_14_gr1) + (L_NL - ${L}) * kappa_laplacian_gr1'
inputs = 'gr0 gr1 gr2 gr3 gr4 gamma_01 gamma_12 gamma_13 gamma_14 torque_01_gr1 torque_12_gr1 torque_13_gr1 torque_14_gr1 L_NL kappa_laplacian_gr1'
[]
[gr2_bulk_term]
type = ParsedCompute
buffer = 'gr2_bulk_term'
expression = '-L_NL*${mu} * (gr2^3 - gr2 + 2*gr2*(gamma_02*gr0^2 + gamma_12*gr1^2 + gamma_23*gr3^2 + gamma_24*gr4^2) - torque_02_gr2 - torque_12_gr2 - torque_23_gr2 - torque_24_gr2) + (L_NL - ${L}) * kappa_laplacian_gr2'
inputs = 'gr0 gr1 gr2 gr3 gr4 gamma_02 gamma_12 gamma_23 gamma_24 torque_02_gr2 torque_12_gr2 torque_23_gr2 torque_24_gr2 L_NL kappa_laplacian_gr2'
[]
[gr3_bulk_term]
type = ParsedCompute
buffer = 'gr3_bulk_term'
expression = '-L_NL*${mu} * (gr3^3 - gr3 + 2*gr3*(gamma_03*gr0^2 + gamma_13*gr1^2 + gamma_23*gr2^2 + gamma_34*gr4^2) - torque_03_gr3 - torque_13_gr3 - torque_23_gr3 - torque_34_gr3) + (L_NL - ${L}) * kappa_laplacian_gr3'
inputs = 'gr0 gr1 gr2 gr3 gr4 gamma_03 gamma_13 gamma_23 gamma_34 torque_03_gr3 torque_13_gr3 torque_23_gr3 torque_34_gr3 L_NL kappa_laplacian_gr3'
[]
[gr4_bulk_term]
type = ParsedCompute
buffer = 'gr4_bulk_term'
expression = '-L_NL*${mu} * (gr4^3 - gr4 + 2*gr4*(gamma_04*gr0^2 + gamma_14*gr1^2 + gamma_24*gr2^2 + gamma_34*gr3^2) - torque_04_gr4 - torque_14_gr4 - torque_24_gr4 - torque_34_gr4) + (L_NL - ${L}) * kappa_laplacian_gr4'
inputs = 'gr0 gr1 gr2 gr3 gr4 gamma_04 gamma_14 gamma_24 gamma_34 torque_04_gr4 torque_14_gr4 torque_24_gr4 torque_34_gr4 L_NL kappa_laplacian_gr4'
[]
[NL_gr0]
type = ForwardFFT
buffer = NL_gr0
input = 'gr0_bulk_term'
[]
[NL_gr1]
type = ForwardFFT
buffer = NL_gr1
input = 'gr1_bulk_term'
[]
[NL_gr2]
type = ForwardFFT
buffer = NL_gr2
input = 'gr2_bulk_term'
[]
[NL_gr3]
type = ForwardFFT
buffer = NL_gr3
input = 'gr3_bulk_term'
[]
[NL_gr4]
type = ForwardFFT
buffer = NL_gr4
input = 'gr4_bulk_term'
[]
[NL_gr0_smooth]
type = ParsedCompute
buffer = NL_gr0_smooth
expression = 'smooth*NL_gr0'
inputs = 'smooth NL_gr0'
[]
[NL_gr1_smooth]
type = ParsedCompute
buffer = NL_gr1_smooth
expression = 'smooth*NL_gr1'
inputs = 'smooth NL_gr1'
[]
[NL_gr2_smooth]
type = ParsedCompute
buffer = NL_gr2_smooth
expression = 'smooth*NL_gr2'
inputs = 'smooth NL_gr2'
[]
[NL_gr3_smooth]
type = ParsedCompute
buffer = NL_gr3_smooth
expression = 'smooth*NL_gr3'
inputs = 'smooth NL_gr3'
[]
[NL_gr4_smooth]
type = ParsedCompute
buffer = NL_gr4_smooth
expression = 'smooth*NL_gr4'
inputs = 'smooth NL_gr4'
[]
# Properties for output
[grain_ID]
type = ParsedCompute
buffer = 'grain_ID'
expression = 'if(gr0>=max(gr1,max(gr2,max(gr3,gr4))), 0, if(gr1>=max(gr2,max(gr3,gr4)), 1, if(gr2>=max(gr3,gr4), 2, if(gr3>=gr4, 3, 4))))'
inputs = 'gr0 gr1 gr2 gr3 gr4'
[]
[gradient_energy]
type = GradientEnergyDensity
buffer = gradient_energy
gradient_buffers = 'grad_gr0 grad_gr1 grad_gr2 grad_gr3 grad_gr4'
kappa = ${kappa}
[]
[total_energy]
type = ParsedCompute
buffer = 'total_energy'
expression = '${mu} * (${f0}) + gradient_energy'
inputs = 'gr0 gr1 gr2 gr3 gr4 gamma_01 gamma_02 gamma_03 gamma_04 gamma_12 gamma_13 gamma_14 gamma_23 gamma_24 gamma_34 gradient_energy'
[]
[]
[]
[Postprocessors]
[total_gb_energy]
type = TensorIntegralPostprocessor
buffer = total_energy
[]
[]
[TensorSolver]
type = AdamsBashforthMoulton
buffer = 'gr0 gr1 gr2 gr3 gr4'
reciprocal_buffer = 'gr0_bar gr1_bar gr2_bar gr3_bar gr4_bar'
linear_reciprocal = 'L_kappa_laplacian L_kappa_laplacian L_kappa_laplacian L_kappa_laplacian L_kappa_laplacian'
nonlinear_reciprocal = 'NL_gr0_smooth NL_gr1_smooth NL_gr2_smooth NL_gr3_smooth NL_gr4_smooth'
substeps = 1000
predictor_order = 1
corrector_order = 1
corrector_steps = 1
[]
[TensorOutputs]
[xdmf]
type = XDMFTensorOutput
buffer = 'gr0 gr1 gr2 gr3 gr4 bnds sigma grain_ID'
output_mode = 'NODE NODE NODE NODE NODE NODE NODE CELL'
enable_hdf5 = true
transpose = true
[]
[]
[Executioner]
type = Transient
dt = 5
num_steps = 50
[]
[Outputs]
csv = true
execute_on = 'INITIAL TIMESTEP_END'
[]
(test/tests/tensor_compute/parallel_roundtrip_3d.i)
[Domain]
# Test parallel FFT round-trip with slab decomposition in 3D
device_names = "cpu cpu cpu"
device_weights = "1 1 1"
dim = 3
nx = 64
ny = 64
nz = 64
xmax = ${fparse pi*4}
ymax = ${fparse pi*4}
zmax = ${fparse pi*4}
[]
[TensorBuffers]
[eta_gold]
[]
[eta]
[]
[eta_bar]
[]
[eta_roundtrip]
[]
[diff]
[]
[zero]
[]
[]
[TensorComputes]
[Initialize]
[eta_gold]
type = ParsedCompute
buffer = eta_gold
expression = 'sin(x)+sin(y)+sin(z)+cos(2*x)*sin(3*y)*cos(z)'
extra_symbols = true
[]
[eta]
type = ParsedCompute
buffer = eta
expression = eta_gold
inputs = eta_gold
[]
[zero]
type = ConstantReciprocalTensor
buffer = zero
real = 0
imaginary = 0
[]
[]
[Solve]
# Test: eta -> FFT -> iFFT -> eta_roundtrip
# eta_roundtrip should equal eta (within numerical precision)
[eta_bar]
type = ForwardFFT
buffer = eta_bar
input = eta
[]
[eta_roundtrip]
type = InverseFFT
buffer = eta_roundtrip
input = eta_bar
[]
[]
[Postprocess]
[diff]
type = ParsedCompute
buffer = diff
expression = 'abs(eta - eta_roundtrip) + abs(eta - eta_gold)'
inputs = 'eta eta_roundtrip eta_gold'
[]
[]
[]
[Postprocessors]
[max_error]
type = TensorExtremeValuePostprocessor
buffer = diff
value_type = MAX
[]
[l2_error]
type = TensorIntegralPostprocessor
buffer = diff
[]
[]
[TensorSolver]
type = AdamsBashforthMoulton
buffer = eta
reciprocal_buffer = eta_bar
linear_reciprocal = zero
nonlinear_reciprocal = zero
[]
[TensorOutputs]
[eta]
type = XDMFTensorOutput
buffer = 'eta'
output_mode = 'CELL'
enable_hdf5 = true
[]
[]
[Problem]
type = TensorProblem
[]
[Executioner]
type = Transient
num_steps = 1
[]
[Outputs]
csv = true
execute_on = 'INITIAL TIMESTEP_END'
[]
(test/tests/cahnhilliard/cahnhilliard_explicit.i)
#
# Simple Cahn-Hilliard solve on a 2D grid. We create a matching (conforming)
# MOOSE mesh (with one element per FFT grid cell) and project the solution onto
# the MOOSE mesh to utilize the exodus output object.
#
[Domain]
dim = 2
nx = 50
ny = 50
xmax = 3
ymax = 3
mesh_mode = DOMAIN
device_names = cpu
[]
[TensorBuffers]
[c]
map_to_aux_variable = c
[]
[cbar]
[]
[mu]
map_to_aux_variable = mu
[]
[mubar]
[]
[dc_dt_bar]
[]
# constant tensors
[Mbar]
[]
[Mkappabarbar]
[]
[]
[TensorComputes]
[Initialize]
[c]
# Random initial condition around a concentration of 1/2
type = RandomTensor
buffer = c
min = 0.44
max = 0.56
seed = 0
[]
[mu_init]
type = ConstantTensor
buffer = mu
[]
# precompute fixed factors for the solve
[Mbar]
type = ReciprocalLaplacianFactor
factor = 0.2 # Mobility
buffer = Mbar
[]
[Mkappabarbar]
type = ReciprocalLaplacianSquareFactor
factor = '${fparse 0.2 * 1e-4}' # M * kappa
buffer = Mkappabarbar
[]
[dc_dt_bar_IC]
type = ConstantReciprocalTensor
buffer = dc_dt_bar
[]
[]
[Solve]
[cahn_hilliard]
[mu]
type = ParsedCompute
buffer = mu
expression = '0.1*c^2*(c-1)^2'
derivatives = c
inputs = c
[]
[mubar]
type = ForwardFFT
buffer = mubar
input = mu
[]
[dc_dt_bar]
type = ParsedCompute
buffer = dc_dt_bar
expression = 'Mbar*mubar - Mkappabarbar*cbar'
inputs = 'Mbar mubar Mkappabarbar cbar'
[]
[cbar]
type = ForwardFFT
buffer = cbar
input = c
[]
[]
[]
[]
[TensorSolver]
type = ForwardEulerSolver
time_derivative_reciprocal = dc_dt_bar
root_compute = cahn_hilliard
buffer = c
reciprocal_buffer = cbar
substeps = 50
[]
[AuxVariables]
[mu]
# the mu tensor is projected onto this elemental variable
family = MONOMIAL
order = CONSTANT
[]
[c]
# the c tensor is projected onto this nodal variable
[]
[]
[Problem]
type = TensorProblem
[]
[Executioner]
type = Transient
num_steps = 100
dt = 1e-1
[]
[Outputs]
exodus = true
csv = true
[]
(test/tests/implicit_fd/crank_thin_slab.i)
# Crank, "The Mathematics of Diffusion" (2nd ed.), Sec. 2.5, eq. (2.15), with the implicit
# solver: an instantaneous planar source C0 = 1 confined to the slab -h < x < h, h = 1,
# diffusing into an infinite medium, has the exact solution
# C(x, t) = (C0/2) (erf((h - x) / (2 sqrt(D t))) + erf((h + x) / (2 sqrt(D t)))).
# The same problem as real_space/thin_slab_diffusion.i, which steps it explicitly.
#
# Pseudo-1D (ny = 1, Y periodic), D = 1. The X faces are 10 diffusion lengths beyond the slab
# edge at the comparison time t = 1, so the far Dirichlet u = 0 does not measurably affect the
# solution.
# Backward Euler with substeps of dt / substeps: the error is first order in the substep.
substeps = 100
[Domain]
dim = 2
# dx = 0.1 puts the slab edges x = +/-1 on cell faces, so the box IC holds the slab mass
nx = 220
ny = 1
parallel_mode = REAL_SPACE
periodic_directions = 'Y'
xmin = -11
xmax = 11
ymin = -0.5
ymax = 0.5
[]
[Functions]
[slab]
type = ParsedFunction
expression = 'if(abs(x) < 1, 1, 0)'
[]
[]
[TensorBuffers]
[u]
[]
[dudt_u]
[]
[lap_u]
[]
[u_exact]
[]
[diff]
[]
[]
[TensorComputes]
[Initialize]
[u_ic]
type = MooseFunctionTensor
buffer = u
function = slab
[]
[]
[BCs]
# far boundaries, approximating the infinite medium
[left]
type = TensorDirichletBC
variable = u
boundary = left
value = 0
[]
[right]
type = TensorDirichletBC
variable = u
boundary = right
value = 0
[]
[]
[Solve]
[dudt]
type = TimeDerivativeOperator
buffer = dudt_u
input = u
[]
[lap]
type = FiniteDifferenceLaplacian
buffer = lap_u
input = u
factor = -1
[]
[]
[Postprocess]
[u_exact]
type = ParsedCompute
buffer = u_exact
expression = '0.5 * (erf((1 - x) / (2 * sqrt(t))) + erf((1 + x) / (2 * sqrt(t)))) + 0*y'
extra_symbols = true
[]
[diff]
type = ParsedCompute
buffer = diff
expression = 'abs(u - u_exact)'
inputs = 'u u_exact'
[]
[]
[]
[TensorSolver]
type = ImplicitFDSolver
buffer = u
operators = 'dudt lap'
root_compute = dudt
substeps = ${substeps}
l_tol = 1e-10
[]
[Postprocessors]
[max_error]
type = TensorExtremeValuePostprocessor
buffer = diff
value_type = MAX
[]
[]
[Problem]
type = TensorProblem
[]
[Executioner]
type = Transient
dt = 1
num_steps = 1
[]
[Outputs]
csv = true
[]
(benchmarks/02_oswald_ripening/simple.i)
[Domain]
dim = 2
nx = 4
ny = 4
xmax = 1
ymax = 1
device_names = 'cuda:0'
mesh_mode = DOMAIN
[]
[TensorBuffers]
# variables
[n1]
[]
[n2]
[]
[n3]
[]
[n1_bar]
[]
[n2_bar]
[]
[n3_bar]
[]
[mu_n1]
[]
[mu_n2]
[]
[mu_n3]
[]
[mu_n1_bar]
[]
[mu_n2_bar]
[]
[mu_n3_bar]
[]
[Lbar] # zero
[]
[]
[TensorComputes]
[Initialize]
[Lbar]
type = ConstantReciprocalTensor
buffer = Lbar
real = 0
imaginary = 0
[]
[n1]
type = ConstantTensor
buffer = n1
real = 1
[]
[n2]
type = ConstantTensor
buffer = n2
real = 1
[]
[n3]
type = ConstantTensor
buffer = n3
real = 1
[]
[mu_n1]
type = ConstantTensor
buffer = mu_n1
real = 1
[]
[]
[Solve]
[mu_n2]
type = ParsedCompute
buffer = mu_n2
expression = 'n3'
inputs = n3
[]
[mu_n3]
type = ParsedCompute
buffer = mu_n3
expression = 'n3*n3'
inputs = n3
[]
[mu_n1_bar]
type = ForwardFFT
buffer = mu_n1_bar
input = mu_n1
[]
[mu_n2_bar]
type = ForwardFFT
buffer = mu_n2_bar
input = mu_n2
[]
[mu_n3_bar]
type = ForwardFFT
buffer = mu_n3_bar
input = mu_n3
[]
[n1_bar]
type = ForwardFFT
buffer = n1_bar
input = n1
[]
[n2_bar]
type = ForwardFFT
buffer = n2_bar
input = n2
[]
[n3_bar]
type = ForwardFFT
buffer = n3_bar
input = n3
[]
[]
[]
[TensorSolver]
# type = SecantSolver
type = BroydenSolver
substeps = 1
max_iterations = 10
damping = 0.5
buffer = 'n1 n2 n3'
tolerance = 1e-5
dt_epsilon = 1e-5
reciprocal_buffer = 'n1_bar n2_bar n3_bar'
linear_reciprocal = 'Lbar Lbar Lbar'
nonlinear_reciprocal = 'mu_n1_bar mu_n2_bar mu_n3_bar'
verbose = true
[]
[Postprocessors]
[n1]
type = TensorAveragePostprocessor
buffer = n1
execute_on = 'TIMESTEP_END'
[]
[n2]
type = TensorAveragePostprocessor
buffer = n2
execute_on = 'TIMESTEP_END'
[]
[n3]
type = TensorAveragePostprocessor
buffer = n3
execute_on = 'TIMESTEP_END'
[]
[]
[Problem]
type = TensorProblem
[]
[Executioner]
type = Transient
num_steps = 1
dt = 1e-2
[]
[Outputs]
perf_graph = true
execute_on = 'TIMESTEP_END'
[]
(test/tests/solvers/etdrk4_diffusion.i)
D = 0.05
k = 1.0
ss = 1
dt = '${units 10 s }'
[Domain]
dim = 1
nx = 64
xmax = '${fparse 2*pi}'
mesh_mode = DUMMY
[]
[TensorComputes]
[Initialize]
[u0]
type = ParsedCompute
buffer = u0
extra_symbols = true
expression = 'sin(${k}*x)'
[]
[u]
type = ParsedCompute
buffer = u
inputs = u0
expression = 'u0'
[]
[L]
type = ReciprocalLaplacianFactor
factor = ${D}
buffer = L
[]
[zero]
type = ConstantReciprocalTensor
buffer = zero
[]
[]
[Solve]
[u_bar]
type = ForwardFFT
buffer = u_bar
input = u
[]
[u_exact]
type = ParsedCompute
buffer = u_exact
inputs = u0
extra_symbols = true
expression = 'u0*exp(-${D}*${k}^2*t)'
[]
[u_diff_sq]
type = ParsedCompute
buffer = u_diff_sq
inputs = 'u u_exact'
expression = '(u - u_exact)^2'
[]
[]
[]
[TensorSolver]
type = ETDRK4Solver
buffer = 'u'
reciprocal_buffer = 'u_bar'
linear_reciprocal = 'L'
nonlinear_reciprocal = 'zero'
substeps = ${ss}
[]
[Problem]
type = TensorProblem
[]
[Postprocessors]
[mse]
type = TensorIntegralPostprocessor
buffer = u_diff_sq
[]
[rmse]
type = ParsedPostprocessor
expression = 'sqrt(mse)'
pp_names = 'mse'
pp_symbols = 'mse'
[]
[]
[Executioner]
type = Transient
num_steps = 10
dt = ${dt}
[]
[Outputs]
file_base = etdrk4_diffusion_rmse
csv = true
[]
(test/tests/implicit_fd/cutback.i)
# Backward Euler diffusion of a Gaussian with a linear iteration limit that the first dt
# exceeds. The torch PCG solve needs about 44 iterations at dt = 0.008, 34 at 0.004 and 23
# at 0.002 (32 x 32, l_tol = 1e-8), so with l_max_its = 30 the step is cut twice and then
# converges.
D = 0.5
n = 32
[Domain]
dim = 2
nx = ${n}
ny = ${n}
xmax = 1
ymax = 1
parallel_mode = REAL_SPACE
periodic_directions = 'X Y'
[]
[TensorBuffers]
[u]
[]
[dudt_u]
[]
[lap_u]
[]
[]
[TensorComputes]
[Initialize]
[u_ic]
type = ParsedCompute
buffer = u
expression = 'exp(-((x - 0.5)^2 + (y - 0.5)^2) / 0.005)'
extra_symbols = true
[]
[]
[Solve]
[dudt]
type = TimeDerivativeOperator
buffer = dudt_u
input = u
[]
[lap]
type = FiniteDifferenceLaplacian
buffer = lap_u
input = u
factor = '${fparse -D}'
[]
[]
[]
[TensorSolver]
type = ImplicitFDSolver
buffer = u
operators = 'dudt lap'
linear_solver = TORCH_PCG
l_max_its = 30
[]
[Postprocessors]
[max_u]
type = TensorExtremeValuePostprocessor
buffer = u
value_type = MAX
[]
[]
[Problem]
type = TensorProblem
[]
[Executioner]
type = Transient
num_steps = 2
[TimeStepper]
type = TensorSolveIterationAdaptiveDT
dt = 0.008
# no growth or shrinking from the iteration count, only the cut on failure
min_iterations = 0
max_iterations = 1000
[]
[]
[Outputs]
csv = true
[]
(test/tests/tensor_compute/backandforth.i)
[Domain]
xmax = ${fparse pi*4}
ymax = ${fparse pi*4}
mesh_mode = DUMMY
[]
[TensorBuffers]
[eta_gold]
[]
[eta]
[]
[eta_bar]
[]
[eta2]
[]
[zero]
[]
[diff]
[]
[]
[TensorComputes]
[Initialize]
[eta_gold]
type = ParsedCompute
buffer = eta_gold
expression = 'sin(x)+sin(y)+sin(z)'
extra_symbols = true
[]
[eta]
type = ParsedCompute
buffer = eta
expression = eta_gold
inputs = eta_gold
[]
[eta2]
type = ConstantTensor
buffer = eta2
real = 1
[]
[zero]
type = ConstantReciprocalTensor
buffer = zero
real = 0
imaginary = 0
[]
[]
[Solve]
[eta_bar]
type = ForwardFFT
buffer = eta_bar
input = eta
[]
[eta_2]
type = InverseFFT
buffer = eta2
input = eta_bar
[]
[]
[Postprocess]
[diff]
type = ParsedCompute
buffer = diff
expression = 'abs(eta - eta2) + abs(eta - eta_gold)'
inputs = 'eta eta2 eta_gold'
[]
[]
[]
[Postprocessors]
[norm]
type = TensorIntegralPostprocessor
buffer = diff
[]
[]
[TensorSolver]
type = AdamsBashforthMoulton
buffer = eta
reciprocal_buffer = eta_bar
linear_reciprocal = zero
nonlinear_reciprocal = zero
[]
[Problem]
type = TensorProblem
[]
[Executioner]
type = Transient
num_steps = 4
[]
[Outputs]
csv = true
[]
(benchmarks/01_spinodal_decomposition/1a_secant.i)
[Domain]
dim = 2
nx = 200
ny = 200
xmax = 200
ymax = 200
device_names = 'cuda'
mesh_mode = DOMAIN
[]
[TensorBuffers]
[c]
map_to_aux_variable = c
[]
[cbar]
[]
[mu]
[]
[mubar]
[]
[Mbarmubar]
[]
# constant tensors
[Mbar]
[]
[kappabarbar]
[]
# postprocessing
[F]
[]
[Fgrad]
[]
[]
[TensorComputes]
[Initialize]
[c]
type = ParsedCompute
buffer = c
extra_symbols = true
expression = 'c0+epsilon*(cos(0.105*x)*cos(0.11*y)+(cos(0.13*x)*cos(0.087*y))^2+cos(0.025*x-0.15*y)*cos(0.07*x-0.02*y))'
constant_names = 'c0 epsilon'
constant_expressions = '0.5 0.01'
[]
[Mbar]
type = ReciprocalLaplacianFactor
factor = 5 # Mobility
buffer = Mbar
[]
[kappabarbar]
type = ReciprocalLaplacianSquareFactor
factor = -10 # -kappa*M
buffer = kappabarbar
[]
[]
[Solve]
[mu]
type = ParsedCompute
buffer = mu
expression = 'rho_s*(c-c_alpha)^2*(c_beta-c)^2'
constant_names = 'rho_s c_alpha c_beta'
constant_expressions = '5 0.3 0.7'
derivatives = c
inputs = c
[]
[mubar]
type = ForwardFFT
buffer = mubar
input = mu
[]
[Mbarmubar]
type = ParsedCompute
buffer = Mbarmubar
expression = 'Mbar*mubar'
inputs = 'Mbar mubar'
[]
[cbar]
type = ForwardFFT
buffer = cbar
input = c
[]
[]
[Postprocess]
[Fgrad]
type = FFTGradientSquare
buffer = Fgrad
input = c
factor = 1 # kappa/2
[]
[F]
type = ParsedCompute
buffer = F
expression = 'rho_s * (c-c_alpha)^2 * (c_beta-c)^2 + Fgrad'
constant_names = 'rho_s c_alpha c_beta'
constant_expressions = '5 0.3 0.7'
inputs = 'c Fgrad'
[]
[]
[]
[TensorSolver]
type = SecantSolver
substeps = 5
max_iterations = 50
tolerance = 1e-7
dt_epsilon = 1e-5
buffer = c
reciprocal_buffer = cbar
linear_reciprocal = kappabarbar
nonlinear_reciprocal = Mbarmubar
[]
[AuxVariables]
[c]
[]
[]
[Postprocessors]
[min_c]
type = TensorExtremeValuePostprocessor
buffer = c
value_type = MIN
execute_on = 'TIMESTEP_END'
[]
[max_c]
type = TensorExtremeValuePostprocessor
buffer = c
value_type = MAX
execute_on = 'TIMESTEP_END'
[]
[F]
type = TensorIntegralPostprocessor
buffer = F
[]
[]
[Problem]
type = TensorProblem
[]
[Executioner]
type = Transient
num_steps = 900
[TimeStepper]
type = IterationAdaptiveDT
growth_factor = 1.01
dt = 1
[]
# dtmax = 200
[]
[Outputs]
exodus = true
csv = true
perf_graph = true
execute_on = 'TIMESTEP_END'
[]
(benchmarks/02_oswald_ripening/2a.i)
[Domain]
dim = 2
nx = 200
ny = 200
xmax = 200
ymax = 200
mesh_mode = DOMAIN
[]
fchem = 'fa:=rho^2*(c-ca)^2;
fb:=rho^2*(cb-c)^2;
h:=n1^3*(6*n1^2-15*n1+10) +
n2^3*(6*n2^2-15*n2+10) +
n3^3*(6*n3^2-15*n3+10) +
n4^3*(6*n4^2-15*n4+10);
g:=n1^2*(1-n1)^2 +
n2^2*(1-n2)^2 +
n3^2*(1-n3)^2 +
n4^2*(1-n4)^2 +
alpha*(
n1^2*n2^2 + n1^2*n3^2 + n1^2*n4^2 +
n2^2*n1^2 + n2^2*n3^2 + n2^2*n4^2 +
n3^2*n1^2 + n3^2*n2^2 + n3^2*n4^2 +
n4^2*n1^2 + n4^2*n2^2 + n4^2*n3^2);
(fa*(1-h) + fb*h + w*g)'
nic = 'epsilon*(cos((0.01*idx)*x-4)*cos((0.007+0.01*idx)*y)
+cos((0.11+0.01*idx)*x)*cos((0.11+0.01*idx)*y)
+psi*(cos((0.046+0.001*idx)*x+(0.0405+0.001*idx)*y)
*cos((0.031+0.001*idx)*x-(0.004+0.001*idx)*y))^2)^2'
cnames = 'rho ca cb alpha w L M'
cvalues = 'sqrt(2) 0.3 0.7 5 1 5 5'
[TensorBuffers]
# variables
[c]
# map_to_aux_variable = c
[]
[n1]
[]
[n2]
[]
[n3]
[]
[n4]
[]
[c_bar]
[]
[n1_bar]
[]
[n2_bar]
[]
[n3_bar]
[]
[n4_bar]
[]
[mu_c]
# map_to_aux_variable = mu
[]
[mu_n1]
[]
[mu_n2]
[]
[mu_n3]
[]
[mu_n4]
[]
[mu_c_bar]
[]
[mu_n1_bar]
[]
[mu_n2_bar]
[]
[mu_n3_bar]
[]
[mu_n4_bar]
[]
[Mbar_mu_c_bar]
[]
# constant tensors
[Lbar] # FFT(M*laplacian)
[]
[MkappaL2bar] # FFT(-M*kappa*laplacian^2)
[]
[kappaLbar] # FFT(L*kappa*laplacian)
[]
# postprocessing
[F]
[]
[Fgrad_c]
[]
[Fgrad_n1]
[]
[Fgrad_n2]
[]
[Fgrad_n3]
[]
[Fgrad_n4]
[]
[bnds]
#map_to_aux_variable = bnds
[]
[]
[TensorComputes]
[Initialize]
[c]
type = ParsedCompute
buffer = c
extra_symbols = true
expression = 'c0+epsilon*(cos(0.105*x)*cos(0.11*y)+(cos(0.13*x)*cos(0.087*y))^2+cos(0.025*x-0.15*y)*cos(0.07*x-0.02*y))'
constant_names = 'c0 epsilon'
constant_expressions = '0.5 0.01'
[]
[Lbar]
type = ReciprocalLaplacianFactor
# Mobility is pulled into the chemical potential below
buffer = Lbar
[]
[MkappaL2bar]
type = ReciprocalLaplacianSquareFactor
factor = -15 # -kappa_c*M
buffer = MkappaL2bar
[]
[kappaLbar]
type = ReciprocalLaplacianFactor
buffer = kappaLbar
factor = 15 # kappa_ni*L
[]
[n1]
type = ParsedCompute
buffer = n1
expression = ${nic}
extra_symbols = true
constant_names = 'idx epsilon psi'
constant_expressions = ' 1 0.1 1.5'
[]
[n2]
type = ParsedCompute
buffer = n2
expression = ${nic}
extra_symbols = true
constant_names = 'idx epsilon psi'
constant_expressions = ' 2 0.1 1.5'
[]
[n3]
type = ParsedCompute
buffer = n3
expression = ${nic}
extra_symbols = true
constant_names = 'idx epsilon psi'
constant_expressions = ' 3 0.1 1.5'
[]
[n4]
type = ParsedCompute
buffer = n4
expression = ${nic}
extra_symbols = true
constant_names = 'idx epsilon psi'
constant_expressions = ' 4 0.1 1.5'
[]
[]
[Solve]
[mu_c]
type = ParsedCompute
buffer = mu_c
expression = '${fchem}*M'
constant_names = ${cnames}
constant_expressions = ${cvalues}
derivatives = c
inputs = 'c n1 n2 n3 n4'
[]
[mu_n1]
type = ParsedCompute
buffer = mu_n1
expression = '${fchem}*(-L)'
constant_names = ${cnames}
constant_expressions = ${cvalues}
derivatives = n1
inputs = 'c n1 n2 n3 n4'
[]
[mu_n2]
type = ParsedCompute
buffer = mu_n2
expression = '${fchem}*(-L)'
constant_names = ${cnames}
constant_expressions = ${cvalues}
derivatives = n2
inputs = 'c n1 n2 n3 n4'
[]
[mu_n3]
type = ParsedCompute
buffer = mu_n3
expression = '${fchem}*(-L)'
constant_names = ${cnames}
constant_expressions = ${cvalues}
derivatives = n3
inputs = 'c n1 n2 n3 n4'
[]
[mu_n4]
type = ParsedCompute
buffer = mu_n4
expression = '${fchem}*(-L)'
constant_names = ${cnames}
constant_expressions = ${cvalues}
derivatives = n4
inputs = 'c n1 n2 n3 n4'
[]
[mu_c_bar]
type = ForwardFFT
buffer = mu_c_bar
input = mu_c
[]
[mu_n1_bar]
type = ForwardFFT
buffer = mu_n1_bar
input = mu_n1
[]
[mu_n2_bar]
type = ForwardFFT
buffer = mu_n2_bar
input = mu_n2
[]
[mu_n3_bar]
type = ForwardFFT
buffer = mu_n3_bar
input = mu_n3
[]
[mu_n4_bar]
type = ForwardFFT
buffer = mu_n4_bar
input = mu_n4
[]
[Mbar_mu_c_bar]
type = ParsedCompute
buffer = Mbar_mu_c_bar
expression = 'Lbar*mu_c_bar'
inputs = 'Lbar mu_c_bar'
[]
[c_bar]
type = ForwardFFT
buffer = c_bar
input = c
[]
[n1_bar]
type = ForwardFFT
buffer = n1_bar
input = n1
[]
[n2_bar]
type = ForwardFFT
buffer = n2_bar
input = n2
[]
[n3_bar]
type = ForwardFFT
buffer = n3_bar
input = n3
[]
[n4_bar]
type = ForwardFFT
buffer = n4_bar
input = n4
[]
[]
[Postprocess]
[Fgrad_c]
type = FFTGradientSquare
buffer = Fgrad_c
input = c
factor = 1.5 # kappa/2
[]
[Fgrad_n1]
type = FFTGradientSquare
buffer = Fgrad_n1
input = n1
factor = 1.5 # kappa/2
[]
[Fgrad_n2]
type = FFTGradientSquare
buffer = Fgrad_n2
input = n2
factor = 1.5 # kappa/2
[]
[Fgrad_n3]
type = FFTGradientSquare
buffer = Fgrad_n3
input = n3
factor = 1.5 # kappa/2
[]
[Fgrad_n4]
type = FFTGradientSquare
buffer = Fgrad_n4
input = n4
factor = 1.5 # kappa/2
[]
[F]
type = ParsedCompute
buffer = F
expression = '${fchem} + Fgrad_c + Fgrad_n1 + Fgrad_n2 + Fgrad_n3 + Fgrad_n4'
constant_names = ${cnames}
constant_expressions = ${cvalues}
inputs = 'c n1 n2 n3 n4 Fgrad_c Fgrad_n1 Fgrad_n2 Fgrad_n3 Fgrad_n4'
[]
[bnds]
type = ParsedCompute
buffer = bnds
expression = 'n1^2 + n2^2 + n3^2 + n4^2'
inputs = 'n1 n2 n3 n4'
[]
[]
[]
[TensorSolver]
type = AdamsBashforthMoulton
buffer = 'c n1 n2 n3 n4'
reciprocal_buffer = 'c_bar n1_bar n2_bar n3_bar n4_bar'
linear_reciprocal = 'MkappaL2bar kappaLbar kappaLbar kappaLbar kappaLbar'
nonlinear_reciprocal = 'Mbar_mu_c_bar mu_n1_bar mu_n2_bar mu_n3_bar mu_n4_bar'
substeps = 2000
predictor_order = 2
corrector_order = 2
corrector_steps = 0
[]
[AuxVariables]
[c]
[]
[bnds]
[]
[]
[Postprocessors]
[min_c]
type = TensorExtremeValuePostprocessor
buffer = c
value_type = MIN
execute_on = 'TIMESTEP_END'
[]
[max_c]
type = TensorExtremeValuePostprocessor
buffer = c
value_type = MAX
execute_on = 'TIMESTEP_END'
[]
[F]
type = TensorIntegralPostprocessor
buffer = F
[]
# [stable_dt]
# type = SemiImplicitCriticalTimeStep
# buffer = MkappaL2bar
# []
[]
[Problem]
type = TensorProblem
[]
[Executioner]
type = Transient
num_steps = 1030
[TimeStepper]
type = IterationAdaptiveDT
growth_factor = 1.1
dt = 0.001
[]
dtmax = 10
[]
[Outputs]
csv = true
perf_graph = true
execute_on = 'TIMESTEP_END'
[]
[TensorOutputs]
[xdmf]
type = XDMFTensorOutput
buffer = 'c bnds'
output_mode = 'CELL CELL'
[]
[]
(test/tests/parsed_tensor/local_vars_derivative.i)
#
# Test differentiation of local variables in ParsedCompute
#
# We test the expression with a buffer input: r := sqrt(a^2 + 1); r^2
# The derivative with respect to a should be: d/da(r^2) = 2*r * dr/da = 2*r * a/r = 2*a
#
[Domain]
dim = 2
nx = 20
ny = 20
xmax = 2
ymax = 2
mesh_mode = DUMMY
[]
[TensorBuffers]
[a] # Input variable
[]
[df_da] # Auto-differentiated derivative
[]
[df_da_exact] # Hand-coded exact derivative
[]
[error] # Absolute difference
[]
[]
[TensorComputes]
[Solve]
# Initialize input buffer
[init_a]
type = ParsedCompute
buffer = a
expression = 'x + 0.5*y'
extra_symbols = true
[]
# Auto-differentiated derivative: d/da(r^2) where r:=sqrt(a^2+1)
[auto_derivative]
type = ParsedCompute
buffer = df_da
expression = 'r:=sqrt(a^2+1); r^2'
derivatives = 'a'
inputs = 'a'
[]
# Hand-coded exact derivative: d/da(r^2) = 2*a
[exact_derivative]
type = ParsedCompute
buffer = df_da_exact
expression = '2*a'
inputs = 'a'
[]
# Compute absolute error
[compute_error]
type = ParsedCompute
buffer = error
expression = 'abs(df_da - df_da_exact)'
inputs = 'df_da df_da_exact'
[]
[]
[]
[Postprocessors]
[integral_error]
type = TensorIntegralPostprocessor
buffer = error
execute_on = 'INITIAL'
[]
[]
[Problem]
type = TensorProblem
[]
[Executioner]
type = Transient
num_steps = 0
[]
[Outputs]
csv = true
[]
(test/tests/typed_tensors/gradient_vector.i)
[Domain]
dim = 3
nx = 20
ny = 10
nz = 5
mesh_mode = DUMMY
device_names = cpu
[]
[TensorComputes]
[Initialize]
[c]
type = ParsedCompute
buffer = c
extra_symbols = true
expression = 'sin(x*8*pi)+cos(y*4*pi)+sin(z*2*pi)'
[]
[grad_c]
type = GradientVector
buffer = grad_c
input = c
[]
[]
[]
[Problem]
type = TensorProblem
print_debug_output = true
[]
[Executioner]
type = Transient
num_steps = 1
[]
[TensorOutputs]
[xdmf]
type = XDMFTensorOutput
buffer = 'c grad_c'
file_base = gradient
output_mode = 'NODE NODE'
enable_hdf5 = true
[]
[]
(examples/anisotropic_grain_growth/isotropic_five_grain.i)
interface_width = 1.6
side = 80
gbe_max = '${units 0.65 J/m^2}'
L = '${fparse 1.0 * 1.6 / ${interface_width} }'
# ------------------------------------------------------------------
# Isotropic reference case.
#
# The GB energy is fixed at sigma = 0.65 J/m^2 for all boundaries,
# equal to gbe_max. Consequently gamma_ij = 1.5 for all pairs (the
# symmetric-well value), there are no torque terms, the mobility is
# uniform (L_NL == L), and the mobility-split correction
# (L_NL - L)*kappa*laplacian(gr_i) vanishes identically.
# ------------------------------------------------------------------
# ------------------------------------------------------------------
# Periodic Voronoi-like IC for 5 grains.
#
# Each grain is seeded at a point (xi, yi). We use a smooth *periodic*
# distance metric based on sine functions,
# d_i^2 = (side/pi)^2 * [ sin(pi*(x-xi)/side)^2 + sin(pi*(y-yi)/side)^2 ]
# which reduces to the Euclidean distance near the seed and wraps
# correctly across the periodic boundaries.
#
# The order parameters are then a softmax over the negative distances,
# gr_i = exp(-a*d_i) / sum_j exp(-a*d_j), a = 4/interface_width
# For any two competing grains this reduces exactly to the usual
# 0.5*(1 - tanh(2*(d_i - d_j)/interface_width)) profile, so the
# interfaces come out with the correct width, the partition of unity
# sum_i gr_i = 1 holds identically, and the cell structure is the
# (diffuse) Voronoi tessellation of the seeds under the periodic metric.
# ------------------------------------------------------------------
aexp = '${fparse 4.0 / ${interface_width} }'
lp = '${fparse ${side} / pi }'
kp = '${fparse pi / ${side} }'
# seed points (spread out over the periodic domain)
d0 = 'sqrt((${lp}*sin(${kp}*(x-8)))^2 + (${lp}*sin(${kp}*(y-6)))^2)'
d1 = 'sqrt((${lp}*sin(${kp}*(x-28)))^2 + (${lp}*sin(${kp}*(y-10)))^2)'
d2 = 'sqrt((${lp}*sin(${kp}*(x-20)))^2 + (${lp}*sin(${kp}*(y-24)))^2)'
d3 = 'sqrt((${lp}*sin(${kp}*(x-4)))^2 + (${lp}*sin(${kp}*(y-28)))^2)'
d4 = 'sqrt((${lp}*sin(${kp}*(x-34)))^2 + (${lp}*sin(${kp}*(y-33)))^2)'
g_gamma0 = '${fparse sqrt(2) / 3 }' # g(gamma=1.5)
f0_gamma0 = ${fparse 1/8}
kappa = '${fparse gbe_max * interface_width * sqrt(f0_gamma0) / g_gamma0 }'
mu = '${fparse gbe_max / (g_gamma0 * interface_width * sqrt(f0_gamma0) ) }'
gamma = 1.5
f0 = '((gr0^4/4 - gr0^2/2) + (gr1^4/4 - gr1^2/2) + (gr2^4/4 - gr2^2/2) + (gr3^4/4 - gr3^2/2) + (gr4^4/4 - gr4^2/2) + ${gamma}*(gr0^2*gr1^2 + gr0^2*gr2^2 + gr0^2*gr3^2 + gr0^2*gr4^2 + gr1^2*gr2^2 + gr1^2*gr3^2 + gr1^2*gr4^2 + gr2^2*gr3^2 + gr2^2*gr4^2 + gr3^2*gr4^2) + 0.25)'
[Domain]
dim = 2
nx = 200
ny = 200
xmax = ${side}
ymax = ${side}
mesh_mode = DUMMY
[]
[TensorComputes]
[Initialize]
# unnormalized softmax weights
[c0]
type = ParsedCompute
buffer = c0
expression = 'exp(-${aexp}*${d0})'
extra_symbols = true
[]
[c1]
type = ParsedCompute
buffer = c1
expression = 'exp(-${aexp}*${d1})'
extra_symbols = true
[]
[c2]
type = ParsedCompute
buffer = c2
expression = 'exp(-${aexp}*${d2})'
extra_symbols = true
[]
[c3]
type = ParsedCompute
buffer = c3
expression = 'exp(-${aexp}*${d3})'
extra_symbols = true
[]
[c4]
type = ParsedCompute
buffer = c4
expression = 'exp(-${aexp}*${d4})'
extra_symbols = true
[]
# normalized order parameters (partition of unity by construction)
[gr0]
type = ParsedCompute
buffer = gr0
expression = 'c0/(c0+c1+c2+c3+c4)'
inputs = 'c0 c1 c2 c3 c4'
[]
[gr1]
type = ParsedCompute
buffer = gr1
expression = 'c1/(c0+c1+c2+c3+c4)'
inputs = 'c0 c1 c2 c3 c4'
[]
[gr2]
type = ParsedCompute
buffer = gr2
expression = 'c2/(c0+c1+c2+c3+c4)'
inputs = 'c0 c1 c2 c3 c4'
[]
[gr3]
type = ParsedCompute
buffer = gr3
expression = 'c3/(c0+c1+c2+c3+c4)'
inputs = 'c0 c1 c2 c3 c4'
[]
[gr4]
type = ParsedCompute
buffer = gr4
expression = '1 - gr0 - gr1 - gr2 - gr3'
inputs = 'gr0 gr1 gr2 gr3'
[]
[L_kappa_laplacian]
type = ReciprocalLaplacianFactor
buffer = 'L_kappa_laplacian'
factor = '${fparse ${L} * ${kappa}}'
[]
[smooth]
type = DeAliasingTensor
method = HOULI
buffer = smooth
[]
[]
[Solve]
[bnds]
type = ParsedCompute
buffer = 'bnds'
inputs = 'gr0 gr1 gr2 gr3 gr4'
expression = 'gr0^2 + gr1^2 + gr2^2 + gr3^2 + gr4^2'
[]
## FFT
[gr0_bar]
type = ForwardFFT
buffer = gr0_bar
input = gr0
[]
[gr1_bar]
type = ForwardFFT
buffer = gr1_bar
input = gr1
[]
[gr2_bar]
type = ForwardFFT
buffer = gr2_bar
input = gr2
[]
[gr3_bar]
type = ForwardFFT
buffer = gr3_bar
input = gr3
[]
[gr4_bar]
type = ForwardFFT
buffer = gr4_bar
input = gr4
[]
## bulk driving forces (constant mobility L, constant gamma = ${gamma})
[gr0_bulk_term]
type = ParsedCompute
buffer = 'gr0_bulk_term'
expression = '-${L}*${mu} * (gr0^3 - gr0 + 2*${gamma}*gr0*(gr1^2 + gr2^2 + gr3^2 + gr4^2))'
inputs = 'gr0 gr1 gr2 gr3 gr4'
[]
[gr1_bulk_term]
type = ParsedCompute
buffer = 'gr1_bulk_term'
expression = '-${L}*${mu} * (gr1^3 - gr1 + 2*${gamma}*gr1*(gr0^2 + gr2^2 + gr3^2 + gr4^2))'
inputs = 'gr0 gr1 gr2 gr3 gr4'
[]
[gr2_bulk_term]
type = ParsedCompute
buffer = 'gr2_bulk_term'
expression = '-${L}*${mu} * (gr2^3 - gr2 + 2*${gamma}*gr2*(gr0^2 + gr1^2 + gr3^2 + gr4^2))'
inputs = 'gr0 gr1 gr2 gr3 gr4'
[]
[gr3_bulk_term]
type = ParsedCompute
buffer = 'gr3_bulk_term'
expression = '-${L}*${mu} * (gr3^3 - gr3 + 2*${gamma}*gr3*(gr0^2 + gr1^2 + gr2^2 + gr4^2))'
inputs = 'gr0 gr1 gr2 gr3 gr4'
[]
[gr4_bulk_term]
type = ParsedCompute
buffer = 'gr4_bulk_term'
expression = '-${L}*${mu} * (gr4^3 - gr4 + 2*${gamma}*gr4*(gr0^2 + gr1^2 + gr2^2 + gr3^2))'
inputs = 'gr0 gr1 gr2 gr3 gr4'
[]
[NL_gr0]
type = ForwardFFT
buffer = NL_gr0
input = 'gr0_bulk_term'
[]
[NL_gr1]
type = ForwardFFT
buffer = NL_gr1
input = 'gr1_bulk_term'
[]
[NL_gr2]
type = ForwardFFT
buffer = NL_gr2
input = 'gr2_bulk_term'
[]
[NL_gr3]
type = ForwardFFT
buffer = NL_gr3
input = 'gr3_bulk_term'
[]
[NL_gr4]
type = ForwardFFT
buffer = NL_gr4
input = 'gr4_bulk_term'
[]
[NL_gr0_smooth]
type = ParsedCompute
buffer = NL_gr0_smooth
expression = 'smooth*NL_gr0'
inputs = 'smooth NL_gr0'
[]
[NL_gr1_smooth]
type = ParsedCompute
buffer = NL_gr1_smooth
expression = 'smooth*NL_gr1'
inputs = 'smooth NL_gr1'
[]
[NL_gr2_smooth]
type = ParsedCompute
buffer = NL_gr2_smooth
expression = 'smooth*NL_gr2'
inputs = 'smooth NL_gr2'
[]
[NL_gr3_smooth]
type = ParsedCompute
buffer = NL_gr3_smooth
expression = 'smooth*NL_gr3'
inputs = 'smooth NL_gr3'
[]
[NL_gr4_smooth]
type = ParsedCompute
buffer = NL_gr4_smooth
expression = 'smooth*NL_gr4'
inputs = 'smooth NL_gr4'
[]
# Properties for output
[grain_ID]
type = ParsedCompute
buffer = 'grain_ID'
expression = 'if(gr0>=max(gr1,max(gr2,max(gr3,gr4))), 0, if(gr1>=max(gr2,max(gr3,gr4)), 1, if(gr2>=max(gr3,gr4), 2, if(gr3>=gr4, 3, 4))))'
inputs = 'gr0 gr1 gr2 gr3 gr4'
[]
[grad_gr0]
type = GradientVector
buffer = grad_gr0
input = gr0
[]
[grad_gr1]
type = GradientVector
buffer = grad_gr1
input = gr1
[]
[grad_gr2]
type = GradientVector
buffer = grad_gr2
input = gr2
[]
[grad_gr3]
type = GradientVector
buffer = grad_gr3
input = gr3
[]
[grad_gr4]
type = GradientVector
buffer = grad_gr4
input = gr4
[]
[gradient_energy]
type = GradientEnergyDensity
buffer = gradient_energy
gradient_buffers = 'grad_gr0 grad_gr1 grad_gr2 grad_gr3 grad_gr4'
kappa = ${kappa}
[]
[total_energy]
type = ParsedCompute
buffer = 'total_energy'
expression = '${mu} * (${f0}) + gradient_energy'
inputs = 'gr0 gr1 gr2 gr3 gr4 gradient_energy'
[]
[]
[]
[Postprocessors]
[total_gb_energy]
type = TensorIntegralPostprocessor
buffer = total_energy
[]
[]
[TensorSolver]
type = AdamsBashforthMoulton
buffer = 'gr0 gr1 gr2 gr3 gr4'
reciprocal_buffer = 'gr0_bar gr1_bar gr2_bar gr3_bar gr4_bar'
linear_reciprocal = 'L_kappa_laplacian L_kappa_laplacian L_kappa_laplacian L_kappa_laplacian L_kappa_laplacian'
nonlinear_reciprocal = 'NL_gr0_smooth NL_gr1_smooth NL_gr2_smooth NL_gr3_smooth NL_gr4_smooth'
substeps = 1000
predictor_order = 1
corrector_order = 1
corrector_steps = 1
[]
[TensorOutputs]
[xdmf]
type = XDMFTensorOutput
buffer = 'gr0 gr1 gr2 gr3 gr4 bnds grain_ID'
output_mode = 'NODE NODE NODE NODE NODE NODE CELL'
enable_hdf5 = true
transpose = true
[]
[]
[Executioner]
type = Transient
dt = 5
num_steps = 50
[]
[Outputs]
csv = true
execute_on = 'INITIAL TIMESTEP_END'
[]
(test/tests/implicit_fd/bc_mms.i)
# Implicit solve of u_t - D Laplacian(u) = f on the unit square with boundary faces, against the
# manufactured solution
#
# u = g + tf t q, g = cos(3 pi x / 2) cos(pi y) + x y, q = x^2 - y^2,
#
# with tf = 0 for the steady problem -D Laplacian(u) = f and tf = 1 for backward Euler.
# q is harmonic, so f = tf q - D Laplacian(g) is independent of time and the backward Euler
# step makes no time error: the error is the spatial one, provided the boundary values are
# taken at the time of the unknown, t + dt (at t it would be of order dt).
#
# Each face has a different condition and value source:
# left (x = 0) Dirichlet u = cos(pi y) - tf t y^2 function
# right (x = 1) Robin ra u + rb du/dx = c function
# or buffer (right_buffer, steady)
# bottom (y = 0) Neumann du/dn = -du/dy = -x buffer
# top (y = 1) Neumann du/dn = du/dy = x - 2 tf t function
# or buffer (top_buffer, values at t)
D = 0.5
n = 32
stencil = 3
tf = 0
ops = 'lap'
num_steps = 1
dt = 0.05
# Robin coefficients on the right face (the 5-point stencil supports ra = 1, rb = 0 only)
ra = 1
rb = 1
[Domain]
dim = 2
nx = ${n}
ny = ${n}
xmax = 1
ymax = 1
parallel_mode = REAL_SPACE
[]
[Functions]
[u_exact]
type = ParsedFunction
expression = 'cos(1.5*pi*x) * cos(pi*y) + x*y + ${tf} * t * (x^2 - y^2)'
[]
[f_func]
type = ParsedFunction
# Laplacian(g) = -13/4 pi^2 cos(3 pi x / 2) cos(pi y)
expression = '${tf} * (x^2 - y^2) + ${D} * 3.25 * pi^2 * cos(1.5*pi*x) * cos(pi*y)'
[]
[right_c]
type = ParsedFunction
# on x = 1: u = y + tf t (1 - y^2), du/dx = 3/2 pi cos(pi y) + y + 2 tf t
expression = '${ra} * (y + ${tf} * t * (1 - y^2)) + ${rb} * (1.5*pi*cos(pi*y) + y + 2 * ${tf} * t)'
[]
[bottom_flux]
type = ParsedFunction
expression = '-x'
[]
[top_flux]
type = ParsedFunction
expression = 'x - 2 * ${tf} * t'
[]
[]
[TensorBuffers]
[u]
[]
[dudt_u]
[]
[lap_u]
[]
[f]
[]
[bottom_flux]
[]
[right_c]
[]
[top_flux]
[]
[exact]
[]
[diff]
[]
[]
[TensorComputes]
[Initialize]
[u_ic]
type = MooseFunctionTensor
buffer = u
function = u_exact
[]
[f_ic]
type = MooseFunctionTensor
buffer = f
function = f_func
[]
# a face value: depends on the tangential coordinate x only
[bottom_flux]
type = MooseFunctionTensor
buffer = bottom_flux
function = bottom_flux
[]
[right_c]
type = MooseFunctionTensor
buffer = right_c
function = right_c
[]
[]
[BCs]
active = 'left right bottom top'
[left]
type = TensorDirichletBC
variable = u
boundary = left
value_function = u_exact
[]
[right]
type = TensorRobinBC
variable = u
boundary = right
a = ${ra}
b = ${rb}
c_function = right_c
[]
# the Robin c from a buffer instead (active = 'left right_buffer bottom top'), steady only
[right_buffer]
type = TensorRobinBC
variable = u
boundary = right
a = ${ra}
b = ${rb}
c_buffer = right_c
[]
[bottom]
type = TensorNeumannBC
variable = u
boundary = bottom
flux_buffer = bottom_flux
[]
[top]
type = TensorNeumannBC
variable = u
boundary = top
flux_function = top_flux
[]
# the top flux from a buffer instead (active = 'left right bottom top_buffer'); a buffer
# value is the one its compute wrote at the start of the substep, at t
[top_buffer]
type = TensorNeumannBC
variable = u
boundary = top
flux_buffer = top_flux
[]
[]
[Solve]
[top_flux]
type = MooseFunctionTensor
buffer = top_flux
function = top_flux
[]
[dudt]
type = TimeDerivativeOperator
buffer = dudt_u
input = u
[]
[lap]
type = FiniteDifferenceLaplacian
buffer = lap_u
input = u
factor = '${fparse -D}'
stencil_width = ${stencil}
[]
[]
[Postprocess]
[exact_compute]
type = MooseFunctionTensor
buffer = exact
function = u_exact
[]
[diff_compute]
type = ParsedCompute
buffer = diff
expression = 'abs(u - exact)'
inputs = 'u exact'
[]
[]
[]
[TensorSolver]
type = ImplicitFDSolver
buffer = u
operators = '${ops}'
source = f
linear_solver = TORCH_PCG
l_tol = 1e-10
[]
[Postprocessors]
[max_error]
type = TensorExtremeValuePostprocessor
buffer = diff
value_type = MAX
[]
[]
[Problem]
type = TensorProblem
[]
[Executioner]
type = Transient
num_steps = ${num_steps}
dt = ${dt}
[]
[Outputs]
csv = true
[]
(benchmarks/01_spinodal_decomposition/1a_implicit_fd.i)
#
# PFHub benchmark 1a (spinodal decomposition, square periodic domain) with the
# implicit finite-difference solver. Same problem as 1a.i:
#
# dc/dt = div(M grad(f'(c) - kappa Laplacian(c))), f = rho_s (c - c_alpha)^2 (c_beta - c)^2
#
# Backward Euler, with the biharmonic implicit and the double-well flux
# divergence explicit:
#
# (c - c^n)/dt + M kappa Laplacian(Laplacian(c)) = M Laplacian(f'(c^n))
#
# M = 5, kappa = 2, rho_s = 5, c_alpha = 0.3, c_beta = 0.7.
#
# substeps per time step, as in 1a_solver.i (each substep is one linear solve)
substeps = 1000
[Domain]
dim = 2
nx = 200
ny = 200
xmax = 200
ymax = 200
parallel_mode = REAL_SPACE
periodic_directions = 'X Y'
[]
[TensorBuffers]
[c]
[]
[dcdt]
[]
[bih_c]
[]
[mu]
[]
[rhs]
[]
# postprocessing
[lap_c]
[]
[F]
[]
[]
[TensorComputes]
[Initialize]
[c]
type = ParsedCompute
buffer = c
extra_symbols = true
expression = 'c0+epsilon*(cos(0.105*x)*cos(0.11*y)+(cos(0.13*x)*cos(0.087*y))^2+cos(0.025*x-0.15*y)*cos(0.07*x-0.02*y))'
constant_names = 'c0 epsilon'
constant_expressions = '0.5 0.01'
[]
[]
[Solve]
# implicit operators
[dcdt]
type = TimeDerivativeOperator
buffer = dcdt
input = c
[]
[bih]
type = FiniteDifferenceBiharmonic
buffer = bih_c
input = c
factor = 10 # M * kappa
[]
# explicit source M Laplacian(f'(c^n))
[explicit]
[mu]
type = ParsedCompute
buffer = mu
expression = 'rho_s*(c-c_alpha)^2*(c_beta-c)^2'
constant_names = 'rho_s c_alpha c_beta'
constant_expressions = '5 0.3 0.7'
derivatives = c
inputs = c
[]
[rhs]
type = FiniteDifferenceLaplacian
buffer = rhs
input = mu
factor = 5 # M
[]
[]
[]
[Postprocess]
# On the periodic grid sum |grad c|^2 = -sum c Laplacian(c) for the 3-point
# Laplacian, so the gradient energy (kappa/2)|grad c|^2 integrates to the same
# total as -(kappa/2) c Laplacian(c).
[lap_c]
type = FiniteDifferenceLaplacian
buffer = lap_c
input = c
[]
[F]
type = ParsedCompute
buffer = F
expression = 'rho_s * (c-c_alpha)^2 * (c_beta-c)^2 - kappa / 2 * c * lap_c'
constant_names = 'rho_s c_alpha c_beta kappa'
constant_expressions = '5 0.3 0.7 2'
inputs = 'c lap_c'
[]
[]
[]
[TensorSolver]
type = ImplicitFDSolver
buffer = c
operators = 'dcdt bih'
source = rhs
root_compute = explicit
substeps = ${substeps}
[]
[UserObjects]
[terminator]
type = Terminator
expression = change<1e-4
[]
[]
[Postprocessors]
[min_c]
type = TensorExtremeValuePostprocessor
buffer = c
value_type = MIN
execute_on = 'TIMESTEP_END'
[]
[max_c]
type = TensorExtremeValuePostprocessor
buffer = c
value_type = MAX
execute_on = 'TIMESTEP_END'
[]
[F]
type = TensorIntegralPostprocessor
buffer = F
[]
[change]
type = TensorIntegralChangePostprocessor
buffer = c
[]
# cumulative wall time of the run (s)
[wall_time]
type = PerfGraphData
section_name = Root
data_type = TOTAL
[]
[]
[Problem]
type = TensorProblem
[]
[Executioner]
type = Transient
num_steps = 1000
[TimeStepper]
type = IterationAdaptiveDT
growth_factor = 1.1
dt = 1
[]
dtmax = 300
[]
[TensorOutputs]
[xdmf]
type = XDMFTensorOutput
buffer = 'c mu'
enable_hdf5 = true
[]
[]
[Outputs]
csv = true
perf_graph = true
execute_on = 'TIMESTEP_END'
[]
(test/tests/real_space/laplacian3d.i)
[Domain]
dim = 3
nx = 30
ny = 24
nz = 17
parallel_mode = REAL_SPACE
periodic_directions = 'X Y Z'
xmin = -1
ymin = -1
zmin = -1
xmax = 1
ymax = 1
zmax = 1
[]
[TensorBuffers]
[u]
type = PlainTensorBuffer
[]
[u_gold]
type = PlainTensorBuffer
[]
[lap]
type = PlainTensorBuffer
[]
[]
[TensorComputes]
[Initialize]
[u_ic]
type = ParsedCompute
buffer = u
expression = 'sin(pi*(x+0.5))*sin(pi*(y+0.5))*sin(pi*(z+0.5))'
extra_symbols = true
[]
[lap_gold_ic]
type = ParsedCompute
buffer = lap_gold
#expression = '0'
expression = '-3*pi*pi*sin(pi*(x+0.5))*sin(pi*(y+0.5))*sin(pi*(z+0.5))'
extra_symbols = true
expand = REAL
[]
[]
[Solve]
[lap_compute]
type = FiniteDifferenceLaplacian
input = u
buffer = lap
[]
[diff]
type = ParsedCompute
buffer = diff
expression = 'abs(lap - lap_gold)'
inputs = 'lap lap_gold'
[]
[]
[]
[Postprocessors]
[max_error]
type = TensorExtremeValuePostprocessor
buffer = diff
value_type = MAX
[]
[]
[TensorOutputs]
# active = ''
[lap]
type = XDMFTensorOutput
buffer = 'lap lap_gold diff'
enable_hdf5 = true
[]
[]
[Executioner]
type = Transient
num_steps = 1
[]
[Outputs]
[out]
type = CSV
[]
[]
(examples/lbm/Phase-field/droplet_impact.i)
#
# Droplet Impact on a Thin Liquid Film
# PHYSICAL REVIEW E 97, 033309 (2018) - Section III.D
#
# Domain
Nx = 1500
Ny = 500
# Fluid properties (Re=500, We=8000, 1000:1)
rho_l = 1000.0
rho_g = 1.0
# mu_l = 20.0
# mu_g = 0.2
nu_l = 0.02
nu_g = 0.2
sigma = 0.0625
# Phase field parameters
tau_h = 0.8
D = 5
[Domain]
dim = 2
nx = '${Nx}'
ny = '${Ny}'
xmax = '${Nx}'
ymax = '${Ny}'
device_names = 'cuda'
parallel_mode = REAL_SPACE
periodic_directions = 'X Y'
[]
[Stencil]
[d2q9]
type = LBMD2Q9
[]
[]
[TensorBuffers]
[phi]
type = LBMTensorBuffer
buffer_type = ms
file = phi.h5
[]
[ux]
type = LBMTensorBuffer
buffer_type = ms
file = ux.h5
[]
[uy]
type = LBMTensorBuffer
buffer_type = ms
file = uy.h5
[]
[velocity]
type = LBMTensorBuffer
buffer_type = mv
[]
[grad_phi]
type = LBMTensorBuffer
buffer_type = mv
[]
[laplacian_phi]
type = LBMTensorBuffer
buffer_type = ms
[]
[mu]
type = LBMTensorBuffer
buffer_type = ms
[]
[forces]
type = LBMTensorBuffer
buffer_type = mv
[]
[speed]
type = LBMTensorBuffer
buffer_type = ms
[]
[pressure]
type = LBMTensorBuffer
buffer_type = ms
[]
[rho]
type = LBMTensorBuffer
buffer_type = ms
[]
[h]
type = LBMTensorBuffer
buffer_type = df
[]
[h_post_collision]
type = LBMTensorBuffer
buffer_type = df
[]
[h_eq]
type = LBMTensorBuffer
buffer_type = df
[]
[relaxation_tensor]
type = LBMTensorBuffer
buffer_type = ms
[]
[f]
type = LBMTensorBuffer
buffer_type = df
[]
[f_post_collision]
type = LBMTensorBuffer
buffer_type = df
[]
[f_eq]
type = LBMTensorBuffer
buffer_type = df
[]
[]
[TensorComputes/Initialize]
[u_stack]
type = LBMStackTensors
buffer = velocity
inputs = 'ux uy'
[]
[grad_phi_init]
type = LBMIsotropicGradient
buffer = grad_phi
scalar_field = phi
[]
[rho_init]
type = ParsedCompute
buffer = rho
expression = 'phi * (rho_l - rho_g) + rho_g'
constant_names = 'rho_l rho_g'
constant_expressions = '${rho_l} ${rho_g}'
inputs = phi
[]
[pressure_init]
type = LBMConstantTensor
buffer = pressure
constants = 0.3
[]
# Equilibrium
[h_eq_init]
type = LBMPhaseEquilibrium
buffer = h_eq
phi = phi
velocity = velocity
[]
[h_init]
type = ParsedCompute
buffer = h
expression = 'h_eq'
inputs = h_eq
[]
[h_post_collision_init]
type = ParsedCompute
buffer = h_post_collision
expression = 'h_eq'
inputs = h_eq
[]
[f_eq_init]
type = LBMPressureCorrectedEquilibrium
buffer = f_eq
rho = rho
velocity = velocity
pressure = pressure
[]
[f_init]
type = ParsedCompute
buffer = f
expression = 'f_eq'
inputs = f_eq
[]
[f_post_collision_init]
type = ParsedCompute
buffer = f_post_collision
expression = 'f_eq'
inputs = f_eq
[]
[]
[TensorComputes/Solve]
[compute_phi]
type = LBMComputeDensity
buffer = phi
f = h
[]
[grad_phi]
type = LBMIsotropicGradient
buffer = grad_phi
scalar_field = phi
[]
[laplacian_phi]
type = LBMIsotropicLaplacian
buffer = laplacian_phi
scalar_field = phi
[]
[potential]
type = LBMComputeChemicalPotential
buffer = mu
phi = phi
laplacian_phi = laplacian_phi
thickness = D
sigma = sigma
[]
[compute_forces]
type = LBMComputeSurfaceForces
buffer = forces
chemical_potential = mu
grad_phi = grad_phi
[]
[density]
type = ParsedCompute
buffer = rho
expression = 'phi * (rho_l - rho_g) + rho_g'
constant_names = 'rho_l rho_g'
constant_expressions = '${rho_l} ${rho_g}'
inputs = phi
[]
[velocity]
type = LBMComputeVelocity
buffer = velocity
f = f
rho = rho
enable_forces = true
forces = forces
[]
[h_eq]
type = LBMPhaseEquilibrium
buffer = h_eq
phi = phi
velocity = velocity
[]
[phase_collision]
type = LBMBGKCollision
buffer = h_post_collision
f = h
feq = h_eq
tau0 = tau_h
[]
[apply_forces_phase]
type = LBMAllenCahnSource
buffer = h_post_collision
phi = phi
velocity = velocity
grad_phi = grad_phi
tau = tau_h
thickness = D
[]
[relaxation_tensor]
type = ParsedCompute
buffer = relaxation_tensor
expression = '(phi * (nu_l - nu_g) + nu_g) / cs2 + 0.5'
constant_names = 'nu_l nu_g cs2'
constant_expressions = '${nu_l} ${nu_g} 0.333333333333'
inputs = 'phi'
[]
[pressure]
type = LBMPhaseFieldPressure
buffer = pressure
f = f
velocity = velocity
grad_phi = grad_phi
rho = rho
rho_l = '${rho_l}'
rho_g = '${rho_g}'
[]
[f_eq]
type = LBMPressureCorrectedEquilibrium
buffer = f_eq
rho = rho
velocity = velocity
pressure = pressure
[]
[collision]
type = LBMBGKCollision
buffer = f_post_collision
f = f
feq = f_eq
tau0 = 1.0
is_dynamic_relaxation = true
tau_tensor = relaxation_tensor
[]
[apply_forces_hydro]
type = LBMForceDistribution
buffer = f_post_collision
grad_phi = grad_phi
velocity = velocity
forces = forces
tau_tensor = relaxation_tensor
tau = 1.0
rho_l = '${rho_l}'
rho_g = '${rho_g}'
is_dynamic_relaxation = true
[]
[]
[TensorComputes/Boundary]
# Bounce back on both top and bottom
[top_fluid]
type = LBMBounceBack
buffer = f
f_old = f_post_collision
boundary = top
[]
[bottom_fluid]
type = LBMBounceBack
buffer = f
f_old = f_post_collision
boundary = bottom
[]
[top_phase]
type = LBMBounceBack
buffer = h
f_old = h_post_collision
boundary = top
[]
[bottom_phase]
type = LBMBounceBack
buffer = h
f_old = h_post_collision
boundary = bottom
[]
[]
[TensorSolver]
type = LBMStream
buffer = 'h f'
f_old = 'h_post_collision f_post_collision'
[]
[Problem]
type = LatticeBoltzmannProblem
substeps = 200
print_debug_output = true
scalar_constant_names = 'tau_h D sigma'
scalar_constant_values = '${tau_h} ${D} ${sigma}'
residual_tensor = speed
[]
[Executioner]
type = Transient
num_steps = 50
[]
[TensorOutputs]
[xdmf]
type = XDMFTensorOutput
buffer = 'phi velocity rho'
output_mode = 'Cell Cell Cell'
enable_hdf5 = true
transpose = false
[]
[]
(test/tests/tensor_compute/rotating_grain_secant.i)
w=6
[Domain]
dim = 2
nx = 40
ny = 40
xmax = ${fparse w*pi*2}
ymax = ${fparse w*pi*2/sin(pi/3)}
mesh_mode = DOMAIN
[]
[AuxVariables]
[phi]
[]
[]
[Outputs]
exodus = false
[]
[TensorBuffers]
[psi]
map_to_aux_variable = phi
[]
[psibar]
[]
[psi3]
[]
[psi3bar]
[]
# constant tensors
[linear]
[]
[]
crystal = '-(sin(sin(a)*y/2+cos(a)*x/2)^2 + sin(sin(a+1/3*pi)*y/2+cos(a+1/3*pi)*x/2)^2 + sin(sin(a-1/3*pi)*y/2+cos(a-1/3*pi)*x/2)^2 - 1.5)*0.25'
[Functions]
[grain1]
type = ParsedFunction
expression = 'a := 0; ${crystal}'
[]
[grain2]
type = ParsedFunction
expression = 'a := 0.95; ${crystal}'
[]
[domain]
type = ParsedFunction
expression = 'r := (x-${w}*pi)^2+(y-${w}*pi)^2; if(r<(${w}*2/3*pi)^2, grain2, grain1)'
symbol_names = 'grain1 grain2'
symbol_values = 'grain1 grain2'
[]
[]
[TensorComputes]
[Initialize]
[psi]
type = MooseFunctionTensor
buffer = psi
function = domain
[]
[linear]
type = SwiftHohenbergLinear
buffer = linear
alpha = 1
r = 0.025
[]
[]
[Solve]
[psi3]
type = ParsedCompute
buffer = psi3
expression = "0.20*psi^2-psi^3"
inputs = psi
[]
[psibar]
type = ForwardFFT
buffer = psibar
input = psi
[]
[psi3bar]
type = ForwardFFT
buffer = psi3bar
input = psi3
[]
[]
[]
[TensorSolver]
type = SecantSolver
buffer = psi
substeps = 3
reciprocal_buffer = psibar
linear_reciprocal = linear
nonlinear_reciprocal = psi3bar
[]
[Problem]
type = TensorProblem
[]
[Executioner]
type = Transient
num_steps = 10
[TimeStepper]
type = TensorSolveIterationAdaptiveDT
dt = 1
max_iterations = 400
min_iterations = 100
growth_factor = 1.4
cutback_factor = 0.9
[]
dtmax = 500
[]
[TensorOutputs]
[xdmf]
type = XDMFTensorOutput
buffer = 'psi'
enable_hdf5 = true
# Do not transpose output to avoid regolding the test. In practice the default
# of transpose = true should always be used
transpose = false
[]
[]
(test/tests/real_space/semi_infinite_diffusion.i)
# Verification against Crank, "The Mathematics of Diffusion" (2nd ed.), Sec. 3.3(i),
# eq. (3.13): a semi-infinite medium (x > 0) with uniform initial concentration C0 = 0
# and constant surface concentration C1 maintained at x = 0 has the exact solution
# C(x, t) = C1 * erfc(x / (2*sqrt(D*t)))
# (special case of (3.13) with C0 = 0, using erfc = 1 - erf).
#
# Pseudo-1D (ny = 1, Y periodic), D = 1. The domain extends 10 diffusion lengths at
# the comparison time t = 1 (erfc(10) ~ 2e-45), so the far Dirichlet u = 0 does not
# measurably affect the solution near x = 0.
[Domain]
dim = 2
nx = 100
ny = 1
parallel_mode = REAL_SPACE
periodic_directions = 'Y'
xmin = 0
xmax = 10
ymin = -0.5
ymax = 0.5
[]
[TensorComputes]
# no [Initialize]: buffers start at zero, the C0 = 0 initial condition
[BCs]
[left]
type = TensorDirichletBC
variable = u
boundary = left
value = 1
[]
[right]
# Far boundary, approximating the semi-infinite medium's x -> infinity
# condition; diffusion has not reached here by the comparison time.
type = TensorDirichletBC
variable = u
boundary = right
value = 0
[]
[]
[Solve]
[dt]
type = FiniteDifferenceLaplacian
input = u
buffer = dudt
factor = 1
[]
[u_exact]
type = ParsedCompute
buffer = u_exact
expression = 'erfc(x / (2 * sqrt(t))) + 0*y'
extra_symbols = true
[]
[diff]
type = ParsedCompute
buffer = diff
expression = 'abs(u - u_exact)'
inputs = 'u u_exact'
[]
[]
[]
[TensorSolver]
type = RealSpaceForwardEuler
buffer = u
time_derivative = dudt
substeps = 250
[]
[Postprocessors]
[max_error]
type = TensorExtremeValuePostprocessor
buffer = diff
value_type = MAX
execute_on = 'TIMESTEP_END'
[]
[]
[Executioner]
type = Transient
dt = 1
num_steps = 1
[]
[Outputs]
[out]
type = CSV
[]
[]
(test/tests/kks/KKS_no_flux_bc.i)
#
# Kim-Kim-Suzuki with no-flux BC imposed using the smooth boundary method (SBM), solved on a 2D grid.
# Mask tensor 'psi' supplies the mask for the solve region to the system.
# Note: c is not directly conserved here - the masked value (psi > 0.0)*c will however be conserved.
#
# Constants for Initial Conditions
r = 30
l = 4.2
# Initial condition function for order parameter
eta_IC = '0.5*(1-tanh(2*(sqrt(x^2+y^2)-${r})/${l}))'
# Phase-field model parameters
kappa_eta = 5
rho_sq = 2
w = 1
M = 5
L = 5
c0_a = 0.3
c0_b = 0.7
# Expressions for switching function and bulk Gibbs energy
h_eta = 'eta^3*(6*eta^2-15*eta+10)'
F = '${h_eta}*(${rho_sq}*((c - (1-${h_eta})*(${c0_b} - ${c0_a}))-${c0_a})^2) + (1-${h_eta})*(${rho_sq}*((c + (${h_eta})*(${c0_b} - ${c0_a}))-${c0_b})^2 ) + ${w}*(eta^2)*(1-eta)^2'
[Domain]
dim = 2
nx = 20
ny = 20
xmin = -50
xmax = 50
ymin = -50
ymax = 50
# run on a CUDA device (adjust this to `cpu` if not available)
device_names = 'cpu'
# automatically create a matching mesh
mesh_mode = DUMMY
[]
[Functions]
[psi_func]
type = ParsedFunction
expression = 'if(x<x_min-${l},0,if(x>x_min+${l},1,0.5-0.5*cos(pi*(x-(x_min-${l}))/2/${l}) )) * if(x<x_max-${l},1,if(x>x_max+${l},0,0.5+0.5*cos(pi*(x-(x_max-${l}))/2/${l}) ))'
symbol_names = 'x_min x_max y_min y_max'
symbol_values = '-20 20 -50 50'
[]
[]
[TensorComputes]
[Initialize]
[c_IC]
type = ParsedCompute
buffer = c
expression = '0.6 + (${c0_a}-0.6)*${eta_IC}'
extra_symbols = 'true'
[]
[eta_IC]
type = ParsedCompute
buffer = eta
expression = '${eta_IC}'
extra_symbols = 'true'
[]
[psi_init]
type = MooseFunctionTensor
function = psi_func
buffer = psi
[]
[zero]
type = ConstantReciprocalTensor
buffer = zero
[]
[M]
type = ConstantTensor
buffer = M
real = ${M}
[]
[L]
type = ConstantTensor
buffer = L
real = ${L}
[]
[L_kappa]
type = ConstantTensor
buffer = L_kappa
real = ${fparse ${L} * ${kappa_eta} }
[]
[]
[Solve]
[cbar]
type = ForwardFFT
buffer = cbar
input = c
[]
[etabar]
type = ForwardFFT
buffer = etabar
input = eta
[]
[mu]
type = ParsedCompute
buffer = 'mu'
expression = '${F}'
inputs = 'c eta'
derivatives = 'c'
[]
[div_J]
type = ReciprocalMatDiffusion
buffer = 'div_J'
chemical_potential = mu
mobility = M
psi = psi
[]
[domega_chem_deta]
type = ParsedCompute
buffer = 'domega_chem_deta'
expression = '${F} - mu*c'
inputs = 'mu c eta'
derivatives = 'eta'
[]
[AC_bulk]
type = ReciprocalAllenCahn
buffer = AC_bulk
dF_chem_deta = domega_chem_deta
L = L
psi = psi
[]
[kappa_grad_eta]
type = ReciprocalMatDiffusion
buffer = 'kappa_grad_eta'
chemical_potential = 'eta'
mobility = 'L_kappa'
psi = psi
[]
[AC_bar]
type = ParsedCompute
buffer = AC_bar
expression = 'kappa_grad_eta + AC_bulk'
inputs = 'AC_bulk kappa_grad_eta'
[]
[]
[]
[TensorSolver]
type = AdamsBashforthMoulton
buffer = 'c eta'
reciprocal_buffer = 'cbar etabar'
linear_reciprocal = 'zero zero'
nonlinear_reciprocal = 'div_J AC_bar'
substeps = 1e3
predictor_order = 3
[]
[Postprocessors]
[total_C]
type = TensorIntegralPostprocessor
buffer = c
execute_on = 'INITIAL TIMESTEP_END'
[]
[total_eta]
type = TensorIntegralPostprocessor
buffer = eta
execute_on = 'INITIAL TIMESTEP_END'
[]
[]
[TensorOutputs]
[xdmf]
type = XDMFTensorOutput
buffer = 'eta c mu psi'
enable_hdf5 = true
transpose = false
[]
[]
[Executioner]
type = Transient
dt = 0.1
num_steps = 10
[]
[Outputs]
csv = true
perf_graph = true
execute_on = 'INITIAL TIMESTEP_END'
[]
(test/tests/anisotropic_grain_growth/sigma3_circular_grain.i)
interface_width = 2.0
r0 = 3
gbe_max = '${units 0.8797226 J/m^2}'
L = '${fparse 1.0 * 1.6 / ${interface_width}}'
g_gamma0 = '${fparse sqrt(2) / 3}' # g(gamma=1.5)
f0_gamma0 = ${fparse 1/8}
kappa = '${fparse gbe_max * interface_width * sqrt(f0_gamma0) / g_gamma0}'
mu = '${fparse gbe_max / (g_gamma0 * interface_width * sqrt(f0_gamma0))}'
g_to_gamma_func = '(1.0/(-3.0944 * g^8 -1.8169*g^6 + 10.323 * g^4 - 8.1819*g^2 + 2.0033))'
dgamma_dsigma = '(g * (24.7552*g^6 + 10.9014*g^4 - 41.292*g^2 + 16.3638) / (-3.0944*g^8 - 1.8169*g^6 + 10.323*g^4 - 8.1819*g^2 + 2.0033)^2 / sqrt(${kappa} * ${mu}))'
f0 = '((gr0^4/4 - gr0^2/2) + (gr1^4/4 - gr1^2/2) + gamma_01*gr0^2*gr1^2 + 0.25)'
[Domain]
dim = 2
nx = 32
ny = 32
xmax = 8
ymax = 8
mesh_mode = DUMMY
floating_precision = SINGLE
[]
[TensorComputes]
[Initialize]
[gr0]
type = ParsedCompute
buffer = 'gr0'
extra_symbols = 'true'
expression = 'radius:=sqrt((x-${Domain/xmax}/2)^2+(y-${Domain/ymax}/2)^2);0.5 - 0.5*tanh(2*(radius-${r0})/${interface_width})'
[]
[gr1]
type = ParsedCompute
buffer = 'gr1'
extra_symbols = 'true'
expression = 'radius:=sqrt((x-${Domain/xmax}/2)^2+(y-${Domain/ymax}/2)^2);0.5 + 0.5*tanh(2*(radius-${r0})/${interface_width})'
[]
[L_kappa_laplacian]
type = ReciprocalLaplacianFactor
buffer = L_kappa_laplacian
factor = ${fparse ${L} * ${kappa}}
[]
[kappa_laplacian]
type = ReciprocalLaplacianFactor
buffer = kappa_laplacian
factor = '${kappa}'
[]
[smooth]
type = DeAliasingTensor
method = HOULI
buffer = smooth
[]
[]
[Solve]
## FFT
[gr0_bar]
type = ForwardFFT
buffer = gr0_bar
input = gr0
[]
[gr1_bar]
type = ForwardFFT
buffer = gr1_bar
input = gr1
[]
# Gradients
[grad_gr0]
type = GradientVector
buffer = grad_gr0
input = gr0_bar
input_is_reciprocal = true
[]
[grad_gr1]
type = GradientVector
buffer = grad_gr1
input = gr1_bar
input_is_reciprocal = true
[]
# Get interface energy
[sigma_gr0_gr1]
type = PairwiseAnisotropicGBEnergy
buffer = 'sigma_gr0_gr1'
dsigma_dgrad_grain1 = 'dsigma_gr0_gr1_dgrad_gr0'
dsigma_dgrad_grain2 = 'dsigma_gr0_gr1_dgrad_gr1'
grad_grain1_buffer = 'grad_gr0'
grad_grain2_buffer = 'grad_gr1'
interface_width = '${interface_width}'
libtorch_model_file = 'marlin:anisotropic_gb_energy/gb_energy_hull_2d.pt'
chunk_size = 256
[]
[gamma_01]
type = ParsedCompute
buffer = 'gamma_01'
expression = 'g:=sigma_gr0_gr1/sqrt(${kappa}*${mu});${g_to_gamma_func}'
inputs = 'sigma_gr0_gr1'
[]
[coeff_01]
type = ParsedCompute
buffer = 'coeff_01'
expression = 'g:=sigma_gr0_gr1/sqrt(${kappa}*${mu});${dgamma_dsigma} * gr0^2 *gr1^2'
inputs = 'sigma_gr0_gr1 gr0 gr1'
[]
[torque_01_gr0]
type = AnisotropyTorque
buffer = torque_01_gr0
dmu_dn = dsigma_gr0_gr1_dgrad_gr0
g = 'coeff_01'
[]
[torque_01_gr1]
type = AnisotropyTorque
buffer = torque_01_gr1
dmu_dn = dsigma_gr0_gr1_dgrad_gr1
g = 'coeff_01'
[]
[kappa_laplacian_gr0_hat]
type = ParsedCompute
buffer = kappa_laplacian_gr0_hat
inputs = 'gr0_bar kappa_laplacian'
expression = 'gr0_bar * kappa_laplacian'
[]
[kappa_laplacian_gr1_hat]
type = ParsedCompute
buffer = kappa_laplacian_gr1_hat
inputs = 'gr1_bar kappa_laplacian'
expression = 'gr1_bar * kappa_laplacian'
[]
[kappa_laplacian_gr0]
type = InverseFFT
buffer = kappa_laplacian_gr0
input = kappa_laplacian_gr0_hat
[]
[kappa_laplacian_gr1]
type = InverseFFT
buffer = kappa_laplacian_gr1
input = kappa_laplacian_gr1_hat
[]
[gr0_bulk_term]
type = ParsedCompute
buffer = 'gr0_bulk_term'
expression = 'L_NL:=${L}*(sigma_gr0_gr1)/${gbe_max};-L_NL*${mu} * (gr0^3 - gr0 + 2*gr0*(gamma_01*gr1^2) - torque_01_gr0) + (L_NL - ${L})*kappa_laplacian_gr0'
inputs = 'gr0 gr1 gamma_01 torque_01_gr0 sigma_gr0_gr1 kappa_laplacian_gr0'
[]
[gr1_bulk_term]
type = ParsedCompute
buffer = 'gr1_bulk_term'
expression = 'L_NL:=${L}*(sigma_gr0_gr1)/${gbe_max};-L_NL*${mu} * (gr1^3 - gr1 + 2*gr1*(gamma_01*gr0^2) - torque_01_gr1) + (L_NL - ${L})*kappa_laplacian_gr1'
inputs = 'gr0 gr1 gamma_01 torque_01_gr1 sigma_gr0_gr1 kappa_laplacian_gr1'
[]
## build non-linear terms and smooth them
[NL_gr0]
type = ForwardFFT
buffer = NL_gr0
input = 'gr0_bulk_term'
[]
[NL_gr1]
type = ForwardFFT
buffer = NL_gr1
input = 'gr1_bulk_term'
[]
[NL_gr0_smooth]
type = ParsedCompute
buffer = NL_gr0_smooth
expression = 'smooth*NL_gr0'
inputs = 'smooth NL_gr0'
[]
[NL_gr1_smooth]
type = ParsedCompute
buffer = NL_gr1_smooth
expression = 'smooth*NL_gr1'
inputs = 'smooth NL_gr1'
[]
# Properties for output
[sigma]
type = ParsedCompute
buffer = 'sigma'
expression = 'gr0^2*gr1^2*sigma_gr0_gr1'
inputs = 'sigma_gr0_gr1 gr0 gr1'
[]
[gradient_energy]
type = GradientEnergyDensity
buffer = gradient_energy
gradient_buffers = 'grad_gr0 grad_gr1'
kappa = ${kappa}
[]
[total_energy]
type = ParsedCompute
buffer = 'total_energy'
expression = '${mu} * (${f0}) + gradient_energy'
inputs = 'gr0 gr1 gamma_01 gradient_energy'
[]
[]
[]
[Postprocessors]
[total_gb_energy]
type = TensorIntegralPostprocessor
buffer = total_energy
[]
[]
[TensorSolver]
type = AdamsBashforthMoulton
buffer = 'gr0 gr1'
reciprocal_buffer = 'gr0_bar gr1_bar'
linear_reciprocal = 'L_kappa_laplacian L_kappa_laplacian'
nonlinear_reciprocal = 'NL_gr0_smooth NL_gr1_smooth'
substeps = 1e2
predictor_order = 1
corrector_order = 1
corrector_steps = 1
[]
[TensorOutputs]
active = ''
[xdmf]
type = XDMFTensorOutput
buffer = 'gr0 gr1 sigma_gr0_gr1 sigma total_energy'
output_mode = 'NODE NODE NODE NODE NODE'
enable_hdf5 = true
transpose = false
[]
[]
[Executioner]
type = Transient
dt = 1
num_steps = 2
[]
[Outputs]
csv = true
execute_on = 'INITIAL TIMESTEP_END'
[]
(test/tests/implicit_fd/crank_semi_infinite.i)
# Crank, "The Mathematics of Diffusion" (2nd ed.), Sec. 3.3(i), eq. (3.13), with the implicit
# solver: a semi-infinite medium (x > 0) with zero initial concentration and constant surface
# concentration C1 = 1 at x = 0 has the exact solution
# C(x, t) = erfc(x / (2 sqrt(D t))).
# The same problem as real_space/semi_infinite_diffusion.i, which steps it explicitly.
#
# Pseudo-1D (ny = 1, Y periodic), D = 1. The domain extends 10 diffusion lengths at the
# comparison time t = 1, so the far Dirichlet u = 0 does not measurably affect the solution.
# Backward Euler with substeps of dt / substeps: the error is first order in the substep.
substeps = 100
[Domain]
dim = 2
nx = 100
ny = 1
parallel_mode = REAL_SPACE
periodic_directions = 'Y'
xmin = 0
xmax = 10
ymin = -0.5
ymax = 0.5
[]
[TensorBuffers]
[u]
[]
[dudt_u]
[]
[lap_u]
[]
[u_exact]
[]
[diff]
[]
[]
[TensorComputes]
# no [Initialize]: buffers start at zero, the C0 = 0 initial condition
[BCs]
[left]
type = TensorDirichletBC
variable = u
boundary = left
value = 1
[]
[right]
# far boundary, approximating the semi-infinite medium's x -> infinity condition
type = TensorDirichletBC
variable = u
boundary = right
value = 0
[]
[]
[Solve]
[dudt]
type = TimeDerivativeOperator
buffer = dudt_u
input = u
[]
[lap]
type = FiniteDifferenceLaplacian
buffer = lap_u
input = u
factor = -1
[]
[]
[Postprocess]
[u_exact]
type = ParsedCompute
buffer = u_exact
expression = 'erfc(x / (2 * sqrt(t))) + 0*y'
extra_symbols = true
[]
[diff]
type = ParsedCompute
buffer = diff
expression = 'abs(u - u_exact)'
inputs = 'u u_exact'
[]
[]
[]
[TensorSolver]
type = ImplicitFDSolver
buffer = u
operators = 'dudt lap'
root_compute = dudt
substeps = ${substeps}
l_tol = 1e-10
[]
[Postprocessors]
[max_error]
type = TensorExtremeValuePostprocessor
buffer = diff
value_type = MAX
[]
[]
[Problem]
type = TensorProblem
[]
[Executioner]
type = Transient
dt = 1
num_steps = 1
[]
[Outputs]
csv = true
[]
(examples/degeus_mechanics/mech.i)
[Domain]
dim = 3
nx = 32
ny = 32
nz = 32
xmax = ${fparse 2*pi}
ymax = ${fparse 2*pi}
zmax = ${fparse 2*pi}
mesh_mode = DUMMY
[]
[TensorComputes]
[Initialize]
[Finit]
type = RankTwoIdentity
buffer = F
[]
[phase]
type = PhaseMechanicsTest
buffer = phase
[]
[K]
type = ParsedCompute
buffer = K
expression = '(1-phase)*Ka + phase*Kb'
inputs = phase
constant_names = 'Ka Kb'
constant_expressions = '0.833 8.33'
[]
[mu]
type = ParsedCompute
buffer = mu
expression = '(1-phase)*mua + phase*mub'
inputs = phase
constant_names = 'mua mub'
constant_expressions = '0.386 3.86'
[]
[]
[Solve]
[hyper_elasticity]
type = HyperElasticIsotropic
buffer = stress
F = Fnew
K = K
mu = mu
[]
[root]
[applied_strain]
type = MacroscopicShearTensor
buffer = applied_strain
[]
[mech]
type = FFTMechanics
buffer = Fnew
F = F
K = K
mu = mu
l_tol = 1e-2
nl_rel_tol = 2e-2
nl_abs_tol = 2e-2
constitutive_model = hyper_elasticity
stress = stress
applied_macroscopic_strain = applied_strain
[]
[]
[]
[Postprocess]
[displacements]
type = ComputeDisplacements
buffer = disp
F = F
[]
[vonmises]
type = ComputeVonMisesStress
buffer = sV
[]
[]
[]
[TensorSolver]
# no variables are integrated by this solver (FFTMechanics performs a steady state mechanics solve)
type = ForwardEulerSolver
root_compute = root
# deformation tensor is just forwarded Fnew -> F
forward_buffer = F
forward_buffer_new = Fnew
substeps = 10
[]
[TensorOutputs]
[deformation_tensor]
type = XDMFTensorOutput
buffer = 'disp sV F'
output_mode = 'OVERSIZED_NODAL CELL CELL'
enable_hdf5 = true
[]
[]
[Executioner]
type = Transient
num_steps = 100
dt = 0.01
[]
(test/tests/real_space/deep_ghost_faces.i)
# A stencil reaching four cells across a face (the 5-point biharmonic) with Neumann faces in x:
# its four ghost layers are the even mirror of the owned cells about the face. The result on
# 0 < x < 16 then equals the same stencil on the periodic domain 0 < x < 32 of the mirrored field
# (deep_ghost_periodic.i), which needs no ghost fill at a face, to round-off.
#
# u = exp(cos(pi x / 16)) sin(2 pi y / 8) is even about x = 0 and x = 16. With Dirichlet faces and
# u_ic = sin(pi x / 16) exp(cos(2 pi y / 8)), odd about both, the ghosts are the odd mirror.
u_ic = 'exp(cos(pi*x/16))*sin(2*pi*y/8)'
[Domain]
dim = 2
nx = 16
ny = 8
xmax = 16
ymax = 8
parallel_mode = REAL_SPACE
periodic_directions = 'Y'
[]
[TensorBuffers]
[u]
[]
[bih]
[]
[bih_sq]
[]
[]
[TensorComputes]
[Initialize]
[u_ic]
type = ParsedCompute
buffer = u
extra_symbols = true
expression = ${u_ic}
[]
[]
[BCs]
[left]
type = TensorNeumannBC
variable = u
boundary = left
[]
[right]
type = TensorNeumannBC
variable = u
boundary = right
[]
[]
[Postprocess]
[bih]
type = FiniteDifferenceBiharmonic
buffer = bih
input = u
stencil_width = 5
[]
[bih_sq]
type = ParsedCompute
buffer = bih_sq
expression = 'bih^2'
inputs = bih
[]
[]
[]
[Postprocessors]
[integral_bih_sq]
type = TensorIntegralPostprocessor
buffer = bih_sq
[]
[max_bih]
type = TensorExtremeValuePostprocessor
buffer = bih
value_type = MAX
[]
[min_bih]
type = TensorExtremeValuePostprocessor
buffer = bih
value_type = MIN
[]
[]
[Problem]
type = TensorProblem
[]
[Executioner]
type = Transient
num_steps = 1
[]
[Outputs]
csv = true
[]
(test/tests/solvers/coupled.i)
#
# Simple Cahn-Hilliard solve on a 2D grid.
#
[Domain]
dim = 2
nx = 150
ny = 150
xmax = '${fparse pi*2}'
ymax = '${fparse pi*2}'
mesh_mode = DUMMY
[]
[GlobalParams]
constant_names = 'A B'
constant_expressions = '1 3.5'
[]
[TensorComputes]
[Initialize]
[u]
type = ParsedCompute
buffer = u
extra_symbols = true
expression = 'sin(x)*sin(y)'
expand = REAL
[]
[v]
type = ParsedCompute
buffer = v
extra_symbols = true
expression = 'cos(x)*cos(y)'
expand = REAL
[]
[zero]
type = ConstantReciprocalTensor
buffer = zero
[]
# precompute fixed factors for the solve
[D1]
type = ReciprocalLaplacianFactor
factor = 1e-2
buffer = D1
[]
[D2]
type = ReciprocalLaplacianFactor
factor = 1e-3
buffer = D2
[]
[]
[Solve]
[u_bar]
type = ForwardFFT
buffer = u_bar
input = u
[]
[v_bar]
type = ForwardFFT
buffer = v_bar
input = v
[]
[]
[]
[TensorSolver]
type = AdamsBashforthMoultonCoupled
buffer = 'u v'
reciprocal_buffer = 'u_bar v_bar'
linear_reciprocal = 'D1 D1'
linear_offdiag_cols = '0 1'
linear_offdiag_rows = '1 0'
linear_offdiag = 'D2 D2'
nonlinear_reciprocal = 'zero zero'
substeps = ${ss}
corrector_steps = ${cs}
predictor_order = ${order}
corrector_order = ${order}
[]
[Problem]
type = TensorProblem
[]
[Postprocessors]
[u_min]
type = TensorExtremeValuePostprocessor
buffer = u
value_type = MIN
[]
[u_max]
type = TensorExtremeValuePostprocessor
buffer = u
value_type = MAX
[]
[v_min]
type = TensorExtremeValuePostprocessor
buffer = v
value_type = MIN
[]
[v_max]
type = TensorExtremeValuePostprocessor
buffer = v
value_type = MAX
[]
[U]
type = TensorIntegralPostprocessor
buffer = u
[]
[V]
type = TensorIntegralPostprocessor
buffer = v
[]
[]
[Executioner]
type = Transient
num_steps = 25
dt = 10
[]
[Outputs]
file_base = coupled_${ss}_${cs}_${order}
csv = true
[]
(examples/lbm/Phase-field/spinodal_decomposition.i)
#
# Spinodal decomposition
# PHYSICAL REVIEW E 97, 033309 (2018) - Section III.C
#
# Domain
Nx = 200
Ny = 200
# Fluid properties
rho_l = 1000.0
rho_g = 1.0
nu_l = 0.1
nu_g = 1.0
sigma = 0.2
# Phase field parameters
tau_h = 0.67
D = 4
[Domain]
dim = 2
nx = '${Nx}'
ny = '${Ny}'
xmax = '${Nx}'
ymax = '${Ny}'
device_names='cpu'
parallel_mode = REAL_SPACE
periodic_directions = 'X Y'
[]
[Stencil]
[d2q9]
type = LBMD2Q9
[]
[]
[TensorBuffers]
# Macroscopic phase field variables
[phi]
type = LBMTensorBuffer
buffer_type = ms
[]
[grad_phi]
type = LBMTensorBuffer
buffer_type = mv
[]
[laplacian_phi]
type = LBMTensorBuffer
buffer_type = ms
[]
[mu]
type = LBMTensorBuffer
buffer_type = ms
[]
[forces]
type = LBMTensorBuffer
buffer_type = mv
[]
# Macroscopic hydrodynamic variables
[velocity]
type = LBMTensorBuffer
buffer_type = mv
[]
[pressure]
type = LBMTensorBuffer
buffer_type = ms
[]
[rho]
type = LBMTensorBuffer
buffer_type = ms
[]
# LBM phase field variabels
[h]
type = LBMTensorBuffer
buffer_type = df
[]
[h_post_collision]
type = LBMTensorBuffer
buffer_type = df
[]
[h_eq]
type = LBMTensorBuffer
buffer_type = df
[]
[relaxation_tensor]
type = LBMTensorBuffer
buffer_type = ms
[]
# LBM hydrodynamic variables
[fdummy]
type = LBMTensorBuffer
buffer_type = df
[]
[f]
type = LBMTensorBuffer
buffer_type = df
[]
[f_post_collision]
type = LBMTensorBuffer
buffer_type = df
[]
[f_eq]
type = LBMTensorBuffer
buffer_type = df
[]
[]
[TensorComputes/Initialize]
[phi_init]
type = RandomTensor
buffer = phi
min = 0.3233
max = 0.3433
[]
[grad_phi_init]
type = LBMIsotropicGradient
buffer = grad_phi
scalar_field = phi
[]
[rho_init]
type = ParsedCompute
buffer = rho
extra_symbols = true
expression = 'phi*(rho_l - rho_g) + rho_g'
constant_names = 'rho_l rho_g'
constant_expressions = '${rho_l} ${rho_g}'
inputs = phi
[]
[pressure_init]
type = LBMConstantTensor
buffer = pressure
constants = 0.3
[]
# Phase field equilibrium distribution initialization
[h_eq_init]
type = LBMPhaseEquilibrium
buffer = h_eq
phi = phi
velocity = velocity
[]
[h_post_collision_init]
type = LBMPhaseEquilibrium
buffer = h_post_collision
phi = phi
velocity = velocity
[]
[h_init]
type = LBMPhaseEquilibrium
buffer = h
phi = phi
velocity = velocity
[]
# Hydrodynamic equilibrium distribution initialization
[f_eq_init]
type = LBMPressureCorrectedEquilibrium
buffer = f_eq
rho = rho
velocity = velocity
pressure = pressure
[]
[f_post_collision_init]
type = ParsedCompute
buffer = f_post_collision
expression = 'f_eq'
inputs = f_eq
[]
[f_init]
type = ParsedCompute
buffer = f
expression = 'f_eq'
inputs = f_eq
[]
[]
[TensorComputes/Solve]
# Phase Field
[compute_phi]
type = LBMComputeDensity
buffer = phi
f = h
[]
[grad_phi]
type = LBMIsotropicGradient
buffer = grad_phi
scalar_field = phi
[]
[laplacian_phi]
type = LBMIsotropicLaplacian
buffer = laplacian_phi
scalar_field = phi
[]
[potential]
type = LBMComputeChemicalPotential
buffer = mu
phi = phi
laplacian_phi = laplacian_phi
thickness = D
sigma = sigma
[]
[forces]
type = LBMComputeSurfaceForces
buffer = forces
chemical_potential = mu
grad_phi = grad_phi
[]
# Hydrodynamics
[density]
type = ParsedCompute
buffer = rho
extra_symbols = true
expression = 'phi*(rho_l - rho_g) + rho_g'
constant_names = 'rho_l rho_g'
constant_expressions = '${rho_l} ${rho_g}'
inputs = phi
[]
[velocity]
type = LBMComputeVelocity
buffer = velocity
f = f
rho = rho
enable_forces = true
forces = forces
[]
# Phase-field
[h_eq]
type = LBMPhaseEquilibrium
buffer = h_eq
phi = phi
velocity = velocity
[]
[phase_collision]
type = LBMBGKCollision
buffer = h_post_collision
f = h
feq = h_eq
tau0 = tau_h
[]
[apply_forces_phase]
type = LBMAllenCahnSource
buffer = h_post_collision
phi = phi
velocity = velocity
grad_phi = grad_phi
tau = tau_h
thickness = D
[]
# Hydrodynamics
[relaxation_tensor]
type = ParsedCompute
buffer = relaxation_tensor
extra_symbols = true
expression = '(phi*(nu_l - nu_g) + nu_g)/cs2+0.5'
constant_names = 'nu_l nu_g cs2'
constant_expressions = '${nu_l} ${nu_g} 0.3333'
inputs = phi
[]
[pressure]
type = LBMPhaseFieldPressure
buffer = pressure
f = f
velocity = velocity
grad_phi = grad_phi
rho = rho
rho_l = '${rho_l}'
rho_g = '${rho_g}'
[]
[f_eq]
type = LBMPressureCorrectedEquilibrium
buffer = f_eq
rho = rho
velocity = velocity
pressure = pressure
[]
[collision]
type = LBMBGKCollision
buffer = f_post_collision
f = f
feq = f_eq
tau0 = 1.0
is_dynamic_relaxation = true
tau_tensor = relaxation_tensor
[]
[apply_forces_hydro]
type = LBMForceDistribution
buffer = f_post_collision
grad_phi = grad_phi
velocity = velocity
forces = forces
tau_tensor = relaxation_tensor
tau = 1.0
rho_l = '${rho_l}'
rho_g = '${rho_g}'
is_dynamic_relaxation = true
[]
[]
[TensorSolver]
type = LBMStream
buffer = 'h f'
f_old = 'h_post_collision f_post_collision'
[]
[Problem]
type = LatticeBoltzmannProblem
substeps = 500
print_debug_output = true
scalar_constant_names = 'tau_h D sigma'
scalar_constant_values = '${tau_h} ${D} ${sigma}'
log_interval = 100
residual_tensor = speed
[]
[Executioner]
type = Transient
num_steps = 100
[]
[TensorOutputs]
[xdmf]
type = XDMFTensorOutput
buffer = 'phi rho velocity'
output_mode = 'Cell Cell Cell'
enable_hdf5 = true
# transpose = false
[]
[]
(examples/libtorch_kks/KKS_libtorch.i)
#
# Kim-Kim-Suzuki with Gibbs energy supplied by a torch model, solved on a 2D grid.
#
# Constants for Initial Conditions
r = 30
l = 4.2
# Initial condition function for order parameter
eta_IC = '0.5*(1-tanh(2*(sqrt(x^2+y^2)-${r})/${l}))'
# Phase-field model parameters
kappa_eta = 5
w = 1
M = 5
L = 5
# Expressions for switching function and bulk Gibbs energy
h_eta = 'eta^3*(6*eta^2-15*eta+10)'
[Domain]
dim = 2
nx = 100
ny = 100
xmin = -50
xmax = 50
ymin = -50
ymax = 50
# automatically create a matching mesh
mesh_mode = DUMMY
[]
[TensorComputes]
[Initialize]
[c_IC]
type = ParsedCompute
buffer = c
expression = '0.6 + (0.3-0.6)*${eta_IC}'
extra_symbols = 'true'
[]
[eta_IC]
type = ParsedCompute
buffer = eta
expression = '${eta_IC}'
extra_symbols = 'true'
[]
[psi_init]
type = ConstantTensor
buffer = psi
real = 1
[]
[M]
type = ConstantTensor
buffer = M
real = ${M}
[]
[L]
type = ConstantTensor
buffer = L
real = ${L}
[]
[L_kappa]
type = ReciprocalLaplacianFactor
buffer = L_kappa
factor = ${fparse ${L} * ${kappa_eta} }
[]
[h_eta_IC]
type = ParsedCompute
buffer = h_eta
expression = '${h_eta}'
inputs = eta
[]
[G_func_IC]
type = LibtorchGibbsEnergy
buffer = 'G'
phase_fractions = 'h_eta'
concentrations = 'c'
domega_detas = 'dG_dh'
chem_pots = 'mu'
libtorch_model_file = 'torch_NN_gibbs_model.pt'
[]
[smooth]
type = DeAliasingTensor
method = HOULI
buffer = smooth
[]
[]
[Solve]
[h_eta]
type = ParsedCompute
buffer = h_eta
expression = '${h_eta}'
inputs = eta
[]
[G_func]
type = LibtorchGibbsEnergy
buffer = 'G'
phase_fractions = 'h_eta'
concentrations = 'c'
domega_detas = 'dG_dh'
chem_pots = 'mu'
libtorch_model_file = 'torch_NN_gibbs_model.pt'
[]
[dG_deta]
type = ParsedCompute
buffer = 'dG_deta'
inputs = 'eta dG_dh'
expression = 'dG_dh * ${h_eta} + ${w} * eta^2 * (1-eta^2)^2'
derivatives = 'eta'
[]
[etabar]
type = ForwardFFT
buffer = etabar
input = eta
[]
[AC_bulk]
type = ReciprocalAllenCahn
L = L
buffer = AC_bulk
dF_chem_deta = dG_deta
psi = psi
[]
[NL_eta]
type = ParsedCompute
buffer = NL_eta
expression = 'AC_bulk '
inputs = 'AC_bulk'
[]
[cbar]
type = ForwardFFT
buffer = cbar
input = c
[]
[div_J]
type = ReciprocalMatDiffusion
buffer = 'div_J'
chemical_potential = mu
mobility = M
psi = psi
[]
[NL_c]
type = ParsedCompute
buffer = 'NL_c'
inputs = 'div_J smooth'
expression = 'smooth * div_J'
[]
[]
[]
[TensorSolver]
type = AdamsBashforthMoulton
buffer = 'c eta'
reciprocal_buffer = 'cbar etabar'
linear_reciprocal = '0 L_kappa'
nonlinear_reciprocal = 'NL_c NL_eta'
substeps = 1e3
predictor_order = 3
corrector_order = 1
corrector_steps = 1
[]
[Postprocessors]
[total_c]
type = TensorIntegralPostprocessor
buffer = c
[]
[]
[TensorOutputs]
[xdmf]
type = XDMFTensorOutput
buffer = 'eta c mu psi dG_deta dG_dh G'
enable_hdf5 = true
transpose = false
[]
[]
[Executioner]
type = Transient
num_steps = 100
[TimeStepper]
type = IterationAdaptiveDT
growth_factor = 1.25
dt = 0.1
[]
dtmax = 10
[]
[Outputs]
csv = true
perf_graph = true
execute_on = 'INITIAL TIMESTEP_END'
[]
(test/tests/typed_tensors/gradient.i)
[Domain]
dim = 3
nx = 20
ny = 10
nz = 5
mesh_mode = DUMMY
device_names = cpu
[]
[TensorComputes]
[Initialize]
[c]
type = ParsedCompute
buffer = c
extra_symbols = true
expression = 'sin(x*8*pi)+cos(y*4*pi)+sin(z*2*pi)'
[]
[grad_c]
type = NEML2GradientVector
buffer = grad_c
input = c
[]
[]
[]
[Problem]
type = TensorProblem
print_debug_output = true
[]
[Executioner]
type = Transient
num_steps = 1
[]
[TensorOutputs]
[xdmf]
type = XDMFTensorOutput
buffer = 'c grad_c'
file_base = gradient
output_mode = 'NODE NODE'
enable_hdf5 = true
[]
[]
(test/tests/gradient/gradient.i)
[Domain]
dim = 3
nx = 40
ny = 40
nz = 40
xmax = ${fparse pi*2}
ymax = ${fparse pi*4}
zmax = ${fparse pi*6}
mesh_mode = DUMMY
[]
[TensorBuffers]
[s]
[]
[gradx_s]
[]
[grady_s]
[]
[gradz_s]
[]
[cx]
[]
[cy]
[]
[cz]
[]
[diff]
[]
[]
[TensorComputes]
[Initialize]
[sin]
type = ParsedCompute
buffer = s
extra_symbols = true
expression = 'sin(x)+sin(y)+sin(z)'
[]
[cosx]
type = ParsedCompute
buffer = cx
extra_symbols = true
expression = 'cos(x)'
[]
[cosy]
type = ParsedCompute
buffer = cy
extra_symbols = true
expression = 'cos(y)'
[]
[cosz]
type = ParsedCompute
buffer = cz
extra_symbols = true
expression = 'cos(z)'
[]
[gradx_sin]
type = FFTGradient
buffer = gradx_s
input = s
direction = x
[]
[grady_sin]
type = FFTGradient
buffer = grady_s
input = s
direction = y
[]
[gradz_sin]
type = FFTGradient
buffer = gradz_s
input = s
direction = z
[]
[diff]
type = ParsedCompute
buffer = diff
inputs = 'gradx_s grady_s gradz_s cx cy cz'
expression = 'abs(gradx_s - cx)+abs(grady_s - cy)+abs(gradz_s - cz)'
[]
[]
[]
[Postprocessors]
[diff]
type = TensorIntegralPostprocessor
buffer = diff
[]
[]
[Problem]
type = TensorProblem
[]
[Executioner]
type = Transient
num_steps = 1
[]
[Outputs]
csv = true
[]
(benchmarks/01_spinodal_decomposition/1a.i)
[Domain]
dim = 2
nx = 200
ny = 200
xmax = 200
ymax = 200
device_names = 'cuda'
mesh_mode = DOMAIN
[]
[TensorBuffers]
[c]
map_to_aux_variable = c
[]
[cbar]
[]
[mu]
# map_to_aux_variable = mu
[]
[mubar]
[]
[Mbarmubar]
[]
# constant tensors
[Mbar]
[]
[kappabarbar]
[]
# postprocessing
[F]
[]
[Fgrad]
[]
[]
[TensorComputes]
[Initialize]
[c]
type = ParsedCompute
buffer = c
extra_symbols = true
expression = 'c0+epsilon*(cos(0.105*x)*cos(0.11*y)+(cos(0.13*x)*cos(0.087*y))^2+cos(0.025*x-0.15*y)*cos(0.07*x-0.02*y))'
constant_names = 'c0 epsilon'
constant_expressions = '0.5 0.01'
[]
[Mbar]
type = ReciprocalLaplacianFactor
factor = 5 # Mobility
buffer = Mbar
[]
[kappabarbar]
type = ReciprocalLaplacianSquareFactor
factor = -10 # -kappa*M
buffer = kappabarbar
[]
[]
[Solve]
[mu]
type = ParsedCompute
buffer = mu
expression = 'rho_s*(c-c_alpha)^2*(c_beta-c)^2'
constant_names = 'rho_s c_alpha c_beta'
constant_expressions = '5 0.3 0.7'
derivatives = c
inputs = c
[]
[mubar]
type = ForwardFFT
buffer = mubar
input = mu
[]
[Mbarmubar]
type = ParsedCompute
buffer = Mbarmubar
expression = 'Mbar*mubar'
inputs = 'Mbar mubar'
[]
[cbar]
type = ForwardFFT
buffer = cbar
input = c
[]
[]
[Postprocess]
[Fgrad]
type = FFTGradientSquare
buffer = Fgrad
input = c
factor = 1 # kappa/2
[]
[F]
type = ParsedCompute
buffer = F
expression = 'rho_s * (c-c_alpha)^2 * (c_beta-c)^2 + Fgrad'
constant_names = 'rho_s c_alpha c_beta'
constant_expressions = '5 0.3 0.7'
inputs = 'c Fgrad'
[]
[]
[]
[UserObjects]
[terminator]
type = Terminator
expression = change<1e-4
[]
[]
[TensorTimeIntegrators]
[c]
type = FFTSemiImplicit
buffer = c
history_size = 1
reciprocal_buffer = cbar
linear_reciprocal = kappabarbar
nonlinear_reciprocal = Mbarmubar
[]
[]
[AuxVariables]
# [mu]
# family = MONOMIAL
# order = CONSTANT
# []
[c]
# family = MONOMIAL
# order = CONSTANT
[]
[]
[Postprocessors]
[min_c]
type = TensorExtremeValuePostprocessor
buffer = c
value_type = MIN
execute_on = 'TIMESTEP_END'
[]
[max_c]
type = TensorExtremeValuePostprocessor
buffer = c
value_type = MAX
execute_on = 'TIMESTEP_END'
[]
[F]
type = TensorIntegralPostprocessor
buffer = F
[]
[change]
type = TensorIntegralChangePostprocessor
buffer = c
[]
[]
[Problem]
type = TensorProblem
spectral_solve_substeps = 1000
[]
[Executioner]
type = Transient
num_steps = 1000
[TimeStepper]
type = IterationAdaptiveDT
growth_factor = 1.1
dt = 1
[]
dtmax = 300
[]
[Outputs]
exodus = true
csv = true
perf_graph = true
execute_on = 'TIMESTEP_END'
[]
(test/tests/implicit_fd/be_mode3d.i)
# Backward Euler diffusion u_t = D Laplacian(u) of a single periodic Fourier
# mode. On the periodic cell-centred grid the mode is an eigenvector of the
# discrete Laplacian with eigenvalue -lambda_h, so every implicit step must
# multiply it by exactly g = 1 / (1 + dt D lambda_h), up to the linear solver
# tolerance.
D = 0.5
# 5 steps of dt, then 5 steps of dt2 (dt2 != dt exercises the operator rebuild)
dt = 0.01
dt2 = 0.01
n = 16
stencil = 3
dim = 3
# Symbol of -Laplacian per axis for the wavenumber 2 pi, h = 1/n:
# 3-point: (2 - 2 cos(2 pi h)) / h^2
# 5-point: (5/2 - 8/3 cos(2 pi h) + 1/6 cos(4 pi h)) / h^2
lambda3 = '${fparse n^2 * (2 - 2 * cos(2 * pi / n))}'
lambda5 = '${fparse n^2 * (5 / 2 - 8 / 3 * cos(2 * pi / n) + 1 / 6 * cos(4 * pi / n))}'
lambda = '${fparse dim * if(stencil = 3, lambda3, lambda5)}'
[Domain]
dim = 3
nx = ${n}
ny = ${n}
nz = ${n}
zmax = 1
xmax = 1
ymax = 1
parallel_mode = REAL_SPACE
periodic_directions = 'X Y Z'
[]
[TensorBuffers]
[u]
[]
[dudt_u]
[]
[lap_u]
[]
[gold]
[]
[diff]
[]
[]
[TensorComputes]
[Initialize]
[u_ic]
type = ParsedCompute
buffer = u
expression = 'sin(2*pi*x)*sin(2*pi*y)*sin(2*pi*z)'
extra_symbols = true
[]
[]
[Solve]
[dudt]
type = TimeDerivativeOperator
buffer = dudt_u
input = u
[]
[lap]
type = FiniteDifferenceLaplacian
buffer = lap_u
input = u
factor = '${fparse -D}'
stencil_width = ${stencil}
[]
[]
[Postprocess]
[gold_compute]
type = ParsedCompute
buffer = gold
# g(dt)^(t/dt) up to t1 = 5 dt, then g(dt)^5 g(dt2)^((t - t1)/dt2)
expression = 'sin(2*pi*x)*sin(2*pi*y)*sin(2*pi*z) * if(t < t1 + dt / 2, g1^(t / dt), g1^5 * g2^((t - t1) / dt2))'
constant_names = 'g1 g2 dt dt2 t1'
constant_expressions = '${fparse 1 / (1 + dt * D * lambda)} ${fparse 1 / (1 + dt2 * D * lambda)} ${dt} ${dt2} ${fparse 5 * dt}'
extra_symbols = true
[]
[diff_compute]
type = ParsedCompute
buffer = diff
expression = 'abs(u - gold)'
inputs = 'u gold'
[]
[]
[]
[TensorSolver]
type = ImplicitFDSolver
buffer = u
operators = 'dudt lap'
root_compute = dudt
[]
[Postprocessors]
[max_error]
type = TensorExtremeValuePostprocessor
buffer = diff
value_type = MAX
[]
[max_gold]
type = TensorExtremeValuePostprocessor
buffer = gold
value_type = MAX
[]
[]
[Problem]
type = TensorProblem
[]
[Executioner]
type = Transient
num_steps = 10
[TimeStepper]
type = TimeSequenceStepper
time_sequence = '${fparse 1 * dt} ${fparse 2 * dt} ${fparse 3 * dt} ${fparse 4 * dt} ${fparse 5 * dt}
${fparse 5 * dt + dt2} ${fparse 5 * dt + 2 * dt2} ${fparse 5 * dt + 3 * dt2}
${fparse 5 * dt + 4 * dt2} ${fparse 5 * dt + 5 * dt2}'
[]
[]
[Outputs]
csv = true
[]
(test/tests/tensor_compute/parallel.i)
[Domain]
device_names = "cuda:1 cuda:0 cpu"
device_weights = "10 10 1"
parallel_mode = FFT_SLAB
dim = 2
nx = 400
ny = 400
xmax = ${fparse pi*2*30}
ymax = ${fparse pi*2*30}
[]
# [Mesh]
# type = GeneratedMesh
# dim =1
# []
[TensorBuffers]
[psi]
# map_to_aux_variable = psi
[]
[psibar]
[]
[psi3]
[]
[psi3bar]
[]
# constant tensors
[linear]
[]
# output
[filter]
# map_to_aux_variable = filter
[]
[filterbar]
[]
[]
[AuxVariables]
[psi]
[]
[filter]
[]
[]
[TensorComputes]
[Initialize]
[psi]
type = RandomTensor
buffer = psi
min = 0
max = 0.07
[]
[linear]
type = SwiftHohenbergLinear
buffer = linear
alpha = 1
r = 0.025
[]
[]
[Solve]
[psi3]
type = ParsedCompute
buffer = psi3
expression = "0.20*psi^2-psi^3"
inputs = psi
[]
[psibar]
type = ForwardFFT
buffer = psibar
input = psi
[]
[psi3bar]
type = ForwardFFT
buffer = psi3bar
input = psi3
[]
[]
[Postprocess]
[low_pass]
type = ParsedCompute
buffer = filterbar
extra_symbols = true
expression = 'psibar * exp(-k2*10)'
inputs = psibar
[]
[filter]
type = InverseFFT
buffer = filter
input = filterbar
[]
[]
[]
[TensorTimeIntegrators]
[c]
type = FFTSemiImplicit
buffer = psi
reciprocal_buffer = psibar
linear_reciprocal = linear
nonlinear_reciprocal = psi3bar
[]
[]
[Problem]
type = TensorProblem
spectral_solve_substeps = 1000
[]
[Executioner]
type = Transient
num_steps = 300
[TimeStepper]
type = IterationAdaptiveDT
growth_factor = 1.2
dt = 10
[]
dtmax = 1000
[]
[Postprocessors]
[min_psi]
type = TensorExtremeValuePostprocessor
buffer = psi
value_type = MIN
execute_on = 'TIMESTEP_END'
[]
[max_psi]
type = TensorExtremeValuePostprocessor
buffer = psi
value_type = MAX
execute_on = 'TIMESTEP_END'
[]
[Psi]
type = TensorIntegralPostprocessor
buffer = psi
[]
[]
# [TensorOutputs]
# [xdmf]
# type = XDMFTensorOutput
# buffer = 'psi'
# output_mode = 'Node'
# enable_hdf5 = true
# []
# []
[Outputs]
exodus = true
perf_graph = true
execute_on = 'TIMESTEP_END'
[]
(examples/cahn_hilliard/cahnhilliard4.i)
[Domain]
dim = 3
nx = 100
ny = 100
nz = 100
xmax = ${fparse pi*4}
ymax = ${fparse pi*4}
zmax = ${fparse pi*4}
device_names = 'cuda'
mesh_mode = DUMMY
debug = true
[]
[TensorBuffers]
[c]
[]
[cbar]
[]
[mu]
[]
[mubar]
[]
[Mbarmubar]
[]
# constant tensors
[Mbar]
[]
[kappabarbar]
[]
[]
[TensorOutputs]
[xdmf]
type = XDMFTensorOutput
buffer = 'c mu'
output_mode = 'Node Cell'
enable_hdf5 = true
[]
[]
[TensorComputes]
[Initialize]
[c]
type = RandomTensor
buffer = c
min = 0.44
max = 0.56
[]
[Mbar]
type = ReciprocalLaplacianFactor
factor = 0.2 # Mobility
buffer = Mbar
[]
[kappabarbar]
type = ReciprocalLaplacianSquareFactor
factor = -0.001 # kappa
buffer = kappabarbar
[]
[]
[Solve]
[mu]
type = ParsedCompute
buffer = mu
expression = '0.1*c^2*(c-1)^2 + c*sin(x/2)*0.005'
extra_symbols = true
derivatives = c
# expression = "0.4*c^3-0.6*c^2+0.2*c"
inputs = c
[]
[mubar]
type = ForwardFFT
buffer = mubar
input = mu
[]
[Mbarmubar]
type = ParsedCompute
buffer = Mbarmubar
expression = 'Mbar*mubar'
inputs = 'Mbar mubar'
[]
[cbar]
type = ForwardFFT
buffer = cbar
input = c
[]
[]
[]
[TensorTimeIntegrators]
[c]
type = FFTSemiImplicit
buffer = c
reciprocal_buffer = cbar
linear_reciprocal = kappabarbar
nonlinear_reciprocal = Mbarmubar
[]
[]
[Postprocessors]
[min_c]
type = TensorExtremeValuePostprocessor
buffer = c
value_type = MIN
execute_on = 'TIMESTEP_END'
[]
[max_c]
type = TensorExtremeValuePostprocessor
buffer = c
value_type = MAX
execute_on = 'TIMESTEP_END'
[]
[C]
type = TensorIntegralPostprocessor
buffer = c
execute_on = 'TIMESTEP_END'
[]
[cavg]
type = TensorAveragePostprocessor
buffer = c
execute_on = 'TIMESTEP_END'
[]
[]
[Problem]
type = TensorProblem
spectral_solve_substeps = 1000
[]
[Executioner]
type = Transient
num_steps = 50
[TimeStepper]
type = IterationAdaptiveDT
growth_factor = 1.8
dt = 0.1
[]
dtmax = 500
[]
[Outputs]
csv = true
perf_graph = true
execute_on = 'TIMESTEP_END'
[]
(test/tests/solvers/diagonal.i)
#
# Simple Cahn-Hilliard solve on a 2D grid.
#
[Domain]
dim = 2
nx = 150
ny = 150
xmax = '${fparse pi*2}'
ymax = '${fparse pi*2}'
mesh_mode = DUMMY
[]
[GlobalParams]
constant_names = 'A B'
constant_expressions = '1 3.5'
[]
[TensorComputes]
[Initialize]
[u]
type = ParsedCompute
buffer = u
extra_symbols = true
expression = 'sin(x)*sin(y)'
expand = REAL
[]
[v]
type = ConstantTensor
buffer = v
real = 0
[]
# precompute fixed factors for the solve
[Du]
type = ReciprocalLaplacianFactor
factor = 1e-2
buffer = Du
[]
[Dv]
type = ReciprocalLaplacianFactor
factor = 1e-3
buffer = Dv
[]
[]
[Solve]
[u_bar]
type = ForwardFFT
buffer = u_bar
input = u
[]
[v_bar]
type = ForwardFFT
buffer = v_bar
input = v
[]
[source_u]
type = ParsedCompute
buffer = source_u
expression = 'A - (B+1)*u +u^2*v'
inputs = 'u v'
[]
[source_u_bar]
type = ForwardFFT
buffer = source_u_bar
input = source_u
[]
[source_v]
type = ParsedCompute
buffer = source_v
expression = 'B*u - u^2*v'
inputs = 'u v'
[]
[source_v_bar]
type = ForwardFFT
buffer = source_v_bar
input = source_v
[]
[]
[]
[TensorSolver]
type = AdamsBashforthMoulton
buffer = 'u v'
reciprocal_buffer = 'u_bar v_bar'
linear_reciprocal = 'Du Dv'
nonlinear_reciprocal = 'source_u_bar source_v_bar'
substeps = ${ss}
corrector_steps = ${cs}
predictor_order = ${order}
corrector_order = ${order}
[]
[Problem]
type = TensorProblem
[]
[Postprocessors]
[u_min]
type = TensorExtremeValuePostprocessor
buffer = u
value_type = MIN
[]
[u_max]
type = TensorExtremeValuePostprocessor
buffer = u
value_type = MAX
[]
[v_min]
type = TensorExtremeValuePostprocessor
buffer = v
value_type = MIN
[]
[v_max]
type = TensorExtremeValuePostprocessor
buffer = v
value_type = MAX
[]
[U]
type = TensorIntegralPostprocessor
buffer = u
[]
[V]
type = TensorIntegralPostprocessor
buffer = v
[]
[]
[Executioner]
type = Transient
num_steps = 25
dt = 0.5
[]
[Outputs]
file_base = diagonal_${ss}_${cs}_${order}
csv = true
[]
(test/tests/lbm/phase.i)
# Domain
Nx = 20
Ny = 20
# Fluid properties
rho_l = 5.0
rho_g = 1.0
nu_l = 0.1
nu_g = 1.0
sigma = 0.2
# Phase field parameters
tau_h = 1.0
D = 4
[Domain]
dim = 2
nx = '${Nx}'
ny = '${Ny}'
xmax = '${Nx}'
ymax = '${Ny}'
device_names='cpu'
parallel_mode = REAL_SPACE
periodic_directions = 'X Y'
[]
[Stencil]
[d2q9]
type = LBMD2Q9
[]
[]
[TensorBuffers]
# Macroscopic phase field variables
[phi]
type = LBMTensorBuffer
buffer_type = ms
[]
[grad_phi]
type = LBMTensorBuffer
buffer_type = mv
[]
[laplacian_phi]
type = LBMTensorBuffer
buffer_type = ms
[]
[mu]
type = LBMTensorBuffer
buffer_type = ms
[]
[forces]
type = LBMTensorBuffer
buffer_type = mv
[]
# Macroscopic hydrodynamic variables
[velocity]
type = LBMTensorBuffer
buffer_type = mv
[]
[pressure]
type = LBMTensorBuffer
buffer_type = ms
[]
[rho]
type = LBMTensorBuffer
buffer_type = ms
[]
# LBM phase field variabels
[h]
type = LBMTensorBuffer
buffer_type = df
[]
[h_post_collision]
type = LBMTensorBuffer
buffer_type = df
[]
[h_eq]
type = LBMTensorBuffer
buffer_type = df
[]
[relaxation_tensor]
type = LBMTensorBuffer
buffer_type = ms
[]
# LBM hydrodynamic variables
[fdummy]
type = LBMTensorBuffer
buffer_type = df
[]
[f]
type = LBMTensorBuffer
buffer_type = df
[]
[f_post_collision]
type = LBMTensorBuffer
buffer_type = df
[]
[f_eq]
type = LBMTensorBuffer
buffer_type = df
[]
[]
[TensorComputes/Initialize]
[phi_init]
type = ParsedCompute
buffer = phi
extra_symbols = true
expression = '0.3333 + 0.01*sin((12.9898*x + 78.233*y)*2*pi)'
[]
[grad_phi_init]
type = LBMIsotropicGradient
buffer = grad_phi
scalar_field = phi
[]
[rho_init]
type = ParsedCompute
buffer = rho
extra_symbols = true
expression = 'phi*(rho_l - rho_g) + rho_g'
constant_names = 'rho_l rho_g'
constant_expressions = '${rho_l} ${rho_g}'
inputs = phi
[]
[pressure_init]
type = LBMConstantTensor
buffer = pressure
constants = 0.3
[]
# Phase field equilibrium distribution initialization
[h_eq_init]
type = LBMPhaseEquilibrium
buffer = h_eq
phi = phi
velocity = velocity
[]
[h_post_collision_init]
type = LBMPhaseEquilibrium
buffer = h_post_collision
phi = phi
velocity = velocity
[]
[h_init]
type = LBMPhaseEquilibrium
buffer = h
phi = phi
velocity = velocity
[]
# Hydrodynamic equilibrium distribution initialization
[f_eq_init]
type = LBMPressureCorrectedEquilibrium
buffer = f_eq
rho = rho
velocity = velocity
pressure = pressure
[]
[f_post_collision_init]
type = ParsedCompute
buffer = f_post_collision
expression = 'f_eq'
inputs = f_eq
[]
[f_init]
type = ParsedCompute
buffer = f
expression = 'f_eq'
inputs = f_eq
[]
[]
[TensorComputes/Solve]
# Phase Field
[compute_phi]
type = LBMComputeDensity
buffer = phi
f = h
[]
[grad_phi]
type = LBMIsotropicGradient
buffer = grad_phi
scalar_field = phi
[]
[laplacian_phi]
type = LBMIsotropicLaplacian
buffer = laplacian_phi
scalar_field = phi
[]
[potential]
type = LBMComputeChemicalPotential
buffer = mu
phi = phi
laplacian_phi = laplacian_phi
thickness = D
sigma = sigma
[]
[forces]
type = LBMComputeSurfaceForces
buffer = forces
chemical_potential = mu
grad_phi = grad_phi
[]
# Hydrodynamics
[density]
type = ParsedCompute
buffer = rho
extra_symbols = true
expression = 'phi*(rho_l - rho_g) + rho_g'
constant_names = 'rho_l rho_g'
constant_expressions = '${rho_l} ${rho_g}'
inputs = phi
[]
[velocity]
type = LBMComputeVelocity
buffer = velocity
f = f
rho = rho
enable_forces = true
forces = forces
[]
# Phase-field
[h_eq]
type = LBMPhaseEquilibrium
buffer = h_eq
phi = phi
velocity = velocity
[]
[phase_collision]
type = LBMBGKCollision
buffer = h_post_collision
f = h
feq = h_eq
tau0 = tau_h
[]
[apply_forces_phase]
type = LBMAllenCahnSource
buffer = h_post_collision
phi = phi
velocity = velocity
grad_phi = grad_phi
tau = tau_h
thickness = D
[]
# Hydrodynamics
[relaxation_tensor]
type = ParsedCompute
buffer = relaxation_tensor
extra_symbols = true
expression = '(phi*(nu_l - nu_g) + nu_g)/cs2+0.5'
constant_names = 'nu_l nu_g cs2'
constant_expressions = '${nu_l} ${nu_g} 0.3333'
inputs = phi
[]
[pressure]
type = LBMPhaseFieldPressure
buffer = pressure
f = f
velocity = velocity
grad_phi = grad_phi
rho = rho
rho_l = '${rho_l}'
rho_g = '${rho_g}'
[]
[f_eq]
type = LBMPressureCorrectedEquilibrium
buffer = f_eq
rho = rho
velocity = velocity
pressure = pressure
[]
[collision]
type = LBMBGKCollision
buffer = f_post_collision
f = f
feq = f_eq
tau0 = 1.0
is_dynamic_relaxation = true
tau_tensor = relaxation_tensor
[]
[apply_forces_hydro]
type = LBMForceDistribution
buffer = f_post_collision
grad_phi = grad_phi
velocity = velocity
forces = forces
tau_tensor = relaxation_tensor
tau = 1.0
rho_l = '${rho_l}'
rho_g = '${rho_g}'
is_dynamic_relaxation = true
[]
[]
[TensorSolver]
type = LBMStream
buffer = 'h f'
f_old = 'h_post_collision f_post_collision'
[]
[Postprocessors]
[phi_min]
type = TensorExtremeValuePostprocessor
buffer = phi
value_type = MIN
[]
[phi_max]
type = TensorExtremeValuePostprocessor
buffer = phi
value_type = MAX
[]
[density_min]
type = TensorExtremeValuePostprocessor
buffer = rho
value_type = MIN
[]
[density_max]
type = TensorExtremeValuePostprocessor
buffer = rho
value_type = MAX
[]
[]
[Problem]
type = LatticeBoltzmannProblem
substeps = 5
print_debug_output = true
scalar_constant_names = 'tau_h D sigma'
scalar_constant_values = '${tau_h} ${D} ${sigma}'
[]
[Executioner]
type = Transient
num_steps = 5
[]
[Outputs]
file_base = phase
csv = true
[]
(test/tests/implicit_fd/biharmonic_mode.i)
# Backward Euler for u_t = -M kappa Laplacian(Laplacian(u)) of a single periodic
# Fourier mode. The mode is an eigenvector of the discrete Laplacian with
# eigenvalue -lambda_h, so of the discrete biharmonic with eigenvalue lambda_h^2,
# and every implicit step must multiply it by exactly
# g = 1 / (1 + dt M kappa lambda_h^2), up to the linear solver tolerance.
Mkappa = 1e-3
dt = 0.01
n = 32
stencil = 3
# Symbol of -Laplacian per axis for the wavenumber 2 pi, h = 1/n (see be_mode.i)
lambda3 = '${fparse n^2 * (2 - 2 * cos(2 * pi / n))}'
lambda5 = '${fparse n^2 * (5 / 2 - 8 / 3 * cos(2 * pi / n) + 1 / 6 * cos(4 * pi / n))}'
lambda = '${fparse 2 * if(stencil = 3, lambda3, lambda5)}'
[Domain]
dim = 2
nx = ${n}
ny = ${n}
xmax = 1
ymax = 1
parallel_mode = REAL_SPACE
periodic_directions = 'X Y'
[]
[TensorBuffers]
[u]
[]
[dudt_u]
[]
[bih_u]
[]
[gold]
[]
[diff]
[]
[]
[TensorComputes]
[Initialize]
[u_ic]
type = ParsedCompute
buffer = u
expression = 'sin(2*pi*x)*sin(2*pi*y)'
extra_symbols = true
[]
[]
[Solve]
[dudt]
type = TimeDerivativeOperator
buffer = dudt_u
input = u
[]
[bih]
type = FiniteDifferenceBiharmonic
buffer = bih_u
input = u
factor = ${Mkappa}
stencil_width = ${stencil}
[]
[]
[Postprocess]
[gold_compute]
type = ParsedCompute
buffer = gold
expression = 'sin(2*pi*x)*sin(2*pi*y) * g^(t / dt)'
constant_names = 'g dt'
constant_expressions = '${fparse 1 / (1 + dt * Mkappa * lambda^2)} ${dt}'
extra_symbols = true
[]
[diff_compute]
type = ParsedCompute
buffer = diff
expression = 'abs(u - gold)'
inputs = 'u gold'
[]
[]
[]
[TensorSolver]
type = ImplicitFDSolver
buffer = u
operators = 'dudt bih'
root_compute = dudt
[]
[Postprocessors]
[max_error]
type = TensorExtremeValuePostprocessor
buffer = diff
value_type = MAX
[]
[max_gold]
type = TensorExtremeValuePostprocessor
buffer = gold
value_type = MAX
[]
[]
[Problem]
type = TensorProblem
[]
[Executioner]
type = Transient
num_steps = 10
dt = ${dt}
[]
[Outputs]
csv = true
[]
(examples/lbm/Phase-field/static_bubble_3d.i)
#
# 3D Static bubble test case
# Based on the 2D static bubble (PHYSICAL REVIEW E 97, 033309 - Section III.A)
# Small domain to verify 3D gradient/laplacian correctness
#
# Domain (small for quick testing)
Nx = 40
Ny = 40
Nz = 40
# Bubble parameters
Cx = '${Nx}/2.0'
Cy = '${Ny}/2.0'
Cz = '${Nz}/2.0'
R = 12
# Fluid properties
rho_l = 1000.0
rho_g = 1.0
nu_l = 0.1
nu_g = 0.1
sigma = 0.001
# Phase field parameters
tau_h = 0.7
D = 4
[Domain]
dim = 3
nx = '${Nx}'
ny = '${Ny}'
nz = '${Nz}'
xmax = '${Nx}'
ymax = '${Ny}'
zmax = '${Nz}'
device_names = 'cpu'
parallel_mode = REAL_SPACE
periodic_directions = 'X Y Z'
[]
[Stencil]
[d3q27]
type = LBMD3Q27
[]
[]
[TensorBuffers]
# Macroscopic phase field variables
[phi]
type = LBMTensorBuffer
buffer_type = ms
[]
[grad_phi]
type = LBMTensorBuffer
buffer_type = mv
[]
[laplacian_phi]
type = LBMTensorBuffer
buffer_type = ms
[]
[mu]
type = LBMTensorBuffer
buffer_type = ms
[]
[forces]
type = LBMTensorBuffer
buffer_type = mv
[]
# Macroscopic hydrodynamic variables
[velocity]
type = LBMTensorBuffer
buffer_type = mv
[]
[pressure]
type = LBMTensorBuffer
buffer_type = ms
[]
[rho]
type = LBMTensorBuffer
buffer_type = ms
[]
# LBM phase field variables
[h]
type = LBMTensorBuffer
buffer_type = df
[]
[h_post_collision]
type = LBMTensorBuffer
buffer_type = df
[]
[h_eq]
type = LBMTensorBuffer
buffer_type = df
[]
[relaxation_tensor]
type = LBMTensorBuffer
buffer_type = ms
[]
# LBM hydrodynamic variables
[f]
type = LBMTensorBuffer
buffer_type = df
[]
[f_post_collision]
type = LBMTensorBuffer
buffer_type = df
[]
[f_eq]
type = LBMTensorBuffer
buffer_type = df
[]
[]
[TensorComputes/Initialize]
[phi_init]
type = ParsedCompute
buffer = phi
expression = '0.5 + 0.5 * tanh(2*(R - sqrt((x - Cx)^2 + (y - Cy)^2 + (z - Cz)^2)) / D)'
constant_names = 'Cx Cy Cz R D'
constant_expressions = '${Cx} ${Cy} ${Cz} ${R} ${D}'
extra_symbols = true
[]
[grad_phi_init]
type = LBMIsotropicGradient
buffer = grad_phi
scalar_field = phi
[]
[rho_init]
type = ParsedCompute
buffer = rho
extra_symbols = true
expression = 'phi*(rho_l - rho_g) + rho_g'
constant_names = 'rho_l rho_g'
constant_expressions = '${rho_l} ${rho_g}'
inputs = phi
[]
[pressure_init]
type = LBMConstantTensor
buffer = pressure
constants = 0.3
[]
[h_eq_init]
type = LBMPhaseEquilibrium
buffer = h_eq
phi = phi
velocity = velocity
[]
[h_post_collision_init]
type = LBMPhaseEquilibrium
buffer = h_post_collision
phi = phi
velocity = velocity
[]
[h_init]
type = LBMPhaseEquilibrium
buffer = h
phi = phi
velocity = velocity
[]
[f_eq_init]
type = LBMPressureCorrectedEquilibrium
buffer = f_eq
rho = rho
velocity = velocity
pressure = pressure
[]
[f_post_collision_init]
type = ParsedCompute
buffer = f_post_collision
expression = 'f_eq'
inputs = f_eq
[]
[f_init]
type = ParsedCompute
buffer = f
expression = 'f_eq'
inputs = f_eq
[]
[]
[TensorComputes/Solve]
# Phase Field
[compute_phi]
type = LBMComputeDensity
buffer = phi
f = h
[]
[grad_phi]
type = LBMIsotropicGradient
buffer = grad_phi
scalar_field = phi
[]
[laplacian_phi]
type = LBMIsotropicLaplacian
buffer = laplacian_phi
scalar_field = phi
[]
[potential]
type = LBMComputeChemicalPotential
buffer = mu
phi = phi
laplacian_phi = laplacian_phi
thickness = D
sigma = sigma
[]
[forces]
type = LBMComputeSurfaceForces
buffer = forces
chemical_potential = mu
grad_phi = grad_phi
[]
# Hydrodynamics
[density]
type = ParsedCompute
buffer = rho
extra_symbols = true
expression = 'phi*(rho_l - rho_g) + rho_g'
constant_names = 'rho_l rho_g'
constant_expressions = '${rho_l} ${rho_g}'
inputs = phi
[]
[velocity]
type = LBMComputeVelocity
buffer = velocity
f = f
rho = rho
enable_forces = true
forces = forces
[]
[h_eq]
type = LBMPhaseEquilibrium
buffer = h_eq
phi = phi
velocity = velocity
[]
[phase_collision]
type = LBMBGKCollision
buffer = h_post_collision
f = h
feq = h_eq
tau0 = tau_h
[]
[apply_forces_phase]
type = LBMAllenCahnSource
buffer = h_post_collision
phi = phi
velocity = velocity
grad_phi = grad_phi
tau = tau_h
thickness = D
[]
[relaxation_tensor]
type = ParsedCompute
buffer = relaxation_tensor
extra_symbols = true
expression = '(phi*(nu_l - nu_g) + nu_g)/cs2+0.5'
constant_names = 'nu_l nu_g cs2'
constant_expressions = '${nu_l} ${nu_g} 0.3333'
inputs = phi
[]
[pressure]
type = LBMPhaseFieldPressure
buffer = pressure
f = f
velocity = velocity
grad_phi = grad_phi
rho = rho
rho_l = '${rho_l}'
rho_g = '${rho_g}'
[]
[f_eq]
type = LBMPressureCorrectedEquilibrium
buffer = f_eq
rho = rho
velocity = velocity
pressure = pressure
[]
[collision]
type = LBMBGKCollision
buffer = f_post_collision
f = f
feq = f_eq
tau0 = 1.0
is_dynamic_relaxation = true
tau_tensor = relaxation_tensor
[]
[apply_forces_hydro]
type = LBMForceDistribution
buffer = f_post_collision
grad_phi = grad_phi
velocity = velocity
forces = forces
tau_tensor = relaxation_tensor
tau = 1.0
rho_l = '${rho_l}'
rho_g = '${rho_g}'
is_dynamic_relaxation = true
[]
[]
[TensorSolver]
type = LBMStream
buffer = 'h f'
f_old = 'h_post_collision f_post_collision'
[]
[Postprocessors]
[velocity_min]
type = TensorExtremeValuePostprocessor
buffer = velocity
value_type = MIN
[]
[velocity_max]
type = TensorExtremeValuePostprocessor
buffer = velocity
value_type = MAX
[]
[density_min]
type = TensorExtremeValuePostprocessor
buffer = rho
value_type = MIN
[]
[density_max]
type = TensorExtremeValuePostprocessor
buffer = rho
value_type = MAX
[]
[]
[Problem]
type = LatticeBoltzmannProblem
substeps = 10
print_debug_output = true
scalar_constant_names = 'tau_h D sigma'
scalar_constant_values = '${tau_h} ${D} ${sigma}'
residual_tensor = speed
[]
[Executioner]
type = Transient
num_steps = 50
[]
[TensorOutputs]
[xdmf]
type = XDMFTensorOutput
buffer = 'phi rho velocity forces'
output_mode = 'Cell Cell Cell Cell'
enable_hdf5 = true
# transpose = false
[]
[]
(examples/anisotropic_grain_growth/spherical_grain_Ni.i)
interface_width = 1.6
r0 = 7.5
# Ni
gbe_max = '${units 0.8797226 J/m^2}'
L = '${fparse 1.0 * 1.6 / ${interface_width}}'
g_gamma0 = '${fparse sqrt(2) / 3}' # g(gamma=1.5)
f0_gamma0 = ${fparse 1/8}
kappa = '${fparse gbe_max * interface_width * sqrt(f0_gamma0) / g_gamma0}'
mu = '${fparse gbe_max / (g_gamma0 * interface_width * sqrt(f0_gamma0))}'
g_to_gamma_func = '(1.0/(-3.0944 * g^8 -1.8169*g^6 + 10.323 * g^4 - 8.1819*g^2 + 2.0033))'
dgamma_dsigma = '(g * (24.7552*g^6 + 10.9014*g^4 - 41.292*g^2 + 16.3638) / (-3.0944*g^8 - 1.8169*g^6 + 10.323*g^4 - 8.1819*g^2 + 2.0033)^2 / sqrt(${kappa} * ${mu}))'
f0 = '((gr0^4/4 - gr0^2/2) + (gr1^4/4 - gr1^2/2) + gamma_01*gr0^2*gr1^2 + 0.25)'
[Domain]
dim = 3
nx = 100
ny = 100
nz = 100
xmax = 20
ymax = 20
zmax = 20
mesh_mode = DUMMY
[]
[TensorComputes]
[Initialize]
[gr0]
type = ParsedCompute
buffer = 'gr0'
extra_symbols = 'true'
expression = 'radius:=sqrt((x-${Domain/xmax}/2)^2+(y-${Domain/ymax}/2)^2+(z-${Domain/zmax}/2)^2);0.5 - 0.5*tanh(2*(radius-${r0})/${interface_width})'
[]
[gr1]
type = ParsedCompute
buffer = 'gr1'
extra_symbols = 'true'
expression = 'radius:=sqrt((x-${Domain/xmax}/2)^2+(y-${Domain/ymax}/2)^2+(z-${Domain/zmax}/2)^2);0.5 + 0.5*tanh(2*(radius-${r0})/${interface_width})'
[]
[L_kappa_laplacian]
type = ReciprocalLaplacianFactor
buffer = L_kappa_laplacian
factor = ${fparse ${L} * ${kappa}}
[]
[kappa_laplacian]
type = ReciprocalLaplacianFactor
buffer = kappa_laplacian
factor = '${kappa}'
[]
[smooth]
type = DeAliasingTensor
method = HOULI
buffer = smooth
[]
[]
[Solve]
## FFT
[gr0_bar]
type = ForwardFFT
buffer = gr0_bar
input = gr0
[]
[gr1_bar]
type = ForwardFFT
buffer = gr1_bar
input = gr1
[]
[gr0_bar_smooth]
type = ParsedCompute
buffer = gr0_bar_smooth
expression = 'gr0_bar * smooth'
inputs = 'gr0_bar smooth'
[]
[gr1_bar_smooth]
type = ParsedCompute
buffer = gr1_bar_smooth
expression = 'gr1_bar * smooth'
inputs = 'gr1_bar smooth'
[]
# Gradients
[grad_gr0]
type = GradientVector
buffer = grad_gr0
input = gr0_bar_smooth
input_is_reciprocal = true
[]
[grad_gr1]
type = GradientVector
buffer = grad_gr1
input = gr1_bar_smooth
input_is_reciprocal = true
[]
# Get interface energy
[sigma_gr0_gr1]
type = PairwiseAnisotropicGBEnergy
buffer = 'sigma_gr0_gr1'
dsigma_dgrad_grain1 = 'dsigma_gr0_gr1_dgrad_gr0'
dsigma_dgrad_grain2 = 'dsigma_gr0_gr1_dgrad_gr1'
grad_grain1_buffer = 'grad_gr0'
grad_grain2_buffer = 'grad_gr1'
interface_width = '${interface_width}'
libtorch_model_file = 'marlin:anisotropic_gb_energy/Ni_R1_R3.pt'
chunk_size = 1e5
[]
[gamma_01]
type = ParsedCompute
buffer = 'gamma_01'
expression = 'g:=sigma_gr0_gr1/sqrt(${kappa}*${mu});${g_to_gamma_func}'
inputs = 'sigma_gr0_gr1'
[]
[coeff_01]
type = ParsedCompute
buffer = 'coeff_01'
expression = 'g:=sigma_gr0_gr1/sqrt(${kappa}*${mu});${dgamma_dsigma} * gr0^2 *gr1^2'
inputs = 'sigma_gr0_gr1 gr0 gr1'
[]
[torque_01_gr0]
type = AnisotropyTorque
buffer = torque_01_gr0
dmu_dn = dsigma_gr0_gr1_dgrad_gr0
g = 'coeff_01'
[]
[torque_01_gr1]
type = AnisotropyTorque
buffer = torque_01_gr1
dmu_dn = dsigma_gr0_gr1_dgrad_gr1
g = 'coeff_01'
[]
[kappa_laplacian_gr0_hat]
type = ParsedCompute
buffer = kappa_laplacian_gr0_hat
inputs = 'gr0_bar kappa_laplacian'
expression = 'gr0_bar * kappa_laplacian'
[]
[kappa_laplacian_gr1_hat]
type = ParsedCompute
buffer = kappa_laplacian_gr1_hat
inputs = 'gr1_bar kappa_laplacian'
expression = 'gr1_bar * kappa_laplacian'
[]
[kappa_laplacian_gr0]
type = InverseFFT
buffer = kappa_laplacian_gr0
input = kappa_laplacian_gr0_hat
[]
[kappa_laplacian_gr1]
type = InverseFFT
buffer = kappa_laplacian_gr1
input = kappa_laplacian_gr1_hat
[]
[gr0_bulk_term]
type = ParsedCompute
buffer = 'gr0_bulk_term'
expression = 'L_NL:=${L}*(sigma_gr0_gr1)/${gbe_max};-L_NL*${mu} * (gr0^3 - gr0 + 2*gr0*(gamma_01*gr1^2) - torque_01_gr0) + (L_NL - ${L})*kappa_laplacian_gr0'
inputs = 'gr0 gr1 gamma_01 torque_01_gr0 sigma_gr0_gr1 kappa_laplacian_gr0'
[]
[gr1_bulk_term]
type = ParsedCompute
buffer = 'gr1_bulk_term'
expression = 'L_NL:=${L}*(sigma_gr0_gr1)/${gbe_max};-L_NL*${mu} * (gr1^3 - gr1 + 2*gr1*(gamma_01*gr0^2) - torque_01_gr1) + (L_NL - ${L})*kappa_laplacian_gr1'
inputs = 'gr0 gr1 gamma_01 torque_01_gr1 sigma_gr0_gr1 kappa_laplacian_gr1'
[]
## build non-linear terms and smooth them
[NL_gr0]
type = ForwardFFT
buffer = NL_gr0
input = 'gr0_bulk_term'
[]
[NL_gr1]
type = ForwardFFT
buffer = NL_gr1
input = 'gr1_bulk_term'
[]
[NL_gr0_smooth]
type = ParsedCompute
buffer = NL_gr0_smooth
expression = 'smooth*NL_gr0'
inputs = 'smooth NL_gr0'
[]
[NL_gr1_smooth]
type = ParsedCompute
buffer = NL_gr1_smooth
expression = 'smooth*NL_gr1'
inputs = 'smooth NL_gr1'
[]
# Properties for output
[sigma]
type = ParsedCompute
buffer = 'sigma'
expression = 'gr0^2*gr1^2*sigma_gr0_gr1'
inputs = 'sigma_gr0_gr1 gr0 gr1'
[]
[gradient_energy]
type = GradientEnergyDensity
buffer = gradient_energy
gradient_buffers = 'grad_gr0 grad_gr1'
kappa = ${kappa}
[]
[total_energy]
type = ParsedCompute
buffer = 'total_energy'
expression = '${mu} * (${f0}) + gradient_energy'
inputs = 'gr0 gr1 gamma_01 gradient_energy'
[]
[]
[]
[Postprocessors]
[total_gb_energy]
type = TensorIntegralPostprocessor
buffer = total_energy
[]
[]
[TensorSolver]
type = AdamsBashforthMoulton
buffer = 'gr0 gr1'
reciprocal_buffer = 'gr0_bar gr1_bar'
linear_reciprocal = 'L_kappa_laplacian L_kappa_laplacian'
nonlinear_reciprocal = 'NL_gr0_smooth NL_gr1_smooth'
substeps = 100
predictor_order = 2
corrector_order = 1
corrector_steps = 2
[]
[TensorOutputs]
[xdmf]
type = XDMFTensorOutput
buffer = 'gr0 gr1 sigma_gr0_gr1'
output_mode = 'NODE NODE NODE'
enable_hdf5 = true
transpose = false
[]
[]
[Executioner]
type = Transient
dt = 0.1
num_steps = 200
[]
[Outputs]
csv = true
execute_on = 'INITIAL TIMESTEP_END'
[]
(test/tests/postprocessors/interface_velocity.i)
[Domain]
dim = 2
nx = 10
ny = 2
xmax = '${fparse pi*4}'
mesh_mode = DUMMY
[]
[TensorComputes]
[Solve]
[c]
type = ParsedCompute
buffer = c
extra_symbols = true
expression = sin(x+0.2*t)
expand = REAL
[]
[]
[]
[Postprocessors]
[v]
type = TensorInterfaceVelocityPostprocessor
buffer = c
[]
[]
[Problem]
type = TensorProblem
[]
[Executioner]
type = Transient
num_steps = 10
dt = 0.01
[]
[Outputs]
csv = true
[]
(test/tests/lbm/phase_3D.i)
# Domain
Nx = 20
Ny = 20
Nz = 20
# Fluid properties
rho_l = 5.0
rho_g = 1.0
nu_l = 0.1
nu_g = 1.0
sigma = 0.2
# Phase field parameters
tau_h = 1.0
D = 4
[Domain]
dim = 3
nx = '${Nx}'
ny = '${Ny}'
nz = '${Nz}'
xmax = '${Nx}'
ymax = '${Ny}'
zmax = '${Nz}'
device_names='cpu'
parallel_mode = REAL_SPACE
periodic_directions = 'X Y Z'
[]
[Stencil]
[d3q27]
type = LBMD3Q27
[]
[]
[TensorBuffers]
# Macroscopic phase field variables
[phi]
type = LBMTensorBuffer
buffer_type = ms
[]
[grad_phi]
type = LBMTensorBuffer
buffer_type = mv
[]
[laplacian_phi]
type = LBMTensorBuffer
buffer_type = ms
[]
[mu]
type = LBMTensorBuffer
buffer_type = ms
[]
[forces]
type = LBMTensorBuffer
buffer_type = mv
[]
# Macroscopic hydrodynamic variables
[velocity]
type = LBMTensorBuffer
buffer_type = mv
[]
[pressure]
type = LBMTensorBuffer
buffer_type = ms
[]
[rho]
type = LBMTensorBuffer
buffer_type = ms
[]
# LBM phase field variabels
[h]
type = LBMTensorBuffer
buffer_type = df
[]
[h_post_collision]
type = LBMTensorBuffer
buffer_type = df
[]
[h_eq]
type = LBMTensorBuffer
buffer_type = df
[]
[relaxation_tensor]
type = LBMTensorBuffer
buffer_type = ms
[]
# LBM hydrodynamic variables
[fdummy]
type = LBMTensorBuffer
buffer_type = df
[]
[f]
type = LBMTensorBuffer
buffer_type = df
[]
[f_post_collision]
type = LBMTensorBuffer
buffer_type = df
[]
[f_eq]
type = LBMTensorBuffer
buffer_type = df
[]
[]
[TensorComputes/Initialize]
[phi_init]
type = ParsedCompute
buffer = phi
extra_symbols = true
expression = '0.3333 + 0.01*sin((12.9898*x + 78.233*y + 43.1201 *z)*2*pi)'
[]
[grad_phi_init]
type = LBMIsotropicGradient
buffer = grad_phi
scalar_field = phi
[]
[rho_init]
type = ParsedCompute
buffer = rho
extra_symbols = true
expression = 'phi*(rho_l - rho_g) + rho_g'
constant_names = 'rho_l rho_g'
constant_expressions = '${rho_l} ${rho_g}'
inputs = phi
[]
[pressure_init]
type = LBMConstantTensor
buffer = pressure
constants = 0.3
[]
# Phase field equilibrium distribution initialization
[h_eq_init]
type = LBMPhaseEquilibrium
buffer = h_eq
phi = phi
velocity = velocity
[]
[h_post_collision_init]
type = LBMPhaseEquilibrium
buffer = h_post_collision
phi = phi
velocity = velocity
[]
[h_init]
type = LBMPhaseEquilibrium
buffer = h
phi = phi
velocity = velocity
[]
# Hydrodynamic equilibrium distribution initialization
[f_eq_init]
type = LBMPressureCorrectedEquilibrium
buffer = f_eq
rho = rho
velocity = velocity
pressure = pressure
[]
[f_post_collision_init]
type = ParsedCompute
buffer = f_post_collision
expression = 'f_eq'
inputs = f_eq
[]
[f_init]
type = ParsedCompute
buffer = f
expression = 'f_eq'
inputs = f_eq
[]
[]
[TensorComputes/Solve]
# Phase Field
[compute_phi]
type = LBMComputeDensity
buffer = phi
f = h
[]
[grad_phi]
type = LBMIsotropicGradient
buffer = grad_phi
scalar_field = phi
[]
[laplacian_phi]
type = LBMIsotropicLaplacian
buffer = laplacian_phi
scalar_field = phi
[]
[potential]
type = LBMComputeChemicalPotential
buffer = mu
phi = phi
laplacian_phi = laplacian_phi
thickness = D
sigma = sigma
[]
[forces]
type = LBMComputeSurfaceForces
buffer = forces
chemical_potential = mu
grad_phi = grad_phi
[]
# Hydrodynamics
[density]
type = ParsedCompute
buffer = rho
extra_symbols = true
expression = 'phi*(rho_l - rho_g) + rho_g'
constant_names = 'rho_l rho_g'
constant_expressions = '${rho_l} ${rho_g}'
inputs = phi
[]
[velocity]
type = LBMComputeVelocity
buffer = velocity
f = f
rho = rho
enable_forces = true
forces = forces
[]
# Phase-field
[h_eq]
type = LBMPhaseEquilibrium
buffer = h_eq
phi = phi
velocity = velocity
[]
[phase_collision]
type = LBMBGKCollision
buffer = h_post_collision
f = h
feq = h_eq
tau0 = tau_h
[]
[apply_forces_phase]
type = LBMAllenCahnSource
buffer = h_post_collision
phi = phi
velocity = velocity
grad_phi = grad_phi
tau = tau_h
thickness = D
[]
# Hydrodynamics
[relaxation_tensor]
type = ParsedCompute
buffer = relaxation_tensor
extra_symbols = true
expression = '(phi*(nu_l - nu_g) + nu_g)/cs2+0.5'
constant_names = 'nu_l nu_g cs2'
constant_expressions = '${nu_l} ${nu_g} 0.3333'
inputs = phi
[]
[pressure]
type = LBMPhaseFieldPressure
buffer = pressure
f = f
velocity = velocity
grad_phi = grad_phi
rho = rho
rho_l = '${rho_l}'
rho_g = '${rho_g}'
[]
[f_eq]
type = LBMPressureCorrectedEquilibrium
buffer = f_eq
rho = rho
velocity = velocity
pressure = pressure
[]
[collision]
type = LBMBGKCollision
buffer = f_post_collision
f = f
feq = f_eq
tau0 = 1.0
is_dynamic_relaxation = true
tau_tensor = relaxation_tensor
[]
[apply_forces_hydro]
type = LBMForceDistribution
buffer = f_post_collision
grad_phi = grad_phi
velocity = velocity
forces = forces
tau_tensor = relaxation_tensor
tau = 1.0
rho_l = '${rho_l}'
rho_g = '${rho_g}'
is_dynamic_relaxation = true
[]
[]
[TensorSolver]
type = LBMStream
buffer = 'h f'
f_old = 'h_post_collision f_post_collision'
[]
[Postprocessors]
[phi_min]
type = TensorExtremeValuePostprocessor
buffer = phi
value_type = MIN
[]
[phi_max]
type = TensorExtremeValuePostprocessor
buffer = phi
value_type = MAX
[]
[density_min]
type = TensorExtremeValuePostprocessor
buffer = rho
value_type = MIN
[]
[density_max]
type = TensorExtremeValuePostprocessor
buffer = rho
value_type = MAX
[]
[velocity_min]
type = TensorExtremeValuePostprocessor
buffer = velocity
value_type = MIN
[]
[velocity_max]
type = TensorExtremeValuePostprocessor
buffer = velocity
value_type = MAX
[]
[]
[Problem]
type = LatticeBoltzmannProblem
substeps = 5
print_debug_output = true
scalar_constant_names = 'tau_h D sigma'
scalar_constant_values = '${tau_h} ${D} ${sigma}'
[]
[Executioner]
type = Transient
num_steps = 5
[]
[Outputs]
file_base = phase_3D
csv = true
[]
(test/tests/tensor_compute/parallel_roundtrip.i)
[Domain]
# Test parallel FFT round-trip with slab decomposition
device_names = "cpu cpu cpu"
device_weights = "1 1 1"
parallel_mode = FFT_SLAB
dim = 2
nx = 128
ny = 128
xmax = ${fparse pi*4}
ymax = ${fparse pi*4}
[]
[TensorBuffers]
[eta_gold]
[]
[eta]
[]
[eta_bar]
[]
[eta_roundtrip]
[]
[diff]
[]
[zero]
[]
[]
[TensorComputes]
[Initialize]
[eta_gold]
type = ParsedCompute
buffer = eta_gold
expression = 'sin(x)+sin(y)+cos(2*x)*sin(3*y)'
extra_symbols = true
[]
[eta]
type = ParsedCompute
buffer = eta
expression = eta_gold
inputs = eta_gold
[]
[zero]
type = ConstantReciprocalTensor
buffer = zero
real = 0
imaginary = 0
[]
[]
[Solve]
# Test: eta -> FFT -> iFFT -> eta_roundtrip
# eta_roundtrip should equal eta (within numerical precision)
[eta_bar]
type = ForwardFFT
buffer = eta_bar
input = eta
[]
[eta_roundtrip]
type = InverseFFT
buffer = eta_roundtrip
input = eta_bar
[]
[]
[Postprocess]
[diff]
type = ParsedCompute
buffer = diff
expression = 'abs(eta - eta_roundtrip) + abs(eta - eta_gold)'
inputs = 'eta eta_roundtrip eta_gold'
[]
[]
[]
[Postprocessors]
[max_error]
type = TensorExtremeValuePostprocessor
buffer = diff
value_type = MAX
[]
[l2_error]
type = TensorIntegralPostprocessor
buffer = diff
[]
[]
[TensorSolver]
type = AdamsBashforthMoulton
buffer = eta
reciprocal_buffer = eta_bar
linear_reciprocal = zero
nonlinear_reciprocal = zero
[]
[Problem]
type = TensorProblem
[]
[Executioner]
type = Transient
num_steps = 1
[]
[Outputs]
csv = true
execute_on = 'INITIAL TIMESTEP_END'
[]
(test/tests/real_space/diffusion.i)
[Domain]
dim = 2
nx = 80
ny = 60
parallel_mode = REAL_SPACE
periodic_directions = 'X Y'
xmin = -1
ymin = -1
xmax = 1
ymax = 1
[]
[TensorComputes]
[Initialize]
[u_ic]
type = ParsedCompute
buffer = u
expression = 'exp((-x^2-y^2)*100)'
extra_symbols = true
[]
[]
[Solve]
[dt]
type = FiniteDifferenceLaplacian
input = u
buffer = dudt
[]
[]
[]
[TensorSolver]
type = RealSpaceForwardEuler
buffer = u
time_derivative = dudt
substeps = 100
[]
[Postprocessors]
[max_u]
type = TensorExtremeValuePostprocessor
buffer = u
value_type = MAX
execute_on = 'INITIAL TIMESTEP_END'
[]
[U]
type = TensorIntegralPostprocessor
buffer = u
execute_on = 'INITIAL TIMESTEP_END'
[]
[]
[TensorOutputs]
# active = ''
[u]
type = XDMFTensorOutput
buffer = 'u dudt'
enable_hdf5 = true
[]
[]
[Executioner]
type = Transient
dt = 1e-2
num_steps = 100
[]
[Outputs]
[out]
type = CSV
[]
[]
(test/tests/real_space/thin_slab_diffusion.i)
# Verification against Crank, "The Mathematics of Diffusion" (2nd ed.), Sec. 2.5,
# eq. (2.15): an instantaneous planar source of concentration C0 confined initially
# to a thin slab -h < x < h, diffusing into an infinite medium, has the exact solution
# C(x, t) = (C0/2) * { erf[(h-x)/(2*sqrt(D*t))] + erf[(h+x)/(2*sqrt(D*t))] }
#
# Pseudo-1D (ny = 1, Y periodic), D = 1, h = 1. The X faces are 10 diffusion lengths
# beyond the slab edge at the comparison time t = 1, so the far-field Dirichlet u = 0
# does not measurably affect the solution near the slab.
[Domain]
dim = 2
# dx = 0.1 puts the slab edges x = +/-1 on cell faces, so the box IC holds exactly
# the slab mass 2*h*C0 (nx = 200 leaves a ~1% deficit that does not refine away)
nx = 220
ny = 1
parallel_mode = REAL_SPACE
periodic_directions = 'Y'
xmin = -11
xmax = 11
ymin = -0.5
ymax = 0.5
[]
[TensorComputes]
[Initialize]
[u_ic]
type = ParsedCompute
buffer = u
# C0 = 1 inside the slab |x| < h = 1, zero outside
expression = 'if(abs(x) < 1, 1, 0) + 0*y'
extra_symbols = true
[]
[]
[BCs]
[left]
type = TensorDirichletBC
variable = u
boundary = left
value = 0
[]
[right]
type = TensorDirichletBC
variable = u
boundary = right
value = 0
[]
[]
[Solve]
[dt]
type = FiniteDifferenceLaplacian
input = u
buffer = dudt
factor = 1
[]
[u_exact]
type = ParsedCompute
buffer = u_exact
expression = '0.5 * (erf((1 - x) / (2 * sqrt(t))) + erf((1 + x) / (2 * sqrt(t)))) + 0*y'
extra_symbols = true
[]
[diff]
type = ParsedCompute
buffer = diff
expression = 'abs(u - u_exact)'
inputs = 'u u_exact'
[]
[]
[]
[TensorSolver]
type = RealSpaceForwardEuler
buffer = u
time_derivative = dudt
# dx = 0.1; explicit-diffusion CFL limit dt_cfl = dx^2/(2*D) = 5e-3,
# requiring >= dt/dt_cfl = 200 substeps for dt = 1; 250 gives a safety margin.
substeps = 250
[]
[Postprocessors]
[max_error]
type = TensorExtremeValuePostprocessor
buffer = diff
value_type = MAX
execute_on = 'TIMESTEP_END'
[]
[]
[Executioner]
type = Transient
dt = 1
num_steps = 1
[]
[Outputs]
[out]
type = CSV
[]
[]
(examples/lbm/Phase-field/layered_poiseuille.i)
#
# Layered Poiseuille Flow
# PHYSICAL REVIEW E 97, 033309 (2018) - Section III.B
#
# Domain
Nx = 10
Ny = 400
# Fluid properties
rho_l = 1000.0
rho_g = 1.0
# nu_l = 0.1
# nu_g = 1.0
sigma = 0.001
mu_l = 100.0 # rho_l * nu_l
mu_g = 1.0 # rho_g * nu_g
# Phase field parameters
# M = 0.1
# cs2 = 0.333333333333
tau_h = 0.8 # 0.5 + '${M}' / '${cs2}'
D = 5
# Driving force: Gx = uc * (mu_l + mu_g) / h^2
# uc = 1e-4
# h = # '${Ny} / 2'
Gx = 2.53e-07 # '${uc} * (${mu_l} + ${mu_g}) / (${h}^2)'
[Domain]
dim = 2
nx = '${Nx}'
ny = '${Ny}'
xmax = '${Nx}'
ymax = '${Ny}'
device_names = 'cpu'
parallel_mode = REAL_SPACE
periodic_directions = 'X Y'
[]
[Stencil]
[d2q9]
type = LBMD2Q9
[]
[]
[TensorBuffers]
# Macroscopic phase field variables
[phi]
type = LBMTensorBuffer
buffer_type = ms
file = phi_init.h5
[]
[grad_phi]
type = LBMTensorBuffer
buffer_type = mv
[]
[laplacian_phi]
type = LBMTensorBuffer
buffer_type = ms
[]
[mu]
type = LBMTensorBuffer
buffer_type = ms
[]
[forces]
type = LBMTensorBuffer
buffer_type = mv
[]
[body_force]
type = LBMTensorBuffer
buffer_type = mv
[]
# Macroscopic hydrodynamic variables
[velocity]
type = LBMTensorBuffer
buffer_type = mv
[]
[speed]
type = LBMTensorBuffer
buffer_type = ms
[]
[pressure]
type = LBMTensorBuffer
buffer_type = ms
[]
[rho]
type = LBMTensorBuffer
buffer_type = ms
[]
# LBM phase field variables
[h]
type = LBMTensorBuffer
buffer_type = df
[]
[h_post_collision]
type = LBMTensorBuffer
buffer_type = df
[]
[h_eq]
type = LBMTensorBuffer
buffer_type = df
[]
[relaxation_tensor]
type = LBMTensorBuffer
buffer_type = ms
[]
# LBM hydrodynamic variables
[f]
type = LBMTensorBuffer
buffer_type = df
[]
[f_post_collision]
type = LBMTensorBuffer
buffer_type = df
[]
[f_eq]
type = LBMTensorBuffer
buffer_type = df
[]
[]
[TensorComputes/Initialize]
[grad_phi_init]
type = LBMIsotropicGradient
buffer = grad_phi
scalar_field = phi
[]
[rho_init]
type = ParsedCompute
buffer = rho
expression = 'phi * (rho_l - rho_g) + rho_g'
constant_names = 'rho_l rho_g'
constant_expressions = '${rho_l} ${rho_g}'
inputs = phi
[]
[pressure_init]
type = LBMConstantTensor
buffer = pressure
constants = 0.3
[]
[body_force_init]
type = LBMConstantTensor
buffer = body_force
constants = '${Gx} 0.00'
[]
# Phase field equilibrium distribution initialization
[h_eq_init]
type = LBMPhaseEquilibrium
buffer = h_eq
phi = phi
velocity = velocity
[]
[h_post_collision_init]
type = LBMPhaseEquilibrium
buffer = h_post_collision
phi = phi
velocity = velocity
[]
[h_init]
type = LBMPhaseEquilibrium
buffer = h
phi = phi
velocity = velocity
[]
# Hydrodynamic equilibrium distribution initialization
[f_eq_init]
type = LBMPressureCorrectedEquilibrium
buffer = f_eq
rho = rho
velocity = velocity
pressure = pressure
[]
[f_post_collision_init]
type = ParsedCompute
buffer = f_post_collision
expression = 'f_eq'
inputs = f_eq
[]
[f_init]
type = ParsedCompute
buffer = f
expression = 'f_eq'
inputs = f_eq
[]
[]
[TensorComputes/Solve]
# Phase Field
[compute_phi]
type = LBMComputeDensity
buffer = phi
f = h
[]
[grad_phi]
type = LBMIsotropicGradient
buffer = grad_phi
scalar_field = phi
[]
[laplacian_phi]
type = LBMIsotropicLaplacian
buffer = laplacian_phi
scalar_field = phi
[]
[potential]
type = LBMComputeChemicalPotential
buffer = mu
phi = phi
laplacian_phi = laplacian_phi
thickness = D
sigma = sigma
[]
[compute_forces]
type = LBMComputeSurfaceForces
buffer = forces
chemical_potential = mu
grad_phi = grad_phi
[]
[add_body_force]
type = ParsedCompute
buffer = forces
expression = 'forces + body_force'
inputs = 'forces body_force'
[]
# Hydrodynamics
[density]
type = ParsedCompute
buffer = rho
expression = 'phi * (rho_l - rho_g) + rho_g'
constant_names = 'rho_l rho_g'
constant_expressions = '${rho_l} ${rho_g}'
inputs = phi
[]
[velocity]
type = LBMComputeVelocity
buffer = velocity
f = f
rho = rho
enable_forces = true
forces = forces
# add_body_force = true
# body_force_x = '${Gx}'
[]
# Phase-field
[h_eq]
type = LBMPhaseEquilibrium
buffer = h_eq
phi = phi
velocity = velocity
[]
[phase_collision]
type = LBMBGKCollision
buffer = h_post_collision
f = h
feq = h_eq
tau0 = tau_h
[]
[apply_forces_phase]
type = LBMAllenCahnSource
buffer = h_post_collision
phi = phi
velocity = velocity
grad_phi = grad_phi
tau = tau_h
thickness = D
[]
# Hydrodynamics
[relaxation_tensor]
type = ParsedCompute
buffer = relaxation_tensor
# Implements Eq 26: Sharp step-function for dynamic viscosity
expression = '(if(phi >= 0.5, mu_l, mu_g) / rho) / cs2 + 0.5'
constant_names = 'mu_l mu_g cs2'
constant_expressions = '${mu_l} ${mu_g} 0.333333333333'
inputs = 'phi rho'
[]
[pressure]
type = LBMPhaseFieldPressure
buffer = pressure
f = f
velocity = velocity
grad_phi = grad_phi
rho = rho
rho_l = '${rho_l}'
rho_g = '${rho_g}'
[]
[f_eq]
type = LBMPressureCorrectedEquilibrium
buffer = f_eq
rho = rho
velocity = velocity
pressure = pressure
[]
[collision]
type = LBMBGKCollision
buffer = f_post_collision
f = f
feq = f_eq
tau0 = 1.0
is_dynamic_relaxation = true
tau_tensor = relaxation_tensor
[]
[apply_forces_hydro]
type = LBMForceDistribution
buffer = f_post_collision
grad_phi = grad_phi
velocity = velocity
forces = forces
tau_tensor = relaxation_tensor
tau = 1.0
rho_l = '${rho_l}'
rho_g = '${rho_g}'
is_dynamic_relaxation = true
[]
[speed]
type = LBMComputeVelocityMagnitude
buffer = speed
velocity = velocity
[]
[]
[TensorComputes/Boundary]
[top_fluid]
type = LBMBounceBack
buffer = f
f_old = f_post_collision
boundary = top
[]
[bottom_fluid]
type = LBMBounceBack
buffer = f
f_old = f_post_collision
boundary = bottom
[]
[top_phase]
type = LBMBounceBack
buffer = h
f_old = h_post_collision
boundary = top
[]
[bottom_phase]
type = LBMBounceBack
buffer = h
f_old = h_post_collision
boundary = bottom
[]
[]
[TensorSolver]
type = LBMStream
buffer = 'h f'
f_old = 'h_post_collision f_post_collision'
[]
[Problem]
type = LatticeBoltzmannProblem
# Keep this low for this setup: high substeps with top/bottom bounce-back can blow up to NaN.
substeps = 100000
print_debug_output = true
scalar_constant_names = 'tau_h D sigma'
scalar_constant_values = '${tau_h} ${D} ${sigma}'
residual_tensor = speed
[]
[Executioner]
type = Transient
num_steps = 2
[]
[TensorOutputs]
[xdmf]
type = XDMFTensorOutput
buffer = 'phi velocity rho'
output_mode = 'Cell Cell Cell'
enable_hdf5 = true
transpose = false
[]
[]
(test/tests/tensor_compute/coupled_pf_mech.i)
[Domain]
dim = 3
nx = 128
ny = 128
nz = 128
xmax = ${fparse pi*4}
ymax = ${fparse pi*4}
zmax = ${fparse pi*4}
mesh_mode = DUMMY
[]
[TensorBuffers]
# phase field
[c]
[]
[cbar]
[]
[mu]
[]
[mubar]
[]
[Mbarmubar]
[]
# mechanics
[disp_x]
[]
[disp_y]
[]
[disp_z]
[]
[mumechbar]
[]
[mumech]
[]
# constant tensors
[Mbar]
[]
[kappabarbar]
[]
[]
[TensorOutputs]
[xdmf]
type = XDMFTensorOutput
buffer = 'c disp_x disp_y disp_z mu mumech'
output_mode = 'Node Node Node Node Cell Cell'
enable_hdf5 = true
[]
[]
[TensorComputes]
[Initialize]
[c]
type = RandomTensor
buffer = c
min = 0.44
max = 0.56
[]
[disp_x]
type = RandomTensor
buffer = disp_x
min = 0
max = 0
[]
[disp_y]
type = RandomTensor
buffer = disp_y
min = 0
max = 0
[]
[disp_z]
type = RandomTensor
buffer = disp_z
min = 0
max = 0
[]
[Mbar]
type = ReciprocalLaplacianFactor
factor = 0.2 # Mobility
buffer = Mbar
[]
[kappabarbar]
type = ReciprocalLaplacianSquareFactor
factor = -0.001 # kappa
buffer = kappabarbar
[]
[]
[Solve]
[mu]
# chemical potential (real space)
type = ParsedCompute
buffer = mu
expression = '0.1*c^2*(c-1)^2' # + c*sin(x/2)*0.005'
extra_symbols = true
derivatives = c
inputs = c
[]
[mubar]
# chemical potential (reciprocal space)
type = ForwardFFT
buffer = mubar
input = mu
[]
[mumechbar]
# mechanical chemical potential (reciprocal space)
type = FFTElasticChemicalPotential
buffer = mumechbar
cbar = cbar
displacements = 'disp_x disp_y disp_z'
lambda = 100
mu = 50
e0 = 0.02
[]
[mumech]
# chemical potential (reciprocal space)
type = InverseFFT
buffer = mumech
input = mumechbar
[]
[Mbarmubar]
type = ParsedCompute
buffer = Mbarmubar
expression = 'Mbar*(mubar+mumechbar)'
inputs = 'Mbar mubar mumechbar'
[]
[cbar]
type = ForwardFFT
buffer = cbar
input = c
[]
[qsmech]
type = FFTQuasistaticElasticity
displacements = 'disp_x disp_y disp_z'
cbar = cbar
lambda = 100
mu = 50
e0 = 0.02
[]
[]
[]
[TensorTimeIntegrators]
[c]
type = FFTSemiImplicit
buffer = c
reciprocal_buffer = cbar
linear_reciprocal = kappabarbar
nonlinear_reciprocal = Mbarmubar
[]
[]
[Postprocessors]
[min_c]
type = TensorExtremeValuePostprocessor
buffer = c
value_type = MIN
execute_on = 'TIMESTEP_END'
[]
[max_c]
type = TensorExtremeValuePostprocessor
buffer = c
value_type = MAX
execute_on = 'TIMESTEP_END'
[]
[min_disp_x]
type = TensorExtremeValuePostprocessor
buffer = disp_x
value_type = MIN
execute_on = 'TIMESTEP_END'
[]
[max_disp_x]
type = TensorExtremeValuePostprocessor
buffer = disp_x
value_type = MAX
execute_on = 'TIMESTEP_END'
[]
[min_disp_y]
type = TensorExtremeValuePostprocessor
buffer = disp_y
value_type = MIN
execute_on = 'TIMESTEP_END'
[]
[max_disp_y]
type = TensorExtremeValuePostprocessor
buffer = disp_y
value_type = MAX
execute_on = 'TIMESTEP_END'
[]
[min_disp_z]
type = TensorExtremeValuePostprocessor
buffer = disp_z
value_type = MIN
execute_on = 'TIMESTEP_END'
[]
[max_disp_z]
type = TensorExtremeValuePostprocessor
buffer = disp_z
value_type = MAX
execute_on = 'TIMESTEP_END'
[]
[C]
type = TensorIntegralPostprocessor
buffer = c
execute_on = 'TIMESTEP_END'
[]
[cavg]
type = TensorAveragePostprocessor
buffer = c
execute_on = 'TIMESTEP_END'
[]
[]
[Problem]
type = TensorProblem
spectral_solve_substeps = 1000
print_debug_output = true
[]
[Executioner]
type = Transient
num_steps = 100
[TimeStepper]
type = IterationAdaptiveDT
growth_factor = 1.8
dt = 0.1
[]
dtmax = 1000
[]
[Outputs]
csv = true
perf_graph = true
execute_on = 'TIMESTEP_END'
[]
(benchmarks/02_oswald_ripening/2a_secant.i)
[Domain]
dim = 2
nx = 120
ny = 120
xmax = 200
ymax = 200
device_names = 'cuda:1'
mesh_mode = DOMAIN
[]
fchem='fa:=rho^2*(c-ca)^2;
fb:=rho^2*(cb-c)^2;
h:=n1^3*(6*n1^2-15*n1+10) +
n2^3*(6*n2^2-15*n2+10) +
n3^3*(6*n3^2-15*n3+10) +
n4^3*(6*n4^2-15*n4+10);
g:=n1^2*(1-n1)^2 +
n2^2*(1-n2)^2 +
n3^2*(1-n3)^2 +
n4^2*(1-n4)^2 +
alpha*(
n1^2*n2^2 + n1^2*n3^2 + n1^2*n4^2 +
n2^2*n1^2 + n2^2*n3^2 + n2^2*n4^2 +
n3^2*n1^2 + n3^2*n2^2 + n3^2*n4^2 +
n4^2*n1^2 + n4^2*n2^2 + n4^2*n3^2);
(fa*(1-h) + fb*h + w*g)'
nic = 'epsilon*(cos((0.01*idx)*x-4)*cos((0.007+0.01*idx)*y)
+cos((0.11+0.01*idx)*x)*cos((0.11+0.01*idx)*y)
+psi*(cos((0.046+0.001*idx)*x+(0.0405+0.001*idx)*y)
*cos((0.031+0.001*idx)*x-(0.004+0.001*idx)*y))^2)^2'
cnames = 'rho ca cb alpha w L M'
cvalues= 'sqrt(2) 0.3 0.7 5 1 5 5'
[TensorBuffers]
# variables
[c]
[]
[n1]
[]
[n2]
[]
[n3]
[]
[n4]
[]
[c_bar]
[]
[n1_bar]
[]
[n2_bar]
[]
[n3_bar]
[]
[n4_bar]
[]
[mu_c]
[]
[mu_n1]
[]
[mu_n2]
[]
[mu_n3]
[]
[mu_n4]
[]
[mu_c_bar]
[]
[mu_n1_bar]
[]
[mu_n2_bar]
[]
[mu_n3_bar]
[]
[mu_n4_bar]
[]
[Mbar_mu_c_bar]
[]
# constant tensors
[Lbar] # FFT(M*laplacian)
[]
[MkappaL2bar] # FFT(-M*kappa*laplacian^2)
[]
[kappaLbar] # FFT(L*kappa*laplacian)
[]
# postprocessing
[F]
[]
[Fgrad_c]
[]
[Fgrad_n1]
[]
[Fgrad_n2]
[]
[Fgrad_n3]
[]
[Fgrad_n4]
[]
[bnds]
[]
[]
[TensorComputes]
[Initialize]
[c]
type = ParsedCompute
buffer = c
extra_symbols = true
expression = 'c0+epsilon*(cos(0.105*x)*cos(0.11*y)+(cos(0.13*x)*cos(0.087*y))^2+cos(0.025*x-0.15*y)*cos(0.07*x-0.02*y))'
constant_names = 'c0 epsilon'
constant_expressions = '0.5 0.01'
[]
[Lbar]
type = ReciprocalLaplacianFactor
# Mobility is pulled into the chemical potential below
buffer = Lbar
[]
[MkappaL2bar]
type = ReciprocalLaplacianSquareFactor
factor = -15 # -kappa_c*M
buffer = MkappaL2bar
[]
[kappaLbar]
type = ReciprocalLaplacianFactor
buffer = kappaLbar
factor = 15 # kappa_ni*L
[]
[n1]
type = ParsedCompute
buffer = n1
expression = ${nic}
extra_symbols = true
constant_names = 'idx epsilon psi'
constant_expressions = ' 1 0.1 1.5'
[]
[n2]
type = ParsedCompute
buffer = n2
expression = ${nic}
extra_symbols = true
constant_names = 'idx epsilon psi'
constant_expressions = ' 2 0.1 1.5'
[]
[n3]
type = ParsedCompute
buffer = n3
expression = ${nic}
extra_symbols = true
constant_names = 'idx epsilon psi'
constant_expressions = ' 3 0.1 1.5'
[]
[n4]
type = ParsedCompute
buffer = n4
expression = ${nic}
extra_symbols = true
constant_names = 'idx epsilon psi'
constant_expressions = ' 4 0.1 1.5'
[]
[]
[Solve]
[mu_c]
type = ParsedCompute
buffer = mu_c
expression = '${fchem}*M'
constant_names = ${cnames}
constant_expressions = ${cvalues}
derivatives = c
inputs = 'c n1 n2 n3 n4'
[]
[mu_n1]
type = ParsedCompute
buffer = mu_n1
expression = '${fchem}*(-L)'
constant_names = ${cnames}
constant_expressions = ${cvalues}
derivatives = n1
inputs = 'c n1 n2 n3 n4'
[]
[mu_n2]
type = ParsedCompute
buffer = mu_n2
expression = '${fchem}*(-L)'
constant_names = ${cnames}
constant_expressions = ${cvalues}
derivatives = n2
inputs = 'c n1 n2 n3 n4'
[]
[mu_n3]
type = ParsedCompute
buffer = mu_n3
expression = '${fchem}*(-L)'
constant_names = ${cnames}
constant_expressions = ${cvalues}
derivatives = n3
inputs = 'c n1 n2 n3 n4'
[]
[mu_n4]
type = ParsedCompute
buffer = mu_n4
expression = '${fchem}*(-L)'
constant_names = ${cnames}
constant_expressions = ${cvalues}
derivatives = n4
inputs = 'c n1 n2 n3 n4'
[]
[mu_c_bar]
type = ForwardFFT
buffer = mu_c_bar
input = mu_c
[]
[mu_n1_bar]
type = ForwardFFT
buffer = mu_n1_bar
input = mu_n1
[]
[mu_n2_bar]
type = ForwardFFT
buffer = mu_n2_bar
input = mu_n2
[]
[mu_n3_bar]
type = ForwardFFT
buffer = mu_n3_bar
input = mu_n3
[]
[mu_n4_bar]
type = ForwardFFT
buffer = mu_n4_bar
input = mu_n4
[]
[Mbar_mu_c_bar]
type = ParsedCompute
buffer = Mbar_mu_c_bar
expression = 'Lbar*mu_c_bar'
inputs = 'Lbar mu_c_bar'
[]
[c_bar]
type = ForwardFFT
buffer = c_bar
input = c
[]
[n1_bar]
type = ForwardFFT
buffer = n1_bar
input = n1
[]
[n2_bar]
type = ForwardFFT
buffer = n2_bar
input = n2
[]
[n3_bar]
type = ForwardFFT
buffer = n3_bar
input = n3
[]
[n4_bar]
type = ForwardFFT
buffer = n4_bar
input = n4
[]
[]
[Postprocess]
[Fgrad_c]
type = FFTGradientSquare
buffer = Fgrad_c
input = c
factor = 1.5 # kappa/2
[]
[Fgrad_n1]
type = FFTGradientSquare
buffer = Fgrad_n1
input = n1
factor = 1.5 # kappa/2
[]
[Fgrad_n2]
type = FFTGradientSquare
buffer = Fgrad_n2
input = n2
factor = 1.5 # kappa/2
[]
[Fgrad_n3]
type = FFTGradientSquare
buffer = Fgrad_n3
input = n3
factor = 1.5 # kappa/2
[]
[Fgrad_n4]
type = FFTGradientSquare
buffer = Fgrad_n4
input = n4
factor = 1.5 # kappa/2
[]
[F]
type = ParsedCompute
buffer = F
expression = '${fchem} + Fgrad_c + Fgrad_n1 + Fgrad_n2 + Fgrad_n3 + Fgrad_n4'
constant_names = ${cnames}
constant_expressions = ${cvalues}
inputs = 'c n1 n2 n3 n4 Fgrad_c Fgrad_n1 Fgrad_n2 Fgrad_n3 Fgrad_n4'
[]
[bnds]
type = ParsedCompute
buffer = bnds
expression = 'n1^2 + n2^2 + n3^2 + n4^2'
inputs = 'n1 n2 n3 n4'
[]
[]
[]
[TensorSolver]
type = SecantSolver
substeps = 1
max_iterations = 1000
# damping = 0.75
relative_tolerance = 1e-6
absolute_tolerance = 1e-6
buffer = 'c n1 n2 n3 n4'
dt_epsilon = 1e-7
reciprocal_buffer = 'c_bar n1_bar n2_bar n3_bar n4_bar'
linear_reciprocal = 'MkappaL2bar kappaLbar kappaLbar kappaLbar kappaLbar'
nonlinear_reciprocal = 'Mbar_mu_c_bar mu_n1_bar mu_n2_bar mu_n3_bar mu_n4_bar'
# verbose = true
[]
[Postprocessors]
[min_c]
type = TensorExtremeValuePostprocessor
buffer = c
value_type = MIN
execute_on = 'TIMESTEP_END'
[]
[max_c]
type = TensorExtremeValuePostprocessor
buffer = c
value_type = MAX
execute_on = 'TIMESTEP_END'
[]
[F]
type = TensorIntegralPostprocessor
buffer = F
[]
[]
[Problem]
type = TensorProblem
[]
[Executioner]
type = Transient
# num_steps = 2
end_time = 1e+5
[TimeStepper]
type = TensorSolveIterationAdaptiveDT
dt = 0.1
max_iterations = 500
min_iterations = 300
growth_factor = 1.1
cutback_factor = 0.9
[]
[]
[Outputs]
csv = true
perf_graph = true
execute_on = 'TIMESTEP_END'
[]
[TensorOutputs]
[c]
type = XDMFTensorOutput
buffer = 'c bnds'
output_mode = 'NODE NODE'
enable_hdf5 = true
[]
[]
(examples/lbm/Phase-field/static_bubble.i)
#
# Static bubble test case
# PHYSICAL REVIEW E 97, 033309 (2018) - Section III.A
# Intended outcome is to have (spurious) velocity magnitude around 1.0e-10
#
# Domain
Nx = 200
Ny = 200
# Bubble parameters
Cx = '${Nx}/2.0'
Cy = '${Ny}/2.0'
R = 50
# Fluid properties
rho_l = 1000.0
rho_g = 1.0
nu_l = 0.1
nu_g = 0.1
sigma = 0.001
# Phase field parameters
tau_h = 0.7
D = 5
[Domain]
dim = 2
nx = '${Nx}'
ny = '${Ny}'
xmax = '${Nx}'
ymax = '${Ny}'
device_names='cpu'
parallel_mode = REAL_SPACE
periodic_directions = 'X Y'
[]
[Stencil]
[d2q9]
type = LBMD2Q9
[]
[]
[TensorBuffers]
# Macroscopic phase field variables
[phi]
type = LBMTensorBuffer
buffer_type = ms
[]
[grad_phi]
type = LBMTensorBuffer
buffer_type = mv
[]
[laplacian_phi]
type = LBMTensorBuffer
buffer_type = ms
[]
[mu]
type = LBMTensorBuffer
buffer_type = ms
[]
[forces]
type = LBMTensorBuffer
buffer_type = mv
[]
# Macroscopic hydrodynamic variables
[velocity]
type = LBMTensorBuffer
buffer_type = mv
[]
[pressure]
type = LBMTensorBuffer
buffer_type = ms
[]
[rho]
type = LBMTensorBuffer
buffer_type = ms
[]
# LBM phase field variabels
[h]
type = LBMTensorBuffer
buffer_type = df
[]
[h_post_collision]
type = LBMTensorBuffer
buffer_type = df
[]
[h_eq]
type = LBMTensorBuffer
buffer_type = df
[]
[relaxation_tensor]
type = LBMTensorBuffer
buffer_type = ms
[]
# LBM hydrodynamic variables
[fdummy]
type = LBMTensorBuffer
buffer_type = df
[]
[f]
type = LBMTensorBuffer
buffer_type = df
[]
[f_post_collision]
type = LBMTensorBuffer
buffer_type = df
[]
[f_eq]
type = LBMTensorBuffer
buffer_type = df
[]
[]
[TensorComputes/Initialize]
[phi_init]
type = ParsedCompute
buffer = phi
expression = '0.5 + 0.5 * tanh(2*(R - sqrt((x - Cx)^2 + (y - Cy)^2)) / D)'
constant_names = 'Cx Cy R D'
constant_expressions = '${Cx} ${Cy} ${R} ${D}'
extra_symbols = true
[]
[grad_phi_init]
type = LBMIsotropicGradient
buffer = grad_phi
scalar_field = phi
[]
[rho_init]
type = ParsedCompute
buffer = rho
extra_symbols = true
expression = 'phi*(rho_l - rho_g) + rho_g'
constant_names = 'rho_l rho_g'
constant_expressions = '${rho_l} ${rho_g}'
inputs = phi
[]
[pressure_init]
type = LBMConstantTensor
buffer = pressure
constants = 0.3
[]
# Phase field equilibrium distribution initialization
[h_eq_init]
type = LBMPhaseEquilibrium
buffer = h_eq
phi = phi
velocity = velocity
[]
[h_post_collision_init]
type = LBMPhaseEquilibrium
buffer = h_post_collision
phi = phi
velocity = velocity
[]
[h_init]
type = LBMPhaseEquilibrium
buffer = h
phi = phi
velocity = velocity
[]
# Hydrodynamic equilibrium distribution initialization
[f_eq_init]
type = LBMPressureCorrectedEquilibrium
buffer = f_eq
rho = rho
velocity = velocity
pressure = pressure
[]
[f_post_collision_init]
type = ParsedCompute
buffer = f_post_collision
expression = 'f_eq'
inputs = f_eq
[]
[f_init]
type = ParsedCompute
buffer = f
expression = 'f_eq'
inputs = f_eq
[]
[]
[TensorComputes/Solve]
# Phase Field
[compute_phi]
type = LBMComputeDensity
buffer = phi
f = h
[]
[grad_phi]
type = LBMIsotropicGradient
buffer = grad_phi
scalar_field = phi
[]
[laplacian_phi]
type = LBMIsotropicLaplacian
buffer = laplacian_phi
scalar_field = phi
[]
[potential]
type = LBMComputeChemicalPotential
buffer = mu
phi = phi
laplacian_phi = laplacian_phi
thickness = D
sigma = sigma
[]
[forces]
type = LBMComputeSurfaceForces
buffer = forces
chemical_potential = mu
grad_phi = grad_phi
[]
# Hydrodynamics
[density]
type = ParsedCompute
buffer = rho
extra_symbols = true
expression = 'phi*(rho_l - rho_g) + rho_g'
constant_names = 'rho_l rho_g'
constant_expressions = '${rho_l} ${rho_g}'
inputs = phi
[]
[velocity]
type = LBMComputeVelocity
buffer = velocity
f = f
rho = rho
enable_forces = true
forces = forces
[]
# Phase-field
[h_eq]
type = LBMPhaseEquilibrium
buffer = h_eq
phi = phi
velocity = velocity
[]
[phase_collision]
type = LBMBGKCollision
buffer = h_post_collision
f = h
feq = h_eq
tau0 = tau_h
[]
[apply_forces_phase]
type = LBMAllenCahnSource
buffer = h_post_collision
phi = phi
velocity = velocity
grad_phi = grad_phi
tau = tau_h
thickness = D
[]
# Hydrodynamics
[relaxation_tensor]
type = ParsedCompute
buffer = relaxation_tensor
extra_symbols = true
expression = '(phi*(nu_l - nu_g) + nu_g)/cs2+0.5'
constant_names = 'nu_l nu_g cs2'
constant_expressions = '${nu_l} ${nu_g} 0.3333'
inputs = phi
[]
[pressure]
type = LBMPhaseFieldPressure
buffer = pressure
f = f
velocity = velocity
grad_phi = grad_phi
rho = rho
rho_l = '${rho_l}'
rho_g = '${rho_g}'
[]
[f_eq]
type = LBMPressureCorrectedEquilibrium
buffer = f_eq
rho = rho
velocity = velocity
pressure = pressure
[]
[collision]
type = LBMBGKCollision
buffer = f_post_collision
f = f
feq = f_eq
tau0 = 1.0
is_dynamic_relaxation = true
tau_tensor = relaxation_tensor
[]
[apply_forces_hydro]
type = LBMForceDistribution
buffer = f_post_collision
grad_phi = grad_phi
velocity = velocity
forces = forces
tau_tensor = relaxation_tensor
tau = 1.0
rho_l = '${rho_l}'
rho_g = '${rho_g}'
is_dynamic_relaxation = true
[]
[]
[TensorSolver]
type = LBMStream
buffer = 'h f'
f_old = 'h_post_collision f_post_collision'
[]
[Problem]
type = LatticeBoltzmannProblem
substeps = 50
print_debug_output = true
scalar_constant_names = 'tau_h D sigma'
scalar_constant_values = '${tau_h} ${D} ${sigma}'
residual_tensor = speed
[]
[Executioner]
type = Transient
num_steps = 100
[]
[TensorOutputs]
[xdmf]
type = XDMFTensorOutput
buffer = 'phi rho velocity forces'
output_mode = 'Cell Cell Cell Cell'
enable_hdf5 = true
# transpose = false
[]
[]
(test/tests/real_space/deep_ghost_periodic.i)
# The reference of deep_ghost_faces.i: the field mirrored onto the periodic domain 0 < x < 32,
# where the 5-point biharmonic reads only periodic ghosts. The postprocessors take 0 < x < 16.
u_ic = 'exp(cos(pi*x/16))*sin(2*pi*y/8)'
[Domain]
dim = 2
nx = 32
ny = 8
xmax = 32
ymax = 8
parallel_mode = REAL_SPACE
periodic_directions = 'X Y'
[]
[TensorBuffers]
[u]
[]
[bih]
[]
[bih_strip]
[]
[bih_sq]
[]
[]
[TensorComputes]
[Initialize]
[u_ic]
type = ParsedCompute
buffer = u
extra_symbols = true
expression = ${u_ic}
[]
[]
[Postprocess]
[bih]
type = FiniteDifferenceBiharmonic
buffer = bih
input = u
stencil_width = 5
[]
# 0 outside the strip, which is between the extremes of both test fields there
[bih_strip]
type = ParsedCompute
buffer = bih_strip
extra_symbols = true
expression = 'if(x < 16, bih, 0)'
inputs = bih
[]
[bih_sq]
type = ParsedCompute
buffer = bih_sq
expression = 'bih_strip^2'
inputs = bih_strip
[]
[]
[]
[Postprocessors]
[integral_bih_sq]
type = TensorIntegralPostprocessor
buffer = bih_sq
[]
[max_bih]
type = TensorExtremeValuePostprocessor
buffer = bih_strip
value_type = MAX
[]
[min_bih]
type = TensorExtremeValuePostprocessor
buffer = bih_strip
value_type = MIN
[]
[]
[Problem]
type = TensorProblem
[]
[Executioner]
type = Transient
num_steps = 1
[]
[Outputs]
csv = true
[]
(examples/swift_hohenberg/rotating_grain.i)
#
# Solve a simple Swift-Hohenberg crystal phase field problem. The initial condition is
# a circular grain that is rotated against the surropunding matrix.
# This example demonstrates the use of the [TensorComputes/Postprocess] system to perform
# compute steps just prior to running the output objects. Here we perform a low-pass filtering
# by forward transfroming the psi amplitude field into frequency space, attenuating frequencies
# by the exponent of their wave number, and transforming back into real space. This filtering
# makes the dislocation structure in the crystal more pronounced in the visualization.
#
w=60
[Domain]
dim = 2
nx = 400
ny = 400
xmax = ${fparse pi*2*w}
ymax = ${fparse pi*2*w}
device_names = 'cuda'
mesh_mode = DOMAIN
[]
[TensorBuffers]
[psi]
map_to_aux_variable = psi
[]
[psibar]
[]
[psi3]
[]
[psi3bar]
[]
# constant tensors
[linear]
[]
# output
[filter]
map_to_aux_variable = filter
[]
[filterbar]
[]
[]
[AuxVariables]
[psi]
[]
[filter]
[]
[]
crystal = '-sin(sin(a)*y/2+cos(a)*x/2)^2*sin(sin(a+1/3*pi)*y/2+cos(a+1/3*pi)*x/2)^2*sin(sin(a-1/3*pi)*y/2+cos(a-1/3*pi)*x/2)^2'
[Functions]
[grain1]
type = ParsedFunction
expression = 'a := 0; ${crystal}'
[]
[grain2]
type = ParsedFunction
expression = 'a := 0.95; ${crystal}'
[]
[domain]
type = ParsedFunction
expression = 'r := (x-${w}*pi)^2+(y-${w}*pi)^2; if(r<(${w}*2/3*pi)^2, grain2, grain1)'
symbol_names = 'grain1 grain2'
symbol_values = 'grain1 grain2'
[]
[]
[TensorComputes]
[Initialize]
[psi]
type = MooseFunctionTensor
buffer = psi
function = domain
[]
[linear]
type = SwiftHohenbergLinear
buffer = linear
alpha = 1
r = 0.025
[]
[]
[Solve]
[psi3]
type = ParsedCompute
buffer = psi3
expression = "0.20*psi^2-psi^3"
inputs = psi
[]
[psibar]
type = ForwardFFT
buffer = psibar
input = psi
[]
[psi3bar]
type = ForwardFFT
buffer = psi3bar
input = psi3
[]
[]
[Postprocess]
[low_pass]
type = ParsedCompute
buffer = filterbar
extra_symbols = true
expression = 'psibar * exp(-k2*10)'
inputs = psibar
[]
[filter]
type = InverseFFT
buffer = filter
input = filterbar
[]
[]
[]
[TensorSolver]
type = AdamsBashforthMoulton
buffer = psi
reciprocal_buffer = psibar
linear_reciprocal = linear
nonlinear_reciprocal = psi3bar
substeps = 100
[]
[Problem]
type = TensorProblem
[]
[Executioner]
type = Transient
num_steps = 120
[TimeStepper]
type = IterationAdaptiveDT
growth_factor = 1.1
dt = 5
[]
dtmax = 500
[]
[Postprocessors]
[min_psi]
type = TensorExtremeValuePostprocessor
buffer = psi
value_type = MIN
execute_on = 'TIMESTEP_END'
[]
[max_psi]
type = TensorExtremeValuePostprocessor
buffer = psi
value_type = MAX
execute_on = 'TIMESTEP_END'
[]
[Psi]
type = TensorIntegralPostprocessor
buffer = psi
[]
[]
[Outputs]
exodus = true
perf_graph = true
execute_on = 'TIMESTEP_END'
[]
(test/tests/cahnhilliard/cahnhilliard.i)
#
# Simple Cahn-Hilliard solve on a 2D grid. We create a matching (conforming)
# MOOSE mesh (with one element per FFT grid cell) and project the solution onto
# the MOOSE mesh to utilize the exodus output object.
#
[Domain]
dim = 2
nx = 20
ny = 20
xmax = 3
ymax = 3
mesh_mode = DOMAIN
[]
# In this input we fully trely on implicit TensorBuffer declaration
[TensorComputes]
[Initialize]
[c]
# Random initial condition around a concentration of 1/2
type = RandomTensor
buffer = c
min = 0.44
max = 0.56
seed = 0
[]
[mu_init]
type = ConstantTensor
buffer = mu
[]
# precompute fixed factors for the solve
[Mbar]
type = ReciprocalLaplacianFactor
factor = 0.2 # Mobility
buffer = Mbar
[]
[kappabarbar]
type = ReciprocalLaplacianSquareFactor
factor = -0.001 # kappa
buffer = kappabarbar
[]
[]
[Solve]
[cahn_hilliard]
[mu]
type = ParsedCompute
buffer = mu
expression = '0.1*c^2*(c-1)^2'
derivatives = c
inputs = c
[]
[mubar]
type = ForwardFFT
buffer = mubar
input = mu
[]
[Mbarmubar]
type = ParsedCompute
buffer = Mbarmubar
expression = 'Mbar*mubar'
inputs = 'Mbar mubar'
[]
[cbar]
type = ForwardFFT
buffer = cbar
input = c
[]
[]
[]
[]
[TensorSolver]
type = AdamsBashforthMoulton
root_compute = cahn_hilliard
buffer = c
reciprocal_buffer = cbar
linear_reciprocal = kappabarbar
nonlinear_reciprocal = Mbarmubar
substeps = 10
[]
[AuxVariables]
[mu]
# the mu tensor is projected onto this elemental variable
family = MONOMIAL
order = CONSTANT
[]
[c]
# the c tensor is projected onto this nodal variable
[]
[]
[AuxKernels]
active = ''
[c]
type = ProjectTensorAux
buffer = c
variable = c
execute_on = 'INITIAL TIMESTEP_END'
[]
[mu]
type = ProjectTensorAux
buffer = mu
variable = mu
execute_on = 'INITIAL TIMESTEP_END'
[]
[]
[Postprocessors]
[min_c]
type = SemiImplicitCriticalTimeStep
buffer = kappabarbar
execute_on = 'INITIAL TIMESTEP_END'
[]
[delta_int_c]
type = TensorIntegralChangePostprocessor
buffer = c
[]
[]
[Problem]
type = TensorProblem
[]
[Executioner]
type = Transient
num_steps = 10
dt = 1e-3
[]
[TensorOutputs]
active = ''
[xdmf]
type = XDMFTensorOutput
buffer = 'c mu'
output_mode = 'Node Cell'
enable_hdf5 = true
# Do not transpose output to avoid regolding the test. In practice the default
# of transpose = true should always be used
transpose = false
[]
[xdmf2]
# second output to trigger the hdf5 thread safety error
type = XDMFTensorOutput
buffer = 'c'
output_mode = 'Cell'
enable_hdf5 = true
# Do not transpose output to avoid regolding the test. In practice the default
# of transpose = true should always be used
transpose = false
[]
[]
[Outputs]
exodus = true
csv = true
[]
(test/tests/implicit_fd/biharmonic_mode3d.i)
# Backward Euler for u_t = -M kappa Laplacian(Laplacian(u)) of a single periodic
# Fourier mode. The mode is an eigenvector of the discrete Laplacian with
# eigenvalue -lambda_h, so of the discrete biharmonic with eigenvalue lambda_h^2,
# and every implicit step must multiply it by exactly
# g = 1 / (1 + dt M kappa lambda_h^2), up to the linear solver tolerance.
# 3D version of biharmonic_mode.i.
Mkappa = 1e-3
dt = 0.01
n = 16
stencil = 3
# Symbol of -Laplacian per axis for the wavenumber 2 pi, h = 1/n (see be_mode.i)
lambda3 = '${fparse n^2 * (2 - 2 * cos(2 * pi / n))}'
lambda5 = '${fparse n^2 * (5 / 2 - 8 / 3 * cos(2 * pi / n) + 1 / 6 * cos(4 * pi / n))}'
lambda = '${fparse 3 * if(stencil = 3, lambda3, lambda5)}'
[Domain]
dim = 3
nx = ${n}
ny = ${n}
nz = ${n}
xmax = 1
ymax = 1
zmax = 1
parallel_mode = REAL_SPACE
periodic_directions = 'X Y Z'
[]
[TensorBuffers]
[u]
[]
[dudt_u]
[]
[bih_u]
[]
[gold]
[]
[diff]
[]
[]
[TensorComputes]
[Initialize]
[u_ic]
type = ParsedCompute
buffer = u
expression = 'sin(2*pi*x)*sin(2*pi*y)*sin(2*pi*z)'
extra_symbols = true
[]
[]
[Solve]
[dudt]
type = TimeDerivativeOperator
buffer = dudt_u
input = u
[]
[bih]
type = FiniteDifferenceBiharmonic
buffer = bih_u
input = u
factor = ${Mkappa}
stencil_width = ${stencil}
[]
[]
[Postprocess]
[gold_compute]
type = ParsedCompute
buffer = gold
expression = 'sin(2*pi*x)*sin(2*pi*y)*sin(2*pi*z) * g^(t / dt)'
constant_names = 'g dt'
constant_expressions = '${fparse 1 / (1 + dt * Mkappa * lambda^2)} ${dt}'
extra_symbols = true
[]
[diff_compute]
type = ParsedCompute
buffer = diff
expression = 'abs(u - gold)'
inputs = 'u gold'
[]
[]
[]
[TensorSolver]
type = ImplicitFDSolver
buffer = u
operators = 'dudt bih'
root_compute = dudt
[]
[Postprocessors]
[max_error]
type = TensorExtremeValuePostprocessor
buffer = diff
value_type = MAX
[]
[max_gold]
type = TensorExtremeValuePostprocessor
buffer = gold
value_type = MAX
[]
[]
[Problem]
type = TensorProblem
[]
[Executioner]
type = Transient
num_steps = 10
dt = ${dt}
[]
[Outputs]
csv = true
[]
(examples/cahn_hilliard/cahnhilliard.i)
#
# Simple Cahn-Hilliard solve on a 2D grid. We create a matching (conforming)
# MOOSE mesh (with one element per FFT grid cell) and project the solution onto
# the MOOSE mesh to utilize the exodus output object.
#
[Domain]
dim = 2
nx = 200
ny = 200
xmax = ${fparse pi*8}
ymax = ${fparse pi*8}
# automatically create a matching mesh
mesh_mode = DOMAIN
[]
[TensorBuffers]
[c]
# perform fast mapping to the matching mesh by directly writing to
# the solution vector of the specified Auxvariable
map_to_aux_variable = c
[]
[cbar]
[]
[mu]
map_to_aux_variable = mu
[]
[mubar]
[]
[Mbarmubar]
[]
# constant tensors
[Mbar]
[]
[kappabarbar]
[]
[]
[TensorComputes]
[Initialize]
[c]
# Random initial condition around a concentration of 1/2
type = RandomTensor
buffer = c
min = 0.44
max = 0.56
[]
# precompute fixed factors for the solve
[Mbar]
type = ReciprocalLaplacianFactor
factor = 0.2 # Mobility
buffer = Mbar
[]
[kappabarbar]
type = ReciprocalLaplacianSquareFactor
factor = -0.001 # kappa
buffer = kappabarbar
[]
[mu_init]
type = ConstantTensor
buffer = mu
real = 0
[]
[]
[Solve]
[cahn_hilliard]
[mu]
type = ParsedCompute
buffer = mu
expression = '0.1*c^2*(c-1)^2'
derivatives = c
inputs = c
[]
[mubar]
type = ForwardFFT
buffer = mubar
input = mu
[]
[Mbarmubar]
type = ParsedCompute
buffer = Mbarmubar
expression = 'Mbar*mubar'
inputs = 'Mbar mubar'
[]
[cbar]
type = ForwardFFT
buffer = cbar
input = c
[]
[]
[]
[]
[TensorSolver]
type = AdamsBashforthMoulton
root_compute = cahn_hilliard
buffer = c
reciprocal_buffer = cbar
linear_reciprocal = kappabarbar
nonlinear_reciprocal = Mbarmubar
substeps = 1000
[]
[AuxVariables]
[mu]
# the mu tensor is projected onto this elemental variable
family = MONOMIAL
order = CONSTANT
[]
[c]
# the c tensor is projected onto this nodal variable
[]
[]
# a slower but more flexible alternative to `map_to_aux_variable` is running
# these `ProjectTensorAux` AuxKernels to perform the projection. This aprpoach
# also supports non-conforming meshes.
[AuxKernels]
# [c]
# type = ProjectTensorAux
# buffer = c
# variable = c
# execute_on = final
# []
# [f]
# type = ProjectTensorAux
# buffer = f
# variable = f
# execute_on = TIMESTEP_END
# []
[]
[Postprocessors]
[min_c]
type = ElementExtremeValue
variable = c
value_type = MIN
execute_on = 'TIMESTEP_END'
[]
[max_c]
type = ElementExtremeValue
variable = c
value_type = MAX
execute_on = 'TIMESTEP_END'
[]
# [F]
# type = ElementIntegralVariablePostprocessor
# variable = f
# execute_on = 'TIMESTEP_END'
# []
[C]
type = ElementIntegralVariablePostprocessor
variable = c
execute_on = 'TIMESTEP_END'
[]
[]
[Problem]
type = TensorProblem
[]
[Executioner]
type = Transient
num_steps = 100
[TimeStepper]
type = IterationAdaptiveDT
growth_factor = 1.8
dt = 0.1
[]
dtmax = 1000
[]
[Outputs]
exodus = true
csv = true
perf_graph = true
execute_on = 'TIMESTEP_END'
[]
(benchmarks/01_spinodal_decomposition/1b.i)
[Domain]
dim = 2
nx = 200
ny = 200
xmin = -10
ymin = -10
xmax = 210
ymax = 210
device_names = 'cuda'
mesh_mode = DOMAIN
[]
[TensorBuffers]
[domain]
map_to_aux_variable = domain
[]
[c]
map_to_aux_variable = c
[]
[cbar]
[]
[mu]
# map_to_aux_variable = mu
[]
[mubar]
[]
[Mbarmubar]
[]
# constant tensors
[Mbar]
[]
[kappabarbar]
[]
# postprocessing
[F]
[]
[Fgrad]
[]
[]
[TensorComputes]
[Initialize]
[domain]
type = ParsedCompute
buffer = domain
extra_symbols = true
expression = 'w:=3;dx:=max(tanh(-x/w),tanh((x-200)/w)); dy:=max(tanh(-y/w),tanh((y-200)/w));1-0.999999999*max(dx,dy)'
[]
[c]
type = ParsedCompute
buffer = c
extra_symbols = true
expression = 'c0+epsilon*(cos(0.105*x)*cos(0.11*y)+(cos(0.13*x)*cos(0.087*y))^2+cos(0.025*x-0.15*y)*cos(0.07*x-0.02*y))'
constant_names = 'c0 epsilon'
constant_expressions = '0.5 0.01'
[]
[Mbar]
type = ReciprocalLaplacianFactor
factor = 5 # Mobility
buffer = Mbar
[]
[kappabarbar]
type = ReciprocalLaplacianSquareFactor
factor = -10 # -kappa*M
buffer = kappabarbar
[]
[]
[Solve]
[mu]
type = ParsedCompute
buffer = mu
expression = 'rho_s*(c-c_alpha)^2*(c_beta-c)^2'
constant_names = 'rho_s c_alpha c_beta'
constant_expressions = '5 0.3 0.7'
derivatives = c
inputs = c
[]
[mubar]
type = ForwardFFT
buffer = mubar
input = mu
[]
[Mbarmubar]
type = ParsedCompute
buffer = Mbarmubar
expression = 'Mbar*mubar'
inputs = 'Mbar mubar'
[]
[cbar]
type = ForwardFFT
buffer = cbar
input = c
[]
[]
[Postprocess]
[Fgrad]
type = FFTGradientSquare
buffer = Fgrad
input = c
factor = 1 # kappa/2
[]
[F]
type = ParsedCompute
buffer = F
expression = 'rho_s * (c-c_alpha)^2 * (c_beta-c)^2 + Fgrad'
constant_names = 'rho_s c_alpha c_beta'
constant_expressions = '5 0.3 0.7'
inputs = 'c Fgrad'
[]
[]
[]
[UserObjects]
[terminator]
type = Terminator
expression = change<1e-4
[]
[]
[TensorTimeIntegrators]
[c]
type = FFTSemiImplicit
buffer = c
history_size = 1
reciprocal_buffer = cbar
linear_reciprocal = kappabarbar
nonlinear_reciprocal = Mbarmubar
[]
[]
[AuxVariables]
# [mu]
# family = MONOMIAL
# order = CONSTANT
# []
[c]
# family = MONOMIAL
# order = CONSTANT
[]
[domain]
[]
[]
[Postprocessors]
[min_c]
type = TensorExtremeValuePostprocessor
buffer = c
value_type = MIN
execute_on = 'TIMESTEP_END'
[]
[max_c]
type = TensorExtremeValuePostprocessor
buffer = c
value_type = MAX
execute_on = 'TIMESTEP_END'
[]
[F]
type = TensorIntegralPostprocessor
buffer = F
[]
[change]
type = TensorIntegralChangePostprocessor
buffer = c
[]
[]
[Problem]
type = TensorProblem
spectral_solve_substeps = 1000
[]
[Executioner]
type = Transient
num_steps = 1 # 1000
[TimeStepper]
type = IterationAdaptiveDT
growth_factor = 1.1
dt = 1
[]
dtmax = 300
[]
[Outputs]
exodus = true
csv = true
perf_graph = true
execute_on = 'TIMESTEP_END'
[]
(examples/cahn_hilliard/cahnhilliard3.i)
[Domain]
dim = 3
nx = 100
ny = 100
nz = 100
xmax = ${fparse pi*4}
ymax = ${fparse pi*4}
zmax = ${fparse pi*4}
device_names = 'cuda'
mesh_mode = DUMMY
[]
[TensorBuffers]
[c]
[]
[cbar]
[]
[mu]
[]
[mubar]
[]
[Mbarmubar]
[]
# constant tensors
[Mbar]
[]
[kappabarbar]
[]
[]
[TensorOutputs]
[xdmf]
type = XDMFTensorOutput
buffer = 'c mu'
output_mode = 'Node Cell'
enable_hdf5 = true
[]
[]
[TensorComputes]
[Initialize]
[c]
type = RandomTensor
buffer = c
min = 0.44
max = 0.56
[]
[Mbar]
type = ReciprocalLaplacianFactor
factor = 0.2 # Mobility
buffer = Mbar
[]
[kappabarbar]
type = ReciprocalLaplacianSquareFactor
factor = -0.001 # kappa
buffer = kappabarbar
[]
[]
[Solve]
[mu]
type = ParsedCompute
buffer = mu
expression = '0.1*c^2*(c-1)^2'
derivatives = c
# expression = "0.4*c^3-0.6*c^2+0.2*c"
inputs = c
[]
[mubar]
type = ForwardFFT
buffer = mubar
input = mu
[]
[Mbarmubar]
type = ParsedCompute
buffer = Mbarmubar
expression = 'Mbar*mubar'
inputs = 'Mbar mubar'
[]
[cbar]
type = ForwardFFT
buffer = cbar
input = c
[]
[]
[]
[TensorTimeIntegrators]
[c]
type = FFTSemiImplicit
buffer = c
reciprocal_buffer = cbar
linear_reciprocal = kappabarbar
nonlinear_reciprocal = Mbarmubar
[]
[]
[Postprocessors]
[min_c]
type = TensorExtremeValuePostprocessor
buffer = c
value_type = MIN
execute_on = 'TIMESTEP_END'
[]
[max_c]
type = TensorExtremeValuePostprocessor
buffer = c
value_type = MAX
execute_on = 'TIMESTEP_END'
[]
[C]
type = TensorIntegralPostprocessor
buffer = c
execute_on = 'TIMESTEP_END'
[]
[cavg]
type = TensorAveragePostprocessor
buffer = c
execute_on = 'TIMESTEP_END'
[]
[]
[Problem]
type = TensorProblem
spectral_solve_substeps = 1000
[]
[Executioner]
type = Transient
num_steps = 20
[TimeStepper]
type = IterationAdaptiveDT
growth_factor = 1.8
dt = 0.1
[]
dtmax = 1000
[]
[Outputs]
csv = true
perf_graph = true
execute_on = 'TIMESTEP_END'
[]
(test/tests/solvers/nl_coupled.i)
#
# Simple Cahn-Hilliard solve on a 2D grid.
#
[Domain]
dim = 2
nx = 150
ny = 150
xmax = '${fparse pi*2}'
ymax = '${fparse pi*2}'
mesh_mode = DUMMY
[]
[GlobalParams]
constant_names = 'A B'
constant_expressions = '1 3.5'
[]
[TensorComputes]
[Initialize]
[u]
type = ParsedCompute
buffer = u
extra_symbols = true
expression = 'sin(x)*sin(y)'
expand = REAL
[]
[v]
type = ParsedCompute
buffer = v
extra_symbols = true
expression = 'cos(x)*cos(y)'
expand = REAL
[]
[zero]
type = ConstantReciprocalTensor
buffer = zero
[]
# precompute fixed factors for the solve
[D1]
type = ReciprocalLaplacianFactor
factor = 1e-2
buffer = D1
[]
[D2]
type = ReciprocalLaplacianFactor
factor = 1e-3
buffer = D2
[]
[]
[Solve]
[u_bar]
type = ForwardFFT
buffer = u_bar
input = u
[]
[v_bar]
type = ForwardFFT
buffer = v_bar
input = v
[]
[Du]
type = ParsedCompute
buffer = Du
expression = 'D2*v_bar'
inputs = 'D2 v_bar'
[]
[Dv]
type = ParsedCompute
buffer = Dv
expression = 'D2*u_bar'
inputs = 'D2 u_bar'
[]
[]
[]
[TensorSolver]
type = AdamsBashforthMoulton
buffer = 'u v'
reciprocal_buffer = 'u_bar v_bar'
linear_reciprocal = 'D1 D1'
nonlinear_reciprocal = 'Du Dv'
substeps = ${ss}
corrector_steps = ${cs}
predictor_order = ${order}
corrector_order = ${order}
[]
[Problem]
type = TensorProblem
[]
[Postprocessors]
[u_min]
type = TensorExtremeValuePostprocessor
buffer = u
value_type = MIN
[]
[u_max]
type = TensorExtremeValuePostprocessor
buffer = u
value_type = MAX
[]
[v_min]
type = TensorExtremeValuePostprocessor
buffer = v
value_type = MIN
[]
[v_max]
type = TensorExtremeValuePostprocessor
buffer = v
value_type = MAX
[]
[U]
type = TensorIntegralPostprocessor
buffer = u
[]
[V]
type = TensorIntegralPostprocessor
buffer = v
[]
[]
[Executioner]
type = Transient
num_steps = 25
dt = 10
[]
[Outputs]
file_base = nl_coupled_${ss}_${cs}_${order}
csv = true
[]
(test/tests/real_space/neumann_linear.i)
# Nonzero-flux Neumann boundary condition: steady 1D diffusion with u(0) = 1
# (Dirichlet, left) and du/dn = 2 (Neumann, right) has the exact solution
# u = 1 + 2*x. Y is periodic, and the IC is not the steady profile.
[Domain]
dim = 2
nx = 20
ny = 8
parallel_mode = REAL_SPACE
periodic_directions = 'Y'
xmin = 0
xmax = 1
ymin = -1
ymax = 1
[]
[Functions]
[u_ic_func]
type = ParsedFunction
expression = '0.5'
[]
[u_exact_func]
type = ParsedFunction
expression = '1 + 2 * x'
[]
[]
[TensorComputes]
[Initialize]
[u_ic]
type = MooseFunctionTensor
buffer = u
function = u_ic_func
[]
[]
[BCs]
[left]
type = TensorDirichletBC
variable = u
boundary = left
value = 1
[]
[right]
type = TensorNeumannBC
variable = u
boundary = right
flux = 2
[]
[]
[Solve]
[dt]
type = FiniteDifferenceLaplacian
input = u
buffer = dudt
[]
[u_exact]
type = MooseFunctionTensor
buffer = u_exact
function = u_exact_func
[]
[diff]
type = ParsedCompute
buffer = diff
expression = 'abs(u - u_exact)'
inputs = 'u u_exact'
[]
[]
[]
[TensorSolver]
type = RealSpaceForwardEuler
buffer = u
time_derivative = dudt
substeps = 1000
[]
[Postprocessors]
[max_error]
type = TensorExtremeValuePostprocessor
buffer = diff
value_type = MAX
execute_on = 'TIMESTEP_END'
[]
[]
[Executioner]
type = Transient
# same grid and CFL margin as dirichlet_linear.i; the Neumann face makes the slowest
# mode decay more slowly, so max_error needs 15 steps to plateau
dt = 1
num_steps = 15
[]
[Outputs]
[out]
type = CSV
[]
[]
(test/tests/histogram/test.i)
[Domain]
dim = 3
nx = 10
ny = 10
nz = 10
mesh_mode = DUMMY
[]
[TensorBuffers]
[c]
[]
[]
[TensorComputes]
[Initialize]
[c]
type = ParsedCompute
buffer = c
extra_symbols = true
expression = '0.1*x^2+0.2*y^2+0.3*z^2'
[]
[]
[]
[VectorPostprocessors]
[hist]
type = TensorHistogram
buffer = c
bins = 20
min = 0
max = 1
execute_on = 'TIMESTEP_END'
[]
[]
[Problem]
type = TensorProblem
[]
[Executioner]
type = Transient
num_steps = 1
[]
[Outputs]
csv = true
execute_on = 'TIMESTEP_END'
[]
(test/tests/real_space/neumann_conservation.i)
# Zero-flux Neumann boundary condition: pure diffusion with zero flux on the X faces
# and periodic Y, from a non-uniform initial condition. The total integral of u must
# be conserved to near machine precision while u relaxes to its mean.
[Domain]
dim = 2
nx = 20
ny = 8
parallel_mode = REAL_SPACE
periodic_directions = 'Y'
xmin = 0
xmax = 1
ymin = -1
ymax = 1
[]
[TensorComputes]
[Initialize]
[u_ic]
type = ParsedCompute
buffer = u
# non-uniform in x and y, so diffusion moves mass internally
expression = '1 + sin(2 * pi * x) + 0.3 * cos(pi * y)'
extra_symbols = true
[]
[]
[BCs]
[left]
type = TensorNeumannBC
variable = u
boundary = left
flux = 0
[]
[right]
type = TensorNeumannBC
variable = u
boundary = right
flux = 0
[]
[]
[Solve]
[dt]
type = FiniteDifferenceLaplacian
input = u
buffer = dudt
[]
[]
[]
[TensorSolver]
type = RealSpaceForwardEuler
buffer = u
time_derivative = dudt
substeps = 1000
[]
[Postprocessors]
[mass]
type = TensorIntegralPostprocessor
buffer = u
execute_on = 'INITIAL TIMESTEP_END'
[]
[]
[Executioner]
type = Transient
# same grid and CFL margin as dirichlet_linear.i
dt = 1
num_steps = 4
[]
[Outputs]
[out]
type = CSV
[]
[]
(test/tests/gradient/gradient_square.i)
[Domain]
dim = 3
nx = 40
ny = 40
nz = 40
xmax = ${fparse pi*2}
ymax = ${fparse pi*4}
zmax = ${fparse pi*6}
mesh_mode = DUMMY
device_names = cpu
[]
[TensorBuffers]
[s]
[]
[grad_sq]
[]
[c2]
[]
[diff]
[]
[]
[TensorComputes]
[Initialize]
[sin]
type = ParsedCompute
buffer = s
extra_symbols = true
expression = 'sin(x)+sin(y)+sin(z)'
[]
[cos2]
type = ParsedCompute
buffer = c2
extra_symbols = true
expression = 'cos(x)^2+cos(y)^2+cos(z)^2'
[]
[grad_sq]
type = FFTGradientSquare
buffer = grad_sq
input = s
[]
[diff]
type = ParsedCompute
buffer = diff
inputs = 'grad_sq c2'
expression = 'abs(grad_sq - c2)'
[]
[]
[]
[Postprocessors]
[diff]
type = TensorIntegralPostprocessor
buffer = diff
[]
[]
[Problem]
type = TensorProblem
[]
[Executioner]
type = Transient
num_steps = 1
[]
[Outputs]
csv = true
[]
(test/tests/tensor_compute/test.i)
[Mesh]
type = UniformTensorMesh
dim = 2
nx = 100
ny = 100
nz = 100
xmax = ${fparse pi*4}
ymax = ${fparse pi*4}
zmax = ${fparse pi*4}
[]
[TensorBuffers]
[eta]
[]
[eta_bar]
[]
[f]
[]
[fbar]
[]
[kappa_k2]
[]
[]
[TensorComputes]
[Initialize]
[eta]
type = ParsedTensor
buffer = eta
function = 'sin(x)+sin(y)+sin(z)'
[]
[kappa_k2]
type = ReciprocalLaplacianFactor
factor = 0.2
buffer = kappa_k2
[]
[]
[Solve]
[f]
type = ParsedCompute
buffer = f
expression = '0.1*(eta+2)^2*(eta-2)^2'
derivatives = eta
inputs = eta
[]
[fbar]
type = ForwardFFT
buffer = fbar
input = f
[]
[eta_bar]
type = ForwardFFT
buffer = eta_bar
input = eta
[]
[]
[]
[TensorTimeIntegrators]
[eta]
type = FFTSemiImplicit
buffer = eta
reciprocal_buffer = eta_bar
linear_reciprocal = kappa_k2
nonlinear_reciprocal = fbar
[]
[]
[AuxVariables]
[eta]
[]
[f]
[]
[]
[AuxKernels]
[eta]
type = ProjectTensorAux
buffer = eta
variable = eta
execute_on = TIMESTEP_END
[]
[f]
type = ProjectTensorAux
buffer = f
variable = f
execute_on = TIMESTEP_END
[]
[]
[Postprocessors]
[min_eta]
type = ElementExtremeValue
variable = eta
value_type = MIN
execute_on = 'TIMESTEP_END'
[]
[max_eta]
type = ElementExtremeValue
variable = eta
value_type = MAX
execute_on = 'TIMESTEP_END'
[]
[F]
type = ElementIntegralVariablePostprocessor
variable = f
execute_on = 'TIMESTEP_END'
[]
[Eta]
type = ElementIntegralVariablePostprocessor
variable = eta
execute_on = 'TIMESTEP_END'
[]
[]
[Problem]
type = TensorProblem
[]
[Executioner]
type = Transient
num_steps = 100
dt = 0.1
[]
[Outputs]
exodus = true
csv = true
perf_graph = true
execute_on = 'TIMESTEP_END'
[]
(test/tests/kks/KKS_libtorch.i)
#
# Kim-Kim-Suzuki with Gibbs energy supplied by a torch model, solved on a 2D grid.
#
# Constants for Initial Conditions
r = 30
l = 4.2
# Initial condition function for order parameter
eta_IC = '0.5*(1-tanh(2*(sqrt(x^2+y^2)-${r})/${l}))'
# Phase-field model parameters
kappa_eta = 5
w = 1
M = 5
L = 5
# Expressions for switching function and bulk Gibbs energy
h_eta = 'eta^3*(6*eta^2-15*eta+10)'
[Domain]
dim = 2
nx = 50
ny = 50
xmin = -50
xmax = 50
ymin = -50
ymax = 50
# automatically create a matching mesh
mesh_mode = DUMMY
[]
[TensorComputes]
[Initialize]
[c_IC]
type = ParsedCompute
buffer = c
expression = '0.7 + (0.3-0.6)*${eta_IC}'
extra_symbols = 'true'
[]
[eta_IC]
type = ParsedCompute
buffer = eta
expression = '${eta_IC}'
extra_symbols = 'true'
[]
[psi_init]
type = ConstantTensor
buffer = psi
real = 1
[]
[M]
type = ConstantTensor
buffer = M
real = ${M}
[]
[L]
type = ConstantTensor
buffer = L
real = ${L}
[]
[L_kappa]
type = ReciprocalLaplacianFactor
buffer = L_kappa
factor = ${fparse ${L} * ${kappa_eta} }
[]
[h_eta_IC]
type = ParsedCompute
buffer = h_eta
expression = '${h_eta}'
inputs = eta
[]
[G_func_IC]
type = LibtorchGibbsEnergy
buffer = 'G'
phase_fractions = 'h_eta'
concentrations = 'c'
domega_detas = 'dG_dh'
chem_pots = 'mu'
libtorch_model_file = 'marlin:libtorch_gibbs_energy/torch_NN_gibbs_model.pt'
[]
[]
[Solve]
[h_eta]
type = ParsedCompute
buffer = h_eta
expression = '${h_eta}'
inputs = eta
[]
[G_func]
type = LibtorchGibbsEnergy
buffer = 'G'
phase_fractions = 'h_eta'
concentrations = 'c'
domega_detas = 'dG_dh'
chem_pots = 'mu'
libtorch_model_file = 'marlin:libtorch_gibbs_energy/torch_NN_gibbs_model.pt'
[]
[dG_deta]
type = ParsedCompute
buffer = 'dG_deta'
inputs = 'eta dG_dh'
expression = 'dG_dh * ${h_eta} + ${w} * eta^2 * (1-eta^2)^2'
derivatives = 'eta'
[]
[etabar]
type = ForwardFFT
buffer = etabar
input = eta
[]
[AC_bulk]
type = ReciprocalAllenCahn
L = L
buffer = AC_bulk
dF_chem_deta = dG_deta
psi = psi
[]
[NL_eta]
type = ParsedCompute
buffer = NL_eta
expression = 'AC_bulk '
inputs = 'AC_bulk'
[]
[cbar]
type = ForwardFFT
buffer = cbar
input = c
[]
[div_J]
type = ReciprocalMatDiffusion
buffer = 'div_J'
chemical_potential = mu
mobility = M
psi = psi
[]
[]
[]
[TensorSolver]
type = AdamsBashforthMoulton
buffer = 'c eta'
reciprocal_buffer = 'cbar etabar'
linear_reciprocal = '0 L_kappa'
nonlinear_reciprocal = 'div_J NL_eta'
substeps = 1e3
predictor_order = 3
[]
[TensorOutputs]
[xdmf]
type = XDMFTensorOutput
buffer = 'eta c mu psi dG_deta dG_dh G'
enable_hdf5 = true
transpose = false
[]
[]
[Executioner]
type = Transient
dt = 0.1
num_steps = 10
[]
[Outputs]
csv = true
perf_graph = true
execute_on = 'INITIAL TIMESTEP_END'
[]
(benchmarks/02_oswald_ripening/2a_broyden.i)
[Domain]
dim = 2
nx = 200
ny = 200
xmax = 200
ymax = 200
device_names = 'cuda:0'
mesh_mode = DOMAIN
[]
fchem='fa:=rho^2*(c-ca)^2;
fb:=rho^2*(cb-c)^2;
h:=n1^3*(6*n1^2-15*n1+10) +
n2^3*(6*n2^2-15*n2+10) +
n3^3*(6*n3^2-15*n3+10) +
n4^3*(6*n4^2-15*n4+10);
g:=n1^2*(1-n1)^2 +
n2^2*(1-n2)^2 +
n3^2*(1-n3)^2 +
n4^2*(1-n4)^2 +
alpha*(
n1^2*n2^2 + n1^2*n3^2 + n1^2*n4^2 +
n2^2*n1^2 + n2^2*n3^2 + n2^2*n4^2 +
n3^2*n1^2 + n3^2*n2^2 + n3^2*n4^2 +
n4^2*n1^2 + n4^2*n2^2 + n4^2*n3^2);
(fa*(1-h) + fb*h + w*g)'
nic = 'epsilon*(cos((0.01*idx)*x-4)*cos((0.007+0.01*idx)*y)
+cos((0.11+0.01*idx)*x)*cos((0.11+0.01*idx)*y)
+psi*(cos((0.046+0.001*idx)*x+(0.0405+0.001*idx)*y)
*cos((0.031+0.001*idx)*x-(0.004+0.001*idx)*y))^2)^2'
cnames = 'rho ca cb alpha w L M'
cvalues= 'sqrt(2) 0.3 0.7 5 1 5 5'
[TensorBuffers]
# variables
[c]
map_to_aux_variable = c
[]
[n1]
[]
[n2]
[]
[n3]
[]
[n4]
[]
[c_bar]
[]
[n1_bar]
[]
[n2_bar]
[]
[n3_bar]
[]
[n4_bar]
[]
[mu_c]
# map_to_aux_variable = mu
[]
[mu_n1]
[]
[mu_n2]
[]
[mu_n3]
[]
[mu_n4]
[]
[mu_c_bar]
[]
[mu_n1_bar]
[]
[mu_n2_bar]
[]
[mu_n3_bar]
[]
[mu_n4_bar]
[]
[Mbar_mu_c_bar]
[]
# constant tensors
[Lbar] # FFT(M*laplacian)
[]
[MkappaL2bar] # FFT(-M*kappa*laplacian^2)
[]
[kappaLbar] # FFT(L*kappa*laplacian)
[]
# postprocessing
[F]
[]
[Fgrad_c]
[]
[Fgrad_n1]
[]
[Fgrad_n2]
[]
[Fgrad_n3]
[]
[Fgrad_n4]
[]
[bnds]
map_to_aux_variable = bnds
[]
[]
[TensorComputes]
[Initialize]
[c]
type = ParsedCompute
buffer = c
extra_symbols = true
expression = 'c0+epsilon*(cos(0.105*x)*cos(0.11*y)+(cos(0.13*x)*cos(0.087*y))^2+cos(0.025*x-0.15*y)*cos(0.07*x-0.02*y))'
constant_names = 'c0 epsilon'
constant_expressions = '0.5 0.01'
[]
[Lbar]
type = ReciprocalLaplacianFactor
# Mobility is pulled into the chemical potential below
buffer = Lbar
[]
[MkappaL2bar]
type = ReciprocalLaplacianSquareFactor
factor = -15 # -kappa_c*M
buffer = MkappaL2bar
[]
[kappaLbar]
type = ReciprocalLaplacianFactor
buffer = kappaLbar
factor = 15 # kappa_ni*L
[]
[n1]
type = ParsedCompute
buffer = n1
expression = ${nic}
extra_symbols = true
constant_names = 'idx epsilon psi'
constant_expressions = ' 1 0.1 1.5'
[]
[n2]
type = ParsedCompute
buffer = n2
expression = ${nic}
extra_symbols = true
constant_names = 'idx epsilon psi'
constant_expressions = ' 2 0.1 1.5'
[]
[n3]
type = ParsedCompute
buffer = n3
expression = ${nic}
extra_symbols = true
constant_names = 'idx epsilon psi'
constant_expressions = ' 3 0.1 1.5'
[]
[n4]
type = ParsedCompute
buffer = n4
expression = ${nic}
extra_symbols = true
constant_names = 'idx epsilon psi'
constant_expressions = ' 4 0.1 1.5'
[]
[]
[Solve]
[mu_c]
type = ParsedCompute
buffer = mu_c
expression = '${fchem}*M'
constant_names = ${cnames}
constant_expressions = ${cvalues}
derivatives = c
inputs = 'c n1 n2 n3 n4'
[]
[mu_n1]
type = ParsedCompute
buffer = mu_n1
expression = '${fchem}*(-L)'
constant_names = ${cnames}
constant_expressions = ${cvalues}
derivatives = n1
inputs = 'c n1 n2 n3 n4'
[]
[mu_n2]
type = ParsedCompute
buffer = mu_n2
expression = '${fchem}*(-L)'
constant_names = ${cnames}
constant_expressions = ${cvalues}
derivatives = n2
inputs = 'c n1 n2 n3 n4'
[]
[mu_n3]
type = ParsedCompute
buffer = mu_n3
expression = '${fchem}*(-L)'
constant_names = ${cnames}
constant_expressions = ${cvalues}
derivatives = n3
inputs = 'c n1 n2 n3 n4'
[]
[mu_n4]
type = ParsedCompute
buffer = mu_n4
expression = '${fchem}*(-L)'
constant_names = ${cnames}
constant_expressions = ${cvalues}
derivatives = n4
inputs = 'c n1 n2 n3 n4'
[]
[mu_c_bar]
type = ForwardFFT
buffer = mu_c_bar
input = mu_c
[]
[mu_n1_bar]
type = ForwardFFT
buffer = mu_n1_bar
input = mu_n1
[]
[mu_n2_bar]
type = ForwardFFT
buffer = mu_n2_bar
input = mu_n2
[]
[mu_n3_bar]
type = ForwardFFT
buffer = mu_n3_bar
input = mu_n3
[]
[mu_n4_bar]
type = ForwardFFT
buffer = mu_n4_bar
input = mu_n4
[]
[Mbar_mu_c_bar]
type = ParsedCompute
buffer = Mbar_mu_c_bar
expression = 'Lbar*mu_c_bar'
inputs = 'Lbar mu_c_bar'
[]
[c_bar]
type = ForwardFFT
buffer = c_bar
input = c
[]
[n1_bar]
type = ForwardFFT
buffer = n1_bar
input = n1
[]
[n2_bar]
type = ForwardFFT
buffer = n2_bar
input = n2
[]
[n3_bar]
type = ForwardFFT
buffer = n3_bar
input = n3
[]
[n4_bar]
type = ForwardFFT
buffer = n4_bar
input = n4
[]
[]
[Postprocess]
[Fgrad_c]
type = FFTGradientSquare
buffer = Fgrad_c
input = c
factor = 1.5 # kappa/2
[]
[Fgrad_n1]
type = FFTGradientSquare
buffer = Fgrad_n1
input = n1
factor = 1.5 # kappa/2
[]
[Fgrad_n2]
type = FFTGradientSquare
buffer = Fgrad_n2
input = n2
factor = 1.5 # kappa/2
[]
[Fgrad_n3]
type = FFTGradientSquare
buffer = Fgrad_n3
input = n3
factor = 1.5 # kappa/2
[]
[Fgrad_n4]
type = FFTGradientSquare
buffer = Fgrad_n4
input = n4
factor = 1.5 # kappa/2
[]
[F]
type = ParsedCompute
buffer = F
expression = '${fchem} + Fgrad_c + Fgrad_n1 + Fgrad_n2 + Fgrad_n3 + Fgrad_n4'
constant_names = ${cnames}
constant_expressions = ${cvalues}
inputs = 'c n1 n2 n3 n4 Fgrad_c Fgrad_n1 Fgrad_n2 Fgrad_n3 Fgrad_n4'
[]
[bnds]
type = ParsedCompute
buffer = bnds
expression = 'n1^2 + n2^2 + n3^2 + n4^2'
inputs = 'n1 n2 n3 n4'
[]
[]
[]
[TensorSolver]
type = BroydenSolver
substeps = 10
max_iterations = 1000
damping = 0.5
relative_tolerance = 1e-6
absolute_tolerance = 1e-5
buffer = 'c n1 n2 n3 n4'
dt_epsilon = 1e-5
reciprocal_buffer = 'c_bar n1_bar n2_bar n3_bar n4_bar'
linear_reciprocal = 'MkappaL2bar kappaLbar kappaLbar kappaLbar kappaLbar'
nonlinear_reciprocal = 'Mbar_mu_c_bar mu_n1_bar mu_n2_bar mu_n3_bar mu_n4_bar'
# verbose = true
[]
[AuxVariables]
[c]
[]
[bnds]
[]
[]
[Postprocessors]
[min_c]
type = TensorExtremeValuePostprocessor
buffer = c
value_type = MIN
execute_on = 'TIMESTEP_END'
[]
[max_c]
type = TensorExtremeValuePostprocessor
buffer = c
value_type = MAX
execute_on = 'TIMESTEP_END'
[]
[F]
type = TensorIntegralPostprocessor
buffer = F
[]
[]
[Problem]
type = TensorProblem
[]
[Executioner]
type = Transient
# num_steps = 2
end_time = 1e+5
[TimeStepper]
type = TensorSolveIterationAdaptiveDT
dt = 1e-4
max_iterations = 500
min_iterations = 100
growth_factor = 1.1
[]
[]
[Outputs]
exodus = true
csv = true
perf_graph = true
execute_on = 'TIMESTEP_END'
[]
(test/tests/implicit_fd/poisson_mms.i)
# Steady periodic Poisson problem -D Laplacian(u) = f with the manufactured
# solution u = sin(2 pi x) cos(4 pi y) + cos(6 pi x) / 2 (zero mean). The
# operator is singular (constants), and the solver returns the zero-mean
# solution, so the error against u converges at the stencil order (2 for the
# 3-point, 4 for the 5-point stencil).
D = 0.5
n = 32
[Domain]
dim = 2
nx = ${n}
ny = ${n}
xmax = 1
ymax = 1
parallel_mode = REAL_SPACE
periodic_directions = 'X Y'
[]
[TensorBuffers]
[u]
[]
[lap_u]
[]
[f]
[]
[exact]
[]
[diff]
[]
[]
[TensorComputes]
[Initialize]
[u_ic]
type = ParsedCompute
buffer = u
# initial guess (any field; the solve returns the zero-mean solution)
expression = 'sin(2*pi*x) * sin(2*pi*y)'
extra_symbols = true
[]
[f_ic]
type = ParsedCompute
buffer = f
# -D Laplacian(u): the two modes have |k|^2 = 20 pi^2 and 36 pi^2
expression = 'D * (20 * pi^2 * sin(2*pi*x) * cos(4*pi*y) + 18 * pi^2 * cos(6*pi*x))'
constant_names = 'D'
constant_expressions = '${D}'
extra_symbols = true
[]
[]
[Solve]
[lap]
type = FiniteDifferenceLaplacian
buffer = lap_u
input = u
factor = '${fparse -D}'
[]
[]
[Postprocess]
[exact_compute]
type = ParsedCompute
buffer = exact
expression = 'sin(2*pi*x) * cos(4*pi*y) + cos(6*pi*x) / 2'
extra_symbols = true
[]
[diff_compute]
type = ParsedCompute
buffer = diff
expression = 'abs(u - exact)'
inputs = 'u exact'
[]
[]
[]
[TensorSolver]
type = ImplicitFDSolver
buffer = u
operators = 'lap'
source = f
[]
[Postprocessors]
[max_error]
type = TensorExtremeValuePostprocessor
buffer = diff
value_type = MAX
[]
[mean_u]
type = TensorAveragePostprocessor
buffer = u
[]
[]
[Problem]
type = TensorProblem
[]
[Executioner]
type = Transient
num_steps = 1
[]
[Outputs]
csv = true
[]
(test/tests/real_space/laplacian.i)
[Domain]
dim = 2
nx = 80
ny = 60
parallel_mode = REAL_SPACE
periodic_directions = 'X Y'
xmin = -1
ymin = -1
xmax = 1
ymax = 1
[]
[TensorBuffers]
[u]
type = PlainTensorBuffer
[]
[u_gold]
type = PlainTensorBuffer
[]
[lap]
type = PlainTensorBuffer
[]
[]
[TensorComputes]
[Initialize]
[u_ic]
type = ParsedCompute
buffer = u
expression = 'sin(pi*(x+0.5))*sin(pi*(y+0.5))'
extra_symbols = true
[]
[lap_gold_ic]
type = ParsedCompute
buffer = lap_gold
#expression = '0'
expression = '-2*pi*pi*sin(pi*(x+0.5))*sin(pi*(y+0.5))'
extra_symbols = true
expand = REAL
[]
[]
[Solve]
[lap_compute]
type = FiniteDifferenceLaplacian
input = u
buffer = lap
[]
[diff]
type = ParsedCompute
buffer = diff
expression = 'abs(lap - lap_gold)'
inputs = 'lap lap_gold'
[]
[]
[]
[Postprocessors]
[max_error]
type = TensorExtremeValuePostprocessor
buffer = diff
value_type = MAX
[]
[]
[TensorOutputs]
active = ''
[lap]
type = XDMFTensorOutput
buffer = 'lap lap_gold diff'
enable_hdf5 = true
[]
[]
[Executioner]
type = Transient
num_steps = 1
[]
[Outputs]
[out]
type = CSV
[]
[]
(test/tests/tensor_compute/coupled_pf_mech_secant.i)
[Domain]
dim = 3
nx = 128
ny = 128
nz = 128
xmax = ${fparse pi*4}
ymax = ${fparse pi*4}
zmax = ${fparse pi*4}
mesh_mode = DUMMY
[]
[TensorBuffers]
# phase field
[c]
[]
[cbar]
[]
[mu]
[]
[mubar]
[]
[Mbarmubar]
[]
# mechanics
[disp_x]
[]
[disp_y]
[]
[disp_z]
[]
[mumechbar]
[]
[mumech]
[]
# constant tensors
[Mbar]
[]
[kappabarbar]
[]
[]
[TensorOutputs]
[xdmf]
type = XDMFTensorOutput
buffer = 'c disp_x disp_y disp_z mu mumech'
output_mode = 'Node Node Node Node Cell Cell'
enable_hdf5 = true
[]
[]
[TensorComputes]
[Initialize]
[c]
type = RandomTensor
buffer = c
min = 0.44
max = 0.56
[]
[mu_init]
type = ConstantTensor
buffer = mu
[]
[mumech_init]
type = ConstantTensor
buffer = mumech
[]
[disp_x]
type = RandomTensor
buffer = disp_x
min = 0
max = 0
[]
[disp_y]
type = RandomTensor
buffer = disp_y
min = 0
max = 0
[]
[disp_z]
type = RandomTensor
buffer = disp_z
min = 0
max = 0
[]
[Mbar]
type = ReciprocalLaplacianFactor
factor = 0.2 # Mobility
buffer = Mbar
[]
[kappabarbar]
type = ReciprocalLaplacianSquareFactor
factor = -0.001 # kappa
buffer = kappabarbar
[]
[]
[Solve]
[mu]
# chemical potential (real space)
type = ParsedCompute
buffer = mu
expression = '0.1*c^2*(c-1)^2' # + c*sin(x/2)*0.005'
extra_symbols = true
derivatives = c
inputs = c
[]
[mubar]
# chemical potential (reciprocal space)
type = ForwardFFT
buffer = mubar
input = mu
[]
[mumechbar]
# mechanical chemical potential (reciprocal space)
type = FFTElasticChemicalPotential
buffer = mumechbar
cbar = cbar
displacements = 'disp_x disp_y disp_z'
lambda = 100
mu = 50
e0 = 0.02
[]
[mumech]
# chemical potential (reciprocal space)
type = InverseFFT
buffer = mumech
input = mumechbar
[]
[Mbarmubar]
type = ParsedCompute
buffer = Mbarmubar
expression = 'Mbar*(mubar+mumechbar)'
inputs = 'Mbar mubar mumechbar'
[]
[cbar]
type = ForwardFFT
buffer = cbar
input = c
[]
[qsmech]
type = FFTQuasistaticElasticity
displacements = 'disp_x disp_y disp_z'
cbar = cbar
lambda = 100
mu = 50
e0 = 0.02
[]
[]
[]
[TensorSolver]
type = SecantSolver
substeps = 1
max_iterations = 1000
# damping = 0.75
relative_tolerance = 1e-6
absolute_tolerance = 1e-6
buffer = c
dt_epsilon = 1e-7
reciprocal_buffer = cbar
linear_reciprocal = kappabarbar
nonlinear_reciprocal = Mbarmubar
verbose = true
[]
[Postprocessors]
[min_c]
type = TensorExtremeValuePostprocessor
buffer = c
value_type = MIN
execute_on = 'TIMESTEP_END'
[]
[max_c]
type = TensorExtremeValuePostprocessor
buffer = c
value_type = MAX
execute_on = 'TIMESTEP_END'
[]
[min_disp_x]
type = TensorExtremeValuePostprocessor
buffer = disp_x
value_type = MIN
execute_on = 'TIMESTEP_END'
[]
[max_disp_x]
type = TensorExtremeValuePostprocessor
buffer = disp_x
value_type = MAX
execute_on = 'TIMESTEP_END'
[]
[min_disp_y]
type = TensorExtremeValuePostprocessor
buffer = disp_y
value_type = MIN
execute_on = 'TIMESTEP_END'
[]
[max_disp_y]
type = TensorExtremeValuePostprocessor
buffer = disp_y
value_type = MAX
execute_on = 'TIMESTEP_END'
[]
[min_disp_z]
type = TensorExtremeValuePostprocessor
buffer = disp_z
value_type = MIN
execute_on = 'TIMESTEP_END'
[]
[max_disp_z]
type = TensorExtremeValuePostprocessor
buffer = disp_z
value_type = MAX
execute_on = 'TIMESTEP_END'
[]
[C]
type = TensorIntegralPostprocessor
buffer = c
execute_on = 'TIMESTEP_END'
[]
[cavg]
type = TensorAveragePostprocessor
buffer = c
execute_on = 'TIMESTEP_END'
[]
[]
[Problem]
type = TensorProblem
[]
[Executioner]
type = Transient
end_time = 100
[TimeStepper]
type = TensorSolveIterationAdaptiveDT
dt = 0.1
max_iterations = 500
min_iterations = 300
growth_factor = 1.1
cutback_factor = 0.9
[]
[]
[Outputs]
csv = true
perf_graph = true
execute_on = 'TIMESTEP_END'
[]
(test/tests/mechanics/mech3d.i)
[Domain]
dim = 3
nx = 16
ny = 16
nz = 16
xmax = ${fparse 2*pi}
ymax = ${fparse 2*pi}
zmax = ${fparse 2*pi}
mesh_mode = DUMMY
parallel_mode = FFT_AUTO
[]
[TensorComputes]
[Initialize]
[phase]
type = ParsedCompute
expression = '(cos(x)/2+0.5)^1*(cos(y)/2+0.5)^1*(cos(z)/2+0.5)^1'
extra_symbols = true
buffer = phase
[]
[K]
type = ParsedCompute
buffer = K
expression = '(1-phase)*Ka + phase*Kb'
inputs = phase
constant_names = 'Ka Kb'
constant_expressions = '1 10'
[]
[mu]
type = ParsedCompute
buffer = mu
expression = '(1-phase)*mua + phase*mub'
inputs = phase
constant_names = 'mua mub'
constant_expressions = '0.5 5'
[]
[Finit]
type = RankTwoIdentity
buffer = F
[]
[]
[Solve]
[hyper_elasticity]
type = HyperElasticIsotropic
buffer = stress
F = Fnew
K = K
mu = mu
[]
[root]
[applied_strain]
type = MacroscopicShearTensor
buffer = applied_strain
[]
[mech]
type = FFTMechanics
buffer = Fnew
F = F
K = K
mu = mu
l_tol = 1e-2
nl_rel_tol = 2e-2
nl_abs_tol = 2e-2
constitutive_model = hyper_elasticity
stress = stress
applied_macroscopic_strain = applied_strain
[]
[]
[]
[Postprocess]
[displacements]
type = ComputeDisplacements
buffer = disp
F = F
[]
[vonmises]
type = ComputeVonMisesStress
buffer = sV
[]
[]
[]
[TensorSolver]
# no variables are integrated by this solver (FFTMechanics performs a steady state mechanics solve)
type = ForwardEulerSolver
root_compute = root
# deformation tensor is just forwarded Fnew -> F
forward_buffer = F
forward_buffer_new = Fnew
substeps = 10
[]
[TensorOutputs]
active = 'parallel' # serial
[serial]
type = XDMFTensorOutput
file_base = mech3d_serial
buffer = 'disp sV F phase'
output_mode = 'OVERSIZED_NODAL CELL CELL NODE'
enable_hdf5 = true
execute_on = 'TIMESTEP_END'
[]
[parallel]
# NODE and OVERSIZED_NODAL are not yet available in parallel output
type = XDMFTensorOutput
file_base = mech3d_parallel
buffer = 'sV F phase'
output_mode = 'CELL CELL CELL'
enable_hdf5 = true
execute_on = 'TIMESTEP_END'
[]
[]
[Executioner]
type = Transient
num_steps = 3
dt = 0.01
[]
(examples/cahn_hilliard/cahnhilliard2.i)
#
# The same simple Cahn-Hilliard solve as cahnhilliard.i, but on a 3D grid
# and using the faster TensorOutputs system.
#
[Domain]
dim = 3
nx = 200
ny = 200
nz = 200
xmax = ${fparse pi*8}
ymax = ${fparse pi*8}
zmax = ${fparse pi*8}
# run on a CUDA device (adjust this to `cpu` if not available)
device_names = 'cuda'
# create a single element dummy mesh. Output will use the custom XDMF output
# in the `TensorOutputs` system.
mesh_mode = DUMMY
[]
[TensorBuffers]
[c]
[]
[cbar]
[]
[mu]
[]
[mubar]
[]
[Mbarmubar]
[]
# constant tensors
[Mbar]
[]
[kappabarbar]
[]
[]
[TensorOutputs]
# the TensorOutouts system supports asynchronous threaded output.
# for GOU calculations a copy of the solution fields is moved to the CPU,
# and while the output files are written the next time step is already
# starting to compute.
[xdmf]
type = XDMFTensorOutput
buffer = 'c mu'
enable_hdf5 = true
[]
[]
[TensorComputes]
[Initialize]
[c]
type = RandomTensor
buffer = c
min = 0.44
max = 0.56
[]
[Mbar]
type = ReciprocalLaplacianFactor
factor = 0.2 # Mobility
buffer = Mbar
[]
[kappabarbar]
type = ReciprocalLaplacianSquareFactor
factor = -0.001 # kappa
buffer = kappabarbar
[]
[]
[Solve]
[mu]
type = ParsedCompute
buffer = mu
expression = '0.1*c^2*(c-1)^2'
derivatives = c
inputs = c
[]
[mubar]
type = ForwardFFT
buffer = mubar
input = mu
[]
[Mbarmubar]
type = ParsedCompute
buffer = Mbarmubar
expression = 'Mbar*mubar'
inputs = 'Mbar mubar'
[]
[cbar]
type = ForwardFFT
buffer = cbar
input = c
[]
[]
[]
[TensorSolver]
type = AdamsBashforthMoulton
buffer = c
reciprocal_buffer = cbar
linear_reciprocal = kappabarbar
nonlinear_reciprocal = Mbarmubar
substeps = 1000
[]
[Postprocessors]
[min_c]
type = TensorExtremeValuePostprocessor
buffer = c
value_type = MIN
execute_on = 'TIMESTEP_END'
[]
[max_c]
type = TensorExtremeValuePostprocessor
buffer = c
value_type = MAX
execute_on = 'TIMESTEP_END'
[]
[C]
type = TensorIntegralPostprocessor
buffer = c
execute_on = 'TIMESTEP_END'
[]
[cavg]
type = TensorAveragePostprocessor
buffer = c
execute_on = 'TIMESTEP_END'
[]
[]
[Problem]
type = TensorProblem
[]
[Executioner]
type = Transient
num_steps = 100
[TimeStepper]
type = IterationAdaptiveDT
growth_factor = 1.8
dt = 0.1
[]
dtmax = 1000
[]
[Outputs]
csv = true
perf_graph = true
execute_on = 'TIMESTEP_END'
[]
(test/tests/lbm/stacking.i)
[Domain]
dim = 2
nx = 10
ny = 10
mesh_mode = DUMMY
parallel_mode = REAL_SPACE
periodic_directions = 'X Y'
[]
[Stencil]
[d2q9]
type = LBMD2Q9
[]
[]
[TensorBuffers]
[ux]
type=LBMTensorBuffer
buffer_type = ms
[]
[uy]
type=LBMTensorBuffer
buffer_type = ms
[]
[u]
type=LBMTensorBuffer
buffer_type = mv
[]
[]
[TensorComputes/Initialize]
[velocity_x]
type = ParsedCompute
buffer = ux
expression = '0.1*sin(x/(2*pi*4))*cos(y/(2*pi*4))'
extra_symbols=true
[]
[velocity_y]
type = ParsedCompute
buffer = uy
expression = '-0.1*cos(x/(2*pi*4))*sin(y/(2*pi*4))'
extra_symbols=true
[]
[u_stack]
type=LBMStackTensors
buffer=u
inputs='ux uy'
[]
[]
[Problem]
type = LatticeBoltzmannProblem
substeps = 1
[]
[Postprocessors]
[velocity_x_min]
type = TensorExtremeValuePostprocessor
buffer = ux
value_type = MIN
[]
[velocity_x_max]
type = TensorExtremeValuePostprocessor
buffer = ux
value_type = MAX
[]
[velocity_y_min]
type = TensorExtremeValuePostprocessor
buffer = uy
value_type = MIN
[]
[velocity_y_max]
type = TensorExtremeValuePostprocessor
buffer = uy
value_type = MAX
[]
[u_stack_min]
type = TensorExtremeValuePostprocessor
buffer = u
value_type = MIN
[]
[u_stack_max]
type = TensorExtremeValuePostprocessor
buffer = u
value_type = MAX
[]
[]
[Executioner]
type = Transient
num_steps = 2
[]
[Outputs]
file_base = stacking
csv = true
[]
(test/tests/tensor_compute/group.i)
[Domain]
dim = 3
nx = 128
ny = 128
nz = 128
xmax = ${fparse pi*4}
ymax = ${fparse pi*4}
zmax = ${fparse pi*4}
mesh_mode = DUMMY
[]
[TensorBuffers]
# phase field
[c]
[]
[cbar]
[]
[mu]
[]
[mubar]
[]
[Mbarmubar]
[]
# mechanics
[disp_x]
[]
[disp_y]
[]
[disp_z]
[]
[mumechbar]
[]
[mumech]
[]
# constant tensors
[Mbar]
[]
[kappabarbar]
[]
[]
[TensorOutputs]
[xdmf]
type = XDMFTensorOutput
buffer = 'c disp_x disp_y disp_z mu mumech'
output_mode = 'Node Node Node Node Cell Cell'
enable_hdf5 = true
[]
[]
[TensorComputes]
[Initialize]
[c]
type = RandomTensor
buffer = c
min = 0.44
max = 0.56
[]
[disp_x]
type = RandomTensor
buffer = disp_x
min = 0
max = 0
[]
[disp_y]
type = RandomTensor
buffer = disp_y
min = 0
max = 0
[]
[disp_z]
type = RandomTensor
buffer = disp_z
min = 0
max = 0
[]
[Mbar]
type = ReciprocalLaplacianFactor
factor = 0.2 # Mobility
buffer = Mbar
[]
[kappabarbar]
type = ReciprocalLaplacianSquareFactor
factor = -0.001 # kappa
buffer = kappabarbar
[]
[]
[Solve]
[mu]
# chemical potential (real space)
type = ParsedCompute
buffer = mu
expression = '0.1*c^2*(c-1)^2' # + c*sin(x/2)*0.005'
extra_symbols = true
derivatives = c
inputs = c
[]
[mubar]
# chemical potential (reciprocal space)
type = ForwardFFT
buffer = mubar
input = mu
[]
[mumechbar]
# mechanical chemical potential (reciprocal space)
type = FFTElasticChemicalPotential
buffer = mumechbar
cbar = cbar
displacements = 'disp_x disp_y disp_z'
lambda = 100
mu = 50
e0 = 0.02
[]
[mumech]
# chemical potential (reciprocal space)
type = InverseFFT
buffer = mumech
input = mumechbar
[]
[Mbarmubar]
type = ParsedCompute
buffer = Mbarmubar
expression = 'Mbar*(mubar+mumechbar)'
inputs = 'Mbar mubar mumechbar'
[]
[cbar]
type = ForwardFFT
buffer = cbar
input = c
[]
[qsmech]
type = FFTQuasistaticElasticity
displacements = 'disp_x disp_y disp_z'
cbar = cbar
lambda = 100
mu = 50
e0 = 0.02
[]
[group]
type = ComputeGroup
computes = 'cbar mumech mu mubar'
[]
[]
[]
[TensorSolver]
type = AdamsBashforthMoulton
buffer = c
reciprocal_buffer = cbar
linear_reciprocal = kappabarbar
nonlinear_reciprocal = Mbarmubar
[]
[Postprocessors]
[min_c]
type = TensorExtremeValuePostprocessor
buffer = c
value_type = MIN
execute_on = 'TIMESTEP_END'
[]
[max_c]
type = TensorExtremeValuePostprocessor
buffer = c
value_type = MAX
execute_on = 'TIMESTEP_END'
[]
[min_disp_x]
type = TensorExtremeValuePostprocessor
buffer = disp_x
value_type = MIN
execute_on = 'TIMESTEP_END'
[]
[max_disp_x]
type = TensorExtremeValuePostprocessor
buffer = disp_x
value_type = MAX
execute_on = 'TIMESTEP_END'
[]
[min_disp_y]
type = TensorExtremeValuePostprocessor
buffer = disp_y
value_type = MIN
execute_on = 'TIMESTEP_END'
[]
[max_disp_y]
type = TensorExtremeValuePostprocessor
buffer = disp_y
value_type = MAX
execute_on = 'TIMESTEP_END'
[]
[min_disp_z]
type = TensorExtremeValuePostprocessor
buffer = disp_z
value_type = MIN
execute_on = 'TIMESTEP_END'
[]
[max_disp_z]
type = TensorExtremeValuePostprocessor
buffer = disp_z
value_type = MAX
execute_on = 'TIMESTEP_END'
[]
[C]
type = TensorIntegralPostprocessor
buffer = c
execute_on = 'TIMESTEP_END'
[]
[cavg]
type = TensorAveragePostprocessor
buffer = c
execute_on = 'TIMESTEP_END'
[]
[]
[Problem]
type = TensorProblem
spectral_solve_substeps = 1000
print_debug_output = true
[]
[Executioner]
type = Transient
num_steps = 100
[TimeStepper]
type = IterationAdaptiveDT
growth_factor = 1.8
dt = 0.1
[]
dtmax = 1000
[]
[Outputs]
csv = true
perf_graph = true
execute_on = 'TIMESTEP_END'
[]
(test/tests/implicit_fd/be_mode.i)
# Backward Euler diffusion u_t = D Laplacian(u) of a single periodic Fourier
# mode. On the periodic cell-centred grid the mode is an eigenvector of the
# discrete Laplacian with eigenvalue -lambda_h, so every implicit step must
# multiply it by exactly g = 1 / (1 + dt D lambda_h), up to the linear solver
# tolerance.
D = 0.5
# 5 steps of dt, then 5 steps of dt2 (dt2 != dt exercises the operator rebuild)
dt = 0.01
dt2 = 0.01
n = 32
stencil = 3
dim = 2
# Symbol of -Laplacian per axis for the wavenumber 2 pi, h = 1/n:
# 3-point: (2 - 2 cos(2 pi h)) / h^2
# 5-point: (5/2 - 8/3 cos(2 pi h) + 1/6 cos(4 pi h)) / h^2
lambda3 = '${fparse n^2 * (2 - 2 * cos(2 * pi / n))}'
lambda5 = '${fparse n^2 * (5 / 2 - 8 / 3 * cos(2 * pi / n) + 1 / 6 * cos(4 * pi / n))}'
lambda = '${fparse dim * if(stencil = 3, lambda3, lambda5)}'
[Domain]
dim = 2
nx = ${n}
ny = ${n}
xmax = 1
ymax = 1
parallel_mode = REAL_SPACE
periodic_directions = 'X Y'
[]
[TensorBuffers]
[u]
[]
[dudt_u]
[]
[lap_u]
[]
[gold]
[]
[diff]
[]
[]
[TensorComputes]
[Initialize]
[u_ic]
type = ParsedCompute
buffer = u
expression = 'sin(2*pi*x)*sin(2*pi*y)'
extra_symbols = true
[]
[]
[Solve]
[dudt]
type = TimeDerivativeOperator
buffer = dudt_u
input = u
[]
[lap]
type = FiniteDifferenceLaplacian
buffer = lap_u
input = u
factor = '${fparse -D}'
stencil_width = ${stencil}
[]
[]
[Postprocess]
[gold_compute]
type = ParsedCompute
buffer = gold
# g(dt)^(t/dt) up to t1 = 5 dt, then g(dt)^5 g(dt2)^((t - t1)/dt2)
expression = 'sin(2*pi*x)*sin(2*pi*y) * if(t < t1 + dt / 2, g1^(t / dt), g1^5 * g2^((t - t1) / dt2))'
constant_names = 'g1 g2 dt dt2 t1'
constant_expressions = '${fparse 1 / (1 + dt * D * lambda)} ${fparse 1 / (1 + dt2 * D * lambda)} ${dt} ${dt2} ${fparse 5 * dt}'
extra_symbols = true
[]
[diff_compute]
type = ParsedCompute
buffer = diff
expression = 'abs(u - gold)'
inputs = 'u gold'
[]
[]
[]
[TensorSolver]
type = ImplicitFDSolver
buffer = u
operators = 'dudt lap'
root_compute = dudt
[]
[Postprocessors]
[max_error]
type = TensorExtremeValuePostprocessor
buffer = diff
value_type = MAX
[]
[max_gold]
type = TensorExtremeValuePostprocessor
buffer = gold
value_type = MAX
[]
[]
[Problem]
type = TensorProblem
[]
[Executioner]
type = Transient
num_steps = 10
[TimeStepper]
type = TimeSequenceStepper
time_sequence = '${fparse 1 * dt} ${fparse 2 * dt} ${fparse 3 * dt} ${fparse 4 * dt} ${fparse 5 * dt}
${fparse 5 * dt + dt2} ${fparse 5 * dt + 2 * dt2} ${fparse 5 * dt + 3 * dt2}
${fparse 5 * dt + 4 * dt2} ${fparse 5 * dt + 5 * dt2}'
[]
[]
[Outputs]
csv = true
[]
(benchmarks/01_spinodal_decomposition/1a_solver.i)
[Domain]
dim = 2
nx = 200
ny = 200
xmax = 200
ymax = 200
device_names = 'cuda'
mesh_mode = DOMAIN
[]
[TensorBuffers]
[c]
map_to_aux_variable = c
[]
[cbar]
[]
[mu]
# map_to_aux_variable = mu
[]
[mubar]
[]
[Mbarmubar]
[]
# constant tensors
[Mbar]
[]
[kappabarbar]
[]
# postprocessing
[F]
[]
[Fgrad]
[]
[]
[TensorComputes]
[Initialize]
[c]
type = ParsedCompute
buffer = c
extra_symbols = true
expression = 'c0+epsilon*(cos(0.105*x)*cos(0.11*y)+(cos(0.13*x)*cos(0.087*y))^2+cos(0.025*x-0.15*y)*cos(0.07*x-0.02*y))'
constant_names = 'c0 epsilon'
constant_expressions = '0.5 0.01'
[]
[Mbar]
type = ReciprocalLaplacianFactor
factor = 5 # Mobility
buffer = Mbar
[]
[kappabarbar]
type = ReciprocalLaplacianSquareFactor
factor = -10 # -kappa*M
buffer = kappabarbar
[]
[]
[Solve]
[mu]
type = ParsedCompute
buffer = mu
expression = 'rho_s*(c-c_alpha)^2*(c_beta-c)^2'
constant_names = 'rho_s c_alpha c_beta'
constant_expressions = '5 0.3 0.7'
derivatives = c
inputs = c
[]
[mubar]
type = ForwardFFT
buffer = mubar
input = mu
[]
[Mbarmubar]
type = ParsedCompute
buffer = Mbarmubar
expression = 'Mbar*mubar'
inputs = 'Mbar mubar'
[]
[cbar]
type = ForwardFFT
buffer = cbar
input = c
[]
[]
[Postprocess]
[Fgrad]
type = FFTGradientSquare
buffer = Fgrad
input = c
factor = 1 # kappa/2
[]
[F]
type = ParsedCompute
buffer = F
expression = 'rho_s * (c-c_alpha)^2 * (c_beta-c)^2 + Fgrad'
constant_names = 'rho_s c_alpha c_beta'
constant_expressions = '5 0.3 0.7'
inputs = 'c Fgrad'
[]
[]
[]
[UserObjects]
[terminator]
type = Terminator
expression = change<1e-4
[]
[]
[TensorSolver]
type = AdamsBashforthMoulton
buffer = c
substeps = 1000
history_size = 1
reciprocal_buffer = cbar
linear_reciprocal = kappabarbar
nonlinear_reciprocal = Mbarmubar
[]
[AuxVariables]
# [mu]
# family = MONOMIAL
# order = CONSTANT
# []
[c]
# family = MONOMIAL
# order = CONSTANT
[]
[]
[Postprocessors]
[min_c]
type = TensorExtremeValuePostprocessor
buffer = c
value_type = MIN
execute_on = 'TIMESTEP_END'
[]
[max_c]
type = TensorExtremeValuePostprocessor
buffer = c
value_type = MAX
execute_on = 'TIMESTEP_END'
[]
[F]
type = TensorIntegralPostprocessor
buffer = F
[]
[change]
type = TensorIntegralChangePostprocessor
buffer = c
[]
[]
[Problem]
type = TensorProblem
spectral_solve_substeps = 1000
[]
[Executioner]
type = Transient
num_steps = 1000
[TimeStepper]
type = IterationAdaptiveDT
growth_factor = 1.1
dt = 1
[]
dtmax = 300
[]
[Outputs]
exodus = true
csv = true
perf_graph = true
execute_on = 'TIMESTEP_END'
[]