- variableThe name of the variable that this residual object operates on
C++ Type:NonlinearVariableName
Controllable:No
Description:The name of the variable that this residual object operates on
ADBodyForce
Description
ADBodyForce
implements a force term in momentum transport or structural mechanics or a source term in species/mass transport. The strong form, given a domain is defined as
where is the source term (negative if a sink) and the second term on the left hand side represents the strong forms of other kernels. The ADBodyForce
weak form, in inner-product notation, is defined as
where the are the test functions, and are the trial solutions in the finite dimensional space for the unknown ().
The force is constructed through a user supplied constant , function value evaluated at the current time and quadrature point , and/or postprocessor value . The constant , supplied through the parameter value
, may also be controlled over the course of a transient simulation with a Controls
block. , , are supplied through the input parameters value
, function
, and postprocessor
respectively. Not supplying , , or through its corresponding parameter is equivalent to setting its value to unity.
Example Syntax
The case below demonstrates the use of ADBodyForce
where the force term is supplied solely through the a function (denoted by function
):
[Kernels]
active = 'diff'
[./diff]
type = ADDiffusion
variable = u
[../]
[]
(test/tests/bcs/ad_bc_preset_nodal/bc_function_preset.i)Input Parameters
- blockThe list of blocks (ids or names) that this object will be applied
C++ Type:std::vector<SubdomainName>
Controllable:No
Description:The list of blocks (ids or names) that this object will be applied
- displacementsThe displacements
C++ Type:std::vector<VariableName>
Controllable:No
Description:The displacements
- function1A function that describes the body force
Default:1
C++ Type:FunctionName
Controllable:No
Description:A function that describes the body force
- postprocessor1A postprocessor whose value is multiplied by the body force
Default:1
C++ Type:PostprocessorName
Controllable:No
Description:A postprocessor whose value is multiplied by the body force
- prop_getter_suffixAn optional suffix parameter that can be appended to any attempt to retrieve/get material properties. The suffix will be prepended with a '_' character.
C++ Type:MaterialPropertyName
Controllable:No
Description:An optional suffix parameter that can be appended to any attempt to retrieve/get material properties. The suffix will be prepended with a '_' character.
- use_interpolated_stateFalseFor the old and older state use projected material properties interpolated at the quadrature points. To set up projection use the ProjectedStatefulMaterialStorageAction.
Default:False
C++ Type:bool
Controllable:No
Description:For the old and older state use projected material properties interpolated at the quadrature points. To set up projection use the ProjectedStatefulMaterialStorageAction.
- value1Coefficient to multiply by the body force term
Default:1
C++ Type:double
Controllable:Yes
Description:Coefficient to multiply by the body force term
Optional Parameters
- absolute_value_vector_tagsThe tags for the vectors this residual object should fill with the absolute value of the residual contribution
C++ Type:std::vector<TagName>
Controllable:No
Description:The tags for the vectors this residual object should fill with the absolute value of the residual contribution
- extra_matrix_tagsThe extra tags for the matrices this Kernel should fill
C++ Type:std::vector<TagName>
Controllable:No
Description:The extra tags for the matrices this Kernel should fill
- extra_vector_tagsThe extra tags for the vectors this Kernel should fill
C++ Type:std::vector<TagName>
Controllable:No
Description:The extra tags for the vectors this Kernel should fill
- matrix_tagssystemThe tag for the matrices this Kernel should fill
Default:system
C++ Type:MultiMooseEnum
Options:nontime, system
Controllable:No
Description:The tag for the matrices this Kernel should fill
- vector_tagsnontimeThe tag for the vectors this Kernel should fill
Default:nontime
C++ Type:MultiMooseEnum
Options:nontime, time
Controllable:No
Description:The tag for the vectors this Kernel should fill
Tagging 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.
- diag_save_inThe name of auxiliary variables to save this Kernel's diagonal Jacobian contributions to. Everything about that variable must match everything about this variable (the type, what blocks it's on, etc.)
C++ Type:std::vector<AuxVariableName>
Controllable:No
Description:The name of auxiliary variables to save this Kernel's diagonal Jacobian contributions to. Everything about that variable must match everything about this variable (the type, what blocks it's on, etc.)
- enableTrueSet the enabled status of the MooseObject.
Default:True
C++ Type:bool
Controllable:Yes
Description:Set the enabled status of the MooseObject.
- implicitTrueDetermines whether this object is calculated using an implicit or explicit form
Default:True
C++ Type:bool
Controllable:No
Description:Determines whether this object is calculated using an implicit or explicit form
- save_inThe name of auxiliary variables to save this Kernel's residual contributions to. Everything about that variable must match everything about this variable (the type, what blocks it's on, etc.)
C++ Type:std::vector<AuxVariableName>
Controllable:No
Description:The name of auxiliary variables to save this Kernel's residual contributions to. Everything about that variable must match everything about this variable (the type, what blocks it's on, etc.)
- seed0The seed for the master random number generator
Default:0
C++ Type:unsigned int
Controllable:No
Description:The seed for the master random number generator
- use_displaced_meshFalseWhether or not this object should use the displaced mesh for computation. Note that in the case this is true but no displacements are provided in the Mesh block the undisplaced mesh will still be used.
Default:False
C++ Type:bool
Controllable:No
Description:Whether or not this object should use the displaced mesh for computation. Note that in the case this is true but no displacements are provided in the Mesh block the undisplaced mesh will still be used.
Advanced Parameters
Input Files
- (test/tests/nodalkernels/constraint_enforcement/ad-upper-and-lower-bound.i)
- (test/tests/bcs/ad_penalty_dirichlet_bc/function_penalty_dirichlet_bc_test.i)
- (test/tests/kernels/ad_2d_diffusion/2d_diffusion_bodyforce_test.i)
- (test/tests/kernels/ad_scalar_kernel_constraint/diffusion_override_scalar.i)
- (test/tests/problems/reference_residual_problem/ad_abs_ref.i)
- (modules/optimization/test/tests/executioners/transient_and_adjoint/nonlinear_diffusivity.i)
- (modules/optimization/test/tests/optimizationreporter/nonlinear_material/forward_and_adjoint.i)
- (test/tests/materials/ad_material/conversion/1d_dirichlet.i)
- (test/tests/kernels/ad_reaction/ad_reaction.i)
- (modules/optimization/test/tests/executioners/steady_and_adjoint/nonlinear_diffusion.i)
- (modules/stochastic_tools/examples/sobol/diffusion.i)
- (test/tests/kernels/ad_scalar_kernel_constraint/diffusion_bipass_scalar.i)
- (examples/ex14_pps/ex14.i)
- (modules/level_set/test/tests/functions/olsson_bubble/olsson_bubble_adjac.i)
- (modules/heat_transfer/test/tests/ad_convective_heat_flux/coupled.i)
- (test/tests/bcs/ad_penalty_dirichlet_bc/penalty_dirichlet_bc_test.i)
- (modules/optimization/examples/diffusion_reaction/forward_exact.i)
- (modules/optimization/test/tests/reporter/TransientSyntheticDataCreator/transient_synthetic_data.i)
- (test/tests/bcs/ad_function_dirichlet_bc/test.i)
- (test/tests/kernels/ad_scalar_kernel_constraint/scalar_constraint_together.i)
- (modules/stochastic_tools/examples/parameter_study/diffusion_vector.i)
- (test/tests/kernels/ad_jacobians/adfunction.i)
- (modules/optimization/test/tests/misc/scaling_test/scaling_test.i)
- (test/tests/kernels/ad_jacobians/test.i)
- (modules/optimization/examples/diffusion_reaction/forward_and_adjoint.i)
- (modules/stochastic_tools/examples/parameter_study/diffusion_time.i)
- (modules/stochastic_tools/examples/parameter_study/diffusion.i)
- (test/tests/kernels/diffusion_with_hanging_node/ad_simple_diffusion.i)
- (modules/optimization/examples/simpleTransient/nonlinear_forward_and_adjoint.i)
(test/tests/bcs/ad_bc_preset_nodal/bc_function_preset.i)
[Mesh]
type = GeneratedMesh
dim = 2
nx = 10
ny = 10
nz = 0
zmin = 0
zmax = 0
elem_type = QUAD4
[]
[Variables]
active = 'u'
[./u]
order = FIRST
family = LAGRANGE
[../]
[]
[Functions]
[./left]
type = ParsedFunction
expression = 'y'
[../]
[./right]
type = ParsedFunction
expression = '1+y'
[../]
[]
[Kernels]
active = 'diff'
[./diff]
type = ADDiffusion
variable = u
[../]
[]
[BCs]
active = 'left right'
[./left]
type = ADFunctionDirichletBC
variable = u
boundary = 3
function = left
[../]
[./right]
type = ADFunctionDirichletBC
variable = u
boundary = 1
function = right
[../]
[]
[Executioner]
type = Steady
solve_type = 'PJFNK'
[]
[Outputs]
file_base = bc_func_out
exodus = true
[]
(test/tests/nodalkernels/constraint_enforcement/ad-upper-and-lower-bound.i)
l=10
nx=100
num_steps=10
[Mesh]
type = GeneratedMesh
dim = 1
xmax = ${l}
nx = ${nx}
[]
[Variables]
[u]
[]
[lm_upper]
[]
[lm_lower]
[]
[]
[ICs]
[u]
type = FunctionIC
variable = u
function = 'x'
[]
[]
[Kernels]
[time]
type = ADTimeDerivative
variable = u
[]
[diff]
type = ADDiffusion
variable = u
[]
[ffn]
type = ADBodyForce
variable = u
function = 'if(x<5,-1,1)'
[]
[]
[NodalKernels]
[upper_bound]
type = ADUpperBoundNodalKernel
variable = lm_upper
v = u
exclude_boundaries = 'left right'
upper_bound = 10
[]
[forces_from_upper]
type = ADCoupledForceNodalKernel
variable = u
v = lm_upper
coef = -1
[]
[lower_bound]
type = ADLowerBoundNodalKernel
variable = lm_lower
v = u
exclude_boundaries = 'left right'
lower_bound = 0
[]
[forces_from_lower]
type = ADCoupledForceNodalKernel
variable = u
v = lm_lower
coef = 1
[]
[]
[BCs]
[left]
type = ADDirichletBC
boundary = left
value = 0
variable = u
[]
[right]
type = ADDirichletBC
boundary = right
value = ${l}
variable = u
[]
[]
[Preconditioning]
[smp]
type = SMP
full = true
[]
[]
[Executioner]
type = Transient
num_steps = ${num_steps}
solve_type = NEWTON
dtmin = 1
petsc_options_iname = '-snes_max_linear_solve_fail -ksp_max_it -pc_type -sub_pc_factor_levels -snes_linesearch_type'
petsc_options_value = '0 30 asm 16 basic'
[]
[Outputs]
exodus = true
[csv]
type = CSV
execute_on = 'nonlinear timestep_end'
[]
[dof]
type = DOFMap
execute_on = 'initial'
[]
[]
[Debug]
show_var_residual_norms = true
[]
[Postprocessors]
[active_upper_lm]
type = GreaterThanLessThanPostprocessor
variable = lm_upper
execute_on = 'nonlinear timestep_end'
value = 1e-8
comparator = 'greater'
[]
[upper_violations]
type = GreaterThanLessThanPostprocessor
variable = u
execute_on = 'nonlinear timestep_end'
value = ${fparse 10+1e-8}
comparator = 'greater'
[]
[active_lower_lm]
type = GreaterThanLessThanPostprocessor
variable = lm_lower
execute_on = 'nonlinear timestep_end'
value = 1e-8
comparator = 'greater'
[]
[lower_violations]
type = GreaterThanLessThanPostprocessor
variable = u
execute_on = 'nonlinear timestep_end'
value = -1e-8
comparator = 'less'
[]
[nls]
type = NumNonlinearIterations
[]
[cum_nls]
type = CumulativeValuePostprocessor
postprocessor = nls
[]
[]
(test/tests/bcs/ad_penalty_dirichlet_bc/function_penalty_dirichlet_bc_test.i)
[Mesh]
type = GeneratedMesh
dim = 2
xmin = -1
xmax = 1
ymin = -1
ymax = 1
nx = 10
ny = 10
elem_type = QUAD9
[]
[Functions]
[./forcing_fn]
type = ParsedFunction
expression = -4+x*x+y*y
[../]
[./solution]
type = ParsedGradFunction
value = x*x+y*y
grad_x = 2*x
grad_y = 2*y
[../]
[]
[Variables]
[./u]
order = SECOND
family = HIERARCHIC
[../]
[]
[Kernels]
active = 'diff forcing reaction'
[./diff]
type = ADDiffusion
variable = u
[../]
[./reaction]
type = Reaction
variable = u
[../]
[./forcing]
type = ADBodyForce
variable = u
function = forcing_fn
[../]
[]
[BCs]
active = 'bc_all'
[./bc_all]
type = ADFunctionPenaltyDirichletBC
variable = u
function = solution
boundary = 'top left right bottom'
penalty = 1e6
[../]
[]
[Postprocessors]
[./dofs]
type = NumDOFs
[../]
[./h]
type = AverageElementSize
[../]
[./L2error]
type = ElementL2Error
variable = u
function = solution
[../]
[./H1error]
type = ElementH1Error
variable = u
function = solution
[../]
[./H1Semierror]
type = ElementH1SemiError
variable = u
function = solution
[../]
[]
[Executioner]
type = Steady
solve_type = 'NEWTON'
nl_rel_tol = 1e-14
[]
[Outputs]
execute_on = 'timestep_end'
exodus = true
[]
(test/tests/kernels/ad_2d_diffusion/2d_diffusion_bodyforce_test.i)
###########################################################
# This is a simple test of the Kernel System.
# It solves the Laplacian equation on a small 2x2 grid.
# The "Diffusion" kernel is used to calculate the
# residuals of the weak form of this operator. The
# "BodyForce" kernel is used to apply a time-dependent
# volumetric source.
###########################################################
[Mesh]
[./square]
type = GeneratedMeshGenerator
nx = 2
ny = 2
dim = 2
[../]
[]
[Variables]
active = 'u'
[./u]
order = FIRST
family = LAGRANGE
[../]
[]
[Kernels]
[./diff]
type = ADDiffusion
variable = u
[../]
[./bf]
type = ADBodyForce
variable = u
postprocessor = ramp
[../]
[]
[Functions]
[./ramp]
type = ParsedFunction
expression = 't'
[../]
[]
[Postprocessors]
[./ramp]
type = FunctionValuePostprocessor
function = ramp
execute_on = linear
[../]
[]
[BCs]
active = 'left right'
[./left]
type = DirichletBC
variable = u
boundary = 3
value = 0
[../]
[./right]
type = DirichletBC
variable = u
boundary = 1
value = 0
[../]
[]
[Executioner]
type = Transient
dt = 1.0
end_time = 1.0
solve_type = 'NEWTON'
[]
[Outputs]
file_base = bodyforce_out
exodus = true
[]
(test/tests/kernels/ad_scalar_kernel_constraint/diffusion_override_scalar.i)
[Mesh]
type = GeneratedMesh
dim = 2
xmin = -1
xmax = 1
ymin = -1
ymax = 1
nx = 2
ny = 2
elem_type = QUAD9
[]
[Functions]
[exact_fn]
type = ParsedFunction
value = 'x*x+y*y'
[]
[ffn]
type = ParsedFunction
value = -4
[]
[bottom_bc_fn]
type = ParsedFunction
value = -2*y
[]
[right_bc_fn]
type = ParsedFunction
value = 2*x
[]
[top_bc_fn]
type = ParsedFunction
value = 2*y
[]
[left_bc_fn]
type = ParsedFunction
value = -2*x
[]
[]
[Variables]
[u]
family = LAGRANGE
order = SECOND
[]
[lambda]
family = SCALAR
order = FIRST
[]
[]
[Kernels]
# Make sure that we can derive from the scalar base class
# but actually not assign a scalar variable
[diff]
type = ADDiffusionNoScalar
variable = u
scalar_variable = lambda
[]
[ffnk]
type = ADBodyForce
variable = u
function = ffn
[]
[sk_lm]
type = ADScalarLMKernel
variable = u
kappa = lambda
pp_name = pp
value = 2.666666666666666
[]
[]
[Problem]
kernel_coverage_check = false
error_on_jacobian_nonzero_reallocation = true
[]
[BCs]
[bottom]
type = FunctionNeumannBC
variable = u
boundary = 'bottom'
function = bottom_bc_fn
[]
[right]
type = FunctionNeumannBC
variable = u
boundary = 'right'
function = right_bc_fn
[]
[top]
type = FunctionNeumannBC
variable = u
boundary = 'top'
function = top_bc_fn
[]
[left]
type = FunctionNeumannBC
variable = u
boundary = 'left'
function = left_bc_fn
[]
[]
[Postprocessors]
# integrate the volume of domain since original objects set
# int(phi)=V0, rather than int(phi-V0)=0
[pp]
type = FunctionElementIntegral
function = 1
execute_on = initial
[]
[l2_err]
type = ElementL2Error
variable = u
function = exact_fn
execute_on = 'initial timestep_end'
[]
[]
[Preconditioning]
[pc]
type = SMP
full = true
solve_type = 'NEWTON'
[]
[]
[Executioner]
type = Steady
nl_rel_tol = 1e-9
l_tol = 1.e-10
nl_max_its = 10
# This example builds an indefinite matrix, so "-pc_type hypre -pc_hypre_type boomeramg" cannot
# be used reliably on this problem. ILU(0) seems to do OK in both serial and parallel in my testing,
# I have not seen any zero pivot issues.
petsc_options_iname = '-pc_type -sub_pc_type'
petsc_options_value = 'bjacobi ilu'
# This is a linear problem, so we don't need to recompute the
# Jacobian. This isn't a big deal for a Steady problems, however, as
# there is only one solve.
solve_type = 'LINEAR'
[]
[Outputs]
# exodus = true
csv = true
hide = lambda
[]
(test/tests/problems/reference_residual_problem/ad_abs_ref.i)
[Mesh]
type = GeneratedMesh
dim = 1
nx = 10
[]
[GlobalParams]
absolute_value_vector_tags = 'absref'
[]
[Problem]
type = ReferenceResidualProblem
reference_vector = 'absref'
extra_tag_vectors = 'absref'
[]
[Variables]
[u][]
[v]
scaling = 1e-6
[]
[]
[Functions]
[ramp]
type = ParsedFunction
expression = 'if(t < 5, t - 5, 0) * x'
[]
[]
[Kernels]
[u_dt]
type = ADTimeDerivative
variable = u
[]
[u_coupled_rx]
type = ADCoupledForce
variable = u
v = v
coef = 1
[]
[v_dt]
type = ADTimeDerivative
variable = v
[]
[v_neg_force]
type = ADBodyForce
variable = v
value = ${fparse -1 / 2}
function = ramp
[]
[v_force]
type = ADBodyForce
variable = v
value = 1
function = ramp
[]
[]
[Postprocessors]
[u_avg]
type = ElementAverageValue
variable = u
execute_on = 'TIMESTEP_END INITIAL'
[]
[v_avg]
type = ElementAverageValue
variable = v
execute_on = 'TIMESTEP_END INITIAL'
[]
[timestep]
type = TimePostprocessor
outputs = 'none'
[]
[v_old]
type = ElementAverageValue
variable = v
execute_on = TIMESTEP_BEGIN
outputs = none
[]
[u_old]
type = ElementAverageValue
variable = u
execute_on = TIMESTEP_BEGIN
outputs = none
[]
[v_exact]
type = ParsedPostprocessor
pp_names = 'timestep v_old'
expression = 't := if(timestep > 5, 5, timestep); (t^2 - 9 * t) / 8'
[]
[u_exact]
type = ParsedPostprocessor
pp_names = 'u_old v_exact'
expression = 'u_old + v_exact'
[]
[]
[Executioner]
type = Transient
petsc_options = '-snes_converged_reason'
petsc_options_iname = '-pc_type'
petsc_options_value = 'lu'
line_search = none
num_steps = 10
nl_rel_tol = 1e-06
verbose = true
[]
[Outputs]
csv = true
[]
(modules/optimization/test/tests/executioners/transient_and_adjoint/nonlinear_diffusivity.i)
[Mesh]
[gmg]
type = GeneratedMeshGenerator
dim = 2
xmax = 1
ymax = 1
nx = 10
ny = 10
[]
[]
[Problem]
nl_sys_names = 'nl0 adjoint'
[]
[Variables]
[u]
[]
[u_adjoint]
solver_sys = adjoint
[]
[]
[Kernels]
[time]
type = TimeDerivative
variable = u
[]
[diff]
type = ADMatDiffusion
variable = u
diffusivity = D
[]
[src]
type = ADBodyForce
variable = u
value = 1
[]
[src_adjoint]
type = ADBodyForce
variable = u_adjoint
value = 1
[]
[]
[BCs]
[dirichlet]
type = ADDirichletBC
variable = u
boundary = 'top right'
value = 0
[]
[]
[Materials]
[diffc]
type = ADParsedMaterial
property_name = D
expression = '0.1 + 5 * u'
coupled_variables = 'u'
[]
[]
[Postprocessors]
[u_avg]
type = ElementAverageValue
variable = u
execute_on = 'TIMESTEP_END ADJOINT_TIMESTEP_END'
[]
[u_adjoint_avg]
type = ElementAverageValue
variable = u_adjoint
execute_on = ADJOINT_TIMESTEP_END
[]
[inner_product]
type = VariableInnerProduct
variable = u
second_variable = u_adjoint
execute_on = ADJOINT_TIMESTEP_END
[]
[]
[Executioner]
type = TransientAndAdjoint
forward_system = nl0
adjoint_system = adjoint
dt = 0.2
num_steps = 5
nl_rel_tol = 1e-12
l_tol = 1e-12
[]
[Outputs]
[forward]
type = CSV
[]
[adjoint]
type = CSV
execute_on = 'INITIAL ADJOINT_TIMESTEP_END'
[]
[console]
type = Console
execute_postprocessors_on = 'INITIAL TIMESTEP_END ADJOINT_TIMESTEP_END'
[]
[]
(modules/optimization/test/tests/optimizationreporter/nonlinear_material/forward_and_adjoint.i)
[Mesh]
[gmg]
type = GeneratedMeshGenerator
dim = 2
nx = 10
ny = 10
xmax = 2
ymax = 2
[]
[]
[Problem]
nl_sys_names = 'nl0 adjoint'
kernel_coverage_check = false
[]
[Variables]
[forwardT]
[]
[adjointT]
solver_sys = adjoint
[]
[]
[Kernels]
[heat_conduction]
type = ADMatDiffusion
variable = forwardT
diffusivity = 'conductivity'
[]
[heat_source]
type = ADBodyForce
function = volumetric_heat_func
variable = forwardT
[]
[]
[DiracKernels]
[pt]
type = ReporterPointSource
variable = adjointT
x_coord_name = measurement_locations/measurement_xcoord
y_coord_name = measurement_locations/measurement_ycoord
z_coord_name = measurement_locations/measurement_zcoord
value_name = measurement_locations/misfit_values
[]
[]
[Materials]
[NonlinearConductivity]
type = ADParsedMaterial
property_name = conductivity
expression = '10+500*forwardT'
coupled_variables = 'forwardT'
[]
[]
[Functions]
[volumetric_heat_func]
type = ParsedOptimizationFunction
expression = q
param_symbol_names = 'q'
param_vector_name = 'params/heat_source'
[]
[]
[BCs]
[left]
type = NeumannBC
variable = forwardT
boundary = left
value = 0
[]
[right]
type = NeumannBC
variable = forwardT
boundary = right
value = 0
[]
[bottom]
type = DirichletBC
variable = forwardT
boundary = bottom
value = 2
[]
[top]
type = DirichletBC
variable = forwardT
boundary = top
value = 1
[]
[]
[Reporters]
[measurement_locations]
type = OptimizationData
variable = forwardT
[]
[params]
type = ConstantReporter
real_vector_names = 'heat_source'
real_vector_values = '0' # Dummy
[]
[]
[VectorPostprocessors]
[gradient_vpp]
type = ElementOptimizationSourceFunctionInnerProduct
function = volumetric_heat_func
variable = adjointT
execute_on = ADJOINT_TIMESTEP_END
[]
[]
[Executioner]
type = SteadyAndAdjoint
forward_system = nl0
adjoint_system = adjoint
line_search = none
nl_abs_tol = 1e-12
nl_rel_tol = 1e-12
l_tol = 1e-12
petsc_options_iname = '-pc_type'
petsc_options_value = 'lu'
[]
[Outputs]
console = false
[]
(test/tests/materials/ad_material/conversion/1d_dirichlet.i)
[Mesh]
type = GeneratedMesh
dim = 1
nx = 10
xmax = 2
[]
[Variables]
[v]
initial_condition = 1.1
[]
[]
[Kernels]
inactive = 'ad_diff'
[diff]
type = MatDiffusion
variable = v
diffusivity = 'coef'
[]
[ad_diff]
type = ADMatDiffusion
variable = v
diffusivity = 'ad_coef_2'
[]
[sink]
type = ADBodyForce
variable = v
function = 'sink'
[]
[]
[BCs]
[bounds]
type = DirichletBC
variable = v
boundary = 'left right'
value = 0
[]
[]
[Functions]
[sink]
type = ParsedFunction
expression = '3*x^3'
[]
[]
[Materials]
[ad_coef]
type = ADParsedMaterial
property_name = 'ad_coef'
expression = '0.01 * max(v, 1)'
coupled_variables = 'v'
[]
[converter_to_regular]
type = MaterialADConverter
ad_props_in = 'ad_coef'
reg_props_out = 'coef'
[]
# at this point we should have lost the derivatives
[converter_to_ad]
type = MaterialADConverter
reg_props_in = 'coef'
ad_props_out = 'ad_coef_2'
[]
[]
[Executioner]
type = Steady
solve_type = 'NEWTON'
[]
[Outputs]
exodus = true
[]
(test/tests/kernels/ad_reaction/ad_reaction.i)
[Mesh]
type = GeneratedMesh
dim = 2
nx = 5
ny = 5
[]
[Variables]
[u]
[]
[]
[Kernels]
[diffusion]
type = ADDiffusion
variable = u
[]
[reaction]
type = ADReaction
variable = u
[]
[force]
type = ADBodyForce
variable = u
[]
[]
[BCs]
[left]
type = ADDirichletBC
boundary = left
variable = u
value = 0
[]
[]
[Executioner]
type = Steady
solve_type = NEWTON
[]
[Outputs]
exodus = true
[]
(modules/optimization/test/tests/executioners/steady_and_adjoint/nonlinear_diffusion.i)
[Mesh]
[gmg]
type = GeneratedMeshGenerator
dim = 2
xmax = 1
ymax = 1
nx = 10
ny = 10
[]
[]
[Problem]
nl_sys_names = 'nl0 adjoint'
[]
[Variables]
[u]
[]
[u_adjoint]
solver_sys = adjoint
[]
[]
[Kernels]
[diff]
type = ADMatDiffusion
variable = u
diffusivity = D
[]
[src]
type = ADBodyForce
variable = u
value = 1
[]
[src_adjoint]
type = ADBodyForce
variable = u_adjoint
value = 1
[]
[]
[BCs]
[dirichlet]
type = ADDirichletBC
variable = u
boundary = 'top right'
value = 0
[]
[]
[Materials]
[diffc]
type = ADParsedMaterial
property_name = D
expression = '0.1 + 5 * u'
coupled_variables = 'u'
[]
[]
[Postprocessors]
[u_avg]
type = ElementAverageValue
variable = u
[]
[u_adjoint_avg]
type = ElementAverageValue
variable = u_adjoint
execute_on = ADJOINT_TIMESTEP_END
[]
[inner_product]
type = VariableInnerProduct
variable = u
second_variable = u_adjoint
execute_on = ADJOINT_TIMESTEP_END
[]
[]
[Executioner]
type = SteadyAndAdjoint
forward_system = nl0
adjoint_system = adjoint
nl_rel_tol = 1e-12
l_tol = 1e-12
[]
[Outputs]
exodus = true
[]
(modules/stochastic_tools/examples/sobol/diffusion.i)
[Mesh]
type = GeneratedMesh
dim = 2
nx = 10
ny = 10
[]
[Variables/T]
initial_condition = 300
[]
[Kernels]
[time]
type = ADTimeDerivative
variable = T
[]
[diff]
type = ADMatDiffusion
variable = T
diffusivity = diffusivity
[]
[source]
type = ADBodyForce
variable = T
value = 100
function = 1
[]
[]
[BCs]
[left]
type = ADDirichletBC
variable = T
boundary = left
value = 300
[]
[right]
type = ADNeumannBC
variable = T
boundary = right
value = -100
[]
[]
[Materials/constant]
type = ADGenericConstantMaterial
prop_names = 'diffusivity'
prop_values = 1
[]
[Executioner]
type = Transient
solve_type = NEWTON
num_steps = 4
dt = 0.25
[]
[Postprocessors]
[T_avg]
type = ElementAverageValue
variable = T
execute_on = 'initial timestep_end'
[]
[q_left]
type = ADSideDiffusiveFluxAverage
variable = T
boundary = left
diffusivity = diffusivity
execute_on = 'initial timestep_end'
[]
[]
[Controls/stochastic]
type = SamplerReceiver
[]
[Outputs]
[]
(test/tests/kernels/ad_scalar_kernel_constraint/diffusion_bipass_scalar.i)
[Mesh]
type = GeneratedMesh
dim = 2
xmin = -1
xmax = 1
ymin = -1
ymax = 1
nx = 2
ny = 2
elem_type = QUAD9
[]
[Functions]
[exact_fn]
type = ParsedFunction
value = 'x*x+y*y'
[]
[ffn]
type = ParsedFunction
value = -4
[]
[bottom_bc_fn]
type = ParsedFunction
value = -2*y
[]
[right_bc_fn]
type = ParsedFunction
value = 2*x
[]
[top_bc_fn]
type = ParsedFunction
value = 2*y
[]
[left_bc_fn]
type = ParsedFunction
value = -2*x
[]
[]
[Variables]
[u]
family = LAGRANGE
order = SECOND
[]
[lambda]
family = SCALAR
order = FIRST
[]
[]
[Kernels]
# Make sure that we can derive from the scalar base class
# but actually not assign a scalar variable
[diff]
type = ADDiffusionNoScalar
variable = u
[]
[ffnk]
type = ADBodyForce
variable = u
function = ffn
[]
[sk_lm]
type = ADScalarLMKernel
variable = u
kappa = lambda
pp_name = pp
value = 2.666666666666666
[]
[]
[Problem]
kernel_coverage_check = false
error_on_jacobian_nonzero_reallocation = true
[]
[BCs]
[bottom]
type = ADFunctionNeumannBC
variable = u
boundary = 'bottom'
function = bottom_bc_fn
[]
[right]
type = ADFunctionNeumannBC
variable = u
boundary = 'right'
function = right_bc_fn
[]
[top]
type = ADFunctionNeumannBC
variable = u
boundary = 'top'
function = top_bc_fn
[]
[left]
type = ADFunctionNeumannBC
variable = u
boundary = 'left'
function = left_bc_fn
[]
[]
[Postprocessors]
# integrate the volume of domain since original objects set
# int(phi)=V0, rather than int(phi-V0)=0
[pp]
type = FunctionElementIntegral
function = 1
execute_on = initial
[]
[l2_err]
type = ElementL2Error
variable = u
function = exact_fn
execute_on = 'initial timestep_end'
[]
[]
[Preconditioning]
[pc]
type = SMP
full = true
solve_type = 'NEWTON'
[]
[]
[Executioner]
type = Steady
residual_and_jacobian_together = true
nl_rel_tol = 1e-9
l_tol = 1.e-10
nl_max_its = 10
# This example builds an indefinite matrix, so "-pc_type hypre -pc_hypre_type boomeramg" cannot
# be used reliably on this problem
petsc_options_iname = '-pc_type -pc_factor_shift_type'
petsc_options_value = 'lu NONZERO'
# This is a linear problem, so we don't need to recompute the
# Jacobian. This isn't a big deal for a Steady problems, however, as
# there is only one solve.
solve_type = 'LINEAR'
[]
[Outputs]
# exodus = true
csv = true
hide = lambda
[]
(examples/ex14_pps/ex14.i)
[Mesh]
type = GeneratedMesh
dim = 2
nx = 32
ny = 32
xmin = 0.0
xmax = 1.0
ymin = 0.0
ymax = 1.0
[]
[Variables]
[forced]
order = FIRST
family = LAGRANGE
[]
[]
[Functions]
# A ParsedFunction allows us to supply analytic expressions directly in the input file
[exact]
type = ParsedFunction
expression = sin(alpha*pi*x)
symbol_names = alpha
symbol_values = 16
[]
# This function is an actual compiled function
[force]
type = ExampleFunction
alpha = 16
[]
[]
[Kernels]
[diff]
type = ADDiffusion
variable = forced
[]
# This Kernel can take a function name to use
[forcing]
type = ADBodyForce
variable = forced
function = force
[]
[]
[BCs]
# The BC can take a function name to use
[all]
type = FunctionDirichletBC
variable = forced
boundary = 'bottom right top left'
function = exact
[]
[]
[Executioner]
type = Steady
solve_type = NEWTON
petsc_options_iname = '-pc_type -pc_hypre_type'
petsc_options_value = 'hypre boomeramg'
[]
[Postprocessors]
[h]
type = AverageElementSize
[]
[error]
type = ElementL2Error
variable = forced
function = exact
[]
[]
[Outputs]
execute_on = 'timestep_end'
exodus = true
csv = true
[]
(modules/level_set/test/tests/functions/olsson_bubble/olsson_bubble_adjac.i)
[Mesh]
type = GeneratedMesh
dim = 2
nx = 10
ny = 10
displacements = 'disp_x disp_y'
[]
[Problem]
kernel_coverage_check = false
[]
[Variables]
[bubble]
[]
[disp_x]
[]
[disp_y]
[]
[]
[Kernels]
[bubble]
type = ADBodyForce
variable = bubble
function = bubble_func
use_displaced_mesh = true
[]
[dt]
type = ADTimeDerivative
variable = bubble
[]
[]
[Functions]
[bubble_func]
type = LevelSetOlssonBubble
center = '0.5 0.5 0'
radius = 0.4
epsilon = 0.05
[]
[]
[Executioner]
solve_type = NEWTON
type = Transient
num_steps = 1
[]
[Outputs]
exodus = true
[]
(modules/heat_transfer/test/tests/ad_convective_heat_flux/coupled.i)
[Mesh]
type = GeneratedMesh
dim = 3
nx = 10
[]
[Variables]
[./temp]
initial_condition = 200.0
[../]
[]
[Kernels]
[./heat_dt]
type = ADTimeDerivative
variable = temp
[../]
[./heat_conduction]
type = Diffusion
variable = temp
[../]
[./heat]
type = ADBodyForce
variable = temp
value = 0
[../]
[]
[BCs]
[./right]
type = ADConvectiveHeatFluxBC
variable = temp
boundary = 'right'
T_infinity = T_inf
heat_transfer_coefficient = htc
[../]
[]
[Materials]
[chf_mat]
type = ADConvectiveHeatFluxTest
temperature = temp
boundary = 'right'
[]
[]
[Postprocessors]
[./left_temp]
type = SideAverageValue
variable = temp
boundary = left
execute_on = 'TIMESTEP_END initial'
[../]
[./right_temp]
type = SideAverageValue
variable = temp
boundary = right
[../]
[./right_flux]
type = SideDiffusiveFluxAverage
variable = temp
boundary = right
diffusivity = 1
[../]
[]
[Executioner]
type = Transient
num_steps = 10
dt = 1
nl_abs_tol = 1e-12
[]
[Outputs]
[./out]
type = CSV
time_step_interval = 10
[../]
[]
(test/tests/bcs/ad_penalty_dirichlet_bc/penalty_dirichlet_bc_test.i)
[Mesh]
type = GeneratedMesh
dim = 2
xmin = -1
xmax = 1
ymin = -1
ymax = 1
nx = 10
ny = 10
elem_type = QUAD9
[]
[Functions]
[./forcing_fn]
type = ParsedFunction
expression = -2*(x*x+y*y-2)+(1-x*x)*(1-y*y)
[../]
[./solution]
type = ParsedGradFunction
value = (1-x*x)*(1-y*y)
grad_x = 2*(x*y*y-x)
grad_y = 2*(x*x*y-y)
[../]
[]
[Variables]
[./u]
order = SECOND
family = HIERARCHIC
[../]
[]
[Kernels]
active = 'diff forcing reaction'
[./diff]
type = ADDiffusion
variable = u
[../]
[./reaction]
type = Reaction
variable = u
[../]
[./forcing]
type = ADBodyForce
variable = u
function = forcing_fn
[../]
[]
[BCs]
active = 'bc_all'
[./bc_all]
type = ADPenaltyDirichletBC
variable = u
value = 0
boundary = 'top left right bottom'
penalty = 1e5
[../]
[]
[Postprocessors]
[./dofs]
type = NumDOFs
[../]
[./h]
type = AverageElementSize
[../]
[./L2error]
type = ElementL2Error
variable = u
function = solution
[../]
[./H1error]
type = ElementH1Error
variable = u
function = solution
[../]
[./H1Semierror]
type = ElementH1SemiError
variable = u
function = solution
[../]
[]
[Executioner]
type = Steady
solve_type = 'NEWTON'
nl_rel_tol = 1e-14
[]
[Outputs]
execute_on = 'timestep_end'
exodus = true
[]
(modules/optimization/examples/diffusion_reaction/forward_exact.i)
[Mesh]
[square]
type = GeneratedMeshGenerator
dim = 2
nx = 16
ny = 16
xmin = 0
xmax = 1
ymin = 0
ymax = 1
[]
[]
[Variables/u]
[]
[Functions]
[rxn_func]
type = ParsedFunction
expression = 'exp(x * y) - 1'
[]
[]
[Materials]
[ad_dc_prop]
type = ADParsedMaterial
expression = '1 + u'
coupled_variables = 'u'
property_name = dc_prop
[]
[ad_rxn_prop]
type = ADGenericFunctionMaterial
prop_values = 'rxn_func'
prop_names = rxn_prop
outputs = exodus
[]
#ADMatReaction includes a negative sign in residual evaluation, so we need to
#reverse this with a negative reaction rate. However, we wanted the parameter
#to remain positive in the optimization problem so we do the same thing here,
#which is why there is one object to evaluate function and another to flip
#it's sign for the kernel
[ad_neg_rxn_prop]
type = ADParsedMaterial
expression = '-rxn_prop'
material_property_names = 'rxn_prop'
property_name = 'neg_rxn_prop'
[]
[]
[Kernels]
[udot]
type = ADTimeDerivative
variable = u
[]
[diff]
type = ADMatDiffusion
variable = u
diffusivity = dc_prop
[]
[reaction]
type = ADMatReaction
variable = u
reaction_rate = neg_rxn_prop
[]
[src]
type = ADBodyForce
variable = u
value = 1
[]
[]
[BCs]
[dirichlet]
type = DirichletBC
variable = u
boundary = 'left bottom'
value = 0
[]
[]
[Executioner]
type = Transient
solve_type = NEWTON
petsc_options_iname = '-pc_type -pc_factor_mat_solver_package'
petsc_options_value = 'lu superlu_dist'
dt = 0.1
end_time = 1
[]
[Reporters]
[sample]
type = TransientSyntheticDataCreator
variable = u
single_set_of_measurement_points = '0.625 0.625 0 0.5 0.5 0 0.25 0.25 0
0.875 0.625 0 0.625 0.875 0 0.75 0.25 0 0.25 0.75 0 0.8125 0.9375 0
0.75 0.75 0
0.8125 0.75 0
0.875 0.75 0
0.9375 0.75 0
1 0.75 0
0.8125 0.8125 0
0.875 0.8125 0
0.9375 0.8125 0
1 0.8125 0
0.875 0.875 0
0.9375 0.875 0
1 0.875 0
0.9375 0.9375 0
1 0.9375 0
1 1 0'
measurement_times_for_all_points = '0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0'
outputs = csv_final
[]
[]
[AuxVariables]
[reaction_rate]
[]
[]
[AuxKernels]
[reaction_rate_aux]
type = FunctionAux
variable = reaction_rate
function = rxn_func
execute_on = TIMESTEP_END
[]
[]
[Postprocessors]
[u1]
type = PointValue
variable = u
point = '0.25 0.25 0'
[]
[u2]
type = PointValue
variable = u
point = '0.75 0.75 0'
[]
[u3]
type = PointValue
variable = u
point = '1 1 0'
[]
[]
[Outputs]
exodus = true
csv = true
[csv_final]
type = CSV
execute_on = 'FINAL'
file_base = forward_exact_csv
[]
[]
(modules/optimization/test/tests/reporter/TransientSyntheticDataCreator/transient_synthetic_data.i)
[Mesh]
[square]
type = GeneratedMeshGenerator
dim = 2
nx = 16
ny = 16
xmin = 0
xmax = 1
ymin = 0
ymax = 1
[]
[]
[Variables/u]
[]
[Functions]
[rxn_func]
type = ParsedFunction
expression = 'exp(x * y) - 1'
[]
[]
[Materials]
[ad_dc_prop]
type = ADParsedMaterial
expression = '1 + u'
coupled_variables = 'u'
property_name = dc_prop
[]
[ad_rxn_prop]
type = ADGenericFunctionMaterial
prop_values = 'rxn_func'
prop_names = rxn_prop
[]
[ad_neg_rxn_prop]
type = ADParsedMaterial
expression = '-rxn_prop'
material_property_names = 'rxn_prop'
property_name = 'neg_rxn_prop'
[]
[]
[Kernels]
[udot]
type = ADTimeDerivative
variable = u
[]
[diff]
type = ADMatDiffusion
variable = u
diffusivity = dc_prop
[]
[reaction]
type = ADMatReaction
variable = u
reaction_rate = neg_rxn_prop
[]
[src]
type = ADBodyForce
variable = u
value = 1
[]
[]
[BCs]
[dirichlet]
type = DirichletBC
variable = u
boundary = 'left bottom'
value = 0
[]
[]
[Executioner]
type = Transient
solve_type = NEWTON
petsc_options_iname = '-pc_type -pc_factor_mat_solver_package'
petsc_options_value = 'lu superlu_dist'
dt = 0.1
end_time = 1
[]
[Reporters]
[sample]
type = TransientSyntheticDataCreator
variable = u
single_set_of_measurement_points = '
0.75 0.75 0
0.9375 0.9375 0
1 0.9375 0
1 1 0'
measurement_times_for_all_points = '0.1 0.2 0.3'
[]
[]
[AuxVariables]
[reaction_rate]
[]
[]
[AuxKernels]
[reaction_rate_aux]
type = FunctionAux
variable = reaction_rate
function = rxn_func
execute_on = TIMESTEP_END
[]
[]
[Outputs]
[csv]
type = CSV
execute_on = 'FINAL'
[]
[]
(test/tests/bcs/ad_function_dirichlet_bc/test.i)
###########################################################
# This is a test of Boundary Condition System. The
# FunctionDirichletBC is used to contribute the residuals
# to the boundary term operators in the weak form.
#
# @Requirement F3.40
###########################################################
[Mesh]
[./square]
type = GeneratedMeshGenerator
dim = 2
nx = 32
ny = 32
[../]
[]
[Variables]
[./u]
[../]
[]
[Functions]
[./ff_1]
type = ParsedFunction
expression = alpha*alpha*pi
symbol_names = 'alpha'
symbol_values = '16'
[../]
[./ff_2]
type = ParsedFunction
expression = pi*sin(alpha*pi*x)
symbol_names = 'alpha'
symbol_values = '16'
[../]
[./forcing_func]
type = CompositeFunction
functions = 'ff_1 ff_2'
[../]
[./bc_func]
type = ParsedFunction
expression = sin(alpha*pi*x)
symbol_names = 'alpha'
symbol_values = '16'
[../]
[]
[Kernels]
[./diff]
type = ADDiffusion
variable = u
[../]
[./forcing]
type = ADBodyForce
variable = u
function = forcing_func
[../]
[]
[BCs]
[./all]
type = ADFunctionDirichletBC
variable = u
boundary = 'left right'
function = bc_func
[../]
[]
[Executioner]
type = Steady
nl_rel_tol = 1e-12
[]
[Outputs]
execute_on = 'timestep_end'
exodus = true
[]
(test/tests/kernels/ad_scalar_kernel_constraint/scalar_constraint_together.i)
[Mesh]
type = GeneratedMesh
dim = 2
xmin = -1
xmax = 1
ymin = -1
ymax = 1
nx = 2
ny = 2
elem_type = QUAD9
[]
[Functions]
[exact_fn]
type = ParsedFunction
value = 'x*x+y*y'
[]
[ffn]
type = ParsedFunction
value = -4
[]
[bottom_bc_fn]
type = ParsedFunction
value = -2*y
[]
[right_bc_fn]
type = ParsedFunction
value = 2*x
[]
[top_bc_fn]
type = ParsedFunction
value = 2*y
[]
[left_bc_fn]
type = ParsedFunction
value = -2*x
[]
[]
[Variables]
[u]
family = LAGRANGE
order = SECOND
[]
[lambda]
family = SCALAR
order = FIRST
[]
[]
[Kernels]
[diff]
type = ADDiffusion
variable = u
[]
[ffnk]
type = ADBodyForce
variable = u
function = ffn
[]
[sk_lm]
type = ADScalarLMKernel
variable = u
kappa = lambda
pp_name = pp
value = 2.666666666666666
[]
[]
[Problem]
kernel_coverage_check = false
error_on_jacobian_nonzero_reallocation = true
[]
[BCs]
[bottom]
type = ADFunctionNeumannBC
variable = u
boundary = 'bottom'
function = bottom_bc_fn
[]
[right]
type = ADFunctionNeumannBC
variable = u
boundary = 'right'
function = right_bc_fn
[]
[top]
type = ADFunctionNeumannBC
variable = u
boundary = 'top'
function = top_bc_fn
[]
[left]
type = ADFunctionNeumannBC
variable = u
boundary = 'left'
function = left_bc_fn
[]
[]
[Postprocessors]
# integrate the volume of domain since original objects set
# int(phi)=V0, rather than int(phi-V0)=0
[pp]
type = FunctionElementIntegral
function = 1
execute_on = initial
[]
[l2_err]
type = ElementL2Error
variable = u
function = exact_fn
execute_on = 'initial timestep_end'
[]
[]
[Executioner]
type = Steady
residual_and_jacobian_together = true
nl_rel_tol = 1e-9
l_tol = 1.e-10
petsc_options_iname = '-pc_type -pc_factor_mat_solver_package'
petsc_options_value = 'lu superlu_dist'
solve_type = NEWTON
[]
[Outputs]
# exodus = true
csv = true
hide = lambda
[]
(modules/stochastic_tools/examples/parameter_study/diffusion_vector.i)
[Mesh]
type = GeneratedMesh
dim = 2
nx = 10
ny = 10
[]
[Variables/T]
initial_condition = 300
[]
[Kernels]
[time]
type = ADTimeDerivative
variable = T
[]
[diff]
type = ADMatDiffusion
variable = T
diffusivity = diffusivity
[]
[source]
type = ADBodyForce
variable = T
value = 100
function = 1
[]
[]
[BCs]
[left]
type = ADDirichletBC
variable = T
boundary = left
value = 300
[]
[right]
type = ADNeumannBC
variable = T
boundary = right
value = -100
[]
[]
[Materials/constant]
type = ADGenericConstantMaterial
prop_names = 'diffusivity'
prop_values = 1
[]
[Executioner]
type = Transient
num_steps = 4
dt = 0.25
[]
[Postprocessors]
[T_avg]
type = ElementAverageValue
variable = T
execute_on = 'initial timestep_end'
[]
[q_left]
type = ADSideDiffusiveFluxAverage
variable = T
boundary = left
diffusivity = diffusivity
execute_on = 'initial timestep_end'
[]
[]
[Reporters]
[acc]
type = AccumulateReporter
reporters = 'T_avg/value q_left/value'
[]
[]
[Controls/stochastic]
type = SamplerReceiver
[]
[Outputs]
[]
(test/tests/kernels/ad_jacobians/adfunction.i)
[Mesh]
type = GeneratedMesh
dim = 2
nx = 10
ny = 10
displacements = 'disp_x disp_y'
[]
[Problem]
kernel_coverage_check = false
[]
[Variables]
[c]
[]
[disp_x]
[]
[disp_y]
[]
[]
[Kernels]
[source]
type = ADBodyForce
variable = c
function = source_func
use_displaced_mesh = true
displacements = ''
#displacements = 'disp_x disp_y'
[]
[dt]
type = ADTimeDerivative
variable = c
[]
[]
[Functions]
[source_func]
type = ParsedFunction
expression = 'x + y^2'
[]
[]
[Executioner]
type = Transient
solve_type = NEWTON
num_steps = 1
[]
(modules/optimization/test/tests/misc/scaling_test/scaling_test.i)
[Problem]
nl_sys_names = 'nl0 adjoint'
kernel_coverage_check = false
[]
[Mesh]
[gmg]
type = GeneratedMeshGenerator
dim = 3
nx = 4
ny = 2
nz = 1
xmin = 9.4615
xmax = 92.0115
ymin = 3.175
ymax = 22.225
zmin = 0.489
zmax = 0.755
[]
[]
[Variables]
[T]
scaling = 10
[]
[lam_T]
solver_sys = adjoint
scaling = 1e3
[]
[]
[Kernels]
[heat_conduction]
type = ADMatDiffusion
variable = T
diffusivity = thermal_conductivity
[]
[heat_source]
type = ADBodyForce
function = src_fuel_function
variable = T
[]
[]
[BCs]
[dir_BC_front]
type = NeumannBC
variable = T
boundary = front
value = 2
[]
[dir_BC_back]
type = DirichletBC
variable = T
boundary = back
value = 300
[]
[]
[Materials]
# fuel properties
[fuel_thermal]
type = ADGenericConstantMaterial
prop_names = thermal_conductivity
prop_values = 17.6e3
[]
[]
[Executioner]
type = SteadyAndAdjoint
forward_system = nl0
adjoint_system = adjoint
petsc_options_iname = '-pc_type -pc_factor_mat_solver_package'
petsc_options_value = 'lu mumps'
line_search = 'none'
nl_rel_tol = 1e-6
nl_abs_tol = 1e-30
nl_max_its = 10
l_max_its = 10
[]
##---------Forward Optimization stuff------------------#
[Reporters]
[measure_data]
type = ConstantReporter
real_vector_names = 'x y z u weight'
real_vector_values = '0.2 0.2 0.0; 0.3 0.8 0.0; 0 0 0; 5 5 5; 1 1 1'
[]
[params_fuel]
type = ConstantReporter
real_vector_names = 'source'
real_vector_values = '5e7' # Dummy
[]
[]
[Functions]
[src_fuel_function]
type = ParsedOptimizationFunction
expression = q
param_symbol_names = 'q'
param_vector_name = 'params_fuel/source'
[]
[]
##---------Adjoint Optimization stuff------------------#
[DiracKernels]
[adjointLoad_T]
type = ReporterPointSource
variable = lam_T
x_coord_name = measure_data/x
y_coord_name = measure_data/y
z_coord_name = measure_data/z
value_name = measure_data/u
[]
[]
##--------- Outputs ------------------#
[Debug]
show_var_residual_norms = true
[]
(test/tests/kernels/ad_jacobians/test.i)
[Mesh]
type = GeneratedMesh
dim = 2
[]
[Variables]
[./u]
[../]
[]
[Kernels]
[./damage_dt]
type = ADTimeDerivative
variable = u
[../]
[./damage]
type = ADBodyForce
value = 1
variable = u
[../]
[]
[Preconditioning]
[./smp]
type = SMP
full = true
[../]
[]
[Executioner]
type = Transient
num_steps = 1
[]
(modules/optimization/examples/diffusion_reaction/forward_and_adjoint.i)
[Mesh]
[square]
type = GeneratedMeshGenerator
dim = 2
nx = 16
ny = 16
xmin = 0
xmax = 1
ymin = 0
ymax = 1
[]
[]
[Variables/u]
[]
[Reporters]
[params]
type = ConstantReporter
real_vector_names = 'reaction_rate'
real_vector_values = '0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0' # Dummy
outputs = none
[]
[data]
type = OptimizationData
variable = u
measurement_file = forward_exact_csv_sample_0011.csv
file_xcoord = measurement_xcoord
file_ycoord = measurement_ycoord
file_zcoord = measurement_zcoord
file_time = measurement_time
file_value = simulation_values
outputs = none
[]
[]
[Functions]
[rxn_func]
type = ParameterMeshFunction
exodus_mesh = parameter_mesh_out.e
parameter_name = params/reaction_rate
[]
[]
[Materials]
[ad_dc_prop]
type = ADParsedMaterial
expression = '1 + u'
coupled_variables = 'u'
property_name = dc_prop
[]
[ad_rxn_prop]
type = ADGenericFunctionMaterial
prop_values = 'rxn_func'
prop_names = rxn_prop
[]
#ADMatReaction includes a negative sign in residual evaluation, so we need to
#reverse this with a negative reaction rate. However, we wanted the parameter
#to remain positive, which is why there is one object to evaluate function
#and another to flip it's sign for the kernel
[ad_neg_rxn_prop]
type = ADParsedMaterial
expression = '-rxn_prop'
material_property_names = 'rxn_prop'
property_name = 'neg_rxn_prop'
[]
[]
[Kernels]
[udot]
type = ADTimeDerivative
variable = u
[]
[diff]
type = ADMatDiffusion
variable = u
diffusivity = dc_prop
[]
[reaction]
type = ADMatReaction
variable = u
reaction_rate = neg_rxn_prop
[]
[src]
type = ADBodyForce
variable = u
value = 1
[]
[]
[BCs]
[dirichlet]
type = DirichletBC
variable = u
boundary = 'left bottom'
value = 0
[]
[]
[Executioner]
type = TransientAndAdjoint
forward_system = nl0
adjoint_system = adjoint
petsc_options_iname = '-pc_type'
petsc_options_value = 'lu'
dt = 0.1
end_time = 1
nl_rel_tol = 1e-12
[]
[Problem]
nl_sys_names = 'nl0 adjoint'
kernel_coverage_check = false
skip_nl_system_check = true
[]
[Variables]
[u_adjoint]
initial_condition = 0
solver_sys = adjoint
outputs = none
[]
[]
[DiracKernels]
[misfit]
type = ReporterTimePointSource
variable = u_adjoint
value_name = data/misfit_values
x_coord_name = data/measurement_xcoord
y_coord_name = data/measurement_ycoord
z_coord_name = data/measurement_zcoord
time_name = data/measurement_time
[]
[]
[VectorPostprocessors]
[adjoint]
type = ElementOptimizationReactionFunctionInnerProduct
variable = u_adjoint
forward_variable = u
function = rxn_func
execute_on = ADJOINT_TIMESTEP_END
outputs = none
[]
[]
[AuxVariables]
[reaction_rate]
[]
[]
[AuxKernels]
[reaction_rate_aux]
type = FunctionAux
variable = reaction_rate
function = rxn_func
execute_on = TIMESTEP_END
[]
[]
[Postprocessors]
[u1]
type = PointValue
variable = u
point = '0.25 0.25 0'
[]
[u2]
type = PointValue
variable = u
point = '0.75 0.75 0'
[]
[u3]
type = PointValue
variable = u
point = '1 1 0'
[]
[]
[Outputs]
exodus = true
console = false
csv = true
[]
(modules/stochastic_tools/examples/parameter_study/diffusion_time.i)
[Mesh]
type = GeneratedMesh
dim = 2
nx = 10
ny = 10
[]
[Variables/T]
initial_condition = 300
[]
[Kernels]
[time]
type = ADTimeDerivative
variable = T
[]
[diff]
type = ADMatDiffusion
variable = T
diffusivity = diffusivity
[]
[source]
type = ADBodyForce
variable = T
value = 100
function = 1
[]
[]
[BCs]
[left]
type = ADDirichletBC
variable = T
boundary = left
value = 300
[]
[right]
type = ADNeumannBC
variable = T
boundary = right
value = -100
[]
[]
[Materials/constant]
type = ADGenericConstantMaterial
prop_names = 'diffusivity'
prop_values = 1
[]
[Executioner]
type = Transient
num_steps = 4
dt = 0.25
[]
[Postprocessors]
[T_avg]
type = ElementAverageValue
variable = T
execute_on = 'initial timestep_end'
[]
[q_left]
type = ADSideDiffusiveFluxAverage
variable = T
boundary = left
diffusivity = diffusivity
execute_on = 'initial timestep_end'
[]
[]
[VectorPostprocessors]
[T_vec]
type = LineValueSampler
variable = T
start_point = '0 0.5 0'
end_point = '1 0.5 0'
num_points = 11
sort_by = x
execute_on = 'initial timestep_end'
[]
[]
[Controls/stochastic]
type = SamplerReceiver
[]
[Outputs]
[]
(modules/stochastic_tools/examples/parameter_study/diffusion.i)
[Mesh]
type = GeneratedMesh
dim = 2
nx = 10
ny = 10
[]
[Variables/T]
initial_condition = 300
[]
[Kernels]
[time]
type = ADTimeDerivative
variable = T
[]
[diff]
type = ADMatDiffusion
variable = T
diffusivity = diffusivity
[]
[source]
type = ADBodyForce
variable = T
value = 100
function = 1
[]
[]
[BCs]
[left]
type = ADDirichletBC
variable = T
boundary = left
value = 300
[]
[right]
type = ADNeumannBC
variable = T
boundary = right
value = -100
[]
[]
[Materials/constant]
type = ADGenericConstantMaterial
prop_names = 'diffusivity'
prop_values = 1
[]
[Executioner]
type = Transient
num_steps = 4
dt = 0.25
[]
[Postprocessors]
[T_avg]
type = ElementAverageValue
variable = T
execute_on = 'initial timestep_end'
[]
[q_left]
type = ADSideDiffusiveFluxAverage
variable = T
boundary = left
diffusivity = diffusivity
execute_on = 'initial timestep_end'
[]
[]
[Controls/stochastic]
type = SamplerReceiver
[]
[Outputs]
[]
(test/tests/kernels/diffusion_with_hanging_node/ad_simple_diffusion.i)
[Mesh]
type = GeneratedMesh
dim = 2
nx = 2
ny = 1
[]
[Variables]
[./u]
[../]
[]
[Kernels]
[./diff]
type = ADDiffusion
variable = u
[../]
[force]
type = ADBodyForce
variable = u
function = '0'
[]
[]
[BCs]
# BCs cannot be preset due to Jacobian test
[./left]
type = DirichletBC
preset = false
variable = u
boundary = left
value = 0
[../]
[./right]
type = DirichletBC
preset = false
variable = u
boundary = right
value = 1
[../]
[]
[Preconditioning]
[./pre]
type = SMP
full = true
[../]
[]
[Executioner]
type = Steady
solve_type = 'NEWTON'
petsc_options = '-pc_svd_monitor'
petsc_options_iname = '-pc_type'
petsc_options_value = 'svd'
[]
[Outputs]
exodus = true
[]
[Adaptivity]
marker = box
max_h_level = 1
initial_steps = 1
[./Markers]
[./box]
type = BoxMarker
bottom_left = '0.5 0 0'
top_right = '1 1 0'
inside = 'refine'
outside = 'do_nothing'
[../]
[../]
[]
(modules/optimization/examples/simpleTransient/nonlinear_forward_and_adjoint.i)
[Mesh]
[gmg]
type = GeneratedMeshGenerator
dim = 2
nx = 10
ny = 10
xmin = -1
xmax = 1
ymin = -1
ymax = 1
[]
[]
[Variables]
[u]
[]
[]
[VectorPostprocessors]
[src_values]
type = CSVReader
csv_file = source_params.csv
header = true
outputs = none
[]
[]
[ICs]
[initial]
type = FunctionIC
variable = u
function = exact
[]
[]
[Kernels]
[dt]
type = ADTimeDerivative
variable = u
[]
[diff]
type = ADMatDiffusion
variable = u
diffusivity = D
[]
[src]
type = ADBodyForce
variable = u
function = source
[]
[]
[BCs]
[dirichlet]
type = DirichletBC
variable = u
boundary = 'left right top bottom'
value = 0
[]
[]
[Materials]
[diffc]
type = ADParsedMaterial
property_name = D
expression = '1 + u'
coupled_variables = u
[]
[]
[Functions]
[exact]
type = ParsedFunction
value = '2*exp(-2.0*(x - sin(2*pi*t))^2)*exp(-2.0*(y - cos(2*pi*t))^2)*cos((1/2)*x*pi)*cos((1/2)*y*pi)/pi'
[]
[source]
type = NearestReporterCoordinatesFunction
x_coord_name = src_values/coordx
y_coord_name = src_values/coordy
time_name = src_values/time
value_name = src_values/values
[]
[]
[Executioner]
type = TransientAndAdjoint
forward_system = nl0
adjoint_system = adjoint
num_steps = 100
end_time = 1
nl_rel_tol = 1e-12
l_tol = 1e-12
petsc_options_iname = '-pc_type'
petsc_options_value = 'lu'
[]
[Reporters]
[measured_data]
type = OptimizationData
measurement_file = mms_data.csv
file_xcoord = x
file_ycoord = y
file_zcoord = z
file_time = t
file_value = u
variable = u
execute_on = timestep_end
outputs = none
[]
[]
[Postprocessors]
[topRight_pp]
type = PointValue
point = '0.5 0.5 0'
variable = u
execute_on = TIMESTEP_END
[]
[bottomRight_pp]
type = PointValue
point = '-0.5 0.5 0'
variable = u
execute_on = TIMESTEP_END
[]
[bottomLeft_pp]
type = PointValue
point = '-0.5 -0.5 0'
variable = u
execute_on = TIMESTEP_END
[]
[topLeft_pp]
type = PointValue
point = '0.5 -0.5 0'
variable = u
execute_on = TIMESTEP_END
[]
[]
[Outputs]
csv = true
console = false
[]
[Problem]
nl_sys_names = 'nl0 adjoint'
kernel_coverage_check = false
[]
[Variables]
[u_adjoint]
solver_sys = adjoint
outputs = none
[]
[]
[DiracKernels]
[misfit]
type = ReporterTimePointSource
variable = u_adjoint
value_name = measured_data/misfit_values
x_coord_name = measured_data/measurement_xcoord
y_coord_name = measured_data/measurement_ycoord
z_coord_name = measured_data/measurement_zcoord
time_name = measured_data/measurement_time
[]
[]
[VectorPostprocessors]
[adjoint]
type = ElementOptimizationSourceFunctionInnerProduct
variable = u_adjoint
function = source
execute_on = ADJOINT_TIMESTEP_END
outputs = none
[]
[]