From 84fb4207bf18f651e6bef9ea6878a97f01cd5bb6 Mon Sep 17 00:00:00 2001 From: "Joshua E. Hansel" Date: Fri, 11 Oct 2024 09:45:20 -0500 Subject: [PATCH 1/3] Copied previous NL aux solution during NL iteration Closes #28807 --- framework/include/systems/AuxiliarySystem.h | 3 ++- framework/src/problems/FEProblemBase.C | 2 +- framework/src/systems/AuxiliarySystem.C | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/framework/include/systems/AuxiliarySystem.h b/framework/include/systems/AuxiliarySystem.h index dae30d4f2a11..60e456054b0a 100644 --- a/framework/include/systems/AuxiliarySystem.h +++ b/framework/include/systems/AuxiliarySystem.h @@ -131,7 +131,8 @@ class AuxiliarySystem : public SystemBase, public PerfGraphInterface virtual System & system() override { return _sys; } virtual const System & system() const override { return _sys; } - virtual void setPreviousNewtonSolution(); + /// Copies the current solution into the previous nonlinear iteration solution + virtual void copyCurrentIntoPreviousNL(); void setScalarVariableCoupleableTags(ExecFlagType type); diff --git a/framework/src/problems/FEProblemBase.C b/framework/src/problems/FEProblemBase.C index 88761843c925..45c79c18d2be 100644 --- a/framework/src/problems/FEProblemBase.C +++ b/framework/src/problems/FEProblemBase.C @@ -7401,7 +7401,7 @@ FEProblemBase::computePostCheck(NonlinearImplicitSystem & sys, if (vectorTagExists(Moose::PREVIOUS_NL_SOLUTION_TAG)) { _current_nl_sys->setPreviousNewtonSolution(old_soln); - _aux->setPreviousNewtonSolution(); + _aux->copyCurrentIntoPreviousNL(); } // MOOSE doesn't change the search_direction diff --git a/framework/src/systems/AuxiliarySystem.C b/framework/src/systems/AuxiliarySystem.C index 1c8c8b0a136d..55244e0050d7 100644 --- a/framework/src/systems/AuxiliarySystem.C +++ b/framework/src/systems/AuxiliarySystem.C @@ -792,10 +792,10 @@ AuxiliarySystem::needMaterialOnSide(BoundaryID bnd_id) } void -AuxiliarySystem::setPreviousNewtonSolution() +AuxiliarySystem::copyCurrentIntoPreviousNL() { - // Evaluate aux variables to get the solution vector - compute(EXEC_LINEAR); + if (solutionPreviousNewton()) + *solutionPreviousNewton() = *currentSolution(); } template From c1cdf737078908111b4d9be14856fea45a28a166 Mon Sep 17 00:00:00 2001 From: "Joshua E. Hansel" Date: Wed, 9 Oct 2024 13:43:02 -0500 Subject: [PATCH 2/3] Redesigned previous iteration test Refs #28807 --- .../gold/test_out.csv | 3 + .../previous_newton_iteration/gold/test_out.e | Bin 43136 -> 0 bytes .../previous_newton_iteration/test.i | 167 +++++------------- .../variables/previous_newton_iteration/tests | 8 +- 4 files changed, 52 insertions(+), 126 deletions(-) create mode 100644 test/tests/variables/previous_newton_iteration/gold/test_out.csv delete mode 100644 test/tests/variables/previous_newton_iteration/gold/test_out.e diff --git a/test/tests/variables/previous_newton_iteration/gold/test_out.csv b/test/tests/variables/previous_newton_iteration/gold/test_out.csv new file mode 100644 index 000000000000..d85365c89cb4 --- /dev/null +++ b/test/tests/variables/previous_newton_iteration/gold/test_out.csv @@ -0,0 +1,3 @@ +time,u,v +0,1,1 +1,0.90909090909091,0.9 diff --git a/test/tests/variables/previous_newton_iteration/gold/test_out.e b/test/tests/variables/previous_newton_iteration/gold/test_out.e deleted file mode 100644 index 748f91362f89f82519c1b97b4f7db33901a94e0a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 43136 zcmeHQ4Vc`-dET=P+}URX4%kp=5jbEl{<$*-|G>sR&S!GPKL0!XC9-Z;d#89;+U#o2 zcZP(YB(w>krThgRLZPK3@RSBa-O!{CcWp@k6Mm9DA;dJ$q-h_w7%(M3LS5YNozd({ zT4}Y?%ETAnJkRb(GvB=W=9_Q6`O#>mbNPyKi9})o{U*|HI{d7v%SE%G>3wvUNSsQ) zW`t!mU8U=_^qY_|N(K1zYcaK)N(t0F-B^y%>q-vvNPm=G%E@UhhiE*n1^2p6WE$TK0{JNyPhvpODEKib*9e=M7Ca z<*h~`P4d`=a)g{w2F>(q$!J-UHIJ~xA-%bmV<7P?#QHceP%ys1%`w)^n*@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 2024 11:09:06 -0500 Subject: [PATCH 3/3] Added AverageVariableChange post-processor Refs #28801 --- .../postprocessors/AverageVariableChange.md | 41 +++++++++ .../postprocessors/AverageVariableChange.h | 45 ++++++++++ .../postprocessors/AverageVariableChange.C | 84 +++++++++++++++++++ .../average_variable_change/base.i | 72 ++++++++++++++++ .../gold/steady_out.csv | 6 ++ .../gold/transient_out.csv | 10 +++ .../average_variable_change/steady.i | 40 +++++++++ .../average_variable_change/tests | 22 +++++ .../average_variable_change/transient.i | 46 ++++++++++ 9 files changed, 366 insertions(+) create mode 100644 framework/doc/content/source/postprocessors/AverageVariableChange.md create mode 100644 framework/include/postprocessors/AverageVariableChange.h create mode 100644 framework/src/postprocessors/AverageVariableChange.C create mode 100644 test/tests/postprocessors/average_variable_change/base.i create mode 100644 test/tests/postprocessors/average_variable_change/gold/steady_out.csv create mode 100644 test/tests/postprocessors/average_variable_change/gold/transient_out.csv create mode 100644 test/tests/postprocessors/average_variable_change/steady.i create mode 100644 test/tests/postprocessors/average_variable_change/tests create mode 100644 test/tests/postprocessors/average_variable_change/transient.i diff --git a/framework/doc/content/source/postprocessors/AverageVariableChange.md b/framework/doc/content/source/postprocessors/AverageVariableChange.md new file mode 100644 index 000000000000..751f35bcfc08 --- /dev/null +++ b/framework/doc/content/source/postprocessors/AverageVariableChange.md @@ -0,0 +1,41 @@ +# AverageVariableChange + +This post-processor computes a volume-weighted norm of the change of a variable +or auxiliary variable over a time step or a nonlinear iteration: + +!equation +||\delta u||_{\Omega,p} = \left(\frac{1}{|\Omega|} \int\limits_\Omega |\delta u|^p \, d\Omega\right)^{\frac{1}{p}} \,, + +where + +- $\delta u$ is the variable change of interest, +- $\Omega$ is the domain over which the norm is taken, +- $|\Omega|$ is the volume of the domain, and +- $p$ is the order of the norm (either 1 or 2). + +Denoting the current time index by $n$ and the current nonlinear iteration index +by $(\ell)$, the variable change may be with respect to either the old time value, + +!equation +\delta u \equiv u_n^{(\ell)} - u_{n-1} + +or the previous nonlinear iteration value, + +!equation +\delta u \equiv u_n^{(\ell)} - u_n^{(\ell-1)} + +as determined by the value of [!param](/Postprocessors/AverageVariableChange/change_over). + +Volume-weighting the norm produces a value that is independent of the size of +the domain. Without doing this, there is a domain volume bias in the norm. +Suppose $\delta u$ is constant over the domain with a value $\overline{\delta u}$: + +!equation +||\delta u||_{p} = \left(\int\limits_\Omega |\overline{\delta u}|^p \, d\Omega\right)^{\frac{1}{p}} + = |\overline{\delta u}| |\Omega|^{\frac{1}{p}} \,. + +!syntax parameters /Postprocessors/AverageVariableChange + +!syntax inputs /Postprocessors/AverageVariableChange + +!syntax children /Postprocessors/AverageVariableChange diff --git a/framework/include/postprocessors/AverageVariableChange.h b/framework/include/postprocessors/AverageVariableChange.h new file mode 100644 index 000000000000..1a21b38457b0 --- /dev/null +++ b/framework/include/postprocessors/AverageVariableChange.h @@ -0,0 +1,45 @@ +//* 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 "ElementIntegralVariablePostprocessor.h" + +/** + * Computes the volume-weighted L1 or L2 norm of the change of a variable over a + * time step or between nonlinear iterations. + */ +class AverageVariableChange : public ElementIntegralVariablePostprocessor +{ +public: + static InputParameters validParams(); + + AverageVariableChange(const InputParameters & parameters); + + virtual void initialize() override; + virtual void execute() override; + virtual void threadJoin(const UserObject & y) override; + virtual void finalize() override; + virtual Real getValue() const override; + virtual Real computeQpIntegral() override; + +protected: + /// Interval over which to compute change + const MooseEnum & _change_over; + /// "Old" solution value in the change + const VariableValue & _u_change_old; + + /// Selected norm + const MooseEnum & _norm; + /// Norm exponent + const unsigned int _norm_exponent; + + /// Subdomain(s) volume + Real _volume; +}; diff --git a/framework/src/postprocessors/AverageVariableChange.C b/framework/src/postprocessors/AverageVariableChange.C new file mode 100644 index 000000000000..6aa898856f5a --- /dev/null +++ b/framework/src/postprocessors/AverageVariableChange.C @@ -0,0 +1,84 @@ +//* 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 "AverageVariableChange.h" +#include "MooseUtils.h" + +registerMooseObject("MooseApp", AverageVariableChange); + +InputParameters +AverageVariableChange::validParams() +{ + InputParameters params = ElementIntegralVariablePostprocessor::validParams(); + + params.addClassDescription("Computes the volume-weighted L1 or L2 norm of the change of a " + "variable over a time step or between nonlinear iterations."); + + MooseEnum change_over("time_step nonlinear_iteration"); + params.addRequiredParam( + "change_over", change_over, "Interval over which to compute the change"); + + MooseEnum norm("L1 L2"); + params.addRequiredParam("norm", norm, "Type of norm to compute"); + + return params; +} + +AverageVariableChange::AverageVariableChange(const InputParameters & parameters) + : ElementIntegralVariablePostprocessor(parameters), + _change_over(getParam("change_over")), + _u_change_old(_change_over == "time_step" ? coupledValueOld("variable") + : coupledValuePreviousNL("variable")), + _norm(getParam("norm")), + _norm_exponent(_norm == "L1" ? 1 : 2), + _volume(0) +{ +} + +void +AverageVariableChange::initialize() +{ + ElementIntegralVariablePostprocessor::initialize(); + _volume = 0; +} + +void +AverageVariableChange::execute() +{ + ElementIntegralVariablePostprocessor::execute(); + _volume += _current_elem_volume; +} + +void +AverageVariableChange::threadJoin(const UserObject & y) +{ + ElementIntegralVariablePostprocessor::threadJoin(y); + const auto & pps = static_cast(y); + _volume += pps._volume; +} + +void +AverageVariableChange::finalize() +{ + gatherSum(_volume); + gatherSum(_integral_value); +} + +Real +AverageVariableChange::getValue() const +{ + mooseAssert(!MooseUtils::absoluteFuzzyEqual(_volume, 0.0), "Volume must be nonzero."); + return std::pow(_integral_value / _volume, 1.0 / _norm_exponent); +} + +Real +AverageVariableChange::computeQpIntegral() +{ + return std::pow(std::abs(_u[_qp] - _u_change_old[_qp]), _norm_exponent); +} diff --git a/test/tests/postprocessors/average_variable_change/base.i b/test/tests/postprocessors/average_variable_change/base.i new file mode 100644 index 000000000000..6e4e5ce09d05 --- /dev/null +++ b/test/tests/postprocessors/average_variable_change/base.i @@ -0,0 +1,72 @@ +aux_execute_on = 'INITIAL NONLINEAR_CONVERGENCE TIMESTEP_END' +pp_execute_on = 'INITIAL NONLINEAR_CONVERGENCE TIMESTEP_END' +output_execute_on = 'INITIAL NONLINEAR TIMESTEP_END' + +[Mesh] + type = GeneratedMesh + dim = 2 + nx = 10 + ny = 10 + xmax = 2 + ymax = 2 +[] + +[Variables] + [sol] + [] +[] + +[AuxVariables] + [aux] + [] +[] + +[AuxKernels] + [aux_kernel] + type = ParsedAux + variable = aux + functor_names = 'sol' + functor_symbols = 'u' + expression = 'u' + execute_on = ${aux_execute_on} + [] +[] + +[Kernels] + [diff] + type = Diffusion + variable = sol + [] +[] + +[BCs] + [left] + type = DirichletBC + variable = sol + boundary = left + value = 0 + [] + [right] + type = DirichletBC + variable = sol + boundary = right + value = 1 + [] +[] + +[Problem] + previous_nl_solution_required = true +[] + +[Executioner] + solve_type = 'PJFNK' + petsc_options_iname = '-pc_type' + petsc_options_value = 'hypre' + nl_rel_tol = 0 + nl_abs_tol = 1e-8 +[] + +[Outputs] + csv = true + execute_on = ${output_execute_on} +[] diff --git a/test/tests/postprocessors/average_variable_change/gold/steady_out.csv b/test/tests/postprocessors/average_variable_change/gold/steady_out.csv new file mode 100644 index 000000000000..af2c0fbe9c94 --- /dev/null +++ b/test/tests/postprocessors/average_variable_change/gold/steady_out.csv @@ -0,0 +1,6 @@ +time,aux_avg,aux_diff_l1,sol_avg,sol_diff_l1,sol_diff_l2 +0,0,0,0,0,0 +0.001,0.05,0.05,0.05,0.05,0.18257418583506 +0.002,0.5000000662596,0.4500000662596,0.5000000662596,0.4500000662596,0.51961533896988 +0.003,0.50000000000575,1.1618620291334e-07,0.50000000000575,1.1618620291334e-07,1.4653850459149e-07 +1,0.50000000000575,1.1618620291334e-07,0.50000000000575,1.1618620291334e-07,1.4653850459149e-07 diff --git a/test/tests/postprocessors/average_variable_change/gold/transient_out.csv b/test/tests/postprocessors/average_variable_change/gold/transient_out.csv new file mode 100644 index 000000000000..408fa0895703 --- /dev/null +++ b/test/tests/postprocessors/average_variable_change/gold/transient_out.csv @@ -0,0 +1,10 @@ +time,aux_nlit,aux_ts,sol_nlit,sol_ts +0,0,0,0,0 +0.0001,0.05,0.05,0.05,0.05 +0.0002,0.11021258306293,0.16021258306293,0.11021258306293,0.16021258306293 +0.0003,1.5959019350813e-07,0.16021256040952,1.5959019350813e-07,0.16021256040952 +0.1,0,0.16021256040952,0,0.16021256040952 +0.1001,0,0,0,0 +0.1002,0.075808624717138,0.075808624717138,0.075808624717138,0.075808624717138 +0.1003,5.3715533178459e-08,0.0758085898486,5.3715533178459e-08,0.0758085898486 +0.2,0,0.0758085898486,0,0.0758085898486 diff --git a/test/tests/postprocessors/average_variable_change/steady.i b/test/tests/postprocessors/average_variable_change/steady.i new file mode 100644 index 000000000000..cd90a7321db5 --- /dev/null +++ b/test/tests/postprocessors/average_variable_change/steady.i @@ -0,0 +1,40 @@ +!include base.i + +[Postprocessors] + [sol_avg] + type = ElementAverageValue + variable = sol + execute_on = ${pp_execute_on} + [] + [sol_diff_l1] + type = AverageVariableChange + variable = sol + change_over = nonlinear_iteration + norm = l1 + execute_on = ${pp_execute_on} + [] + [sol_diff_l2] + type = AverageVariableChange + variable = sol + change_over = nonlinear_iteration + norm = l2 + execute_on = ${pp_execute_on} + [] + + [aux_avg] + type = ElementAverageValue + variable = aux + execute_on = ${pp_execute_on} + [] + [aux_diff_l1] + type = AverageVariableChange + variable = aux + change_over = nonlinear_iteration + norm = l1 + execute_on = ${pp_execute_on} + [] +[] + +[Executioner] + type = Steady +[] diff --git a/test/tests/postprocessors/average_variable_change/tests b/test/tests/postprocessors/average_variable_change/tests new file mode 100644 index 000000000000..d8a366bce077 --- /dev/null +++ b/test/tests/postprocessors/average_variable_change/tests @@ -0,0 +1,22 @@ +[Tests] + design = 'AverageVariableChange.md' + issues = '#28801' + + [test] + requirement = 'The system shall be able to compute volume-weighted norms of the difference of a variable between nonlinear iterations and time steps' + [steady] + type = CSVDiff + input = 'steady.i' + csvdiff = 'steady_out.csv' + abs_zero = 1e-5 + detail = 'for a steady executioner.' + [] + [transient] + type = CSVDiff + input = 'transient.i' + csvdiff = 'transient_out.csv' + abs_zero = 1e-5 + detail = 'for a transient executioner.' + [] + [] +[] diff --git a/test/tests/postprocessors/average_variable_change/transient.i b/test/tests/postprocessors/average_variable_change/transient.i new file mode 100644 index 000000000000..0c92a9f01af5 --- /dev/null +++ b/test/tests/postprocessors/average_variable_change/transient.i @@ -0,0 +1,46 @@ +!include base.i + +[Kernels] + [time_derivative] + type = TimeDerivative + variable = sol + [] +[] + +[Postprocessors] + [sol_nlit] + type = AverageVariableChange + variable = sol + change_over = nonlinear_iteration + norm = l1 + execute_on = ${pp_execute_on} + [] + [sol_ts] + type = AverageVariableChange + variable = sol + change_over = time_step + norm = l1 + execute_on = ${pp_execute_on} + [] + + [aux_nlit] + type = AverageVariableChange + variable = aux + change_over = nonlinear_iteration + norm = l1 + execute_on = ${pp_execute_on} + [] + [aux_ts] + type = AverageVariableChange + variable = aux + change_over = time_step + norm = l1 + execute_on = ${pp_execute_on} + [] +[] + +[Executioner] + type = Transient + dt = 0.1 + num_steps = 2 +[]