Skip to content

Commit

Permalink
inversion test using piecewiseMultiLinearFromReporter or piecewiseMul…
Browse files Browse the repository at this point in the history
…tiConstantFromReporter to describe body force
  • Loading branch information
lynnmunday committed Sep 16, 2022
1 parent 3d8651f commit 07101e8
Show file tree
Hide file tree
Showing 15 changed files with 895 additions and 518 deletions.
2 changes: 0 additions & 2 deletions examples/simpleSteadyGriddedData/adjoint.i
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@
[Functions]
[source]
type = PiecewiseMultilinearFromReporter
# type = PiecewiseMulticonstantFromReporter
# direction = 'right right'
values_name = 'gridData/parameter'
grid_name = 'gridData/grid'
axes_name = 'gridData/axes'
Expand Down
112 changes: 112 additions & 0 deletions examples/simpleSteadyGriddedData/adjoint_const.i
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
[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 = syntheticNodal.csv
file_xcoord = x
file_ycoord = y
file_zcoord = z
file_value = u
[]
[gridData]
type = GriddedDataReporter
data_file = 'gridded_source_params_const.txt'
outputs = none
[]
[]

[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'
[]
[]

[Functions]
[source]
type = PiecewiseMulticonstantFromReporter
direction = 'right right'
values_name = 'gridData/parameter'
grid_name = 'gridData/grid'
axes_name = 'gridData/axes'
step_name = 'gridData/step'
dim_name = 'gridData/dim'
[]
[]

[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
[]
69 changes: 36 additions & 33 deletions examples/simpleSteadyGriddedData/forward.i
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,15 @@
[]

[Functions]
###----- Function to produce BodyForce for synthetic measurement data
# [synthetic]
# type = ParsedFunction
# vars='A1 L1 C1 A2 L2 C2'
# vals='10 1.5 0 -10 2 0'
# value = 'A1*sin(2*pi/L1*(x+C1))*A2*sin(2*pi/L2*(y+C2))'
# []
[source]
type = PiecewiseMultilinearFromReporter
# type = PiecewiseMulticonstantFromReporter
# direction = 'right right'
values_name = 'gridData/parameter'
grid_name = 'gridData/grid'
axes_name = 'gridData/axes'
Expand All @@ -87,44 +92,42 @@
file_value = u
variable = u
execute_on = timestep_end
outputs=none
[]
[gridData]
type = GriddedDataReporter
data_file = 'gridded_source_params.txt'
outputs = none
[]
[gridData]
type = GriddedDataReporter
data_file = 'gridded_source_params.txt'
outputs = none
[]

[]

[VectorPostprocessors]
#----- BEGIN: VPP produce synthetic data
[nodal]
type = NodalValueSampler
sort_by = id
variable = u
[]
[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 produce synthetic data
###----- VPP produce synthetic measurement data
# [nodal]
# type = NodalValueSampler
# sort_by = id
# variable = u
# []
[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
[]
[]


[Outputs]
# exodus = true
# csv = true
csv = true
console = false
[]
121 changes: 121 additions & 0 deletions examples/simpleSteadyGriddedData/forward_const.i
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
[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
[]
[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 = PiecewiseMulticonstantFromReporter
direction = 'right right'
values_name = 'gridData/parameter'
grid_name = 'gridData/grid'
axes_name = 'gridData/axes'
step_name = 'gridData/step'
dim_name = 'gridData/dim'
[]
[]

[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 = syntheticNodal.csv
file_xcoord = x
file_ycoord = y
file_zcoord = z
file_value = u
variable = u
execute_on = timestep_end
outputs=none
[]
[gridData]
type = GriddedDataReporter
data_file = 'gridded_source_params_const.txt'
outputs = none
[]
[]

[VectorPostprocessors]
[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
[]
[]

[Outputs]
# exodus = true
csv = true
console = false
[]
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
id,u,x,y,z
0,0.95658362042007,0.5,-0.9,0
0.575,2.64660281359,0.5,-0.325,0
1.15,-2.2110578584852,0.5,0.25,0
1.725,-1.8473258313108,0.5,0.825,0
2.3,0.22880461118954,0.5,1.4,0
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
id,u,x,y,z
0,-1.1018382492446,-0.5,-0.9,0
0.575,-3.0657575989378,-0.5,-0.325,0
1.15,2.5360977137657,-0.5,0.25,0
1.725,2.0016608223546,-0.5,0.825,0
2.3,-0.341436174908,-0.5,1.4,0

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
id,u,x,y,z
0,1.1407467839022,0.5,-0.9,0
0.575,3.1192716676809,0.5,-0.325,0
1.15,-2.6175760590462,0.5,0.25,0
1.725,-2.3228716525221,0.5,0.825,0
2.3,0.93284289946732,0.5,1.4,0
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
id,u,x,y,z
0,-1.1407523117604,-0.5,-0.9,0
0.575,-3.1192698998733,-0.5,-0.325,0
1.15,2.6175760032011,-0.5,0.25,0
1.725,2.3228698004762,-0.5,0.825,0
2.3,-0.9328373862911,-0.5,1.4,0
19 changes: 8 additions & 11 deletions examples/simpleSteadyGriddedData/gridded_source_params.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
# This is from source_params.csv
AXIS X
-0.8 0 0.8
-1.0 -0.35 0.35 1.0
AXIS Y
-0.8 0 1.3
-1.0 -0.5 0 0.5 1.0 1.5
DATA
-1
9
-3
7
-5
5
-7
3
-9
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
Loading

0 comments on commit 07101e8

Please sign in to comment.