Skip to content

Commit

Permalink
Force inversion with nonlinear diffusion problem, where the conductiv…
Browse files Browse the repository at this point in the history
…ity is a function of temperature. Gradient computation is checked with FD gradient and passes, and the tests include both limited memory BFGS as well as reduced Newton's method with matrix-free Hessian. closes idaholab#25
  • Loading branch information
mguddati authored and dschwen committed Aug 24, 2022
1 parent 6c0398c commit 718da22
Show file tree
Hide file tree
Showing 12 changed files with 1,221 additions and 1 deletion.
2 changes: 1 addition & 1 deletion modules/optimization/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ EXTERNAL_PETSC_SOLVER := no
FLUID_PROPERTIES := no
FUNCTIONAL_EXPANSION_TOOLS := no
HEAT_CONDUCTION := yes
LEVEL_SET := no
LEVEL_SET := yes
MISC := no
NAVIER_STOKES := no
PHASE_FIELD := no
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
[Mesh]
type = GeneratedMesh
dim = 2
nx = 10
ny = 10
xmin = 0
xmax = 3.141
ymin = 0
ymax = 3.141
[]



[Variables]
[u]
[]
[v]
[]
[]

[ICs]
[./u_ic]
type = FunctionIC
variable = 'u'
function = parsed_function
[../]
[./v_ic]
type = FunctionIC
variable = 'v'
function = 'x'
[../]
[]

[Functions]
[./parsed_function]
type = ParsedFunction
value = 'sin(x)-cos(y/2)'
[../]
[./parsed_grad_function]
type = ParsedVectorFunction
value_x = 'cos(x)'
value_y = 'sin(y/2)/2'
[../]
[./parsed_gradx_function]
type = ParsedFunction
value = 'cos(x)'
[../]
[]

[AuxVariables]
[./funcGrad_u]
order = CONSTANT
family = MONOMIAL_VEC
[../]
[./auxGrad_u]
order = CONSTANT
family = MONOMIAL_VEC
[../]
[./auxGrad_v]
order = CONSTANT
family = MONOMIAL_VEC
[../]
[./funcGrad_u_x]
order = CONSTANT
family = MONOMIAL
[../]
[./auxGrad_u_x]
order = CONSTANT
family = MONOMIAL
[../]
[./auxGrad_v_x]
order = CONSTANT
family = MONOMIAL
[../]
[]

[AuxKernels]
[vec]
type = VectorFunctionAux
variable = funcGrad_u
function = parsed_grad_function
[../]
[grad_u]
type = MaterialScaledGradientVector
gradient_variable = u
variable = auxGrad_u
[]
[grad_v]
type = MaterialScaledGradientVector
gradient_variable = v
variable = auxGrad_v
material_scaling = 'trig_material'
[]
[funcGrad_u_x]
type = VectorVariableComponentAux
variable = funcGrad_u_x
vector_variable = funcGrad_u
component = 'x'
[]
[auxGrad_u_x]
type = VectorVariableComponentAux
variable = auxGrad_u_x
vector_variable = auxGrad_u
component = 'x'
[]
[auxGrad_v_x]
type = VectorVariableComponentAux
variable = auxGrad_v_x
vector_variable = auxGrad_v
component = 'x'
[]
[]

[Materials]
[steel]
type = GenericFunctionMaterial
prop_names = 'trig_material'
prop_values = 'parsed_gradx_function'
[]
[]

[VectorPostprocessors]
[results]
type = LineValueSampler
start_point = '0 1 0'
end_point = '3.141 1 0'
variable = 'funcGrad_u_x auxGrad_u_x auxGrad_v_x'
num_points = 20
sort_by = x
[]
[]

[Problem]
solve = false
[]
[Executioner]
type = Steady
[]

[Outputs]
# console = true
csv = true
[]
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
[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 = MaterialScaledGradientVector
gradient_variable = forwardT
variable = dDdTgradT
material_scaling = 'dDdT'
[]
[]
[Materials]
[LinearizedConductivity]
type = ADParsedMaterial
f_name = 'linearized_conductivity'
function = '10+500*forwardT'
args = 'forwardT'
[]
[dDdT]
type = ParsedMaterial
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
[]
[]


[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 = VectorOfPostprocessors
postprocessors = 'heatSourceGradient'
[]
[]
[Postprocessors]
[heatSourceGradient]
type = VariableFunctionElementIntegral
function = volumetric_heat_func_deriv
variable = adjointT
[]
[]
[Functions]
[volumetric_heat_func_deriv]
type = ParsedFunction
value = dq
vars = 'dq'
vals = 1
[]
[]


[Outputs]
console = false
[]
Loading

0 comments on commit 718da22

Please sign in to comment.