- value_nameName of vector-postprocessor or reporter vector containing value data.
C++ Type:ReporterName
Unit:(no unit assumed)
Controllable:No
Description:Name of vector-postprocessor or reporter vector containing value data.
NearestReporterCoordinatesFunction
This Function finds the nearest point in the specified vectors of coordinates and returns the values specified in the vector of values at the index of the nearest point. All the vectors must be specified using either vector postprocessors or reporter vectors. This function interpolates linearly in time with transient data.
Overview
This function computes values based on coordinate and time data. This data comes in the form of vector reporter or vectorpostprocessor values. The required parameter "value_name" is the name of the vector containing the values used to set the variable to. "x_coord_name"/"y_coord_name"/"z_coord_name" are vectors with the x-/y-/z-coordinate data. The auxkernel will set the variable's nodal/elemental values based on the nearest point in this data. "time_name" is the name of the time data; the kernel will linearly interpolate between two closest times for a certain coordinate, without extrapolating. "x_coord_name", "y_coord_name", "z_coord_name", and "time_name" will assume to be 0 when not specified. When specified, "x_coord_name", "y_coord_name", "z_coord_name", and "time_name" must all be the same length as "value_name".
Example Input File Syntax
Here are several examples of different combinations where x, y, z, and time data is specified:
[Functions]
active = 'xyzt'
[xx]
type = NearestReporterCoordinatesFunction
x_coord_name = 'values1D/coordx'
value_name = 'values1D/value'
[]
[xy]
type = NearestReporterCoordinatesFunction
x_coord_name = 'values2D/coordx'
y_coord_name = 'values2D/coordy'
value_name = 'values2D/value'
[]
[xyz]
type = NearestReporterCoordinatesFunction
x_coord_name = 'values3D/coordx'
y_coord_name = 'values3D/coordy'
z_coord_name = 'values3D/coordz'
value_name = 'values3D/value'
[]
[xyzt]
type = NearestReporterCoordinatesFunction
x_coord_name = 'values4D/coordx'
y_coord_name = 'values4D/coordy'
z_coord_name = 'values4D/coordz'
time_name = 'values4D/time'
value_name = 'values4D/value'
[]
[errorv]
type = NearestReporterCoordinatesFunction
x_coord_name = 'values4D/coordx'
value_name = 'values1D/val'
[]
[errorx]
type = NearestReporterCoordinatesFunction
x_coord_name = 'values1D/coordx'
y_coord_name = 'values4D/coordx'
value_name = 'values4D/value'
[]
[errory]
type = NearestReporterCoordinatesFunction
x_coord_name = 'values4D/coordx'
y_coord_name = 'values1D/coordx'
value_name = 'values4D/value'
[]
[errorz]
type = NearestReporterCoordinatesFunction
variable = val
x_coord_name = 'values4D/coordx'
z_coord_name = 'values1D/coordx'
value_name = 'values4D/value'
[]
[errort]
type = NearestReporterCoordinatesFunction
x_coord_name = 'values4D/coordx'
time_name = 'values1D/coordx'
value_name = 'values4D/value'
[]
[]
[Reporters]
[values1D]
type = ConstantReporter
real_vector_names = 'coordx value'
real_vector_values = '0.25 0.75;
0.00 1.00'
[]
[values2D]
type = ConstantReporter
real_vector_names = 'coordx coordy value'
real_vector_values = '0.25 0.75 0.25 0.75;
0.25 0.25 0.75 0.75;
0.00 1.00 2.00 3.00'
[]
[values3D]
type = ConstantReporter
real_vector_names = 'coordx coordy coordz value'
real_vector_values = '0.25 0.75 0.25 0.75 0.25 0.75 0.25 0.75;
0.25 0.25 0.75 0.75 0.25 0.25 0.75 0.75;
0.25 0.25 0.25 0.25 0.75 0.75 0.75 0.75;
0.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00'
[]
[values4D]
type = ConstantReporter
real_vector_names = 'coordx coordy coordz time value'
real_vector_values = '0.25 0.75 0.25 0.75 0.25 0.75 0.25 0.75
0.25 0.75 0.25 0.75 0.25 0.75 0.25 0.75
0.25 0.75 0.25 0.75 0.25 0.75 0.25 0.75;
0.25 0.25 0.75 0.75 0.25 0.25 0.75 0.75
0.25 0.25 0.75 0.75 0.25 0.25 0.75 0.75
0.25 0.25 0.75 0.75 0.25 0.25 0.75 0.75;
0.25 0.25 0.25 0.25 0.75 0.75 0.75 0.75
0.25 0.25 0.25 0.25 0.75 0.75 0.75 0.75
0.25 0.25 0.25 0.25 0.75 0.75 0.75 0.75;
0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
0.50 0.50 0.50 0.50 0.50 0.50 0.50 0.50
1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00;
0.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00
8.00 9.00 10.0 11.0 12.0 13.0 14.0 15.0
16.0 17.0 18.0 19.0 20.0 21.0 22.0 23.0'
[]
[]
(modules/optimization/test/tests/functions/nearest_reporter_coord/nearest_reporter_point.i)Run this test to see how the function interpolates the data between specified times.
Input Parameters
- time_nameName of vector-postprocessor or reporter vector containing time, default is assumed to be all 0s.
C++ Type:ReporterName
Unit:(no unit assumed)
Controllable:No
Description:Name of vector-postprocessor or reporter vector containing time, default is assumed to be all 0s.
- x_coord_nameName of vector-postprocessor or reporter vector containing x-coordinate of points, default is assumed to be all 0s.
C++ Type:ReporterName
Unit:(no unit assumed)
Controllable:No
Description:Name of vector-postprocessor or reporter vector containing x-coordinate of points, default is assumed to be all 0s.
- y_coord_nameName of vector-postprocessor or reporter vector containing y-coordinate of points, default is assumed to be all 0s.
C++ Type:ReporterName
Unit:(no unit assumed)
Controllable:No
Description:Name of vector-postprocessor or reporter vector containing y-coordinate of points, default is assumed to be all 0s.
- z_coord_nameName of vector-postprocessor or reporter vector containing z-coordinate of points, default is assumed to be all 0s.
C++ Type:ReporterName
Unit:(no unit assumed)
Controllable:No
Description:Name of vector-postprocessor or reporter vector containing z-coordinate of points, default is assumed to be all 0s.
Optional Parameters
- control_tagsAdds user-defined labels for accessing object parameters via control logic.
C++ Type:std::vector<std::string>
Unit:(no unit assumed)
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
Unit:(no unit assumed)
Controllable:No
Description:Set the enabled status of the MooseObject.
Advanced Parameters
Input Files
- (modules/optimization/examples/simpleTransient/adjoint.i)
- (modules/optimization/test/tests/optimizationreporter/bimaterial/model.i)
- (modules/combined/test/tests/optimization/invOpt_elasticity_modular/forward.i)
- (modules/optimization/examples/materialTransient/forward.i)
- (modules/optimization/test/tests/functions/nearest_reporter_coord/nearest_reporter_point.i)
- (modules/optimization/test/tests/optimizationreporter/bimaterial/grad.i)
- (modules/optimization/examples/simpleTransient/forward_and_adjoint.i)
- (modules/optimization/test/tests/optimizationreporter/bimaterial/model_and_adjoint.i)
- (modules/optimization/examples/simpleTransient/nonlinear_forward_and_adjoint.i)
- (modules/optimization/test/tests/vectorpostprocessors/adjoint_strain_batch_stress_grad_inner_product/strain_stress_grad_inner_product.i)
- (modules/optimization/examples/simpleTransient/forward.i)
- (modules/optimization/test/tests/vectorpostprocessors/element_source_inner_product/element_source_inner_product.i)
- (modules/optimization/examples/materialFrequency/wave1D/model_grad.i)
- (modules/combined/test/tests/optimization/invOpt_elasticity_modular/grad.i)
- (modules/optimization/test/tests/vectorpostprocessors/adjoint_strain_batch_stress_grad_inner_product/strain_stress_grad_inner_product_material.i)
- (modules/optimization/examples/materialTransient/forward_and_adjoint.i)
- (modules/optimization/examples/materialTransient/gradient.i)
value_name
C++ Type:ReporterName
Unit:(no unit assumed)
Controllable:No
Description:Name of vector-postprocessor or reporter vector containing value data.
x_coord_name
C++ Type:ReporterName
Unit:(no unit assumed)
Controllable:No
Description:Name of vector-postprocessor or reporter vector containing x-coordinate of points, default is assumed to be all 0s.
y_coord_name
C++ Type:ReporterName
Unit:(no unit assumed)
Controllable:No
Description:Name of vector-postprocessor or reporter vector containing y-coordinate of points, default is assumed to be all 0s.
z_coord_name
C++ Type:ReporterName
Unit:(no unit assumed)
Controllable:No
Description:Name of vector-postprocessor or reporter vector containing z-coordinate of points, default is assumed to be all 0s.
time_name
C++ Type:ReporterName
Unit:(no unit assumed)
Controllable:No
Description:Name of vector-postprocessor or reporter vector containing time, default is assumed to be all 0s.
x_coord_name
C++ Type:ReporterName
Unit:(no unit assumed)
Controllable:No
Description:Name of vector-postprocessor or reporter vector containing x-coordinate of points, default is assumed to be all 0s.
y_coord_name
C++ Type:ReporterName
Unit:(no unit assumed)
Controllable:No
Description:Name of vector-postprocessor or reporter vector containing y-coordinate of points, default is assumed to be all 0s.
z_coord_name
C++ Type:ReporterName
Unit:(no unit assumed)
Controllable:No
Description:Name of vector-postprocessor or reporter vector containing z-coordinate of points, default is assumed to be all 0s.
time_name
C++ Type:ReporterName
Unit:(no unit assumed)
Controllable:No
Description:Name of vector-postprocessor or reporter vector containing time, default is assumed to be all 0s.
x_coord_name
C++ Type:ReporterName
Unit:(no unit assumed)
Controllable:No
Description:Name of vector-postprocessor or reporter vector containing x-coordinate of points, default is assumed to be all 0s.
y_coord_name
C++ Type:ReporterName
Unit:(no unit assumed)
Controllable:No
Description:Name of vector-postprocessor or reporter vector containing y-coordinate of points, default is assumed to be all 0s.
z_coord_name
C++ Type:ReporterName
Unit:(no unit assumed)
Controllable:No
Description:Name of vector-postprocessor or reporter vector containing z-coordinate of points, default is assumed to be all 0s.
time_name
C++ Type:ReporterName
Unit:(no unit assumed)
Controllable:No
Description:Name of vector-postprocessor or reporter vector containing time, default is assumed to be all 0s.
value_name
C++ Type:ReporterName
Unit:(no unit assumed)
Controllable:No
Description:Name of vector-postprocessor or reporter vector containing value data.
(modules/optimization/test/tests/functions/nearest_reporter_coord/nearest_reporter_point.i)
[Mesh]
[gmg]
type = GeneratedMeshGenerator
dim = 3
nx = 4
ny = 4
nz = 4
[]
[]
[AuxVariables]
[val]
family = MONOMIAL
order = CONSTANT
[]
[]
[AuxKernels]
[val_aux]
type = FunctionAux
variable = val
function = 'xyzt'
execute_on = 'initial timestep_end'
[]
[]
[Functions]
active = 'xyzt'
[xx]
type = NearestReporterCoordinatesFunction
x_coord_name = 'values1D/coordx'
value_name = 'values1D/value'
[]
[xy]
type = NearestReporterCoordinatesFunction
x_coord_name = 'values2D/coordx'
y_coord_name = 'values2D/coordy'
value_name = 'values2D/value'
[]
[xyz]
type = NearestReporterCoordinatesFunction
x_coord_name = 'values3D/coordx'
y_coord_name = 'values3D/coordy'
z_coord_name = 'values3D/coordz'
value_name = 'values3D/value'
[]
[xyzt]
type = NearestReporterCoordinatesFunction
x_coord_name = 'values4D/coordx'
y_coord_name = 'values4D/coordy'
z_coord_name = 'values4D/coordz'
time_name = 'values4D/time'
value_name = 'values4D/value'
[]
[errorv]
type = NearestReporterCoordinatesFunction
x_coord_name = 'values4D/coordx'
value_name = 'values1D/val'
[]
[errorx]
type = NearestReporterCoordinatesFunction
x_coord_name = 'values1D/coordx'
y_coord_name = 'values4D/coordx'
value_name = 'values4D/value'
[]
[errory]
type = NearestReporterCoordinatesFunction
x_coord_name = 'values4D/coordx'
y_coord_name = 'values1D/coordx'
value_name = 'values4D/value'
[]
[errorz]
type = NearestReporterCoordinatesFunction
variable = val
x_coord_name = 'values4D/coordx'
z_coord_name = 'values1D/coordx'
value_name = 'values4D/value'
[]
[errort]
type = NearestReporterCoordinatesFunction
x_coord_name = 'values4D/coordx'
time_name = 'values1D/coordx'
value_name = 'values4D/value'
[]
[]
[Reporters]
[values1D]
type = ConstantReporter
real_vector_names = 'coordx value'
real_vector_values = '0.25 0.75;
0.00 1.00'
[]
[values2D]
type = ConstantReporter
real_vector_names = 'coordx coordy value'
real_vector_values = '0.25 0.75 0.25 0.75;
0.25 0.25 0.75 0.75;
0.00 1.00 2.00 3.00'
[]
[values3D]
type = ConstantReporter
real_vector_names = 'coordx coordy coordz value'
real_vector_values = '0.25 0.75 0.25 0.75 0.25 0.75 0.25 0.75;
0.25 0.25 0.75 0.75 0.25 0.25 0.75 0.75;
0.25 0.25 0.25 0.25 0.75 0.75 0.75 0.75;
0.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00'
[]
[values4D]
type = ConstantReporter
real_vector_names = 'coordx coordy coordz time value'
real_vector_values = '0.25 0.75 0.25 0.75 0.25 0.75 0.25 0.75
0.25 0.75 0.25 0.75 0.25 0.75 0.25 0.75
0.25 0.75 0.25 0.75 0.25 0.75 0.25 0.75;
0.25 0.25 0.75 0.75 0.25 0.25 0.75 0.75
0.25 0.25 0.75 0.75 0.25 0.25 0.75 0.75
0.25 0.25 0.75 0.75 0.25 0.25 0.75 0.75;
0.25 0.25 0.25 0.25 0.75 0.75 0.75 0.75
0.25 0.25 0.25 0.25 0.75 0.75 0.75 0.75
0.25 0.25 0.25 0.25 0.75 0.75 0.75 0.75;
0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
0.50 0.50 0.50 0.50 0.50 0.50 0.50 0.50
1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00;
0.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00
8.00 9.00 10.0 11.0 12.0 13.0 14.0 15.0
16.0 17.0 18.0 19.0 20.0 21.0 22.0 23.0'
[]
[]
[Problem]
solve = false
kernel_coverage_check = false
skip_nl_system_check = true
[]
[Executioner]
type = Transient
dt = 0.1
end_time = 1
[]
[Outputs]
exodus = true
[]
(modules/optimization/examples/simpleTransient/adjoint.i)
[Mesh]
[gmg]
type = GeneratedMeshGenerator
dim = 2
nx = 10
ny = 10
xmin = -1
xmax = 1
ymin = -1
ymax = 1
[]
[]
[Variables]
[u]
[]
[]
[Kernels]
[dt]
type = TimeDerivative
variable = u
[]
[diff]
type = Diffusion
variable = u
[]
[]
[BCs]
[dirichlet]
type = DirichletBC
variable = u
boundary = 'left right top bottom'
value = 0
[]
[]
[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
[]
[]
[DiracKernels]
[misfit]
type = ReporterTimePointSource
variable = u
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
reverse_time_end = 1
[]
[]
[VectorPostprocessors]
[src_values]
type = CSVReader
csv_file = source_params.csv
header = true
[]
[]
[Functions]
[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
[]
[]
[VectorPostprocessors]
[adjoint]
type = ElementOptimizationSourceFunctionInnerProduct
variable = u
function = source
reverse_time_end = 1
[]
[]
[Executioner]
type = Transient
num_steps = 100
end_time = 1
solve_type = NEWTON
petsc_options_iname = '-pc_type'
petsc_options_value = 'lu'
reuse_preconditioner=true
reuse_preconditioner_max_linear_its=50
[]
[Outputs]
console = false
[]
(modules/optimization/test/tests/optimizationreporter/bimaterial/model.i)
# Steady state Heat conduction in a 2D domain with two diffusivities
# The domain is -4 <= x <= 4 and -4 <= y <= 4
# The top-half of the domain (y > 0) has high diffusivity
# The bottom-half of the domain (y < 0) has low diffusivity
[Mesh]
[gmg]
type = GeneratedMeshGenerator
dim = 2
nx = 16
ny = 16
xmin = -4
xmax = 4
ymin = -4
ymax = 4
[]
[]
[Variables]
[temperature]
[]
[]
[Kernels]
[heat_conduction]
type = MatDiffusion
variable = temperature
diffusivity = diffusivity
[]
[heat_source]
type = BodyForce
value = 100
variable = temperature
[]
[]
[AuxVariables]
[grad_Tx]
order = CONSTANT
family = MONOMIAL
[]
[grad_Ty]
order = CONSTANT
family = MONOMIAL
[]
[grad_Tz]
order = CONSTANT
family = MONOMIAL
[]
[]
[BCs]
[bottom]
type = DirichletBC
variable = temperature
boundary = bottom
value = 0
[]
[]
[Functions]
[diffusivity_function]
type = NearestReporterCoordinatesFunction
x_coord_name = data/coordx
y_coord_name = data/coordy
value_name = data/diffusivity
[]
[]
[Materials]
[mat]
type = GenericFunctionMaterial
prop_names = diffusivity
prop_values = diffusivity_function
[]
[]
[Reporters]
[measure_data]
type = OptimizationData
variable = temperature
objective_name = objective_value
[]
[data]
type = ConstantReporter
real_vector_names = 'coordx coordy diffusivity'
real_vector_values = '0 0; -2 2; 5 10'
[]
[]
[Executioner]
type = Steady
solve_type = NEWTON
petsc_options_iname = '-pc_type'
petsc_options_value = 'lu'
nl_forced_its = 1
line_search = none
nl_abs_tol = 1e-8
[]
[Outputs]
file_base = 'forward'
console = false
[]
(modules/combined/test/tests/optimization/invOpt_elasticity_modular/forward.i)
[GlobalParams]
displacements = 'ux uy'
[]
[Mesh]
[gmg]
type = GeneratedMeshGenerator
dim = 2
nx = 11
ny = 11
xmin = -4
xmax = 4
ymin = -4
ymax = 4
[]
[]
[AuxVariables]
[T]
[]
[]
[Physics]
[SolidMechanics]
[QuasiStatic]
[all]
strain = SMALL
new_system = true
add_variables = true
formulation = TOTAL
incremental = true
volumetric_locking_correction = false
[]
[]
[]
[]
[BCs]
[bottom_x]
type = DirichletBC
variable = ux
boundary = bottom
value = 0.0
[]
[bottom_y]
type = DirichletBC
variable = uy
boundary = bottom
value = 0.0
[]
[top_x]
type = NeumannBC
variable = ux
boundary = top
value = 1.0
[]
[top_y]
type = NeumannBC
variable = uy
boundary = top
value = 1.0
[]
[]
[NEML2]
input = 'elasticity.i'
model = 'forward_elasticity_model'
verbose = true
mode = PARSE_ONLY
device = 'cpu'
enable_AD = true
[]
[Materials]
[output_stress_jacobian]
type = NEML2StressToMOOSE
execute_neml2_model_uo = model
neml2_stress_output = state/S
neml2_strain_input = forces/E
[]
[E_material]
type = GenericFunctionMaterial
prop_names = 'E_material'
prop_values = E
[]
[output_dS_dE]
type = NEML2ParameterDerivativeToSymmetricRankTwoTensorMOOSEMaterialProperty
execute_neml2_model_uo = model
moose_material_property = neml2_ds_dE
# dstress/dE
neml2_variable = state/S
neml2_parameter_derivative = 'E'
# outputs = exodus
[]
[]
[Functions]
[E]
type = NearestReporterCoordinatesFunction
x_coord_name = parametrization/coordx
y_coord_name = parametrization/coordy
value_name = parametrization/youngs_modulus
[]
[]
[Reporters]
[measure_data]
type = OptimizationData
variable = ux
objective_name = objective_value
[]
[parametrization]
type = ConstantReporter
real_vector_names = 'coordx coordy youngs_modulus'
real_vector_values = '0 0 0; ${fparse 8/3} 0 ${fparse -8/3}; 5 5 5'
[]
[]
[UserObjects]
[input_strain]
type = MOOSERankTwoTensorMaterialPropertyToNEML2
moose_material_property = mechanical_strain
neml2_variable = forces/E
[]
[E_material]
type = MOOSERealMaterialToNEML2Parameter
moose_material_property = E_material
neml2_parameter = E
[]
[model]
type = ExecuteNEML2Model
model = forward_elasticity_model
# add other gatherers here if needed
gather_uos = 'input_strain'
gather_param_uos = 'E_material'
# enable_AD = true # AD is not necessary for the forward app
[]
[]
[Executioner]
type = Steady
solve_type = NEWTON
petsc_options_iname = '-pc_type'
petsc_options_value = 'lu'
# better efficiency if we compute them together
residual_and_jacobian_together = true
[]
[Postprocessors]
[point1]
type = PointValue
point = '-1.0 -1.0 0.0'
variable = ux
execute_on = TIMESTEP_END
[]
[point2]
type = PointValue
point = '-1.0 0.0 0.0'
variable = ux
execute_on = TIMESTEP_END
[]
[point3]
type = PointValue
point = '-1.0 1.0 0.0'
variable = ux
execute_on = TIMESTEP_END
[]
[point4]
type = PointValue
point = '0.0 -1.0 0.0'
variable = ux
execute_on = TIMESTEP_END
[]
[point5]
type = PointValue
point = '0.0 0.0 0.0'
variable = ux
execute_on = TIMESTEP_END
[]
[point6]
type = PointValue
point = '0.0 1.0 0.0'
variable = ux
execute_on = TIMESTEP_END
[]
[point7]
type = PointValue
point = '1.0 -1.0 0.0'
variable = ux
execute_on = TIMESTEP_END
[]
[point8]
type = PointValue
point = '1.0 0.0 0.0'
variable = ux
execute_on = TIMESTEP_END
[]
[point9]
type = PointValue
point = '1.0 1.0 0.0'
variable = ux
execute_on = TIMESTEP_END
[]
[]
[Outputs]
file_base = 'forward'
console = false
# exodus = true
# csv = true
[]
(modules/optimization/examples/materialTransient/forward.i)
[Mesh]
[gmg]
type = GeneratedMeshGenerator
dim = 2
xmax = 1
ymax = 1
nx = 10
ny = 10
[]
[]
[Variables/u]
initial_condition = 0
[]
[Kernels]
[dt]
type = TimeDerivative
variable = u
[]
[diff]
type = MatDiffusion
variable = u
diffusivity = D
[]
[src]
type = BodyForce
variable = u
value = 1
[]
[]
[BCs]
[dirichlet]
type = DirichletBC
variable = u
boundary = 'right top'
value = 0
[]
[]
[Materials]
[diffc]
type = GenericFunctionMaterial
prop_names = 'D'
prop_values = 'diffc_fun'
output_properties = 'D'
outputs = 'exodus'
[]
[]
[Functions]
[diffc_fun]
type = NearestReporterCoordinatesFunction
value_name = 'diffc_rep/D_vals'
x_coord_name = 'diffc_rep/D_x_coord'
y_coord_name = 'diffc_rep/D_y_coord'
[]
[]
[Reporters]
[diffc_rep]
type = ConstantReporter
real_vector_names = 'D_x_coord D_y_coord D_vals'
real_vector_values = '0.25 0.75 0.25 0.75;
0.25 0.25 0.75 0.75;
1 0.2 0.2 0.05' # Reference solution
outputs = none
[]
[data]
type = OptimizationData
variable = u
measurement_points = '0.25 0.25 0 0.25 0.75 0 0.75 0.25 0 0.75 0.75 0
0.25 0.25 0 0.25 0.75 0 0.75 0.25 0 0.75 0.75 0
0.25 0.25 0 0.25 0.75 0 0.75 0.25 0 0.75 0.75 0
0.25 0.25 0 0.25 0.75 0 0.75 0.25 0 0.75 0.75 0
0.25 0.25 0 0.25 0.75 0 0.75 0.25 0 0.75 0.75 0
0.25 0.25 0 0.25 0.75 0 0.75 0.25 0 0.75 0.75 0
0.25 0.25 0 0.25 0.75 0 0.75 0.25 0 0.75 0.75 0
0.25 0.25 0 0.25 0.75 0 0.75 0.25 0 0.75 0.75 0
0.25 0.25 0 0.25 0.75 0 0.75 0.25 0 0.75 0.75 0
0.25 0.25 0 0.25 0.75 0 0.75 0.25 0 0.75 0.75 0'
measurement_times = '0.1 0.1 0.1 0.1
0.2 0.2 0.2 0.2
0.3 0.3 0.3 0.3
0.4 0.4 0.4 0.4
0.5 0.5 0.5 0.5
0.6 0.6 0.6 0.6
0.7 0.7 0.7 0.7
0.8 0.8 0.8 0.8
0.9 0.9 0.9 0.9
1.0 1.0 1.0 1.0'
measurement_values = '0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0'
objective_name = objective_value
outputs = none
[]
[]
[Postprocessors]
[D1]
type = PointValue
variable = D
point = '0.25 0.25 0'
[]
[D2]
type = PointValue
variable = D
point = '0.75 0.25 0'
[]
[D3]
type = PointValue
variable = D
point = '0.25 0.75 0'
[]
[D4]
type = PointValue
variable = D
point = '0.75 0.75 0'
[]
[]
[Executioner]
type = Transient
solve_type = NEWTON
nl_rel_tol = 1e-8
nl_abs_tol = 1e-12
dt = 0.1
num_steps = 10
[]
[Outputs]
csv = true
exodus = true
[]
(modules/optimization/test/tests/functions/nearest_reporter_coord/nearest_reporter_point.i)
[Mesh]
[gmg]
type = GeneratedMeshGenerator
dim = 3
nx = 4
ny = 4
nz = 4
[]
[]
[AuxVariables]
[val]
family = MONOMIAL
order = CONSTANT
[]
[]
[AuxKernels]
[val_aux]
type = FunctionAux
variable = val
function = 'xyzt'
execute_on = 'initial timestep_end'
[]
[]
[Functions]
active = 'xyzt'
[xx]
type = NearestReporterCoordinatesFunction
x_coord_name = 'values1D/coordx'
value_name = 'values1D/value'
[]
[xy]
type = NearestReporterCoordinatesFunction
x_coord_name = 'values2D/coordx'
y_coord_name = 'values2D/coordy'
value_name = 'values2D/value'
[]
[xyz]
type = NearestReporterCoordinatesFunction
x_coord_name = 'values3D/coordx'
y_coord_name = 'values3D/coordy'
z_coord_name = 'values3D/coordz'
value_name = 'values3D/value'
[]
[xyzt]
type = NearestReporterCoordinatesFunction
x_coord_name = 'values4D/coordx'
y_coord_name = 'values4D/coordy'
z_coord_name = 'values4D/coordz'
time_name = 'values4D/time'
value_name = 'values4D/value'
[]
[errorv]
type = NearestReporterCoordinatesFunction
x_coord_name = 'values4D/coordx'
value_name = 'values1D/val'
[]
[errorx]
type = NearestReporterCoordinatesFunction
x_coord_name = 'values1D/coordx'
y_coord_name = 'values4D/coordx'
value_name = 'values4D/value'
[]
[errory]
type = NearestReporterCoordinatesFunction
x_coord_name = 'values4D/coordx'
y_coord_name = 'values1D/coordx'
value_name = 'values4D/value'
[]
[errorz]
type = NearestReporterCoordinatesFunction
variable = val
x_coord_name = 'values4D/coordx'
z_coord_name = 'values1D/coordx'
value_name = 'values4D/value'
[]
[errort]
type = NearestReporterCoordinatesFunction
x_coord_name = 'values4D/coordx'
time_name = 'values1D/coordx'
value_name = 'values4D/value'
[]
[]
[Reporters]
[values1D]
type = ConstantReporter
real_vector_names = 'coordx value'
real_vector_values = '0.25 0.75;
0.00 1.00'
[]
[values2D]
type = ConstantReporter
real_vector_names = 'coordx coordy value'
real_vector_values = '0.25 0.75 0.25 0.75;
0.25 0.25 0.75 0.75;
0.00 1.00 2.00 3.00'
[]
[values3D]
type = ConstantReporter
real_vector_names = 'coordx coordy coordz value'
real_vector_values = '0.25 0.75 0.25 0.75 0.25 0.75 0.25 0.75;
0.25 0.25 0.75 0.75 0.25 0.25 0.75 0.75;
0.25 0.25 0.25 0.25 0.75 0.75 0.75 0.75;
0.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00'
[]
[values4D]
type = ConstantReporter
real_vector_names = 'coordx coordy coordz time value'
real_vector_values = '0.25 0.75 0.25 0.75 0.25 0.75 0.25 0.75
0.25 0.75 0.25 0.75 0.25 0.75 0.25 0.75
0.25 0.75 0.25 0.75 0.25 0.75 0.25 0.75;
0.25 0.25 0.75 0.75 0.25 0.25 0.75 0.75
0.25 0.25 0.75 0.75 0.25 0.25 0.75 0.75
0.25 0.25 0.75 0.75 0.25 0.25 0.75 0.75;
0.25 0.25 0.25 0.25 0.75 0.75 0.75 0.75
0.25 0.25 0.25 0.25 0.75 0.75 0.75 0.75
0.25 0.25 0.25 0.25 0.75 0.75 0.75 0.75;
0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
0.50 0.50 0.50 0.50 0.50 0.50 0.50 0.50
1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00;
0.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00
8.00 9.00 10.0 11.0 12.0 13.0 14.0 15.0
16.0 17.0 18.0 19.0 20.0 21.0 22.0 23.0'
[]
[]
[Problem]
solve = false
kernel_coverage_check = false
skip_nl_system_check = true
[]
[Executioner]
type = Transient
dt = 0.1
end_time = 1
[]
[Outputs]
exodus = true
[]
(modules/optimization/test/tests/optimizationreporter/bimaterial/grad.i)
[Mesh]
[gmg]
type = GeneratedMeshGenerator
dim = 2
nx = 16
ny = 16
xmin = -4
xmax = 4
ymin = -4
ymax = 4
[]
[]
[Variables]
[adjoint_T]
[]
[]
[Kernels]
[conduction]
type = MatDiffusion
diffusivity = diffusivity
variable = adjoint_T
[]
[]
[Reporters]
[misfit]
type = OptimizationData
[]
[data]
type = ConstantReporter
real_vector_names = 'coordx coordy diffusivity'
real_vector_values = '0 0; -2 2; 5 10'
[]
[]
[DiracKernels]
[pt]
type = ReporterPointSource
variable = adjoint_T
x_coord_name = misfit/measurement_xcoord
y_coord_name = misfit/measurement_ycoord
z_coord_name = misfit/measurement_zcoord
value_name = misfit/misfit_values
[]
[]
[BCs]
[bottom]
type = DirichletBC
variable = adjoint_T
boundary = bottom
value = 0
[]
[]
[AuxVariables]
[temperature_forward]
[]
[]
[Functions]
[diffusivity_function]
type = NearestReporterCoordinatesFunction
x_coord_name = data/coordx
y_coord_name = data/coordy
value_name = data/diffusivity
[]
[]
[Materials] #same material as what was used in the forward model
[mat]
type = GenericFunctionMaterial
prop_names = diffusivity
prop_values = diffusivity_function
[]
[]
[VectorPostprocessors]
[gradvec]
type = ElementOptimizationDiffusionCoefFunctionInnerProduct
variable = adjoint_T
forward_variable = temperature_forward
function = diffusivity_function
[]
[]
[Executioner]
type = Steady
solve_type = NEWTON
petsc_options_iname = '-pc_type'
petsc_options_value = 'lu'
nl_forced_its = 1
line_search = none
nl_abs_tol = 1e-8
[]
[Outputs]
console = false
file_base = 'adjoint'
[]
(modules/optimization/examples/simpleTransient/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 = TimeDerivative
variable = u
[]
[diff]
type = Diffusion
variable = u
[]
[src]
type = BodyForce
variable = u
function = source
[]
[]
[BCs]
[dirichlet]
type = DirichletBC
variable = u
boundary = 'left right top bottom'
value = 0
[]
[]
[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
objective_name = objective_value
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
[]
[]
(modules/optimization/test/tests/optimizationreporter/bimaterial/model_and_adjoint.i)
# Steady state Heat conduction in a 2D domain with two diffusivities
# The domain is -4 <= x <= 4 and -4 <= y <= 4
# The top-half of the domain (y > 0) has high diffusivity
# The bottom-half of the domain (y < 0) has low diffusivity
[Mesh]
[gmg]
type = GeneratedMeshGenerator
dim = 2
nx = 16
ny = 16
xmin = -4
xmax = 4
ymin = -4
ymax = 4
[]
[]
[Problem]
nl_sys_names = 'nl0 adjoint'
kernel_coverage_check = false
[]
[Variables]
[temperature]
[]
[temperature_adjoint]
solver_sys = adjoint
[]
[]
[Kernels]
[heat_conduction]
type = MatDiffusion
variable = temperature
diffusivity = diffusivity
[]
[heat_source]
type = BodyForce
value = 100
variable = temperature
[]
[]
[BCs]
[bottom]
type = DirichletBC
variable = temperature
boundary = bottom
value = 0
[]
[]
[Functions]
[diffusivity_function]
type = NearestReporterCoordinatesFunction
x_coord_name = data/coordx
y_coord_name = data/coordy
value_name = data/diffusivity
[]
[]
[Materials]
[mat]
type = GenericFunctionMaterial
prop_names = diffusivity
prop_values = diffusivity_function
[]
[]
[DiracKernels]
[pt]
type = ReporterPointSource
variable = temperature_adjoint
x_coord_name = measure_data/measurement_xcoord
y_coord_name = measure_data/measurement_ycoord
z_coord_name = measure_data/measurement_zcoord
value_name = measure_data/misfit_values
[]
[]
[Reporters]
[measure_data]
type = OptimizationData
objective_name = objective_value
variable = temperature
[]
[data]
type = ConstantReporter
real_vector_names = 'coordx coordy diffusivity'
real_vector_values = '0 0; -2 2; 5 10'
[]
[]
[VectorPostprocessors]
[gradvec]
type = ElementOptimizationDiffusionCoefFunctionInnerProduct
variable = temperature_adjoint
forward_variable = temperature
function = diffusivity_function
execute_on = ADJOINT_TIMESTEP_END
[]
[]
[Executioner]
type = SteadyAndAdjoint
forward_system = nl0
adjoint_system = adjoint
petsc_options_iname = '-pc_type'
petsc_options_value = 'lu'
nl_forced_its = 1
line_search = none
nl_abs_tol = 1e-8
[]
[Outputs]
console = false
[]
(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
objective_name = objective_value
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
[]
[]
(modules/optimization/test/tests/vectorpostprocessors/adjoint_strain_batch_stress_grad_inner_product/strain_stress_grad_inner_product.i)
[Mesh]
[gmg]
type = GeneratedMeshGenerator
dim = 2
nx = 4
ny = 4
[]
[]
[Variables]
[v]
initial_condition = 1
[]
[]
[Kernels]
[null]
type = NullKernel
variable = v
[]
[]
[UserObjects]
[batch_deriv]
type = BatchPropertyDerivativeRankTwoTensorReal
material_property = number
[]
# assign value using the following object
[batch]
type = OptimizationBatchPropertyDerivativeTest
batch_deriv_uo = batch_deriv
prop = tensor
execute_on = 'LINEAR'
[]
[]
[Materials]
[prop1]
type = GenericConstantRankTwoTensor
tensor_name = tensor
tensor_values = '1 6 5 6 2 4 5 4 3'
[]
[prop2]
type = GenericFunctionMaterial
prop_names = number
prop_values = '1.0'
[]
[prop3]
type = GenericConstantRankTwoTensor
tensor_name = dummy_strain
tensor_values = '10 11 12 13 14 15 16 17 18'
[]
[]
[Functions]
[fcn]
type = NearestReporterCoordinatesFunction
x_coord_name = param/coordx
y_coord_name = param/coordy
value_name = param/value
[]
[]
[Reporters]
[param]
type = ConstantReporter
real_vector_names = 'coordx coordy value'
real_vector_values = '0 0.5 1; 0 0.5 1; 1.0 2.0 3.0'
outputs = none
[]
[]
[VectorPostprocessors]
[inner_product]
type = AdjointStrainBatchStressGradInnerProduct
adjoint_strain_name = dummy_strain
stress_derivative = batch_deriv
function = fcn
variable = v
[]
[]
[Executioner]
type = Transient
dt = 0.1
end_time = 0.1
[]
[Outputs]
csv = true
execute_on = final
[]
(modules/optimization/examples/simpleTransient/forward.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 = TimeDerivative
variable = u
[]
[diff]
type = Diffusion
variable = u
[]
[src]
type = BodyForce
variable = u
function = source
[]
[]
[BCs]
[dirichlet]
type = DirichletBC
variable = u
boundary = 'left right top bottom'
value = 0
[]
[]
[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 = Transient
num_steps = 100
end_time = 1
solve_type = NEWTON
petsc_options_iname = '-pc_type'
petsc_options_value = 'lu'
reuse_preconditioner = true
reuse_preconditioner_max_linear_its = 50
[]
[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
objective_name = objective_value
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
[]
(modules/optimization/test/tests/vectorpostprocessors/element_source_inner_product/element_source_inner_product.i)
[Mesh]
[gmg]
type = GeneratedMeshGenerator
dim = 3
nx = 4
ny = 4
nz = 4
[]
[]
[AuxVariables]
[u]
initial_condition = 1
[]
[]
[AuxKernels]
[u_val]
type = ParsedAux
variable = u
use_xyzt = true
function = 't'
[]
[]
[Functions]
[xyzt]
type = NearestReporterCoordinatesFunction
x_coord_name = 'values4D/coordx'
y_coord_name = 'values4D/coordy'
z_coord_name = 'values4D/coordz'
time_name = 'values4D/time'
value_name = 'values4D/value'
[]
[]
[Reporters]
[values4D]
type = ConstantReporter
real_vector_names = 'coordx coordy coordz time value'
real_vector_values = '0.25 0.75 0.25 0.75 0.25 0.75 0.25 0.75
0.25 0.75 0.25 0.75 0.25 0.75 0.25 0.75
0.25 0.75 0.25 0.75 0.25 0.75 0.25 0.75;
0.25 0.25 0.75 0.75 0.25 0.25 0.75 0.75
0.25 0.25 0.75 0.75 0.25 0.25 0.75 0.75
0.25 0.25 0.75 0.75 0.25 0.25 0.75 0.75;
0.25 0.25 0.25 0.25 0.75 0.75 0.75 0.75
0.25 0.25 0.25 0.25 0.75 0.75 0.75 0.75
0.25 0.25 0.25 0.25 0.75 0.75 0.75 0.75;
0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
0.50 0.50 0.50 0.50 0.50 0.50 0.50 0.50
1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00;
0.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00
8.00 9.00 10.0 11.0 12.0 13.0 14.0 15.0
16.0 17.0 18.0 19.0 20.0 21.0 22.0 23.0'
outputs = none
[]
[]
[VectorPostprocessors]
[inner_product]
type = ElementOptimizationSourceFunctionInnerProduct
variable = u
function = xyzt
execute_on = 'initial timestep_end'
[]
[]
[Problem]
solve = false
kernel_coverage_check = false
skip_nl_system_check = true
[]
[Executioner]
type = Transient
dt = 0.1
end_time = 1
[]
[Outputs]
csv = true
execute_on = final
[]
(modules/optimization/examples/materialFrequency/wave1D/model_grad.i)
id = 1
frequencyHz = 1.0
omega = '${fparse 2*3.14159265359*frequencyHz}'
[Problem]
nl_sys_names = 'nl0 adjoint'
kernel_coverage_check = false
skip_nl_system_check = true
[]
[Executioner]
type = SteadyAndAdjoint
forward_system = nl0
adjoint_system = adjoint
petsc_options_iname = '-pc_type'
petsc_options_value = 'lu'
nl_forced_its = 1
line_search = none
nl_abs_tol = 1e-8
[]
[Outputs]
csv = false
console = false
json = false
[]
[Mesh]
type = GeneratedMesh
dim = 1
nx = 200
xmax = 2
[]
[Variables]
[ur]
[]
[ui]
[]
[uradj]
initial_condition = 0
solver_sys = adjoint
[]
[uiadj]
initial_condition = 0
solver_sys = adjoint
[]
[]
[Kernels]
[stiff]
type = MatDiffusion
variable = ur
diffusivity = G
[]
[mass]
type = Reaction
variable = ur
rate = '${fparse -1.0*omega*omega}'
[]
[stiffV]
type = MatDiffusion
variable = ui
diffusivity = G
[]
[massV]
type = Reaction
variable = ui
rate = '${fparse -1.0*omega*omega}'
[]
[]
[BCs]
[leftU]
type = CoupledVarNeumannBC
boundary = left
variable = ur
coef = 2.0
v = ui
[]
[leftV]
type = CoupledVarNeumannBC
boundary = left
variable = ui
coef = -2.0
v = ur
[]
[right]
type = NeumannBC
variable = ur
boundary = right
value = 1
[]
[]
[Materials]
[G]
type = GenericFunctionMaterial
prop_names = G
prop_values = G_function
[]
[]
[Functions]
[G_function]
type = NearestReporterCoordinatesFunction
x_coord_name = parameters/coordx
value_name = parameters/G
[]
[]
[Reporters]
[parameters]
type = ConstantReporter
real_vector_names = 'coordx G'
# 'True value when used to generate synthetic data'
# real_vector_values = '5.0 15.0; 4.0 4.0'
real_vector_values = '1.0; 4.0'
[]
[]
[DiracKernels]
[misfit_ur]
type = ReporterPointSource
variable = uradj
x_coord_name = measure_data_ur/measurement_xcoord
y_coord_name = measure_data_ur/measurement_ycoord
z_coord_name = measure_data_ur/measurement_zcoord
value_name = measure_data_ur/misfit_values
[]
[misfit_ui]
type = ReporterPointSource
variable = uiadj
x_coord_name = measure_data_ui/measurement_xcoord
y_coord_name = measure_data_ui/measurement_ycoord
z_coord_name = measure_data_ui/measurement_zcoord
value_name = measure_data_ui/misfit_values
[]
[]
[VectorPostprocessors]
[gradient_from_real]
type = ElementOptimizationDiffusionCoefFunctionInnerProduct
variable = uradj
forward_variable = ur
function = G_function
execute_on = ADJOINT_TIMESTEP_END
# Just to confirm this happens BEFORE the gradient calcutions
execution_order_group = -1
[]
[gradient_from_imag]
type = ElementOptimizationDiffusionCoefFunctionInnerProduct
variable = uiadj
forward_variable = ui
function = G_function
execute_on = ADJOINT_TIMESTEP_END
# Just to confirm this happens BEFORE the gradient calcutions
execution_order_group = -1
[]
[]
[Reporters]
[measure_data_ur]
type = OptimizationData
objective_name = obj_val
variable = 'ur'
file_value = 'value'
measurement_file = 'measurement/frequency_ur_${id}.csv'
[]
[measure_data_ui]
type = OptimizationData
objective_name = obj_val
variable = 'ui'
file_value = 'value'
measurement_file = 'measurement/frequency_ui_${id}.csv'
[]
[gradient]
type = ParsedVectorReporter
name = gradient
reporter_names = 'gradient_from_real/inner_product gradient_from_imag/inner_product'
reporter_symbols = 'a b'
expression = 'a+b'
execute_on = ADJOINT_TIMESTEP_END
execution_order_group = 0
[]
[objective]
type = ParsedScalarReporter
name = objective
reporter_names = 'measure_data_ur/obj_val measure_data_ui/obj_val'
reporter_symbols = 'a b'
expression = 'a+b'
execute_on = ADJOINT_TIMESTEP_END
# Just to confirm this happens after the gradient calcutions
execution_order_group = 1
[]
[]
(modules/combined/test/tests/optimization/invOpt_elasticity_modular/grad.i)
[Mesh]
displacements = 'ux uy'
[gmg]
type = GeneratedMeshGenerator
dim = 2
nx = 11
ny = 11
xmin = -4
xmax = 4
ymin = -4
ymax = 4
[]
[]
[Variables]
# adjoint
[ux]
[]
[uy]
[]
[]
[AuxVariables]
[dummy]
[]
[T]
[]
# displacement variables to be transferred from the forward app
# we use them to compute stress and stress derivative wrt E
[state_x]
[]
[state_y]
[]
[]
[DiracKernels]
[misfit_is_adjoint_force]
type = ReporterPointSource
variable = ux
x_coord_name = misfit/measurement_xcoord
y_coord_name = misfit/measurement_ycoord
z_coord_name = misfit/measurement_zcoord
value_name = misfit/misfit_values
[]
[]
[Physics]
[SolidMechanics]
[QuasiStatic]
[all]
strain = SMALL
new_system = true
add_variables = true
formulation = TOTAL
incremental = true
volumetric_locking_correction = false
displacements = 'ux uy'
# add base name to distinguish between forward and adjoint
# the total lagrangian formulation does not add base_name correctly without setting both, which should be improved
base_name = 'adjoint'
strain_base_name = 'adjoint'
[]
displacements = 'ux uy'
[]
[]
[]
[BCs]
[bottom_ux]
type = DirichletBC
variable = ux
boundary = bottom
value = 0.0
[]
[bottom_uy]
type = DirichletBC
variable = uy
boundary = bottom
value = 0.0
[]
[]
[NEML2]
# two elasticity models are listed inside "elasticity.i" for forward and adjoint, respectively
input = 'elasticity.i'
model = 'adjoint_elasticity_model'
verbose = false
temperature = 'T'
mode = PARSE_ONLY
device = 'cpu'
enable_AD = true
[]
[UserObjects]
[gather_E]
type = MOOSERealMaterialToNEML2Parameter
moose_material_property = E_material
neml2_parameter = E
execute_on = 'INITIAL TIMESTEP_BEGIN'
[]
# forward model
[forward_input_strain]
type = MOOSERankTwoTensorMaterialPropertyToNEML2
moose_material_property = forward_mechanical_strain
neml2_variable = forces/E
[]
[forward_model]
type = ExecuteNEML2Model
model = 'forward_elasticity_model'
# add other gatherers here if needed
enable_AD = true
gather_uos = 'forward_input_strain'
gather_param_uos = 'gather_E'
[]
# adjoint model
[adjoint_input_strain]
type = MOOSERankTwoTensorMaterialPropertyToNEML2
moose_material_property = adjoint_mechanical_strain
neml2_variable = forces/E
[]
[adjoint_model]
type = ExecuteNEML2Model
model = 'adjoint_elasticity_model'
# add other gatherers here if needed
enable_AD = true
gather_uos = 'adjoint_input_strain'
gather_param_uos = 'gather_E'
[]
[]
[Materials]
[adjoint_stress]
type = NEML2StressToMOOSE
execute_neml2_model_uo = adjoint_model
neml2_stress_output = state/S
neml2_strain_input = forces/E
base_name = 'adjoint'
[]
[forward_strain]
type = ComputeSmallStrain
displacements = 'state_x state_y'
base_name = 'forward'
[]
[forward_dstress_dE]
type = NEML2ParameterDerivativeToSymmetricRankTwoTensorMOOSEMaterialProperty
execute_neml2_model_uo = forward_model
moose_material_property = forward_dstress_dE
neml2_variable = state/S
neml2_parameter_derivative = E # young's modulus
[]
# adjoint and forward use the same young's modulus value
[E_material]
type = GenericFunctionMaterial
prop_names = 'E_material'
prop_values = E
[]
[]
[Functions]
[E]
type = NearestReporterCoordinatesFunction
x_coord_name = parametrization/coordx
y_coord_name = parametrization/coordy
value_name = parametrization/youngs_modulus
[]
[]
[Reporters]
[measure_data]
type = OptimizationData
variable = ux
[]
[misfit]
type = OptimizationData
[]
[parametrization]
type = ConstantReporter
real_vector_names = 'coordx coordy youngs_modulus'
real_vector_values = '0 0 0; ${fparse 8/3} 0 ${fparse -8/3}; 5 5 5'
[]
[]
[VectorPostprocessors]
[grad_youngs_modulus]
type = AdjointStrainSymmetricStressGradInnerProduct
stress_derivative_name = 'forward_dstress_dE'
adjoint_strain_name = 'adjoint_mechanical_strain'
variable = dummy
function = E
[]
[]
[Executioner]
type = Steady
solve_type = NEWTON
petsc_options_iname = '-pc_type'
petsc_options_value = 'lu'
# we do not compute them together as this is overwritting DiracKernel's residual calculation, which should be improved
residual_and_jacobian_together = false
[]
[Outputs]
file_base = 'adjoint'
console = false
[]
(modules/optimization/test/tests/vectorpostprocessors/adjoint_strain_batch_stress_grad_inner_product/strain_stress_grad_inner_product_material.i)
[Mesh]
[gmg]
type = GeneratedMeshGenerator
dim = 2
nx = 4
ny = 4
[]
[]
[Variables]
[v]
initial_condition = 1
[]
[]
[Kernels]
[null]
type = NullKernel
variable = v
[]
[]
[Materials]
[prop1] # dummy stress deriv
type = GenericConstantSymmetricRankTwoTensor
tensor_name = tensor
tensor_values = '1 2 3 4 5 6'
[]
[prop2]
type = GenericConstantRankTwoTensor
tensor_name = dummy_strain
tensor_values = '10 11 12 13 14 15 16 17 18'
[]
[]
[Functions]
[fcn]
type = NearestReporterCoordinatesFunction
x_coord_name = param/coordx
y_coord_name = param/coordy
value_name = param/value
[]
[]
[Reporters]
[param]
type = ConstantReporter
real_vector_names = 'coordx coordy value'
real_vector_values = '0 0.5 1; 0 0.5 1; 1.0 2.0 3.0'
outputs = none
[]
[]
[VectorPostprocessors]
[inner_product]
type = AdjointStrainSymmetricStressGradInnerProduct
adjoint_strain_name = dummy_strain
stress_derivative_name = tensor
function = fcn
variable = v
[]
[]
[Executioner]
type = Transient
dt = 0.1
end_time = 0.1
[]
[Outputs]
csv = true
execute_on = final
[]
(modules/optimization/examples/materialTransient/forward_and_adjoint.i)
[Mesh]
[gmg]
type = GeneratedMeshGenerator
dim = 2
xmax = 1
ymax = 1
nx = 10
ny = 10
[]
[]
[Variables/u]
initial_condition = 0
[]
[Kernels]
[dt]
type = TimeDerivative
variable = u
[]
[diff]
type = MatDiffusion
variable = u
diffusivity = D
[]
[src]
type = BodyForce
variable = u
value = 1
[]
[]
[BCs]
[dirichlet]
type = DirichletBC
variable = u
boundary = 'right top'
value = 0
[]
[]
[Materials]
[diffc]
type = GenericFunctionMaterial
prop_names = 'D'
prop_values = 'diffc_fun'
output_properties = 'D'
outputs = 'exodus'
[]
[]
[Functions]
[diffc_fun]
type = NearestReporterCoordinatesFunction
value_name = 'diffc_rep/D_vals'
x_coord_name = 'diffc_rep/D_x_coord'
y_coord_name = 'diffc_rep/D_y_coord'
[]
[]
[Reporters]
[diffc_rep]
type = ConstantReporter
real_vector_names = 'D_x_coord D_y_coord D_vals'
real_vector_values = '0.25 0.75 0.25 0.75;
0.25 0.25 0.75 0.75;
1 0.2 0.2 0.05' # Reference solution
outputs = none
[]
[data]
type = OptimizationData
objective_name = objective_value
variable = u
outputs = none
[]
[]
[Postprocessors]
[D1]
type = PointValue
variable = D
point = '0.25 0.25 0'
[]
[D2]
type = PointValue
variable = D
point = '0.75 0.25 0'
[]
[D3]
type = PointValue
variable = D
point = '0.25 0.75 0'
[]
[D4]
type = PointValue
variable = D
point = '0.75 0.75 0'
[]
[]
[Executioner]
type = TransientAndAdjoint
forward_system = nl0
adjoint_system = adjoint
nl_rel_tol = 1e-8
nl_abs_tol = 1e-12
l_tol = 1e-12
dt = 0.1
num_steps = 10
[]
[Problem]
nl_sys_names = 'nl0 adjoint'
kernel_coverage_check = false
[]
[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 = ElementOptimizationDiffusionCoefFunctionInnerProduct
variable = u_adjoint
forward_variable = u
function = diffc_fun
execute_on = ADJOINT_TIMESTEP_END
outputs = none
[]
[]
[Outputs]
# The default exodus object executes only during the forward system solve,
# so the adjoint variable in the resulting file will show only 0.
# Unfortunately, there is no way to output the adjoint variable with Exodus.
exodus = true
console = false
[]
(modules/optimization/examples/materialTransient/gradient.i)
[Mesh]
[gmg]
type = GeneratedMeshGenerator
dim = 2
xmax = 1
ymax = 1
nx = 10
ny = 10
[]
[]
[Variables/u_adjoint]
initial_condition = 0
[]
[Kernels]
[dt]
type = TimeDerivative
variable = u_adjoint
[]
[diff]
type = MatDiffusion
variable = u_adjoint
diffusivity = D
[]
[]
[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
reverse_time_end = 1
[]
[]
[BCs]
[dirichlet]
type = DirichletBC
variable = u_adjoint
boundary = 'right top'
value = 0
[]
[]
[Materials]
[diffc]
type = GenericFunctionMaterial
prop_names = 'D'
prop_values = 'diffc_fun'
[]
[]
[Functions]
[diffc_fun]
type = NearestReporterCoordinatesFunction
value_name = 'diffc_rep/D_vals'
x_coord_name = 'diffc_rep/D_x_coord'
y_coord_name = 'diffc_rep/D_y_coord'
[]
[]
[Reporters]
[diffc_rep]
type = ConstantReporter
real_vector_names = 'D_x_coord D_y_coord D_vals'
real_vector_values = '0.25 0.75 0.25 0.75;
0.25 0.25 0.75 0.75;
0.1 10 10 0.1' # Reference solution
outputs = none
[]
[data]
type = OptimizationData
[]
[]
[AuxVariables/u]
[]
[UserObjects]
[load_u]
type = AdjointSolutionUserObject
mesh = forward_out.e
system_variables = 'u'
reverse_time_end = 1
execute_on = 'timestep_begin'
[]
[]
[AuxKernels]
[u_aux]
type = SolutionAux
variable = u
solution = load_u
direct = true
execute_on = 'timestep_begin'
[]
[]
[VectorPostprocessors]
[adjoint]
type = ElementOptimizationDiffusionCoefFunctionInnerProduct
variable = u_adjoint
forward_variable = u
function = diffc_fun
reverse_time_end = 1
[]
[]
[Executioner]
type = Transient
solve_type = NEWTON
nl_rel_tol = 1e-8
nl_abs_tol = 1e-12
dt = 0.1
num_steps = 10
[]