-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #55 from lynnmunday/vectorNearPointFunctionSteady
vectorNearestPointFunction steady state example
- Loading branch information
Showing
8 changed files
with
387 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
[Mesh] | ||
[gmg] | ||
type = GeneratedMeshGenerator | ||
dim = 2 | ||
nx = 20 | ||
ny = 25 | ||
xmin = -1 | ||
xmax = 1 | ||
ymin = -1 | ||
ymax = 1.5 | ||
[] | ||
[] | ||
|
||
[Problem] | ||
extra_tag_vectors = 'ref' | ||
[] | ||
|
||
[AuxVariables] | ||
[residual_src] | ||
[] | ||
[] | ||
|
||
[AuxKernels] | ||
[residual_src] | ||
type = TagVectorAux | ||
vector_tag = 'ref' | ||
v = 'u' | ||
variable = 'residual_src' | ||
[] | ||
[] | ||
|
||
|
||
[Variables] | ||
[u] | ||
[] | ||
[] | ||
|
||
[Kernels] | ||
[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 = syntheticLineData.csv | ||
file_xcoord = x | ||
file_ycoord = y | ||
file_zcoord = z | ||
file_value = u | ||
[] | ||
[] | ||
|
||
[DiracKernels] | ||
[misfit] | ||
type = VectorPointSource | ||
variable = u | ||
value = measured_data/misfit_values | ||
coord_x = measured_data/measurement_xcoord | ||
coord_y = measured_data/measurement_ycoord | ||
coord_z = measured_data/measurement_zcoord | ||
extra_vector_tags = 'ref' | ||
[] | ||
[] | ||
|
||
[VectorPostprocessors] | ||
[src_values] | ||
type = CSVReader | ||
csv_file = source_params.csv | ||
header = true | ||
[] | ||
[] | ||
|
||
[Functions] | ||
[source] | ||
type = VectorNearestPointFunction | ||
coord_x = src_values/coordx | ||
coord_y = src_values/coordy | ||
time = src_values/time | ||
value = src_values/values | ||
[] | ||
[] | ||
|
||
[VectorPostprocessors] | ||
[adjoint] | ||
type = ElementOptimizationSourceFunctionInnerProduct | ||
variable = u | ||
function = source | ||
[] | ||
[] | ||
|
||
[Executioner] | ||
type = Steady | ||
solve_type = NEWTON | ||
line_search=none | ||
petsc_options_iname = '-pc_type' | ||
petsc_options_value = 'lu' | ||
[] | ||
|
||
[Outputs] | ||
console = false | ||
[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
[Mesh] | ||
[gmg] | ||
type = GeneratedMeshGenerator | ||
dim = 2 | ||
nx = 20 | ||
ny = 25 | ||
xmin = -1 | ||
xmax = 1 | ||
ymin = -1 | ||
ymax = 1.5 | ||
[] | ||
[] | ||
|
||
[Problem] | ||
extra_tag_vectors = 'ref' | ||
[] | ||
|
||
[AuxVariables] | ||
[residual_src] | ||
[] | ||
[] | ||
|
||
[AuxKernels] | ||
[residual_src] | ||
type = TagVectorAux | ||
vector_tag = 'ref' | ||
v = 'u' | ||
variable = 'residual_src' | ||
[] | ||
[] | ||
|
||
[Variables] | ||
[u] | ||
[] | ||
[] | ||
|
||
[VectorPostprocessors] | ||
#---------- BEGIN: VPP for optimization | ||
[src_values] | ||
type = CSVReader | ||
csv_file = source_params.csv | ||
header = true | ||
[] | ||
#---------- END: VPP for optimization | ||
|
||
# #---------- BEGIN: VPP for synthetic data simulations | ||
# [src_values] | ||
# type = CSVReader | ||
# csv_file = synthetic_source_params.csv | ||
# header = true | ||
# [] | ||
# [line1] | ||
# type = LineValueSampler | ||
# start_point = '0.5 -0.9 0' | ||
# end_point = '0.5 1.4 0' | ||
# num_points = 5 | ||
# sort_by = id | ||
# variable = u | ||
# [] | ||
# [line2] | ||
# type = LineValueSampler | ||
# start_point = '-0.5 -0.9 0' | ||
# end_point = '-0.5 1.4 0' | ||
# num_points = 5 | ||
# sort_by = id | ||
# variable = u | ||
# [] | ||
# #----- END: VPP for synthetic data simulations | ||
[] | ||
|
||
|
||
[Kernels] | ||
[diff] | ||
type = Diffusion | ||
variable = u | ||
[] | ||
[src] | ||
type = BodyForce | ||
variable = u | ||
function = source | ||
extra_vector_tags = 'ref' | ||
[] | ||
[] | ||
|
||
[BCs] | ||
[dirichlet] | ||
type = DirichletBC | ||
variable = u | ||
boundary = 'left right top bottom' | ||
value = 0 | ||
[] | ||
[] | ||
|
||
[Functions] | ||
[source] | ||
type = VectorNearestPointFunction | ||
coord_x = src_values/coordx | ||
coord_y = src_values/coordy | ||
time = src_values/time | ||
value = src_values/values | ||
[] | ||
[] | ||
|
||
[Executioner] | ||
type = Steady | ||
solve_type = NEWTON | ||
line_search=none | ||
petsc_options_iname = '-pc_type' | ||
petsc_options_value = 'lu' | ||
[] | ||
|
||
[Reporters] | ||
[measured_data] | ||
type = OptimizationData | ||
measurement_file = syntheticLineData.csv | ||
file_xcoord = x | ||
file_ycoord = y | ||
file_zcoord = z | ||
file_value = u | ||
variable = u | ||
execute_on = timestep_end | ||
[] | ||
[] | ||
|
||
[Outputs] | ||
console = false | ||
[] |
11 changes: 11 additions & 0 deletions
11
examples/simpleSteady/gold/main_out_OptimizationReporter_0001.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
adjoint,measurement_time,measurement_values,measurement_xcoord,measurement_ycoord,measurement_zcoord,misfit_values,simulation_values,source | ||
0,0,0.12167978288653,0,0,0,0,0.12167978288653,1 | ||
0,0,0.45533154094397,0,0,0,0,0.45533154094397,2 | ||
0,0,0.47326307589773,0,0,0,0,0.47326307589773,-1 | ||
0,0,0.3925248098792,0,0,0,0,0.3925248098792,3 | ||
0,0,0.09631748263822,0,0,0,0,0.09631748263822,0 | ||
0,0,-0.0034929354865351,0,0,0,0,-0.0034929354865347,0 | ||
0,0,0.085617624411979,0,0,0,0,0.085617624411979,0 | ||
0,0,0.27245239918046,0,0,0,0,0.27245239918046,0 | ||
0,0,0.27032670013135,0,0,0,0,0.27032670013135,0 | ||
0,0,0.06274715505589,0,0,0,0,0.06274715505589,0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
[StochasticTools] | ||
[] | ||
|
||
[OptimizationReporter] | ||
type = ObjectiveGradientMinimize | ||
|
||
parameter_names = 'source' | ||
num_values = '4' | ||
[] | ||
|
||
[Executioner] | ||
type = Optimize | ||
# tao_solver = taolmvm | ||
# petsc_options_iname='-tao_gatol' | ||
# petsc_options_value='1e-3' | ||
|
||
tao_solver = taonls | ||
petsc_options_iname = '-tao_gttol -tao_nls_pc_type -tao_nls_ksp_type' | ||
petsc_options_value = '1e-5 none cg' | ||
|
||
verbose = true | ||
[] | ||
|
||
[MultiApps] | ||
[forward] | ||
type = OptimizeFullSolveMultiApp | ||
input_files = forward.i | ||
execute_on = FORWARD | ||
[] | ||
[adjoint] | ||
type = OptimizeFullSolveMultiApp | ||
input_files = adjoint.i | ||
execute_on = ADJOINT | ||
[] | ||
[homogeneous_forward] | ||
type = OptimizeFullSolveMultiApp | ||
input_files = forward.i | ||
execute_on = "HOMOGENEOUS_FORWARD" | ||
[] | ||
[] | ||
|
||
[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/simulation_values | ||
measured_data/measurement_values | ||
measured_data/measurement_time' | ||
to_reporters = 'OptimizationReporter/misfit_values | ||
OptimizationReporter/simulation_values | ||
OptimizationReporter/measurement_values | ||
OptimizationReporter/measurement_time' | ||
[] | ||
|
||
[to_adjoint] | ||
type = MultiAppReporterTransfer | ||
to_multi_app = adjoint | ||
from_reporters = 'OptimizationReporter/source OptimizationReporter/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/adjoint' | ||
[] | ||
|
||
[to_homogeneous_forward] | ||
type = MultiAppReporterTransfer | ||
to_multi_app = homogeneous_forward | ||
from_reporters = 'OptimizationReporter/source' | ||
to_reporters = 'src_values/values' | ||
[] | ||
|
||
[from_homogeneous_forward] | ||
type = MultiAppReporterTransfer | ||
from_multi_app = homogeneous_forward | ||
from_reporters = 'measured_data/misfit_values | ||
measured_data/simulation_values | ||
measured_data/measurement_values | ||
measured_data/measurement_time' | ||
to_reporters = 'OptimizationReporter/misfit_values | ||
OptimizationReporter/simulation_values | ||
OptimizationReporter/measurement_values | ||
OptimizationReporter/measurement_time' | ||
[] | ||
|
||
[] | ||
|
||
[Outputs] | ||
csv=true | ||
[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
coordx,coordy,time,values | ||
-0.5,0.5,0.0,.0 | ||
0.5,0.5,0.0,.0 | ||
-0.5,-0.5,0.0,.0 | ||
0.5,-0.5,0.0,.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
id,u,x,y,z | ||
0,0.12167978288653,0.5,-0.9,0 | ||
0.575,0.45533154094397,0.5,-0.325,0 | ||
1.15,0.47326307589773,0.5,0.25,0 | ||
1.725,0.3925248098792,0.5,0.825,0 | ||
2.3,0.09631748263822,0.5,1.4,0 | ||
0,-0.0034929354865351,-0.5,-0.9,0 | ||
0.575,0.085617624411979,-0.5,-0.325,0 | ||
1.15,0.27245239918046,-0.5,0.25,0 | ||
1.725,0.27032670013135,-0.5,0.825,0 | ||
2.3,0.06274715505589,-0.5,1.4,0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
coordx,coordy,time,values | ||
-0.5,0.5,0.0,1.0 | ||
0.5,0.5,0.0,2.0 | ||
-0.5,-0.5,0.0,-1.0 | ||
0.5,-0.5,0.0,3.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[Tests] | ||
[Steady] | ||
design = 'VectorNearestPointFunction.md' | ||
issues = '#52' | ||
[hessian] | ||
type = CSVDiff | ||
input = main.i | ||
csvdiff = main_out_OptimizationReporter_0001.csv | ||
rel_err = 0.01 | ||
max_threads = 1 | ||
# steady solve | ||
recover = false | ||
requirement = 'The system shall be able to perform hessian based steady state force-inversion optimization for a body force described by the VectorNearestPointFunction' | ||
[] | ||
[] | ||
[] |