- bufferThe buffer this compute is writing to
C++ Type:std::string
Controllable:No
Description:The buffer this compute is writing to
ConstantTensor
Constant tensor in real space.
ConstantTensor and ConstantReciprocalTensor set a tensor to a constant value in real space and reciprocal space respectively. The reciprocal space version takes an "imaginary" value parameter.
Overview
Writes a constant scalar into the target buffer each time it runs. Use "buffer" to select the destination and "real" to provide the value.
Example Input File Syntax
[TensorComputes<<<{"href": "../../syntax/TensorComputes/index.html"}>>>]
[Initialize<<<{"href": "../../syntax/TensorComputes/Initialize/index.html"}>>>]
[A]
type = ConstantTensor<<<{"description": "Constant tensor in real space.", "href": "ConstantTensor.html"}>>>
buffer<<<{"description": "The buffer this compute is writing to"}>>> = A
real<<<{"description": "Real part of the constant value."}>>> = 2
[]
[]
[](test/tests/neml2/scalar.i)Input Parameters
- fullFalseConstruct a full tensor will all entries
Default:False
C++ Type:bool
Controllable:No
Description:Construct a full tensor will all entries
- real0.0Real part of the constant value.
Default:0.0
C++ Type:std::string
Controllable:No
Description:Real part of the constant value.
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/cahnhilliard/cahnhilliard_explicit_smooth.i)
- (test/tests/cahnhilliard/cahnhilliard.i)
- (test/tests/neml2/scalar.i)
- (examples/cahn_hilliard/cahnhilliard.i)
- (test/tests/cahnhilliard/cahnhilliard_explicit.i)
- (test/tests/postprocessors/postprocessors.i)
- (test/tests/tensor_compute/coupled_pf_mech_secant.i)
- (test/tests/tensor_compute/backandforth.i)
- (test/tests/kks/KKS_no_flux_bc.i)
- (benchmarks/02_oswald_ripening/simple.i)
- (test/tests/solvers/diagonal.i)
- (test/tests/kks/KKS_libtorch.i)
- (examples/libtorch_kks/KKS_libtorch.i)
imaginary
Default:0.0
C++ Type:std::string
Controllable:No
Description:Imaginary part of the constant value.
buffer
C++ Type:std::string
Controllable:No
Description:The buffer this compute is writing to
real
Default:0.0
C++ Type:std::string
Controllable:No
Description:Real part of the constant value.
(test/tests/neml2/scalar.i)
[Domain]
dim = 2
nx = 2
ny = 2
xmax = 1
ymax = 1
mesh_mode = DUMMY
[]
[Problem]
type = TensorProblem
[]
[TensorComputes]
[Initialize]
[A]
type = ConstantTensor
buffer = A
real = 2
[]
[B]
type = ConstantTensor
buffer = B
real = 3
[]
[C]
type = NEML2TensorCompute
neml2_input_file = neml2_input.i
neml2_model = multiply
marlin_inputs = 'A B'
neml2_inputs = 'forces/A forces/B'
neml2_outputs = 'state/C'
marlin_outputs = 'C'
[]
[]
[]
[Postprocessors]
[C]
type = TensorAveragePostprocessor
buffer = C
[]
[]
[Executioner]
type = Transient
num_steps = 1
[]
[Outputs]
csv = true
[]
(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/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/neml2/scalar.i)
[Domain]
dim = 2
nx = 2
ny = 2
xmax = 1
ymax = 1
mesh_mode = DUMMY
[]
[Problem]
type = TensorProblem
[]
[TensorComputes]
[Initialize]
[A]
type = ConstantTensor
buffer = A
real = 2
[]
[B]
type = ConstantTensor
buffer = B
real = 3
[]
[C]
type = NEML2TensorCompute
neml2_input_file = neml2_input.i
neml2_model = multiply
marlin_inputs = 'A B'
neml2_inputs = 'forces/A forces/B'
neml2_outputs = 'state/C'
marlin_outputs = 'C'
[]
[]
[]
[Postprocessors]
[C]
type = TensorAveragePostprocessor
buffer = C
[]
[]
[Executioner]
type = Transient
num_steps = 1
[]
[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'
[]
(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/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
[]
(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/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
[]
(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 = '30 70 0 100'
[]
[]
[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'
[]
(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/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/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'
[]
(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'
[]