From 28cdd39817460371d3edc320f34e9b0e09dbcc39 Mon Sep 17 00:00:00 2001 From: dewenyushu Date: Fri, 9 Jun 2023 11:59:15 -0700 Subject: [PATCH] Add elastic inversion capability using batch materials Add documentation and tests Refs #352 --- Makefile | 3 +- .../source/userobjects/BatchStressGrad.md | 22 ++ .../AdjointStrainStressGradInnerProduct.md | 23 ++ include/userobjects/BatchStressGrad.h | 33 +++ .../AdjointStrainStressGradInnerProduct.h | 31 +++ src/userobjects/BatchStressGrad.C | 46 ++++ .../AdjointStrainStressGradInnerProduct.C | 48 +++++ .../main_out_OptimizationReporter_0001.csv | 10 + .../grad.i | 204 ++++++++++++++++++ .../main.i | 126 +++++++++++ .../model.i | 166 ++++++++++++++ .../tests | 16 ++ 12 files changed, 727 insertions(+), 1 deletion(-) create mode 100644 doc/content/source/userobjects/BatchStressGrad.md create mode 100644 doc/content/source/vectorpostprocessors/AdjointStrainStressGradInnerProduct.md create mode 100644 include/userobjects/BatchStressGrad.h create mode 100644 include/vectorpostprocessors/AdjointStrainStressGradInnerProduct.h create mode 100644 src/userobjects/BatchStressGrad.C create mode 100644 src/vectorpostprocessors/AdjointStrainStressGradInnerProduct.C create mode 100644 test/tests/bimaterial_elastic_inversion_batch_mat/gold/main_out_OptimizationReporter_0001.csv create mode 100644 test/tests/bimaterial_elastic_inversion_batch_mat/grad.i create mode 100644 test/tests/bimaterial_elastic_inversion_batch_mat/main.i create mode 100644 test/tests/bimaterial_elastic_inversion_batch_mat/model.i create mode 100644 test/tests/bimaterial_elastic_inversion_batch_mat/tests diff --git a/Makefile b/Makefile index 9606bc593..a0fab8ab4 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ ############################################################################### # # Optional Environment variables -# MOOSE_DIR - Root directory of the MOOSE project +# MOOSE_DIR - Root directory of the MOOSE project # ############################################################################### # Use the MOOSE submodule if it exists and MOOSE_DIR is not set @@ -40,6 +40,7 @@ TENSOR_MECHANICS := yes WATER_STEAM_EOS := no XFEM := yes POROUS_FLOW := no +OPTIMIZATION := yes include $(MOOSE_DIR)/modules/modules.mk ############################################################################### diff --git a/doc/content/source/userobjects/BatchStressGrad.md b/doc/content/source/userobjects/BatchStressGrad.md new file mode 100644 index 000000000..fad967931 --- /dev/null +++ b/doc/content/source/userobjects/BatchStressGrad.md @@ -0,0 +1,22 @@ +# BatchStressGrad + +## Description + +This `UserObject` computes double contraction of the elastic tensor derivative and the forward mechanical strain, i.e., +\begin{equation} +\underbrace{\frac{\partial \boldsymbol{C}}{\partial p}}_{\text{elastic tensor derivative}} \underbrace{(\boldsymbol{L} u)}_{\text{forward strain}} +\end{equation} +as a batch material. +Here, the $\boldsymbol{C}$ is the elastic tensor, $p$ is the interested parameter, $\boldsymbol{L}$ is the differential operator for elasticity problem, and $\boldsymbol{L} u$ is strain from the forward problem. This object requires the elastic tensor derivative material property (i.e., $\frac{\partial \boldsymbol{C}}{\partial p}$) as its input. + +This object is used together with [AdjointStrainStressGradInnerProduct](/AdjointStrainStressGradInnerProduct.md) in a elastic inversion problem. + +## Example Input File Syntax + +!listing examples/bimaterialElastic_batch_mat/grad.i block=UserObjects/stress_grad_lambda + +!syntax parameters /UserObjects/BatchStressGrad + +!syntax inputs /UserObjects/BatchStressGrad + +!syntax children /UserObjects/BatchStressGrad diff --git a/doc/content/source/vectorpostprocessors/AdjointStrainStressGradInnerProduct.md b/doc/content/source/vectorpostprocessors/AdjointStrainStressGradInnerProduct.md new file mode 100644 index 000000000..63f2ef43d --- /dev/null +++ b/doc/content/source/vectorpostprocessors/AdjointStrainStressGradInnerProduct.md @@ -0,0 +1,23 @@ +# AdjointStrainStressGradInnerProduct + +!syntax description /VectorPostprocessors/AdjointStrainStressGradInnerProduct + +## Description + +This `VectorPostprocessor` computes the gradient of objective function with respect to interested parameter for elastic problem. Specifically, +\begin{equation} + \frac{\text{d}\boldsymbol{F}}{\text{d}p} = - \int \underbrace{(\boldsymbol{L}\lambda)^T}_{\text{adjoint strain}} \underbrace{\frac{\partial \boldsymbol{C}}{\partial p} (\boldsymbol{L} u)}_{\text{stress gradient}} \text{d}\Omega, +\end{equation} +where $\boldsymbol{F}$ is the objective function, $\boldsymbol{L}$ is the differential operator for the elasticity problem, $\lambda$ is the adjoint displacement, $\boldsymbol{C}$ is the elastic tensor, $p$ is the interested parameter, and $u$ is displacement from the forward problem. + +Specifically, this object takes the `adjoint strain` and the `stress gradient` as inputs, computes the double contraction of the two inputs, and integrate over the entire domain. Specifically, the `adjoint strain` is the strain from the adjoint problem, the `stress gradient` should be a batch material (e.g., [BatchStressGrad](/BatchStressGrad.md)). + +## Example Input File Syntax + +!listing examples/bimaterialElastic_batch_mat/grad.i block=VectorPostprocessors/grad_lambda + +!syntax parameters /VectorPostprocessors/AdjointStrainStressGradInnerProduct + +!syntax inputs /VectorPostprocessors/AdjointStrainStressGradInnerProduct + +!syntax children /VectorPostprocessors/AdjointStrainStressGradInnerProduct diff --git a/include/userobjects/BatchStressGrad.h b/include/userobjects/BatchStressGrad.h new file mode 100644 index 000000000..ff7006e1a --- /dev/null +++ b/include/userobjects/BatchStressGrad.h @@ -0,0 +1,33 @@ +//* This file is part of the MOOSE framework +//* https://www.mooseframework.org +//* +//* All rights reserved, see COPYRIGHT for full restrictions +//* https://github.com/idaholab/moose/blob/master/COPYRIGHT +//* +//* Licensed under LGPL 2.1, please see LICENSE for details +//* https://www.gnu.org/licenses/lgpl-2.1.html + +#pragma once + +#include "BatchMaterial.h" + +typedef BatchMaterial< + // tuple representation + BatchMaterialUtils::TupleStd, + // output data type + RankTwoTensor, + // gathered input data types: + BatchMaterialUtils::GatherMatProp, + BatchMaterialUtils::GatherMatProp> + + BatchStressGradParent; + +class BatchStressGrad : public BatchStressGradParent +{ +public: + static InputParameters validParams(); + + BatchStressGrad(const InputParameters & params); + + void batchCompute() override; +}; diff --git a/include/vectorpostprocessors/AdjointStrainStressGradInnerProduct.h b/include/vectorpostprocessors/AdjointStrainStressGradInnerProduct.h new file mode 100644 index 000000000..6c9009fe1 --- /dev/null +++ b/include/vectorpostprocessors/AdjointStrainStressGradInnerProduct.h @@ -0,0 +1,31 @@ +//* This file is part of the MOOSE framework +//* https://www.mooseframework.org +//* +//* All rights reserved, see COPYRIGHT for full restrictions +//* https://github.com/idaholab/moose/blob/master/COPYRIGHT +//* +//* Licensed under LGPL 2.1, please see LICENSE for details +//* https://www.gnu.org/licenses/lgpl-2.1.html + +#pragma once + +#include "ElementOptimizationFunctionInnerProduct.h" +#include "BatchStressGrad.h" + +class AdjointStrainStressGradInnerProduct : public ElementOptimizationFunctionInnerProduct +{ +public: + static InputParameters validParams(); + + AdjointStrainStressGradInnerProduct(const InputParameters & parameters); + +protected: + virtual Real computeQpInnerProduct() override; + /// Base name of the material system + const std::string _base_name; + /// Holds adjoint strain at current quadrature points + const MaterialProperty & _adjoint_strain; + /// UO that holds gradient of stress wrt material parameter at current quadrature points + const BatchStressGrad & _stress_grad_uo; + const BatchStressGrad::OutputVector & _stress_grad_uo_output; +}; diff --git a/src/userobjects/BatchStressGrad.C b/src/userobjects/BatchStressGrad.C new file mode 100644 index 000000000..9a3564e0f --- /dev/null +++ b/src/userobjects/BatchStressGrad.C @@ -0,0 +1,46 @@ +//* This file is part of the MOOSE framework +//* https://www.mooseframework.org +//* +//* All rights reserved, see COPYRIGHT for full restrictions +//* https://github.com/idaholab/moose/blob/master/COPYRIGHT +//* +//* Licensed under LGPL 2.1, please see LICENSE for details +//* https://www.gnu.org/licenses/lgpl-2.1.html + +#include "BatchStressGrad.h" +#include "libmesh/int_range.h" + +registerMooseObject("BlackBearApp", BatchStressGrad); + +InputParameters +BatchStressGrad::validParams() +{ + auto params = BatchStressGradParent::validParams(); + params.addRequiredParam( + "elastic_tensor_derivative", "Name of the elastic tensor derivative material property."); + return params; +} + +BatchStressGrad::BatchStressGrad(const InputParameters & params) + : BatchStressGradParent(params, + // here we pass the derivative of elastic tensor wrt to the parameter + "elastic_tensor_derivative", + // here we pass in the forward strain + "forward_mechanical_strain") +{ +} + +void +BatchStressGrad::batchCompute() +{ + for (const auto i : index_range(_input_data)) + { + const auto & input = _input_data[i]; + auto & output = _output_data[i]; + + const auto & elasticity_dev = std::get<0>(input); + const auto & strain = std::get<1>(input); + + output = elasticity_dev * strain; + } +} diff --git a/src/vectorpostprocessors/AdjointStrainStressGradInnerProduct.C b/src/vectorpostprocessors/AdjointStrainStressGradInnerProduct.C new file mode 100644 index 000000000..773abca2b --- /dev/null +++ b/src/vectorpostprocessors/AdjointStrainStressGradInnerProduct.C @@ -0,0 +1,48 @@ +//* This file is part of the MOOSE framework +//* https://www.mooseframework.org +//* +//* All rights reserved, see COPYRIGHT for full restrictions +//* https://github.com/idaholab/moose/blob/master/COPYRIGHT +//* +//* Licensed under LGPL 2.1, please see LICENSE for details +//* https://www.gnu.org/licenses/lgpl-2.1.html + +#include "AdjointStrainStressGradInnerProduct.h" + +registerMooseObject("BlackBearApp", AdjointStrainStressGradInnerProduct); + +InputParameters +AdjointStrainStressGradInnerProduct::validParams() +{ + InputParameters params = ElementOptimizationFunctionInnerProduct::validParams(); + params.addRequiredParam( + "stress_grad_name", + "Name of the stress gradient user object with respect to the material parameter"); + + params.addRequiredParam( + "adjoint_strain_name", "Name of the strain property in the adjoint problem"); + + params.addClassDescription("Compute the gradient for elastic material inversion"); + return params; +} +AdjointStrainStressGradInnerProduct::AdjointStrainStressGradInnerProduct( + const InputParameters & parameters) + : ElementOptimizationFunctionInnerProduct(parameters), + _base_name(isParamValid("base_name") ? getParam("base_name") + "_" : ""), + _adjoint_strain(getMaterialPropertyByName( + getParam("adjoint_strain_name"))), + _stress_grad_uo(getUserObject("stress_grad_name")), + _stress_grad_uo_output(_stress_grad_uo.getOutputData()) +{ +} + +Real +AdjointStrainStressGradInnerProduct::computeQpInnerProduct() +{ + if (!_stress_grad_uo.outputReady()) + mooseError("Stress gradient batch material property is not ready to output."); + + const auto index = _stress_grad_uo.getIndex(_current_elem->id()); + + return -_adjoint_strain[_qp].doubleContraction(_stress_grad_uo_output[index + _qp]); +} diff --git a/test/tests/bimaterial_elastic_inversion_batch_mat/gold/main_out_OptimizationReporter_0001.csv b/test/tests/bimaterial_elastic_inversion_batch_mat/gold/main_out_OptimizationReporter_0001.csv new file mode 100644 index 000000000..8244086d8 --- /dev/null +++ b/test/tests/bimaterial_elastic_inversion_batch_mat/gold/main_out_OptimizationReporter_0001.csv @@ -0,0 +1,10 @@ +grad_lambda,grad_mu,lambda,measurement_time,measurement_values,measurement_xcoord,measurement_ycoord,measurement_zcoord,misfit_values,mu,simulation_values +6.1849349929517e-08,2.7439401009507e-06,4.9999848958062,0,4.46462,-1,-1,0,-1.3156694844696e-07,1.0000001501249,4.4646198684331 +6.0822263185714e-09,2.2329018523184e-07,4.0000654135139,0,6.447155,-1,0,0,-1.5608052539307e-07,2.0000014605072,6.4471548439195 +1.5709256099651e-09,3.1031720332756e-09,3.0001400501022,0,8.434803,-1,1,0,-1.6059464336138e-07,2.9999869855298,8.4348028394054 +0,0,0,0,4.176264,0,-1,0,-1.5114235196734e-07,0,4.1762638488576 +0,0,0,0,6.172984,0,0,0,-1.7986893752209e-07,0,6.1729838201311 +0,0,0,0,8.200859,0,1,0,5.6683557403403e-08,0,8.2008590566836 +0,0,0,0,4.049477,1,-1,0,1.9859902877783e-07,0,4.049477198599 +0,0,0,0,6.052499,1,0,0,3.469401415046e-07,0,6.0524993469401 +0,0,0,0,8.079385,1,1,0,-2.7443372196956e-07,0,8.0793847255663 diff --git a/test/tests/bimaterial_elastic_inversion_batch_mat/grad.i b/test/tests/bimaterial_elastic_inversion_batch_mat/grad.i new file mode 100644 index 000000000..a0d0b89da --- /dev/null +++ b/test/tests/bimaterial_elastic_inversion_batch_mat/grad.i @@ -0,0 +1,204 @@ +[Mesh] + [gmg] + type = GeneratedMeshGenerator + dim = 2 + nx = 11 + ny = 11 + xmin = -4 + xmax = 4 + ymin = -4 + ymax = 4 + [] +[] + +[Variables] + [ux] + [] + [uy] + [] +[] + +[AuxVariables] + [state_x] + [] + [state_y] + [] + [dummy] + [] +[] + +[DiracKernels] + [misfit_is_adjoint_force] + type = ReporterPointSource + variable = ux + x_coord_name = misfit/measurement_xcoord + y_coord_name = misfit/measurement_ycoord + z_coord_name = misfit/measurement_zcoord + value_name = misfit/misfit_values + [] +[] + +[Kernels] + [div_sigma_x] + type = StressDivergenceTensors + variable = ux + displacements = 'ux uy' + component = 0 + volumetric_locking_correction = false + [] + [div_sigma_y] + type = StressDivergenceTensors + variable = uy + displacements = 'ux uy' + component = 1 + volumetric_locking_correction = false + [] +[] + +[BCs] + [bottom_ux] + type = DirichletBC + variable = ux + boundary = bottom + value = 0.0 + [] + [bottom_uy] + type = DirichletBC + variable = uy + boundary = bottom + value = 0.0 + [] +[] + +[Materials] + [stress] + type = ComputeLinearElasticStress + [] + [strain] + type = ComputeSmallStrain + displacements = 'ux uy' + [] + [elasticity_tensor] + type = ComputeVariableIsotropicElasticityTensor + args = dummy + youngs_modulus = E_material + poissons_ratio = nu_material + [] + [E_material] + type = GenericFunctionMaterial + prop_names = 'E_material' + prop_values = E + [] + [nu_material] + type = GenericFunctionMaterial + prop_names = 'nu_material' + prop_values = nu + [] + [forward_strain] + type = ComputeSmallStrain + displacements = 'state_x state_y' + base_name = 'forward' + [] + # Below are the gradients of elasticity tensor for this elastic inversion problem + [dC_dlambda] + type = ComputeElasticityTensor + C_ijkl = '1 1 1 1 1 1 0 0 0' + fill_method = symmetric9 + base_name = 'dC_dlambda' + [] + [dC_dmu] + type = ComputeElasticityTensor + C_ijkl = '2 0 0 2 0 2 1 1 1' + fill_method = symmetric9 + base_name = 'dC_dmu' + [] +[] + +[Functions] + [E] + type = ParsedFunction + expression = mu*(3*lambda+2*mu)/(lambda+mu) + symbol_names = 'lambda mu' + symbol_values = 'lambda mu' + [] + [nu] + type = ParsedFunction + expression = lambda/2/(lambda+mu) + symbol_names = 'lambda mu' + symbol_values = 'lambda mu' + [] + [lambda] + type = NearestReporterCoordinatesFunction + x_coord_name = parametrization/coordx + y_coord_name = parametrization/coordy + value_name = parametrization/lambda + [] + [mu] + type = NearestReporterCoordinatesFunction + x_coord_name = parametrization/coordx + y_coord_name = parametrization/coordy + value_name = parametrization/mu + [] +[] + +[Reporters] + [measure_data] + type = OptimizationData + variable = ux + [] + [misfit] + type = OptimizationData + [] + [parametrization] + type = ConstantReporter + real_vector_names = 'coordx coordy lambda mu' + real_vector_values = '0 1 2; 0 1 2; 5 4 3; 1 2 3' + [] +[] + +# Below is the part where a customized userObject that takes NEML stress gradient +# and transforms it into a batch material that has the output type as RankTwoTensor +# One userObject per gradient material property from NEML +[UserObjects] + [stress_grad_lambda] + type = BatchStressGrad + elastic_tensor_derivative = 'dC_dlambda_elasticity_tensor' # calculated in dC_dlambda + execution_order_group = -1 # need to make sure that the UO executes before the VPP + [] + [stress_grad_mu] + type = BatchStressGrad + elastic_tensor_derivative = 'dC_dmu_elasticity_tensor' # calculated in dC_dmu + execution_order_group = -1 # need to make sure that the UO executes before the VPP + [] +[] + +# Below is where the stress gradient batch material objects are utilized in the +# actual gradient calculations +[VectorPostprocessors] + [grad_lambda] + type = AdjointStrainStressGradInnerProduct + stress_grad_name = 'stress_grad_lambda' + adjoint_strain_name = 'mechanical_strain' + variable = dummy + function = lambda + [] + [grad_mu] + type = AdjointStrainStressGradInnerProduct + stress_grad_name = 'stress_grad_mu' + adjoint_strain_name = 'mechanical_strain' + variable = dummy + function = mu + [] +[] + +[Executioner] + type = Steady + solve_type = NEWTON + petsc_options_iname = '-pc_type' + petsc_options_value = 'lu' +[] + +[Outputs] + file_base = 'adjoint' + console = false +[] diff --git a/test/tests/bimaterial_elastic_inversion_batch_mat/main.i b/test/tests/bimaterial_elastic_inversion_batch_mat/main.i new file mode 100644 index 000000000..4562525c1 --- /dev/null +++ b/test/tests/bimaterial_elastic_inversion_batch_mat/main.i @@ -0,0 +1,126 @@ +[Optimization] +[] + +[OptimizationReporter] + type = OptimizationReporter + parameter_names = 'lambda mu' + num_values = '3 3' + #initial_condition = '5 4 3 ; 1 2 1' + initial_condition = '5.0 5.0 5.0; 1.0 1.0 1.0' + lower_bounds = '0.1; 0.1' + upper_bounds = '10.0; 10.0' + 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 = '4.464620e+00 6.447155e+00 8.434803e+00 + 4.176264e+00 6.172984e+00 8.200859e+00 + 4.049477e+00 6.052499e+00 8.079385e+00' +[] + +[Executioner] + type = Optimize + tao_solver = taobqnls #taobncg #taoblmvm + petsc_options_iname = '-tao_gatol -tao_ls_type -tao_max_it' + petsc_options_value = '5e-6 unit 500' + + #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 + execute_on = ADJOINT + [] +[] + +[Transfers] + [toForward] + type = MultiAppReporterTransfer + to_multi_app = forward + from_reporters = 'OptimizationReporter/measurement_xcoord + OptimizationReporter/measurement_ycoord + OptimizationReporter/measurement_zcoord + OptimizationReporter/measurement_time + OptimizationReporter/measurement_values + OptimizationReporter/lambda + OptimizationReporter/mu' + to_reporters = 'measure_data/measurement_xcoord + measure_data/measurement_ycoord + measure_data/measurement_zcoord + measure_data/measurement_time + measure_data/measurement_values + parametrization/lambda + parametrization/mu' + [] + [get_misfit] + type = MultiAppReporterTransfer + from_multi_app = forward + from_reporters = 'measure_data/simulation_values' + to_reporters = 'OptimizationReporter/simulation_values' + [] + [set_state_for_adjoint] + type = MultiAppCopyTransfer + from_multi_app = forward + to_multi_app = adjoint + source_variable = 'ux uy' + variable = 'state_x state_y' + [] + [setup_adjoint_run] + type = MultiAppReporterTransfer + to_multi_app = adjoint + from_reporters = 'OptimizationReporter/measurement_xcoord + OptimizationReporter/measurement_ycoord + OptimizationReporter/measurement_zcoord + OptimizationReporter/measurement_time + OptimizationReporter/misfit_values + OptimizationReporter/lambda + OptimizationReporter/mu' + to_reporters = 'misfit/measurement_xcoord + misfit/measurement_ycoord + misfit/measurement_zcoord + misfit/measurement_time + misfit/misfit_values + parametrization/lambda + parametrization/mu' + [] + [get_grad_lambda] + type = MultiAppReporterTransfer + from_multi_app = adjoint + from_reporters = 'grad_lambda/inner_product' + to_reporters = 'OptimizationReporter/grad_lambda' + [] + [get_grad_mu] + type = MultiAppReporterTransfer + from_multi_app = adjoint + from_reporters = 'grad_mu/inner_product' + to_reporters = 'OptimizationReporter/grad_mu' + [] +[] + +[Reporters] + [optInfo] + type = OptimizationInfo + items = 'current_iterate function_value gnorm' + [] +[] + +[Outputs] + console = false + csv = true +[] diff --git a/test/tests/bimaterial_elastic_inversion_batch_mat/model.i b/test/tests/bimaterial_elastic_inversion_batch_mat/model.i new file mode 100644 index 000000000..c6717e0f8 --- /dev/null +++ b/test/tests/bimaterial_elastic_inversion_batch_mat/model.i @@ -0,0 +1,166 @@ +[Mesh] + [gmg] + type = GeneratedMeshGenerator + dim = 2 + nx = 11 + ny = 11 + xmin = -4 + xmax = 4 + ymin = -4 + ymax = 4 + [] +[] + +[Variables] + [ux] + [] + [uy] + [] +[] + +[AuxVariables] + [dummy] + [] +[] + +[Kernels] + [div_sigma_x] + type = StressDivergenceTensors + variable = ux + displacements = 'ux uy' + component = 0 + volumetric_locking_correction = false + [] + [div_sigma_y] + type = StressDivergenceTensors + variable = uy + displacements = 'ux uy' + component = 1 + volumetric_locking_correction = false + [] +[] + +[BCs] + [bottom_ux] + type = DirichletBC + variable = ux + boundary = bottom + value = 0.0 + [] + [bottom_uy] + type = DirichletBC + variable = uy + boundary = bottom + value = 0.0 + [] + [top_fx] + type = NeumannBC + variable = ux + boundary = top + value = 1.0 + [] + [top_fy] + type = NeumannBC + variable = uy + boundary = top + value = 1.0 + [] +[] + +[Materials] + [stress] + type = ComputeLinearElasticStress + [] + [strain] + type = ComputeSmallStrain + displacements = 'ux uy' + [] + [elasticity_tensor] + type = ComputeVariableIsotropicElasticityTensor + args = dummy + youngs_modulus = E_material + poissons_ratio = nu_material + [] + [E_material] + type = GenericFunctionMaterial + prop_names = 'E_material' + prop_values = E + [] + [nu_material] + type = GenericFunctionMaterial + prop_names = 'nu_material' + prop_values = nu + [] +[] + +[Functions] + [E] + type = ParsedFunction + expression = mu*(3*lambda+2*mu)/(lambda+mu) + symbol_names = 'lambda mu' + symbol_values = 'lambda mu' + [] + [nu] + type = ParsedFunction + expression = lambda/2/(lambda+mu) + symbol_names = 'lambda mu' + symbol_values = 'lambda mu' + [] + [lambda] + type = NearestReporterCoordinatesFunction + x_coord_name = parametrization/coordx + y_coord_name = parametrization/coordy + value_name = parametrization/lambda + [] + [mu] + type = NearestReporterCoordinatesFunction + x_coord_name = parametrization/coordx + y_coord_name = parametrization/coordy + value_name = parametrization/mu + [] +[] + +[Reporters] + [measure_data] + type = OptimizationData + variable = ux + [] + [parametrization] + type = ConstantReporter + real_vector_names = 'coordx coordy lambda mu' + real_vector_values = '0 1 2; 0 1 2; 5 4 3; 1 2 3' + [] +[] + +[Executioner] + type = Steady + solve_type = NEWTON + petsc_options_iname = '-pc_type' + petsc_options_value = 'lu' +[] + +[Postprocessors] + [point1] + type = PointValue + point = '-1.0 -1.0 0.0' + variable = ux + execute_on = TIMESTEP_END + [] + [point2] + type = PointValue + point = '-1.0 0.0 0.0' + variable = ux + execute_on = TIMESTEP_END + [] + [point3] + type = PointValue + point = '-1.0 1.0 0.0' + variable = ux + execute_on = TIMESTEP_END + [] +[] + +[Outputs] + file_base = 'forward' + console = false +[] diff --git a/test/tests/bimaterial_elastic_inversion_batch_mat/tests b/test/tests/bimaterial_elastic_inversion_batch_mat/tests new file mode 100644 index 000000000..fe4e39f73 --- /dev/null +++ b/test/tests/bimaterial_elastic_inversion_batch_mat/tests @@ -0,0 +1,16 @@ +[Tests] + issues = '#352' + design= 'BatchStressGrad.md AdjointStrainStressGradInnerProduct.md' + [grad] + requirement = "The system shall be able to invert for elastic moduli using batch materials." + type = CSVDiff + abs_zero = 1e-6 + rel_err = 1e-6 + input = main.i + csvdiff = main_out_OptimizationReporter_0001.csv + max_threads = 1 + method = opt + # steady solve + recover = false + [] +[]