- objective_nameName of reporter value defining the objective.
C++ Type:ReporterValueName
Controllable:No
Description:Name of reporter value defining the objective.
- variableVector of variable names to sample at measurement points.
C++ Type:std::vector<VariableName>
Unit:(no unit assumed)
Controllable:No
Description:Vector of variable names to sample at measurement points.
- variable_weight_namesVector of weight reporter names that will create a reporter to transfer weights into. The ordering of these weight reporter names corresponds to the ordering used in variable.
C++ Type:std::vector<std::string>
Controllable:No
Description:Vector of weight reporter names that will create a reporter to transfer weights into. The ordering of these weight reporter names corresponds to the ordering used in variable.
OptimizationData
Reporter to hold measurement and simulation data for optimization problems
Overview
OptimizationData
is a reporter typically used for storing measurement data in a inverse optimization simulation. This reporter creates the following vectors:
measurement_xcoord
measurement_ycoord
measurement_zcoord
measurement_time
measurement_values
simulation_values
misfit_values
The measurement_
vectors can be filled in using "measurement_values", "measurement_points", and "measurement_times" or with a CSV file using "measurement_file", "file_xcoord", "file_ycoord", "file_zcoord", "file_value", and "file_time". The simulation_values
and misfit_values
are calculated in this object if "variable" is specified and the measurement location and values are filled. See OptimizationData for more information on these input parameters and what the vectors mean.
For cases where more than one variable is being sampled, the contribution of each sampled variable to the measurement value are specified by weights in csv file input using "file_variable_weights". These weights are then multiplied by each variable in the forward problem by specifying "variable_weight_names". There must be one "variable_weight_names" per "variable" being sampled and their ordering must be the same. A typical use case for this would be to specify "file_variable_weights" in the main optimization application input file to be read in along with the other parameters normally read from file. Next, these reporter weights would be transferred to the forward and adjoint problem subapps. In the forward subapp, "file_variable_weights" and "variable" would both be specified in the OptimizationData
block and would weight the different variable contributions to the simulation_values
and misfit_values
. In the adjoint subapp, the weights are transferred into a reporter that is used to scale the misfit applied by the ReporterPointSource using "weight_name".
If the "objective_name" is set by the user OptimizationData
will create and store the L2 Norm of the misfit values divided by two. This can be useful for running an inverse optimization problem with the GeneralOptimization reporter.
Example Input File Syntax
OptimizationData
is typically used in the forward and homogeneous optimization sub-applications to sample the solution for simulation_values
, calculating misfit_values
, and storing the objective value provided by objective_name
. The measurement data can either be specified directly on each subapp or transferred from the optimization main application which would also require the simulation and misfit values to be transferred back to the main application. OptimizationData
is also used in the adjoint/gradient sub-application to hold the misfit values to apply the ReporterPointSource Dirac kernel. The following code blocks demonstrate this utilization of OptimizationData
. The OptimizationData in the main application reads the measurement locations and values. A MultiAppReporterTransfer transfers the measurement data to the forward, adjoint/gradient, and homogeneous application within the OptimizationData
reporter declared in those inputs. The forward and homogeneous applications then sample the specified vector specified in "variable". The main application then receives the simulation data using a MultiAppReporterTransfer, which OptimizationReporter uses to calculate the misfit and transfer to the adjoint/gradient sub-application, which uses that data to apply the ReporterPointSource kernel.
[OptimizationReporter<<<{"href": "../../syntax/OptimizationReporter/index.html"}>>>]
type = GeneralOptimization
objective_name = objective_value
parameter_names = 'parameter_results'
num_values = '3'
[]
[Transfers<<<{"href": "../../syntax/Transfers/index.html"}>>>]
# FORWARD transfers
[toForward_measument]
type = MultiAppReporterTransfer<<<{"description": "Transfers reporter data between two applications.", "href": "../transfers/MultiAppReporterTransfer.html"}>>>
to_multi_app<<<{"description": "The name of the MultiApp to transfer the data to"}>>> = forward
from_reporters<<<{"description": "List of the reporter names (object_name/value_name) to transfer the value from."}>>> = 'main/measurement_xcoord
main/measurement_ycoord
main/measurement_zcoord
main/measurement_time
main/measurement_values
OptimizationReporter/parameter_results'
to_reporters<<<{"description": "List of the reporter names (object_name/value_name) to transfer the value to."}>>> = 'measure_data/measurement_xcoord
measure_data/measurement_ycoord
measure_data/measurement_zcoord
measure_data/measurement_time
measure_data/measurement_values
point_source/value'
[]
[fromForward]
type = MultiAppReporterTransfer<<<{"description": "Transfers reporter data between two applications.", "href": "../transfers/MultiAppReporterTransfer.html"}>>>
from_multi_app<<<{"description": "The name of the MultiApp to receive data from"}>>> = forward
# Note: We are transferring the misfit values into main misfit
from_reporters<<<{"description": "List of the reporter names (object_name/value_name) to transfer the value from."}>>> = 'measure_data/objective_value measure_data/misfit_values'
to_reporters<<<{"description": "List of the reporter names (object_name/value_name) to transfer the value to."}>>> = 'OptimizationReporter/objective_value main/misfit_values'
[]
# ADJOINT transfers
#NOTE: the adjoint variable we are transferring is actually the gradient
[toAdjoint]
type = MultiAppReporterTransfer<<<{"description": "Transfers reporter data between two applications.", "href": "../transfers/MultiAppReporterTransfer.html"}>>>
to_multi_app<<<{"description": "The name of the MultiApp to transfer the data to"}>>> = adjoint
from_reporters<<<{"description": "List of the reporter names (object_name/value_name) to transfer the value from."}>>> = 'main/measurement_xcoord
main/measurement_ycoord
main/measurement_zcoord
main/measurement_time
main/misfit_values'
to_reporters<<<{"description": "List of the reporter names (object_name/value_name) to transfer the value to."}>>> = 'misfit/measurement_xcoord
misfit/measurement_ycoord
misfit/measurement_zcoord
misfit/measurement_time
misfit/misfit_values'
[]
[fromAdjoint]
type = MultiAppReporterTransfer<<<{"description": "Transfers reporter data between two applications.", "href": "../transfers/MultiAppReporterTransfer.html"}>>>
from_multi_app<<<{"description": "The name of the MultiApp to receive data from"}>>> = adjoint
from_reporters<<<{"description": "List of the reporter names (object_name/value_name) to transfer the value from."}>>> = 'gradient/adjoint'
to_reporters<<<{"description": "List of the reporter names (object_name/value_name) to transfer the value to."}>>> = 'OptimizationReporter/grad_parameter_results'
[]
# HESSIAN transfers. Same as forward.
[toHomoForward]
type = MultiAppReporterTransfer<<<{"description": "Transfers reporter data between two applications.", "href": "../transfers/MultiAppReporterTransfer.html"}>>>
multi_app<<<{"description": "The name of the MultiApp to transfer data with"}>>> = homogeneousForward
direction<<<{"description": "Whether this Transfer will be 'to' or 'from' a MultiApp, or bidirectional, by providing both FROM_MULTIAPP and TO_MULTIAPP."}>>> = to_multiapp
from_reporters<<<{"description": "List of the reporter names (object_name/value_name) to transfer the value from."}>>> = 'main/measurement_xcoord
main/measurement_ycoord
main/measurement_zcoord
main/measurement_time
main/measurement_values
OptimizationReporter/parameter_results'
to_reporters<<<{"description": "List of the reporter names (object_name/value_name) to transfer the value to."}>>> = 'measure_data/measurement_xcoord
measure_data/measurement_ycoord
measure_data/measurement_zcoord
measure_data/measurement_time
measure_data/measurement_values
point_source/value'
[]
[fromHomoForward]
type = MultiAppReporterTransfer<<<{"description": "Transfers reporter data between two applications.", "href": "../transfers/MultiAppReporterTransfer.html"}>>>
multi_app<<<{"description": "The name of the MultiApp to transfer data with"}>>> = homogeneousForward
direction<<<{"description": "Whether this Transfer will be 'to' or 'from' a MultiApp, or bidirectional, by providing both FROM_MULTIAPP and TO_MULTIAPP."}>>> = from_multiapp
# Note: We are transferring the simulation values into misfit
# this has to be done when using general opt and homogenous forward.
from_reporters<<<{"description": "List of the reporter names (object_name/value_name) to transfer the value from."}>>> = 'measure_data/simulation_values'
to_reporters<<<{"description": "List of the reporter names (object_name/value_name) to transfer the value to."}>>> = 'main/misfit_values'
[]
[]
(modules/optimization/test/tests/optimizationreporter/point_loads/main.i)[Reporters<<<{"href": "../../syntax/Reporters/index.html"}>>>]
[measure_data]
type = OptimizationData<<<{"description": "Reporter to hold measurement and simulation data for optimization problems", "href": "OptimizationData.html"}>>>
objective_name<<<{"description": "Name of reporter value defining the objective."}>>> = objective_value
variable<<<{"description": "Vector of variable names to sample at measurement points."}>>> = temperature
[]
[]
(modules/optimization/test/tests/optimizationreporter/point_loads/forward.i)[Reporters<<<{"href": "../../syntax/Reporters/index.html"}>>>]
[measure_data]
type = OptimizationData<<<{"description": "Reporter to hold measurement and simulation data for optimization problems", "href": "OptimizationData.html"}>>>
variable<<<{"description": "Vector of variable names to sample at measurement points."}>>> = temperature
[]
[]
(modules/optimization/test/tests/optimizationreporter/point_loads/forward_homogeneous.i)[Reporters<<<{"href": "../../syntax/Reporters/index.html"}>>>]
[misfit]
type = OptimizationData<<<{"description": "Reporter to hold measurement and simulation data for optimization problems", "href": "OptimizationData.html"}>>>
[]
[]
[DiracKernels<<<{"href": "../../syntax/DiracKernels/index.html"}>>>]
[pt]
type = ReporterPointSource<<<{"description": "Apply a point load defined by Reporter.", "href": "../dirackernels/ReporterPointSource.html"}>>>
variable<<<{"description": "The name of the variable that this residual object operates on"}>>> = adjoint
x_coord_name<<<{"description": "reporter x-coordinate name. This uses the reporter syntax <reporter>/<name>."}>>> = misfit/measurement_xcoord
y_coord_name<<<{"description": "reporter y-coordinate name. This uses the reporter syntax <reporter>/<name>."}>>> = misfit/measurement_ycoord
z_coord_name<<<{"description": "reporter z-coordinate name. This uses the reporter syntax <reporter>/<name>."}>>> = misfit/measurement_zcoord
value_name<<<{"description": "reporter value name. This uses the reporter syntax <reporter>/<name>."}>>> = misfit/misfit_values
extra_vector_tags<<<{"description": "The extra tags for the vectors this Kernel should fill"}>>> = 'ref'
[]
[]
(modules/optimization/test/tests/optimizationreporter/point_loads/adjoint.i)Input Parameters
- allow_duplicate_execution_on_initialFalseIn the case where this UserObject is depended upon by an initial condition, allow it to be executed twice during the initial setup (once before the IC and again after mesh adaptivity (if applicable).
Default:False
C++ Type:bool
Controllable:No
Description:In the case where this UserObject is depended upon by an initial condition, allow it to be executed twice during the initial setup (once before the IC and again after mesh adaptivity (if applicable).
- execute_onTIMESTEP_ENDThe list of flag(s) indicating when this object should be executed. For a description of each flag, see https://mooseframework.inl.gov/source/interfaces/SetupInterface.html.
Default:TIMESTEP_END
C++ Type:ExecFlagEnum
Options:XFEM_MARK, FORWARD, ADJOINT, HOMOGENEOUS_FORWARD, ADJOINT_TIMESTEP_BEGIN, ADJOINT_TIMESTEP_END, NONE, INITIAL, LINEAR, LINEAR_CONVERGENCE, NONLINEAR, NONLINEAR_CONVERGENCE, POSTCHECK, TIMESTEP_END, TIMESTEP_BEGIN, MULTIAPP_FIXED_POINT_END, MULTIAPP_FIXED_POINT_BEGIN, MULTIAPP_FIXED_POINT_CONVERGENCE, FINAL, CUSTOM
Controllable:No
Description:The list of flag(s) indicating when this object should be executed. For a description of each flag, see https://mooseframework.inl.gov/source/interfaces/SetupInterface.html.
- execution_order_group0Execution order groups are executed in increasing order (e.g., the lowest number is executed first). Note that negative group numbers may be used to execute groups before the default (0) group. Please refer to the user object documentation for ordering of user object execution within a group.
Default:0
C++ Type:int
Controllable:No
Description:Execution order groups are executed in increasing order (e.g., the lowest number is executed first). Note that negative group numbers may be used to execute groups before the default (0) group. Please refer to the user object documentation for ordering of user object execution within a group.
- force_postauxFalseForces the UserObject to be executed in POSTAUX
Default:False
C++ Type:bool
Controllable:No
Description:Forces the UserObject to be executed in POSTAUX
- force_preauxFalseForces the UserObject to be executed in PREAUX
Default:False
C++ Type:bool
Controllable:No
Description:Forces the UserObject to be executed in PREAUX
- force_preicFalseForces the UserObject to be executed in PREIC during initial setup
Default:False
C++ Type:bool
Controllable:No
Description:Forces the UserObject to be executed in PREIC during initial setup
Execution Scheduling Parameters
- control_tagsAdds user-defined labels for accessing object parameters via control logic.
C++ Type:std::vector<std::string>
Controllable:No
Description:Adds user-defined labels for accessing object parameters via control logic.
- enableTrueSet the enabled status of the MooseObject.
Default:True
C++ Type:bool
Controllable:Yes
Description:Set the enabled status of the MooseObject.
- outputsVector of output names where you would like to restrict the output of variables(s) associated with this object
C++ Type:std::vector<OutputName>
Controllable:No
Description:Vector of output names where you would like to restrict the output of variables(s) associated with this object
- 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
- file_timetimetime column name from csv file being read in.
Default:time
C++ Type:std::string
Controllable:No
Description:time column name from csv file being read in.
- file_valuevaluemeasurement value column name from csv file being read in.
Default:value
C++ Type:std::string
Controllable:No
Description:measurement value column name from csv file being read in.
- file_variable_weightsvariable weight column names from csv file being read in.
C++ Type:std::vector<std::string>
Controllable:No
Description:variable weight column names from csv file being read in.
- file_xcoordxx coordinate column name from measurement_file csv being read in.
Default:x
C++ Type:std::string
Controllable:No
Description:x coordinate column name from measurement_file csv being read in.
- file_ycoordyy coordinate column name from csv file being read in.
Default:y
C++ Type:std::string
Controllable:No
Description:y coordinate column name from csv file being read in.
- file_zcoordzz coordinate column name from csv file being read in.
Default:z
C++ Type:std::string
Controllable:No
Description:z coordinate column name from csv file being read in.
- measurement_fileCSV file with measurement value and coordinates (value, x, y, z).
C++ Type:FileName
Controllable:No
Description:CSV file with measurement value and coordinates (value, x, y, z).
File Measurement Data Parameters
- measurement_pointsPoint locations corresponding to each measurement value
C++ Type:std::vector<libMesh::Point>
Controllable:No
Description:Point locations corresponding to each measurement value
- measurement_timesTimes corresponding to each measurement value
C++ Type:std::vector<double>
Unit:(no unit assumed)
Controllable:No
Description:Times corresponding to each measurement value
- measurement_valuesMeasurement values collected from locations given by measurement_points
C++ Type:std::vector<double>
Unit:(no unit assumed)
Controllable:No
Description:Measurement values collected from locations given by measurement_points
Input Measurement Data Parameters
- 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
Unit:(no unit assumed)
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.
Material Property Retrieval Parameters
Input Files
- (modules/optimization/test/tests/optimizationreporter/bimaterial/grad.i)
- (modules/optimization/test/tests/optimizationreporter/constant_heat_source/main_nonLinear.i)
- (modules/optimization/examples/materialTransient/optimize_nograd.i)
- (modules/optimization/test/tests/optimizationreporter/mesh_source/main_linearRestart.i)
- (modules/combined/test/tests/optimization/invOpt_mechanics/forward_and_adjoint.i)
- (modules/optimization/test/tests/optimizationreporter/point_loads/main_auto_adjoint.i)
- (modules/combined/test/tests/optimization/invOpt_nonlinear/main.i)
- (modules/optimization/test/tests/optimizationreporter/general_opt/point_loads_gen_opt/forward_and_adjoint_transfer_data.i)
- (modules/optimization/examples/simpleTransient/adjoint_mesh.i)
- (modules/combined/test/tests/optimization/invOpt_bc_convective/forward.i)
- (modules/optimization/examples/simpleTransient/main_gradient.i)
- (modules/combined/test/tests/optimization/invOpt_elasticity_modular/forward.i)
- (modules/optimization/test/tests/optimizationreporter/function_misfit/forward_and_adjoint.i)
- (modules/optimization/test/tests/optimizationreporter/function_misfit/main_auto_side.i)
- (modules/combined/test/tests/optimization/invOpt_nonlinear/forward.i)
- (modules/optimization/test/tests/optimizationreporter/point_loads/adjoint.i)
- (modules/optimization/test/tests/optimizationreporter/general_opt/point_loads_gen_opt/forward.i)
- (modules/optimization/test/tests/executioners/constrained/inequality/forward_and_adjoint.i)
- (modules/optimization/test/tests/outputs/exodus_optimization_steady/forward.i)
- (modules/optimization/test/tests/optimizationreporter/material/adjoint.i)
- (modules/optimization/test/tests/misc/scaling_test/forward_and_adjoint.i)
- (modules/optimization/test/tests/optimizationreporter/constant_heat_source/forward_nonLinear.i)
- (modules/optimization/test/tests/optimizationreporter/bc_load_linearFunction/forward_and_adjoint.i)
- (modules/optimization/test/tests/outputs/exodus_optimization_steady/main.i)
- (modules/optimization/examples/simpleTransient/adjoint.i)
- (modules/optimization/examples/materialTransient/forward.i)
- (modules/optimization/test/tests/optimizationreporter/mesh_source/forward.i)
- (modules/optimization/test/tests/optimizationreporter/general_opt/point_loads_gen_opt/forward_homogeneous.i)
- (modules/optimization/test/tests/executioners/constrained/inequality/main_auto_adjoint.i)
- (modules/optimization/examples/diffusion_reaction_XYDelaunay/forward_and_adjoint.i)
- (modules/optimization/test/tests/outputs/exodus_optimization_steady/main_auto_adjoint.i)
- (modules/optimization/examples/simpleTransient/forward_and_adjoint.i)
- (modules/optimization/test/tests/optimizationreporter/point_loads/forward_and_adjoint.i)
- (modules/optimization/test/tests/optimizationreporter/bc_load_linearFunction/adjoint.i)
- (modules/optimization/test/tests/optimizationreporter/mesh_source/main.i)
- (modules/optimization/test/tests/optimizationreporter/function_misfit/forward_and_adjoint_side.i)
- (modules/optimization/test/tests/optimizationreporter/point_loads/main.i)
- (modules/combined/test/tests/optimization/invOpt_mechanics/forward.i)
- (modules/optimization/test/tests/optimizationreporter/mesh_source/adjoint.i)
- (modules/optimization/test/tests/optimizationreporter/general_opt/point_loads_gen_opt/main_auto_adjoint_transfer_data.i)
- (modules/optimization/test/tests/optimizationreporter/point_loads/forward_homogeneous.i)
- (modules/optimization/test/tests/optimizationreporter/bimaterial/main_auto_adjoint.i)
- (modules/optimization/test/tests/optimizationreporter/point_loads/forward.i)
- (modules/combined/test/tests/optimization/invOpt_bc_convective/adjoint.i)
- (modules/optimization/test/tests/optimizationreporter/constant_heat_source/adjoint_nonLinear.i)
- (modules/optimization/examples/materialTransient/forward_and_adjoint.i)
- (modules/combined/test/tests/optimization/invOpt_nonlinear/homogeneous_forward.i)
- (modules/optimization/test/tests/optimizationreporter/constant_heat_source/forward.i)
- (modules/optimization/test/tests/optimizationreporter/material/forward.i)
- (modules/optimization/test/tests/optimizationreporter/nonlinear_material/main.i)
- (modules/optimization/test/tests/optimizationreporter/bimaterial/model.i)
- (modules/optimization/examples/materialFrequency/wave1D/model_grad.i)
- (modules/optimization/test/tests/optimizationreporter/bimaterial/model_and_adjoint.i)
- (modules/optimization/test/tests/outputs/exodus_optimization_steady/adjoint_iteration_output.i)
- (modules/optimization/examples/simpleTransient/main_mesh.i)
- (modules/optimization/test/tests/optimizationreporter/material/main.i)
- (modules/optimization/test/tests/optimizationreporter/bc_load_linearFunction/main.i)
- (modules/optimization/test/tests/optimizationreporter/bimaterial/main.i)
- (modules/optimization/test/tests/optimizationreporter/mesh_source/main_auto_adjoint.i)
- (modules/optimization/examples/materialTransient/optimize_grad.i)
- (modules/combined/test/tests/optimization/invOpt_mechanics/adjoint.i)
- (modules/optimization/test/tests/optimizationreporter/constant_heat_source/adjoint.i)
- (modules/combined/test/tests/optimization/invOpt_bc_convective/main.i)
- (modules/optimization/test/tests/optimizationreporter/material/adjoint_explicit.i)
- (modules/optimization/test/tests/optimizationreporter/general_opt/point_loads_gen_opt/main_auto_adjoint.i)
- (modules/combined/test/tests/optimization/invOpt_elasticity_modular/main.i)
- (modules/optimization/test/tests/optimizationreporter/nonlinear_material/forward_and_adjoint.i)
- (modules/combined/test/tests/optimization/invOpt_nonlinear/simulation.i)
- (modules/optimization/test/tests/optimizationreporter/bc_load_linearFunction/forward.i)
- (modules/optimization/examples/simpleTransient/forward.i)
- (modules/optimization/test/tests/optimizationreporter/constant_heat_source/main.i)
- (modules/optimization/test/tests/optimizationreporter/general_opt/point_loads_gen_opt/forward_and_adjoint.i)
- (modules/optimization/test/tests/outputs/exodus_optimization_steady/forward_and_adjoint_iteration_output.i)
- (modules/combined/test/tests/optimization/invOpt_mechanics/main.i)
- (modules/optimization/test/tests/optimizationreporter/general_opt/point_loads_gen_opt/adjoint.i)
- (modules/optimization/examples/materialTransient/gradient.i)
- (modules/optimization/test/tests/optimizationreporter/general_opt/point_loads_gen_opt/main_separate_multiapps.i)
- (modules/optimization/examples/simpleTransient/forward_mesh.i)
- (modules/optimization/examples/diffusion_reaction/forward_and_adjoint.i)
- (modules/optimization/examples/simpleTransient/nonlinear_forward_and_adjoint.i)
- (modules/optimization/examples/diffusion_reaction/optimize.i)
- (modules/optimization/test/tests/optimizationreporter/mesh_source/forward_and_adjoint.i)
- (modules/combined/test/tests/optimization/invOpt_nonlinear/adjoint.i)
- (modules/combined/test/tests/optimization/invOpt_elasticity_modular/grad.i)
- (modules/optimization/examples/materialTransient/optimize_auto_adjoint.i)
- (modules/optimization/examples/diffusion_reaction_XYDelaunay/optimize.i)
- (modules/optimization/test/tests/optimizationreporter/optimizationdata/two_vars_file.i)
- (modules/optimization/test/tests/optimizationreporter/function_misfit/main_auto.i)
- (modules/optimization/test/tests/optimizationreporter/bc_load_linearFunction/homogeneous_forward.i)
measurement_values
C++ Type:std::vector<double>
Unit:(no unit assumed)
Controllable:No
Description:Measurement values collected from locations given by measurement_points
measurement_points
C++ Type:std::vector<libMesh::Point>
Controllable:No
Description:Point locations corresponding to each measurement value
measurement_times
C++ Type:std::vector<double>
Unit:(no unit assumed)
Controllable:No
Description:Times corresponding to each measurement value
measurement_file
C++ Type:FileName
Controllable:No
Description:CSV file with measurement value and coordinates (value, x, y, z).
file_xcoord
Default:x
C++ Type:std::string
Controllable:No
Description:x coordinate column name from measurement_file csv being read in.
file_ycoord
Default:y
C++ Type:std::string
Controllable:No
Description:y coordinate column name from csv file being read in.
file_zcoord
Default:z
C++ Type:std::string
Controllable:No
Description:z coordinate column name from csv file being read in.
file_value
Default:value
C++ Type:std::string
Controllable:No
Description:measurement value column name from csv file being read in.
file_time
Default:time
C++ Type:std::string
Controllable:No
Description:time column name from csv file being read in.
variable
C++ Type:std::vector<VariableName>
Unit:(no unit assumed)
Controllable:No
Description:Vector of variable names to sample at measurement points.
file_variable_weights
C++ Type:std::vector<std::string>
Controllable:No
Description:variable weight column names from csv file being read in.
variable_weight_names
C++ Type:std::vector<std::string>
Controllable:No
Description:Vector of weight reporter names that will create a reporter to transfer weights into. The ordering of these weight reporter names corresponds to the ordering used in variable.
variable_weight_names
C++ Type:std::vector<std::string>
Controllable:No
Description:Vector of weight reporter names that will create a reporter to transfer weights into. The ordering of these weight reporter names corresponds to the ordering used in variable.
variable
C++ Type:std::vector<VariableName>
Unit:(no unit assumed)
Controllable:No
Description:Vector of variable names to sample at measurement points.
file_variable_weights
C++ Type:std::vector<std::string>
Controllable:No
Description:variable weight column names from csv file being read in.
file_variable_weights
C++ Type:std::vector<std::string>
Controllable:No
Description:variable weight column names from csv file being read in.
variable
C++ Type:std::vector<VariableName>
Unit:(no unit assumed)
Controllable:No
Description:Vector of variable names to sample at measurement points.
weight_name
C++ Type:ReporterName
Controllable:No
Description:Name of vector-postprocessor or reporter vector containing weights to scale value, default is assumed to be all 1s.
objective_name
C++ Type:ReporterValueName
Controllable:No
Description:Name of reporter value defining the objective.
variable
C++ Type:std::vector<VariableName>
Unit:(no unit assumed)
Controllable:No
Description:Vector of variable names to sample at measurement points.
(modules/optimization/test/tests/optimizationreporter/point_loads/main.i)
# DO NOT CHANGE THIS TEST
# this test is documented as an example in forceInv_pointLoads.md
# if this test is changed, the figures will need to be updated.
measurement_points = '0.5 0.28 0
0.5 0.6 0
0.5 0.8 0
0.5 1.1 0'
measurement_values = '293 304 315 320'
[Optimization]
[]
[OptimizationReporter]
type = GeneralOptimization
objective_name = objective_value
parameter_names = 'parameter_results'
num_values = '3'
[]
[Reporters]
[main]
type = OptimizationData
measurement_points = ${measurement_points}
measurement_values = ${measurement_values}
[]
[]
[Executioner]
type = Optimize
tao_solver = taonls
petsc_options_iname = '-tao_gttol -tao_max_it -tao_nls_pc_type -tao_nls_ksp_type'
petsc_options_value = '1e-5 10 none cg'
verbose = true
[]
[MultiApps]
[forward]
type = FullSolveMultiApp
input_files = forward.i
execute_on = "FORWARD"
[]
[adjoint]
type = FullSolveMultiApp
input_files = adjoint.i
execute_on = "ADJOINT"
[]
[homogeneousForward]
type = FullSolveMultiApp
input_files = forward_homogeneous.i
execute_on = "HOMOGENEOUS_FORWARD"
[]
[]
[Transfers]
# FORWARD transfers
[toForward_measument]
type = MultiAppReporterTransfer
to_multi_app = forward
from_reporters = 'main/measurement_xcoord
main/measurement_ycoord
main/measurement_zcoord
main/measurement_time
main/measurement_values
OptimizationReporter/parameter_results'
to_reporters = 'measure_data/measurement_xcoord
measure_data/measurement_ycoord
measure_data/measurement_zcoord
measure_data/measurement_time
measure_data/measurement_values
point_source/value'
[]
[fromForward]
type = MultiAppReporterTransfer
from_multi_app = forward
# Note: We are transferring the misfit values into main misfit
from_reporters = 'measure_data/objective_value measure_data/misfit_values'
to_reporters = 'OptimizationReporter/objective_value main/misfit_values'
[]
# ADJOINT transfers
#NOTE: the adjoint variable we are transferring is actually the gradient
[toAdjoint]
type = MultiAppReporterTransfer
to_multi_app = adjoint
from_reporters = 'main/measurement_xcoord
main/measurement_ycoord
main/measurement_zcoord
main/measurement_time
main/misfit_values'
to_reporters = 'misfit/measurement_xcoord
misfit/measurement_ycoord
misfit/measurement_zcoord
misfit/measurement_time
misfit/misfit_values'
[]
[fromAdjoint]
type = MultiAppReporterTransfer
from_multi_app = adjoint
from_reporters = 'gradient/adjoint'
to_reporters = 'OptimizationReporter/grad_parameter_results'
[]
# HESSIAN transfers. Same as forward.
[toHomoForward]
type = MultiAppReporterTransfer
multi_app = homogeneousForward
direction = to_multiapp
from_reporters = 'main/measurement_xcoord
main/measurement_ycoord
main/measurement_zcoord
main/measurement_time
main/measurement_values
OptimizationReporter/parameter_results'
to_reporters = 'measure_data/measurement_xcoord
measure_data/measurement_ycoord
measure_data/measurement_zcoord
measure_data/measurement_time
measure_data/measurement_values
point_source/value'
[]
[fromHomoForward]
type = MultiAppReporterTransfer
multi_app = homogeneousForward
direction = from_multiapp
# Note: We are transferring the simulation values into misfit
# this has to be done when using general opt and homogenous forward.
from_reporters = 'measure_data/simulation_values'
to_reporters = 'main/misfit_values'
[]
[]
[Reporters]
[optInfo]
type = OptimizationInfo
[]
[]
[Outputs]
csv = true
[]
(modules/optimization/test/tests/optimizationreporter/point_loads/forward.i)
# DO NOT CHANGE THIS TEST
# this test is documented as an example in forceInv_pointLoads.md
# if this test is changed, the figures will need to be updated.
[Mesh]
[gmg]
type = GeneratedMeshGenerator
dim = 2
nx = 10
ny = 10
xmax = 1
ymax = 1.4
[]
[]
[Variables]
[temperature]
[]
[]
[Kernels]
[heat_conduction]
type = MatDiffusion
variable = temperature
diffusivity = thermal_conductivity
[]
[]
[DiracKernels]
[pt]
type = ReporterPointSource
variable = temperature
x_coord_name = 'point_source/x'
y_coord_name = 'point_source/y'
z_coord_name = 'point_source/z'
value_name = 'point_source/value'
[]
[]
[BCs]
[left]
type = DirichletBC
variable = temperature
boundary = left
value = 300
[]
[right]
type = DirichletBC
variable = temperature
boundary = right
value = 300
[]
[bottom]
type = DirichletBC
variable = temperature
boundary = bottom
value = 300
[]
[top]
type = DirichletBC
variable = temperature
boundary = top
value = 300
[]
[]
[Materials]
[steel]
type = GenericConstantMaterial
prop_names = thermal_conductivity
prop_values = 5
[]
[]
[Executioner]
type = Steady
solve_type = NEWTON
nl_abs_tol = 1e-6
nl_rel_tol = 1e-8
petsc_options_iname = '-pc_type'
petsc_options_value = 'lu'
[]
[VectorPostprocessors]
[point_source]
type = ConstantVectorPostprocessor
vector_names = 'x y z value'
value = '0.2 0.7 0.4;
0.2 0.56 1;
0 0 0;
-1000 120 500'
execute_on = LINEAR
[]
[vertical]
type = LineValueSampler
variable = 'temperature'
start_point = '0.5 0 0'
end_point = '0.5 1.4 0'
num_points = 21
sort_by = y
[]
[]
[Reporters]
[measure_data]
type = OptimizationData
objective_name = objective_value
variable = temperature
[]
[]
[Outputs]
console = false
file_base = 'forward'
[]
(modules/optimization/test/tests/optimizationreporter/point_loads/forward_homogeneous.i)
# DO NOT CHANGE THIS TEST
# this test is documented as an example in forceInv_pointLoads.md
# if this test is changed, the figures will need to be updated.
[Mesh]
[gmg]
type = GeneratedMeshGenerator
dim = 2
nx = 10
ny = 10
xmax = 1
ymax = 1.4
[]
[]
[Variables]
[temperature]
[]
[]
[Kernels]
[heat_conduction]
type = MatDiffusion
variable = temperature
diffusivity = thermal_conductivity
[]
[]
[DiracKernels]
[pt]
type = ReporterPointSource
variable = temperature
x_coord_name = 'point_source/x'
y_coord_name = 'point_source/y'
z_coord_name = 'point_source/z'
value_name = 'point_source/value'
[]
[]
[BCs]
[left]
type = DirichletBC
variable = temperature
boundary = left
value = 0
[]
[right]
type = DirichletBC
variable = temperature
boundary = right
value = 0
[]
[bottom]
type = DirichletBC
variable = temperature
boundary = bottom
value = 0
[]
[top]
type = DirichletBC
variable = temperature
boundary = top
value = 0
[]
[]
[Materials]
[steel]
type = GenericConstantMaterial
prop_names = thermal_conductivity
prop_values = 5
[]
[]
[Executioner]
type = Steady
solve_type = NEWTON
nl_abs_tol = 1e-6
nl_rel_tol = 1e-8
petsc_options_iname = '-pc_type'
petsc_options_value = 'lu'
[]
[VectorPostprocessors]
[point_source]
type = ConstantVectorPostprocessor
vector_names = 'x y z value'
value = '0.2 0.7 0.4;
0.2 0.56 1;
0 0 0;
-1000 120 500'
execute_on = LINEAR
[]
[]
[Reporters]
[measure_data]
type = OptimizationData
variable = temperature
[]
[]
[Outputs]
console = false
file_base = 'forward_homo'
[]
(modules/optimization/test/tests/optimizationreporter/point_loads/adjoint.i)
# DO NOT CHANGE THIS TEST
# this test is documented as an example in forceInv_pointLoads.md
# if this test is changed, the figures will need to be updated.
[Mesh]
type = GeneratedMesh
dim = 2
nx = 10
ny = 10
xmax = 1
ymax = 1.4
[]
[Variables]
[adjoint]
[]
[]
[Problem]
extra_tag_vectors = 'ref'
[]
[AuxVariables]
[residual_src]
[]
[]
[AuxKernels]
[residual_src]
type = TagVectorAux
vector_tag = 'ref'
v = 'adjoint'
variable = 'residual_src'
[]
[]
[Variables]
[adjoint]
[]
[]
[Kernels]
[heat_conduction]
type = MatDiffusion
variable = adjoint
diffusivity = thermal_conductivity
[]
[]
#-----every adjoint problem should have these two
[DiracKernels]
[pt]
type = ReporterPointSource
variable = adjoint
x_coord_name = misfit/measurement_xcoord
y_coord_name = misfit/measurement_ycoord
z_coord_name = misfit/measurement_zcoord
value_name = misfit/misfit_values
extra_vector_tags = 'ref'
[]
[]
[Reporters]
[misfit]
type = OptimizationData
[]
[]
[BCs]
[left]
type = DirichletBC
variable = adjoint
boundary = left
value = 0
[]
[right]
type = DirichletBC
variable = adjoint
boundary = right
value = 0
[]
[bottom]
type = DirichletBC
variable = adjoint
boundary = bottom
value = 0
[]
[top]
type = DirichletBC
variable = adjoint
boundary = top
value = 0
[]
[]
[Materials]
[steel]
type = GenericConstantMaterial
prop_names = thermal_conductivity
prop_values = 5
[]
[]
[Executioner]
type = Steady
solve_type = NEWTON
nl_abs_tol = 1e-6
nl_rel_tol = 1e-8
petsc_options_iname = '-pc_type'
petsc_options_value = 'lu'
[]
[VectorPostprocessors]
[gradient]
type = PointValueSampler
points = '0.2 0.2 0
0.7 0.56 0
0.4 1 0'
variable = adjoint
sort_by = id
[]
[]
[Outputs]
console = false
exodus = false
file_base = 'adjoint'
[]
(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/test/tests/optimizationreporter/constant_heat_source/main_nonLinear.i)
[Optimization]
[]
[OptimizationReporter]
type = GeneralOptimization
objective_name = objective_value
parameter_names = 'parameter_results'
num_values = '1'
initial_condition = '500'
lower_bounds = '0.1'
upper_bounds = '10000'
[]
[Reporters]
[main]
type = OptimizationData
measurement_points = '0.2 0.2 0
0.8 0.6 0
0.2 1.4 0
0.8 1.8 0'
measurement_values = '270 339 321 221'
[]
[]
[Executioner]
type = Optimize
tao_solver = taoblmvm
petsc_options_iname = '-tao_gatol'
petsc_options_value = '.01'
verbose = true
[]
[MultiApps]
[forward]
type = FullSolveMultiApp
input_files = forward_nonLinear.i
execute_on = FORWARD
[]
[adjoint]
type = FullSolveMultiApp
input_files = adjoint_nonLinear.i
execute_on = ADJOINT
[]
[]
[Transfers]
[toForward_measument]
type = MultiAppReporterTransfer
to_multi_app = forward
from_reporters = 'main/measurement_xcoord
main/measurement_ycoord
main/measurement_zcoord
main/measurement_time
main/measurement_values
OptimizationReporter/parameter_results'
to_reporters = 'measure_data/measurement_xcoord
measure_data/measurement_ycoord
measure_data/measurement_zcoord
measure_data/measurement_time
measure_data/measurement_values
params/q'
[]
[toAdjoint]
type = MultiAppReporterTransfer
to_multi_app = adjoint
from_reporters = 'main/measurement_xcoord
main/measurement_ycoord
main/measurement_zcoord
main/measurement_time
main/misfit_values
OptimizationReporter/parameter_results'
to_reporters = 'misfit/measurement_xcoord
misfit/measurement_ycoord
misfit/measurement_zcoord
misfit/measurement_time
misfit/misfit_values
params/q'
[]
[fromForward]
type = MultiAppReporterTransfer
from_multi_app = forward
from_reporters = 'measure_data/misfit_values measure_data/objective_value'
to_reporters = 'main/misfit_values OptimizationReporter/objective_value'
[]
[fromadjoint]
type = MultiAppReporterTransfer
from_multi_app = adjoint
from_reporters = 'gradient_vpp/inner_product'
to_reporters = 'OptimizationReporter/grad_parameter_results'
[]
#for temperature dependent material
[fromforwardMesh]
type = MultiAppCopyTransfer
from_multi_app = forward
to_multi_app = adjoint
source_variable = 'T'
variable = 'T'
[]
[]
[Reporters]
[optInfo]
type = OptimizationInfo
[]
[]
[Outputs]
csv = true
[]
(modules/optimization/examples/materialTransient/optimize_nograd.i)
[Optimization]
[]
[OptimizationReporter]
type = GeneralOptimization
objective_name = objective_value
parameter_names = 'D'
num_values = '4'
initial_condition = '0.2 0.2 0.2 0.2'
[]
[Reporters]
[main]
type = OptimizationData
measurement_file = forward_out_data_0011.csv
file_xcoord = measurement_xcoord
file_ycoord = measurement_ycoord
file_zcoord = measurement_zcoord
file_time = measurement_time
file_value = simulation_values
[]
[]
[MultiApps]
[forward]
type = FullSolveMultiApp
input_files = forward.i
cli_args = 'Outputs/csv=false;Outputs/console=false'
execute_on = FORWARD
[]
[]
[Transfers]
[to_forward]
type = MultiAppReporterTransfer
to_multi_app = forward
from_reporters = 'main/measurement_values
OptimizationReporter/D'
to_reporters = 'data/measurement_values
diffc_rep/D_vals'
[]
[from_forward]
type = MultiAppReporterTransfer
from_multi_app = forward
from_reporters = 'data/objective_value'
to_reporters = 'OptimizationReporter/objective_value'
[]
[]
[Executioner]
type = Optimize
tao_solver = taonm
petsc_options_iname = '-tao_gatol -tao_nm_lambda'
petsc_options_value = '1e-8 0.25'
verbose = true
[]
(modules/optimization/test/tests/optimizationreporter/mesh_source/main_linearRestart.i)
[Optimization]
[]
[OptimizationReporter]
type = ParameterMeshOptimization
objective_name = objective_value
parameter_names = 'source'
parameter_meshes = 'parameter_mesh_restart_out.e'
exodus_timesteps_for_parameter_mesh_variable = 2
initial_condition_mesh_variable = restart_source
lower_bounds = -1
upper_bounds = 5
outputs = none
[]
[Reporters]
[main]
type = OptimizationData
# Random points
measurement_points = '0.78193073 0.39115321 0
0.72531893 0.14319403 0
0.14052488 0.86976625 0
0.401893 0.54241797 0
0.02645427 0.43320192 0
0.28856889 0.0035165 0
0.51433644 0.94485949 0
0.29252255 0.7962032 0
0.04925654 0.58018889 0
0.04717357 0.9556314 0'
# sin(x*pi/2)*sin(y*pi/2)
measurement_values = '0.54299466 0.20259611 0.21438235 0.44418597 0.02613676
0.00241892 0.72014019 0.42096307 0.06108895 0.07385256'
[]
[]
[Executioner]
type = Optimize
tao_solver = taoblmvm
petsc_options_iname = '-tao_gatol'
petsc_options_value = '1e-4'
verbose = true
[]
[MultiApps]
[forward]
type = FullSolveMultiApp
input_files = forward.i
execute_on = FORWARD
[]
[adjoint]
type = FullSolveMultiApp
input_files = adjoint.i
execute_on = ADJOINT
[]
[]
[Transfers]
[toForward_measument]
type = MultiAppReporterTransfer
to_multi_app = forward
from_reporters = 'main/measurement_xcoord
main/measurement_ycoord
main/measurement_zcoord
main/measurement_time
main/measurement_values
OptimizationReporter/source'
to_reporters = 'measure_data/measurement_xcoord
measure_data/measurement_ycoord
measure_data/measurement_zcoord
measure_data/measurement_time
measure_data/measurement_values
src_rep/vals'
[]
[toAdjoint]
type = MultiAppReporterTransfer
to_multi_app = adjoint
from_reporters = 'main/measurement_xcoord
main/measurement_ycoord
main/measurement_zcoord
main/measurement_time
main/misfit_values
OptimizationReporter/source'
to_reporters = 'misfit/measurement_xcoord
misfit/measurement_ycoord
misfit/measurement_zcoord
misfit/measurement_time
misfit/misfit_values
src_rep/vals'
[]
[fromForward]
type = MultiAppReporterTransfer
from_multi_app = forward
from_reporters = 'measure_data/misfit_values measure_data/objective_value'
to_reporters = 'main/misfit_values OptimizationReporter/objective_value'
[]
[fromadjoint]
type = MultiAppReporterTransfer
from_multi_app = adjoint
from_reporters = 'gradient_vpp/inner_product'
to_reporters = 'OptimizationReporter/grad_source'
[]
[]
[Reporters]
[optInfo]
type = OptimizationInfo
items = 'current_iterate function_value gnorm'
[]
[]
[Outputs]
csv = true
[]
(modules/combined/test/tests/optimization/invOpt_mechanics/forward_and_adjoint.i)
# DO NOT CHANGE THIS TEST
# this test is documented as an example in forceInv_NeumannBC.md
# if this test is changed, the figures will need to be updated.
[Mesh]
type = GeneratedMesh
dim = 2
nx = 10
ny = 2
xmin = 0.0
xmax = 5.0
ymin = 0.0
ymax = 1.0
use_displaced_mesh = false
[]
[Variables]
[disp_x]
[]
[disp_y]
[]
[]
[Physics]
[SolidMechanics]
[QuasiStatic]
displacements = 'disp_x disp_y'
[all]
displacements = 'disp_x disp_y'
strain = SMALL
[]
[]
[]
[]
[BCs]
[left_ux]
type = DirichletBC
variable = disp_x
boundary = left
value = 0
[]
[left_uy]
type = DirichletBC
variable = disp_y
boundary = left
value = 0
[]
[right_fy]
type = FunctionNeumannBC
variable = disp_y
boundary = right
function = right_fy_func
[]
[right_fx]
type = FunctionNeumannBC
variable = disp_x
boundary = right
function = right_fx_func
[]
[]
[Functions]
[right_fy_func]
type = ParsedOptimizationFunction
expression = 'val_y'
param_symbol_names = 'val_x val_y'
param_vector_name = 'params/right_values'
[]
[right_fx_func]
type = ParsedOptimizationFunction
expression = 'val_x'
param_symbol_names = 'val_x val_y'
param_vector_name = 'params/right_values'
[]
[]
[Materials]
[elasticity]
type = ComputeIsotropicElasticityTensor
youngs_modulus = 10e3
poissons_ratio = 0.3
[]
[stress]
type = ComputeLinearElasticStress
[]
[]
[Preconditioning]
[nl0]
type = SMP
nl_sys = 'nl0'
petsc_options_iname = '-pc_type'
petsc_options_value = 'lu'
full = true
[]
[adjoint]
type = SMP
nl_sys = 'adjoint'
petsc_options_iname = '-pc_type'
petsc_options_value = 'lu'
full = true
[]
[]
[Executioner]
type = SteadyAndAdjoint
forward_system = nl0
adjoint_system = adjoint
nl_abs_tol = 1e-6
nl_rel_tol = 1e-8
[]
[VectorPostprocessors]
[point_sample]
type = PointValueSampler
variable = 'disp_x disp_y'
points = '5.0 1.0 0'
sort_by = x
[]
[]
[Reporters]
[measure_data_x]
type = OptimizationData
objective_name = objective_value
variable = disp_x
measurement_points = '5.0 1.0 0.0'
measurement_values = '-13.00873469088'
[]
[measure_data_y]
type = OptimizationData
objective_name = objective_value
variable = disp_y
measurement_points = '5.0 1.0 0.0'
measurement_values = '85.008027719915'
[]
[params]
type = ConstantReporter
real_vector_names = 'right_values'
real_vector_values = '-1300 2100 ' # True Values
[]
[combined]
type = ParsedVectorReporter
name = gradient
reporter_names = 'adjoint_pt_x/inner_product adjoint_pt_y/inner_product'
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
[]
[obj]
type = ParsedScalarReporter
name = obj_val
reporter_names = 'measure_data_x/objective_value
measure_data_y/objective_value'
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
[]
[]
[Outputs]
csv = false
console = false
exodus = false
file_base = 'forward'
execute_on = 'FINAL'
json = false
[]
[Problem]
nl_sys_names = 'nl0 adjoint'
kernel_coverage_check = false
skip_nl_system_check = true
[]
[Variables]
[adjoint_x]
initial_condition = 0
solver_sys = adjoint
outputs = none
[]
[adjoint_y]
initial_condition = 0
solver_sys = adjoint
outputs = none
[]
[]
[DiracKernels]
[pt_x]
type = ReporterPointSource
variable = adjoint_x
x_coord_name = measure_data_x/measurement_xcoord
y_coord_name = measure_data_x/measurement_ycoord
z_coord_name = measure_data_x/measurement_zcoord
value_name = measure_data_x/misfit_values
[]
[pt_y]
type = ReporterPointSource
variable = adjoint_y
x_coord_name = measure_data_y/measurement_xcoord
y_coord_name = measure_data_y/measurement_ycoord
z_coord_name = measure_data_y/measurement_zcoord
value_name = measure_data_y/misfit_values
[]
[]
[VectorPostprocessors]
[adjoint_pt_x]
type = SideOptimizationNeumannFunctionInnerProduct
variable = adjoint_x
function = right_fx_func
boundary = right
execute_on = ADJOINT_TIMESTEP_END
[]
[adjoint_pt_y]
type = SideOptimizationNeumannFunctionInnerProduct
variable = adjoint_y
function = right_fy_func
boundary = right
execute_on = ADJOINT_TIMESTEP_END
[]
[]
(modules/optimization/test/tests/optimizationreporter/point_loads/main_auto_adjoint.i)
measurement_points = '0.5 0.28 0
0.5 0.6 0
0.5 0.8 0
0.5 1.1 0'
measurement_values = '293 304 315 320'
[Optimization]
[]
[OptimizationReporter]
type = GeneralOptimization
objective_name = objective_value
parameter_names = 'parameter_results'
num_values = '3'
[]
[Reporters]
[main]
type = OptimizationData
measurement_points = ${measurement_points}
measurement_values = ${measurement_values}
[]
[]
[Executioner]
type = Optimize
tao_solver = taolmvm
petsc_options_iname = '-tao_gttol -tao_ls_type'
petsc_options_value = '1e-5 unit'
verbose = true
[]
[MultiApps]
[forward]
type = FullSolveMultiApp
input_files = forward_and_adjoint.i
execute_on = "FORWARD"
[]
[]
[Transfers]
# FORWARD transfers
[toForward_measument]
type = MultiAppReporterTransfer
to_multi_app = forward
from_reporters = 'main/measurement_xcoord
main/measurement_ycoord
main/measurement_zcoord
main/measurement_time
main/measurement_values
OptimizationReporter/parameter_results'
to_reporters = 'measure_data/measurement_xcoord
measure_data/measurement_ycoord
measure_data/measurement_zcoord
measure_data/measurement_time
measure_data/measurement_values
point_source/value'
[]
[fromForward]
type = MultiAppReporterTransfer
from_multi_app = forward
from_reporters = 'measure_data/objective_value
gradient/temperature_adjoint'
to_reporters = 'OptimizationReporter/objective_value
OptimizationReporter/grad_parameter_results'
[]
[]
[Outputs]
csv = true
[]
(modules/combined/test/tests/optimization/invOpt_nonlinear/main.i)
[Optimization]
[]
[Mesh]
type = GeneratedMesh
dim = 2
nx = 10
ny = 10
xmax = 2
ymax = 2
[]
[OptimizationReporter]
type = GeneralOptimization
objective_name = objective_value
parameter_names = 'heat_source'
num_values = '1'
initial_condition = '0'
lower_bounds = '0.1'
upper_bounds = '10000'
[]
[Reporters]
[main]
type = OptimizationData
measurement_points = '0.2 0.2 0
0.8 0.6 0
0.2 1.4 0
0.8 1.8 0'
measurement_values = '1.98404 1.91076 1.56488 1.23863'
[]
[]
[Executioner]
type = Optimize
tao_solver = taonls
petsc_options_iname = '-tao_gttol -tao_max_it -tao_nls_pc_type -tao_nls_ksp_type'
petsc_options_value = ' 1e-5 5 none cg'
verbose = true
[]
[MultiApps]
[forward]
type = FullSolveMultiApp
input_files = forward.i
execute_on = FORWARD
clone_parent_mesh = true
[]
[homogeneous_forward]
type = FullSolveMultiApp
input_files = homogeneous_forward.i
execute_on = HOMOGENEOUS_FORWARD
clone_parent_mesh = true
[]
[adjoint]
type = FullSolveMultiApp
input_files = adjoint.i
execute_on = ADJOINT
clone_parent_mesh = true
[]
[]
[Transfers]
## RUN FORWARD SIMULATION WITH CURRENT PARAMETERS AS FORCE,
## AND EXTRACT SIMULATED VALUES AT MEASUREMENT POINTS
## AS WELL AS TOTAL FIELD VARIABLE FOR NONLINEAR PURPOSES
[MeasurementLocationsToForward]
type = MultiAppReporterTransfer
to_multi_app = forward
from_reporters = 'main/measurement_xcoord
main/measurement_ycoord
main/measurement_zcoord
main/measurement_time
main/measurement_values
OptimizationReporter/heat_source'
to_reporters = 'measurement_locations/measurement_xcoord
measurement_locations/measurement_ycoord
measurement_locations/measurement_zcoord
measurement_locations/measurement_time
measurement_locations/measurement_values
params/heat_source'
[]
[SimulatedDataFromForward]
type = MultiAppReporterTransfer
from_multi_app = forward
from_reporters = 'measurement_locations/misfit_values measurement_locations/objective_value'
to_reporters = 'main/misfit_values OptimizationReporter/objective_value'
[]
### RUN THE HOMOGENEOUS_FORWARD WITH CURRENT NONLINEAR STATE, PARAMETER_STEP,
### AND EXTRACT SIMULATED DATA AT MEASURMENT POINTS
[CurrentStateFromForwardNonlinearToHomogeneousForwardNonlinear]
type = MultiAppCopyTransfer
from_multi_app = forward
to_multi_app = homogeneous_forward
source_variable = 'forwardT'
variable = 'forwardT'
[]
[MeasurementLocationsToHomogeneousForward]
type = MultiAppReporterTransfer
to_multi_app = homogeneous_forward
from_reporters = 'main/measurement_xcoord
main/measurement_ycoord
main/measurement_zcoord
main/measurement_time
main/measurement_values
OptimizationReporter/heat_source'
to_reporters = 'measurement_locations/measurement_xcoord
measurement_locations/measurement_ycoord
measurement_locations/measurement_zcoord
measurement_locations/measurement_time
measurement_locations/measurement_values
params/heat_source'
[]
[SimulatedDataFromHomogeneousForward]
type = MultiAppReporterTransfer
from_multi_app = homogeneous_forward
from_reporters = 'measurement_locations/simulation_values'
to_reporters = 'main/misfit_values'
[]
### RUN THE ADJOINT WITH CURRENT NONLINEAR STATE, WITH MISFIT AS EXCITATION,
### AND EXTRACT GRADIENT
[CurrentStateToAdjointNonlinear]
type = MultiAppCopyTransfer
from_multi_app = forward
to_multi_app = adjoint
source_variable = 'forwardT'
variable = 'forwardT'
[]
[MisfitToAdjoint]
type = MultiAppReporterTransfer
to_multi_app = adjoint
from_reporters = 'main/measurement_xcoord
main/measurement_ycoord
main/measurement_zcoord
main/measurement_time
main/misfit_values
OptimizationReporter/heat_source'
to_reporters = 'misfit/measurement_xcoord
misfit/measurement_ycoord
misfit/measurement_zcoord
misfit/measurement_time
misfit/misfit_values
params/heat_source'
[]
[GradientFromAdjoint]
type = MultiAppReporterTransfer
from_multi_app = adjoint
from_reporters = 'gradient_vpp/inner_product'
to_reporters = 'OptimizationReporter/grad_heat_source'
[]
[]
[Reporters]
[optInfo]
type = OptimizationInfo
[]
[]
[Outputs]
csv = true
[]
(modules/optimization/test/tests/optimizationreporter/general_opt/point_loads_gen_opt/forward_and_adjoint_transfer_data.i)
[Mesh]
[gmg]
type = GeneratedMeshGenerator
dim = 2
nx = 10
ny = 10
xmax = 1
ymax = 1.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 = thermal_conductivity
[]
[]
[DiracKernels]
[pt]
type = ReporterPointSource
variable = temperature
x_coord_name = 'point_source/x'
y_coord_name = 'point_source/y'
z_coord_name = 'point_source/z'
value_name = 'point_source/value'
[]
[misfit]
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
[]
[]
[BCs]
[left]
type = DirichletBC
variable = temperature
boundary = left
value = 300
[]
[right]
type = DirichletBC
variable = temperature
boundary = right
value = 300
[]
[bottom]
type = DirichletBC
variable = temperature
boundary = bottom
value = 300
[]
[top]
type = DirichletBC
variable = temperature
boundary = top
value = 300
[]
[]
[Materials]
[steel]
type = GenericConstantMaterial
prop_names = thermal_conductivity
prop_values = 5
[]
[]
[Executioner]
type = SteadyAndAdjoint
forward_system = nl0
adjoint_system = adjoint
nl_rel_tol = 1e-12
l_tol = 1e-12
petsc_options_iname = '-pc_type'
petsc_options_value = 'lu'
[]
[VectorPostprocessors]
[gradient]
type = PointValueSampler
points = '0.2 0.2 0
0.7 0.56 0
0.4 1 0'
variable = temperature_adjoint
sort_by = id
execute_on = ADJOINT_TIMESTEP_END
[]
[]
[Reporters]
[measure_data]
type = OptimizationData
variable = temperature
objective_name = misfit_norm
[]
[point_source]
type = ConstantReporter
real_vector_names = 'x y z value'
real_vector_values = '0.2 0.7 0.4;
0.2 0.56 1;
0 0 0;
-1000 120 500'
[]
[]
[Outputs]
console = false
[]
(modules/optimization/examples/simpleTransient/adjoint_mesh.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
[]
[src_values]
type = ConstantReporter
real_vector_names = 'time values'
real_vector_values = '0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0;
0' # dummy
[]
[]
[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
[]
[]
[Functions]
[source]
type = ParameterMeshFunction
exodus_mesh = source_mesh_in.e
time_name = src_values/time
parameter_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 -pc_hypre_type'
petsc_options_value = 'hypre boomeramg'
[]
[Outputs]
console = false
[]
(modules/combined/test/tests/optimization/invOpt_bc_convective/forward.i)
[Mesh]
[gmg]
type = GeneratedMeshGenerator
dim = 2
nx = 10
ny = 20
xmax = 1
ymax = 2
[]
[]
[Variables]
[temperature]
[]
[]
[Kernels]
[heat_conduction]
type = ADHeatConduction
variable = temperature
[]
[]
[BCs]
[left]
type = ConvectiveFluxFunction
variable = temperature
boundary = 'left'
T_infinity = 100.0
coefficient = function1
[]
[right]
type = NeumannBC
variable = temperature
boundary = right
value = -100
[]
[bottom]
type = DirichletBC
variable = temperature
boundary = bottom
value = 500
[]
[top]
type = DirichletBC
variable = temperature
boundary = top
value = 600
[]
[]
[Materials]
[steel]
type = ADGenericConstantMaterial
prop_names = thermal_conductivity
prop_values = 5
[]
[]
[Executioner]
type = Steady
solve_type = PJFNK
nl_abs_tol = 1e-6
nl_rel_tol = 1e-8
petsc_options_iname = '-pc_type'
petsc_options_value = 'lu'
[]
[Functions]
[function1]
type = ParsedOptimizationFunction
expression = 'a'
param_symbol_names = 'a'
param_vector_name = 'params/vals'
[]
[]
[VectorPostprocessors]
[vertical]
type = LineValueSampler
variable = 'temperature'
start_point = '0.1 0.0 0.0'
end_point = '0.1 2.0 0.0'
num_points = 21
sort_by = id
[]
[]
[Reporters]
[measure_data]
type = OptimizationData
objective_name = objective_value
variable = temperature
[]
[params]
type = ConstantReporter
real_vector_names = 'vals'
real_vector_values = '0' # Dummy value
[]
[]
[Outputs]
csv = true
exodus = false
console = false
file_base = 'forward'
[]
(modules/optimization/examples/simpleTransient/main_gradient.i)
[Optimization]
[]
[OptimizationReporter]
type = GeneralOptimization
objective_name = objective_value
parameter_names = 'source'
num_values = '44'
[]
[Reporters]
[main]
type = OptimizationData
[]
[]
[MultiApps]
[forward]
type = FullSolveMultiApp
input_files = forward.i
execute_on = FORWARD
[]
[adjoint]
type = FullSolveMultiApp
input_files = adjoint.i
execute_on = ADJOINT
[]
[]
[Transfers]
[to_forward]
type = MultiAppReporterTransfer
to_multi_app = forward
from_reporters = 'OptimizationReporter/source'
to_reporters = 'src_values/values'
[]
[from_forward]
type = MultiAppReporterTransfer
from_multi_app = forward
from_reporters = 'measured_data/misfit_values measured_data/objective_value'
to_reporters = 'main/misfit_values OptimizationReporter/objective_value'
[]
[to_adjoint]
type = MultiAppReporterTransfer
to_multi_app = adjoint
from_reporters = 'OptimizationReporter/source main/misfit_values'
to_reporters = 'src_values/values measured_data/misfit_values'
[]
[from_adjoint]
type = MultiAppReporterTransfer
from_multi_app = adjoint
from_reporters = 'adjoint/inner_product'
to_reporters = 'OptimizationReporter/grad_source'
[]
[]
[Executioner]
type = Optimize
solve_on = none
tao_solver = taolmvm
petsc_options_iname = '-tao_gatol -tao_ls_type'
petsc_options_value = '1e-2 unit'
verbose = true
[]
[Postprocessors]
[elapsed]
type = PerfGraphData
section_name = "Root"
data_type = total
[]
[]
[Outputs]
[pgraph]
type = PerfGraphOutput
level = 1
[]
[]
(modules/combined/test/tests/optimization/invOpt_elasticity_modular/forward.i)
[Mesh]
[gmg]
type = GeneratedMeshGenerator
dim = 2
nx = 11
ny = 11
xmin = -4
xmax = 4
ymin = -4
ymax = 4
[]
displacements = 'disp_x disp_y'
[]
[Variables]
[disp_x]
[]
[disp_y]
[]
[]
[AuxVariables]
[T]
[]
[]
[Physics]
[SolidMechanics]
[QuasiStatic]
displacements = 'disp_x disp_y'
[all]
strain = SMALL
new_system = true
formulation = TOTAL
incremental = true
volumetric_locking_correction = false
displacements = 'disp_x disp_y'
[]
[]
[]
[]
[NEML2]
input = 'elasticity.i'
verbose = true
device = 'cpu'
[all]
model = 'forward_elasticity_model'
moose_input_types = 'MATERIAL'
moose_inputs = 'neml2_strain'
neml2_inputs = 'forces/E'
moose_parameter_types = 'MATERIAL'
moose_parameters = 'E_material'
neml2_parameters = 'E'
moose_output_types = 'MATERIAL'
moose_outputs = 'neml2_stress'
neml2_outputs = 'state/S'
moose_derivative_types = 'MATERIAL'
moose_derivatives = 'neml2_jacobian'
neml2_derivatives = 'state/S forces/E'
[]
[]
[BCs]
[bottom_x]
type = DirichletBC
variable = disp_x
boundary = bottom
value = 0.0
[]
[bottom_y]
type = DirichletBC
variable = disp_y
boundary = bottom
value = 0.0
[]
[top_x]
type = NeumannBC
variable = disp_x
boundary = top
value = 1.0
[]
[top_y]
type = NeumannBC
variable = disp_y
boundary = top
value = 1.0
[]
[]
[Materials]
[convert_strain]
type = RankTwoTensorToSymmetricRankTwoTensor
from = 'mechanical_strain'
to = 'neml2_strain'
[]
[stress]
type = ComputeLagrangianObjectiveCustomSymmetricStress
custom_small_stress = 'neml2_stress'
custom_small_jacobian = 'neml2_jacobian'
[]
[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 = disp_x
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'
[]
[]
[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
nl_rel_tol = 1e-10
nl_abs_tol = 1e-14
[]
[Postprocessors]
[point1]
type = PointValue
point = '-1.0 -1.0 0.0'
variable = disp_x
execute_on = TIMESTEP_END
[]
[point2]
type = PointValue
point = '-1.0 0.0 0.0'
variable = disp_x
execute_on = TIMESTEP_END
[]
[point3]
type = PointValue
point = '-1.0 1.0 0.0'
variable = disp_x
execute_on = TIMESTEP_END
[]
[point4]
type = PointValue
point = '0.0 -1.0 0.0'
variable = disp_x
execute_on = TIMESTEP_END
[]
[point5]
type = PointValue
point = '0.0 0.0 0.0'
variable = disp_x
execute_on = TIMESTEP_END
[]
[point6]
type = PointValue
point = '0.0 1.0 0.0'
variable = disp_x
execute_on = TIMESTEP_END
[]
[point7]
type = PointValue
point = '1.0 -1.0 0.0'
variable = disp_x
execute_on = TIMESTEP_END
[]
[point8]
type = PointValue
point = '1.0 0.0 0.0'
variable = disp_x
execute_on = TIMESTEP_END
[]
[point9]
type = PointValue
point = '1.0 1.0 0.0'
variable = disp_x
execute_on = TIMESTEP_END
[]
[]
[Outputs]
file_base = 'forward'
console = false
[]
(modules/optimization/test/tests/optimizationreporter/function_misfit/forward_and_adjoint.i)
[Mesh]
[gmg]
type = GeneratedMeshGenerator
dim = 2
nx = 15
ny = 15
xmin = 0
ymin = 0
xmax = 1
ymax = 1.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 = thermal_conductivity
[]
# apply gradient material as a body force since the integral is over the whole domain
[adj_source]
type = MatBodyForce
variable = temperature_adjoint
material_property = obj_misfit_gradient
[]
[]
[DiracKernels]
[pt]
type = ReporterPointSource
variable = temperature
x_coord_name = 'point_source/x'
y_coord_name = 'point_source/y'
z_coord_name = 'point_source/z'
value_name = 'point_source/value'
[]
[]
[BCs]
[left]
type = DirichletBC
variable = temperature
boundary = left
value = 300
[]
[right]
type = DirichletBC
variable = temperature
boundary = right
value = 300
[]
[bottom]
type = DirichletBC
variable = temperature
boundary = bottom
value = 300
[]
[top]
type = DirichletBC
variable = temperature
boundary = top
value = 300
[]
[]
[Materials]
[steel]
type = GenericConstantMaterial
prop_names = thermal_conductivity
prop_values = 5
[]
# Create two materials.
# 1. Material which the integral of is our objective
# 2. dM/du material which is used for our adjoint problem
[beam]
type = MisfitReporterOffsetFunctionMaterial
x_coord_name = measure_data/measurement_xcoord
y_coord_name = measure_data/measurement_ycoord
z_coord_name = measure_data/measurement_zcoord
measurement_value_name = measure_data/measurement_values
forward_variable = temperature
property_name = 'obj_misfit'
function = gauss
[]
[]
[Functions]
[gauss]
type = ParsedFunction
expression = 'exp(-2.0 *(x^2 + y^2 + z^2)/(beam_radii^2))'
symbol_names = 'beam_radii'
symbol_values = '.025'
[]
[]
[Executioner]
type = SteadyAndAdjoint
forward_system = nl0
adjoint_system = adjoint
nl_rel_tol = 1e-12
l_tol = 1e-12
petsc_options_iname = '-pc_type'
petsc_options_value = 'lu'
[]
[VectorPostprocessors]
[gradient]
type = PointValueSampler
points = '0.2 0.2 0
0.7 0.56 0
0.4 1 0'
variable = temperature_adjoint
sort_by = id
execute_on = ADJOINT_TIMESTEP_END
[]
[]
[Postprocessors]
[objective]
type = ElementIntegralMaterialProperty
mat_prop = obj_misfit
execute_on = 'ADJOINT_TIMESTEP_END TIMESTEP_END'
[]
[]
[Reporters]
[measure_data]
type = OptimizationData
variable = temperature
[]
[point_source]
type = ConstantReporter
real_vector_names = 'x y z value'
real_vector_values = '0.2 0.7 0.4;
0.2 0.56 1;
0 0 0;
-1000 120 500'
[]
[]
[Outputs]
console = false
[]
(modules/optimization/test/tests/optimizationreporter/function_misfit/main_auto_side.i)
measurement_points = '0.2 1.4 0
0.9 1.4 0'
measurement_values = '289 302.3'
[Optimization]
[]
[OptimizationReporter]
type = GeneralOptimization
objective_name = objective_value
parameter_names = 'parameter_results'
num_values = '3'
[]
[Reporters]
[main]
type = OptimizationData
measurement_points = ${measurement_points}
measurement_values = ${measurement_values}
[]
[]
[Executioner]
type = Optimize
tao_solver = taobqnktr
petsc_options_iname = '-tao_gatol'
petsc_options_value = '1e-8'
## THESE OPTIONS ARE FOR TESTING THE ADJOINT GRADIENT
# petsc_options_iname = '-tao_max_it -tao_fd_test -tao_test_gradient -tao_fd_gradient -tao_fd_delta -tao_gatol'
# petsc_options_value = '1 true true false 1e-3 1e10'
# petsc_options = '-tao_test_gradient_view'
verbose = true
[]
[MultiApps]
[forward]
type = FullSolveMultiApp
input_files = forward_and_adjoint_side.i
execute_on = "FORWARD"
[]
[]
[Transfers]
# FORWARD transfers
[toForward_measument]
type = MultiAppReporterTransfer
to_multi_app = forward
from_reporters = 'main/measurement_xcoord
main/measurement_ycoord
main/measurement_zcoord
main/measurement_time
main/measurement_values
OptimizationReporter/parameter_results'
to_reporters = 'measure_data/measurement_xcoord
measure_data/measurement_ycoord
measure_data/measurement_zcoord
measure_data/measurement_time
measure_data/measurement_values
point_source/value'
[]
[fromForward]
type = MultiAppReporterTransfer
from_multi_app = forward
from_reporters = 'objective/value
gradient/temperature_adjoint'
to_reporters = 'OptimizationReporter/objective_value
OptimizationReporter/grad_parameter_results'
[]
[]
[Outputs]
csv = true
[]
(modules/combined/test/tests/optimization/invOpt_nonlinear/forward.i)
[Executioner]
type = Steady
solve_type = NEWTON
line_search = none
nl_abs_tol = 1e-12
nl_rel_tol = 1e-12
petsc_options_iname = '-pc_type'
petsc_options_value = 'lu'
[]
[Mesh]
[]
[Variables]
[forwardT]
[]
[]
[Kernels]
[heat_conduction]
type = ADHeatConduction
thermal_conductivity = 'conductivity'
variable = forwardT
[]
[heat_source]
type = ADMatHeatSource
material_property = 'volumetric_heat'
variable = forwardT
[]
[]
[Materials]
[NonlinearConductivity]
type = ADParsedMaterial
f_name = 'conductivity'
function = '10+500*forwardT'
args = 'forwardT'
[]
[volumetric_heat]
type = ADGenericFunctionMaterial
prop_names = 'volumetric_heat'
prop_values = 'volumetric_heat_func'
[]
[]
[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
objective_name = objective_value
variable = forwardT
[]
[params]
type = ConstantReporter
real_vector_names = 'heat_source'
real_vector_values = '0' # Dummy
[]
[]
[Outputs]
console = false
[]
(modules/optimization/test/tests/optimizationreporter/point_loads/adjoint.i)
# DO NOT CHANGE THIS TEST
# this test is documented as an example in forceInv_pointLoads.md
# if this test is changed, the figures will need to be updated.
[Mesh]
type = GeneratedMesh
dim = 2
nx = 10
ny = 10
xmax = 1
ymax = 1.4
[]
[Variables]
[adjoint]
[]
[]
[Problem]
extra_tag_vectors = 'ref'
[]
[AuxVariables]
[residual_src]
[]
[]
[AuxKernels]
[residual_src]
type = TagVectorAux
vector_tag = 'ref'
v = 'adjoint'
variable = 'residual_src'
[]
[]
[Variables]
[adjoint]
[]
[]
[Kernels]
[heat_conduction]
type = MatDiffusion
variable = adjoint
diffusivity = thermal_conductivity
[]
[]
#-----every adjoint problem should have these two
[DiracKernels]
[pt]
type = ReporterPointSource
variable = adjoint
x_coord_name = misfit/measurement_xcoord
y_coord_name = misfit/measurement_ycoord
z_coord_name = misfit/measurement_zcoord
value_name = misfit/misfit_values
extra_vector_tags = 'ref'
[]
[]
[Reporters]
[misfit]
type = OptimizationData
[]
[]
[BCs]
[left]
type = DirichletBC
variable = adjoint
boundary = left
value = 0
[]
[right]
type = DirichletBC
variable = adjoint
boundary = right
value = 0
[]
[bottom]
type = DirichletBC
variable = adjoint
boundary = bottom
value = 0
[]
[top]
type = DirichletBC
variable = adjoint
boundary = top
value = 0
[]
[]
[Materials]
[steel]
type = GenericConstantMaterial
prop_names = thermal_conductivity
prop_values = 5
[]
[]
[Executioner]
type = Steady
solve_type = NEWTON
nl_abs_tol = 1e-6
nl_rel_tol = 1e-8
petsc_options_iname = '-pc_type'
petsc_options_value = 'lu'
[]
[VectorPostprocessors]
[gradient]
type = PointValueSampler
points = '0.2 0.2 0
0.7 0.56 0
0.4 1 0'
variable = adjoint
sort_by = id
[]
[]
[Outputs]
console = false
exodus = false
file_base = 'adjoint'
[]
(modules/optimization/test/tests/optimizationreporter/general_opt/point_loads_gen_opt/forward.i)
[Mesh]
[gmg]
type = GeneratedMeshGenerator
dim = 2
nx = 10
ny = 10
xmax = 1
ymax = 1.4
[]
[]
[Variables]
[temperature]
[]
[]
[Kernels]
[heat_conduction]
type = MatDiffusion
variable = temperature
diffusivity = thermal_conductivity
[]
[]
[DiracKernels]
[pt]
type = ReporterPointSource
variable = temperature
x_coord_name = 'point_source/x'
y_coord_name = 'point_source/y'
z_coord_name = 'point_source/z'
value_name = 'point_source/value'
[]
[]
[BCs]
[left]
type = DirichletBC
variable = temperature
boundary = left
value = 300
[]
[right]
type = DirichletBC
variable = temperature
boundary = right
value = 300
[]
[bottom]
type = DirichletBC
variable = temperature
boundary = bottom
value = 300
[]
[top]
type = DirichletBC
variable = temperature
boundary = top
value = 300
[]
[]
[Materials]
[steel]
type = GenericConstantMaterial
prop_names = thermal_conductivity
prop_values = 5
[]
[]
[Executioner]
type = Steady
solve_type = NEWTON
nl_abs_tol = 1e-6
nl_rel_tol = 1e-8
petsc_options_iname = '-pc_type'
petsc_options_value = 'lu'
[]
[VectorPostprocessors]
[point_source]
type = ConstantVectorPostprocessor
vector_names = 'x y z value'
value = '0.2 0.7 0.4;
0.2 0.56 1;
0 0 0;
-1000 120 500'
execute_on = LINEAR
[]
[vertical]
type = LineValueSampler
variable = 'temperature'
start_point = '0.5 0 0'
end_point = '0.5 1.4 0'
num_points = 21
sort_by = y
[]
[]
[Reporters]
[measure_data]
type = OptimizationData
variable = temperature
objective_name = misfit_norm
measurement_points = ${measurement_points}
measurement_values = ${measurement_values}
[]
[]
[Outputs]
console = false
file_base = 'forward'
[]
(modules/optimization/test/tests/executioners/constrained/inequality/forward_and_adjoint.i)
[Mesh]
[gmg]
type = GeneratedMeshGenerator
dim = 2
nx = 10
ny = 20
xmax = 1
ymax = 1
[]
[]
[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 = thermal_conductivity
[]
[]
[BCs]
[left]
type = FunctionNeumannBC
variable = temperature
boundary = left
function = left_function
[]
[bottom]
type = DirichletBC
variable = temperature
boundary = bottom
value = 200
[]
[top]
type = DirichletBC
variable = temperature
boundary = top
value = 100
[]
[]
[Functions]
[left_function]
type = ParsedOptimizationFunction
expression = 'a + b*y'
param_symbol_names = 'a b'
param_vector_name = 'params/left'
[]
[dc_db]
type = ParsedFunction
expression = 'y'
[]
[]
[Materials]
[steel]
type = GenericConstantMaterial
prop_names = thermal_conductivity
prop_values = 5
[]
[]
[Preconditioning]
[nl0]
type = SMP
nl_sys = 'nl0'
petsc_options_iname = '-pc_type'
petsc_options_value = 'lu'
[]
[adjoint]
type = SMP
nl_sys = 'adjoint'
petsc_options_iname = '-pc_type'
petsc_options_value = 'lu'
[]
[]
[Executioner]
type = SteadyAndAdjoint
forward_system = nl0
adjoint_system = adjoint
line_search = none
nl_rel_tol = 1e-12
l_tol = 1e-12
[]
[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
[]
[]
[VectorPostprocessors]
[grad_bc_left]
type = SideOptimizationNeumannFunctionInnerProduct
variable = temperature_adjoint
function = left_function
boundary = left
execute_on = ADJOINT_TIMESTEP_END
[]
[]
[Postprocessors]
[sum]
type = FunctionSideIntegral
boundary = left
function = left_function
[]
[]
[Reporters]
[measure_data]
type = OptimizationData
variable = temperature
objective_name = objective_value
[]
[params]
type = ConstantReporter
real_vector_names = 'left'
real_vector_values = '0 0' # Dummy
execute_on = NONE
[]
[]
[Outputs]
console = false
exodus = false
json = true
[]
#---------Inequality constraints------------#
[VectorPostprocessors]
[gradient_c]
type = VectorOfPostprocessors
postprocessors = 'dc_da dc_db'
[]
[ineq]
type = VectorOfPostprocessors
postprocessors = 'constraint'
[]
[]
[Postprocessors]
[constraint]
type = ParsedPostprocessor
expression = '150 - sum' # 150 is the constraint we want to satisfy
pp_names = sum
[]
[dc_da]
type = FunctionSideIntegral
boundary = left
function = -1
[]
[dc_db]
type = FunctionSideIntegral
boundary = left
function = '-y'
[]
[]
(modules/optimization/test/tests/outputs/exodus_optimization_steady/forward.i)
[Mesh]
[]
[Variables]
[temperature]
[]
[]
[Kernels]
[heat_conduction]
type = MatDiffusion
variable = temperature
diffusivity = thermal_conductivity
[]
[heat_source]
type = BodyForce
value = 1000
variable = temperature
[]
[]
[BCs]
[left]
type = NeumannBC
variable = temperature
boundary = left
value = 0
[]
[right]
type = NeumannBC
variable = temperature
boundary = right
value = 0
[]
[bottom]
type = DirichletBC
variable = temperature
boundary = bottom
value = 200
[]
[top]
type = DirichletBC
variable = temperature
boundary = top
value = 100
[]
[]
[Functions]
[thermo_conduct]
type = ParsedOptimizationFunction
expression = 'alpha'
param_symbol_names = 'alpha'
param_vector_name = 'params/p1'
[]
[]
[Materials]
[steel]
type = GenericFunctionMaterial
prop_names = 'thermal_conductivity'
prop_values = 'thermo_conduct'
[]
[]
[Executioner]
type = Steady
solve_type = NEWTON
nl_abs_tol = 1e-8
nl_rel_tol = 1e-8
petsc_options_iname = '-ksp_type -pc_type -pc_factor_mat_solver_package'
petsc_options_value = 'preonly lu superlu_dist'
[]
[Reporters]
[measure_data]
type = OptimizationData
objective_name = objective_value
variable = temperature
outputs = none
[]
[params]
type = ConstantReporter
real_vector_names = 'p1'
real_vector_values = '0' # Dummy value
[]
[]
[Outputs]
console = false
file_base = 'forward'
[exo]
type = ExodusOptimizationSteady
execute_on = 'TIMESTEP_END'
[]
[]
(modules/optimization/test/tests/optimizationreporter/material/adjoint.i)
[Mesh]
[]
[Variables]
[adjointVar]
[]
[]
[Kernels]
[heat_conduction]
type = MatDiffusion
variable = adjointVar
diffusivity = thermal_conductivity
[]
[]
[DiracKernels]
[pt]
type = ReporterPointSource
variable = adjointVar
x_coord_name = misfit/measurement_xcoord
y_coord_name = misfit/measurement_ycoord
z_coord_name = misfit/measurement_zcoord
value_name = misfit/misfit_values
[]
[]
[Reporters]
[misfit]
type = OptimizationData
[]
[params]
type = ConstantReporter
real_vector_names = 'p1'
real_vector_values = '0' # Dummy value
[]
[]
[AuxVariables]
[temperature_forward]
[]
[]
[BCs]
[left]
type = NeumannBC
variable = adjointVar
boundary = left
value = 0
[]
[right]
type = NeumannBC
variable = adjointVar
boundary = right
value = 0
[]
[bottom]
type = DirichletBC
variable = adjointVar
boundary = bottom
value = 0
[]
[top]
type = DirichletBC
variable = adjointVar
boundary = top
value = 0
[]
[]
[Functions]
[thermo_conduct]
type = ParsedOptimizationFunction
expression = 'alpha'
param_symbol_names = 'alpha'
param_vector_name = 'params/p1'
[]
[]
[Materials]
[thermalProp]
type = GenericFunctionMaterial
prop_names = 'thermal_conductivity'
prop_values = 'thermo_conduct'
[]
[]
[Executioner]
type = Steady
solve_type = PJFNK
nl_abs_tol = 1e-8
nl_rel_tol = 1e-8
petsc_options_iname = '-ksp_type -pc_type -pc_factor_mat_solver_package'
petsc_options_value = 'preonly lu superlu_dist'
[]
[VectorPostprocessors]
[adjoint_grad]
type = ElementOptimizationDiffusionCoefFunctionInnerProduct
variable = adjointVar
forward_variable = temperature_forward
function = thermo_conduct
[]
[]
[Outputs]
console = false
file_base = 'adjoint'
[]
(modules/optimization/test/tests/misc/scaling_test/forward_and_adjoint.i)
[Mesh]
[generated]
type = GeneratedMeshGenerator
dim = 2
nx = 10
ny = 10
ymin = 0
xmin = 0
xmax = 10
ymax = 10
[]
[]
[Problem]
nl_sys_names = 'nl0 adjoint'
kernel_coverage_check = FALSE
[]
[Variables]
[T_real]
initial_condition = 1e-8
scaling = 10
[]
[T_imag]
initial_condition = 1e-8
[]
[T_real_adj]
solver_sys = adjoint
[]
[T_imag_adj]
solver_sys = adjoint
[]
[]
[Kernels]
[heat_conduction_real]
type = MatDiffusion
variable = T_real
diffusivity = k
[]
[heat_source_real]
type = MatCoupledForce
variable = T_real
v = T_imag
material_properties = 'force_mat'
[]
[heat_conduction_imag]
type = MatDiffusion
variable = T_imag
diffusivity = k
[]
[heat_source_imag]
type = MatCoupledForce
variable = T_imag
v = T_real
material_properties = 'force_mat'
coef = -1
[]
[]
[Materials]
[k_mat]
type = GenericFunctionMaterial
prop_names = 'k'
prop_values = 'kappa_func'
[]
[mats]
type = GenericConstantMaterial
prop_names = 'rho omega cp '
prop_values = '1.0 1.0 1.0 '
[]
[force_mat]
type = ParsedMaterial
property_name = force_mat
expression = 'rho * omega * cp'
material_property_names = 'rho omega cp'
[]
[phase]
type = ADParsedMaterial
coupled_variables = 'T_real T_imag'
expression = 'atan2(T_imag, T_real)'
property_name = phase
[]
[]
[Functions]
[gauss]
type = ParsedFunction
expression = 'exp(-2.0 *(x^2 + y^2 + z^2)/(beam_radii^2))'
symbol_names = 'beam_radii'
symbol_values = '0.1'
[]
[kappa_func]
type = ParsedOptimizationFunction
expression = 'k '
param_symbol_names = 'k '
param_vector_name = 'params/k'
[]
[]
[BCs]
[real_top]
type = FunctionNeumannBC
variable = T_real
boundary = top
function = 'exp((-2.0 *(x)^2)/0.1)'
[]
[]
[DiracKernels]
[misfit_real]
type = ReporterPointSource
variable = T_real_adj
x_coord_name = measure_data_real/measurement_xcoord
y_coord_name = measure_data_real/measurement_ycoord
z_coord_name = measure_data_real/measurement_zcoord
value_name = measure_data_real/misfit_values
[]
[misfit_imag]
type = ReporterPointSource
variable = T_imag_adj
x_coord_name = measure_data_imag/measurement_xcoord
y_coord_name = measure_data_imag/measurement_ycoord
z_coord_name = measure_data_imag/measurement_zcoord
value_name = measure_data_imag/misfit_values
[]
[]
[AuxVariables]
[phase]
[]
[]
[AuxKernels]
[phase]
type = ParsedAux
variable = phase
coupled_variables = 'T_imag T_real'
expression = 'atan2(T_imag, T_real)'
execute_on = 'TIMESTEP_END'
[]
[]
[Reporters]
[measure_data_real]
type = OptimizationData
variable = T_real
objective_name = objective_value
measurement_values = '0.10391 -0.0064'
measurement_points = '0.55 10 0
3.55 10 0'
[]
[measure_data_imag]
type = OptimizationData
objective_name = objective_value
variable = T_imag
measurement_values = '-0.08234 -0.00181'
measurement_points = '0.55 10 0
3.55 10 0'
[]
[params]
type = ConstantReporter
real_vector_names = 'k'
real_vector_values = '2' # Dummy value
[]
[gradient]
type = ParsedVectorReporter
name = inner
reporter_names = 'gradient_real/inner_product gradient_imag/inner_product'
reporter_symbols = 'a b'
expression = 'a+b'
execute_on = ADJOINT_TIMESTEP_END
execution_order_group = 1
[]
[obj]
type = ParsedScalarReporter
name = value
reporter_names = 'measure_data_real/objective_value measure_data_imag/objective_value'
reporter_symbols = 'a b'
expression = 'a+b'
execute_on = ADJOINT_TIMESTEP_END
execution_order_group = 1
[]
[]
[VectorPostprocessors]
[gradient_real]
type = ElementOptimizationDiffusionCoefFunctionInnerProduct
variable = T_real_adj
forward_variable = T_real
function = kappa_func
execute_on = ADJOINT_TIMESTEP_END
[]
[gradient_imag]
type = ElementOptimizationDiffusionCoefFunctionInnerProduct
variable = T_imag_adj
forward_variable = T_imag
function = kappa_func
execute_on = ADJOINT_TIMESTEP_END
[]
[]
[Executioner]
type = SteadyAndAdjoint
forward_system = nl0
adjoint_system = adjoint
nl_rel_tol = 1e-12
nl_abs_tol = 1e-10
l_tol = 1e-10
automatic_scaling = false
petsc_options_iname = '-pc_type'
petsc_options_value = 'lu'
line_search = l2
verbose = true
[]
[Outputs]
console = true
execute_on = FINAL
[]
(modules/optimization/test/tests/optimizationreporter/constant_heat_source/forward_nonLinear.i)
[Mesh]
type = GeneratedMesh
dim = 2
nx = 10
ny = 10
xmax = 2
ymax = 2
[]
[Variables]
[T]
initial_condition = 100
[]
[]
[Kernels]
[heat_conduction]
type = MatDiffusion
variable = T
diffusivity = thermal_conductivity
[]
[heat_source]
type = BodyForce
function = volumetric_heat_func
variable = T
[]
[]
[BCs]
[left]
type = NeumannBC
variable = T
boundary = left
value = 0
[]
[right]
type = NeumannBC
variable = T
boundary = right
value = 0
[]
[bottom]
type = DirichletBC
variable = T
boundary = bottom
value = 200
[]
[top]
type = DirichletBC
variable = T
boundary = top
value = 100
[]
[]
[Functions]
[volumetric_heat_func]
type = ParsedOptimizationFunction
expression = q
param_symbol_names = 'q'
param_vector_name = 'params/q'
[]
[]
[Materials]
[steel]
type = ParsedMaterial
f_name = 'thermal_conductivity'
function = '.01*T'
args = 'T'
[]
[]
[Executioner]
type = Steady
solve_type = PJFNK
nl_abs_tol = 1e-8
nl_rel_tol = 1e-8
petsc_options_iname = '-ksp_type -pc_type -pc_factor_mat_solver_package'
petsc_options_value = 'preonly lu superlu_dist'
[]
[Reporters]
[measure_data]
type = OptimizationData
objective_name = objective_value
variable = T
[]
[params]
type = ConstantReporter
real_vector_names = 'q'
real_vector_values = '0' # Dummy value
[]
[]
[Outputs]
console = false
file_base = 'forward_nl'
[]
(modules/optimization/test/tests/optimizationreporter/bc_load_linearFunction/forward_and_adjoint.i)
[Mesh]
[gmg]
type = GeneratedMeshGenerator
dim = 2
nx = 10
ny = 20
xmax = 1
ymax = 2
bias_x = 1.1
bias_y = 1.1
[]
[]
[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 = thermal_conductivity
[]
[]
[BCs]
[left]
type = FunctionNeumannBC
variable = temperature
boundary = left
function = left_function
[]
[right]
type = FunctionNeumannBC
variable = temperature
boundary = right
function = right_function
[]
[bottom]
type = DirichletBC
variable = temperature
boundary = bottom
value = 200
[]
[top]
type = DirichletBC
variable = temperature
boundary = top
value = 100
[]
[]
[Functions]
[left_function]
type = ParsedOptimizationFunction
expression = 'a + b*y'
param_symbol_names = 'a b'
param_vector_name = 'params/left'
[]
[right_function]
type = ParsedOptimizationFunction
expression = 'a'
param_symbol_names = 'a'
param_vector_name = 'params/right'
[]
[]
[Materials]
[steel]
type = GenericConstantMaterial
prop_names = thermal_conductivity
prop_values = 5
[]
[]
[Preconditioning]
[nl0]
type = SMP
nl_sys = 'nl0'
petsc_options_iname = '-pc_type'
petsc_options_value = 'lu'
[]
[adjoint]
type = SMP
nl_sys = 'adjoint'
petsc_options_iname = '-pc_type'
petsc_options_value = 'lu'
[]
[]
[Executioner]
type = SteadyAndAdjoint
forward_system = nl0
adjoint_system = adjoint
line_search = none
nl_rel_tol = 1e-12
l_tol = 1e-12
[]
[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
weight_name = measure_data/weight
[]
[]
[VectorPostprocessors]
[grad_bc_left]
type = SideOptimizationNeumannFunctionInnerProduct
variable = temperature_adjoint
function = left_function
boundary = left
execute_on = ADJOINT_TIMESTEP_END
[]
[grad_bc_right]
type = SideOptimizationNeumannFunctionInnerProduct
variable = temperature_adjoint
function = right_function
boundary = right
execute_on = ADJOINT_TIMESTEP_END
[]
[]
[Reporters]
[measure_data]
type = OptimizationData
variable = temperature
measurement_file = 'measurementData.csv'
file_xcoord = 'coordx'
file_ycoord ='y'
file_zcoord = 'z'
file_value = 'weightedMeasurement'
file_variable_weights = 'weight'
variable_weight_names = 'weight'
[]
[params]
type = ConstantReporter
real_vector_names = 'left right'
real_vector_values = '0 0; 0' # Dummy
[]
[vector_sqsum]
type = ParsedVectorRealReductionReporter
name = sqsum
reporter_name= 'measure_data/misfit_values'
initial_value = 0
expression = 'reduction_value+indexed_value*indexed_value'
outputs=none
[]
[obj_sum]
type = ParsedScalarReporter
name = value
reporter_names = 'vector_sqsum/sqsum'
reporter_symbols = 'a'
expression = '0.5*a'
[]
[]
[Outputs]
console = false
exodus = true
[]
(modules/optimization/test/tests/outputs/exodus_optimization_steady/main.i)
[Optimization]
[]
[Mesh]
type = GeneratedMesh
dim = 2
nx = 10
ny = 10
xmax = 2
ymax = 2
[]
[OptimizationReporter]
type = GeneralOptimization
objective_name = objective_value
parameter_names = 'p1'
num_values = '1'
initial_condition = '7'
lower_bounds = '0'
upper_bounds = '10'
[]
[Reporters]
[main]
type = OptimizationData
measurement_points = '0.2 0.2 0
0.8 0.6 0
0.2 1.4 0
0.8 1.8 0'
measurement_values = '226 254 214 146'
[]
[]
[Executioner]
type = Optimize
tao_solver = taoblmvm
petsc_options_iname = '-tao_gatol'
petsc_options_value = '1e-4'
verbose = true
[]
[MultiApps]
[forward]
type = FullSolveMultiApp
input_files = forward.i
execute_on = "FORWARD"
clone_parent_mesh = true
[]
[adjoint]
type = FullSolveMultiApp
input_files = adjoint_iteration_output.i
execute_on = "ADJOINT"
clone_parent_mesh = true
[]
[]
[Transfers]
[toForward]
type = MultiAppReporterTransfer
to_multi_app = forward
from_reporters = 'main/measurement_xcoord
main/measurement_ycoord
main/measurement_zcoord
main/measurement_time
main/measurement_values
OptimizationReporter/p1'
to_reporters = 'measure_data/measurement_xcoord
measure_data/measurement_ycoord
measure_data/measurement_zcoord
measure_data/measurement_time
measure_data/measurement_values
params/p1'
[]
[fromForward_mesh]
type = MultiAppCopyTransfer
from_multi_app = forward
to_multi_app = adjoint
source_variable = 'temperature'
variable = 'temperature_forward'
[]
[fromForward]
type = MultiAppReporterTransfer
from_multi_app = forward
from_reporters = 'measure_data/misfit_values measure_data/objective_value'
to_reporters = 'main/misfit_values OptimizationReporter/objective_value'
[]
[toAdjoint]
type = MultiAppReporterTransfer
to_multi_app = adjoint
from_reporters = 'main/measurement_xcoord
main/measurement_ycoord
main/measurement_zcoord
main/measurement_time
main/misfit_values
OptimizationReporter/p1'
to_reporters = 'misfit/measurement_xcoord
misfit/measurement_ycoord
misfit/measurement_zcoord
misfit/measurement_time
misfit/misfit_values
params/p1'
[]
[fromAdjoint]
type = MultiAppReporterTransfer
from_multi_app = adjoint
from_reporters = 'adjoint_grad/inner_product'
to_reporters = 'OptimizationReporter/grad_p1'
[]
[]
[Outputs]
csv = 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/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/optimizationreporter/mesh_source/forward.i)
[Mesh]
[gmg]
type = GeneratedMeshGenerator
dim = 2
nx = 10
ny = 10
[]
[]
[Variables/u]
[]
[Kernels]
[diff]
type = Diffusion
variable = u
[]
[src]
type = BodyForce
variable = u
function = src_func
[]
[]
[BCs]
[dirichlet]
type = DirichletBC
variable = u
boundary = 'bottom left'
value = 0
[]
[]
[Functions]
[src_func]
type = ParameterMeshFunction
exodus_mesh = parameter_mesh_in.e
parameter_name = src_rep/vals
[]
[]
[Reporters]
[src_rep]
type = ConstantReporter
real_vector_names = 'vals'
real_vector_values = '1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0'
[]
[measure_data]
type = OptimizationData
objective_name = objective_value
variable = u
outputs = none
[]
[]
[Executioner]
type = Steady
solve_type = NEWTON
[]
[AuxVariables]
[source]
[]
[]
[AuxKernels]
[source_aux]
type = FunctionAux
variable = source
function = src_func
[]
[]
[Outputs]
exodus = true
console = false
execute_on = timestep_end
[]
(modules/optimization/test/tests/optimizationreporter/general_opt/point_loads_gen_opt/forward_homogeneous.i)
[Mesh]
[gmg]
type = GeneratedMeshGenerator
dim = 2
nx = 10
ny = 10
xmax = 1
ymax = 1.4
[]
[]
[Variables]
[temperature]
[]
[]
[Kernels]
[heat_conduction]
type = MatDiffusion
variable = temperature
diffusivity = thermal_conductivity
[]
[]
[DiracKernels]
[pt]
type = ReporterPointSource
variable = temperature
x_coord_name = 'point_source/x'
y_coord_name = 'point_source/y'
z_coord_name = 'point_source/z'
value_name = 'point_source/value'
[]
[]
[BCs]
[left]
type = DirichletBC
variable = temperature
boundary = left
value = 0
[]
[right]
type = DirichletBC
variable = temperature
boundary = right
value = 0
[]
[bottom]
type = DirichletBC
variable = temperature
boundary = bottom
value = 0
[]
[top]
type = DirichletBC
variable = temperature
boundary = top
value = 0
[]
[]
[Materials]
[steel]
type = GenericConstantMaterial
prop_names = thermal_conductivity
prop_values = 5
[]
[]
[Executioner]
type = Steady
solve_type = NEWTON
nl_abs_tol = 1e-6
nl_rel_tol = 1e-8
petsc_options_iname = '-pc_type'
petsc_options_value = 'lu'
[]
[VectorPostprocessors]
[point_source]
type = ConstantVectorPostprocessor
vector_names = 'x y z value'
value = '0.2 0.7 0.4;
0.2 0.56 1;
0 0 0;
-1000 120 500'
execute_on = LINEAR
[]
[]
[Reporters]
[measure_data]
type = OptimizationData
variable = temperature
measurement_points = ${measurement_points}
measurement_values = ${measurement_values}
[]
[]
[Outputs]
console = false
file_base = 'forward_homo'
[]
(modules/optimization/test/tests/executioners/constrained/inequality/main_auto_adjoint.i)
# This tests constrained optimization of a linear and constant function
# that are used to apply NuemannBCs on a side.
[Optimization]
[]
[OptimizationReporter]
type = GeneralOptimization
objective_name = objective_value
parameter_names = 'left'
num_values = '2'
initial_condition = '10 10'
lower_bounds = '0'
upper_bounds = '1000'
inequality_names = 'ineq'
[]
[Reporters]
[main]
type = OptimizationData
measurement_points = '0.2 0.2 0'
measurement_values = '207'
file_value = 'measured_value'
[]
[]
[Executioner]
type = Optimize
tao_solver = taoalmm
petsc_options_iname = '-tao_gatol -tao_catol -tao_almm_type -tao_almm_mu_factor -tao_almm_mu_init -tao_almm_subsolver_tao_type'
petsc_options_value = ' 1e-3 1e-3 phr 1.1 1.0 bqnktr'
verbose = true
[]
[MultiApps]
[forward]
type = FullSolveMultiApp
input_files = forward_and_adjoint.i
execute_on = "FORWARD"
[]
[]
[Reporters]
[optInfo]
type = OptimizationInfo
[]
[]
[Transfers]
[toForward]
type = MultiAppReporterTransfer
to_multi_app = forward
from_reporters = 'main/measurement_xcoord
main/measurement_ycoord
main/measurement_zcoord
main/measurement_time
main/measurement_values
OptimizationReporter/left'
to_reporters = 'measure_data/measurement_xcoord
measure_data/measurement_ycoord
measure_data/measurement_zcoord
measure_data/measurement_time
measure_data/measurement_values
params/left'
[]
[fromForward]
type = MultiAppReporterTransfer
from_multi_app = forward
from_reporters = 'measure_data/objective_value
grad_bc_left/inner_product
ineq/ineq
gradient_c/gradient_c'
to_reporters = 'OptimizationReporter/objective_value
OptimizationReporter/grad_left
OptimizationReporter/ineq
OptimizationReporter/grad_ineq'
[]
[]
(modules/optimization/examples/diffusion_reaction_XYDelaunay/forward_and_adjoint.i)
[Mesh]
[square]
type = GeneratedMeshGenerator
dim = 2
nx = 25
ny = 25
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 = nones
[]
[data]
type = OptimizationData
variable = u
objective_name = objective_value
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
nl_abs_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/optimization/test/tests/outputs/exodus_optimization_steady/main_auto_adjoint.i)
[Optimization]
[]
[OptimizationReporter]
type = GeneralOptimization
objective_name = objective_value
parameter_names = 'parameter_results'
num_values = '3'
[]
[Reporters]
[main]
type = OptimizationData
measurement_points = '0.5 0.28 0
0.5 0.6 0
0.5 0.8 0
0.5 1.1 0'
measurement_values = '293 304 315 320'
[]
[]
[Executioner]
type = Optimize
tao_solver = taolmvm
petsc_options_iname = '-tao_gttol -tao_ls_type'
petsc_options_value = '1e-5 unit'
verbose = true
[]
[MultiApps]
[forward]
type = FullSolveMultiApp
input_files = forward_and_adjoint_iteration_output.i
execute_on = "FORWARD"
[]
[]
[Transfers]
# FORWARD transfers
[toForward_measument]
type = MultiAppReporterTransfer
to_multi_app = forward
from_reporters = 'main/measurement_xcoord
main/measurement_ycoord
main/measurement_zcoord
main/measurement_time
main/measurement_values
OptimizationReporter/parameter_results'
to_reporters = 'measure_data/measurement_xcoord
measure_data/measurement_ycoord
measure_data/measurement_zcoord
measure_data/measurement_time
measure_data/measurement_values
point_source/value'
[]
[fromForward]
type = MultiAppReporterTransfer
from_multi_app = forward
from_reporters = 'measure_data/objective_value
gradient/temperature_adjoint'
to_reporters = 'OptimizationReporter/objective_value
OptimizationReporter/grad_parameter_results'
[]
[]
[Outputs]
csv = true
[]
(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
[]
[]
[Preconditioning]
[nl0]
type = SMP
nl_sys = 'nl0'
petsc_options_iname = '-pc_type'
petsc_options_value = 'lu'
[]
[adjoint]
type = SMP
nl_sys = 'adjoint'
petsc_options_iname = '-pc_type'
petsc_options_value = 'lu'
[]
[]
[Executioner]
type = TransientAndAdjoint
forward_system = nl0
adjoint_system = adjoint
num_steps = 100
end_time = 1
nl_rel_tol = 1e-12
l_tol = 1e-12
[]
[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/point_loads/forward_and_adjoint.i)
[Mesh]
[gmg]
type = GeneratedMeshGenerator
dim = 2
nx = 10
ny = 10
xmax = 1
ymax = 1.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 = thermal_conductivity
[]
[]
[DiracKernels]
[pt]
type = ReporterPointSource
variable = temperature
x_coord_name = 'point_source/x'
y_coord_name = 'point_source/y'
z_coord_name = 'point_source/z'
value_name = 'point_source/value'
[]
[misfit]
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
[]
[]
[BCs]
[left]
type = DirichletBC
variable = temperature
boundary = left
value = 300
[]
[right]
type = DirichletBC
variable = temperature
boundary = right
value = 300
[]
[bottom]
type = DirichletBC
variable = temperature
boundary = bottom
value = 300
[]
[top]
type = DirichletBC
variable = temperature
boundary = top
value = 300
[]
[]
[Materials]
[steel]
type = GenericConstantMaterial
prop_names = thermal_conductivity
prop_values = 5
[]
[]
[Preconditioning]
[nl0]
type = SMP
nl_sys = 'nl0'
petsc_options_iname = '-pc_type'
petsc_options_value = 'lu'
[]
[adjoint]
type = SMP
nl_sys = 'adjoint'
petsc_options_iname = '-pc_type'
petsc_options_value = 'lu'
[]
[]
[Executioner]
type = SteadyAndAdjoint
forward_system = nl0
adjoint_system = adjoint
nl_rel_tol = 1e-12
l_tol = 1e-12
[]
[VectorPostprocessors]
[gradient]
type = PointValueSampler
points = '0.2 0.2 0
0.7 0.56 0
0.4 1 0'
variable = temperature_adjoint
sort_by = id
execute_on = ADJOINT_TIMESTEP_END
[]
[]
[Reporters]
[measure_data]
type = OptimizationData
objective_name = objective_value
variable = temperature
[]
[point_source]
type = ConstantReporter
real_vector_names = 'x y z value'
real_vector_values = '0.2 0.7 0.4;
0.2 0.56 1;
0 0 0;
-1000 120 500'
[]
[]
[Outputs]
console = false
[]
(modules/optimization/test/tests/optimizationreporter/bc_load_linearFunction/adjoint.i)
[Mesh]
[]
[Variables]
[adjoint_T]
[]
[]
[Kernels]
[heat_conduction]
type = MatDiffusion
variable = adjoint_T
diffusivity = thermal_conductivity
[]
[]
[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
weight_name = misfit/weight
[]
[]
[Reporters]
[misfit]
type = OptimizationData
variable_weight_names = 'weight'
[]
[params_left]
type = ConstantReporter
real_vector_names = 'vals'
real_vector_values = '0 0' # Dummy
[]
[params_right]
type = ConstantReporter
real_vector_names = 'vals'
real_vector_values = '0' # Dummy
[]
[]
[BCs]
[left]
type = NeumannBC
variable = adjoint_T
boundary = left
value = 0
[]
[right]
type = NeumannBC
variable = adjoint_T
boundary = right
value = 0
[]
[bottom]
type = DirichletBC
variable = adjoint_T
boundary = bottom
value = 0
[]
[top]
type = DirichletBC
variable = adjoint_T
boundary = top
value = 0
[]
[]
[Materials]
[steel]
type = GenericConstantMaterial
prop_names = thermal_conductivity
prop_values = 5
[]
[]
[Executioner]
type = Steady
solve_type = NEWTON
line_search = none
nl_abs_tol = 1e-8
nl_rel_tol = 1e-8
petsc_options_iname = '-ksp_type -pc_type -pc_factor_mat_solver_package'
petsc_options_value = 'preonly lu superlu_dist'
[]
[Functions]
[left_function]
type = ParsedOptimizationFunction
expression = 'a + b*y'
param_symbol_names = 'a b'
param_vector_name = 'params_left/vals'
[]
[right_function]
type = ParsedOptimizationFunction
expression = 'a'
param_symbol_names = 'a'
param_vector_name = 'params_right/vals'
[]
[]
[VectorPostprocessors]
[grad_bc_left]
type = SideOptimizationNeumannFunctionInnerProduct
variable = adjoint_T
function = left_function
boundary = left
[]
[grad_bc_right]
type = SideOptimizationNeumannFunctionInnerProduct
variable = adjoint_T
function = right_function
boundary = right
[]
[]
[Outputs]
console = false
exodus = false
file_base = 'adjoint'
[]
(modules/optimization/test/tests/optimizationreporter/mesh_source/main.i)
[Optimization]
[]
[OptimizationReporter]
type = ParameterMeshOptimization
objective_name = objective_value
parameter_names = 'source'
parameter_meshes = 'parameter_mesh_in.e'
[]
[Reporters]
[main]
type = OptimizationData
# Random points
measurement_points = '0.78193073 0.39115321 0
0.72531893 0.14319403 0
0.14052488 0.86976625 0
0.401893 0.54241797 0
0.02645427 0.43320192 0
0.28856889 0.0035165 0
0.51433644 0.94485949 0
0.29252255 0.7962032 0
0.04925654 0.58018889 0
0.04717357 0.9556314 0'
# sin(x*pi/2)*sin(y*pi/2)
measurement_values = '0.54299466 0.20259611 0.21438235 0.44418597 0.02613676
0.00241892 0.72014019 0.42096307 0.06108895 0.07385256'
[]
[]
[Executioner]
type = Optimize
tao_solver = taolmvm
petsc_options_iname = '-tao_gatol'
petsc_options_value = '1e-4'
verbose = true
[]
[MultiApps]
[forward]
type = FullSolveMultiApp
input_files = forward.i
execute_on = FORWARD
[]
[adjoint]
type = FullSolveMultiApp
input_files = adjoint.i
execute_on = ADJOINT
[]
[]
[Transfers]
[toForward_measument]
type = MultiAppReporterTransfer
to_multi_app = forward
from_reporters = 'main/measurement_xcoord
main/measurement_ycoord
main/measurement_zcoord
main/measurement_time
main/measurement_values
OptimizationReporter/source'
to_reporters = 'measure_data/measurement_xcoord
measure_data/measurement_ycoord
measure_data/measurement_zcoord
measure_data/measurement_time
measure_data/measurement_values
src_rep/vals'
[]
[toAdjoint]
type = MultiAppReporterTransfer
to_multi_app = adjoint
from_reporters = 'main/measurement_xcoord
main/measurement_ycoord
main/measurement_zcoord
main/measurement_time
main/misfit_values
OptimizationReporter/source'
to_reporters = 'misfit/measurement_xcoord
misfit/measurement_ycoord
misfit/measurement_zcoord
misfit/measurement_time
misfit/misfit_values
src_rep/vals'
[]
[fromForward]
type = MultiAppReporterTransfer
from_multi_app = forward
from_reporters = 'measure_data/misfit_values measure_data/objective_value'
to_reporters = 'main/misfit_values OptimizationReporter/objective_value'
[]
[fromadjoint]
type = MultiAppReporterTransfer
from_multi_app = adjoint
from_reporters = 'gradient_vpp/inner_product'
to_reporters = 'OptimizationReporter/grad_source'
[]
[]
(modules/optimization/test/tests/optimizationreporter/function_misfit/forward_and_adjoint_side.i)
[Mesh]
[gmg]
type = GeneratedMeshGenerator
dim = 2
nx = 15
ny = 15
xmin = 0
ymin = 0
xmax = 1
ymax = 1.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 = thermal_conductivity
[]
[]
[DiracKernels]
[pt]
type = ReporterPointSource
variable = temperature
x_coord_name = 'point_source/x'
y_coord_name = 'point_source/y'
z_coord_name = 'point_source/z'
value_name = 'point_source/value'
[]
[]
[BCs]
[left]
type = DirichletBC
variable = temperature
boundary = left
value = 300
[]
[right]
type = DirichletBC
variable = temperature
boundary = right
value = 300
[]
[bottom]
type = DirichletBC
variable = temperature
boundary = bottom
value = 300
[]
# apply gradient material as a side force since the objective integral is only
# over this side
[top]
type = MatNeumannBC
boundary = top
boundary_material = obj_misfit_gradient
variable = temperature_adjoint
value = 1
[]
[]
[Materials]
[steel]
type = GenericConstantMaterial
prop_names = thermal_conductivity
prop_values = 5
[]
# Create two materials.
# 1. Material which the integral of is our objective
# 2. dM/du material which is used for our adjoint problem
[beam]
type = MisfitReporterOffsetFunctionMaterial
x_coord_name = measure_data/measurement_xcoord
y_coord_name = measure_data/measurement_ycoord
z_coord_name = measure_data/measurement_zcoord
measurement_value_name = measure_data/measurement_values
forward_variable = temperature
property_name = obj_misfit
function = gauss
[]
[]
[Functions]
[gauss]
type = ParsedFunction
expression = 'exp(-2.0 *(x^2 + y^2 + z^2)/(beam_radii^2))'
symbol_names = 'beam_radii'
symbol_values = 0.1
[]
[]
[Executioner]
type = SteadyAndAdjoint
forward_system = nl0
adjoint_system = adjoint
nl_rel_tol = 1e-12
nl_abs_tol = 1e-10
l_tol = 1e-12
petsc_options_iname = '-pc_type'
petsc_options_value = 'lu'
[]
[VectorPostprocessors]
[gradient]
type = PointValueSampler
points = '0.2 1.1 0
0.7 1.1 0
0.4 1.1 0'
variable = temperature_adjoint
sort_by = id
execute_on = ADJOINT_TIMESTEP_END
[]
[]
[Postprocessors]
[objective]
type = SideIntegralMaterialProperty
boundary = top
property = obj_misfit
execute_on = 'TIMESTEP_END'
[]
[largest_adjoint]
type = NodalExtremeValue
variable = temperature_adjoint
execute_on = ADJOINT_TIMESTEP_END
[]
[]
[Reporters]
[measure_data]
type = OptimizationData
variable = temperature
[]
[point_source]
type = ConstantReporter
real_vector_names = 'x y z value'
real_vector_values = '0.2 0.7 0.4;
1.1 1.1 1.1;
0 0 0;
-1000 120 500'
[]
[]
[Outputs]
console = false
[]
(modules/optimization/test/tests/optimizationreporter/point_loads/main.i)
# DO NOT CHANGE THIS TEST
# this test is documented as an example in forceInv_pointLoads.md
# if this test is changed, the figures will need to be updated.
measurement_points = '0.5 0.28 0
0.5 0.6 0
0.5 0.8 0
0.5 1.1 0'
measurement_values = '293 304 315 320'
[Optimization]
[]
[OptimizationReporter]
type = GeneralOptimization
objective_name = objective_value
parameter_names = 'parameter_results'
num_values = '3'
[]
[Reporters]
[main]
type = OptimizationData
measurement_points = ${measurement_points}
measurement_values = ${measurement_values}
[]
[]
[Executioner]
type = Optimize
tao_solver = taonls
petsc_options_iname = '-tao_gttol -tao_max_it -tao_nls_pc_type -tao_nls_ksp_type'
petsc_options_value = '1e-5 10 none cg'
verbose = true
[]
[MultiApps]
[forward]
type = FullSolveMultiApp
input_files = forward.i
execute_on = "FORWARD"
[]
[adjoint]
type = FullSolveMultiApp
input_files = adjoint.i
execute_on = "ADJOINT"
[]
[homogeneousForward]
type = FullSolveMultiApp
input_files = forward_homogeneous.i
execute_on = "HOMOGENEOUS_FORWARD"
[]
[]
[Transfers]
# FORWARD transfers
[toForward_measument]
type = MultiAppReporterTransfer
to_multi_app = forward
from_reporters = 'main/measurement_xcoord
main/measurement_ycoord
main/measurement_zcoord
main/measurement_time
main/measurement_values
OptimizationReporter/parameter_results'
to_reporters = 'measure_data/measurement_xcoord
measure_data/measurement_ycoord
measure_data/measurement_zcoord
measure_data/measurement_time
measure_data/measurement_values
point_source/value'
[]
[fromForward]
type = MultiAppReporterTransfer
from_multi_app = forward
# Note: We are transferring the misfit values into main misfit
from_reporters = 'measure_data/objective_value measure_data/misfit_values'
to_reporters = 'OptimizationReporter/objective_value main/misfit_values'
[]
# ADJOINT transfers
#NOTE: the adjoint variable we are transferring is actually the gradient
[toAdjoint]
type = MultiAppReporterTransfer
to_multi_app = adjoint
from_reporters = 'main/measurement_xcoord
main/measurement_ycoord
main/measurement_zcoord
main/measurement_time
main/misfit_values'
to_reporters = 'misfit/measurement_xcoord
misfit/measurement_ycoord
misfit/measurement_zcoord
misfit/measurement_time
misfit/misfit_values'
[]
[fromAdjoint]
type = MultiAppReporterTransfer
from_multi_app = adjoint
from_reporters = 'gradient/adjoint'
to_reporters = 'OptimizationReporter/grad_parameter_results'
[]
# HESSIAN transfers. Same as forward.
[toHomoForward]
type = MultiAppReporterTransfer
multi_app = homogeneousForward
direction = to_multiapp
from_reporters = 'main/measurement_xcoord
main/measurement_ycoord
main/measurement_zcoord
main/measurement_time
main/measurement_values
OptimizationReporter/parameter_results'
to_reporters = 'measure_data/measurement_xcoord
measure_data/measurement_ycoord
measure_data/measurement_zcoord
measure_data/measurement_time
measure_data/measurement_values
point_source/value'
[]
[fromHomoForward]
type = MultiAppReporterTransfer
multi_app = homogeneousForward
direction = from_multiapp
# Note: We are transferring the simulation values into misfit
# this has to be done when using general opt and homogenous forward.
from_reporters = 'measure_data/simulation_values'
to_reporters = 'main/misfit_values'
[]
[]
[Reporters]
[optInfo]
type = OptimizationInfo
[]
[]
[Outputs]
csv = true
[]
(modules/combined/test/tests/optimization/invOpt_mechanics/forward.i)
[Mesh]
[]
[Variables]
[disp_x]
[]
[disp_y]
[]
[]
[Kernels]
[TensorMechanics]
use_displaced_mesh = false
displacements = 'disp_x disp_y'
[]
[]
[BCs]
[left_ux]
type = DirichletBC
variable = disp_x
boundary = left
value = 0
[]
[left_uy]
type = DirichletBC
variable = disp_y
boundary = left
value = 0
[]
[right_fy]
type = FunctionNeumannBC
variable = disp_y
boundary = right
function = right_fy_func
[]
[]
[Functions]
[right_fy_func]
type = ParsedOptimizationFunction
expression = 'val'
param_symbol_names = 'val'
param_vector_name = 'params/right_fy_value'
[]
[]
[Materials]
[elasticity]
type = ComputeIsotropicElasticityTensor
youngs_modulus = 10e3
poissons_ratio = 0.3
[]
[strain]
type = ComputeSmallStrain
displacements = 'disp_x disp_y'
[]
[stress]
type = ComputeLinearElasticStress
[]
[]
[Executioner]
type = Steady
solve_type = PJFNK
nl_abs_tol = 1e-6
nl_rel_tol = 1e-8
petsc_options_iname = '-pc_type'
petsc_options_value = 'lu'
[]
[VectorPostprocessors]
[point_sample]
type = PointValueSampler
variable = 'disp_y'
points = '5.0 1.0 0'
sort_by = x
[]
[]
[Reporters]
[measure_data]
type = OptimizationData
objective_name = objective_value
variable = disp_y
[]
[params]
type = ConstantReporter
real_vector_names = 'right_fy_value'
real_vector_values = '0' # Dummy value
[]
[]
[Outputs]
csv = false
console = false
exodus = false
file_base = 'forward'
[]
(modules/optimization/test/tests/optimizationreporter/mesh_source/adjoint.i)
[Mesh]
[gmg]
type = GeneratedMeshGenerator
dim = 2
nx = 10
ny = 10
[]
[]
[Variables/adjoint_u]
[]
[Kernels]
[heat_conduction]
type = Diffusion
variable = adjoint_u
[]
[]
[DiracKernels]
[pt]
type = ReporterPointSource
variable = adjoint_u
x_coord_name = misfit/measurement_xcoord
y_coord_name = misfit/measurement_ycoord
z_coord_name = misfit/measurement_zcoord
value_name = misfit/misfit_values
[]
[]
[BCs]
[dirichlet]
type = DirichletBC
variable = adjoint_u
boundary = 'bottom left'
value = 0
[]
[]
[Reporters]
[misfit]
type = OptimizationData
[]
[src_rep]
type = ConstantReporter
real_vector_names = 'vals'
real_vector_values = '1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0'
[]
[]
[Executioner]
type = Steady
solve_type = NEWTON
[]
[Functions]
[src_func]
type = ParameterMeshFunction
exodus_mesh = parameter_mesh_in.e
parameter_name = src_rep/vals
[]
[]
[VectorPostprocessors]
[gradient_vpp]
type = ElementOptimizationSourceFunctionInnerProduct
variable = adjoint_u
function = src_func
[]
[]
[Outputs]
console = false
[]
(modules/optimization/test/tests/optimizationreporter/general_opt/point_loads_gen_opt/main_auto_adjoint_transfer_data.i)
[Optimization]
[]
[OptimizationReporter]
type = GeneralOptimization
objective_name = misfit_norm
parameter_names = 'parameter_results'
num_values = '3'
[]
[Reporters]
[measure_data]
type = OptimizationData
measurement_points = '0.5 0.28 0
0.5 0.6 0
0.5 0.8 0
0.5 1.1 0'
measurement_values = '293 304 315 320'
[]
[]
[Executioner]
type = Optimize
tao_solver = taolmvm
petsc_options_iname = '-tao_gttol -tao_ls_type'
petsc_options_value = '1e-5 unit'
verbose = true
[]
[MultiApps]
[forward]
type = FullSolveMultiApp
input_files = forward_and_adjoint_transfer_data.i
execute_on = "FORWARD"
[]
[]
[Transfers]
# FORWARD transfers
[toForward_measument]
type = MultiAppReporterTransfer
to_multi_app = forward
from_reporters = 'measure_data/measurement_xcoord
measure_data/measurement_ycoord
measure_data/measurement_zcoord
measure_data/measurement_time
measure_data/measurement_values
OptimizationReporter/parameter_results'
to_reporters = 'measure_data/measurement_xcoord
measure_data/measurement_ycoord
measure_data/measurement_zcoord
measure_data/measurement_time
measure_data/measurement_values
point_source/value'
[]
[fromForward]
type = MultiAppReporterTransfer
from_multi_app = forward
from_reporters = 'gradient/temperature_adjoint
measure_data/misfit_norm'
to_reporters = 'OptimizationReporter/grad_parameter_results
OptimizationReporter/misfit_norm'
[]
[]
[Outputs]
csv = true
file_base = main_out
[]
(modules/optimization/test/tests/optimizationreporter/point_loads/forward_homogeneous.i)
# DO NOT CHANGE THIS TEST
# this test is documented as an example in forceInv_pointLoads.md
# if this test is changed, the figures will need to be updated.
[Mesh]
[gmg]
type = GeneratedMeshGenerator
dim = 2
nx = 10
ny = 10
xmax = 1
ymax = 1.4
[]
[]
[Variables]
[temperature]
[]
[]
[Kernels]
[heat_conduction]
type = MatDiffusion
variable = temperature
diffusivity = thermal_conductivity
[]
[]
[DiracKernels]
[pt]
type = ReporterPointSource
variable = temperature
x_coord_name = 'point_source/x'
y_coord_name = 'point_source/y'
z_coord_name = 'point_source/z'
value_name = 'point_source/value'
[]
[]
[BCs]
[left]
type = DirichletBC
variable = temperature
boundary = left
value = 0
[]
[right]
type = DirichletBC
variable = temperature
boundary = right
value = 0
[]
[bottom]
type = DirichletBC
variable = temperature
boundary = bottom
value = 0
[]
[top]
type = DirichletBC
variable = temperature
boundary = top
value = 0
[]
[]
[Materials]
[steel]
type = GenericConstantMaterial
prop_names = thermal_conductivity
prop_values = 5
[]
[]
[Executioner]
type = Steady
solve_type = NEWTON
nl_abs_tol = 1e-6
nl_rel_tol = 1e-8
petsc_options_iname = '-pc_type'
petsc_options_value = 'lu'
[]
[VectorPostprocessors]
[point_source]
type = ConstantVectorPostprocessor
vector_names = 'x y z value'
value = '0.2 0.7 0.4;
0.2 0.56 1;
0 0 0;
-1000 120 500'
execute_on = LINEAR
[]
[]
[Reporters]
[measure_data]
type = OptimizationData
variable = temperature
[]
[]
[Outputs]
console = false
file_base = 'forward_homo'
[]
(modules/optimization/test/tests/optimizationreporter/bimaterial/main_auto_adjoint.i)
# This main.i file runs the subapps model.i and grad.i, using an FullSolveMultiApp
# The purpose of main.i is to find the two diffusivity_values
# (one in the bottom material of model.i, and one in the top material of model.i)
# such that the misfit between experimental observations (defined in model.i) and MOOSE predictions is minimised.
# The adjoint computed in grad.i is used to compute the gradient for the gradient based LMVM solver in TAO
# PETSc-TAO optimisation is used to perform this inversion
#
[Optimization]
[]
[OptimizationReporter]
type = GeneralOptimization
objective_name = objective_value
parameter_names = diffusivity_values
num_values = 2 # diffusivity in the bottom material and in the top material of model.i
initial_condition = '3 4' # the expected result is about '1 10' so this initial condition is not too bad
lower_bounds = '1'
upper_bounds = '20'
[]
[Reporters]
[main]
type = OptimizationData
measurement_file = 'synthetic_data.csv'
file_value = 'temperature'
[]
[]
[Executioner]
type = Optimize
tao_solver = taoblmvm
petsc_options_iname = '-tao_gatol'
petsc_options_value = '1e-3'
## THESE OPTIONS ARE FOR TESTING THE ADJOINT GRADIENT
# petsc_options_iname='-tao_max_it -tao_fd_test -tao_test_gradient -tao_fd_gradient -tao_fd_delta -tao_gatol'
# petsc_options_value='1 true true false 1e-8 0.1'
# petsc_options = '-tao_test_gradient_view'
verbose = true
[]
[MultiApps]
[forward]
type = FullSolveMultiApp
input_files = model_and_adjoint.i
execute_on = FORWARD
[]
[]
[Transfers]
[toForward] #pass the coordinates where we knew the measurements to the forward model to do the extraction of the simulation data at the location of the measurements to compute the misfit
type = MultiAppReporterTransfer
to_multi_app = forward
from_reporters = 'main/measurement_xcoord
main/measurement_ycoord
main/measurement_zcoord
main/measurement_time
main/measurement_values
OptimizationReporter/diffusivity_values'
to_reporters = 'measure_data/measurement_xcoord
measure_data/measurement_ycoord
measure_data/measurement_zcoord
measure_data/measurement_time
measure_data/measurement_values
data/diffusivity'
[]
[from_forward] #get the simulation values
type = MultiAppReporterTransfer
from_multi_app = forward
from_reporters = 'measure_data/objective_value
gradvec/inner_product'
to_reporters = 'OptimizationReporter/objective_value
OptimizationReporter/grad_diffusivity_values'
[]
[]
[Outputs]
console = true
csv = true
[]
(modules/optimization/test/tests/optimizationreporter/point_loads/forward.i)
# DO NOT CHANGE THIS TEST
# this test is documented as an example in forceInv_pointLoads.md
# if this test is changed, the figures will need to be updated.
[Mesh]
[gmg]
type = GeneratedMeshGenerator
dim = 2
nx = 10
ny = 10
xmax = 1
ymax = 1.4
[]
[]
[Variables]
[temperature]
[]
[]
[Kernels]
[heat_conduction]
type = MatDiffusion
variable = temperature
diffusivity = thermal_conductivity
[]
[]
[DiracKernels]
[pt]
type = ReporterPointSource
variable = temperature
x_coord_name = 'point_source/x'
y_coord_name = 'point_source/y'
z_coord_name = 'point_source/z'
value_name = 'point_source/value'
[]
[]
[BCs]
[left]
type = DirichletBC
variable = temperature
boundary = left
value = 300
[]
[right]
type = DirichletBC
variable = temperature
boundary = right
value = 300
[]
[bottom]
type = DirichletBC
variable = temperature
boundary = bottom
value = 300
[]
[top]
type = DirichletBC
variable = temperature
boundary = top
value = 300
[]
[]
[Materials]
[steel]
type = GenericConstantMaterial
prop_names = thermal_conductivity
prop_values = 5
[]
[]
[Executioner]
type = Steady
solve_type = NEWTON
nl_abs_tol = 1e-6
nl_rel_tol = 1e-8
petsc_options_iname = '-pc_type'
petsc_options_value = 'lu'
[]
[VectorPostprocessors]
[point_source]
type = ConstantVectorPostprocessor
vector_names = 'x y z value'
value = '0.2 0.7 0.4;
0.2 0.56 1;
0 0 0;
-1000 120 500'
execute_on = LINEAR
[]
[vertical]
type = LineValueSampler
variable = 'temperature'
start_point = '0.5 0 0'
end_point = '0.5 1.4 0'
num_points = 21
sort_by = y
[]
[]
[Reporters]
[measure_data]
type = OptimizationData
objective_name = objective_value
variable = temperature
[]
[]
[Outputs]
console = false
file_base = 'forward'
[]
(modules/combined/test/tests/optimization/invOpt_bc_convective/adjoint.i)
[Mesh]
[gmg]
type = GeneratedMeshGenerator
dim = 2
nx = 10
ny = 20
xmax = 1
ymax = 2
[]
[]
[AuxVariables]
[temperature_forward]
[]
[T2]
[]
[]
[AuxKernels]
[TT]
type = ParsedAux
args = 'temperature temperature_forward'
variable = T2
function = 'temperature*(100-temperature_forward)'
[]
[]
[Variables]
[temperature]
[]
[]
[Kernels]
[heat_conduction]
type = ADHeatConduction
variable = temperature
[]
[]
[DiracKernels]
[pt]
type = ReporterPointSource
variable = temperature
x_coord_name = misfit/measurement_xcoord
y_coord_name = misfit/measurement_ycoord
z_coord_name = misfit/measurement_zcoord
value_name = misfit/misfit_values
[]
[]
[Reporters]
[misfit]
type = OptimizationData
[]
[params]
type = ConstantReporter
real_vector_names = 'vals'
real_vector_values = '0' # Dummy value
[]
[]
[BCs]
[left]
type = ConvectiveFluxFunction
variable = temperature
boundary = 'left'
T_infinity = 0.0
coefficient = function1
[]
[right]
type = NeumannBC
variable = temperature
boundary = right
value = 0
[]
[bottom]
type = DirichletBC
variable = temperature
boundary = bottom
value = 0
[]
[top]
type = DirichletBC
variable = temperature
boundary = top
value = 0
[]
[]
[Materials]
[steel]
type = ADGenericConstantMaterial
prop_names = thermal_conductivity
prop_values = 5
[]
[]
[Executioner]
type = Steady
solve_type = PJFNK
nl_abs_tol = 1e-6
nl_rel_tol = 1e-8
petsc_options_iname = '-pc_type'
petsc_options_value = 'lu'
[]
[Functions]
[function1]
type = ParsedOptimizationFunction
expression = 'a'
param_symbol_names = 'a'
param_vector_name = 'params/vals'
[]
[]
[VectorPostprocessors]
[adjoint_pt]
type = SideOptimizationNeumannFunctionInnerProduct
variable = T2
function = function1
boundary = left
[]
[]
[Outputs]
console = false
exodus = false
file_base = 'adjoint'
[]
(modules/optimization/test/tests/optimizationreporter/constant_heat_source/adjoint_nonLinear.i)
[Mesh]
type = GeneratedMesh
dim = 2
nx = 10
ny = 10
xmax = 2
ymax = 2
[]
[Variables]
[adjoint_T]
[]
[]
[AuxVariables]
[T]
[]
[]
[Kernels]
[heat_conduction]
type = MatDiffusion
variable = adjoint_T
diffusivity = thermal_conductivity
[]
[]
[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
[]
[]
[Reporters]
[misfit]
type = OptimizationData
[]
[params]
type = ConstantReporter
real_vector_names = 'q'
real_vector_values = '0' # Dummy value
[]
[]
[BCs]
[left]
type = NeumannBC
variable = adjoint_T
boundary = left
value = 0
[]
[right]
type = NeumannBC
variable = adjoint_T
boundary = right
value = 0
[]
[bottom]
type = DirichletBC
variable = adjoint_T
boundary = bottom
value = 0
[]
[top]
type = DirichletBC
variable = adjoint_T
boundary = top
value = 0
[]
[]
[Materials]
[steel]
type = ParsedMaterial
f_name = 'thermal_conductivity'
function = '.01*T'
args = 'T'
[]
[]
[Executioner]
type = Steady
solve_type = PJFNK
nl_abs_tol = 1e-8
nl_rel_tol = 1e-8
petsc_options_iname = '-ksp_type -pc_type -pc_factor_mat_solver_package'
petsc_options_value = 'preonly lu superlu_dist'
[]
[Functions]
[volumetric_heat_func]
type = ParsedOptimizationFunction
expression = q
param_symbol_names = 'q'
param_vector_name = 'params/q'
[]
[]
[VectorPostprocessors]
[gradient_vpp]
type = ElementOptimizationSourceFunctionInnerProduct
variable = adjoint_T
function = volumetric_heat_func
[]
[]
[Outputs]
console = false
file_base = 'adjoint_nl'
[]
(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/combined/test/tests/optimization/invOpt_nonlinear/homogeneous_forward.i)
[Executioner]
type = Steady
solve_type = NEWTON
line_search = none
#nl_forced_its = 1
nl_abs_tol = 1e-12
nl_rel_tol = 1e-12
petsc_options_iname = '-pc_type'
petsc_options_value = 'lu'
[]
[Mesh]
[]
[Variables]
[T]
[]
[]
[AuxVariables]
[forwardT]
[]
[_dDdTgradT]
order = CONSTANT
family = MONOMIAL_VEC
[]
[]
[Kernels]
[heat_conduction]
type = ADHeatConduction
thermal_conductivity = 'linearized_conductivity'
variable = T
[]
[heat_source]
type = ADMatHeatSource
material_property = 'volumetric_heat'
variable = T
[]
[advection]
type = ConservativeAdvection
velocity = _dDdTgradT
variable = T
upwinding_type = full #Full upwinding gives somewhat better results
[]
[]
[AuxKernels]
[_dDdTgradT]
type = ADFunctorElementalGradientAux
functor = forwardT
variable = _dDdTgradT
factor_matprop = '_dDdT'
[]
[]
[Materials]
[LinearizedConductivity]
type = ADParsedMaterial
f_name = 'linearized_conductivity'
function = '10+500*forwardT'
args = 'forwardT'
[]
[_dDdT]
type = ADParsedMaterial
f_name = '_dDdT' # "_" represents negation
function = '-500'
args = 'forwardT'
[]
[volumetric_heat]
type = ADGenericFunctionMaterial
prop_names = 'volumetric_heat'
prop_values = 'volumetric_heat_func'
[]
[]
[Functions]
[volumetric_heat_func]
type = ParsedOptimizationFunction
expression = q
param_symbol_names = 'q'
param_vector_name = 'params/heat_source'
[]
[]
[BCs]
[left]
type = NeumannBC
variable = T
boundary = left
value = 0
[]
[right]
type = NeumannBC
variable = T
boundary = right
value = 0
[]
[bottom]
type = DirichletBC
variable = T
boundary = bottom
value = 0
[]
[top]
type = DirichletBC
variable = T
boundary = top
value = 0
[]
[]
[Reporters]
[measurement_locations]
type = OptimizationData
variable = T
[]
[params]
type = ConstantReporter
real_vector_names = 'heat_source'
real_vector_values = '0' # Dummy
[]
[]
[Outputs]
console = false
[]
(modules/optimization/test/tests/optimizationreporter/constant_heat_source/forward.i)
[Mesh]
type = GeneratedMesh
dim = 2
nx = 10
ny = 10
xmax = 2
ymax = 2
[]
[Variables]
[temperature]
[]
[]
[Kernels]
[heat_conduction]
type = MatDiffusion
variable = temperature
diffusivity = thermal_conductivity
[]
[heat_source]
type = BodyForce
function = volumetric_heat_func
variable = temperature
[]
[]
[BCs]
[left]
type = NeumannBC
variable = temperature
boundary = left
value = 0
[]
[right]
type = NeumannBC
variable = temperature
boundary = right
value = 0
[]
[bottom]
type = DirichletBC
variable = temperature
boundary = bottom
value = 200
[]
[top]
type = DirichletBC
variable = temperature
boundary = top
value = 100
[]
[]
[Functions]
[volumetric_heat_func]
type = ParsedOptimizationFunction
expression = q
param_symbol_names = 'q'
param_vector_name = 'params/q'
[]
[]
[Materials]
[steel]
type = GenericConstantMaterial
prop_names = thermal_conductivity
prop_values = 5
[]
[]
[Executioner]
type = Steady
solve_type = PJFNK
petsc_options_iname = '-ksp_type -pc_type -pc_factor_mat_solver_package'
petsc_options_value = 'preonly lu superlu_dist'
[]
[Reporters]
[measure_data]
type = OptimizationData
objective_name = objective_value
variable = temperature
[]
[params]
type = ConstantReporter
real_vector_names = 'q'
real_vector_values = '0' # Dummy value
[]
[]
[Outputs]
console = false
file_base = 'forward'
[]
(modules/optimization/test/tests/optimizationreporter/material/forward.i)
[Mesh]
[]
[Variables]
[temperature]
[]
[]
[Kernels]
[heat_conduction]
type = MatDiffusion
variable = temperature
diffusivity = thermal_conductivity
[]
[heat_source]
type = BodyForce
value = 1000
variable = temperature
[]
[]
[BCs]
[left]
type = NeumannBC
variable = temperature
boundary = left
value = 0
[]
[right]
type = NeumannBC
variable = temperature
boundary = right
value = 0
[]
[bottom]
type = DirichletBC
variable = temperature
boundary = bottom
value = 200
[]
[top]
type = DirichletBC
variable = temperature
boundary = top
value = 100
[]
[]
[Functions]
[thermo_conduct]
type = ParsedOptimizationFunction
expression = 'alpha'
param_symbol_names = 'alpha'
param_vector_name = 'params/p1'
[]
[]
[Materials]
[steel]
type = GenericFunctionMaterial
prop_names = 'thermal_conductivity'
prop_values = 'thermo_conduct'
[]
[]
[Executioner]
type = Steady
solve_type = NEWTON
nl_abs_tol = 1e-8
nl_rel_tol = 1e-8
petsc_options_iname = '-ksp_type -pc_type -pc_factor_mat_solver_package'
petsc_options_value = 'preonly lu superlu_dist'
[]
[Reporters]
[measure_data]
type = OptimizationData
objective_name = objective_value
variable = temperature
[]
[params]
type = ConstantReporter
real_vector_names = 'p1'
real_vector_values = '0' # Dummy value
[]
[]
[Outputs]
console = false
file_base = 'forward'
[]
(modules/optimization/test/tests/optimizationreporter/nonlinear_material/main.i)
[Optimization]
[]
[OptimizationReporter]
type = GeneralOptimization
objective_name = objective_value
parameter_names = 'heat_source'
num_values = '1'
initial_condition = '0'
lower_bounds = '0.1'
upper_bounds = '10000'
[]
[Reporters]
[main]
type = OptimizationData
measurement_points = '0.2 0.2 0
0.8 0.6 0
0.2 1.4 0
0.8 1.8 0'
measurement_values = '1.98404 1.91076 1.56488 1.23863'
[]
[]
[Executioner]
type = Optimize
tao_solver = taolmvm
petsc_options_iname = '-tao_gttol'
petsc_options_value = ' 1e-5'
verbose = true
[]
[MultiApps]
[forward]
type = FullSolveMultiApp
input_files = forward_and_adjoint.i
execute_on = FORWARD
[]
[]
[Transfers]
[to_forward]
type = MultiAppReporterTransfer
to_multi_app = forward
from_reporters = 'main/measurement_xcoord
main/measurement_ycoord
main/measurement_zcoord
main/measurement_time
main/measurement_values
OptimizationReporter/heat_source'
to_reporters = 'measurement_locations/measurement_xcoord
measurement_locations/measurement_ycoord
measurement_locations/measurement_zcoord
measurement_locations/measurement_time
measurement_locations/measurement_values
params/heat_source'
[]
[from_forward]
type = MultiAppReporterTransfer
from_multi_app = forward
from_reporters = 'measurement_locations/objective_value
gradient_vpp/inner_product'
to_reporters = 'OptimizationReporter/objective_value
OptimizationReporter/grad_heat_source'
[]
[]
[Outputs]
csv = true
[]
(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/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
[]
[Preconditioning]
[nl0]
type = SMP
nl_sys = 'nl0'
petsc_options_iname = '-pc_type'
petsc_options_value = 'lu'
full = true
[]
[adjoint]
type = SMP
nl_sys = 'adjoint'
petsc_options_iname = '-pc_type'
petsc_options_value = 'lu'
full = true
[]
[]
[Executioner]
type = SteadyAndAdjoint
forward_system = nl0
adjoint_system = adjoint
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/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
[]
[]
[Preconditioning]
[nl0]
type = SMP
nl_sys = 'nl0'
petsc_options_iname = '-pc_type'
petsc_options_value = 'lu'
[]
[adjoint]
type = SMP
nl_sys = 'adjoint'
petsc_options_iname = '-pc_type'
petsc_options_value = 'lu'
[]
[]
[Executioner]
type = SteadyAndAdjoint
forward_system = nl0
adjoint_system = adjoint
nl_forced_its = 1
line_search = none
nl_abs_tol = 1e-8
[]
[Outputs]
console = false
[]
(modules/optimization/test/tests/outputs/exodus_optimization_steady/adjoint_iteration_output.i)
[Mesh]
[]
[Variables]
[adjointVar]
[]
[]
[Kernels]
[heat_conduction]
type = MatDiffusion
variable = adjointVar
diffusivity = thermal_conductivity
[]
[]
[DiracKernels]
[pt]
type = ReporterPointSource
variable = adjointVar
x_coord_name = misfit/measurement_xcoord
y_coord_name = misfit/measurement_ycoord
z_coord_name = misfit/measurement_zcoord
value_name = misfit/misfit_values
[]
[]
[Reporters]
[misfit]
type = OptimizationData
[]
[params]
type = ConstantReporter
real_vector_names = 'p1'
real_vector_values = '0' # Dummy value
[]
[]
[AuxVariables]
[temperature_forward]
[]
[]
[BCs]
[left]
type = NeumannBC
variable = adjointVar
boundary = left
value = 0
[]
[right]
type = NeumannBC
variable = adjointVar
boundary = right
value = 0
[]
[bottom]
type = DirichletBC
variable = adjointVar
boundary = bottom
value = 0
[]
[top]
type = DirichletBC
variable = adjointVar
boundary = top
value = 0
[]
[]
[Functions]
[thermo_conduct]
type = ParsedOptimizationFunction
expression = 'alpha'
param_symbol_names = 'alpha'
param_vector_name = 'params/p1'
[]
[]
[Materials]
[thermalProp]
type = GenericFunctionMaterial
prop_names = 'thermal_conductivity'
prop_values = 'thermo_conduct'
[]
[]
[Executioner]
type = Steady
solve_type = PJFNK
nl_abs_tol = 1e-8
nl_rel_tol = 1e-8
petsc_options_iname = '-ksp_type -pc_type -pc_factor_mat_solver_package'
petsc_options_value = 'preonly lu superlu_dist'
[]
[VectorPostprocessors]
[adjoint_grad]
type = ElementOptimizationDiffusionCoefFunctionInnerProduct
variable = adjointVar
forward_variable = temperature_forward
function = thermo_conduct
[]
[]
[Outputs]
console = false
file_base = 'adjoint'
[exodus]
type = ExodusOptimizationSteady
execute_on = 'TIMESTEP_END'
[]
[]
(modules/optimization/examples/simpleTransient/main_mesh.i)
[Optimization]
[]
[OptimizationReporter]
type = ParameterMeshOptimization
objective_name = objective_value
parameter_names = 'source'
parameter_meshes = source_mesh_in.e
num_parameter_times = 11
[]
[Reporters]
[main]
type = OptimizationData
[]
[]
[MultiApps]
[forward]
type = FullSolveMultiApp
input_files = forward_mesh.i
execute_on = FORWARD
[]
[adjoint]
type = FullSolveMultiApp
input_files = adjoint_mesh.i
execute_on = ADJOINT
[]
[]
[Transfers]
[to_forward]
type = MultiAppReporterTransfer
to_multi_app = forward
from_reporters = 'OptimizationReporter/source'
to_reporters = 'src_values/values'
[]
[from_forward]
type = MultiAppReporterTransfer
from_multi_app = forward
from_reporters = 'measured_data/misfit_values measured_data/objective_value'
to_reporters = 'main/misfit_values OptimizationReporter/objective_value'
[]
[to_adjoint]
type = MultiAppReporterTransfer
to_multi_app = adjoint
from_reporters = 'OptimizationReporter/source main/misfit_values'
to_reporters = 'src_values/values measured_data/misfit_values'
[]
[from_adjoint]
type = MultiAppReporterTransfer
from_multi_app = adjoint
from_reporters = 'adjoint/inner_product'
to_reporters = 'OptimizationReporter/grad_source'
[]
[]
[Executioner]
type = Optimize
solve_on = none
tao_solver = taolmvm
petsc_options_iname = '-tao_gatol -tao_ls_type'
petsc_options_value = '1e-2 unit'
verbose = true
[]
(modules/optimization/test/tests/optimizationreporter/material/main.i)
[Optimization]
[]
[Mesh]
type = GeneratedMesh
dim = 2
nx = 10
ny = 10
xmax = 2
ymax = 2
[]
[OptimizationReporter]
type = GeneralOptimization
objective_name = objective_value
parameter_names = 'p1'
num_values = '1'
initial_condition = '7'
lower_bounds = '0'
upper_bounds = '10'
[]
[Reporters]
[main]
type = OptimizationData
measurement_points = '0.2 0.2 0
0.8 0.6 0
0.2 1.4 0
0.8 1.8 0'
measurement_values = '226 254 214 146'
[]
[]
[Executioner]
type = Optimize
tao_solver = taoblmvm
petsc_options_iname = '-tao_gatol'
petsc_options_value = '0.0001'
verbose = true
[]
[MultiApps]
[forward]
type = FullSolveMultiApp
input_files = forward.i
execute_on = "FORWARD"
clone_parent_mesh = true
[]
[adjoint]
type = FullSolveMultiApp
input_files = adjoint.i
execute_on = "ADJOINT"
clone_parent_mesh = true
[]
[]
[Transfers]
[toForward]
type = MultiAppReporterTransfer
to_multi_app = forward
from_reporters = 'main/measurement_xcoord
main/measurement_ycoord
main/measurement_zcoord
main/measurement_time
main/measurement_values
OptimizationReporter/p1'
to_reporters = 'measure_data/measurement_xcoord
measure_data/measurement_ycoord
measure_data/measurement_zcoord
measure_data/measurement_time
measure_data/measurement_values
params/p1'
[]
[fromForward_mesh]
type = MultiAppCopyTransfer
from_multi_app = forward
to_multi_app = adjoint
source_variable = 'temperature'
variable = 'temperature_forward'
[]
[fromForward]
type = MultiAppReporterTransfer
from_multi_app = forward
from_reporters = 'measure_data/misfit_values measure_data/objective_value'
to_reporters = 'main/misfit_values OptimizationReporter/objective_value'
[]
[toAdjoint]
type = MultiAppReporterTransfer
to_multi_app = adjoint
from_reporters = 'main/measurement_xcoord
main/measurement_ycoord
main/measurement_zcoord
main/measurement_time
main/misfit_values
OptimizationReporter/p1'
to_reporters = 'misfit/measurement_xcoord
misfit/measurement_ycoord
misfit/measurement_zcoord
misfit/measurement_time
misfit/misfit_values
params/p1'
[]
[fromAdjoint]
type = MultiAppReporterTransfer
from_multi_app = adjoint
from_reporters = 'adjoint_grad/inner_product'
to_reporters = 'OptimizationReporter/grad_p1'
[]
[]
[Outputs]
csv = true
[]
(modules/optimization/test/tests/optimizationreporter/bc_load_linearFunction/main.i)
# This tests that a linear and constant function can be scaled in
# two separate functionNeumannBCs both applied to the same sideset using
# two parsed functions. The scale of the linear and constant functions
# are being parameterized.
[Optimization]
[]
[Mesh]
type = GeneratedMesh
dim = 2
nx = 10
ny = 20
xmax = 1
ymax = 2
bias_x = 1.1
bias_y = 1.1
[]
[OptimizationReporter]
type = GeneralOptimization
objective_name = objective_value
parameter_names = 'left right'
num_values = '2 1'
[]
[Reporters]
[main]
type = OptimizationData
file_xcoord = 'coordx'
file_ycoord = 'y'
file_zcoord = 'z'
file_value = 'weightedMeasurement'
file_variable_weights = 'weight'
measurement_file = 'measurementData.csv'
[]
[]
[Executioner]
type = Optimize
tao_solver = taonls
petsc_options_iname = '-tao_gttol -tao_nls_pc_type -tao_nls_ksp_type'
petsc_options_value = '1e-3 none cg'
verbose = true
[]
[MultiApps]
[forward]
type = FullSolveMultiApp
input_files = forward.i
execute_on = "FORWARD"
clone_parent_mesh = true
[]
[adjoint]
type = FullSolveMultiApp
input_files = adjoint.i
execute_on = "ADJOINT"
clone_parent_mesh = true
[]
[homogeneousForward]
type = FullSolveMultiApp
input_files = homogeneous_forward.i
execute_on = "HOMOGENEOUS_FORWARD"
clone_parent_mesh = true
[]
[]
[Transfers]
[toForward]
type = MultiAppReporterTransfer
to_multi_app = forward
from_reporters = 'main/measurement_xcoord
main/measurement_ycoord
main/measurement_zcoord
main/measurement_time
main/measurement_values
main/weight
OptimizationReporter/left
OptimizationReporter/right'
to_reporters = 'measure_data/measurement_xcoord
measure_data/measurement_ycoord
measure_data/measurement_zcoord
measure_data/measurement_time
measure_data/measurement_values
measure_data/weightForTemperature
params_left/vals
params_right/vals'
[]
[fromForward]
type = MultiAppReporterTransfer
from_multi_app = forward
from_reporters = 'measure_data/misfit_values measure_data/objective_value'
to_reporters = 'main/misfit_values OptimizationReporter/objective_value'
[]
[toAdjoint]
type = MultiAppReporterTransfer
to_multi_app = adjoint
from_reporters = 'main/measurement_xcoord
main/measurement_ycoord
main/measurement_zcoord
main/measurement_time
main/misfit_values
main/weight
OptimizationReporter/left
OptimizationReporter/right'
to_reporters = 'misfit/measurement_xcoord
misfit/measurement_ycoord
misfit/measurement_zcoord
misfit/measurement_time
misfit/misfit_values
misfit/weight
params_left/vals
params_right/vals'
[]
[fromadjoint]
type = MultiAppReporterTransfer
from_multi_app = adjoint
from_reporters = 'grad_bc_left/inner_product
grad_bc_right/inner_product'
to_reporters = 'OptimizationReporter/grad_left
OptimizationReporter/grad_right'
[]
# HESSIAN transfers. Same as forward.
[toHomogeneousForward]
type = MultiAppReporterTransfer
to_multi_app = homogeneousForward
from_reporters = 'main/measurement_xcoord
main/measurement_ycoord
main/measurement_zcoord
main/measurement_time
main/measurement_values
main/weight
OptimizationReporter/left
OptimizationReporter/right'
to_reporters = 'measure_data/measurement_xcoord
measure_data/measurement_ycoord
measure_data/measurement_zcoord
measure_data/measurement_time
measure_data/measurement_values
measure_data/weightForTemperature
params_left/vals
params_right/vals'
[]
[fromHomogeneousForward]
type = MultiAppReporterTransfer
from_multi_app = homogeneousForward
from_reporters = 'measure_data/simulation_values'
to_reporters = 'main/misfit_values'
[]
[]
[Reporters]
[optInfo]
type = OptimizationInfo
items = 'current_iterate function_value gnorm'
[]
[]
[Outputs]
csv = true
console = false
[]
(modules/optimization/test/tests/optimizationreporter/bimaterial/main.i)
# This main.i file runs the subapps model.i and grad.i, using an FullSolveMultiApp
# The purpose of main.i is to find the two diffusivity_values
# (one in the bottom material of model.i, and one in the top material of model.i)
# such that the misfit between experimental observations (defined in model.i) and MOOSE predictions is minimised.
# The adjoint computed in grad.i is used to compute the gradient for the gradient based LMVM solver in TAO
# PETSc-TAO optimisation is used to perform this inversion
#
[Optimization]
[]
[Mesh]
[gmg]
type = GeneratedMeshGenerator
dim = 2
nx = 16
ny = 16
xmin = -4
xmax = 4
ymin = -4
ymax = 4
[]
[]
[OptimizationReporter]
type = GeneralOptimization
objective_name = objective_value
parameter_names = diffusivity_values
num_values = 2 # diffusivity in the bottom material and in the top material of model.i
initial_condition = '15 15' # the expected result is about '1 10' so this initial condition is not too bad
lower_bounds = '1'
upper_bounds = '50'
[]
[Reporters]
[main]
type = OptimizationData
measurement_file = 'synthetic_data.csv'
file_value = 'temperature'
[]
[]
[Executioner]
# type = Optimize
# tao_solver = taoblmvm
# petsc_options_iname = '-tao_fd_gradient -tao_gatol'
# petsc_options_value = ' true 0.001'
type = Optimize
tao_solver = taobqnktr
petsc_options_iname = '-tao_gatol'
petsc_options_value = '1e-3'
## THESE OPTIONS ARE FOR TESTING THE ADJOINT GRADIENT
# petsc_options_iname='-tao_max_it -tao_fd_test -tao_test_gradient -tao_fd_gradient -tao_fd_delta -tao_gatol'
# petsc_options_value='1 true true false 1e-8 0.1'
# petsc_options = '-tao_test_gradient_view'
verbose = true
[]
[MultiApps]
[forward]
type = FullSolveMultiApp
input_files = model.i
execute_on = FORWARD
[]
[adjoint]
type = FullSolveMultiApp
input_files = grad.i #write this input file to compute the adjoint solution and the gradient
execute_on = ADJOINT
[]
[]
[Transfers]
[toForward] #pass the coordinates where we knew the measurements to the forward model to do the extraction of the simulation data at the location of the measurements to compute the misfit
type = MultiAppReporterTransfer
to_multi_app = forward
from_reporters = 'main/measurement_xcoord
main/measurement_ycoord
main/measurement_zcoord
main/measurement_time
main/measurement_values
OptimizationReporter/diffusivity_values'
to_reporters = 'measure_data/measurement_xcoord
measure_data/measurement_ycoord
measure_data/measurement_zcoord
measure_data/measurement_time
measure_data/measurement_values
data/diffusivity'
[]
[from_forward] #get the simulation values
type = MultiAppReporterTransfer
from_multi_app = forward
from_reporters = 'measure_data/misfit_values measure_data/objective_value'
to_reporters = 'main/misfit_values OptimizationReporter/objective_value'
[]
#############
#copy the temperature variable - we will need this for the computation of the gradient
[fromforwardMesh]
type = MultiAppCopyTransfer
from_multi_app = forward
to_multi_app = adjoint
source_variable = 'temperature'
variable = 'temperature_forward'
[]
#############
[toAdjoint] #pass the misfit to the adjoint
type = MultiAppReporterTransfer
to_multi_app = adjoint
from_reporters = 'main/measurement_xcoord
main/measurement_ycoord
main/measurement_zcoord
main/measurement_time
main/misfit_values
OptimizationReporter/diffusivity_values'
to_reporters = 'misfit/measurement_xcoord
misfit/measurement_ycoord
misfit/measurement_zcoord
misfit/measurement_time
misfit/misfit_values
data/diffusivity'
[]
[fromadjoint]
type = MultiAppReporterTransfer
from_multi_app = adjoint
from_reporters = 'gradvec/inner_product'
to_reporters = 'OptimizationReporter/grad_diffusivity_values'
[]
[]
[Outputs]
console = false
csv = true
[]
(modules/optimization/test/tests/optimizationreporter/mesh_source/main_auto_adjoint.i)
[Optimization]
[]
[OptimizationReporter]
type = ParameterMeshOptimization
objective_name = objective_value
parameter_names = 'source'
parameter_meshes = 'parameter_mesh_in.e'
[]
[Reporters]
[main]
type = OptimizationData
# Random points
measurement_points = '0.78193073 0.39115321 0
0.72531893 0.14319403 0
0.14052488 0.86976625 0
0.401893 0.54241797 0
0.02645427 0.43320192 0
0.28856889 0.0035165 0
0.51433644 0.94485949 0
0.29252255 0.7962032 0
0.04925654 0.58018889 0
0.04717357 0.9556314 0'
# sin(x*pi/2)*sin(y*pi/2)
measurement_values = '0.54299466 0.20259611 0.21438235 0.44418597 0.02613676
0.00241892 0.72014019 0.42096307 0.06108895 0.07385256'
[]
[]
[Executioner]
type = Optimize
tao_solver = taobqnls
petsc_options_iname = '-tao_gatol'
petsc_options_value = '1e-4'
verbose = true
[]
[MultiApps]
[forward]
type = FullSolveMultiApp
input_files = forward_and_adjoint.i
execute_on = FORWARD
[]
[]
[Transfers]
[toForward_measument]
type = MultiAppReporterTransfer
to_multi_app = forward
from_reporters = 'main/measurement_xcoord
main/measurement_ycoord
main/measurement_zcoord
main/measurement_time
main/measurement_values
OptimizationReporter/source'
to_reporters = 'measure_data/measurement_xcoord
measure_data/measurement_ycoord
measure_data/measurement_zcoord
measure_data/measurement_time
measure_data/measurement_values
src_rep/vals'
[]
[fromForward]
type = MultiAppReporterTransfer
from_multi_app = forward
from_reporters = 'measure_data/objective_value
gradient_vpp/inner_product'
to_reporters = 'OptimizationReporter/objective_value
OptimizationReporter/grad_source'
[]
[]
(modules/optimization/examples/materialTransient/optimize_grad.i)
[Optimization]
[]
[OptimizationReporter]
type = GeneralOptimization
objective_name = objective_value
parameter_names = 'D'
num_values = '4'
initial_condition = '0.01 0.01 0.01 0.01'
upper_bounds = '1e2'
lower_bounds = '1e-3'
[]
[Reporters]
[main]
type = OptimizationData
measurement_file = forward_out_data_0011.csv
file_xcoord = measurement_xcoord
file_ycoord = measurement_ycoord
file_zcoord = measurement_zcoord
file_time = measurement_time
file_value = simulation_values
[]
[]
[MultiApps]
[forward]
type = FullSolveMultiApp
input_files = forward.i
cli_args = 'Outputs/csv=false;Outputs/console=false'
execute_on = FORWARD
[]
[adjoint]
type = FullSolveMultiApp
input_files = gradient.i
cli_args = 'Outputs/console=false;UserObjects/load_u/mesh=optimize_grad_out_forward0.e'
execute_on = ADJOINT
[]
[]
[Transfers]
[to_forward]
type = MultiAppReporterTransfer
to_multi_app = forward
from_reporters = 'main/measurement_xcoord
main/measurement_ycoord
main/measurement_zcoord
main/measurement_time
main/measurement_values
OptimizationReporter/D'
to_reporters = 'data/measurement_xcoord
data/measurement_ycoord
data/measurement_zcoord
data/measurement_time
data/measurement_values
diffc_rep/D_vals'
[]
[from_forward]
type = MultiAppReporterTransfer
from_multi_app = forward
from_reporters = 'data/misfit_values data/objective_value'
to_reporters = 'main/misfit_values OptimizationReporter/objective_value'
[]
[to_adjoint]
type = MultiAppReporterTransfer
to_multi_app = adjoint
from_reporters = 'main/measurement_xcoord
main/measurement_ycoord
main/measurement_zcoord
main/measurement_time
main/misfit_values
OptimizationReporter/D'
to_reporters = 'data/measurement_xcoord
data/measurement_ycoord
data/measurement_zcoord
data/measurement_time
data/misfit_values
diffc_rep/D_vals'
[]
[from_adjoint]
type = MultiAppReporterTransfer
from_multi_app = adjoint
from_reporters = 'adjoint/inner_product'
to_reporters = 'OptimizationReporter/grad_D'
[]
[]
[Executioner]
type = Optimize
tao_solver = taobqnls
petsc_options_iname = '-tao_gatol'
petsc_options_value = '1e-4'
[]
(modules/combined/test/tests/optimization/invOpt_mechanics/adjoint.i)
[Mesh]
[]
[Variables]
[disp_x]
[]
[disp_y]
[]
[]
[Kernels]
[TensorMechanics]
use_displaced_mesh = false
displacements ='disp_x disp_y'
[]
[]
#-----adjoint problem information------------------
[DiracKernels]
[pt]
type = ReporterPointSource
variable = disp_y
x_coord_name = misfit/measurement_xcoord
y_coord_name = misfit/measurement_ycoord
z_coord_name = misfit/measurement_zcoord
value_name = misfit/misfit_values
[]
[]
[Reporters]
[misfit]
type=OptimizationData
[]
[params]
type = ConstantReporter
real_vector_names = 'right_fy_value'
real_vector_values = '0' # Dummy value
[]
[]
[Functions]
[right_fy_func]
type = ParsedOptimizationFunction
expression = 'val'
param_symbol_names = 'val'
param_vector_name = 'params/right_fy_value'
[]
[]
[VectorPostprocessors]
[adjoint_pt]
type = SideOptimizationNeumannFunctionInnerProduct
variable = disp_y
function = right_fy_func
boundary = right
[]
[]
#---------------------------------------------------
[BCs]
[left_ux]
type = DirichletBC
variable = disp_x
boundary = left
value = 0
[]
[left_uy]
type = DirichletBC
variable = disp_y
boundary = left
value = 0
[]
[right_fy]
type = NeumannBC
variable = disp_y
boundary = right
value = 0 #2000
[]
[]
[Materials]
[elasticity]
type = ComputeIsotropicElasticityTensor
youngs_modulus = 10e3
poissons_ratio = 0.3
[]
[strain]
type = ComputeSmallStrain
displacements = 'disp_x disp_y'
[]
[stress]
type = ComputeLinearElasticStress
[]
[]
[Executioner]
type = Steady
solve_type = PJFNK
nl_abs_tol = 1e-6
nl_rel_tol = 1e-8
petsc_options_iname = '-pc_type'
petsc_options_value = 'lu'
[]
[Outputs]
csv = false
console = false
exodus = false
file_base = 'adjoint'
[]
(modules/optimization/test/tests/optimizationreporter/constant_heat_source/adjoint.i)
[Mesh]
type = GeneratedMesh
dim = 2
nx = 10
ny = 10
xmax = 2
ymax = 2
[]
[Variables]
[adjoint_T]
[]
[]
[Kernels]
[heat_conduction]
type = MatDiffusion
variable = adjoint_T
diffusivity = thermal_conductivity
[]
[]
[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
[]
[]
[Reporters]
[misfit]
type = OptimizationData
[]
[params]
type = ConstantReporter
real_vector_names = 'q'
real_vector_values = '0' # Dummy value
[]
[]
[BCs]
[left]
type = NeumannBC
variable = adjoint_T
boundary = left
value = 0
[]
[right]
type = NeumannBC
variable = adjoint_T
boundary = right
value = 0
[]
[bottom]
type = DirichletBC
variable = adjoint_T
boundary = bottom
value = 0
[]
[top]
type = DirichletBC
variable = adjoint_T
boundary = top
value = 0
[]
[]
[Materials]
[steel]
type = GenericConstantMaterial
prop_names = thermal_conductivity
prop_values = 5
[]
[]
[Executioner]
type = Steady
solve_type = PJFNK
nl_abs_tol = 1e-8
nl_rel_tol = 1e-8
petsc_options_iname = '-ksp_type -pc_type -pc_factor_mat_solver_package'
petsc_options_value = 'preonly lu superlu_dist'
[]
[Functions]
[volumetric_heat_func]
type = ParsedOptimizationFunction
expression = q
param_symbol_names = 'q'
param_vector_name = 'params/q'
[]
[]
[VectorPostprocessors]
[gradient_vpp]
type = ElementOptimizationSourceFunctionInnerProduct
variable = adjoint_T
function = volumetric_heat_func
[]
[]
[Outputs]
console = false
file_base = 'adjoint'
[]
(modules/combined/test/tests/optimization/invOpt_bc_convective/main.i)
[Optimization]
[]
[Mesh]
[gmg]
type = GeneratedMeshGenerator
dim = 2
nx = 10
ny = 20
xmax = 1
ymax = 2
[]
[]
[OptimizationReporter]
type = GeneralOptimization
objective_name = objective_value
parameter_names = 'p1'
num_values = '1'
initial_condition = '9'
upper_bounds = '10'
lower_bounds = '1'
[]
[Reporters]
[main]
type = OptimizationData
measurement_points = '0.1 0 0
0.1 0.1 0
0.1 0.2 0
0.1 0.3 0
0.1 0.4 0
0.1 0.5 0
0.1 0.6 0
0.1 0.7 0
0.1 0.8 0
0.1 0.9 0
0.1 1 0
0.1 1.1 0
0.1 1.2 0
0.1 1.3 0
0.1 1.4 0
0.1 1.5 0
0.1 1.6 0
0.1 1.7 0
0.1 1.8 0
0.1 1.9 0
0.1 2 0'
measurement_values = '500
472.9398111
450.8117197
434.9560747
423.3061045
414.9454912
409.3219399
406.1027006
405.0865428
406.1604905
409.2772668
414.4449772
421.7253934
431.2401042
443.1862012
457.8664824
475.7450186
497.5582912
524.4966003
559.1876637
600'
[]
[]
[Executioner]
type = Optimize
tao_solver = taoblmvm #taolmvm#taonm #taolmvm
petsc_options_iname = '-tao_gatol' # -tao_fd_gradient -tao_fd_delta'
petsc_options_value = '1e-4' #1e-1 '#true 1e-4'
[]
[MultiApps]
[forward]
type = FullSolveMultiApp
input_files = forward.i
execute_on = "FORWARD"
clone_parent_mesh = true
[]
[adjoint]
type = FullSolveMultiApp
input_files = adjoint.i
execute_on = "ADJOINT"
clone_parent_mesh = true
[]
[]
[Transfers]
#these are usually the same for all input files.
[toForward]
type = MultiAppReporterTransfer
to_multi_app = forward
from_reporters = 'main/measurement_xcoord
main/measurement_ycoord
main/measurement_zcoord
main/measurement_time
main/measurement_values
OptimizationReporter/p1'
to_reporters = 'measure_data/measurement_xcoord
measure_data/measurement_ycoord
measure_data/measurement_zcoord
measure_data/measurement_time
measure_data/measurement_values
params/vals'
[]
[fromForward]
type = MultiAppReporterTransfer
from_multi_app = forward
from_reporters = 'measure_data/misfit_values measure_data/objective_value'
to_reporters = 'main/misfit_values OptimizationReporter/objective_value'
[]
[toAdjoint]
type = MultiAppReporterTransfer
to_multi_app = adjoint
from_reporters = 'main/measurement_xcoord
main/measurement_ycoord
main/measurement_zcoord
main/measurement_time
main/misfit_values
OptimizationReporter/p1'
to_reporters = 'misfit/measurement_xcoord
misfit/measurement_ycoord
misfit/measurement_zcoord
misfit/measurement_time
misfit/misfit_values
params/vals'
[]
[fromAdjoint]
type = MultiAppReporterTransfer
from_multi_app = adjoint
from_reporters = 'adjoint_pt/inner_product'
to_reporters = 'OptimizationReporter/grad_p1'
[]
# these are transferring data from subapp to subapp because the adjoint problem
# needs the forward solution to compute the gradient. Maybe this step could be
# done on the main app. The adjoint only passes the adjoint variable (whole mesh)
# to the main app and the main app computes the gradient from this.
[fromForwardtoAdjoint_temp]
type = MultiAppCopyTransfer
from_multi_app = forward
to_multi_app = adjoint
source_variable = 'temperature'
variable = 'temperature_forward'
[]
[]
[Outputs]
csv = true
[]
(modules/optimization/test/tests/optimizationreporter/material/adjoint_explicit.i)
[Mesh]
[]
[Variables]
[adjoint_var]
[]
[]
[Kernels]
[heat_conduction]
type = MatDiffusion
variable = adjoint_var
diffusivity = thermal_conductivity
[]
[]
[DiracKernels]
[pt]
type = ReporterPointSource
variable = adjoint_var
x_coord_name = misfit/measurement_xcoord
y_coord_name = misfit/measurement_ycoord
z_coord_name = misfit/measurement_zcoord
value_name = misfit/misfit_values
[]
[]
[Reporters]
[misfit]
type = OptimizationData
[]
[]
[AuxVariables]
[temperature_forward]
[]
[grad_Tx]
order = CONSTANT
family = MONOMIAL
[]
[grad_Ty]
order = CONSTANT
family = MONOMIAL
[]
[grad_Tz]
order = CONSTANT
family = MONOMIAL
[]
[grad_Tfx]
order = CONSTANT
family = MONOMIAL
[]
[grad_Tfy]
order = CONSTANT
family = MONOMIAL
[]
[grad_Tfz]
order = CONSTANT
family = MONOMIAL
[]
[negative_gradient]
order = CONSTANT
family = MONOMIAL
[]
[]
[AuxKernels]
[grad_Tx]
type = VariableGradientComponent
component = x
variable = grad_Tx
gradient_variable = adjoint_var
[]
[grad_Ty]
type = VariableGradientComponent
component = y
variable = grad_Ty
gradient_variable = adjoint_var
[]
[grad_Tz]
type = VariableGradientComponent
component = z
variable = grad_Tz
gradient_variable = adjoint_var
[]
[grad_Tfx]
type = VariableGradientComponent
component = x
variable = grad_Tfx
gradient_variable = temperature_forward
[]
[grad_Tfy]
type = VariableGradientComponent
component = y
variable = grad_Tfy
gradient_variable = temperature_forward
[]
[grad_Tfz]
type = VariableGradientComponent
component = z
variable = grad_Tfz
gradient_variable = temperature_forward
[]
[negative_gradient]
type = ParsedAux
variable = negative_gradient
args = 'grad_Tx grad_Ty grad_Tz grad_Tfx grad_Tfy grad_Tfz'
function = '-(grad_Tx*grad_Tfx+grad_Ty*grad_Tfy+grad_Tz*grad_Tfz)'
[]
[]
[BCs]
[left]
type = NeumannBC
variable = adjoint_var
boundary = left
value = 0
[]
[right]
type = NeumannBC
variable = adjoint_var
boundary = right
value = 0
[]
[bottom]
type = DirichletBC
variable = adjoint_var
boundary = bottom
value = 0
[]
[top]
type = DirichletBC
variable = adjoint_var
boundary = top
value = 0
[]
[]
[Functions]
[thermo_conduct]
type = ParsedFunction
value = alpha
vars = 'alpha'
vals = 'p1'
[]
[]
[Materials]
[thermalProp]
type = GenericFunctionMaterial
prop_names = 'thermal_conductivity'
prop_values = 'thermo_conduct'
[]
[thermalPropDeriv]
type = GenericFunctionMaterial
prop_names = 'thermal_conductivity_deriv'
prop_values = '1'
[]
[]
[Executioner]
type = Steady
solve_type = NEWTON
nl_abs_tol = 1e-8
nl_rel_tol = 1e-8
petsc_options_iname = '-ksp_type -pc_type -pc_factor_mat_solver_package'
petsc_options_value = 'preonly lu superlu_dist'
[]
[Postprocessors]
[pp_adjoint_grad_parsedFunc]
type = ElementIntegralVariablePostprocessor
variable = negative_gradient
execute_on = 'initial linear'
[]
[p1]
type = ConstantValuePostprocessor
value = 10
execute_on = 'initial linear'
[]
[]
[Controls]
[parameterReceiver]
type = ControlsReceiver
[]
[]
[VectorPostprocessors]
[adjoint_grad]
type = VectorOfPostprocessors
postprocessors = 'pp_adjoint_grad_parsedFunc'
[]
[]
[Outputs]
console = false
file_base = 'adjoint'
[]
(modules/optimization/test/tests/optimizationreporter/general_opt/point_loads_gen_opt/main_auto_adjoint.i)
[Optimization]
[]
[OptimizationReporter]
type = GeneralOptimization
objective_name = misfit_norm
parameter_names = 'parameter_results'
num_values = '3'
[]
[Reporters]
[measure_data]
type = OptimizationData
measurement_points = '0.5 0.28 0
0.5 0.6 0
0.5 0.8 0
0.5 1.1 0'
measurement_values = '293 304 315 320'
[]
[]
[Executioner]
type = Optimize
tao_solver = taolmvm
petsc_options_iname = '-tao_gttol -tao_ls_type'
petsc_options_value = '1e-5 unit'
verbose = true
[]
[MultiApps]
[forward]
type = FullSolveMultiApp
input_files = forward_and_adjoint.i
execute_on = "FORWARD"
[]
[]
[Transfers]
# FORWARD transfers
[toForward_measument]
type = MultiAppReporterTransfer
to_multi_app = forward
from_reporters = 'OptimizationReporter/parameter_results'
to_reporters = 'point_source/value'
[]
[fromForward]
type = MultiAppReporterTransfer
from_multi_app = forward
from_reporters = 'gradient/temperature_adjoint
measure_data/misfit_norm'
to_reporters = 'OptimizationReporter/grad_parameter_results
OptimizationReporter/misfit_norm'
[]
[]
[Outputs]
csv = true
file_base = main_out
[]
(modules/combined/test/tests/optimization/invOpt_elasticity_modular/main.i)
[Optimization]
[]
[OptimizationReporter]
type = GeneralOptimization
objective_name = objective_value
parameter_names = 'youngs_modulus'
num_values = '3'
initial_condition = '5.0 5.0 5.0'
lower_bounds = '0.1'
upper_bounds = '10.0'
[]
[Reporters]
[main]
type = OptimizationData
measurement_points = '-1.0 -1.0 0.0
-1.0 0.0 0.0
-1.0 1.0 0.0
0.0 -1.0 0.0
0.0 0.0 0.0
0.0 1.0 0.0
1.0 -1.0 0.0
1.0 0.0 0.0
1.0 1.0 0.0'
measurement_values = '3.276017e+00
4.763281e+00
6.380137e+00
3.171603e+00
4.660766e+00
6.289842e+00
3.127077e+00
4.608134e+00
6.228638e+00'
[]
[]
[Executioner]
type = Optimize
tao_solver = taobqnls #taobncg #taoblmvm
petsc_options_iname = '-tao_gatol -tao_ls_type -tao_max_it'
petsc_options_value = '1e-10 unit 1000'
# THESE OPTIONS ARE FOR TESTING THE ADJOINT GRADIENT
# petsc_options_iname = '-tao_max_it -tao_fd_test -tao_test_gradient -tao_fd_gradient -tao_fd_delta -tao_gatol'
# petsc_options_value = '1 true true false 1e-8 0.1'
# petsc_options = '-tao_test_gradient_view'
# verbose = true
[]
[MultiApps]
[forward]
type = FullSolveMultiApp
input_files = forward.i
execute_on = FORWARD
[]
[adjoint]
type = FullSolveMultiApp
input_files = grad.i
execute_on = ADJOINT
[]
[]
[Transfers]
[toForward]
type = MultiAppReporterTransfer
to_multi_app = forward
from_reporters = 'main/measurement_xcoord
main/measurement_ycoord
main/measurement_zcoord
main/measurement_time
main/measurement_values
OptimizationReporter/youngs_modulus'
to_reporters = 'measure_data/measurement_xcoord
measure_data/measurement_ycoord
measure_data/measurement_zcoord
measure_data/measurement_time
measure_data/measurement_values
parametrization/youngs_modulus'
[]
[get_misfit]
type = MultiAppReporterTransfer
from_multi_app = forward
from_reporters = 'measure_data/misfit_values measure_data/objective_value'
to_reporters = 'main/misfit_values OptimizationReporter/objective_value'
[]
[set_state_for_adjoint]
type = MultiAppCopyTransfer
from_multi_app = forward
to_multi_app = adjoint
source_variable = 'disp_x disp_y'
variable = 'disp_x disp_y'
[]
[setup_adjoint_run]
type = MultiAppReporterTransfer
to_multi_app = adjoint
from_reporters = 'main/measurement_xcoord
main/measurement_ycoord
main/measurement_zcoord
main/measurement_time
main/misfit_values
OptimizationReporter/youngs_modulus'
to_reporters = 'misfit/measurement_xcoord
misfit/measurement_ycoord
misfit/measurement_zcoord
misfit/measurement_time
misfit/misfit_values
parametrization/youngs_modulus'
[]
[get_grad_youngs_modulus]
type = MultiAppReporterTransfer
from_multi_app = adjoint
from_reporters = 'grad_youngs_modulus/inner_product'
to_reporters = 'OptimizationReporter/grad_youngs_modulus'
[]
[]
[Reporters]
[optInfo]
type = OptimizationInfo
items = 'current_iterate function_value gnorm'
[]
[]
[Outputs]
console = false
csv = true
[]
(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
objective_name = objective_value
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
[]
[]
[Preconditioning]
[nl0]
type = SMP
nl_sys = 'nl0'
petsc_options_iname = '-pc_type'
petsc_options_value = 'lu'
[]
[adjoint]
type = SMP
nl_sys = 'adjoint'
petsc_options_iname = '-pc_type'
petsc_options_value = 'lu'
[]
[]
[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
[]
[Outputs]
console = false
[]
(modules/combined/test/tests/optimization/invOpt_nonlinear/simulation.i)
[Executioner]
type = Steady
solve_type = NEWTON
line_search = none
nl_abs_tol = 1e-12
nl_rel_tol = 1e-12
petsc_options_iname = '-pc_type'
petsc_options_value = 'lu'
[]
[Mesh]
type = GeneratedMesh
dim = 2
nx = 10
ny = 10
xmax = 2
ymax = 2
[]
[Variables]
[forwardT]
[]
[]
[Kernels]
[heat_conduction]
type = ADHeatConduction
thermal_conductivity = 'conductivity'
variable = forwardT
[]
[heat_source]
type = ADMatHeatSource
material_property = 'volumetric_heat'
variable = forwardT
[]
[]
[Materials]
[NonlinearConductivity]
type = ADParsedMaterial
f_name = 'conductivity'
function = '10+500*forwardT'
args = 'forwardT'
[]
[volumetric_heat]
type = ADGenericFunctionMaterial
prop_names = 'volumetric_heat'
prop_values = 'volumetric_heat_func'
[]
[]
[Functions]
[volumetric_heat_func]
type = ParsedFunction
value = q
vars = 'q'
vals = 'heat_source_pp'
[]
[]
[Postprocessors]
[heat_source_pp]
type = ConstantValuePostprocessor
value = 333
execute_on = 'LINEAR'
[]
[]
[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
[]
[]
[Controls]
[parameterReceiver]
type = ControlsReceiver
[]
[]
[VectorPostprocessors]
[data_pt]
type = PointValueSampler
variable = forwardT
points = '0.2 0.2 0
0.8 0.6 0
0.2 1.4 0
0.8 1.8 0'
sort_by = id
[]
[]
[Outputs]
csv = true
[]
(modules/optimization/test/tests/optimizationreporter/bc_load_linearFunction/forward.i)
[Mesh]
[]
[Variables]
[temperature]
[]
[]
[Kernels]
[heat_conduction]
type = MatDiffusion
variable = temperature
diffusivity = thermal_conductivity
[]
[]
[BCs]
[left]
type = FunctionNeumannBC
variable = temperature
boundary = left
function = left_function
[]
[right]
type = FunctionNeumannBC
variable = temperature
boundary = right
function = right_function
[]
[bottom]
type = DirichletBC
variable = temperature
boundary = bottom
value = 200
[]
[top]
type = DirichletBC
variable = temperature
boundary = top
value = 100
[]
[]
[Functions]
[left_function]
type = ParsedOptimizationFunction
expression = 'a + b*y'
param_symbol_names = 'a b'
param_vector_name = 'params_left/vals'
[]
[right_function]
type = ParsedOptimizationFunction
expression = 'a'
param_symbol_names = 'a'
param_vector_name = 'params_right/vals'
[]
[]
[Materials]
[steel]
type = GenericConstantMaterial
prop_names = thermal_conductivity
prop_values = 5
[]
[]
[Executioner]
type = Steady
solve_type = NEWTON
line_search = none
nl_abs_tol = 1e-8
nl_rel_tol = 1e-8
petsc_options_iname = '-ksp_type -pc_type -pc_factor_mat_solver_package'
petsc_options_value = 'preonly lu superlu_dist'
[]
[VectorPostprocessors]
[vertical_1]
type = LineValueSampler
variable = 'temperature'
start_point = '0.2 0.0 0'
end_point = '0.2 2.0 0'
num_points = 21
sort_by = y
[]
[vertical_2]
type = LineValueSampler
variable = 'temperature'
start_point = '0.8 0.0 0'
end_point = '0.8 2.0 0'
num_points = 21
sort_by = y
[]
[]
[Reporters]
[measure_data]
type = OptimizationData
variable = temperature
objective_name = objective_value
variable_weight_names = weightForTemperature
[]
[params_left]
type = ConstantReporter
real_vector_names = 'vals'
real_vector_values = '0 0' # Dummy
[]
[params_right]
type = ConstantReporter
real_vector_names = 'vals'
real_vector_values = '0' # Dummy
[]
[]
[Outputs]
console = false
exodus = false
file_base = 'forward'
[]
(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/optimizationreporter/constant_heat_source/main.i)
[Optimization]
[]
[OptimizationReporter]
type = GeneralOptimization
objective_name = objective_value
parameter_names = 'parameter_results'
num_values = '1'
initial_condition = '500'
lower_bounds = '0.1'
upper_bounds = '10000'
[]
[Reporters]
[main]
type = OptimizationData
measurement_points = '0.2 0.2 0
0.8 0.6 0
0.2 1.4 0
0.8 1.8 0'
measurement_values = '226 254 214 146'
[]
[]
[Executioner]
type = Optimize
tao_solver = taoblmvm
petsc_options_iname = '-tao_gatol'
petsc_options_value = '1e-6'
verbose = true
[]
[MultiApps]
[forward]
type = FullSolveMultiApp
input_files = forward.i
execute_on = FORWARD
[]
[adjoint]
type = FullSolveMultiApp
input_files = adjoint.i
execute_on = ADJOINT
[]
[]
[Transfers]
[toForward_measument]
type = MultiAppReporterTransfer
to_multi_app = forward
from_reporters = 'main/measurement_xcoord
main/measurement_ycoord
main/measurement_zcoord
main/measurement_time
main/measurement_values
OptimizationReporter/parameter_results'
to_reporters = 'measure_data/measurement_xcoord
measure_data/measurement_ycoord
measure_data/measurement_zcoord
measure_data/measurement_time
measure_data/measurement_values
params/q'
[]
[toAdjoint]
type = MultiAppReporterTransfer
to_multi_app = adjoint
from_reporters = 'main/measurement_xcoord
main/measurement_ycoord
main/measurement_zcoord
main/measurement_time
main/misfit_values
OptimizationReporter/parameter_results'
to_reporters = 'misfit/measurement_xcoord
misfit/measurement_ycoord
misfit/measurement_zcoord
misfit/measurement_time
misfit/misfit_values
params/q'
[]
[fromForward]
type = MultiAppReporterTransfer
from_multi_app = forward
from_reporters = 'measure_data/misfit_values measure_data/objective_value'
to_reporters = 'main/misfit_values OptimizationReporter/objective_value'
[]
[fromadjoint]
type = MultiAppReporterTransfer
from_multi_app = adjoint
from_reporters = 'gradient_vpp/inner_product'
to_reporters = 'OptimizationReporter/grad_parameter_results'
[]
[]
[Outputs]
csv = true
[]
(modules/optimization/test/tests/optimizationreporter/general_opt/point_loads_gen_opt/forward_and_adjoint.i)
[Mesh]
[gmg]
type = GeneratedMeshGenerator
dim = 2
nx = 10
ny = 10
xmax = 1
ymax = 1.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 = thermal_conductivity
[]
[]
[DiracKernels]
[pt]
type = ReporterPointSource
variable = temperature
x_coord_name = 'point_source/x'
y_coord_name = 'point_source/y'
z_coord_name = 'point_source/z'
value_name = 'point_source/value'
[]
[misfit]
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
[]
[]
[BCs]
[left]
type = DirichletBC
variable = temperature
boundary = left
value = 300
[]
[right]
type = DirichletBC
variable = temperature
boundary = right
value = 300
[]
[bottom]
type = DirichletBC
variable = temperature
boundary = bottom
value = 300
[]
[top]
type = DirichletBC
variable = temperature
boundary = top
value = 300
[]
[]
[Materials]
[steel]
type = GenericConstantMaterial
prop_names = thermal_conductivity
prop_values = 5
[]
[]
[Executioner]
type = SteadyAndAdjoint
forward_system = nl0
adjoint_system = adjoint
nl_rel_tol = 1e-12
l_tol = 1e-12
petsc_options_iname = '-pc_type'
petsc_options_value = 'lu'
[]
[VectorPostprocessors]
[gradient]
type = PointValueSampler
points = '0.2 0.2 0
0.7 0.56 0
0.4 1 0'
variable = temperature_adjoint
sort_by = id
execute_on = ADJOINT_TIMESTEP_END
[]
[]
[Reporters]
[measure_data]
type = OptimizationData
variable = temperature
measurement_points = '0.5 0.28 0
0.5 0.6 0
0.5 0.8 0
0.5 1.1 0'
measurement_values = '293 304 315 320'
objective_name = misfit_norm
[]
[point_source]
type = ConstantReporter
real_vector_names = 'x y z value'
real_vector_values = '0.2 0.7 0.4;
0.2 0.56 1;
0 0 0;
-1000 120 500'
[]
[]
[Outputs]
console = false
[]
(modules/optimization/test/tests/outputs/exodus_optimization_steady/forward_and_adjoint_iteration_output.i)
[Mesh]
[gmg]
type = GeneratedMeshGenerator
dim = 2
nx = 10
ny = 10
xmax = 1
ymax = 1.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 = thermal_conductivity
[]
[]
[DiracKernels]
[pt]
type = ReporterPointSource
variable = temperature
x_coord_name = 'point_source/x'
y_coord_name = 'point_source/y'
z_coord_name = 'point_source/z'
value_name = 'point_source/value'
[]
[misfit]
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
[]
[]
[BCs]
[left]
type = DirichletBC
variable = temperature
boundary = left
value = 300
[]
[right]
type = DirichletBC
variable = temperature
boundary = right
value = 300
[]
[bottom]
type = DirichletBC
variable = temperature
boundary = bottom
value = 300
[]
[top]
type = DirichletBC
variable = temperature
boundary = top
value = 300
[]
[]
[Materials]
[steel]
type = GenericConstantMaterial
prop_names = thermal_conductivity
prop_values = 5
[]
[]
[Preconditioning]
[nl0]
type = SMP
nl_sys = 'nl0'
petsc_options_iname = '-pc_type'
petsc_options_value = 'lu'
[]
[adjoint]
type = SMP
nl_sys = 'adjoint'
petsc_options_iname = '-pc_type'
petsc_options_value = 'lu'
[]
[]
[Executioner]
type = SteadyAndAdjoint
forward_system = nl0
adjoint_system = adjoint
nl_rel_tol = 1e-12
l_tol = 1e-12
[]
[VectorPostprocessors]
[gradient]
type = PointValueSampler
points = '0.2 0.2 0
0.7 0.56 0
0.4 1 0'
variable = temperature_adjoint
sort_by = id
execute_on = ADJOINT_TIMESTEP_END
[]
[]
[Reporters]
[measure_data]
type = OptimizationData
objective_name = objective_value
variable = temperature
outputs = none
[]
[point_source]
type = ConstantReporter
real_vector_names = 'x y z value'
real_vector_values = '0.2 0.7 0.4;
0.2 0.56 1;
0 0 0;
-1000 120 500'
[]
[]
[Outputs]
console = false
[exodus]
type = ExodusOptimizationSteady
execute_on = 'TIMESTEP_END'
[]
[]
(modules/combined/test/tests/optimization/invOpt_mechanics/main.i)
[Optimization]
[]
[Mesh]
type = GeneratedMesh
dim = 2
nx = 10
ny = 2
xmin = 0.0
xmax = 5.0
ymin = 0.0
ymax = 1.0
[]
[OptimizationReporter]
type = GeneralOptimization
objective_name = objective_value
parameter_names = 'fy_right'
num_values = '1'
initial_condition = '100'
[]
[Reporters]
[main]
type = OptimizationData
measurement_points = '5.0 1.0 0.0'
measurement_values = '80.9'
[]
[]
[Executioner]
type = Optimize
tao_solver = taonls
petsc_options_iname = '-tao_gttol -tao_max_it -tao_nls_pc_type -tao_nls_ksp_type'
petsc_options_value = '1e-5 50 none cg'
verbose = true
[]
[MultiApps]
[forward]
type = FullSolveMultiApp
input_files = forward.i
execute_on = "FORWARD"
clone_parent_mesh = true
[]
[adjoint]
type = FullSolveMultiApp
input_files = adjoint.i
execute_on = "ADJOINT"
clone_parent_mesh = true
[]
# the forward problem has homogeneous boundary conditions so it can be reused here.
[homogeneousForward]
type = FullSolveMultiApp
input_files = forward.i
execute_on = "HOMOGENEOUS_FORWARD"
clone_parent_mesh = true
[]
[]
[Transfers]
[toForward_measument]
type = MultiAppReporterTransfer
to_multi_app = forward
from_reporters = 'main/measurement_xcoord
main/measurement_ycoord
main/measurement_zcoord
main/measurement_time
main/measurement_values
OptimizationReporter/fy_right'
to_reporters = 'measure_data/measurement_xcoord
measure_data/measurement_ycoord
measure_data/measurement_zcoord
measure_data/measurement_time
measure_data/measurement_values
params/right_fy_value'
[]
[fromForward]
type = MultiAppReporterTransfer
from_multi_app = forward
from_reporters = 'measure_data/misfit_values measure_data/objective_value'
to_reporters = 'main/misfit_values OptimizationReporter/objective_value'
[]
[toAdjoint]
type = MultiAppReporterTransfer
to_multi_app = adjoint
from_reporters = 'main/measurement_xcoord
main/measurement_ycoord
main/measurement_zcoord
main/measurement_time
main/misfit_values
OptimizationReporter/fy_right'
to_reporters = 'misfit/measurement_xcoord
misfit/measurement_ycoord
misfit/measurement_zcoord
misfit/measurement_time
misfit/misfit_values
params/right_fy_value'
[]
[fromAdjoint]
type = MultiAppReporterTransfer
from_multi_app = adjoint
from_reporters = 'adjoint_pt/inner_product'
to_reporters = 'OptimizationReporter/grad_fy_right'
[]
[toHomogeneousForward_measument]
type = MultiAppReporterTransfer
to_multi_app = homogeneousForward
from_reporters = 'main/measurement_xcoord
main/measurement_ycoord
main/measurement_zcoord
main/measurement_time
main/measurement_values
OptimizationReporter/fy_right'
to_reporters = 'measure_data/measurement_xcoord
measure_data/measurement_ycoord
measure_data/measurement_zcoord
measure_data/measurement_time
measure_data/measurement_values
params/right_fy_value'
[]
[fromHomogeneousForward]
type = MultiAppReporterTransfer
from_multi_app = homogeneousForward
from_reporters = 'measure_data/simulation_values'
to_reporters = 'main/misfit_values'
[]
[]
[Reporters]
[optInfo]
type = OptimizationInfo
[]
[]
[Outputs]
csv = true
[]
(modules/optimization/test/tests/optimizationreporter/general_opt/point_loads_gen_opt/adjoint.i)
[Mesh]
type = GeneratedMesh
dim = 2
nx = 10
ny = 10
xmax = 1
ymax = 1.4
[]
[Variables]
[adjoint]
[]
[]
[Problem]
extra_tag_vectors = 'ref'
[]
[AuxVariables]
[residual_src]
[]
[]
[AuxKernels]
[residual_src]
type = TagVectorAux
vector_tag = 'ref'
v = 'adjoint'
variable = 'residual_src'
[]
[]
[Variables]
[adjoint]
[]
[]
[Kernels]
[heat_conduction]
type = MatDiffusion
variable = adjoint
diffusivity = thermal_conductivity
[]
[]
#-----every adjoint problem should have these two
[DiracKernels]
[pt]
type = ReporterPointSource
variable = adjoint
x_coord_name = misfit/measurement_xcoord
y_coord_name = misfit/measurement_ycoord
z_coord_name = misfit/measurement_zcoord
value_name = misfit/misfit_values
extra_vector_tags = 'ref'
[]
[]
[Reporters]
[misfit]
type = OptimizationData
measurement_points = ${measurement_points}
measurement_values = ${measurement_values}
[]
[]
[BCs]
[left]
type = DirichletBC
variable = adjoint
boundary = left
value = 0
[]
[right]
type = DirichletBC
variable = adjoint
boundary = right
value = 0
[]
[bottom]
type = DirichletBC
variable = adjoint
boundary = bottom
value = 0
[]
[top]
type = DirichletBC
variable = adjoint
boundary = top
value = 0
[]
[]
[Materials]
[steel]
type = GenericConstantMaterial
prop_names = thermal_conductivity
prop_values = 5
[]
[]
[Executioner]
type = Steady
solve_type = NEWTON
nl_abs_tol = 1e-6
nl_rel_tol = 1e-8
petsc_options_iname = '-pc_type'
petsc_options_value = 'lu'
[]
[VectorPostprocessors]
[gradient]
type = PointValueSampler
points = '0.2 0.2 0
0.7 0.56 0
0.4 1 0'
variable = adjoint
sort_by = id
[]
[]
[Outputs]
console = false
exodus = false
file_base = 'adjoint'
[]
(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
[]
(modules/optimization/test/tests/optimizationreporter/general_opt/point_loads_gen_opt/main_separate_multiapps.i)
measurement_points = '0.5 0.28 0
0.5 0.6 0
0.5 0.8 0
0.5 1.1 0'
measurement_values = '293 304 315 320'
[Optimization]
[]
[OptimizationReporter]
type = GeneralOptimization
objective_name = misfit_norm
parameter_names = 'parameter_results'
num_values = '3'
[]
[Reporters]
[main]
# We need to have an OptimizationData on the main app to allow the
# transferring of the correct information when doing Hessian based optimization.
type = OptimizationData
measurement_points = ${measurement_points}
measurement_values = ${measurement_values}
[]
[]
[Executioner]
type = Optimize
tao_solver = taonls
petsc_options_iname = '-tao_gttol -tao_max_it -tao_nls_pc_type -tao_nls_ksp_type'
petsc_options_value = '1e-5 10 none cg'
verbose = true
[]
[MultiApps]
[forward]
type = FullSolveMultiApp
input_files = forward.i
execute_on = "FORWARD"
cli_args = 'measurement_points="${measurement_points}";measurement_values="${measurement_values}"'
[]
[adjoint]
type = FullSolveMultiApp
input_files = adjoint.i
execute_on = "ADJOINT"
cli_args = 'measurement_points="${measurement_points}";measurement_values="${measurement_values}"'
[]
[homogeneousForward]
type = FullSolveMultiApp
input_files = forward_homogeneous.i
execute_on = "HOMOGENEOUS_FORWARD"
cli_args = 'measurement_points="${measurement_points}";measurement_values="${measurement_values}"'
[]
[]
[Transfers]
# FORWARD transfers
[toForward_measument]
type = MultiAppReporterTransfer
to_multi_app = forward
from_reporters = 'OptimizationReporter/parameter_results'
to_reporters = 'point_source/value'
[]
[fromForward]
type = MultiAppReporterTransfer
from_multi_app = forward
# Note: We are transferring the misfit values into main misfit
from_reporters = 'measure_data/misfit_norm measure_data/misfit_values'
to_reporters = 'OptimizationReporter/misfit_norm main/misfit_values'
[]
# ADJOINT transfers
#NOTE: the adjoint variable we are transferring is actually the gradient
[toAdjoint]
type = MultiAppReporterTransfer
# We are transferring directly from the forward app to the adjoint app
to_multi_app = adjoint
from_reporters = 'main/misfit_values'
to_reporters = 'misfit/misfit_values'
[]
[fromAdjoint]
type = MultiAppReporterTransfer
from_multi_app = adjoint
from_reporters = 'gradient/adjoint'
to_reporters = 'OptimizationReporter/grad_parameter_results'
[]
# HESSIAN transfers. Same as forward.
[toHomoForward]
type = MultiAppReporterTransfer
to_multi_app = homogeneousForward
from_reporters = 'OptimizationReporter/parameter_results'
to_reporters = 'point_source/value'
[]
[fromHomoForward]
type = MultiAppReporterTransfer
from_multi_app = homogeneousForward
# Note: We are transferring the simulation values into misfit
# this has to be done when using general opt and homogenous forward.
from_reporters = 'measure_data/simulation_values'
to_reporters = 'main/misfit_values'
[]
[]
[Reporters]
[optInfo]
type = OptimizationInfo
[]
[]
[Outputs]
csv = true
file_base = main_out
[]
(modules/optimization/examples/simpleTransient/forward_mesh.i)
[Mesh]
[gmg]
type = GeneratedMeshGenerator
dim = 2
nx = 10
ny = 10
xmin = -1
xmax = 1
ymin = -1
ymax = 1
[]
[]
[Variables]
[u]
[]
[]
[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 = ParameterMeshFunction
exodus_mesh = source_mesh_in.e
time_name = src_values/time
parameter_name = src_values/values
[]
[]
[Executioner]
type = Transient
num_steps = 100
end_time = 1
solve_type = NEWTON
petsc_options_iname = '-pc_type -pc_hypre_type'
petsc_options_value = 'hypre boomeramg'
[]
[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
objective_name = objective_value
execute_on = timestep_end
outputs = csv
[]
[src_values]
type = ConstantReporter
real_vector_names = 'time values'
real_vector_values = '0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0;
0' # dummy
[]
[]
[AuxVariables/source]
[]
[AuxKernels]
[source_aux]
type = FunctionAux
variable = source
function = source
[]
[]
[Outputs]
console = false
exodus = true
[]
(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
objective_name = objective_value
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
[]
[]
[Preconditioning]
[nl0]
type = SMP
nl_sys = 'nl0'
petsc_options_iname = '-pc_type'
petsc_options_value = 'lu'
[]
[adjoint]
type = SMP
nl_sys = 'adjoint'
petsc_options_iname = '-pc_type'
petsc_options_value = 'lu'
[]
[]
[Executioner]
type = TransientAndAdjoint
forward_system = nl0
adjoint_system = adjoint
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/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
[]
[]
[Preconditioning]
[nl0]
type = SMP
nl_sys = 'nl0'
petsc_options_iname = '-pc_type'
petsc_options_value = 'lu'
[]
[adjoint]
type = SMP
nl_sys = 'adjoint'
petsc_options_iname = '-pc_type'
petsc_options_value = 'lu'
[]
[]
[Executioner]
type = TransientAndAdjoint
forward_system = nl0
adjoint_system = adjoint
num_steps = 100
end_time = 1
nl_rel_tol = 1e-12
l_tol = 1e-12
[]
[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/examples/diffusion_reaction/optimize.i)
[Optimization]
[]
[OptimizationReporter]
type = ParameterMeshOptimization
objective_name = objective_value
parameter_names = 'reaction_rate'
parameter_meshes = 'parameter_mesh_out.e'
initial_condition = 0
lower_bounds = 0
[]
[Reporters]
[main]
type = OptimizationData
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
[]
[]
[MultiApps]
[forward]
type = FullSolveMultiApp
input_files = forward_and_adjoint.i
execute_on = FORWARD
[]
[]
[Transfers]
[to_forward]
type = MultiAppReporterTransfer
to_multi_app = forward
from_reporters = 'main/measurement_xcoord
main/measurement_ycoord
main/measurement_zcoord
main/measurement_time
main/measurement_values
OptimizationReporter/reaction_rate'
to_reporters = 'data/measurement_xcoord
data/measurement_ycoord
data/measurement_zcoord
data/measurement_time
data/measurement_values
params/reaction_rate'
[]
[from_forward]
type = MultiAppReporterTransfer
from_multi_app = forward
from_reporters = 'adjoint/inner_product data/objective_value'
to_reporters = 'OptimizationReporter/grad_reaction_rate OptimizationReporter/objective_value'
[]
[]
[Reporters]
[optInfo]
type = OptimizationInfo
items = 'current_iterate function_value gnorm'
[]
[]
[Executioner]
type = Optimize
tao_solver = taobqnls
petsc_options_iname = '-tao_gttol -tao_max_it'
#petsc_options_value = '1e-5 100' #use this to get results for paper
petsc_options_value = '1e-5 5'
solve_on = 'NONE'
verbose = true
[]
[Outputs]
csv = true
[]
(modules/optimization/test/tests/optimizationreporter/mesh_source/forward_and_adjoint.i)
[Mesh]
[gmg]
type = GeneratedMeshGenerator
dim = 2
nx = 10
ny = 10
[]
[]
[Problem]
nl_sys_names = 'nl0 adjoint'
kernel_coverage_check = false
[]
[Variables]
[u]
[]
[u_adjoint]
solver_sys = adjoint
[]
[]
[Kernels]
[diff]
type = Diffusion
variable = u
[]
[src]
type = BodyForce
variable = u
function = src_func
[]
[]
[BCs]
[dirichlet]
type = DirichletBC
variable = u
boundary = 'bottom left'
value = 0
[]
[]
[DiracKernels]
[pt]
type = ReporterPointSource
variable = u_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
[]
[]
[Functions]
[src_func]
type = ParameterMeshFunction
exodus_mesh = parameter_mesh_in.e
parameter_name = src_rep/vals
[]
[]
[Reporters]
[src_rep]
type = ConstantReporter
real_vector_names = 'vals'
real_vector_values = '1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0'
[]
[measure_data]
type = OptimizationData
variable = u
objective_name = objective_value
outputs = none
[]
[]
[VectorPostprocessors]
[gradient_vpp]
type = ElementOptimizationSourceFunctionInnerProduct
variable = u_adjoint
function = src_func
execute_on = ADJOINT_TIMESTEP_END
[]
[]
[Preconditioning]
[nl0]
type = SMP
nl_sys = 'nl0'
petsc_options_iname = '-pc_type'
petsc_options_value = 'lu'
[]
[adjoint]
type = SMP
nl_sys = 'adjoint'
petsc_options_iname = '-pc_type'
petsc_options_value = 'lu'
[]
[]
[Executioner]
type = SteadyAndAdjoint
forward_system = nl0
adjoint_system = adjoint
nl_rel_tol = 1e-12
l_tol = 1e-12
[]
[AuxVariables]
[source]
[]
[]
[AuxKernels]
[source_aux]
type = FunctionAux
variable = source
function = src_func
[]
[]
[Outputs]
exodus = true
console = true
execute_on = timestep_end
[]
(modules/combined/test/tests/optimization/invOpt_nonlinear/adjoint.i)
[Executioner]
type = Steady
solve_type = NEWTON
line_search = none
nl_abs_tol = 1e-12
nl_rel_tol = 1e-12
nl_max_its = 100
petsc_options_iname = '-pc_type'
petsc_options_value = 'lu'
[]
[Mesh]
[]
[Variables]
[adjointT]
[]
[]
[AuxVariables]
[forwardT]
[]
[dDdTgradT]
order = CONSTANT
family = MONOMIAL_VEC
[]
[]
[Kernels]
[heat_conduction]
type = ADHeatConduction
thermal_conductivity = 'linearized_conductivity'
variable = adjointT
[]
[advection]
type = LevelSetAdvection
velocity = dDdTgradT
variable = adjointT
[]
[]
[AuxKernels]
[dDdTgradT]
type = ADFunctorElementalGradientAux
functor = forwardT
variable = dDdTgradT
factor_matprop = 'dDdT'
[]
[]
[Materials]
[LinearizedConductivity]
type = ADParsedMaterial
f_name = 'linearized_conductivity'
function = '10+500*forwardT'
args = 'forwardT'
[]
[dDdT]
type = ADParsedMaterial
f_name = 'dDdT'
function = '500'
args = 'forwardT'
[]
[]
[DiracKernels]
[pt]
type = ReporterPointSource
variable = adjointT
x_coord_name = misfit/measurement_xcoord
y_coord_name = misfit/measurement_ycoord
z_coord_name = misfit/measurement_zcoord
value_name = misfit/misfit_values
[]
[]
[Reporters]
[misfit]
type = OptimizationData
[]
[params]
type = ConstantReporter
real_vector_names = 'heat_source'
real_vector_values = '0' # Dummy
[]
[]
[BCs]
[left]
type = NeumannBC
variable = adjointT
boundary = left
value = 0
[]
[right]
type = NeumannBC
variable = adjointT
boundary = right
value = 0
[]
[bottom]
type = DirichletBC
variable = adjointT
boundary = bottom
value = 0
[]
[top]
type = DirichletBC
variable = adjointT
boundary = top
value = 0
[]
[]
[VectorPostprocessors]
[gradient_vpp]
type = ElementOptimizationSourceFunctionInnerProduct
function = volumetric_heat_func
variable = adjointT
[]
[]
[Functions]
[volumetric_heat_func]
type = ParsedOptimizationFunction
expression = q
param_symbol_names = 'q'
param_vector_name = 'params/heat_source'
[]
[]
[Outputs]
console = false
[]
(modules/combined/test/tests/optimization/invOpt_elasticity_modular/grad.i)
[Mesh]
[gmg]
type = GeneratedMeshGenerator
dim = 2
nx = 11
ny = 11
xmin = -4
xmax = 4
ymin = -4
ymax = 4
[]
displacements = 'adj_disp_x adj_disp_y'
[]
[Variables]
# adjoint
[adj_disp_x]
[]
[adj_disp_y]
[]
[]
[AuxVariables]
[dummy]
[]
[T]
[]
# displacement variables to be transferred from the forward app
# we use them to compute stress and stress derivative wrt E
[disp_x]
[]
[disp_y]
[]
[]
[DiracKernels]
[misfit_is_adjoint_force]
type = ReporterPointSource
variable = adj_disp_x
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]
displacements = 'adj_disp_x adj_disp_y'
[adjoint]
strain = SMALL
new_system = true
formulation = TOTAL
incremental = true
volumetric_locking_correction = false
displacements = 'adj_disp_x adj_disp_y'
# 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'
[]
[]
[]
[]
[NEML2]
input = 'elasticity.i'
verbose = true
device = 'cpu'
[forward]
model = 'forward_elasticity_model'
moose_input_types = 'MATERIAL'
moose_inputs = 'forward_strain'
neml2_inputs = 'forces/E'
moose_parameter_types = 'MATERIAL'
moose_parameters = 'E_material'
neml2_parameters = 'E'
moose_output_types = 'MATERIAL'
moose_outputs = 'forward_stress'
neml2_outputs = 'state/S'
moose_parameter_derivative_types = 'MATERIAL'
moose_parameter_derivatives = 'forward_dstress_dE'
neml2_parameter_derivatives = 'state/S E'
[]
[adjoint]
model = 'adjoint_elasticity_model'
moose_input_types = 'MATERIAL'
moose_inputs = 'adjoint_strain'
neml2_inputs = 'forces/E'
moose_parameter_types = 'MATERIAL'
moose_parameters = 'E_material'
neml2_parameters = 'E'
moose_output_types = 'MATERIAL'
moose_outputs = 'adjoint_stress'
neml2_outputs = 'state/S'
moose_derivative_types = 'MATERIAL'
moose_derivatives = 'adjoint_jacobian'
neml2_derivatives = 'state/S forces/E'
[]
[]
[BCs]
[bottom_ux]
type = DirichletBC
variable = adj_disp_x
boundary = bottom
value = 0.0
[]
[bottom_uy]
type = DirichletBC
variable = adj_disp_y
boundary = bottom
value = 0.0
[]
[]
[Materials]
[E_material]
type = GenericFunctionMaterial
prop_names = 'E_material'
prop_values = 'E'
[]
# forward
[forward_strain]
type = ComputeLagrangianStrain
displacements = 'disp_x disp_y'
base_name = 'forward'
[]
[convert_forward_strain]
type = RankTwoTensorToSymmetricRankTwoTensor
from = 'forward_mechanical_strain'
to = 'forward_strain'
[]
# adjoint
[convert_adjoint_strain]
type = RankTwoTensorToSymmetricRankTwoTensor
from = 'adjoint_mechanical_strain'
to = 'adjoint_strain'
[]
[adjoint_stress]
type = ComputeLagrangianObjectiveCustomSymmetricStress
custom_small_stress = 'adjoint_stress'
custom_small_jacobian = 'adjoint_jacobian'
base_name = 'adjoint'
[]
[]
[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 = 'adj_disp_x'
[]
[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
nl_rel_tol = 1e-10
nl_abs_tol = 1e-14
[]
[Outputs]
file_base = 'adjoint'
console = false
[]
(modules/optimization/examples/materialTransient/optimize_auto_adjoint.i)
[Optimization]
[]
[OptimizationReporter]
type = GeneralOptimization
objective_name = objective_value
parameter_names = 'D'
num_values = '4'
initial_condition = '0.01 0.01 0.01 0.01'
upper_bounds = '1e2'
lower_bounds = '1e-3'
[]
[Reporters]
[main]
type = OptimizationData
measurement_file = forward_out_data_0011.csv
file_xcoord = measurement_xcoord
file_ycoord = measurement_ycoord
file_zcoord = measurement_zcoord
file_time = measurement_time
file_value = simulation_values
[]
[]
[MultiApps]
[forward]
type = FullSolveMultiApp
input_files = forward_and_adjoint.i
execute_on = FORWARD
[]
[]
[Transfers]
[to_forward]
type = MultiAppReporterTransfer
to_multi_app = forward
from_reporters = 'main/measurement_xcoord
main/measurement_ycoord
main/measurement_zcoord
main/measurement_time
main/measurement_values
OptimizationReporter/D'
to_reporters = 'data/measurement_xcoord
data/measurement_ycoord
data/measurement_zcoord
data/measurement_time
data/measurement_values
diffc_rep/D_vals'
[]
[from_forward]
type = MultiAppReporterTransfer
from_multi_app = forward
from_reporters = 'data/objective_value
adjoint/inner_product'
to_reporters = 'OptimizationReporter/objective_value
OptimizationReporter/grad_D'
[]
[]
[Executioner]
type = Optimize
tao_solver = taobqnls
petsc_options_iname = '-tao_gatol'
petsc_options_value = '1e-4'
[]
(modules/optimization/examples/diffusion_reaction_XYDelaunay/optimize.i)
[Optimization]
[]
[OptimizationReporter]
type = ParameterMeshOptimization
objective_name = objective_value
parameter_names = 'reaction_rate'
parameter_meshes = 'parameter_mesh_out.e'
lower_bounds = 0
[]
[Reporters]
[main]
type = OptimizationData
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
[]
[]
[MultiApps]
[forward]
type = FullSolveMultiApp
input_files = forward_and_adjoint.i
execute_on = FORWARD
[]
[]
[Transfers]
[to_forward]
type = MultiAppReporterTransfer
to_multi_app = forward
from_reporters = 'main/measurement_xcoord
main/measurement_ycoord
main/measurement_zcoord
main/measurement_time
main/measurement_values
OptimizationReporter/reaction_rate'
to_reporters = 'data/measurement_xcoord
data/measurement_ycoord
data/measurement_zcoord
data/measurement_time
data/measurement_values
params/reaction_rate'
[]
[from_forward]
type = MultiAppReporterTransfer
from_multi_app = forward
from_reporters = 'adjoint/inner_product data/objective_value'
to_reporters = 'OptimizationReporter/grad_reaction_rate OptimizationReporter/objective_value'
[]
[]
[Reporters]
[optInfo]
type = OptimizationInfo
items = 'current_iterate function_value gnorm'
[]
[]
[Executioner]
type = Optimize
tao_solver = taobqnls
petsc_options_iname = '-tao_gttol -tao_max_it'
petsc_options_value = '1e-5 5'
# petsc_options_iname='-tao_fd_test -tao_test_gradient -tao_fd_gradient -tao_fd_delta'
# petsc_options_value='true true false 1e-8'
# petsc_options = '-tao_test_gradient_view'
solve_on = 'NONE'
verbose = true
[]
[Outputs]
csv = true
[]
(modules/optimization/test/tests/optimizationreporter/optimizationdata/two_vars_file.i)
[Mesh]
[gmg]
type = GeneratedMeshGenerator
dim = 2
nx = 2
ny = 2
[]
[]
[Problem]
solve=false
[]
[AuxVariables]
[disp_x]
order = CONSTANT
family = MONOMIAL
[]
[disp_y]
order = CONSTANT
family = MONOMIAL
[]
[T]
order = FIRST
family = LAGRANGE
[]
[]
[AuxKernels]
[aux_disp_x]
type = ParsedAux
variable = disp_x
use_xyzt = true
expression = 'if(x<0.5,2,4)'
[]
[aux_disp_y]
type = ParsedAux
variable = disp_y
use_xyzt = true
expression = 'if(y<0.5,10,50)'
[]
[aux_T]
type = ParsedAux
variable = T
use_xyzt = true
expression = 'x'
[]
[]
[Reporters]
[measure_data]
type = OptimizationData
measurement_file = 'measurementData.csv'
file_value = 'measured_value'
variable = 'disp_x disp_y T'
file_variable_weights = 'weight_u v_weight wT'
variable_weight_names = 'weight_u v_weight wT'
[]
[]
[BCs]
[]
[Executioner]
type = Steady
[]
[Outputs]
csv = true
exodus=true
[]
[Debug]
show_reporters = false
[]
(modules/optimization/test/tests/optimizationreporter/function_misfit/main_auto.i)
measurement_points = '0.5 0.28 0
0.5 0.6 0
0.5 0.8 0
0.5 1.1 0'
measurement_values = '293 304 315 320'
[Optimization]
[]
[OptimizationReporter]
type = GeneralOptimization
objective_name = objective_value
parameter_names = 'parameter_results'
num_values = '3'
[]
[Reporters]
[main]
type = OptimizationData
measurement_points = ${measurement_points}
measurement_values = ${measurement_values}
[]
[]
[Executioner]
type = Optimize
tao_solver = taobqnktr
petsc_options_iname = '-tao_gatol'
petsc_options_value = '1e-8'
verbose = true
[]
[MultiApps]
[forward]
type = FullSolveMultiApp
input_files = forward_and_adjoint.i
execute_on = "FORWARD"
[]
[]
[Transfers]
# FORWARD transfers
[toForward_measument]
type = MultiAppReporterTransfer
to_multi_app = forward
from_reporters = 'main/measurement_xcoord
main/measurement_ycoord
main/measurement_zcoord
main/measurement_time
main/measurement_values
OptimizationReporter/parameter_results'
to_reporters = 'measure_data/measurement_xcoord
measure_data/measurement_ycoord
measure_data/measurement_zcoord
measure_data/measurement_time
measure_data/measurement_values
point_source/value'
[]
[fromForward]
type = MultiAppReporterTransfer
from_multi_app = forward
from_reporters = 'objective/value
gradient/temperature_adjoint'
to_reporters = 'OptimizationReporter/objective_value
OptimizationReporter/grad_parameter_results'
[]
[]
[Outputs]
csv = true
[]
(modules/optimization/test/tests/optimizationreporter/bc_load_linearFunction/homogeneous_forward.i)
[Mesh]
[]
[Variables]
[temperature]
[]
[]
[Kernels]
[heat_conduction]
type = MatDiffusion
variable = temperature
diffusivity = thermal_conductivity
[]
[]
[BCs]
[left]
type = FunctionNeumannBC
variable = temperature
boundary = left
function = left_function
[]
[right]
type = FunctionNeumannBC
variable = temperature
boundary = right
function = right_function
[]
[bottom]
type = DirichletBC
variable = temperature
boundary = bottom
value = 0
[]
[top]
type = DirichletBC
variable = temperature
boundary = top
value = 0
[]
[]
[Functions]
[left_function]
type = ParsedOptimizationFunction
expression = 'a + b*y'
param_symbol_names = 'a b'
param_vector_name = 'params_left/vals'
[]
[right_function]
type = ParsedOptimizationFunction
expression = 'a'
param_symbol_names = 'a'
param_vector_name = 'params_right/vals'
[]
[]
[Materials]
[steel]
type = GenericConstantMaterial
prop_names = thermal_conductivity
prop_values = 5
[]
[]
[Executioner]
type = Steady
line_search = none
solve_type = NEWTON
nl_abs_tol = 1e-8
nl_rel_tol = 1e-8
petsc_options_iname = '-ksp_type -pc_type -pc_factor_mat_solver_package'
petsc_options_value = 'preonly lu superlu_dist'
[]
[VectorPostprocessors]
[vertical_1]
type = LineValueSampler
variable = 'temperature'
start_point = '0.2 0.0 0'
end_point = '0.2 2.0 0'
num_points = 21
sort_by = y
[]
[vertical_2]
type = LineValueSampler
variable = 'temperature'
start_point = '0.8 0.0 0'
end_point = '0.8 2.0 0'
num_points = 21
sort_by = y
[]
[]
[Reporters]
[measure_data]
type = OptimizationData
variable_weight_names = weightForTemperature
variable = temperature
[]
[params_left]
type = ConstantReporter
real_vector_names = 'vals'
real_vector_values = '0 0' # Dummy
[]
[params_right]
type = ConstantReporter
real_vector_names = 'vals'
real_vector_values = '0' # Dummy
[]
[]
[Outputs]
console = false
exodus = false
file_base = 'homogenous'
[]