From 3aab0c24edaa0625eaa657a552210f0f025ba306 Mon Sep 17 00:00:00 2001 From: Matthew Falcone Date: Tue, 7 Oct 2025 16:50:32 +0100 Subject: [PATCH 01/43] Add FoamPostprocessor base class --- .../postprocessors/FoamPostprocessorBase.h | 17 ++++++++++++++++ src/base/hippoApp.C | 3 +++ src/postprocessors/FoamPostprocessorBase.C | 20 +++++++++++++++++++ 3 files changed, 40 insertions(+) create mode 100644 include/postprocessors/FoamPostprocessorBase.h create mode 100644 src/postprocessors/FoamPostprocessorBase.C diff --git a/include/postprocessors/FoamPostprocessorBase.h b/include/postprocessors/FoamPostprocessorBase.h new file mode 100644 index 00000000..97a84dfc --- /dev/null +++ b/include/postprocessors/FoamPostprocessorBase.h @@ -0,0 +1,17 @@ +#pragma once + +#include "UserObject.h" +#include "Postprocessor.h" + +#include "FoamMesh.h" + +class FoamPostprocessorBase : public UserObject, public Postprocessor +{ +public: + static InputParameters validParams(); + + FoamPostprocessorBase(const InputParameters & params); + +protected: + FoamMesh * _mesh; +}; diff --git a/src/base/hippoApp.C b/src/base/hippoApp.C index e89b6314..2abc1d74 100644 --- a/src/base/hippoApp.C +++ b/src/base/hippoApp.C @@ -43,6 +43,9 @@ hippoApp::registerAll(Factory & f, ActionFactory & af, Syntax & syntax) registerSyntaxTask("AddFoamBCAction", "FoamBCs/*", "add_foam_bc"); registerMooseObjectTask("add_foam_bc", FoamBC, false); addTaskDependency("add_aux_variable", "add_foam_bc"); + + // Add [FoamPostprocessors] block + registerSyntax("AddPostprocessorAction", "FoamPostprocessors/*"); } void diff --git a/src/postprocessors/FoamPostprocessorBase.C b/src/postprocessors/FoamPostprocessorBase.C new file mode 100644 index 00000000..e5d249f7 --- /dev/null +++ b/src/postprocessors/FoamPostprocessorBase.C @@ -0,0 +1,20 @@ +#include "FoamPostprocessorBase.h" +#include "FoamProblem.h" + +InputParameters +FoamPostprocessorBase::validParams() +{ + auto params = UserObject::validParams(); + params += Postprocessor::validParams(); + return params; +} + +FoamPostprocessorBase::FoamPostprocessorBase(const InputParameters & params) + : UserObject(params), Postprocessor(this), _mesh(nullptr) +{ + FoamProblem * problem = dynamic_cast(&getSubProblem()); + if (!problem) + mooseError("FoamPostprocessors can only be used with FoamProblem"); + + _mesh = &problem->mesh(); +} From 3c30f86d0d82cf2a5dd3a6a3d8762d0e251f3a19 Mon Sep 17 00:00:00 2001 From: Matthew Falcone Date: Tue, 7 Oct 2025 16:51:35 +0100 Subject: [PATCH 02/43] Add test FoamPostprocessor for input syntax --- .../postprocessors/FoamTestPostprocessor.h | 27 +++++++++++ .../postprocessors/FoamTestPostprocessor.C | 45 +++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 test/include/postprocessors/FoamTestPostprocessor.h create mode 100644 test/src/postprocessors/FoamTestPostprocessor.C diff --git a/test/include/postprocessors/FoamTestPostprocessor.h b/test/include/postprocessors/FoamTestPostprocessor.h new file mode 100644 index 00000000..4f9430f7 --- /dev/null +++ b/test/include/postprocessors/FoamTestPostprocessor.h @@ -0,0 +1,27 @@ +#pragma once + +#include "FoamPostprocessorBase.h" +#include "InputParameters.h" +#include "MooseTypes.h" +#include "UserObject.h" + +class FoamTestPostprocessor : public FoamPostprocessorBase +{ +public: + static InputParameters validParams(); + + FoamTestPostprocessor(const InputParameters & params); + + virtual void execute() override; + + virtual void initialize() override; + + virtual void finalize() override; + + virtual void threadJoin(const UserObject & uo) override; + + virtual PostprocessorValue getValue() const override; + +protected: + Real _value; +}; diff --git a/test/src/postprocessors/FoamTestPostprocessor.C b/test/src/postprocessors/FoamTestPostprocessor.C new file mode 100644 index 00000000..a2d9ad75 --- /dev/null +++ b/test/src/postprocessors/FoamTestPostprocessor.C @@ -0,0 +1,45 @@ +#include "FoamPostprocessorBase.h" +#include "FoamTestPostprocessor.h" +#include "Registry.h" + +registerMooseObject("hippoApp", FoamTestPostprocessor); + +InputParameters +FoamTestPostprocessor::validParams() +{ + return FoamPostprocessorBase::validParams(); +} + +FoamTestPostprocessor::FoamTestPostprocessor(const InputParameters & params) + : FoamPostprocessorBase(params), _value(0.) +{ +} + +void +FoamTestPostprocessor::execute() +{ + _value = 1.; +} + +void +FoamTestPostprocessor::initialize() +{ + _value = 0.; +} + +void +FoamTestPostprocessor::threadJoin(const UserObject & uo) +{ +} + +void +FoamTestPostprocessor::finalize() +{ + gatherSum(_value); +} + +PostprocessorValue +FoamTestPostprocessor::getValue() const +{ + return _value; +} From 34a58e1a9145d63c641f1758bfc8621bdc6a591f Mon Sep 17 00:00:00 2001 From: Matthew Falcone Date: Tue, 7 Oct 2025 16:51:54 +0100 Subject: [PATCH 03/43] Add input syntax test for FoamPostprocessors --- .../tests/actions/foam_postprocessor/foam/0/T | 56 ++++++++++++ .../foam/constant/physicalProperties | 51 +++++++++++ .../foam/system/blockMeshDict | 85 +++++++++++++++++++ .../foam/system/controlDict | 44 ++++++++++ .../foam_postprocessor/foam/system/fvSchemes | 51 +++++++++++ .../foam_postprocessor/foam/system/fvSolution | 61 +++++++++++++ test/tests/actions/foam_postprocessor/main.i | 37 ++++++++ test/tests/actions/foam_postprocessor/tests | 14 +++ 8 files changed, 399 insertions(+) create mode 100644 test/tests/actions/foam_postprocessor/foam/0/T create mode 100644 test/tests/actions/foam_postprocessor/foam/constant/physicalProperties create mode 100644 test/tests/actions/foam_postprocessor/foam/system/blockMeshDict create mode 100644 test/tests/actions/foam_postprocessor/foam/system/controlDict create mode 100644 test/tests/actions/foam_postprocessor/foam/system/fvSchemes create mode 100644 test/tests/actions/foam_postprocessor/foam/system/fvSolution create mode 100644 test/tests/actions/foam_postprocessor/main.i create mode 100644 test/tests/actions/foam_postprocessor/tests diff --git a/test/tests/actions/foam_postprocessor/foam/0/T b/test/tests/actions/foam_postprocessor/foam/0/T new file mode 100644 index 00000000..f8312bb2 --- /dev/null +++ b/test/tests/actions/foam_postprocessor/foam/0/T @@ -0,0 +1,56 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 10 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volScalarField; + location "0"; + object T; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 1 0 0 0]; + +internalField uniform 0.1; + +boundaryField +{ + left + { + type calculated; + value uniform 0.; + } + right + { + type calculated; + value uniform 0.; + } + top + { + type calculated; + value uniform 0.; + } + bottom + { + type calculated; + value uniform 0.; + } + back + { + type calculated; + value uniform 0.; + } + front + { + type calculated; + value uniform 0.; + } +} + + +// ************************************************************************* // diff --git a/test/tests/actions/foam_postprocessor/foam/constant/physicalProperties b/test/tests/actions/foam_postprocessor/foam/constant/physicalProperties new file mode 100644 index 00000000..96a14c15 --- /dev/null +++ b/test/tests/actions/foam_postprocessor/foam/constant/physicalProperties @@ -0,0 +1,51 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 10 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + location "constant"; + object physicalProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +thermoType +{ + type heSolidThermo; + mixture pureMixture; + transport constIsoSolid; + thermo eConst; + equationOfState rhoConst; + specie specie; + energy sensibleInternalEnergy; +} + +mixture +{ + specie + { + molWeight 1; + } + thermodynamics + { + Cv 1; // Specific heat capacity [J/(kg·K)] + Hf 1; // Heat of formation [J/kg] + Tref 0; + } + transport + { + kappa 1; // Thermal conductivity [W/(m·K)] + } + equationOfState + { + rho 1; // Density [kg/m^3] + } +} + + +// ************************************************************************* // diff --git a/test/tests/actions/foam_postprocessor/foam/system/blockMeshDict b/test/tests/actions/foam_postprocessor/foam/system/blockMeshDict new file mode 100644 index 00000000..face9ea6 --- /dev/null +++ b/test/tests/actions/foam_postprocessor/foam/system/blockMeshDict @@ -0,0 +1,85 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object blockMeshDict; +} + +vertices +( + ( 0.0 0.0 0.0 ) + ( 10.0 0.0 0.0 ) + ( 10.0 1.0 0.0 ) + ( 0.0 1.0 0.0 ) + + ( 0.0 0.0 1.0) + ( 10.0 0.0 1.0) + ( 10.0 1.0 1.0) + ( 0.0 1.0 1.0) +); + +blocks +( + hex (0 1 2 3 4 5 6 7) (50 1 1) simpleGrading (25 1 1) +); + +boundary +( + + // interface + left + { + type wall; + faces + ( + (4 7 3 0) + ); + } + + right + { + type wall; + faces + ( + (6 5 1 2) + ); + } + + top + { + type wall; + faces + ( + (2 3 7 6) + ); + } + + front + { + type wall; + faces + ( + (3 2 1 0) + ); + } + + bottom + { + type wall; + faces + ( + (0 1 5 4) + ); + } + + back + { + type wall; + faces + ( + (4 5 6 7) + ); + } + +); diff --git a/test/tests/actions/foam_postprocessor/foam/system/controlDict b/test/tests/actions/foam_postprocessor/foam/system/controlDict new file mode 100644 index 00000000..0383dd23 --- /dev/null +++ b/test/tests/actions/foam_postprocessor/foam/system/controlDict @@ -0,0 +1,44 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 10 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + object controlDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +solver transferTestSolver; + +startFrom startTime; + +startTime 0; + +stopAt endTime; + +endTime 0.32; + +deltaT 0.01; + +writeControl timeStep; + +writeInterval 1; + +writeFormat ascii; + +writePrecision 20; + +writeCompression off; + +timeFormat general; + +timePrecision 20; + +runTimeModifiable true; + +// ************************************************************************* // diff --git a/test/tests/actions/foam_postprocessor/foam/system/fvSchemes b/test/tests/actions/foam_postprocessor/foam/system/fvSchemes new file mode 100644 index 00000000..787f3b83 --- /dev/null +++ b/test/tests/actions/foam_postprocessor/foam/system/fvSchemes @@ -0,0 +1,51 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 12 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + object fvSchemes; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +ddtSchemes +{ + default Euler; +} + +gradSchemes +{ + default Gauss linear; +} + +divSchemes +{ + default none; + + div(phi,U) Gauss linear; + div(phi,K) Gauss linear; + div(phi,h) Gauss linear; + div(((rho*nuEff)*dev2(T(grad(U))))) Gauss linear; +} + +laplacianSchemes +{ + default Gauss linear corrected; +} + +interpolationSchemes +{ + default linear; +} + +snGradSchemes +{ + default corrected; +} + +// ************************************************************************* // diff --git a/test/tests/actions/foam_postprocessor/foam/system/fvSolution b/test/tests/actions/foam_postprocessor/foam/system/fvSolution new file mode 100644 index 00000000..61143b21 --- /dev/null +++ b/test/tests/actions/foam_postprocessor/foam/system/fvSolution @@ -0,0 +1,61 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 12 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + object fvSolution; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +solvers +{ + rho + { + solver diagonal; + } + + rhoFinal + { + $rho; + } + + + "(U|h|p_rgh)" + { + solver PBiCGStab; + preconditioner DILU; + tolerance 1e-8; + relTol 1e-8; + } + + "(U|h|p_rgh)Final" + { + $U; + tolerance 1e-8; + relTol 1e-8; + } +} + +PIMPLE +{ + momentumPredictor yes; + pRefCell 0; + pRefValue 0; +} + +relaxationFactors +{ + equations + { + h 1; + U 1; + } +} + +// ************************************************************************* // diff --git a/test/tests/actions/foam_postprocessor/main.i b/test/tests/actions/foam_postprocessor/main.i new file mode 100644 index 00000000..211b4edd --- /dev/null +++ b/test/tests/actions/foam_postprocessor/main.i @@ -0,0 +1,37 @@ +[Mesh] + type = FoamMesh + case = 'foam' + foam_patch = 'left right bottom top back front' +[] + +[Variables] + [dummy] + family = MONOMIAL + order = CONSTANT + initial_condition = 999 + [] +[] + +[Problem] + type = FoamProblem + solve = false +[] + +[Executioner] + type = Transient + end_time = 0.32 + [TimeSteppers] + [foam] + type = FoamControlledTimeStepper + [] + [] +[] + +[FoamPostprocessors] + [test] + type = FoamTestPostprocessor + [] +[] +[Outputs] + exodus = true +[] diff --git a/test/tests/actions/foam_postprocessor/tests b/test/tests/actions/foam_postprocessor/tests new file mode 100644 index 00000000..f649f15c --- /dev/null +++ b/test/tests/actions/foam_postprocessor/tests @@ -0,0 +1,14 @@ +[Tests] + [postprocessor_test] + [setup] + type = RunCommand + command = 'bash -c "foamCleanCase -case foam && blockMesh -case foam"' + [] + [run] + type = RunApp + input = main.i + prereq = postprocessor_test/setup + allow_warnings = true + [] + [] +[] From da0b2c0b7d19902b2b3e050cb8313ee65e08b3c8 Mon Sep 17 00:00:00 2001 From: Matthew Falcone Date: Wed, 8 Oct 2025 10:45:41 +0100 Subject: [PATCH 04/43] Use BlockRestrictable base class for FoamPostprocessor --- .../postprocessors/FoamPostprocessorBase.h | 2 ++ .../postprocessors/FoamSidePostprocessor.h | 12 ++++++++++ src/base/hippoApp.C | 2 ++ src/postprocessors/FoamPostprocessorBase.C | 11 +++++++++- src/postprocessors/FoamSidePostprocessor.C | 22 +++++++++++++++++++ 5 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 include/postprocessors/FoamSidePostprocessor.h create mode 100644 src/postprocessors/FoamSidePostprocessor.C diff --git a/include/postprocessors/FoamPostprocessorBase.h b/include/postprocessors/FoamPostprocessorBase.h index 97a84dfc..2f06f965 100644 --- a/include/postprocessors/FoamPostprocessorBase.h +++ b/include/postprocessors/FoamPostprocessorBase.h @@ -1,5 +1,6 @@ #pragma once +#include "MooseTypes.h" #include "UserObject.h" #include "Postprocessor.h" @@ -14,4 +15,5 @@ class FoamPostprocessorBase : public UserObject, public Postprocessor protected: FoamMesh * _mesh; + SubdomainName _boundary; }; diff --git a/include/postprocessors/FoamSidePostprocessor.h b/include/postprocessors/FoamSidePostprocessor.h new file mode 100644 index 00000000..e8fdf20f --- /dev/null +++ b/include/postprocessors/FoamSidePostprocessor.h @@ -0,0 +1,12 @@ +#include "BlockRestrictable.h" +#include "FoamPostprocessorBase.h" +#include "InputParameters.h" + +// When FoamMesh is updated use BoundaryRestrictable when Foammesh is refactored +class FoamSidePostprocessor : public FoamPostprocessorBase, public BlockRestrictable +{ +public: + static InputParameters validParams(); + + FoamSidePostprocessor(const InputParameters & params); +}; diff --git a/src/base/hippoApp.C b/src/base/hippoApp.C index 2abc1d74..f474f5f3 100644 --- a/src/base/hippoApp.C +++ b/src/base/hippoApp.C @@ -46,6 +46,8 @@ hippoApp::registerAll(Factory & f, ActionFactory & af, Syntax & syntax) // Add [FoamPostprocessors] block registerSyntax("AddPostprocessorAction", "FoamPostprocessors/*"); + syntax.registerSyntaxType("FoamPostprocessors/*", "PostprocessorName"); + syntax.registerSyntaxType("FoamPostprocessors/*", "UserObjectName"); } void diff --git a/src/postprocessors/FoamPostprocessorBase.C b/src/postprocessors/FoamPostprocessorBase.C index e5d249f7..dfe3da07 100644 --- a/src/postprocessors/FoamPostprocessorBase.C +++ b/src/postprocessors/FoamPostprocessorBase.C @@ -1,5 +1,7 @@ #include "FoamPostprocessorBase.h" #include "FoamProblem.h" +#include "InputParameters.h" +#include "MooseTypes.h" InputParameters FoamPostprocessorBase::validParams() @@ -10,11 +12,18 @@ FoamPostprocessorBase::validParams() } FoamPostprocessorBase::FoamPostprocessorBase(const InputParameters & params) - : UserObject(params), Postprocessor(this), _mesh(nullptr) + : UserObject(params), + Postprocessor(this), + _mesh(nullptr), + _boundary(getParam("boundary")) { FoamProblem * problem = dynamic_cast(&getSubProblem()); if (!problem) mooseError("FoamPostprocessors can only be used with FoamProblem"); _mesh = &problem->mesh(); + + // Remove once updated to use BoundaryRestrictable + const_cast(params).set>("block") = { + params.get("boundary")}; } diff --git a/src/postprocessors/FoamSidePostprocessor.C b/src/postprocessors/FoamSidePostprocessor.C new file mode 100644 index 00000000..19e6bdcc --- /dev/null +++ b/src/postprocessors/FoamSidePostprocessor.C @@ -0,0 +1,22 @@ +#include "BlockRestrictable.h" +#include "FoamPostprocessorBase.h" +#include "FoamSidePostprocessor.h" +#include "InputParameters.h" +#include "MooseTypes.h" + +InputParameters +FoamSidePostprocessor::validParams() +{ + auto params = FoamPostprocessorBase::validParams(); + params.addRequiredParam("boundary", "Boundary where this postprocessor applies"); + + // Remove once changedto BoundaryRestrictable + params.addPrivateParam("_dual_restrictable", false); + params.addPrivateParam>("block"); + return params; +} + +FoamSidePostprocessor::FoamSidePostprocessor(const InputParameters & params) + : FoamPostprocessorBase(params), BlockRestrictable(this) +{ +} From c24291568eb9372e28109e9f3d04bb0d8b47f9ca Mon Sep 17 00:00:00 2001 From: Matthew Falcone Date: Wed, 8 Oct 2025 10:46:35 +0100 Subject: [PATCH 05/43] Update tests to include boundaries --- test/include/postprocessors/FoamTestPostprocessor.h | 4 ++-- test/src/postprocessors/FoamTestPostprocessor.C | 5 ++--- test/tests/actions/foam_postprocessor/main.i | 1 + test/tests/actions/foam_postprocessor/tests | 8 ++++++++ 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/test/include/postprocessors/FoamTestPostprocessor.h b/test/include/postprocessors/FoamTestPostprocessor.h index 4f9430f7..9e3d5193 100644 --- a/test/include/postprocessors/FoamTestPostprocessor.h +++ b/test/include/postprocessors/FoamTestPostprocessor.h @@ -1,11 +1,11 @@ #pragma once -#include "FoamPostprocessorBase.h" +#include "FoamSidePostprocessor.h" #include "InputParameters.h" #include "MooseTypes.h" #include "UserObject.h" -class FoamTestPostprocessor : public FoamPostprocessorBase +class FoamTestPostprocessor : public FoamSidePostprocessor { public: static InputParameters validParams(); diff --git a/test/src/postprocessors/FoamTestPostprocessor.C b/test/src/postprocessors/FoamTestPostprocessor.C index a2d9ad75..31014b95 100644 --- a/test/src/postprocessors/FoamTestPostprocessor.C +++ b/test/src/postprocessors/FoamTestPostprocessor.C @@ -1,4 +1,3 @@ -#include "FoamPostprocessorBase.h" #include "FoamTestPostprocessor.h" #include "Registry.h" @@ -7,11 +6,11 @@ registerMooseObject("hippoApp", FoamTestPostprocessor); InputParameters FoamTestPostprocessor::validParams() { - return FoamPostprocessorBase::validParams(); + return FoamSidePostprocessor::validParams(); } FoamTestPostprocessor::FoamTestPostprocessor(const InputParameters & params) - : FoamPostprocessorBase(params), _value(0.) + : FoamSidePostprocessor(params), _value(0.) { } diff --git a/test/tests/actions/foam_postprocessor/main.i b/test/tests/actions/foam_postprocessor/main.i index 211b4edd..65846fc0 100644 --- a/test/tests/actions/foam_postprocessor/main.i +++ b/test/tests/actions/foam_postprocessor/main.i @@ -30,6 +30,7 @@ [FoamPostprocessors] [test] type = FoamTestPostprocessor + boundary = right [] [] [Outputs] diff --git a/test/tests/actions/foam_postprocessor/tests b/test/tests/actions/foam_postprocessor/tests index f649f15c..68af812c 100644 --- a/test/tests/actions/foam_postprocessor/tests +++ b/test/tests/actions/foam_postprocessor/tests @@ -10,5 +10,13 @@ prereq = postprocessor_test/setup allow_warnings = true [] + [boundary_err] + type = RunException + input = main.i + prereq = postprocessor_test/setup + allow_warnings = true + cli_args='FoamPostprocessors/test/boundary=right1' + expect_err = "do not exist on the mesh: right1" + [] [] [] From 3212f1e354ed81e7fec77f9e2caf7a297ad468ed Mon Sep 17 00:00:00 2001 From: Matthew Falcone Date: Wed, 8 Oct 2025 10:47:12 +0100 Subject: [PATCH 06/43] Add initial side average foam postprocessor --- include/postprocessors/FoamSideAverageValue.h | 23 +++++++ src/postprocessors/FoamSideAverageValue.C | 65 +++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 include/postprocessors/FoamSideAverageValue.h create mode 100644 src/postprocessors/FoamSideAverageValue.C diff --git a/include/postprocessors/FoamSideAverageValue.h b/include/postprocessors/FoamSideAverageValue.h new file mode 100644 index 00000000..638cbdd0 --- /dev/null +++ b/include/postprocessors/FoamSideAverageValue.h @@ -0,0 +1,23 @@ +#include "FoamPostprocessorBase.h" + +class FoamSideAverageValue : public FoamPostprocessorBase +{ + static InputParameters validParams(); + + FoamSideAverageValue(const InputParameters & params); + + virtual void execute() override; + + virtual void initialize() override; + + virtual void finalize() override; + + virtual void threadJoin(const UserObject & uo) override; + + virtual PostprocessorValue getValue() const override; + +protected: + Real _value; + + std::string _foam_scalar; +}; diff --git a/src/postprocessors/FoamSideAverageValue.C b/src/postprocessors/FoamSideAverageValue.C new file mode 100644 index 00000000..a15b52c9 --- /dev/null +++ b/src/postprocessors/FoamSideAverageValue.C @@ -0,0 +1,65 @@ +#include "FoamPostprocessorBase.h" +#include "FoamSideAverageValue.h" +#include "InputParameters.h" +#include "MooseTypes.h" +#include "UserObject.h" + +InputParameters +FoamSideAverageValue::validParams() +{ + auto params = FoamPostprocessorBase::validParams(); + params.addClassDescription( + "Class that calculates the average or scalar on a OpenFOAM boundary patch."); + params.addRequiredParam("foam_scalar", + "Foam variable to be averaged over a boundary patch."); + return params; +} + +FoamSideAverageValue::FoamSideAverageValue(const InputParameters & params) + : FoamPostprocessorBase(params), _value(0.), _foam_scalar(params.get("foam_scalar")) +{ +} + +void +FoamSideAverageValue::initialize() +{ + _value = 0.; +} + +void +FoamSideAverageValue::execute() +{ + auto & var_array = + _mesh->fvMesh().boundary()[_boundary].lookupPatchField( + _foam_scalar); + auto & areas = _mesh->fvMesh().boundary()[_boundary].magSf(); + + Real total_area = 0.; + + for (int i = 0; i < var_array.size(); ++i) + { + _value += var_array[i] * areas[i]; + total_area += areas[i]; + } + + _value /= total_area; +} + +void +FoamSideAverageValue::threadJoin(const UserObject & uo) +{ + const auto & pps = static_cast(uo); + _value += pps._value; +} + +void +FoamSideAverageValue::finalize() +{ + gatherSum(_value); +} + +PostprocessorValue +FoamSideAverageValue::getValue() const +{ + return _value; +} From b812998cb55c71cefb6079a0a42fe948cdbd866a Mon Sep 17 00:00:00 2001 From: Matthew Falcone Date: Wed, 8 Oct 2025 16:25:59 +0100 Subject: [PATCH 07/43] Create working side average postprocessor --- .../postprocessors/FoamPostprocessorBase.h | 19 ------------ include/postprocessors/FoamSideAverageValue.h | 6 ++-- .../postprocessors/FoamSidePostprocessor.h | 7 +++-- src/postprocessors/FoamPostprocessorBase.C | 29 ------------------- src/postprocessors/FoamSideAverageValue.C | 19 +++++++----- src/postprocessors/FoamSidePostprocessor.C | 15 ++++++---- 6 files changed, 28 insertions(+), 67 deletions(-) delete mode 100644 include/postprocessors/FoamPostprocessorBase.h delete mode 100644 src/postprocessors/FoamPostprocessorBase.C diff --git a/include/postprocessors/FoamPostprocessorBase.h b/include/postprocessors/FoamPostprocessorBase.h deleted file mode 100644 index 2f06f965..00000000 --- a/include/postprocessors/FoamPostprocessorBase.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once - -#include "MooseTypes.h" -#include "UserObject.h" -#include "Postprocessor.h" - -#include "FoamMesh.h" - -class FoamPostprocessorBase : public UserObject, public Postprocessor -{ -public: - static InputParameters validParams(); - - FoamPostprocessorBase(const InputParameters & params); - -protected: - FoamMesh * _mesh; - SubdomainName _boundary; -}; diff --git a/include/postprocessors/FoamSideAverageValue.h b/include/postprocessors/FoamSideAverageValue.h index 638cbdd0..447d219a 100644 --- a/include/postprocessors/FoamSideAverageValue.h +++ b/include/postprocessors/FoamSideAverageValue.h @@ -1,7 +1,9 @@ -#include "FoamPostprocessorBase.h" +#pragma once +#include "FoamSidePostprocessor.h" -class FoamSideAverageValue : public FoamPostprocessorBase +class FoamSideAverageValue : public FoamSidePostprocessor { +public: static InputParameters validParams(); FoamSideAverageValue(const InputParameters & params); diff --git a/include/postprocessors/FoamSidePostprocessor.h b/include/postprocessors/FoamSidePostprocessor.h index e8fdf20f..2cffcf54 100644 --- a/include/postprocessors/FoamSidePostprocessor.h +++ b/include/postprocessors/FoamSidePostprocessor.h @@ -1,9 +1,10 @@ -#include "BlockRestrictable.h" -#include "FoamPostprocessorBase.h" +#pragma once + +#include "ElementUserObject.h" #include "InputParameters.h" // When FoamMesh is updated use BoundaryRestrictable when Foammesh is refactored -class FoamSidePostprocessor : public FoamPostprocessorBase, public BlockRestrictable +class FoamSidePostprocessor : public ElementUserObject, public Postprocessor { public: static InputParameters validParams(); diff --git a/src/postprocessors/FoamPostprocessorBase.C b/src/postprocessors/FoamPostprocessorBase.C deleted file mode 100644 index dfe3da07..00000000 --- a/src/postprocessors/FoamPostprocessorBase.C +++ /dev/null @@ -1,29 +0,0 @@ -#include "FoamPostprocessorBase.h" -#include "FoamProblem.h" -#include "InputParameters.h" -#include "MooseTypes.h" - -InputParameters -FoamPostprocessorBase::validParams() -{ - auto params = UserObject::validParams(); - params += Postprocessor::validParams(); - return params; -} - -FoamPostprocessorBase::FoamPostprocessorBase(const InputParameters & params) - : UserObject(params), - Postprocessor(this), - _mesh(nullptr), - _boundary(getParam("boundary")) -{ - FoamProblem * problem = dynamic_cast(&getSubProblem()); - if (!problem) - mooseError("FoamPostprocessors can only be used with FoamProblem"); - - _mesh = &problem->mesh(); - - // Remove once updated to use BoundaryRestrictable - const_cast(params).set>("block") = { - params.get("boundary")}; -} diff --git a/src/postprocessors/FoamSideAverageValue.C b/src/postprocessors/FoamSideAverageValue.C index a15b52c9..163c9376 100644 --- a/src/postprocessors/FoamSideAverageValue.C +++ b/src/postprocessors/FoamSideAverageValue.C @@ -1,13 +1,15 @@ -#include "FoamPostprocessorBase.h" #include "FoamSideAverageValue.h" #include "InputParameters.h" #include "MooseTypes.h" #include "UserObject.h" +#include "FoamMesh.h" + +registerMooseObject("hippoApp", FoamSideAverageValue); InputParameters FoamSideAverageValue::validParams() { - auto params = FoamPostprocessorBase::validParams(); + auto params = FoamSidePostprocessor::validParams(); params.addClassDescription( "Class that calculates the average or scalar on a OpenFOAM boundary patch."); params.addRequiredParam("foam_scalar", @@ -16,26 +18,29 @@ FoamSideAverageValue::validParams() } FoamSideAverageValue::FoamSideAverageValue(const InputParameters & params) - : FoamPostprocessorBase(params), _value(0.), _foam_scalar(params.get("foam_scalar")) + : FoamSidePostprocessor(params), _value(0.), _foam_scalar(params.get("foam_scalar")) { } void FoamSideAverageValue::initialize() { - _value = 0.; } void FoamSideAverageValue::execute() { + auto foam_mesh = dynamic_cast(&_mesh); + auto boundary = blocks()[0]; auto & var_array = - _mesh->fvMesh().boundary()[_boundary].lookupPatchField( + foam_mesh->fvMesh().boundary()[boundary].lookupPatchField( _foam_scalar); - auto & areas = _mesh->fvMesh().boundary()[_boundary].magSf(); + auto & areas = foam_mesh->fvMesh().boundary()[boundary].magSf(); Real total_area = 0.; + _value = 0.; + std::cout << _value << std::endl; for (int i = 0; i < var_array.size(); ++i) { _value += var_array[i] * areas[i]; @@ -48,8 +53,6 @@ FoamSideAverageValue::execute() void FoamSideAverageValue::threadJoin(const UserObject & uo) { - const auto & pps = static_cast(uo); - _value += pps._value; } void diff --git a/src/postprocessors/FoamSidePostprocessor.C b/src/postprocessors/FoamSidePostprocessor.C index 19e6bdcc..942e0833 100644 --- a/src/postprocessors/FoamSidePostprocessor.C +++ b/src/postprocessors/FoamSidePostprocessor.C @@ -1,22 +1,25 @@ -#include "BlockRestrictable.h" -#include "FoamPostprocessorBase.h" +#include "ElementUserObject.h" #include "FoamSidePostprocessor.h" #include "InputParameters.h" #include "MooseTypes.h" +#include "FoamProblem.h" +#include "Postprocessor.h" InputParameters FoamSidePostprocessor::validParams() { - auto params = FoamPostprocessorBase::validParams(); - params.addRequiredParam("boundary", "Boundary where this postprocessor applies"); + auto params = ElementUserObject::validParams(); + params += Postprocessor::validParams(); // Remove once changedto BoundaryRestrictable params.addPrivateParam("_dual_restrictable", false); - params.addPrivateParam>("block"); return params; } FoamSidePostprocessor::FoamSidePostprocessor(const InputParameters & params) - : FoamPostprocessorBase(params), BlockRestrictable(this) + : ElementUserObject(params), Postprocessor(this) { + FoamProblem * problem = dynamic_cast(&getSubProblem()); + if (!problem) + mooseError("FoamPostprocessors can only be used with FoamProblem"); } From dbee8852fac9f8d3dc0645c9c67fbde1f7025d19 Mon Sep 17 00:00:00 2001 From: Matthew Falcone Date: Wed, 8 Oct 2025 16:26:56 +0100 Subject: [PATCH 08/43] Remove unnecessary action tests --- .../postprocessors/FoamTestPostprocessor.C | 44 ---------- .../tests/actions/foam_postprocessor/foam/0/T | 56 ------------ .../foam/constant/physicalProperties | 51 ----------- .../foam/system/blockMeshDict | 85 ------------------- .../foam/system/controlDict | 44 ---------- .../foam_postprocessor/foam/system/fvSchemes | 51 ----------- .../foam_postprocessor/foam/system/fvSolution | 61 ------------- test/tests/actions/foam_postprocessor/main.i | 38 --------- test/tests/actions/foam_postprocessor/tests | 22 ----- 9 files changed, 452 deletions(-) delete mode 100644 test/src/postprocessors/FoamTestPostprocessor.C delete mode 100644 test/tests/actions/foam_postprocessor/foam/0/T delete mode 100644 test/tests/actions/foam_postprocessor/foam/constant/physicalProperties delete mode 100644 test/tests/actions/foam_postprocessor/foam/system/blockMeshDict delete mode 100644 test/tests/actions/foam_postprocessor/foam/system/controlDict delete mode 100644 test/tests/actions/foam_postprocessor/foam/system/fvSchemes delete mode 100644 test/tests/actions/foam_postprocessor/foam/system/fvSolution delete mode 100644 test/tests/actions/foam_postprocessor/main.i delete mode 100644 test/tests/actions/foam_postprocessor/tests diff --git a/test/src/postprocessors/FoamTestPostprocessor.C b/test/src/postprocessors/FoamTestPostprocessor.C deleted file mode 100644 index 31014b95..00000000 --- a/test/src/postprocessors/FoamTestPostprocessor.C +++ /dev/null @@ -1,44 +0,0 @@ -#include "FoamTestPostprocessor.h" -#include "Registry.h" - -registerMooseObject("hippoApp", FoamTestPostprocessor); - -InputParameters -FoamTestPostprocessor::validParams() -{ - return FoamSidePostprocessor::validParams(); -} - -FoamTestPostprocessor::FoamTestPostprocessor(const InputParameters & params) - : FoamSidePostprocessor(params), _value(0.) -{ -} - -void -FoamTestPostprocessor::execute() -{ - _value = 1.; -} - -void -FoamTestPostprocessor::initialize() -{ - _value = 0.; -} - -void -FoamTestPostprocessor::threadJoin(const UserObject & uo) -{ -} - -void -FoamTestPostprocessor::finalize() -{ - gatherSum(_value); -} - -PostprocessorValue -FoamTestPostprocessor::getValue() const -{ - return _value; -} diff --git a/test/tests/actions/foam_postprocessor/foam/0/T b/test/tests/actions/foam_postprocessor/foam/0/T deleted file mode 100644 index f8312bb2..00000000 --- a/test/tests/actions/foam_postprocessor/foam/0/T +++ /dev/null @@ -1,56 +0,0 @@ -/*--------------------------------*- C++ -*----------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | Website: https://openfoam.org - \\ / A nd | Version: 10 - \\/ M anipulation | -\*---------------------------------------------------------------------------*/ -FoamFile -{ - format ascii; - class volScalarField; - location "0"; - object T; -} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -dimensions [0 0 0 1 0 0 0]; - -internalField uniform 0.1; - -boundaryField -{ - left - { - type calculated; - value uniform 0.; - } - right - { - type calculated; - value uniform 0.; - } - top - { - type calculated; - value uniform 0.; - } - bottom - { - type calculated; - value uniform 0.; - } - back - { - type calculated; - value uniform 0.; - } - front - { - type calculated; - value uniform 0.; - } -} - - -// ************************************************************************* // diff --git a/test/tests/actions/foam_postprocessor/foam/constant/physicalProperties b/test/tests/actions/foam_postprocessor/foam/constant/physicalProperties deleted file mode 100644 index 96a14c15..00000000 --- a/test/tests/actions/foam_postprocessor/foam/constant/physicalProperties +++ /dev/null @@ -1,51 +0,0 @@ -/*--------------------------------*- C++ -*----------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | Website: https://openfoam.org - \\ / A nd | Version: 10 - \\/ M anipulation | -\*---------------------------------------------------------------------------*/ -FoamFile -{ - format ascii; - class dictionary; - location "constant"; - object physicalProperties; -} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -thermoType -{ - type heSolidThermo; - mixture pureMixture; - transport constIsoSolid; - thermo eConst; - equationOfState rhoConst; - specie specie; - energy sensibleInternalEnergy; -} - -mixture -{ - specie - { - molWeight 1; - } - thermodynamics - { - Cv 1; // Specific heat capacity [J/(kg·K)] - Hf 1; // Heat of formation [J/kg] - Tref 0; - } - transport - { - kappa 1; // Thermal conductivity [W/(m·K)] - } - equationOfState - { - rho 1; // Density [kg/m^3] - } -} - - -// ************************************************************************* // diff --git a/test/tests/actions/foam_postprocessor/foam/system/blockMeshDict b/test/tests/actions/foam_postprocessor/foam/system/blockMeshDict deleted file mode 100644 index face9ea6..00000000 --- a/test/tests/actions/foam_postprocessor/foam/system/blockMeshDict +++ /dev/null @@ -1,85 +0,0 @@ -FoamFile -{ - version 2.0; - format ascii; - class dictionary; - object blockMeshDict; -} - -vertices -( - ( 0.0 0.0 0.0 ) - ( 10.0 0.0 0.0 ) - ( 10.0 1.0 0.0 ) - ( 0.0 1.0 0.0 ) - - ( 0.0 0.0 1.0) - ( 10.0 0.0 1.0) - ( 10.0 1.0 1.0) - ( 0.0 1.0 1.0) -); - -blocks -( - hex (0 1 2 3 4 5 6 7) (50 1 1) simpleGrading (25 1 1) -); - -boundary -( - - // interface - left - { - type wall; - faces - ( - (4 7 3 0) - ); - } - - right - { - type wall; - faces - ( - (6 5 1 2) - ); - } - - top - { - type wall; - faces - ( - (2 3 7 6) - ); - } - - front - { - type wall; - faces - ( - (3 2 1 0) - ); - } - - bottom - { - type wall; - faces - ( - (0 1 5 4) - ); - } - - back - { - type wall; - faces - ( - (4 5 6 7) - ); - } - -); diff --git a/test/tests/actions/foam_postprocessor/foam/system/controlDict b/test/tests/actions/foam_postprocessor/foam/system/controlDict deleted file mode 100644 index 0383dd23..00000000 --- a/test/tests/actions/foam_postprocessor/foam/system/controlDict +++ /dev/null @@ -1,44 +0,0 @@ -/*--------------------------------*- C++ -*----------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | Website: https://openfoam.org - \\ / A nd | Version: 10 - \\/ M anipulation | -\*---------------------------------------------------------------------------*/ -FoamFile -{ - format ascii; - class dictionary; - object controlDict; -} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -solver transferTestSolver; - -startFrom startTime; - -startTime 0; - -stopAt endTime; - -endTime 0.32; - -deltaT 0.01; - -writeControl timeStep; - -writeInterval 1; - -writeFormat ascii; - -writePrecision 20; - -writeCompression off; - -timeFormat general; - -timePrecision 20; - -runTimeModifiable true; - -// ************************************************************************* // diff --git a/test/tests/actions/foam_postprocessor/foam/system/fvSchemes b/test/tests/actions/foam_postprocessor/foam/system/fvSchemes deleted file mode 100644 index 787f3b83..00000000 --- a/test/tests/actions/foam_postprocessor/foam/system/fvSchemes +++ /dev/null @@ -1,51 +0,0 @@ -/*--------------------------------*- C++ -*----------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | Website: https://openfoam.org - \\ / A nd | Version: 12 - \\/ M anipulation | -\*---------------------------------------------------------------------------*/ -FoamFile -{ - format ascii; - class dictionary; - object fvSchemes; -} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -ddtSchemes -{ - default Euler; -} - -gradSchemes -{ - default Gauss linear; -} - -divSchemes -{ - default none; - - div(phi,U) Gauss linear; - div(phi,K) Gauss linear; - div(phi,h) Gauss linear; - div(((rho*nuEff)*dev2(T(grad(U))))) Gauss linear; -} - -laplacianSchemes -{ - default Gauss linear corrected; -} - -interpolationSchemes -{ - default linear; -} - -snGradSchemes -{ - default corrected; -} - -// ************************************************************************* // diff --git a/test/tests/actions/foam_postprocessor/foam/system/fvSolution b/test/tests/actions/foam_postprocessor/foam/system/fvSolution deleted file mode 100644 index 61143b21..00000000 --- a/test/tests/actions/foam_postprocessor/foam/system/fvSolution +++ /dev/null @@ -1,61 +0,0 @@ -/*--------------------------------*- C++ -*----------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | Website: https://openfoam.org - \\ / A nd | Version: 12 - \\/ M anipulation | -\*---------------------------------------------------------------------------*/ -FoamFile -{ - format ascii; - class dictionary; - object fvSolution; -} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -solvers -{ - rho - { - solver diagonal; - } - - rhoFinal - { - $rho; - } - - - "(U|h|p_rgh)" - { - solver PBiCGStab; - preconditioner DILU; - tolerance 1e-8; - relTol 1e-8; - } - - "(U|h|p_rgh)Final" - { - $U; - tolerance 1e-8; - relTol 1e-8; - } -} - -PIMPLE -{ - momentumPredictor yes; - pRefCell 0; - pRefValue 0; -} - -relaxationFactors -{ - equations - { - h 1; - U 1; - } -} - -// ************************************************************************* // diff --git a/test/tests/actions/foam_postprocessor/main.i b/test/tests/actions/foam_postprocessor/main.i deleted file mode 100644 index 65846fc0..00000000 --- a/test/tests/actions/foam_postprocessor/main.i +++ /dev/null @@ -1,38 +0,0 @@ -[Mesh] - type = FoamMesh - case = 'foam' - foam_patch = 'left right bottom top back front' -[] - -[Variables] - [dummy] - family = MONOMIAL - order = CONSTANT - initial_condition = 999 - [] -[] - -[Problem] - type = FoamProblem - solve = false -[] - -[Executioner] - type = Transient - end_time = 0.32 - [TimeSteppers] - [foam] - type = FoamControlledTimeStepper - [] - [] -[] - -[FoamPostprocessors] - [test] - type = FoamTestPostprocessor - boundary = right - [] -[] -[Outputs] - exodus = true -[] diff --git a/test/tests/actions/foam_postprocessor/tests b/test/tests/actions/foam_postprocessor/tests deleted file mode 100644 index 68af812c..00000000 --- a/test/tests/actions/foam_postprocessor/tests +++ /dev/null @@ -1,22 +0,0 @@ -[Tests] - [postprocessor_test] - [setup] - type = RunCommand - command = 'bash -c "foamCleanCase -case foam && blockMesh -case foam"' - [] - [run] - type = RunApp - input = main.i - prereq = postprocessor_test/setup - allow_warnings = true - [] - [boundary_err] - type = RunException - input = main.i - prereq = postprocessor_test/setup - allow_warnings = true - cli_args='FoamPostprocessors/test/boundary=right1' - expect_err = "do not exist on the mesh: right1" - [] - [] -[] From f274432eb02bdba295def3997bc740a37b183287 Mon Sep 17 00:00:00 2001 From: Matthew Falcone Date: Wed, 8 Oct 2025 16:27:50 +0100 Subject: [PATCH 09/43] Add postprocessor test solver --- test/OpenFOAM/foam_modules.mk | 2 + .../postprocessorTestSolver/Make/files | 3 + .../postprocessorTestSolver/Make/options | 20 ++ .../postprocessorTestSolver.C | 174 ++++++++++++++++++ .../postprocessorTestSolver.H | 147 +++++++++++++++ 5 files changed, 346 insertions(+) create mode 100644 test/OpenFOAM/modules/postprocessorTestSolver/Make/files create mode 100644 test/OpenFOAM/modules/postprocessorTestSolver/Make/options create mode 100644 test/OpenFOAM/modules/postprocessorTestSolver/postprocessorTestSolver.C create mode 100644 test/OpenFOAM/modules/postprocessorTestSolver/postprocessorTestSolver.H diff --git a/test/OpenFOAM/foam_modules.mk b/test/OpenFOAM/foam_modules.mk index 25c3a3a7..5f46dcf9 100644 --- a/test/OpenFOAM/foam_modules.mk +++ b/test/OpenFOAM/foam_modules.mk @@ -11,3 +11,5 @@ build_foam_tests: @$(MAKE) -s -j $(MOOSE_JOBS) test/OpenFOAM/modules/functionTestSolver/ @$(MAKE) -s -j $(MOOSE_JOBS) test/OpenFOAM/modules/laplacianTestSolver/ @$(MAKE) -s -j $(MOOSE_JOBS) test/OpenFOAM/modules/odeTestSolver/ + @$(MAKE) -s -j $(MOOSE_JOBS) test/OpenFOAM/modules/postprocessorTestSolver/ + diff --git a/test/OpenFOAM/modules/postprocessorTestSolver/Make/files b/test/OpenFOAM/modules/postprocessorTestSolver/Make/files new file mode 100644 index 00000000..42765a4f --- /dev/null +++ b/test/OpenFOAM/modules/postprocessorTestSolver/Make/files @@ -0,0 +1,3 @@ +SOURCE += postprocessorTestSolver.C + +LIB = $(FOAM_USER_LIBBIN)/libpostprocessorTestSolver diff --git a/test/OpenFOAM/modules/postprocessorTestSolver/Make/options b/test/OpenFOAM/modules/postprocessorTestSolver/Make/options new file mode 100644 index 00000000..cc845ca8 --- /dev/null +++ b/test/OpenFOAM/modules/postprocessorTestSolver/Make/options @@ -0,0 +1,20 @@ +EXE_INC = \ + -I$(LIB_SRC)/physicalProperties/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/solidThermo/lnInclude \ + -I$(LIB_SRC)/ThermophysicalTransportModels/thermophysicalTransportModel/lnInclude \ + -I$(LIB_SRC)/ThermophysicalTransportModels/solid/lnInclude \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/sampling/lnInclude + +LIB_LIBS = \ + -lsolidThermo \ + -lsolidThermophysicalTransportModels \ + -lcoupledThermophysicalTransportModels \ + -lspecie \ + -lfiniteVolume \ + -lmeshTools \ + -lsampling \ + -lfvModels \ + -lfvConstraints diff --git a/test/OpenFOAM/modules/postprocessorTestSolver/postprocessorTestSolver.C b/test/OpenFOAM/modules/postprocessorTestSolver/postprocessorTestSolver.C new file mode 100644 index 00000000..75c6de42 --- /dev/null +++ b/test/OpenFOAM/modules/postprocessorTestSolver/postprocessorTestSolver.C @@ -0,0 +1,174 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2022-2024 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "dimensionSets.H" +#include "fvMesh.H" +#include "postprocessorTestSolver.H" +#include "fvMeshMover.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace solvers +{ +defineTypeNameAndDebug(postprocessorTestSolver, 0); +addToRunTimeSelectionTable(solver, postprocessorTestSolver, fvMesh); +} +} + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * // + +bool +Foam::solvers::postprocessorTestSolver::dependenciesModified() const +{ + return runTime.controlDict().modified(); +} + +bool +Foam::solvers::postprocessorTestSolver::read() +{ + solver::read(); + + maxDeltaT_ = runTime.controlDict().found("maxDeltaT") + ? runTime.controlDict().lookup("maxDeltaT", runTime.userUnits()) + : vGreat; + + return true; +} + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // +// Solver based on solid.C module +Foam::solvers::postprocessorTestSolver::postprocessorTestSolver(fvMesh & mesh, + autoPtr thermoPtr) + : solver(mesh), + + thermoPtr_(thermoPtr), + thermo_(thermoPtr_()), + + T_(IOobject("T", mesh.time().name(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE), mesh), + + thermophysicalTransport(solidThermophysicalTransportModel::New(thermo_)), + thermo(thermo_), + T(T_) +{ + thermo.validate("solid", "h", "e"); +} + +Foam::solvers::postprocessorTestSolver::postprocessorTestSolver(fvMesh & mesh) + : postprocessorTestSolver(mesh, solidThermo::New(mesh)) +{ + // Read the controls + read(); +} + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::solvers::postprocessorTestSolver::~postprocessorTestSolver() {} + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +Foam::scalar +Foam::solvers::postprocessorTestSolver::maxDeltaT() const +{ + return min(fvModels().maxDeltaT(), maxDeltaT_); +} + +void +Foam::solvers::postprocessorTestSolver::preSolve() +{ + fvModels().preUpdateMesh(); + + // Update the mesh for topology change, mesh to mesh mapping + mesh_.update(); +} + +void +Foam::solvers::postprocessorTestSolver::moveMesh() +{ + if (pimple.firstIter() || pimple.moveMeshOuterCorrectors()) + { + if (!mesh_.mover().solidBody()) + { + FatalErrorInFunction << "Region " << name() << " of type " << type() + << " does not support non-solid body mesh motion" << exit(FatalError); + } + + mesh_.move(); + } +} + +void +Foam::solvers::postprocessorTestSolver::motionCorrector() +{ +} + +void +Foam::solvers::postprocessorTestSolver::prePredictor() +{ +} + +void +Foam::solvers::postprocessorTestSolver::momentumPredictor() +{ +} + +void +Foam::solvers::postprocessorTestSolver::thermophysicalPredictor() +{ + // To set temperature for testing, internal energy must be set. The + // thermo_.correct() call calculates Temperature. + + // Get e and Cv + volScalarField & e = thermo_.he(); + const volScalarField & Cv = thermo_.Cv(); + + // Set e to Cv*(xy + yz + xz)t which gives a non-uniform be first order value of wall heat flux at + // all boundaries. + dimensioned t("t", T.dimensions(), mesh_.time().userTimeValue()); + e = Cv * t; + + thermo_.correct(); +} + +void +Foam::solvers::postprocessorTestSolver::pressureCorrector() +{ +} + +void +Foam::solvers::postprocessorTestSolver::postCorrector() +{ +} + +void +Foam::solvers::postprocessorTestSolver::postSolve() +{ +} + +// ************************************************************************* // diff --git a/test/OpenFOAM/modules/postprocessorTestSolver/postprocessorTestSolver.H b/test/OpenFOAM/modules/postprocessorTestSolver/postprocessorTestSolver.H new file mode 100644 index 00000000..936deacd --- /dev/null +++ b/test/OpenFOAM/modules/postprocessorTestSolver/postprocessorTestSolver.H @@ -0,0 +1,147 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2022-2023 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Class + Foam::solvers::postprocessorTestSolver + +Description + Solver module for to test transfers between OpenFOAM and MOOSE. Based on Solid + solver + +SourceFiles + postprocessorTestSolver.C + +\*---------------------------------------------------------------------------*/ + +#pragma once + +#include "solver.H" +#include "solidThermophysicalTransportModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace solvers +{ + +/*---------------------------------------------------------------------------*\ + Class postprocessorTestSolver Declaration +\*---------------------------------------------------------------------------*/ + +class postprocessorTestSolver : public solver +{ + +protected: + // Control parameters + scalar maxDeltaT_; + + // Thermophysical properties + autoPtr thermoPtr_; + + solidThermo & thermo_; + + volScalarField T_; + + autoPtr thermophysicalTransport; + + // Protected Member Functions + + //- Return true if the solver's dependencies have been modified + virtual bool dependenciesModified() const; + + //- Read controls + virtual bool read(); + +public: + // Public Data + // reference to thermophysical properties + const solidThermo & thermo; + + //- Reference to the temperature field + const volScalarField & T; + + //- Runtime type information + TypeName("postprocessorTestSolver"); + + // Constructors + + //- Construct from region mesh + postprocessorTestSolver(fvMesh & mesh, autoPtr thermoPtr); + + postprocessorTestSolver(fvMesh & mesh); + + //- Disallow default bitwise copy construction + postprocessorTestSolver(const postprocessorTestSolver &) = delete; + + //- Destructor + virtual ~postprocessorTestSolver(); + + // Member Functions + + //- Return the current maximum time-step for stable solution + virtual scalar maxDeltaT() const; + + //- Called at the start of the time-step, before the PIMPLE loop + virtual void preSolve(); + + //- Called at the start of the PIMPLE loop to move the mesh + virtual void moveMesh(); + + //- Corrections that follow mesh motion + virtual void motionCorrector(); + + //- Called at the beginning of the PIMPLE loop + virtual void prePredictor(); + + //- Construct and optionally solve the momentum equation + virtual void momentumPredictor(); + + //- Construct and solve the energy equation, + // convert to temperature + // and update thermophysical and transport properties + virtual void thermophysicalPredictor(); + + //- Construct and solve the pressure equation in the PISO loop + virtual void pressureCorrector(); + + //- Correct the thermophysical transport modelling + virtual void postCorrector(); + + //- Called after the PIMPLE loop at the end of the time-step + virtual void postSolve(); + + // Member Operators + + //- Disallow default bitwise assignment + void operator=(const postprocessorTestSolver &) = delete; +}; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace solvers +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +// ************************************************************************* // From b3bfff1ded7a34429029effaecc5cf3a0a2a596f Mon Sep 17 00:00:00 2001 From: Matthew Falcone Date: Wed, 8 Oct 2025 18:21:10 +0100 Subject: [PATCH 10/43] Make use of current element info in postprocessor --- .../postprocessors/FoamSidePostprocessor.h | 3 ++ src/postprocessors/FoamSideAverageValue.C | 29 +++++++++++-------- src/postprocessors/FoamSidePostprocessor.C | 4 +-- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/include/postprocessors/FoamSidePostprocessor.h b/include/postprocessors/FoamSidePostprocessor.h index 2cffcf54..87e56541 100644 --- a/include/postprocessors/FoamSidePostprocessor.h +++ b/include/postprocessors/FoamSidePostprocessor.h @@ -10,4 +10,7 @@ class FoamSidePostprocessor : public ElementUserObject, public Postprocessor static InputParameters validParams(); FoamSidePostprocessor(const InputParameters & params); + +protected: + Real _volume; }; diff --git a/src/postprocessors/FoamSideAverageValue.C b/src/postprocessors/FoamSideAverageValue.C index 163c9376..1a9d6c6a 100644 --- a/src/postprocessors/FoamSideAverageValue.C +++ b/src/postprocessors/FoamSideAverageValue.C @@ -3,6 +3,7 @@ #include "MooseTypes.h" #include "UserObject.h" #include "FoamMesh.h" +#include registerMooseObject("hippoApp", FoamSideAverageValue); @@ -25,40 +26,44 @@ FoamSideAverageValue::FoamSideAverageValue(const InputParameters & params) void FoamSideAverageValue::initialize() { + _value = 0.; + _volume = 0.; } void FoamSideAverageValue::execute() { auto foam_mesh = dynamic_cast(&_mesh); - auto boundary = blocks()[0]; + int64_t patch_offset = 0; + for (auto & subdomain : foam_mesh->meshSubdomains()) + if (subdomain < _current_elem->subdomain_id()) + patch_offset += foam_mesh->getPatchCount(subdomain); + + auto boundary = foam_mesh->getSubdomainName(_current_elem->subdomain_id()); + auto idx = static_cast(_current_elem->id()) - + static_cast(foam_mesh->rank_element_offset) - patch_offset; + auto & var_array = foam_mesh->fvMesh().boundary()[boundary].lookupPatchField( _foam_scalar); auto & areas = foam_mesh->fvMesh().boundary()[boundary].magSf(); - Real total_area = 0.; - _value = 0.; - - std::cout << _value << std::endl; - for (int i = 0; i < var_array.size(); ++i) - { - _value += var_array[i] * areas[i]; - total_area += areas[i]; - } - - _value /= total_area; + _value += var_array[idx] * areas[idx]; + _volume += areas[idx]; } void FoamSideAverageValue::threadJoin(const UserObject & uo) { + (void)uo; } void FoamSideAverageValue::finalize() { + gatherSum(_volume); gatherSum(_value); + _value /= _volume; } PostprocessorValue diff --git a/src/postprocessors/FoamSidePostprocessor.C b/src/postprocessors/FoamSidePostprocessor.C index 942e0833..ab512d97 100644 --- a/src/postprocessors/FoamSidePostprocessor.C +++ b/src/postprocessors/FoamSidePostprocessor.C @@ -11,13 +11,11 @@ FoamSidePostprocessor::validParams() auto params = ElementUserObject::validParams(); params += Postprocessor::validParams(); - // Remove once changedto BoundaryRestrictable - params.addPrivateParam("_dual_restrictable", false); return params; } FoamSidePostprocessor::FoamSidePostprocessor(const InputParameters & params) - : ElementUserObject(params), Postprocessor(this) + : ElementUserObject(params), Postprocessor(this), _volume(0.) { FoamProblem * problem = dynamic_cast(&getSubProblem()); if (!problem) From acfbcd6fff7e8e86f8ecb2eb3a85e8b3d2c44c15 Mon Sep 17 00:00:00 2001 From: Matthew Falcone Date: Wed, 8 Oct 2025 18:21:41 +0100 Subject: [PATCH 11/43] Add test for FoamSideAverageValue postprocessor --- .../postprocessors/side_average/foam/0/T | 56 ++++++++++++ .../foam/constant/physicalProperties | 51 +++++++++++ .../side_average/foam/system/blockMeshDict | 85 +++++++++++++++++++ .../side_average/foam/system/controlDict | 44 ++++++++++ .../side_average/foam/system/fvSchemes | 51 +++++++++++ .../side_average/foam/system/fvSolution | 61 +++++++++++++ .../side_average/gold/main_out.csv | 34 ++++++++ test/tests/postprocessors/side_average/main.i | 41 +++++++++ test/tests/postprocessors/side_average/tests | 23 +++++ 9 files changed, 446 insertions(+) create mode 100644 test/tests/postprocessors/side_average/foam/0/T create mode 100644 test/tests/postprocessors/side_average/foam/constant/physicalProperties create mode 100644 test/tests/postprocessors/side_average/foam/system/blockMeshDict create mode 100644 test/tests/postprocessors/side_average/foam/system/controlDict create mode 100644 test/tests/postprocessors/side_average/foam/system/fvSchemes create mode 100644 test/tests/postprocessors/side_average/foam/system/fvSolution create mode 100644 test/tests/postprocessors/side_average/gold/main_out.csv create mode 100644 test/tests/postprocessors/side_average/main.i create mode 100644 test/tests/postprocessors/side_average/tests diff --git a/test/tests/postprocessors/side_average/foam/0/T b/test/tests/postprocessors/side_average/foam/0/T new file mode 100644 index 00000000..f8312bb2 --- /dev/null +++ b/test/tests/postprocessors/side_average/foam/0/T @@ -0,0 +1,56 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 10 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volScalarField; + location "0"; + object T; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 1 0 0 0]; + +internalField uniform 0.1; + +boundaryField +{ + left + { + type calculated; + value uniform 0.; + } + right + { + type calculated; + value uniform 0.; + } + top + { + type calculated; + value uniform 0.; + } + bottom + { + type calculated; + value uniform 0.; + } + back + { + type calculated; + value uniform 0.; + } + front + { + type calculated; + value uniform 0.; + } +} + + +// ************************************************************************* // diff --git a/test/tests/postprocessors/side_average/foam/constant/physicalProperties b/test/tests/postprocessors/side_average/foam/constant/physicalProperties new file mode 100644 index 00000000..96a14c15 --- /dev/null +++ b/test/tests/postprocessors/side_average/foam/constant/physicalProperties @@ -0,0 +1,51 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 10 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + location "constant"; + object physicalProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +thermoType +{ + type heSolidThermo; + mixture pureMixture; + transport constIsoSolid; + thermo eConst; + equationOfState rhoConst; + specie specie; + energy sensibleInternalEnergy; +} + +mixture +{ + specie + { + molWeight 1; + } + thermodynamics + { + Cv 1; // Specific heat capacity [J/(kg·K)] + Hf 1; // Heat of formation [J/kg] + Tref 0; + } + transport + { + kappa 1; // Thermal conductivity [W/(m·K)] + } + equationOfState + { + rho 1; // Density [kg/m^3] + } +} + + +// ************************************************************************* // diff --git a/test/tests/postprocessors/side_average/foam/system/blockMeshDict b/test/tests/postprocessors/side_average/foam/system/blockMeshDict new file mode 100644 index 00000000..face9ea6 --- /dev/null +++ b/test/tests/postprocessors/side_average/foam/system/blockMeshDict @@ -0,0 +1,85 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object blockMeshDict; +} + +vertices +( + ( 0.0 0.0 0.0 ) + ( 10.0 0.0 0.0 ) + ( 10.0 1.0 0.0 ) + ( 0.0 1.0 0.0 ) + + ( 0.0 0.0 1.0) + ( 10.0 0.0 1.0) + ( 10.0 1.0 1.0) + ( 0.0 1.0 1.0) +); + +blocks +( + hex (0 1 2 3 4 5 6 7) (50 1 1) simpleGrading (25 1 1) +); + +boundary +( + + // interface + left + { + type wall; + faces + ( + (4 7 3 0) + ); + } + + right + { + type wall; + faces + ( + (6 5 1 2) + ); + } + + top + { + type wall; + faces + ( + (2 3 7 6) + ); + } + + front + { + type wall; + faces + ( + (3 2 1 0) + ); + } + + bottom + { + type wall; + faces + ( + (0 1 5 4) + ); + } + + back + { + type wall; + faces + ( + (4 5 6 7) + ); + } + +); diff --git a/test/tests/postprocessors/side_average/foam/system/controlDict b/test/tests/postprocessors/side_average/foam/system/controlDict new file mode 100644 index 00000000..4e2baf59 --- /dev/null +++ b/test/tests/postprocessors/side_average/foam/system/controlDict @@ -0,0 +1,44 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 10 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + object controlDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +solver postprocessorTestSolver; + +startFrom startTime; + +startTime 0; + +stopAt endTime; + +endTime 0.32; + +deltaT 0.01; + +writeControl timeStep; + +writeInterval 1; + +writeFormat ascii; + +writePrecision 20; + +writeCompression off; + +timeFormat general; + +timePrecision 20; + +runTimeModifiable true; + +// ************************************************************************* // diff --git a/test/tests/postprocessors/side_average/foam/system/fvSchemes b/test/tests/postprocessors/side_average/foam/system/fvSchemes new file mode 100644 index 00000000..787f3b83 --- /dev/null +++ b/test/tests/postprocessors/side_average/foam/system/fvSchemes @@ -0,0 +1,51 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 12 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + object fvSchemes; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +ddtSchemes +{ + default Euler; +} + +gradSchemes +{ + default Gauss linear; +} + +divSchemes +{ + default none; + + div(phi,U) Gauss linear; + div(phi,K) Gauss linear; + div(phi,h) Gauss linear; + div(((rho*nuEff)*dev2(T(grad(U))))) Gauss linear; +} + +laplacianSchemes +{ + default Gauss linear corrected; +} + +interpolationSchemes +{ + default linear; +} + +snGradSchemes +{ + default corrected; +} + +// ************************************************************************* // diff --git a/test/tests/postprocessors/side_average/foam/system/fvSolution b/test/tests/postprocessors/side_average/foam/system/fvSolution new file mode 100644 index 00000000..61143b21 --- /dev/null +++ b/test/tests/postprocessors/side_average/foam/system/fvSolution @@ -0,0 +1,61 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 12 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + object fvSolution; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +solvers +{ + rho + { + solver diagonal; + } + + rhoFinal + { + $rho; + } + + + "(U|h|p_rgh)" + { + solver PBiCGStab; + preconditioner DILU; + tolerance 1e-8; + relTol 1e-8; + } + + "(U|h|p_rgh)Final" + { + $U; + tolerance 1e-8; + relTol 1e-8; + } +} + +PIMPLE +{ + momentumPredictor yes; + pRefCell 0; + pRefValue 0; +} + +relaxationFactors +{ + equations + { + h 1; + U 1; + } +} + +// ************************************************************************* // diff --git a/test/tests/postprocessors/side_average/gold/main_out.csv b/test/tests/postprocessors/side_average/gold/main_out.csv new file mode 100644 index 00000000..d527c99b --- /dev/null +++ b/test/tests/postprocessors/side_average/gold/main_out.csv @@ -0,0 +1,34 @@ +time,test +0,0 +0.01,0.01 +0.02,0.02 +0.03,0.03 +0.04,0.04 +0.05,0.05 +0.06,0.06 +0.07,0.07 +0.08,0.08 +0.09,0.09 +0.1,0.1 +0.11,0.11 +0.12,0.12 +0.13,0.13 +0.14,0.14 +0.15,0.15 +0.16,0.16 +0.17,0.17 +0.18,0.18 +0.19,0.19 +0.2,0.2 +0.21,0.21 +0.22,0.22 +0.23,0.23 +0.24,0.24 +0.25,0.25 +0.26,0.26 +0.27,0.27 +0.28,0.28 +0.29,0.29 +0.3,0.3 +0.31,0.31 +0.32,0.32 diff --git a/test/tests/postprocessors/side_average/main.i b/test/tests/postprocessors/side_average/main.i new file mode 100644 index 00000000..e78e0e7e --- /dev/null +++ b/test/tests/postprocessors/side_average/main.i @@ -0,0 +1,41 @@ +[Mesh] + type = FoamMesh + case = 'foam' + foam_patch = 'left right bottom top back front' +[] + +[Variables] + [dummy] + family = MONOMIAL + order = CONSTANT + initial_condition = 999 + [] +[] + +[Problem] + type = FoamProblem +[] + +[Executioner] + type = Transient + end_time = 0.32 + [TimeSteppers] + [foam] + type = FoamControlledTimeStepper + [] + [] +[] + +[Postprocessors] + [test] + type = FoamSideAverageValue + foam_scalar = 'T' + block = top + execute_on = TIMESTEP_END + [] +[] + +[Outputs] + exodus = false + csv = true +[] diff --git a/test/tests/postprocessors/side_average/tests b/test/tests/postprocessors/side_average/tests new file mode 100644 index 00000000..bf8413ba --- /dev/null +++ b/test/tests/postprocessors/side_average/tests @@ -0,0 +1,23 @@ +[Tests] + [postprocessor_test] + [setup] + type = RunCommand + command = 'bash -c "foamCleanCase -case foam && blockMesh -case foam"' + [] + [check_csv] + type = CSVDiff + input = main.i + prereq = postprocessor_test/setup + csvdiff = main_out.csv + allow_warnings = true + [] + [boundary_err] + type = RunException + input = main.i + prereq = postprocessor_test/setup + allow_warnings = true + cli_args='Postprocessors/test/block=top1' + expect_err = "do not exist on the mesh: top1" + [] + [] +[] From 0c9d93e82052a6c26c10c8093e9879aa4006dfed Mon Sep 17 00:00:00 2001 From: Matthew Falcone Date: Thu, 9 Oct 2025 17:15:32 +0100 Subject: [PATCH 12/43] Updated FoamProcessor so it computes with FoamProblem --- .../postprocessors/FoamPostprocessorBase.h | 23 ++++++++ include/postprocessors/FoamSideAverageValue.h | 10 +--- .../postprocessors/FoamSidePostprocessor.h | 5 +- include/problems/FoamProblem.h | 2 + src/postprocessors/FoamPostprocessorBase.C | 39 ++++++++++++++ src/postprocessors/FoamSideAverageValue.C | 52 +++++++------------ src/postprocessors/FoamSidePostprocessor.C | 9 ++-- src/problems/FoamProblem.C | 21 +++++++- 8 files changed, 110 insertions(+), 51 deletions(-) create mode 100644 include/postprocessors/FoamPostprocessorBase.h create mode 100644 src/postprocessors/FoamPostprocessorBase.C diff --git a/include/postprocessors/FoamPostprocessorBase.h b/include/postprocessors/FoamPostprocessorBase.h new file mode 100644 index 00000000..b668d1ce --- /dev/null +++ b/include/postprocessors/FoamPostprocessorBase.h @@ -0,0 +1,23 @@ +#pragma once + +#include "InputParameters.h" +#include "Postprocessor.h" +#include "ElementUserObject.h" + +class FoamPostprocessorBase : public ElementUserObject, public Postprocessor +{ +public: + static InputParameters validParams(); + + FoamPostprocessorBase(const InputParameters & params); + + virtual void initialize() final; + + virtual void execute() final; + + virtual void finalize() final; + + virtual void threadJoin(const UserObject & uo) final; + + virtual void compute() = 0; +}; diff --git a/include/postprocessors/FoamSideAverageValue.h b/include/postprocessors/FoamSideAverageValue.h index 447d219a..41b35160 100644 --- a/include/postprocessors/FoamSideAverageValue.h +++ b/include/postprocessors/FoamSideAverageValue.h @@ -8,16 +8,10 @@ class FoamSideAverageValue : public FoamSidePostprocessor FoamSideAverageValue(const InputParameters & params); - virtual void execute() override; - - virtual void initialize() override; - - virtual void finalize() override; - - virtual void threadJoin(const UserObject & uo) override; - virtual PostprocessorValue getValue() const override; + virtual void compute() override; + protected: Real _value; diff --git a/include/postprocessors/FoamSidePostprocessor.h b/include/postprocessors/FoamSidePostprocessor.h index 87e56541..aae64c7e 100644 --- a/include/postprocessors/FoamSidePostprocessor.h +++ b/include/postprocessors/FoamSidePostprocessor.h @@ -1,10 +1,9 @@ #pragma once -#include "ElementUserObject.h" -#include "InputParameters.h" +#include "FoamPostprocessorBase.h" // When FoamMesh is updated use BoundaryRestrictable when Foammesh is refactored -class FoamSidePostprocessor : public ElementUserObject, public Postprocessor +class FoamSidePostprocessor : public FoamPostprocessorBase { public: static InputParameters validParams(); diff --git a/include/problems/FoamProblem.h b/include/problems/FoamProblem.h index 1d3d4736..edb2e778 100644 --- a/include/problems/FoamProblem.h +++ b/include/problems/FoamProblem.h @@ -1,6 +1,7 @@ #pragma once #include "FoamMesh.h" +#include "FoamPostprocessorBase.h" #include "FoamSolver.h" #include "FoamVariableField.h" #include "FoamBCBase.h" @@ -47,4 +48,5 @@ class FoamProblem : public ExternalProblem std::vector _foam_variables; std::vector _foam_bcs; + std::vector _foam_postprocessor; }; diff --git a/src/postprocessors/FoamPostprocessorBase.C b/src/postprocessors/FoamPostprocessorBase.C new file mode 100644 index 00000000..a0f10f11 --- /dev/null +++ b/src/postprocessors/FoamPostprocessorBase.C @@ -0,0 +1,39 @@ +#include "FoamPostprocessorBase.h" +#include "InputParameters.h" +#include "Postprocessor.h" +#include "ElementUserObject.h" + +InputParameters +FoamPostprocessorBase::validParams() +{ + + auto params = ElementUserObject::validParams(); + params += Postprocessor::validParams(); + return params; +} + +FoamPostprocessorBase::FoamPostprocessorBase(const InputParameters & params) + : ElementUserObject(params), Postprocessor(this) +{ +} + +void +FoamPostprocessorBase::initialize() +{ +} + +void +FoamPostprocessorBase::execute() +{ +} + +void +FoamPostprocessorBase::finalize() +{ +} + +void +FoamPostprocessorBase::threadJoin(const UserObject & uo) +{ + (void)uo; +} diff --git a/src/postprocessors/FoamSideAverageValue.C b/src/postprocessors/FoamSideAverageValue.C index 1a9d6c6a..c908b9a2 100644 --- a/src/postprocessors/FoamSideAverageValue.C +++ b/src/postprocessors/FoamSideAverageValue.C @@ -1,9 +1,8 @@ +#include "ElementUserObject.h" #include "FoamSideAverageValue.h" #include "InputParameters.h" #include "MooseTypes.h" -#include "UserObject.h" #include "FoamMesh.h" -#include registerMooseObject("hippoApp", FoamSideAverageValue); @@ -24,46 +23,31 @@ FoamSideAverageValue::FoamSideAverageValue(const InputParameters & params) } void -FoamSideAverageValue::initialize() +FoamSideAverageValue::compute() { + auto foam_mesh = dynamic_cast(&getSubProblem().mesh()); _value = 0.; _volume = 0.; -} - -void -FoamSideAverageValue::execute() -{ - auto foam_mesh = dynamic_cast(&_mesh); - int64_t patch_offset = 0; - for (auto & subdomain : foam_mesh->meshSubdomains()) - if (subdomain < _current_elem->subdomain_id()) - patch_offset += foam_mesh->getPatchCount(subdomain); + for (auto & block : ElementUserObject::blocks()) + { - auto boundary = foam_mesh->getSubdomainName(_current_elem->subdomain_id()); - auto idx = static_cast(_current_elem->id()) - - static_cast(foam_mesh->rank_element_offset) - patch_offset; + auto & var_array = + foam_mesh->fvMesh().boundary()[block].lookupPatchField( + _foam_scalar); + auto & areas = foam_mesh->fvMesh().boundary()[block].magSf(); - auto & var_array = - foam_mesh->fvMesh().boundary()[boundary].lookupPatchField( - _foam_scalar); - auto & areas = foam_mesh->fvMesh().boundary()[boundary].magSf(); + for (int i = 0; i < var_array.size(); ++i) + { + _value += var_array[i] * areas[i]; + _volume += areas[i]; + } + } - _value += var_array[idx] * areas[idx]; - _volume += areas[idx]; -} - -void -FoamSideAverageValue::threadJoin(const UserObject & uo) -{ - (void)uo; -} - -void -FoamSideAverageValue::finalize() -{ - gatherSum(_volume); gatherSum(_value); + gatherSum(_volume); _value /= _volume; + + std::cout << _value << std::endl; } PostprocessorValue diff --git a/src/postprocessors/FoamSidePostprocessor.C b/src/postprocessors/FoamSidePostprocessor.C index ab512d97..f4610925 100644 --- a/src/postprocessors/FoamSidePostprocessor.C +++ b/src/postprocessors/FoamSidePostprocessor.C @@ -1,21 +1,20 @@ -#include "ElementUserObject.h" +#include "BlockRestrictable.h" #include "FoamSidePostprocessor.h" #include "InputParameters.h" #include "MooseTypes.h" #include "FoamProblem.h" -#include "Postprocessor.h" InputParameters FoamSidePostprocessor::validParams() { - auto params = ElementUserObject::validParams(); - params += Postprocessor::validParams(); + auto params = FoamPostprocessorBase::validParams(); + params += BlockRestrictable::validParams(); return params; } FoamSidePostprocessor::FoamSidePostprocessor(const InputParameters & params) - : ElementUserObject(params), Postprocessor(this), _volume(0.) + : FoamPostprocessorBase(params), _volume(0.) { FoamProblem * problem = dynamic_cast(&getSubProblem()); if (!problem) diff --git a/src/problems/FoamProblem.C b/src/problems/FoamProblem.C index 8679a555..159d5f93 100644 --- a/src/problems/FoamProblem.C +++ b/src/problems/FoamProblem.C @@ -1,3 +1,4 @@ +#include "Attributes.h" #include "ExternalProblem.h" #include "FoamMesh.h" #include "FoamProblem.h" @@ -57,7 +58,8 @@ FoamProblem::FoamProblem(InputParameters const & params) _foam_mesh->fvMesh()) .ptr()), _foam_variables(), - _foam_bcs() + _foam_bcs(), + _foam_postprocessor() { assert(_foam_mesh); } @@ -78,6 +80,19 @@ FoamProblem::initialSetup() query_bcs.queryInto(_foam_bcs); verifyFoamBCs(); + + std::vector uos; + TheWarehouse::Query query_uos = + theWarehouse().query().condition(Interfaces::Postprocessor); + query_uos.queryInto(uos); + + for (auto uo : uos) + { + auto fpp = dynamic_cast(uo); + if (fpp) + _foam_postprocessor.push_back(fpp); + } + std::cout << _foam_postprocessor.size() << std::endl; } void @@ -103,6 +118,10 @@ FoamProblem::syncSolutions(Direction dir) { var->transferVariable(); } + for (auto & fpp : _foam_postprocessor) + { + fpp->compute(); + } } else if (dir == ExternalProblem::Direction::TO_EXTERNAL_APP) { From ab557d8ca5703f32af5e7d0a1e9b9ffc8c903fc4 Mon Sep 17 00:00:00 2001 From: Matthew Falcone Date: Fri, 10 Oct 2025 09:57:58 +0100 Subject: [PATCH 13/43] Add table for Foam Postprocessors --- include/problems/FoamProblem.h | 3 +++ src/problems/FoamProblem.C | 40 ++++++++++++++++++++++++---------- 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/include/problems/FoamProblem.h b/include/problems/FoamProblem.h index edb2e778..dae211f0 100644 --- a/include/problems/FoamProblem.h +++ b/include/problems/FoamProblem.h @@ -43,6 +43,9 @@ class FoamProblem : public ExternalProblem // check FoamBCs and print summarising table void verifyFoamBCs(); + // check FoamPostprocessors and print summarising table + void verifyFoamPostprocessors(); + FoamMesh * _foam_mesh = nullptr; Hippo::FoamSolver _solver; diff --git a/src/problems/FoamProblem.C b/src/problems/FoamProblem.C index 159d5f93..d1c470f9 100644 --- a/src/problems/FoamProblem.C +++ b/src/problems/FoamProblem.C @@ -81,18 +81,7 @@ FoamProblem::initialSetup() verifyFoamBCs(); - std::vector uos; - TheWarehouse::Query query_uos = - theWarehouse().query().condition(Interfaces::Postprocessor); - query_uos.queryInto(uos); - - for (auto uo : uos) - { - auto fpp = dynamic_cast(uo); - if (fpp) - _foam_postprocessor.push_back(fpp); - } - std::cout << _foam_postprocessor.size() << std::endl; + verifyFoamPostprocessors(); } void @@ -213,3 +202,30 @@ FoamProblem::verifyFoamBCs() } vt.print(_console); } + +void +FoamProblem::verifyFoamPostprocessors() +{ + std::vector pps; + TheWarehouse::Query query_uos = + theWarehouse().query().condition(Interfaces::Postprocessor); + query_uos.queryInto(pps); + + VariadicTable vt({ + "Foam postprocessor", + "Type", + "Boundaries", + }); + + for (auto pp : pps) + { + auto fpp = dynamic_cast(pp); + if (fpp) + { + _foam_postprocessor.push_back(fpp); + vt.addRow(fpp->name(), fpp->type(), listFromVector(fpp->blocks())); + } + } + + vt.print(_console); +} From 38235991f4ca0b312aca5a81f3df43cf3f12a06f Mon Sep 17 00:00:00 2001 From: Matthew Falcone Date: Fri, 10 Oct 2025 10:06:56 +0100 Subject: [PATCH 14/43] Add additional error checks to exisiting Foam Postprocessors --- include/postprocessors/FoamPostprocessorBase.h | 4 ++++ src/postprocessors/FoamPostprocessorBase.C | 9 ++++++++- src/postprocessors/FoamSideAverageValue.C | 10 +++++----- src/postprocessors/FoamSidePostprocessor.C | 4 ---- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/include/postprocessors/FoamPostprocessorBase.h b/include/postprocessors/FoamPostprocessorBase.h index b668d1ce..9d6230ac 100644 --- a/include/postprocessors/FoamPostprocessorBase.h +++ b/include/postprocessors/FoamPostprocessorBase.h @@ -3,6 +3,7 @@ #include "InputParameters.h" #include "Postprocessor.h" #include "ElementUserObject.h" +#include "fvMesh.H" class FoamPostprocessorBase : public ElementUserObject, public Postprocessor { @@ -20,4 +21,7 @@ class FoamPostprocessorBase : public ElementUserObject, public Postprocessor virtual void threadJoin(const UserObject & uo) final; virtual void compute() = 0; + +protected: + Foam::fvMesh * _foam_mesh; }; diff --git a/src/postprocessors/FoamPostprocessorBase.C b/src/postprocessors/FoamPostprocessorBase.C index a0f10f11..59baf5f7 100644 --- a/src/postprocessors/FoamPostprocessorBase.C +++ b/src/postprocessors/FoamPostprocessorBase.C @@ -1,7 +1,9 @@ +#include "FoamMesh.h" #include "FoamPostprocessorBase.h" #include "InputParameters.h" #include "Postprocessor.h" #include "ElementUserObject.h" +#include "FoamProblem.h" InputParameters FoamPostprocessorBase::validParams() @@ -13,8 +15,13 @@ FoamPostprocessorBase::validParams() } FoamPostprocessorBase::FoamPostprocessorBase(const InputParameters & params) - : ElementUserObject(params), Postprocessor(this) + : ElementUserObject(params), Postprocessor(this), _foam_mesh(nullptr) { + FoamProblem * problem = dynamic_cast(&getSubProblem()); + if (!problem) + mooseError("Foam-based Postprocessors can only be used with FoamProblem"); + + _foam_mesh = &problem->mesh().fvMesh(); } void diff --git a/src/postprocessors/FoamSideAverageValue.C b/src/postprocessors/FoamSideAverageValue.C index c908b9a2..d7bf880a 100644 --- a/src/postprocessors/FoamSideAverageValue.C +++ b/src/postprocessors/FoamSideAverageValue.C @@ -3,6 +3,7 @@ #include "InputParameters.h" #include "MooseTypes.h" #include "FoamMesh.h" +#include "volFieldsFwd.H" registerMooseObject("hippoApp", FoamSideAverageValue); @@ -20,6 +21,8 @@ FoamSideAverageValue::validParams() FoamSideAverageValue::FoamSideAverageValue(const InputParameters & params) : FoamSidePostprocessor(params), _value(0.), _foam_scalar(params.get("foam_scalar")) { + if (!_foam_mesh->foundObject(_foam_scalar)) + mooseError("Foam scalar '", _foam_scalar, "' not found."); } void @@ -32,9 +35,8 @@ FoamSideAverageValue::compute() { auto & var_array = - foam_mesh->fvMesh().boundary()[block].lookupPatchField( - _foam_scalar); - auto & areas = foam_mesh->fvMesh().boundary()[block].magSf(); + _foam_mesh->boundary()[block].lookupPatchField(_foam_scalar); + auto & areas = _foam_mesh->boundary()[block].magSf(); for (int i = 0; i < var_array.size(); ++i) { @@ -46,8 +48,6 @@ FoamSideAverageValue::compute() gatherSum(_value); gatherSum(_volume); _value /= _volume; - - std::cout << _value << std::endl; } PostprocessorValue diff --git a/src/postprocessors/FoamSidePostprocessor.C b/src/postprocessors/FoamSidePostprocessor.C index f4610925..ca988a34 100644 --- a/src/postprocessors/FoamSidePostprocessor.C +++ b/src/postprocessors/FoamSidePostprocessor.C @@ -2,7 +2,6 @@ #include "FoamSidePostprocessor.h" #include "InputParameters.h" #include "MooseTypes.h" -#include "FoamProblem.h" InputParameters FoamSidePostprocessor::validParams() @@ -16,7 +15,4 @@ FoamSidePostprocessor::validParams() FoamSidePostprocessor::FoamSidePostprocessor(const InputParameters & params) : FoamPostprocessorBase(params), _volume(0.) { - FoamProblem * problem = dynamic_cast(&getSubProblem()); - if (!problem) - mooseError("FoamPostprocessors can only be used with FoamProblem"); } From af701b78850fc16a37435decbca1a2ec63200f40 Mon Sep 17 00:00:00 2001 From: Matthew Falcone Date: Fri, 10 Oct 2025 10:07:54 +0100 Subject: [PATCH 15/43] Update Postprocessor test solver to be based on fluid solver --- .../postprocessorTestSolver/Make/options | 25 ++++---- .../postprocessorTestSolver.C | 59 +++---------------- .../postprocessorTestSolver.H | 39 +----------- 3 files changed, 25 insertions(+), 98 deletions(-) diff --git a/test/OpenFOAM/modules/postprocessorTestSolver/Make/options b/test/OpenFOAM/modules/postprocessorTestSolver/Make/options index cc845ca8..3d0e96db 100644 --- a/test/OpenFOAM/modules/postprocessorTestSolver/Make/options +++ b/test/OpenFOAM/modules/postprocessorTestSolver/Make/options @@ -1,20 +1,23 @@ EXE_INC = \ + -I$(FOAM_MODULES)/fluid/lnInclude \ + -I$(FOAM_MODULES)/fluidSolver/lnInclude \ + -I$(FOAM_MODULES)/isothermalFluid/lnInclude \ -I$(LIB_SRC)/physicalProperties/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ - -I$(LIB_SRC)/thermophysicalModels/solidThermo/lnInclude \ + -I$(LIB_SRC)/MomentumTransportModels/momentumTransportModels/lnInclude \ + -I$(LIB_SRC)/MomentumTransportModels/compressible/lnInclude \ -I$(LIB_SRC)/ThermophysicalTransportModels/thermophysicalTransportModel/lnInclude \ - -I$(LIB_SRC)/ThermophysicalTransportModels/solid/lnInclude \ + -I$(LIB_SRC)/ThermophysicalTransportModels/fluid/lnInclude \ + -I$(LIB_SRC)/ThermophysicalTransportModels/fluidThermo/lnInclude \ + -I$(LIB_SRC)/finiteVolume/cfdTools \ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/sampling/lnInclude LIB_LIBS = \ - -lsolidThermo \ - -lsolidThermophysicalTransportModels \ - -lcoupledThermophysicalTransportModels \ - -lspecie \ - -lfiniteVolume \ - -lmeshTools \ - -lsampling \ - -lfvModels \ - -lfvConstraints + -lfluid \ + -lfluidSolver \ + -lisothermalFluid \ + -lfluidThermophysicalModels \ + -lcompressibleMomentumTransportModels \ + -lcoupledThermophysicalTransportModels diff --git a/test/OpenFOAM/modules/postprocessorTestSolver/postprocessorTestSolver.C b/test/OpenFOAM/modules/postprocessorTestSolver/postprocessorTestSolver.C index 75c6de42..5d8dfbb6 100644 --- a/test/OpenFOAM/modules/postprocessorTestSolver/postprocessorTestSolver.C +++ b/test/OpenFOAM/modules/postprocessorTestSolver/postprocessorTestSolver.C @@ -24,6 +24,8 @@ License \*---------------------------------------------------------------------------*/ #include "dimensionSets.H" +#include "dimensionedScalar.H" +#include "dimensionedVector.H" #include "fvMesh.H" #include "postprocessorTestSolver.H" #include "fvMeshMover.H" @@ -44,48 +46,9 @@ addToRunTimeSelectionTable(solver, postprocessorTestSolver, fvMesh); // * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * // -bool -Foam::solvers::postprocessorTestSolver::dependenciesModified() const -{ - return runTime.controlDict().modified(); -} - -bool -Foam::solvers::postprocessorTestSolver::read() -{ - solver::read(); - - maxDeltaT_ = runTime.controlDict().found("maxDeltaT") - ? runTime.controlDict().lookup("maxDeltaT", runTime.userUnits()) - : vGreat; - - return true; -} - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // Solver based on solid.C module -Foam::solvers::postprocessorTestSolver::postprocessorTestSolver(fvMesh & mesh, - autoPtr thermoPtr) - : solver(mesh), - - thermoPtr_(thermoPtr), - thermo_(thermoPtr_()), - - T_(IOobject("T", mesh.time().name(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE), mesh), - - thermophysicalTransport(solidThermophysicalTransportModel::New(thermo_)), - thermo(thermo_), - T(T_) -{ - thermo.validate("solid", "h", "e"); -} - -Foam::solvers::postprocessorTestSolver::postprocessorTestSolver(fvMesh & mesh) - : postprocessorTestSolver(mesh, solidThermo::New(mesh)) -{ - // Read the controls - read(); -} +Foam::solvers::postprocessorTestSolver::postprocessorTestSolver(fvMesh & mesh) : fluid(mesh) {} // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // @@ -93,12 +56,6 @@ Foam::solvers::postprocessorTestSolver::~postprocessorTestSolver() {} // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // -Foam::scalar -Foam::solvers::postprocessorTestSolver::maxDeltaT() const -{ - return min(fvModels().maxDeltaT(), maxDeltaT_); -} - void Foam::solvers::postprocessorTestSolver::preSolve() { @@ -145,13 +102,15 @@ Foam::solvers::postprocessorTestSolver::thermophysicalPredictor() // thermo_.correct() call calculates Temperature. // Get e and Cv - volScalarField & e = thermo_.he(); - const volScalarField & Cv = thermo_.Cv(); + volScalarField & h = thermo_.he(); + const volScalarField & Cp = thermo_.Cp(); // Set e to Cv*(xy + yz + xz)t which gives a non-uniform be first order value of wall heat flux at // all boundaries. - dimensioned t("t", T.dimensions(), mesh_.time().userTimeValue()); - e = Cv * t; + dimensioned t("t", thermo_.T().dimensions(), mesh_.time().userTimeValue()); + h = Cp * t; + + U_ = dimensionedVector(dimVelocity, {1., 1., 1.}); thermo_.correct(); } diff --git a/test/OpenFOAM/modules/postprocessorTestSolver/postprocessorTestSolver.H b/test/OpenFOAM/modules/postprocessorTestSolver/postprocessorTestSolver.H index 936deacd..a733d2f7 100644 --- a/test/OpenFOAM/modules/postprocessorTestSolver/postprocessorTestSolver.H +++ b/test/OpenFOAM/modules/postprocessorTestSolver/postprocessorTestSolver.H @@ -35,8 +35,7 @@ SourceFiles #pragma once -#include "solver.H" -#include "solidThermophysicalTransportModel.H" +#include "fluid.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -49,46 +48,15 @@ namespace solvers Class postprocessorTestSolver Declaration \*---------------------------------------------------------------------------*/ -class postprocessorTestSolver : public solver +class postprocessorTestSolver : public fluid { -protected: - // Control parameters - scalar maxDeltaT_; - - // Thermophysical properties - autoPtr thermoPtr_; - - solidThermo & thermo_; - - volScalarField T_; - - autoPtr thermophysicalTransport; - - // Protected Member Functions - - //- Return true if the solver's dependencies have been modified - virtual bool dependenciesModified() const; - - //- Read controls - virtual bool read(); - public: - // Public Data - // reference to thermophysical properties - const solidThermo & thermo; - - //- Reference to the temperature field - const volScalarField & T; - //- Runtime type information TypeName("postprocessorTestSolver"); // Constructors - //- Construct from region mesh - postprocessorTestSolver(fvMesh & mesh, autoPtr thermoPtr); - postprocessorTestSolver(fvMesh & mesh); //- Disallow default bitwise copy construction @@ -99,9 +67,6 @@ public: // Member Functions - //- Return the current maximum time-step for stable solution - virtual scalar maxDeltaT() const; - //- Called at the start of the time-step, before the PIMPLE loop virtual void preSolve(); From 8f8792d1d9b2131498b8d4679826f493e9cea6a7 Mon Sep 17 00:00:00 2001 From: Matthew Falcone Date: Fri, 10 Oct 2025 10:08:23 +0100 Subject: [PATCH 16/43] Update side average test to use fluid-based solver --- .../postprocessors/side_average/foam/0/U | 31 ++++++++++ .../postprocessors/side_average/foam/0/p | 30 ++++++++++ .../postprocessors/side_average/foam/0/p_rgh | 30 ++++++++++ .../postprocessors/side_average/foam/0/rho | 56 +++++++++++++++++++ .../side_average/foam/constant/g | 21 +++++++ .../foam/constant/momentumTransport | 18 ++++++ .../foam/constant/physicalProperties | 11 ++-- test/tests/postprocessors/side_average/tests | 8 +++ 8 files changed, 200 insertions(+), 5 deletions(-) create mode 100644 test/tests/postprocessors/side_average/foam/0/U create mode 100644 test/tests/postprocessors/side_average/foam/0/p create mode 100644 test/tests/postprocessors/side_average/foam/0/p_rgh create mode 100644 test/tests/postprocessors/side_average/foam/0/rho create mode 100644 test/tests/postprocessors/side_average/foam/constant/g create mode 100644 test/tests/postprocessors/side_average/foam/constant/momentumTransport diff --git a/test/tests/postprocessors/side_average/foam/0/U b/test/tests/postprocessors/side_average/foam/0/U new file mode 100644 index 00000000..8b272ee4 --- /dev/null +++ b/test/tests/postprocessors/side_average/foam/0/U @@ -0,0 +1,31 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 12 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volVectorField; + location "0"; + object U; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [ 0 1 -1 0 0 0 0 ]; + +internalField uniform (0 0 0); + +boundaryField +{ + + ".*" + { + type fixedValue; + value $internalField; + } +} + +// ************************************************************************* // diff --git a/test/tests/postprocessors/side_average/foam/0/p b/test/tests/postprocessors/side_average/foam/0/p new file mode 100644 index 00000000..0d00fc2f --- /dev/null +++ b/test/tests/postprocessors/side_average/foam/0/p @@ -0,0 +1,30 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 12 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volScalarField; + location "0"; + object p; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [ 1 -1 -2 0 0 0 0 ]; + +internalField uniform 0; + +boundaryField +{ + ".*" + { + type calculated; + value $internalField; + } +} + +// ************************************************************************* // diff --git a/test/tests/postprocessors/side_average/foam/0/p_rgh b/test/tests/postprocessors/side_average/foam/0/p_rgh new file mode 100644 index 00000000..cfc89a8c --- /dev/null +++ b/test/tests/postprocessors/side_average/foam/0/p_rgh @@ -0,0 +1,30 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 12 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volScalarField; + location "0"; + object p_rgh; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [ 1 -1 -2 0 0 0 0 ]; + +internalField uniform 0; + +boundaryField +{ + ".*" + { + type fixedValue; + value $internalField; + } +} + +// ************************************************************************* // diff --git a/test/tests/postprocessors/side_average/foam/0/rho b/test/tests/postprocessors/side_average/foam/0/rho new file mode 100644 index 00000000..d30a04dc --- /dev/null +++ b/test/tests/postprocessors/side_average/foam/0/rho @@ -0,0 +1,56 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 12 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volScalarField; + location "0"; + object rho; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [1 -3 0 0 0 0 0]; + +internalField uniform 1; + +boundaryField +{ + left + { + type calculated; + value uniform 1; + } + right + { + type calculated; + value uniform 1; + } + top + { + type calculated; + value uniform 1; + } + front + { + type calculated; + value uniform 1; + } + bottom + { + type calculated; + value uniform 1; + } + back + { + type calculated; + value uniform 1; + } +} + + +// ************************************************************************* // diff --git a/test/tests/postprocessors/side_average/foam/constant/g b/test/tests/postprocessors/side_average/foam/constant/g new file mode 100644 index 00000000..8af96f3a --- /dev/null +++ b/test/tests/postprocessors/side_average/foam/constant/g @@ -0,0 +1,21 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 10 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class uniformDimensionedVectorField; + location "constant"; + object g; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 1 -2 0 0 0 0]; +value (0 0 0); + + +// ************************************************************************* // diff --git a/test/tests/postprocessors/side_average/foam/constant/momentumTransport b/test/tests/postprocessors/side_average/foam/constant/momentumTransport new file mode 100644 index 00000000..0416f1a9 --- /dev/null +++ b/test/tests/postprocessors/side_average/foam/constant/momentumTransport @@ -0,0 +1,18 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 10 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + object RASProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +simulationType laminar; + +// ************************************************************************* // diff --git a/test/tests/postprocessors/side_average/foam/constant/physicalProperties b/test/tests/postprocessors/side_average/foam/constant/physicalProperties index 96a14c15..20dafc61 100644 --- a/test/tests/postprocessors/side_average/foam/constant/physicalProperties +++ b/test/tests/postprocessors/side_average/foam/constant/physicalProperties @@ -16,13 +16,13 @@ FoamFile thermoType { - type heSolidThermo; + type heRhoThermo; mixture pureMixture; - transport constIsoSolid; - thermo eConst; + transport const; + thermo hConst; equationOfState rhoConst; specie specie; - energy sensibleInternalEnergy; + energy sensibleEnthalpy; } mixture @@ -33,13 +33,14 @@ mixture } thermodynamics { - Cv 1; // Specific heat capacity [J/(kg·K)] + Cp 1; // Specific heat capacity [J/(kg·K)] Hf 1; // Heat of formation [J/kg] Tref 0; } transport { kappa 1; // Thermal conductivity [W/(m·K)] + mu 1.; } equationOfState { diff --git a/test/tests/postprocessors/side_average/tests b/test/tests/postprocessors/side_average/tests index bf8413ba..f06a67c1 100644 --- a/test/tests/postprocessors/side_average/tests +++ b/test/tests/postprocessors/side_average/tests @@ -19,5 +19,13 @@ cli_args='Postprocessors/test/block=top1' expect_err = "do not exist on the mesh: top1" [] + [invalid_foam_scalar] + type = RunException + input = main.i + prereq = postprocessor_test/setup + allow_warnings = true + cli_args='Postprocessors/test/foam_scalar=T1' + expect_err = "Foam scalar 'T1' not found." + [] [] [] From 18dc1b36688444874392418211b551647ce968c9 Mon Sep 17 00:00:00 2001 From: Matthew Falcone Date: Fri, 10 Oct 2025 10:09:05 +0100 Subject: [PATCH 17/43] Add advective flux postprocessor for calculating mass flux --- .../FoamSideAdvectiveFluxIntegral.h | 20 ++++++ .../FoamSideAdvectiveFluxIntegral.C | 62 +++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 include/postprocessors/FoamSideAdvectiveFluxIntegral.h create mode 100644 src/postprocessors/FoamSideAdvectiveFluxIntegral.C diff --git a/include/postprocessors/FoamSideAdvectiveFluxIntegral.h b/include/postprocessors/FoamSideAdvectiveFluxIntegral.h new file mode 100644 index 00000000..1fce7755 --- /dev/null +++ b/include/postprocessors/FoamSideAdvectiveFluxIntegral.h @@ -0,0 +1,20 @@ +#pragma once +#include "FoamSidePostprocessor.h" + +class FoamSideAdvectiveFluxIntegral : public FoamSidePostprocessor +{ +public: + static InputParameters validParams(); + + FoamSideAdvectiveFluxIntegral(const InputParameters & params); + + virtual PostprocessorValue getValue() const override; + + virtual void compute() override; + +protected: + Real _value; + + std::string _foam_scalar; + std::string _advection_velocity; +}; diff --git a/src/postprocessors/FoamSideAdvectiveFluxIntegral.C b/src/postprocessors/FoamSideAdvectiveFluxIntegral.C new file mode 100644 index 00000000..9fe46a94 --- /dev/null +++ b/src/postprocessors/FoamSideAdvectiveFluxIntegral.C @@ -0,0 +1,62 @@ +#include "ElementUserObject.h" +#include "FoamSideAdvectiveFluxIntegral.h" +#include "InputParameters.h" +#include "MooseTypes.h" +#include "FoamMesh.h" + +registerMooseObject("hippoApp", FoamSideAdvectiveFluxIntegral); + +InputParameters +FoamSideAdvectiveFluxIntegral::validParams() +{ + auto params = FoamSidePostprocessor::validParams(); + params.addClassDescription( + "Class that calculates the average or scalar on a OpenFOAM boundary patch."); + params.addRequiredParam("foam_scalar", "Foam scalar being advected."); + params.addParam("advective_velocity", "U", "Advection velocity"); + return params; +} + +FoamSideAdvectiveFluxIntegral::FoamSideAdvectiveFluxIntegral(const InputParameters & params) + : FoamSidePostprocessor(params), + _value(0.), + _foam_scalar(params.get("foam_scalar")), + _advection_velocity(params.get("advective_velocity")) +{ + + if (!_foam_mesh->foundObject(_foam_scalar)) + mooseError("foam_scalar '", _foam_scalar, "' not found."); + + if (!_foam_mesh->foundObject(_advection_velocity)) + mooseError("advective_velocity '", _advection_velocity, "' not found."); +} + +void +FoamSideAdvectiveFluxIntegral::compute() +{ + _value = 0.; + for (auto & block : ElementUserObject::blocks()) + { + auto & var_array = + _foam_mesh->boundary()[block].lookupPatchField(_foam_scalar); + + auto & vel_array = _foam_mesh->boundary()[block].lookupPatchField( + _advection_velocity); + + auto & areas = _foam_mesh->boundary()[block].magSf(); + auto && normals = _foam_mesh->boundary()[block].nf(); + + for (int i = 0; i < var_array.size(); ++i) + { + _value += var_array[i] * areas[i] * (normals->data()[i] & vel_array[i]); + } + } + + gatherSum(_value); +} + +PostprocessorValue +FoamSideAdvectiveFluxIntegral::getValue() const +{ + return _value; +} From 02f1b4ec4117a266a39bee3e94bbe0cdc7a8c458 Mon Sep 17 00:00:00 2001 From: Matthew Falcone Date: Fri, 10 Oct 2025 10:21:54 +0100 Subject: [PATCH 18/43] Add tests for FoamSideAdvectiveFluxIntegral --- .../postprocessorTestSolver.C | 2 - .../side_advective_flux_integral/foam/0/T | 56 ++++++++++++ .../side_advective_flux_integral/foam/0/U | 31 +++++++ .../side_advective_flux_integral/foam/0/p | 30 +++++++ .../side_advective_flux_integral/foam/0/p_rgh | 30 +++++++ .../side_advective_flux_integral/foam/0/rho | 56 ++++++++++++ .../foam/constant/g | 21 +++++ .../foam/constant/momentumTransport | 18 ++++ .../foam/constant/physicalProperties | 52 ++++++++++++ .../foam/system/blockMeshDict | 85 +++++++++++++++++++ .../foam/system/controlDict | 44 ++++++++++ .../foam/system/fvSchemes | 51 +++++++++++ .../foam/system/fvSolution | 61 +++++++++++++ .../gold/main_out.csv | 34 ++++++++ .../side_advective_flux_integral/main.i | 65 ++++++++++++++ .../side_advective_flux_integral/tests | 23 +++++ 16 files changed, 657 insertions(+), 2 deletions(-) create mode 100644 test/tests/postprocessors/side_advective_flux_integral/foam/0/T create mode 100644 test/tests/postprocessors/side_advective_flux_integral/foam/0/U create mode 100644 test/tests/postprocessors/side_advective_flux_integral/foam/0/p create mode 100644 test/tests/postprocessors/side_advective_flux_integral/foam/0/p_rgh create mode 100644 test/tests/postprocessors/side_advective_flux_integral/foam/0/rho create mode 100644 test/tests/postprocessors/side_advective_flux_integral/foam/constant/g create mode 100644 test/tests/postprocessors/side_advective_flux_integral/foam/constant/momentumTransport create mode 100644 test/tests/postprocessors/side_advective_flux_integral/foam/constant/physicalProperties create mode 100644 test/tests/postprocessors/side_advective_flux_integral/foam/system/blockMeshDict create mode 100644 test/tests/postprocessors/side_advective_flux_integral/foam/system/controlDict create mode 100644 test/tests/postprocessors/side_advective_flux_integral/foam/system/fvSchemes create mode 100644 test/tests/postprocessors/side_advective_flux_integral/foam/system/fvSolution create mode 100644 test/tests/postprocessors/side_advective_flux_integral/gold/main_out.csv create mode 100644 test/tests/postprocessors/side_advective_flux_integral/main.i create mode 100644 test/tests/postprocessors/side_advective_flux_integral/tests diff --git a/test/OpenFOAM/modules/postprocessorTestSolver/postprocessorTestSolver.C b/test/OpenFOAM/modules/postprocessorTestSolver/postprocessorTestSolver.C index 5d8dfbb6..be52f5be 100644 --- a/test/OpenFOAM/modules/postprocessorTestSolver/postprocessorTestSolver.C +++ b/test/OpenFOAM/modules/postprocessorTestSolver/postprocessorTestSolver.C @@ -110,8 +110,6 @@ Foam::solvers::postprocessorTestSolver::thermophysicalPredictor() dimensioned t("t", thermo_.T().dimensions(), mesh_.time().userTimeValue()); h = Cp * t; - U_ = dimensionedVector(dimVelocity, {1., 1., 1.}); - thermo_.correct(); } diff --git a/test/tests/postprocessors/side_advective_flux_integral/foam/0/T b/test/tests/postprocessors/side_advective_flux_integral/foam/0/T new file mode 100644 index 00000000..f8312bb2 --- /dev/null +++ b/test/tests/postprocessors/side_advective_flux_integral/foam/0/T @@ -0,0 +1,56 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 10 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volScalarField; + location "0"; + object T; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 1 0 0 0]; + +internalField uniform 0.1; + +boundaryField +{ + left + { + type calculated; + value uniform 0.; + } + right + { + type calculated; + value uniform 0.; + } + top + { + type calculated; + value uniform 0.; + } + bottom + { + type calculated; + value uniform 0.; + } + back + { + type calculated; + value uniform 0.; + } + front + { + type calculated; + value uniform 0.; + } +} + + +// ************************************************************************* // diff --git a/test/tests/postprocessors/side_advective_flux_integral/foam/0/U b/test/tests/postprocessors/side_advective_flux_integral/foam/0/U new file mode 100644 index 00000000..d23654bb --- /dev/null +++ b/test/tests/postprocessors/side_advective_flux_integral/foam/0/U @@ -0,0 +1,31 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 12 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volVectorField; + location "0"; + object U; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [ 0 1 -1 0 0 0 0 ]; + +internalField uniform (2 -1 0); + +boundaryField +{ + + ".*" + { + type fixedValue; + value $internalField; + } +} + +// ************************************************************************* // diff --git a/test/tests/postprocessors/side_advective_flux_integral/foam/0/p b/test/tests/postprocessors/side_advective_flux_integral/foam/0/p new file mode 100644 index 00000000..0d00fc2f --- /dev/null +++ b/test/tests/postprocessors/side_advective_flux_integral/foam/0/p @@ -0,0 +1,30 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 12 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volScalarField; + location "0"; + object p; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [ 1 -1 -2 0 0 0 0 ]; + +internalField uniform 0; + +boundaryField +{ + ".*" + { + type calculated; + value $internalField; + } +} + +// ************************************************************************* // diff --git a/test/tests/postprocessors/side_advective_flux_integral/foam/0/p_rgh b/test/tests/postprocessors/side_advective_flux_integral/foam/0/p_rgh new file mode 100644 index 00000000..cfc89a8c --- /dev/null +++ b/test/tests/postprocessors/side_advective_flux_integral/foam/0/p_rgh @@ -0,0 +1,30 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 12 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volScalarField; + location "0"; + object p_rgh; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [ 1 -1 -2 0 0 0 0 ]; + +internalField uniform 0; + +boundaryField +{ + ".*" + { + type fixedValue; + value $internalField; + } +} + +// ************************************************************************* // diff --git a/test/tests/postprocessors/side_advective_flux_integral/foam/0/rho b/test/tests/postprocessors/side_advective_flux_integral/foam/0/rho new file mode 100644 index 00000000..e6da2e67 --- /dev/null +++ b/test/tests/postprocessors/side_advective_flux_integral/foam/0/rho @@ -0,0 +1,56 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 12 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volScalarField; + location "0"; + object rho; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [1 -3 0 0 0 0 0]; + +internalField uniform 0.5; + +boundaryField +{ + left + { + type calculated; + value uniform 0.5; + } + right + { + type calculated; + value uniform 0.5; + } + top + { + type calculated; + value uniform 0.5; + } + front + { + type calculated; + value uniform 0.5; + } + bottom + { + type calculated; + value uniform 0.5; + } + back + { + type calculated; + value uniform 0.5; + } +} + + +// ************************************************************************* // diff --git a/test/tests/postprocessors/side_advective_flux_integral/foam/constant/g b/test/tests/postprocessors/side_advective_flux_integral/foam/constant/g new file mode 100644 index 00000000..8af96f3a --- /dev/null +++ b/test/tests/postprocessors/side_advective_flux_integral/foam/constant/g @@ -0,0 +1,21 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 10 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class uniformDimensionedVectorField; + location "constant"; + object g; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 1 -2 0 0 0 0]; +value (0 0 0); + + +// ************************************************************************* // diff --git a/test/tests/postprocessors/side_advective_flux_integral/foam/constant/momentumTransport b/test/tests/postprocessors/side_advective_flux_integral/foam/constant/momentumTransport new file mode 100644 index 00000000..0416f1a9 --- /dev/null +++ b/test/tests/postprocessors/side_advective_flux_integral/foam/constant/momentumTransport @@ -0,0 +1,18 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 10 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + object RASProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +simulationType laminar; + +// ************************************************************************* // diff --git a/test/tests/postprocessors/side_advective_flux_integral/foam/constant/physicalProperties b/test/tests/postprocessors/side_advective_flux_integral/foam/constant/physicalProperties new file mode 100644 index 00000000..20dafc61 --- /dev/null +++ b/test/tests/postprocessors/side_advective_flux_integral/foam/constant/physicalProperties @@ -0,0 +1,52 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 10 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + location "constant"; + object physicalProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +thermoType +{ + type heRhoThermo; + mixture pureMixture; + transport const; + thermo hConst; + equationOfState rhoConst; + specie specie; + energy sensibleEnthalpy; +} + +mixture +{ + specie + { + molWeight 1; + } + thermodynamics + { + Cp 1; // Specific heat capacity [J/(kg·K)] + Hf 1; // Heat of formation [J/kg] + Tref 0; + } + transport + { + kappa 1; // Thermal conductivity [W/(m·K)] + mu 1.; + } + equationOfState + { + rho 1; // Density [kg/m^3] + } +} + + +// ************************************************************************* // diff --git a/test/tests/postprocessors/side_advective_flux_integral/foam/system/blockMeshDict b/test/tests/postprocessors/side_advective_flux_integral/foam/system/blockMeshDict new file mode 100644 index 00000000..face9ea6 --- /dev/null +++ b/test/tests/postprocessors/side_advective_flux_integral/foam/system/blockMeshDict @@ -0,0 +1,85 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object blockMeshDict; +} + +vertices +( + ( 0.0 0.0 0.0 ) + ( 10.0 0.0 0.0 ) + ( 10.0 1.0 0.0 ) + ( 0.0 1.0 0.0 ) + + ( 0.0 0.0 1.0) + ( 10.0 0.0 1.0) + ( 10.0 1.0 1.0) + ( 0.0 1.0 1.0) +); + +blocks +( + hex (0 1 2 3 4 5 6 7) (50 1 1) simpleGrading (25 1 1) +); + +boundary +( + + // interface + left + { + type wall; + faces + ( + (4 7 3 0) + ); + } + + right + { + type wall; + faces + ( + (6 5 1 2) + ); + } + + top + { + type wall; + faces + ( + (2 3 7 6) + ); + } + + front + { + type wall; + faces + ( + (3 2 1 0) + ); + } + + bottom + { + type wall; + faces + ( + (0 1 5 4) + ); + } + + back + { + type wall; + faces + ( + (4 5 6 7) + ); + } + +); diff --git a/test/tests/postprocessors/side_advective_flux_integral/foam/system/controlDict b/test/tests/postprocessors/side_advective_flux_integral/foam/system/controlDict new file mode 100644 index 00000000..4e2baf59 --- /dev/null +++ b/test/tests/postprocessors/side_advective_flux_integral/foam/system/controlDict @@ -0,0 +1,44 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 10 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + object controlDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +solver postprocessorTestSolver; + +startFrom startTime; + +startTime 0; + +stopAt endTime; + +endTime 0.32; + +deltaT 0.01; + +writeControl timeStep; + +writeInterval 1; + +writeFormat ascii; + +writePrecision 20; + +writeCompression off; + +timeFormat general; + +timePrecision 20; + +runTimeModifiable true; + +// ************************************************************************* // diff --git a/test/tests/postprocessors/side_advective_flux_integral/foam/system/fvSchemes b/test/tests/postprocessors/side_advective_flux_integral/foam/system/fvSchemes new file mode 100644 index 00000000..787f3b83 --- /dev/null +++ b/test/tests/postprocessors/side_advective_flux_integral/foam/system/fvSchemes @@ -0,0 +1,51 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 12 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + object fvSchemes; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +ddtSchemes +{ + default Euler; +} + +gradSchemes +{ + default Gauss linear; +} + +divSchemes +{ + default none; + + div(phi,U) Gauss linear; + div(phi,K) Gauss linear; + div(phi,h) Gauss linear; + div(((rho*nuEff)*dev2(T(grad(U))))) Gauss linear; +} + +laplacianSchemes +{ + default Gauss linear corrected; +} + +interpolationSchemes +{ + default linear; +} + +snGradSchemes +{ + default corrected; +} + +// ************************************************************************* // diff --git a/test/tests/postprocessors/side_advective_flux_integral/foam/system/fvSolution b/test/tests/postprocessors/side_advective_flux_integral/foam/system/fvSolution new file mode 100644 index 00000000..61143b21 --- /dev/null +++ b/test/tests/postprocessors/side_advective_flux_integral/foam/system/fvSolution @@ -0,0 +1,61 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 12 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + object fvSolution; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +solvers +{ + rho + { + solver diagonal; + } + + rhoFinal + { + $rho; + } + + + "(U|h|p_rgh)" + { + solver PBiCGStab; + preconditioner DILU; + tolerance 1e-8; + relTol 1e-8; + } + + "(U|h|p_rgh)Final" + { + $U; + tolerance 1e-8; + relTol 1e-8; + } +} + +PIMPLE +{ + momentumPredictor yes; + pRefCell 0; + pRefValue 0; +} + +relaxationFactors +{ + equations + { + h 1; + U 1; + } +} + +// ************************************************************************* // diff --git a/test/tests/postprocessors/side_advective_flux_integral/gold/main_out.csv b/test/tests/postprocessors/side_advective_flux_integral/gold/main_out.csv new file mode 100644 index 00000000..f77363ec --- /dev/null +++ b/test/tests/postprocessors/side_advective_flux_integral/gold/main_out.csv @@ -0,0 +1,34 @@ +time,m_dot_x1,m_dot_x2,m_dot_y1,m_dot_y2,m_dot_z1,m_dot_z2 +0,0,0,0,0,0,0 +0.01,-1,1,5,-5,-3.6347636898442e-17,0 +0.02,-1,1,5,-5,-3.6347636898442e-17,0 +0.03,-1,1,5,-5,-3.6347636898442e-17,0 +0.04,-1,1,5,-5,-3.6347636898442e-17,0 +0.05,-1,1,5,-5,-3.6347636898442e-17,0 +0.06,-1,1,5,-5,-3.6347636898442e-17,0 +0.07,-1,1,5,-5,-3.6347636898442e-17,0 +0.08,-1,1,5,-5,-3.6347636898442e-17,0 +0.09,-1,1,5,-5,-3.6347636898442e-17,0 +0.1,-1,1,5,-5,-3.6347636898442e-17,0 +0.11,-1,1,5,-5,-3.6347636898442e-17,0 +0.12,-1,1,5,-5,-3.6347636898442e-17,0 +0.13,-1,1,5,-5,-3.6347636898442e-17,0 +0.14,-1,1,5,-5,-3.6347636898442e-17,0 +0.15,-1,1,5,-5,-3.6347636898442e-17,0 +0.16,-1,1,5,-5,-3.6347636898442e-17,0 +0.17,-1,1,5,-5,-3.6347636898442e-17,0 +0.18,-1,1,5,-5,-3.6347636898442e-17,0 +0.19,-1,1,5,-5,-3.6347636898442e-17,0 +0.2,-1,1,5,-5,-3.6347636898442e-17,0 +0.21,-1,1,5,-5,-3.6347636898442e-17,0 +0.22,-1,1,5,-5,-3.6347636898442e-17,0 +0.23,-1,1,5,-5,-3.6347636898442e-17,0 +0.24,-1,1,5,-5,-3.6347636898442e-17,0 +0.25,-1,1,5,-5,-3.6347636898442e-17,0 +0.26,-1,1,5,-5,-3.6347636898442e-17,0 +0.27,-1,1,5,-5,-3.6347636898442e-17,0 +0.28,-1,1,5,-5,-3.6347636898442e-17,0 +0.29,-1,1,5,-5,-3.6347636898442e-17,0 +0.3,-1,1,5,-5,-3.6347636898442e-17,0 +0.31,-1,1,5,-5,-3.6347636898442e-17,0 +0.32,-1,1,5,-5,-3.6347636898442e-17,0 diff --git a/test/tests/postprocessors/side_advective_flux_integral/main.i b/test/tests/postprocessors/side_advective_flux_integral/main.i new file mode 100644 index 00000000..dae55e5d --- /dev/null +++ b/test/tests/postprocessors/side_advective_flux_integral/main.i @@ -0,0 +1,65 @@ +[Mesh] + type = FoamMesh + case = 'foam' + foam_patch = 'left right bottom top back front' +[] + +[Variables] + [dummy] + family = MONOMIAL + order = CONSTANT + initial_condition = 999 + [] +[] + +[Problem] + type = FoamProblem +[] + +[Executioner] + type = Transient + end_time = 0.32 + [TimeSteppers] + [foam] + type = FoamControlledTimeStepper + [] + [] +[] + +[Postprocessors] + [m_dot_x1] + type = FoamSideAdvectiveFluxIntegral + foam_scalar = 'rho' + block = left + [] + [m_dot_x2] + type = FoamSideAdvectiveFluxIntegral + foam_scalar = 'rho' + block = right + [] + [m_dot_y1] + type = FoamSideAdvectiveFluxIntegral + foam_scalar = 'rho' + block = bottom + [] + [m_dot_y2] + type = FoamSideAdvectiveFluxIntegral + foam_scalar = 'rho' + block = top + [] + [m_dot_z1] + type = FoamSideAdvectiveFluxIntegral + foam_scalar = 'rho' + block = back + [] + [m_dot_z2] + type = FoamSideAdvectiveFluxIntegral + foam_scalar = 'rho' + block = front + [] +[] + +[Outputs] + exodus = false + csv = true +[] diff --git a/test/tests/postprocessors/side_advective_flux_integral/tests b/test/tests/postprocessors/side_advective_flux_integral/tests new file mode 100644 index 00000000..49aa40cb --- /dev/null +++ b/test/tests/postprocessors/side_advective_flux_integral/tests @@ -0,0 +1,23 @@ +[Tests] + [postprocessor_test] + [setup] + type = RunCommand + command = 'bash -c "foamCleanCase -case foam && blockMesh -case foam"' + [] + [check_csv] + type = CSVDiff + input = main.i + prereq = postprocessor_test/setup + csvdiff = main_out.csv + allow_warnings = true + [] + [invalid_advective_velocity] + type = RunException + input = main.i + prereq = postprocessor_test/setup + allow_warnings = true + cli_args='Postprocessors/m_dot_x1/advective_velocity=U1' + expect_err = "advective_velocity 'U1' not found." + [] + [] +[] From aa6af7fccec1106bb667b1aa7e0e1ce011295c47 Mon Sep 17 00:00:00 2001 From: Matthew Falcone Date: Fri, 10 Oct 2025 14:06:52 +0100 Subject: [PATCH 19/43] Update side average so components of vectors can used --- include/postprocessors/FoamSideAverageValue.h | 12 ++- src/postprocessors/FoamSideAverageValue.C | 81 +++++++++++++++++-- .../postprocessors/side_average/foam/0/U | 2 +- .../side_average/gold/main_out.csv | 68 ++++++++-------- test/tests/postprocessors/side_average/main.i | 38 ++++++++- test/tests/postprocessors/side_average/tests | 6 +- 6 files changed, 158 insertions(+), 49 deletions(-) diff --git a/include/postprocessors/FoamSideAverageValue.h b/include/postprocessors/FoamSideAverageValue.h index 41b35160..bd7e9294 100644 --- a/include/postprocessors/FoamSideAverageValue.h +++ b/include/postprocessors/FoamSideAverageValue.h @@ -1,5 +1,9 @@ #pragma once #include "FoamSidePostprocessor.h" +#include +#include + +static MooseEnum _pp_function_objects("wallHeatFlux wallShearStress"); class FoamSideAverageValue : public FoamSidePostprocessor { @@ -13,7 +17,13 @@ class FoamSideAverageValue : public FoamSidePostprocessor virtual void compute() override; protected: + void createFunctionObject(); + Real _value; - std::string _foam_scalar; + std::string _foam_variable; + + bool _is_vector; + + Foam::functionObject * _function_object; }; diff --git a/src/postprocessors/FoamSideAverageValue.C b/src/postprocessors/FoamSideAverageValue.C index d7bf880a..3b571c4a 100644 --- a/src/postprocessors/FoamSideAverageValue.C +++ b/src/postprocessors/FoamSideAverageValue.C @@ -1,8 +1,11 @@ #include "ElementUserObject.h" +#include "Field.H" #include "FoamSideAverageValue.h" #include "InputParameters.h" +#include "MooseEnum.h" #include "MooseTypes.h" #include "FoamMesh.h" +#include "functionObjects/field/wallShearStress/wallShearStress.H" #include "volFieldsFwd.H" registerMooseObject("hippoApp", FoamSideAverageValue); @@ -10,19 +13,58 @@ registerMooseObject("hippoApp", FoamSideAverageValue); InputParameters FoamSideAverageValue::validParams() { + MooseEnum components("x y z normal magnitude", "magnitude"); auto params = FoamSidePostprocessor::validParams(); params.addClassDescription( "Class that calculates the average or scalar on a OpenFOAM boundary patch."); - params.addRequiredParam("foam_scalar", - "Foam variable to be averaged over a boundary patch."); + params.addRequiredParam( + "foam_variable", "Foam variable or function object to be averaged over a boundary patch."); + params.addParam( + "component", components, "If foam variable is a vector, which component to output"); return params; } FoamSideAverageValue::FoamSideAverageValue(const InputParameters & params) - : FoamSidePostprocessor(params), _value(0.), _foam_scalar(params.get("foam_scalar")) + : FoamSidePostprocessor(params), + _value(0.), + _foam_variable(params.get("foam_variable")), + _is_vector(false), + _function_object(nullptr) { - if (!_foam_mesh->foundObject(_foam_scalar)) - mooseError("Foam scalar '", _foam_scalar, "' not found."); + if (_pp_function_objects.find(_foam_variable) != _pp_function_objects.items().end()) + createFunctionObject(); + + if (_foam_mesh->foundObject(_foam_variable)) + _is_vector = true; + else if (!_foam_mesh->foundObject(_foam_variable)) + mooseError("No Foam scalar or function object called '", _foam_variable, "'."); +} + +void +FoamSideAverageValue::createFunctionObject() +{ + auto fo_dict = + _foam_mesh->time().controlDict().lookupOrDefault(_foam_variable, Foam::dictionary()); + + Foam::wordList patch_names; + for (auto id : blocks()) + patch_names.append(_foam_mesh->boundaryMesh()[id].name()); + + fo_dict.set("patches", patch_names); + fo_dict.set("writeToFile", false); + + if (_foam_variable == "wallHeatFlux") + { + _function_object = static_cast( + new Foam::functionObjects::wallHeatFlux("wallHeatFlux", _foam_mesh->time(), fo_dict)); + } + else if (_foam_variable == "wallShearStress") + { + _function_object = static_cast( + new Foam::functionObjects::wallShearStress("wallShearStress", _foam_mesh->time(), fo_dict)); + } + + _function_object->execute(); } void @@ -31,12 +73,35 @@ FoamSideAverageValue::compute() auto foam_mesh = dynamic_cast(&getSubProblem().mesh()); _value = 0.; _volume = 0.; + + if (_function_object) + _function_object->execute(); + for (auto & block : ElementUserObject::blocks()) { - - auto & var_array = - _foam_mesh->boundary()[block].lookupPatchField(_foam_scalar); auto & areas = _foam_mesh->boundary()[block].magSf(); + Foam::Field var_array; + + if (_is_vector) + { + auto && normals = _foam_mesh->boundary()[block].nf(); + auto & vec_data = + _foam_mesh->boundary()[block].lookupPatchField( + _foam_variable); + + auto components = parameters().get("component"); + if (components == "normal") + var_array = normals & vec_data; + else if (components == "magnitude") + var_array = Foam::mag(vec_data); + else + var_array = vec_data.component(int(components)); + } + else + { + var_array = _foam_mesh->boundary()[block].lookupPatchField( + _foam_variable); + } for (int i = 0; i < var_array.size(); ++i) { diff --git a/test/tests/postprocessors/side_average/foam/0/U b/test/tests/postprocessors/side_average/foam/0/U index 8b272ee4..d23654bb 100644 --- a/test/tests/postprocessors/side_average/foam/0/U +++ b/test/tests/postprocessors/side_average/foam/0/U @@ -16,7 +16,7 @@ FoamFile dimensions [ 0 1 -1 0 0 0 0 ]; -internalField uniform (0 0 0); +internalField uniform (2 -1 0); boundaryField { diff --git a/test/tests/postprocessors/side_average/gold/main_out.csv b/test/tests/postprocessors/side_average/gold/main_out.csv index d527c99b..c3bf1a97 100644 --- a/test/tests/postprocessors/side_average/gold/main_out.csv +++ b/test/tests/postprocessors/side_average/gold/main_out.csv @@ -1,34 +1,34 @@ -time,test -0,0 -0.01,0.01 -0.02,0.02 -0.03,0.03 -0.04,0.04 -0.05,0.05 -0.06,0.06 -0.07,0.07 -0.08,0.08 -0.09,0.09 -0.1,0.1 -0.11,0.11 -0.12,0.12 -0.13,0.13 -0.14,0.14 -0.15,0.15 -0.16,0.16 -0.17,0.17 -0.18,0.18 -0.19,0.19 -0.2,0.2 -0.21,0.21 -0.22,0.22 -0.23,0.23 -0.24,0.24 -0.25,0.25 -0.26,0.26 -0.27,0.27 -0.28,0.28 -0.29,0.29 -0.3,0.3 -0.31,0.31 -0.32,0.32 +time,U_avg_magnitude,U_avg_normal,U_avg_x,U_avg_y,U_avg_z,t_avg +0,0,0,0,0,0,0 +0.01,2.2360679774998,2,2,-1,0,0.01 +0.02,2.2360679774998,2,2,-1,0,0.02 +0.03,2.2360679774998,2,2,-1,0,0.03 +0.04,2.2360679774998,2,2,-1,0,0.04 +0.05,2.2360679774998,2,2,-1,0,0.05 +0.06,2.2360679774998,2,2,-1,0,0.06 +0.07,2.2360679774998,2,2,-1,0,0.07 +0.08,2.2360679774998,2,2,-1,0,0.08 +0.09,2.2360679774998,2,2,-1,0,0.09 +0.1,2.2360679774998,2,2,-1,0,0.1 +0.11,2.2360679774998,2,2,-1,0,0.11 +0.12,2.2360679774998,2,2,-1,0,0.12 +0.13,2.2360679774998,2,2,-1,0,0.13 +0.14,2.2360679774998,2,2,-1,0,0.14 +0.15,2.2360679774998,2,2,-1,0,0.15 +0.16,2.2360679774998,2,2,-1,0,0.16 +0.17,2.2360679774998,2,2,-1,0,0.17 +0.18,2.2360679774998,2,2,-1,0,0.18 +0.19,2.2360679774998,2,2,-1,0,0.19 +0.2,2.2360679774998,2,2,-1,0,0.2 +0.21,2.2360679774998,2,2,-1,0,0.21 +0.22,2.2360679774998,2,2,-1,0,0.22 +0.23,2.2360679774998,2,2,-1,0,0.23 +0.24,2.2360679774998,2,2,-1,0,0.24 +0.25,2.2360679774998,2,2,-1,0,0.25 +0.26,2.2360679774998,2,2,-1,0,0.26 +0.27,2.2360679774998,2,2,-1,0,0.27 +0.28,2.2360679774998,2,2,-1,0,0.28 +0.29,2.2360679774998,2,2,-1,0,0.29 +0.3,2.2360679774998,2,2,-1,0,0.3 +0.31,2.2360679774998,2,2,-1,0,0.31 +0.32,2.2360679774998,2,2,-1,0,0.32 diff --git a/test/tests/postprocessors/side_average/main.i b/test/tests/postprocessors/side_average/main.i index e78e0e7e..5bb95346 100644 --- a/test/tests/postprocessors/side_average/main.i +++ b/test/tests/postprocessors/side_average/main.i @@ -27,12 +27,46 @@ [] [Postprocessors] - [test] + [t_avg] type = FoamSideAverageValue - foam_scalar = 'T' + foam_variable = 'T' block = top execute_on = TIMESTEP_END [] + [U_avg_magnitude] + type = FoamSideAverageValue + foam_variable = 'U' + block = right + execute_on = TIMESTEP_END + [] + [U_avg_normal] + type = FoamSideAverageValue + foam_variable = 'U' + block = right + component = normal + execute_on = TIMESTEP_END + [] + [U_avg_x] + type = FoamSideAverageValue + foam_variable = 'U' + block = right + component = x + execute_on = TIMESTEP_END + [] + [U_avg_y] + type = FoamSideAverageValue + foam_variable = 'U' + block = right + component = y + execute_on = TIMESTEP_END + [] + [U_avg_z] + type = FoamSideAverageValue + foam_variable = 'U' + block = right + component = z + execute_on = TIMESTEP_END + [] [] [Outputs] diff --git a/test/tests/postprocessors/side_average/tests b/test/tests/postprocessors/side_average/tests index f06a67c1..9b345b4c 100644 --- a/test/tests/postprocessors/side_average/tests +++ b/test/tests/postprocessors/side_average/tests @@ -16,7 +16,7 @@ input = main.i prereq = postprocessor_test/setup allow_warnings = true - cli_args='Postprocessors/test/block=top1' + cli_args='Postprocessors/t_avg/block=top1' expect_err = "do not exist on the mesh: top1" [] [invalid_foam_scalar] @@ -24,8 +24,8 @@ input = main.i prereq = postprocessor_test/setup allow_warnings = true - cli_args='Postprocessors/test/foam_scalar=T1' - expect_err = "Foam scalar 'T1' not found." + cli_args='Postprocessors/t_avg/foam_variable=T1' + expect_err = "No Foam scalar or function object called 'T1'." [] [] [] From 2491921f7b7b6803e4adc2f5402e20a7f8bffea3 Mon Sep 17 00:00:00 2001 From: Matthew Falcone Date: Fri, 10 Oct 2025 14:54:16 +0100 Subject: [PATCH 20/43] Improve comments for foam postprocessors --- .../postprocessors/FoamPostprocessorBase.h | 4 +++ .../postprocessors/FoamSidePostprocessor.h | 4 --- .../FoamSideAdvectiveFluxIntegral.C | 2 ++ src/postprocessors/FoamSideAverageValue.C | 32 ++++++++++++------- src/postprocessors/FoamSidePostprocessor.C | 3 +- 5 files changed, 29 insertions(+), 16 deletions(-) diff --git a/include/postprocessors/FoamPostprocessorBase.h b/include/postprocessors/FoamPostprocessorBase.h index 9d6230ac..7847fc1e 100644 --- a/include/postprocessors/FoamPostprocessorBase.h +++ b/include/postprocessors/FoamPostprocessorBase.h @@ -12,6 +12,9 @@ class FoamPostprocessorBase : public ElementUserObject, public Postprocessor FoamPostprocessorBase(const InputParameters & params); + // We dont want the usual UserObject functions to be executed + // But we still want the Foam Postprocessors to be reported with the other + // Foam postprocessors virtual void initialize() final; virtual void execute() final; @@ -20,6 +23,7 @@ class FoamPostprocessorBase : public ElementUserObject, public Postprocessor virtual void threadJoin(const UserObject & uo) final; + // Compute postprocessor, to be called within FoamProblem virtual void compute() = 0; protected: diff --git a/include/postprocessors/FoamSidePostprocessor.h b/include/postprocessors/FoamSidePostprocessor.h index aae64c7e..4a0cbfe9 100644 --- a/include/postprocessors/FoamSidePostprocessor.h +++ b/include/postprocessors/FoamSidePostprocessor.h @@ -2,14 +2,10 @@ #include "FoamPostprocessorBase.h" -// When FoamMesh is updated use BoundaryRestrictable when Foammesh is refactored class FoamSidePostprocessor : public FoamPostprocessorBase { public: static InputParameters validParams(); FoamSidePostprocessor(const InputParameters & params); - -protected: - Real _volume; }; diff --git a/src/postprocessors/FoamSideAdvectiveFluxIntegral.C b/src/postprocessors/FoamSideAdvectiveFluxIntegral.C index 9fe46a94..7ee2aa30 100644 --- a/src/postprocessors/FoamSideAdvectiveFluxIntegral.C +++ b/src/postprocessors/FoamSideAdvectiveFluxIntegral.C @@ -46,12 +46,14 @@ FoamSideAdvectiveFluxIntegral::compute() auto & areas = _foam_mesh->boundary()[block].magSf(); auto && normals = _foam_mesh->boundary()[block].nf(); + // integrate locally for (int i = 0; i < var_array.size(); ++i) { _value += var_array[i] * areas[i] * (normals->data()[i] & vel_array[i]); } } + // Sum across ranks gatherSum(_value); } diff --git a/src/postprocessors/FoamSideAverageValue.C b/src/postprocessors/FoamSideAverageValue.C index 3b571c4a..f5ad71f7 100644 --- a/src/postprocessors/FoamSideAverageValue.C +++ b/src/postprocessors/FoamSideAverageValue.C @@ -31,9 +31,12 @@ FoamSideAverageValue::FoamSideAverageValue(const InputParameters & params) _is_vector(false), _function_object(nullptr) { + // Create function object if the foam variable matches one of the + // available function objects if (_pp_function_objects.find(_foam_variable) != _pp_function_objects.items().end()) createFunctionObject(); + // determine if this is a vector scalar, ahead of computation if (_foam_mesh->foundObject(_foam_variable)) _is_vector = true; else if (!_foam_mesh->foundObject(_foam_variable)) @@ -46,9 +49,7 @@ FoamSideAverageValue::createFunctionObject() auto fo_dict = _foam_mesh->time().controlDict().lookupOrDefault(_foam_variable, Foam::dictionary()); - Foam::wordList patch_names; - for (auto id : blocks()) - patch_names.append(_foam_mesh->boundaryMesh()[id].name()); + Foam::wordList patch_names(blocks().begin(), blocks().end()); fo_dict.set("patches", patch_names); fo_dict.set("writeToFile", false); @@ -70,13 +71,13 @@ FoamSideAverageValue::createFunctionObject() void FoamSideAverageValue::compute() { - auto foam_mesh = dynamic_cast(&getSubProblem().mesh()); - _value = 0.; - _volume = 0.; - if (_function_object) _function_object->execute(); + _value = 0.; + Real volume = 0.; + + // loop over boundary ids for (auto & block : ElementUserObject::blocks()) { auto & areas = _foam_mesh->boundary()[block].magSf(); @@ -84,14 +85,19 @@ FoamSideAverageValue::compute() if (_is_vector) { - auto && normals = _foam_mesh->boundary()[block].nf(); + // get vector data associated with the block auto & vec_data = _foam_mesh->boundary()[block].lookupPatchField( _foam_variable); + // get the component specified in parameters and get the + // component of the vector in that direction auto components = parameters().get("component"); if (components == "normal") + { + auto && normals = _foam_mesh->boundary()[block].nf(); var_array = normals & vec_data; + } else if (components == "magnitude") var_array = Foam::mag(vec_data); else @@ -103,16 +109,20 @@ FoamSideAverageValue::compute() _foam_variable); } + // Integrate for (int i = 0; i < var_array.size(); ++i) { _value += var_array[i] * areas[i]; - _volume += areas[i]; + volume += areas[i]; } } + // sum over ranks gatherSum(_value); - gatherSum(_volume); - _value /= _volume; + gatherSum(volume); + + // divide by area + _value /= volume; } PostprocessorValue diff --git a/src/postprocessors/FoamSidePostprocessor.C b/src/postprocessors/FoamSidePostprocessor.C index ca988a34..cb3b46f1 100644 --- a/src/postprocessors/FoamSidePostprocessor.C +++ b/src/postprocessors/FoamSidePostprocessor.C @@ -7,12 +7,13 @@ InputParameters FoamSidePostprocessor::validParams() { auto params = FoamPostprocessorBase::validParams(); + // Eventually change to BoundaryRestrictable params += BlockRestrictable::validParams(); return params; } FoamSidePostprocessor::FoamSidePostprocessor(const InputParameters & params) - : FoamPostprocessorBase(params), _volume(0.) + : FoamPostprocessorBase(params) { } From 243e9e8fd922dddd349c9f87ff69bda556d7ceb3 Mon Sep 17 00:00:00 2001 From: Matthew Falcone Date: Fri, 10 Oct 2025 14:55:42 +0100 Subject: [PATCH 21/43] Add parallel tests for postprocessors --- .../foam/system/decomposeParDict | 42 +++++++++++++++++++ .../side_advective_flux_integral/tests | 11 ++++- .../side_average/foam/system/decomposeParDict | 42 +++++++++++++++++++ test/tests/postprocessors/side_average/tests | 11 ++++- 4 files changed, 104 insertions(+), 2 deletions(-) create mode 100644 test/tests/postprocessors/side_advective_flux_integral/foam/system/decomposeParDict create mode 100644 test/tests/postprocessors/side_average/foam/system/decomposeParDict diff --git a/test/tests/postprocessors/side_advective_flux_integral/foam/system/decomposeParDict b/test/tests/postprocessors/side_advective_flux_integral/foam/system/decomposeParDict new file mode 100644 index 00000000..0204a6b9 --- /dev/null +++ b/test/tests/postprocessors/side_advective_flux_integral/foam/system/decomposeParDict @@ -0,0 +1,42 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 10 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + location "system"; + object decomposeParDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +numberOfSubdomains 2; + +method simple; + +simpleCoeffs +{ + n (2 1 1); +} + +hierarchicalCoeffs +{ + n (1 1 1); + order xyz; +} + +manualCoeffs +{ + dataFile ""; +} + +distributed no; + +roots ( ); + + +// ************************************************************************* // diff --git a/test/tests/postprocessors/side_advective_flux_integral/tests b/test/tests/postprocessors/side_advective_flux_integral/tests index 49aa40cb..5680c0d7 100644 --- a/test/tests/postprocessors/side_advective_flux_integral/tests +++ b/test/tests/postprocessors/side_advective_flux_integral/tests @@ -2,7 +2,7 @@ [postprocessor_test] [setup] type = RunCommand - command = 'bash -c "foamCleanCase -case foam && blockMesh -case foam"' + command = 'bash -c "foamCleanCase -case foam && blockMesh -case foam && decomposePar -case foam"' [] [check_csv] type = CSVDiff @@ -11,6 +11,15 @@ csvdiff = main_out.csv allow_warnings = true [] + [check_csv_parallel] + type = CSVDiff + input = main.i + prereq = postprocessor_test/setup + csvdiff = main_out.csv + allow_warnings = true + min_parallel=2 + max_parallel=2 + [] [invalid_advective_velocity] type = RunException input = main.i diff --git a/test/tests/postprocessors/side_average/foam/system/decomposeParDict b/test/tests/postprocessors/side_average/foam/system/decomposeParDict new file mode 100644 index 00000000..0204a6b9 --- /dev/null +++ b/test/tests/postprocessors/side_average/foam/system/decomposeParDict @@ -0,0 +1,42 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 10 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + location "system"; + object decomposeParDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +numberOfSubdomains 2; + +method simple; + +simpleCoeffs +{ + n (2 1 1); +} + +hierarchicalCoeffs +{ + n (1 1 1); + order xyz; +} + +manualCoeffs +{ + dataFile ""; +} + +distributed no; + +roots ( ); + + +// ************************************************************************* // diff --git a/test/tests/postprocessors/side_average/tests b/test/tests/postprocessors/side_average/tests index 9b345b4c..622872f0 100644 --- a/test/tests/postprocessors/side_average/tests +++ b/test/tests/postprocessors/side_average/tests @@ -2,7 +2,7 @@ [postprocessor_test] [setup] type = RunCommand - command = 'bash -c "foamCleanCase -case foam && blockMesh -case foam"' + command = 'bash -c "foamCleanCase -case foam && blockMesh -case foam && decomposePar -case foam"' [] [check_csv] type = CSVDiff @@ -11,6 +11,15 @@ csvdiff = main_out.csv allow_warnings = true [] + [check_csv_parallel] + type = CSVDiff + input = main.i + prereq = postprocessor_test/setup + csvdiff = main_out.csv + allow_warnings = true + min_parallel = 2 + max_parallel = 2 + [] [boundary_err] type = RunException input = main.i From ffc896f1d4d61b75ae3b1c0a33a1e979f64d522f Mon Sep 17 00:00:00 2001 From: Matthew Falcone Date: Sun, 16 Nov 2025 10:08:01 +0000 Subject: [PATCH 22/43] Remove FoamPostprocessor block after rebase --- src/base/hippoApp.C | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/base/hippoApp.C b/src/base/hippoApp.C index f474f5f3..e89b6314 100644 --- a/src/base/hippoApp.C +++ b/src/base/hippoApp.C @@ -43,11 +43,6 @@ hippoApp::registerAll(Factory & f, ActionFactory & af, Syntax & syntax) registerSyntaxTask("AddFoamBCAction", "FoamBCs/*", "add_foam_bc"); registerMooseObjectTask("add_foam_bc", FoamBC, false); addTaskDependency("add_aux_variable", "add_foam_bc"); - - // Add [FoamPostprocessors] block - registerSyntax("AddPostprocessorAction", "FoamPostprocessors/*"); - syntax.registerSyntaxType("FoamPostprocessors/*", "PostprocessorName"); - syntax.registerSyntaxType("FoamPostprocessors/*", "UserObjectName"); } void From 4a704f307a729f6d6dac68f1ee110cbe993e5e59 Mon Sep 17 00:00:00 2001 From: Matthew Falcone Date: Fri, 16 Jan 2026 10:33:04 +0000 Subject: [PATCH 23/43] Apply git patch from postprocessor BC branch to get all updates for Foam Postprocessor --- include/postprocessors/FoamSideAverageValue.h | 23 +--- .../postprocessors/FoamSideIntegratedValue.h | 29 ++++ .../postprocessors/FoamSidePostprocessor.h | 4 + src/postprocessors/FoamPostprocessorBase.C | 1 - .../FoamSideAdvectiveFluxIntegral.C | 14 +- src/postprocessors/FoamSideAverageValue.C | 112 +--------------- src/postprocessors/FoamSideIntegratedValue.C | 124 ++++++++++++++++++ src/postprocessors/FoamSidePostprocessor.C | 13 +- .../side_advective_flux_integral/main.i | 12 +- test/tests/postprocessors/side_average/main.i | 14 +- test/tests/postprocessors/side_average/tests | 4 +- 11 files changed, 199 insertions(+), 151 deletions(-) create mode 100644 include/postprocessors/FoamSideIntegratedValue.h create mode 100644 src/postprocessors/FoamSideIntegratedValue.C diff --git a/include/postprocessors/FoamSideAverageValue.h b/include/postprocessors/FoamSideAverageValue.h index bd7e9294..7e31bc7a 100644 --- a/include/postprocessors/FoamSideAverageValue.h +++ b/include/postprocessors/FoamSideAverageValue.h @@ -1,29 +1,14 @@ #pragma once -#include "FoamSidePostprocessor.h" +#include "FoamSideIntegratedValue.h" +#include "InputParameters.h" #include #include -static MooseEnum _pp_function_objects("wallHeatFlux wallShearStress"); - -class FoamSideAverageValue : public FoamSidePostprocessor +class FoamSideAverageValue : public FoamSideIntegratedValue { public: - static InputParameters validParams(); + static InputParameters validParams() { return FoamSideIntegratedValue::validParams(); } FoamSideAverageValue(const InputParameters & params); - - virtual PostprocessorValue getValue() const override; - virtual void compute() override; - -protected: - void createFunctionObject(); - - Real _value; - - std::string _foam_variable; - - bool _is_vector; - - Foam::functionObject * _function_object; }; diff --git a/include/postprocessors/FoamSideIntegratedValue.h b/include/postprocessors/FoamSideIntegratedValue.h new file mode 100644 index 00000000..bcd99af9 --- /dev/null +++ b/include/postprocessors/FoamSideIntegratedValue.h @@ -0,0 +1,29 @@ +#pragma once +#include "FoamSidePostprocessor.h" +#include +#include + +static MooseEnum _pp_function_objects("wallHeatFlux wallShearStress"); + +class FoamSideIntegratedValue : public FoamSidePostprocessor +{ +public: + static InputParameters validParams(); + + FoamSideIntegratedValue(const InputParameters & params); + + virtual PostprocessorValue getValue() const override; + + virtual void compute() override; + +protected: + void createFunctionObject(); + + Real _value; + + std::string _foam_variable; + + bool _is_vector; + + Foam::functionObject * _function_object; +}; diff --git a/include/postprocessors/FoamSidePostprocessor.h b/include/postprocessors/FoamSidePostprocessor.h index 4a0cbfe9..060e661e 100644 --- a/include/postprocessors/FoamSidePostprocessor.h +++ b/include/postprocessors/FoamSidePostprocessor.h @@ -1,6 +1,7 @@ #pragma once #include "FoamPostprocessorBase.h" +#include "MooseTypes.h" class FoamSidePostprocessor : public FoamPostprocessorBase { @@ -8,4 +9,7 @@ class FoamSidePostprocessor : public FoamPostprocessorBase static InputParameters validParams(); FoamSidePostprocessor(const InputParameters & params); + +protected: + std::vector _boundary; }; diff --git a/src/postprocessors/FoamPostprocessorBase.C b/src/postprocessors/FoamPostprocessorBase.C index 59baf5f7..636ed10f 100644 --- a/src/postprocessors/FoamPostprocessorBase.C +++ b/src/postprocessors/FoamPostprocessorBase.C @@ -8,7 +8,6 @@ InputParameters FoamPostprocessorBase::validParams() { - auto params = ElementUserObject::validParams(); params += Postprocessor::validParams(); return params; diff --git a/src/postprocessors/FoamSideAdvectiveFluxIntegral.C b/src/postprocessors/FoamSideAdvectiveFluxIntegral.C index 7ee2aa30..cca40303 100644 --- a/src/postprocessors/FoamSideAdvectiveFluxIntegral.C +++ b/src/postprocessors/FoamSideAdvectiveFluxIntegral.C @@ -35,16 +35,18 @@ void FoamSideAdvectiveFluxIntegral::compute() { _value = 0.; - for (auto & block : ElementUserObject::blocks()) + for (auto & boundary : _boundary) { auto & var_array = - _foam_mesh->boundary()[block].lookupPatchField(_foam_scalar); + _foam_mesh->boundary()[boundary].lookupPatchField( + _foam_scalar); - auto & vel_array = _foam_mesh->boundary()[block].lookupPatchField( - _advection_velocity); + auto & vel_array = + _foam_mesh->boundary()[boundary].lookupPatchField( + _advection_velocity); - auto & areas = _foam_mesh->boundary()[block].magSf(); - auto && normals = _foam_mesh->boundary()[block].nf(); + auto & areas = _foam_mesh->boundary()[boundary].magSf(); + auto && normals = _foam_mesh->boundary()[boundary].nf(); // integrate locally for (int i = 0; i < var_array.size(); ++i) diff --git a/src/postprocessors/FoamSideAverageValue.C b/src/postprocessors/FoamSideAverageValue.C index f5ad71f7..0b53fd28 100644 --- a/src/postprocessors/FoamSideAverageValue.C +++ b/src/postprocessors/FoamSideAverageValue.C @@ -1,132 +1,34 @@ -#include "ElementUserObject.h" #include "Field.H" #include "FoamSideAverageValue.h" +#include "FoamSideIntegratedValue.h" #include "InputParameters.h" -#include "MooseEnum.h" -#include "MooseTypes.h" -#include "FoamMesh.h" -#include "functionObjects/field/wallShearStress/wallShearStress.H" -#include "volFieldsFwd.H" registerMooseObject("hippoApp", FoamSideAverageValue); -InputParameters -FoamSideAverageValue::validParams() -{ - MooseEnum components("x y z normal magnitude", "magnitude"); - auto params = FoamSidePostprocessor::validParams(); - params.addClassDescription( - "Class that calculates the average or scalar on a OpenFOAM boundary patch."); - params.addRequiredParam( - "foam_variable", "Foam variable or function object to be averaged over a boundary patch."); - params.addParam( - "component", components, "If foam variable is a vector, which component to output"); - return params; -} - FoamSideAverageValue::FoamSideAverageValue(const InputParameters & params) - : FoamSidePostprocessor(params), - _value(0.), - _foam_variable(params.get("foam_variable")), - _is_vector(false), - _function_object(nullptr) + : FoamSideIntegratedValue(params) { - // Create function object if the foam variable matches one of the - // available function objects - if (_pp_function_objects.find(_foam_variable) != _pp_function_objects.items().end()) - createFunctionObject(); - - // determine if this is a vector scalar, ahead of computation - if (_foam_mesh->foundObject(_foam_variable)) - _is_vector = true; - else if (!_foam_mesh->foundObject(_foam_variable)) - mooseError("No Foam scalar or function object called '", _foam_variable, "'."); -} - -void -FoamSideAverageValue::createFunctionObject() -{ - auto fo_dict = - _foam_mesh->time().controlDict().lookupOrDefault(_foam_variable, Foam::dictionary()); - - Foam::wordList patch_names(blocks().begin(), blocks().end()); - - fo_dict.set("patches", patch_names); - fo_dict.set("writeToFile", false); - - if (_foam_variable == "wallHeatFlux") - { - _function_object = static_cast( - new Foam::functionObjects::wallHeatFlux("wallHeatFlux", _foam_mesh->time(), fo_dict)); - } - else if (_foam_variable == "wallShearStress") - { - _function_object = static_cast( - new Foam::functionObjects::wallShearStress("wallShearStress", _foam_mesh->time(), fo_dict)); - } - - _function_object->execute(); } void FoamSideAverageValue::compute() { - if (_function_object) - _function_object->execute(); - _value = 0.; - Real volume = 0.; + FoamSideIntegratedValue::compute(); + Real volume = 0.; // loop over boundary ids - for (auto & block : ElementUserObject::blocks()) + for (auto & boundary : _boundary) { - auto & areas = _foam_mesh->boundary()[block].magSf(); - Foam::Field var_array; - - if (_is_vector) - { - // get vector data associated with the block - auto & vec_data = - _foam_mesh->boundary()[block].lookupPatchField( - _foam_variable); - - // get the component specified in parameters and get the - // component of the vector in that direction - auto components = parameters().get("component"); - if (components == "normal") - { - auto && normals = _foam_mesh->boundary()[block].nf(); - var_array = normals & vec_data; - } - else if (components == "magnitude") - var_array = Foam::mag(vec_data); - else - var_array = vec_data.component(int(components)); - } - else + auto & areas = _foam_mesh->boundary()[boundary].magSf(); + for (int i = 0; i < areas.size(); ++i) { - var_array = _foam_mesh->boundary()[block].lookupPatchField( - _foam_variable); - } - - // Integrate - for (int i = 0; i < var_array.size(); ++i) - { - _value += var_array[i] * areas[i]; volume += areas[i]; } } - // sum over ranks - gatherSum(_value); gatherSum(volume); // divide by area _value /= volume; } - -PostprocessorValue -FoamSideAverageValue::getValue() const -{ - return _value; -} diff --git a/src/postprocessors/FoamSideIntegratedValue.C b/src/postprocessors/FoamSideIntegratedValue.C new file mode 100644 index 00000000..bad6e0b8 --- /dev/null +++ b/src/postprocessors/FoamSideIntegratedValue.C @@ -0,0 +1,124 @@ +#include "Field.H" +#include "FoamSideIntegratedValue.h" +#include "InputParameters.h" +#include "MooseEnum.h" +#include "MooseTypes.h" +#include "FoamMesh.h" +#include "functionObjects/field/wallShearStress/wallShearStress.H" +#include "volFieldsFwd.H" + +registerMooseObject("hippoApp", FoamSideIntegratedValue); + +InputParameters +FoamSideIntegratedValue::validParams() +{ + MooseEnum components("x y z normal magnitude", "magnitude"); + auto params = FoamSidePostprocessor::validParams(); + params.addClassDescription( + "Class that calculates the average or scalar on a OpenFOAM boundary patch."); + params.addRequiredParam( + "foam_variable", "Foam variable or function object to be averaged over a boundary patch."); + params.addParam( + "component", components, "If foam variable is a vector, which component to output"); + return params; +} + +FoamSideIntegratedValue::FoamSideIntegratedValue(const InputParameters & params) + : FoamSidePostprocessor(params), + _value(0.), + _foam_variable(params.get("foam_variable")), + _is_vector(false), + _function_object(nullptr) +{ + // Create function object if the foam variable matches one of the + // available function objects + if (_pp_function_objects.find(_foam_variable) != _pp_function_objects.items().end()) + createFunctionObject(); + + // determine if this is a vector scalar, ahead of computation + if (_foam_mesh->foundObject(_foam_variable)) + _is_vector = true; + else if (!_foam_mesh->foundObject(_foam_variable)) + mooseError("No Foam scalar or function object called '", _foam_variable, "'."); +} + +void +FoamSideIntegratedValue::createFunctionObject() +{ + auto fo_dict = + _foam_mesh->time().controlDict().lookupOrDefault(_foam_variable, Foam::dictionary()); + + Foam::wordList patch_names(blocks().begin(), blocks().end()); + + fo_dict.set("patches", patch_names); + fo_dict.set("writeToFile", false); + + if (_foam_variable == "wallHeatFlux") + { + _function_object = static_cast( + new Foam::functionObjects::wallHeatFlux("wallHeatFlux", _foam_mesh->time(), fo_dict)); + } + else if (_foam_variable == "wallShearStress") + { + _function_object = static_cast( + new Foam::functionObjects::wallShearStress("wallShearStress", _foam_mesh->time(), fo_dict)); + } + + _function_object->execute(); +} + +void +FoamSideIntegratedValue::compute() +{ + if (_function_object) + _function_object->execute(); + + _value = 0.; + // loop over boundary ids + for (auto & boundary : _boundary) + { + auto & areas = _foam_mesh->boundary()[boundary].magSf(); + Foam::Field var_array; + + if (_is_vector) + { + // get vector data associated with the boundary + auto & vec_data = + _foam_mesh->boundary()[boundary].lookupPatchField( + _foam_variable); + + // get the component specified in parameters and get the + // component of the vector in that direction + auto components = parameters().get("component"); + if (components == "normal") + { + auto && normals = _foam_mesh->boundary()[boundary].nf(); + var_array = normals & vec_data; + } + else if (components == "magnitude") + var_array = Foam::mag(vec_data); + else + var_array = vec_data.component(int(components)); + } + else + { + var_array = _foam_mesh->boundary()[boundary].lookupPatchField( + _foam_variable); + } + + // Integrate + for (int i = 0; i < var_array.size(); ++i) + { + _value += var_array[i] * areas[i]; + } + } + + // sum over ranks + gatherSum(_value); +} + +PostprocessorValue +FoamSideIntegratedValue::getValue() const +{ + return _value; +} diff --git a/src/postprocessors/FoamSidePostprocessor.C b/src/postprocessors/FoamSidePostprocessor.C index cb3b46f1..98bd6b98 100644 --- a/src/postprocessors/FoamSidePostprocessor.C +++ b/src/postprocessors/FoamSidePostprocessor.C @@ -1,4 +1,3 @@ -#include "BlockRestrictable.h" #include "FoamSidePostprocessor.h" #include "InputParameters.h" #include "MooseTypes.h" @@ -7,13 +6,17 @@ InputParameters FoamSidePostprocessor::validParams() { auto params = FoamPostprocessorBase::validParams(); - // Eventually change to BoundaryRestrictable - params += BlockRestrictable::validParams(); - + params.addRequiredParam>( + "boundary", "List of boundaries where postprocessor applies."); return params; } FoamSidePostprocessor::FoamSidePostprocessor(const InputParameters & params) - : FoamPostprocessorBase(params) + : FoamPostprocessorBase(params), _boundary(params.get>("boundary")) { + for (auto & boundary : _boundary) + { + if (_foam_mesh->boundary().findIndex(boundary) == -1) + mooseError("Boundary '", boundary, "' not found in FoamMesh."); + } } diff --git a/test/tests/postprocessors/side_advective_flux_integral/main.i b/test/tests/postprocessors/side_advective_flux_integral/main.i index dae55e5d..d59ce430 100644 --- a/test/tests/postprocessors/side_advective_flux_integral/main.i +++ b/test/tests/postprocessors/side_advective_flux_integral/main.i @@ -30,32 +30,32 @@ [m_dot_x1] type = FoamSideAdvectiveFluxIntegral foam_scalar = 'rho' - block = left + boundary = left [] [m_dot_x2] type = FoamSideAdvectiveFluxIntegral foam_scalar = 'rho' - block = right + boundary = right [] [m_dot_y1] type = FoamSideAdvectiveFluxIntegral foam_scalar = 'rho' - block = bottom + boundary = bottom [] [m_dot_y2] type = FoamSideAdvectiveFluxIntegral foam_scalar = 'rho' - block = top + boundary = top [] [m_dot_z1] type = FoamSideAdvectiveFluxIntegral foam_scalar = 'rho' - block = back + boundary = back [] [m_dot_z2] type = FoamSideAdvectiveFluxIntegral foam_scalar = 'rho' - block = front + boundary = front [] [] diff --git a/test/tests/postprocessors/side_average/main.i b/test/tests/postprocessors/side_average/main.i index 5bb95346..4d59b508 100644 --- a/test/tests/postprocessors/side_average/main.i +++ b/test/tests/postprocessors/side_average/main.i @@ -1,7 +1,7 @@ [Mesh] type = FoamMesh case = 'foam' - foam_patch = 'left right bottom top back front' + foam_patch = 'right top' [] [Variables] @@ -30,40 +30,40 @@ [t_avg] type = FoamSideAverageValue foam_variable = 'T' - block = top + boundary = top execute_on = TIMESTEP_END [] [U_avg_magnitude] type = FoamSideAverageValue foam_variable = 'U' - block = right + boundary = right execute_on = TIMESTEP_END [] [U_avg_normal] type = FoamSideAverageValue foam_variable = 'U' - block = right + boundary = right component = normal execute_on = TIMESTEP_END [] [U_avg_x] type = FoamSideAverageValue foam_variable = 'U' - block = right + boundary = right component = x execute_on = TIMESTEP_END [] [U_avg_y] type = FoamSideAverageValue foam_variable = 'U' - block = right + boundary = right component = y execute_on = TIMESTEP_END [] [U_avg_z] type = FoamSideAverageValue foam_variable = 'U' - block = right + boundary = right component = z execute_on = TIMESTEP_END [] diff --git a/test/tests/postprocessors/side_average/tests b/test/tests/postprocessors/side_average/tests index 622872f0..a55a9d9e 100644 --- a/test/tests/postprocessors/side_average/tests +++ b/test/tests/postprocessors/side_average/tests @@ -25,8 +25,8 @@ input = main.i prereq = postprocessor_test/setup allow_warnings = true - cli_args='Postprocessors/t_avg/block=top1' - expect_err = "do not exist on the mesh: top1" + cli_args='Postprocessors/t_avg/boundary=top1' + expect_err = "Boundary 'top1' not found in FoamMesh." [] [invalid_foam_scalar] type = RunException From 2a52b95a305bc9cd71eb161dcf33e67b369cc643 Mon Sep 17 00:00:00 2001 From: Matthew Falcone Date: Fri, 16 Jan 2026 10:45:18 +0000 Subject: [PATCH 24/43] Update after initial review of source --- include/postprocessors/FoamSideAverageValue.h | 2 ++ .../postprocessors/FoamSideIntegratedValue.h | 1 + .../postprocessorTestSolver.C | 30 ------------------- .../postprocessorTestSolver.H | 12 ++++---- 4 files changed, 9 insertions(+), 36 deletions(-) diff --git a/include/postprocessors/FoamSideAverageValue.h b/include/postprocessors/FoamSideAverageValue.h index 7e31bc7a..dd9a3774 100644 --- a/include/postprocessors/FoamSideAverageValue.h +++ b/include/postprocessors/FoamSideAverageValue.h @@ -1,6 +1,7 @@ #pragma once #include "FoamSideIntegratedValue.h" #include "InputParameters.h" + #include #include @@ -10,5 +11,6 @@ class FoamSideAverageValue : public FoamSideIntegratedValue static InputParameters validParams() { return FoamSideIntegratedValue::validParams(); } FoamSideAverageValue(const InputParameters & params); + virtual void compute() override; }; diff --git a/include/postprocessors/FoamSideIntegratedValue.h b/include/postprocessors/FoamSideIntegratedValue.h index bcd99af9..fb29aaa1 100644 --- a/include/postprocessors/FoamSideIntegratedValue.h +++ b/include/postprocessors/FoamSideIntegratedValue.h @@ -17,6 +17,7 @@ class FoamSideIntegratedValue : public FoamSidePostprocessor virtual void compute() override; protected: + /// Creates function objects to be executed by compute void createFunctionObject(); Real _value; diff --git a/test/OpenFOAM/modules/postprocessorTestSolver/postprocessorTestSolver.C b/test/OpenFOAM/modules/postprocessorTestSolver/postprocessorTestSolver.C index be52f5be..35cce124 100644 --- a/test/OpenFOAM/modules/postprocessorTestSolver/postprocessorTestSolver.C +++ b/test/OpenFOAM/modules/postprocessorTestSolver/postprocessorTestSolver.C @@ -80,21 +80,6 @@ Foam::solvers::postprocessorTestSolver::moveMesh() } } -void -Foam::solvers::postprocessorTestSolver::motionCorrector() -{ -} - -void -Foam::solvers::postprocessorTestSolver::prePredictor() -{ -} - -void -Foam::solvers::postprocessorTestSolver::momentumPredictor() -{ -} - void Foam::solvers::postprocessorTestSolver::thermophysicalPredictor() { @@ -113,19 +98,4 @@ Foam::solvers::postprocessorTestSolver::thermophysicalPredictor() thermo_.correct(); } -void -Foam::solvers::postprocessorTestSolver::pressureCorrector() -{ -} - -void -Foam::solvers::postprocessorTestSolver::postCorrector() -{ -} - -void -Foam::solvers::postprocessorTestSolver::postSolve() -{ -} - // ************************************************************************* // diff --git a/test/OpenFOAM/modules/postprocessorTestSolver/postprocessorTestSolver.H b/test/OpenFOAM/modules/postprocessorTestSolver/postprocessorTestSolver.H index a733d2f7..19d098f3 100644 --- a/test/OpenFOAM/modules/postprocessorTestSolver/postprocessorTestSolver.H +++ b/test/OpenFOAM/modules/postprocessorTestSolver/postprocessorTestSolver.H @@ -74,13 +74,13 @@ public: virtual void moveMesh(); //- Corrections that follow mesh motion - virtual void motionCorrector(); + virtual void motionCorrector() {}; //- Called at the beginning of the PIMPLE loop - virtual void prePredictor(); + virtual void prePredictor() {}; //- Construct and optionally solve the momentum equation - virtual void momentumPredictor(); + virtual void momentumPredictor() {}; //- Construct and solve the energy equation, // convert to temperature @@ -88,13 +88,13 @@ public: virtual void thermophysicalPredictor(); //- Construct and solve the pressure equation in the PISO loop - virtual void pressureCorrector(); + virtual void pressureCorrector() {}; //- Correct the thermophysical transport modelling - virtual void postCorrector(); + virtual void postCorrector() {}; //- Called after the PIMPLE loop at the end of the time-step - virtual void postSolve(); + virtual void postSolve() {}; // Member Operators From 192f2d5c9e72e3fd7adf6d9e402090d81776aa30 Mon Sep 17 00:00:00 2001 From: Matthew Falcone Date: Fri, 16 Jan 2026 11:49:39 +0000 Subject: [PATCH 25/43] Add separate tests for average and integrated flux postprocessors --- src/postprocessors/FoamSideIntegratedValue.C | 2 +- test/tests/postprocessors/side_average/tests | 16 ---- .../side_integrated_value/foam/0/T | 56 ++++++++++++ .../side_integrated_value/foam/0/U | 31 +++++++ .../side_integrated_value/foam/0/p | 30 +++++++ .../side_integrated_value/foam/0/p_rgh | 30 +++++++ .../side_integrated_value/foam/0/rho | 56 ++++++++++++ .../side_integrated_value/foam/constant/g | 21 +++++ .../foam/constant/momentumTransport | 18 ++++ .../foam/constant/physicalProperties | 52 ++++++++++++ .../foam/system/blockMeshDict | 85 +++++++++++++++++++ .../foam/system/controlDict | 44 ++++++++++ .../foam/system/decomposeParDict | 42 +++++++++ .../foam/system/fvSchemes | 51 +++++++++++ .../foam/system/fvSolution | 61 +++++++++++++ .../side_integrated_value/gold/main_out.csv | 34 ++++++++ .../side_integrated_value/main.i | 75 ++++++++++++++++ .../side_integrated_value/tests | 40 +++++++++ 18 files changed, 727 insertions(+), 17 deletions(-) create mode 100644 test/tests/postprocessors/side_integrated_value/foam/0/T create mode 100644 test/tests/postprocessors/side_integrated_value/foam/0/U create mode 100644 test/tests/postprocessors/side_integrated_value/foam/0/p create mode 100644 test/tests/postprocessors/side_integrated_value/foam/0/p_rgh create mode 100644 test/tests/postprocessors/side_integrated_value/foam/0/rho create mode 100644 test/tests/postprocessors/side_integrated_value/foam/constant/g create mode 100644 test/tests/postprocessors/side_integrated_value/foam/constant/momentumTransport create mode 100644 test/tests/postprocessors/side_integrated_value/foam/constant/physicalProperties create mode 100644 test/tests/postprocessors/side_integrated_value/foam/system/blockMeshDict create mode 100644 test/tests/postprocessors/side_integrated_value/foam/system/controlDict create mode 100644 test/tests/postprocessors/side_integrated_value/foam/system/decomposeParDict create mode 100644 test/tests/postprocessors/side_integrated_value/foam/system/fvSchemes create mode 100644 test/tests/postprocessors/side_integrated_value/foam/system/fvSolution create mode 100644 test/tests/postprocessors/side_integrated_value/gold/main_out.csv create mode 100644 test/tests/postprocessors/side_integrated_value/main.i create mode 100644 test/tests/postprocessors/side_integrated_value/tests diff --git a/src/postprocessors/FoamSideIntegratedValue.C b/src/postprocessors/FoamSideIntegratedValue.C index bad6e0b8..cf045ebc 100644 --- a/src/postprocessors/FoamSideIntegratedValue.C +++ b/src/postprocessors/FoamSideIntegratedValue.C @@ -39,7 +39,7 @@ FoamSideIntegratedValue::FoamSideIntegratedValue(const InputParameters & params) if (_foam_mesh->foundObject(_foam_variable)) _is_vector = true; else if (!_foam_mesh->foundObject(_foam_variable)) - mooseError("No Foam scalar or function object called '", _foam_variable, "'."); + mooseError("No Foam scalar, vector or function object called '", _foam_variable, "'."); } void diff --git a/test/tests/postprocessors/side_average/tests b/test/tests/postprocessors/side_average/tests index a55a9d9e..23d80044 100644 --- a/test/tests/postprocessors/side_average/tests +++ b/test/tests/postprocessors/side_average/tests @@ -20,21 +20,5 @@ min_parallel = 2 max_parallel = 2 [] - [boundary_err] - type = RunException - input = main.i - prereq = postprocessor_test/setup - allow_warnings = true - cli_args='Postprocessors/t_avg/boundary=top1' - expect_err = "Boundary 'top1' not found in FoamMesh." - [] - [invalid_foam_scalar] - type = RunException - input = main.i - prereq = postprocessor_test/setup - allow_warnings = true - cli_args='Postprocessors/t_avg/foam_variable=T1' - expect_err = "No Foam scalar or function object called 'T1'." - [] [] [] diff --git a/test/tests/postprocessors/side_integrated_value/foam/0/T b/test/tests/postprocessors/side_integrated_value/foam/0/T new file mode 100644 index 00000000..f8312bb2 --- /dev/null +++ b/test/tests/postprocessors/side_integrated_value/foam/0/T @@ -0,0 +1,56 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 10 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volScalarField; + location "0"; + object T; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 1 0 0 0]; + +internalField uniform 0.1; + +boundaryField +{ + left + { + type calculated; + value uniform 0.; + } + right + { + type calculated; + value uniform 0.; + } + top + { + type calculated; + value uniform 0.; + } + bottom + { + type calculated; + value uniform 0.; + } + back + { + type calculated; + value uniform 0.; + } + front + { + type calculated; + value uniform 0.; + } +} + + +// ************************************************************************* // diff --git a/test/tests/postprocessors/side_integrated_value/foam/0/U b/test/tests/postprocessors/side_integrated_value/foam/0/U new file mode 100644 index 00000000..d23654bb --- /dev/null +++ b/test/tests/postprocessors/side_integrated_value/foam/0/U @@ -0,0 +1,31 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 12 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volVectorField; + location "0"; + object U; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [ 0 1 -1 0 0 0 0 ]; + +internalField uniform (2 -1 0); + +boundaryField +{ + + ".*" + { + type fixedValue; + value $internalField; + } +} + +// ************************************************************************* // diff --git a/test/tests/postprocessors/side_integrated_value/foam/0/p b/test/tests/postprocessors/side_integrated_value/foam/0/p new file mode 100644 index 00000000..0d00fc2f --- /dev/null +++ b/test/tests/postprocessors/side_integrated_value/foam/0/p @@ -0,0 +1,30 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 12 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volScalarField; + location "0"; + object p; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [ 1 -1 -2 0 0 0 0 ]; + +internalField uniform 0; + +boundaryField +{ + ".*" + { + type calculated; + value $internalField; + } +} + +// ************************************************************************* // diff --git a/test/tests/postprocessors/side_integrated_value/foam/0/p_rgh b/test/tests/postprocessors/side_integrated_value/foam/0/p_rgh new file mode 100644 index 00000000..cfc89a8c --- /dev/null +++ b/test/tests/postprocessors/side_integrated_value/foam/0/p_rgh @@ -0,0 +1,30 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 12 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volScalarField; + location "0"; + object p_rgh; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [ 1 -1 -2 0 0 0 0 ]; + +internalField uniform 0; + +boundaryField +{ + ".*" + { + type fixedValue; + value $internalField; + } +} + +// ************************************************************************* // diff --git a/test/tests/postprocessors/side_integrated_value/foam/0/rho b/test/tests/postprocessors/side_integrated_value/foam/0/rho new file mode 100644 index 00000000..d30a04dc --- /dev/null +++ b/test/tests/postprocessors/side_integrated_value/foam/0/rho @@ -0,0 +1,56 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 12 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volScalarField; + location "0"; + object rho; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [1 -3 0 0 0 0 0]; + +internalField uniform 1; + +boundaryField +{ + left + { + type calculated; + value uniform 1; + } + right + { + type calculated; + value uniform 1; + } + top + { + type calculated; + value uniform 1; + } + front + { + type calculated; + value uniform 1; + } + bottom + { + type calculated; + value uniform 1; + } + back + { + type calculated; + value uniform 1; + } +} + + +// ************************************************************************* // diff --git a/test/tests/postprocessors/side_integrated_value/foam/constant/g b/test/tests/postprocessors/side_integrated_value/foam/constant/g new file mode 100644 index 00000000..8af96f3a --- /dev/null +++ b/test/tests/postprocessors/side_integrated_value/foam/constant/g @@ -0,0 +1,21 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 10 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class uniformDimensionedVectorField; + location "constant"; + object g; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 1 -2 0 0 0 0]; +value (0 0 0); + + +// ************************************************************************* // diff --git a/test/tests/postprocessors/side_integrated_value/foam/constant/momentumTransport b/test/tests/postprocessors/side_integrated_value/foam/constant/momentumTransport new file mode 100644 index 00000000..0416f1a9 --- /dev/null +++ b/test/tests/postprocessors/side_integrated_value/foam/constant/momentumTransport @@ -0,0 +1,18 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 10 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + object RASProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +simulationType laminar; + +// ************************************************************************* // diff --git a/test/tests/postprocessors/side_integrated_value/foam/constant/physicalProperties b/test/tests/postprocessors/side_integrated_value/foam/constant/physicalProperties new file mode 100644 index 00000000..20dafc61 --- /dev/null +++ b/test/tests/postprocessors/side_integrated_value/foam/constant/physicalProperties @@ -0,0 +1,52 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 10 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + location "constant"; + object physicalProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +thermoType +{ + type heRhoThermo; + mixture pureMixture; + transport const; + thermo hConst; + equationOfState rhoConst; + specie specie; + energy sensibleEnthalpy; +} + +mixture +{ + specie + { + molWeight 1; + } + thermodynamics + { + Cp 1; // Specific heat capacity [J/(kg·K)] + Hf 1; // Heat of formation [J/kg] + Tref 0; + } + transport + { + kappa 1; // Thermal conductivity [W/(m·K)] + mu 1.; + } + equationOfState + { + rho 1; // Density [kg/m^3] + } +} + + +// ************************************************************************* // diff --git a/test/tests/postprocessors/side_integrated_value/foam/system/blockMeshDict b/test/tests/postprocessors/side_integrated_value/foam/system/blockMeshDict new file mode 100644 index 00000000..face9ea6 --- /dev/null +++ b/test/tests/postprocessors/side_integrated_value/foam/system/blockMeshDict @@ -0,0 +1,85 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object blockMeshDict; +} + +vertices +( + ( 0.0 0.0 0.0 ) + ( 10.0 0.0 0.0 ) + ( 10.0 1.0 0.0 ) + ( 0.0 1.0 0.0 ) + + ( 0.0 0.0 1.0) + ( 10.0 0.0 1.0) + ( 10.0 1.0 1.0) + ( 0.0 1.0 1.0) +); + +blocks +( + hex (0 1 2 3 4 5 6 7) (50 1 1) simpleGrading (25 1 1) +); + +boundary +( + + // interface + left + { + type wall; + faces + ( + (4 7 3 0) + ); + } + + right + { + type wall; + faces + ( + (6 5 1 2) + ); + } + + top + { + type wall; + faces + ( + (2 3 7 6) + ); + } + + front + { + type wall; + faces + ( + (3 2 1 0) + ); + } + + bottom + { + type wall; + faces + ( + (0 1 5 4) + ); + } + + back + { + type wall; + faces + ( + (4 5 6 7) + ); + } + +); diff --git a/test/tests/postprocessors/side_integrated_value/foam/system/controlDict b/test/tests/postprocessors/side_integrated_value/foam/system/controlDict new file mode 100644 index 00000000..4e2baf59 --- /dev/null +++ b/test/tests/postprocessors/side_integrated_value/foam/system/controlDict @@ -0,0 +1,44 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 10 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + object controlDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +solver postprocessorTestSolver; + +startFrom startTime; + +startTime 0; + +stopAt endTime; + +endTime 0.32; + +deltaT 0.01; + +writeControl timeStep; + +writeInterval 1; + +writeFormat ascii; + +writePrecision 20; + +writeCompression off; + +timeFormat general; + +timePrecision 20; + +runTimeModifiable true; + +// ************************************************************************* // diff --git a/test/tests/postprocessors/side_integrated_value/foam/system/decomposeParDict b/test/tests/postprocessors/side_integrated_value/foam/system/decomposeParDict new file mode 100644 index 00000000..0204a6b9 --- /dev/null +++ b/test/tests/postprocessors/side_integrated_value/foam/system/decomposeParDict @@ -0,0 +1,42 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 10 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + location "system"; + object decomposeParDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +numberOfSubdomains 2; + +method simple; + +simpleCoeffs +{ + n (2 1 1); +} + +hierarchicalCoeffs +{ + n (1 1 1); + order xyz; +} + +manualCoeffs +{ + dataFile ""; +} + +distributed no; + +roots ( ); + + +// ************************************************************************* // diff --git a/test/tests/postprocessors/side_integrated_value/foam/system/fvSchemes b/test/tests/postprocessors/side_integrated_value/foam/system/fvSchemes new file mode 100644 index 00000000..787f3b83 --- /dev/null +++ b/test/tests/postprocessors/side_integrated_value/foam/system/fvSchemes @@ -0,0 +1,51 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 12 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + object fvSchemes; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +ddtSchemes +{ + default Euler; +} + +gradSchemes +{ + default Gauss linear; +} + +divSchemes +{ + default none; + + div(phi,U) Gauss linear; + div(phi,K) Gauss linear; + div(phi,h) Gauss linear; + div(((rho*nuEff)*dev2(T(grad(U))))) Gauss linear; +} + +laplacianSchemes +{ + default Gauss linear corrected; +} + +interpolationSchemes +{ + default linear; +} + +snGradSchemes +{ + default corrected; +} + +// ************************************************************************* // diff --git a/test/tests/postprocessors/side_integrated_value/foam/system/fvSolution b/test/tests/postprocessors/side_integrated_value/foam/system/fvSolution new file mode 100644 index 00000000..61143b21 --- /dev/null +++ b/test/tests/postprocessors/side_integrated_value/foam/system/fvSolution @@ -0,0 +1,61 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 12 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + object fvSolution; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +solvers +{ + rho + { + solver diagonal; + } + + rhoFinal + { + $rho; + } + + + "(U|h|p_rgh)" + { + solver PBiCGStab; + preconditioner DILU; + tolerance 1e-8; + relTol 1e-8; + } + + "(U|h|p_rgh)Final" + { + $U; + tolerance 1e-8; + relTol 1e-8; + } +} + +PIMPLE +{ + momentumPredictor yes; + pRefCell 0; + pRefValue 0; +} + +relaxationFactors +{ + equations + { + h 1; + U 1; + } +} + +// ************************************************************************* // diff --git a/test/tests/postprocessors/side_integrated_value/gold/main_out.csv b/test/tests/postprocessors/side_integrated_value/gold/main_out.csv new file mode 100644 index 00000000..31f72787 --- /dev/null +++ b/test/tests/postprocessors/side_integrated_value/gold/main_out.csv @@ -0,0 +1,34 @@ +time,U_avg_magnitude,U_avg_normal,U_avg_x,U_avg_y,U_avg_z,t_avg +0,0,0,0,0,0,0 +0.01,22.360679774998,10,20,-10,0,0.1 +0.02,22.360679774998,10,20,-10,0,0.2 +0.03,22.360679774998,10,20,-10,0,0.3 +0.04,22.360679774998,10,20,-10,0,0.4 +0.05,22.360679774998,10,20,-10,0,0.5 +0.06,22.360679774998,10,20,-10,0,0.6 +0.07,22.360679774998,10,20,-10,0,0.7 +0.08,22.360679774998,10,20,-10,0,0.8 +0.09,22.360679774998,10,20,-10,0,0.9 +0.1,22.360679774998,10,20,-10,0,1 +0.11,22.360679774998,10,20,-10,0,1.1 +0.12,22.360679774998,10,20,-10,0,1.2 +0.13,22.360679774998,10,20,-10,0,1.3 +0.14,22.360679774998,10,20,-10,0,1.4 +0.15,22.360679774998,10,20,-10,0,1.5 +0.16,22.360679774998,10,20,-10,0,1.6 +0.17,22.360679774998,10,20,-10,0,1.7 +0.18,22.360679774998,10,20,-10,0,1.8 +0.19,22.360679774998,10,20,-10,0,1.9 +0.2,22.360679774998,10,20,-10,0,2 +0.21,22.360679774998,10,20,-10,0,2.1 +0.22,22.360679774998,10,20,-10,0,2.2 +0.23,22.360679774998,10,20,-10,0,2.3 +0.24,22.360679774998,10,20,-10,0,2.4 +0.25,22.360679774998,10,20,-10,0,2.5 +0.26,22.360679774998,10,20,-10,0,2.6 +0.27,22.360679774998,10,20,-10,0,2.7 +0.28,22.360679774998,10,20,-10,0,2.8 +0.29,22.360679774998,10,20,-10,0,2.9 +0.3,22.360679774998,10,20,-10,0,3 +0.31,22.360679774998,10,20,-10,0,3.1 +0.32,22.360679774998,10,20,-10,0,3.2 diff --git a/test/tests/postprocessors/side_integrated_value/main.i b/test/tests/postprocessors/side_integrated_value/main.i new file mode 100644 index 00000000..7587fcf6 --- /dev/null +++ b/test/tests/postprocessors/side_integrated_value/main.i @@ -0,0 +1,75 @@ +[Mesh] + type = FoamMesh + case = 'foam' + foam_patch = 'right top' +[] + +[Variables] + [dummy] + family = MONOMIAL + order = CONSTANT + initial_condition = 999 + [] +[] + +[Problem] + type = FoamProblem +[] + +[Executioner] + type = Transient + end_time = 0.32 + [TimeSteppers] + [foam] + type = FoamControlledTimeStepper + [] + [] +[] + +[Postprocessors] + [t_avg] + type = FoamSideIntegratedValue + foam_variable = 'T' + boundary = top + execute_on = TIMESTEP_END + [] + [U_avg_magnitude] + type = FoamSideIntegratedValue + foam_variable = 'U' + boundary = back + execute_on = TIMESTEP_END + [] + [U_avg_normal] + type = FoamSideIntegratedValue + foam_variable = 'U' + boundary = bottom + component = normal + execute_on = TIMESTEP_END + [] + [U_avg_x] + type = FoamSideIntegratedValue + foam_variable = 'U' + boundary = front + component = x + execute_on = TIMESTEP_END + [] + [U_avg_y] + type = FoamSideIntegratedValue + foam_variable = 'U' + boundary = back + component = y + execute_on = TIMESTEP_END + [] + [U_avg_z] + type = FoamSideIntegratedValue + foam_variable = 'U' + boundary = front + component = z + execute_on = TIMESTEP_END + [] +[] + +[Outputs] + exodus = false + csv = true +[] diff --git a/test/tests/postprocessors/side_integrated_value/tests b/test/tests/postprocessors/side_integrated_value/tests new file mode 100644 index 00000000..ba09e744 --- /dev/null +++ b/test/tests/postprocessors/side_integrated_value/tests @@ -0,0 +1,40 @@ +[Tests] + [postprocessor_test] + [setup] + type = RunCommand + command = 'bash -c "foamCleanCase -case foam && blockMesh -case foam && decomposePar -case foam"' + [] + [check_csv] + type = CSVDiff + input = main.i + prereq = postprocessor_test/setup + csvdiff = main_out.csv + allow_warnings = true + [] + [check_csv_parallel] + type = CSVDiff + input = main.i + prereq = postprocessor_test/setup + csvdiff = main_out.csv + allow_warnings = true + min_parallel = 2 + max_parallel = 2 + [] + [boundary_err] + type = RunException + input = main.i + prereq = postprocessor_test/setup + allow_warnings = true + cli_args='Postprocessors/t_avg/boundary=top1' + expect_err = "Boundary 'top1' not found in FoamMesh." + [] + [invalid_foam_scalar] + type = RunException + input = main.i + prereq = postprocessor_test/setup + allow_warnings = true + cli_args='Postprocessors/t_avg/foam_variable=T1' + expect_err = "No Foam scalar, vector or function object called 'T1'." + [] + [] +[] From 81fd65b7d3376e91f1d6851b78f02fd326c4e682 Mon Sep 17 00:00:00 2001 From: Matthew Falcone Date: Fri, 16 Jan 2026 14:37:58 +0000 Subject: [PATCH 26/43] Add test for invalid scalars for advective flux integral postprocessor --- .../postprocessors/side_advective_flux_integral/tests | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/tests/postprocessors/side_advective_flux_integral/tests b/test/tests/postprocessors/side_advective_flux_integral/tests index 5680c0d7..96e7ac47 100644 --- a/test/tests/postprocessors/side_advective_flux_integral/tests +++ b/test/tests/postprocessors/side_advective_flux_integral/tests @@ -28,5 +28,13 @@ cli_args='Postprocessors/m_dot_x1/advective_velocity=U1' expect_err = "advective_velocity 'U1' not found." [] + [invalid_scalar] + type = RunException + input = main.i + prereq = postprocessor_test/setup + allow_warnings = true + cli_args='Postprocessors/m_dot_x1/foam_scalar=rho1' + expect_err = "foam_scalar 'rho1' not found." + [] [] [] From efa55c4a443f0d092d07ea0156687f563b25fcd6 Mon Sep 17 00:00:00 2001 From: Matthew Falcone Date: Fri, 16 Jan 2026 15:43:17 +0000 Subject: [PATCH 27/43] Add test for wallHeatFlux (using function objects) --- .../postprocessorTestSolver.C | 11 ++- .../side_average/gold/main_out.csv | 64 ++++++++--------- .../foam/system/blockMeshDict | 2 +- .../side_integrated_value/gold/main_out.csv | 68 +++++++++---------- .../side_integrated_value/main.i | 7 ++ 5 files changed, 84 insertions(+), 68 deletions(-) diff --git a/test/OpenFOAM/modules/postprocessorTestSolver/postprocessorTestSolver.C b/test/OpenFOAM/modules/postprocessorTestSolver/postprocessorTestSolver.C index 35cce124..2add8c28 100644 --- a/test/OpenFOAM/modules/postprocessorTestSolver/postprocessorTestSolver.C +++ b/test/OpenFOAM/modules/postprocessorTestSolver/postprocessorTestSolver.C @@ -23,6 +23,7 @@ License \*---------------------------------------------------------------------------*/ +#include "DimensionedField.H" #include "dimensionSets.H" #include "dimensionedScalar.H" #include "dimensionedVector.H" @@ -30,6 +31,9 @@ License #include "postprocessorTestSolver.H" #include "fvMeshMover.H" #include "addToRunTimeSelectionTable.H" +#include "scalar.H" +#include "volFieldsFwd.H" +#include "volMesh.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -92,7 +96,12 @@ Foam::solvers::postprocessorTestSolver::thermophysicalPredictor() // Set e to Cv*(xy + yz + xz)t which gives a non-uniform be first order value of wall heat flux at // all boundaries. - dimensioned t("t", thermo_.T().dimensions(), mesh_.time().userTimeValue()); + // auto x_mesh = + volScalarField t(IOobject("0", "0", mesh_), + mesh_, + dimTemperature, + time().userTimeValue() * mesh_.C().component(0)->internalField(), + time().userTimeValue() * mesh_.C().component(0)->boundaryField()); h = Cp * t; thermo_.correct(); diff --git a/test/tests/postprocessors/side_average/gold/main_out.csv b/test/tests/postprocessors/side_average/gold/main_out.csv index c3bf1a97..f050f207 100644 --- a/test/tests/postprocessors/side_average/gold/main_out.csv +++ b/test/tests/postprocessors/side_average/gold/main_out.csv @@ -1,34 +1,34 @@ time,U_avg_magnitude,U_avg_normal,U_avg_x,U_avg_y,U_avg_z,t_avg 0,0,0,0,0,0,0 -0.01,2.2360679774998,2,2,-1,0,0.01 -0.02,2.2360679774998,2,2,-1,0,0.02 -0.03,2.2360679774998,2,2,-1,0,0.03 -0.04,2.2360679774998,2,2,-1,0,0.04 -0.05,2.2360679774998,2,2,-1,0,0.05 -0.06,2.2360679774998,2,2,-1,0,0.06 -0.07,2.2360679774998,2,2,-1,0,0.07 -0.08,2.2360679774998,2,2,-1,0,0.08 -0.09,2.2360679774998,2,2,-1,0,0.09 -0.1,2.2360679774998,2,2,-1,0,0.1 -0.11,2.2360679774998,2,2,-1,0,0.11 -0.12,2.2360679774998,2,2,-1,0,0.12 -0.13,2.2360679774998,2,2,-1,0,0.13 -0.14,2.2360679774998,2,2,-1,0,0.14 -0.15,2.2360679774998,2,2,-1,0,0.15 -0.16,2.2360679774998,2,2,-1,0,0.16 -0.17,2.2360679774998,2,2,-1,0,0.17 -0.18,2.2360679774998,2,2,-1,0,0.18 -0.19,2.2360679774998,2,2,-1,0,0.19 -0.2,2.2360679774998,2,2,-1,0,0.2 -0.21,2.2360679774998,2,2,-1,0,0.21 -0.22,2.2360679774998,2,2,-1,0,0.22 -0.23,2.2360679774998,2,2,-1,0,0.23 -0.24,2.2360679774998,2,2,-1,0,0.24 -0.25,2.2360679774998,2,2,-1,0,0.25 -0.26,2.2360679774998,2,2,-1,0,0.26 -0.27,2.2360679774998,2,2,-1,0,0.27 -0.28,2.2360679774998,2,2,-1,0,0.28 -0.29,2.2360679774998,2,2,-1,0,0.29 -0.3,2.2360679774998,2,2,-1,0,0.3 -0.31,2.2360679774998,2,2,-1,0,0.31 -0.32,2.2360679774998,2,2,-1,0,0.32 +0.01,2.2360679774998,2,2,-1,0,0.05 +0.02,2.2360679774998,2,2,-1,0,0.1 +0.03,2.2360679774998,2,2,-1,0,0.15 +0.04,2.2360679774998,2,2,-1,0,0.2 +0.05,2.2360679774998,2,2,-1,0,0.25 +0.06,2.2360679774998,2,2,-1,0,0.3 +0.07,2.2360679774998,2,2,-1,0,0.35 +0.08,2.2360679774998,2,2,-1,0,0.4 +0.09,2.2360679774998,2,2,-1,0,0.45 +0.1,2.2360679774998,2,2,-1,0,0.5 +0.11,2.2360679774998,2,2,-1,0,0.55 +0.12,2.2360679774998,2,2,-1,0,0.6 +0.13,2.2360679774998,2,2,-1,0,0.65 +0.14,2.2360679774998,2,2,-1,0,0.7 +0.15,2.2360679774998,2,2,-1,0,0.75 +0.16,2.2360679774998,2,2,-1,0,0.8 +0.17,2.2360679774998,2,2,-1,0,0.85 +0.18,2.2360679774998,2,2,-1,0,0.9 +0.19,2.2360679774998,2,2,-1,0,0.95 +0.2,2.2360679774998,2,2,-1,0,1 +0.21,2.2360679774998,2,2,-1,0,1.05 +0.22,2.2360679774998,2,2,-1,0,1.1 +0.23,2.2360679774998,2,2,-1,0,1.15 +0.24,2.2360679774998,2,2,-1,0,1.2 +0.25,2.2360679774998,2,2,-1,0,1.25 +0.26,2.2360679774998,2,2,-1,0,1.3 +0.27,2.2360679774998,2,2,-1,0,1.35 +0.28,2.2360679774998,2,2,-1,0,1.4 +0.29,2.2360679774998,2,2,-1,0,1.45 +0.3,2.2360679774998,2,2,-1,0,1.5 +0.31,2.2360679774998,2,2,-1,0,1.55 +0.32,2.2360679774998,2,2,-1,0,1.6 diff --git a/test/tests/postprocessors/side_integrated_value/foam/system/blockMeshDict b/test/tests/postprocessors/side_integrated_value/foam/system/blockMeshDict index face9ea6..a59719de 100644 --- a/test/tests/postprocessors/side_integrated_value/foam/system/blockMeshDict +++ b/test/tests/postprocessors/side_integrated_value/foam/system/blockMeshDict @@ -21,7 +21,7 @@ vertices blocks ( - hex (0 1 2 3 4 5 6 7) (50 1 1) simpleGrading (25 1 1) + hex (0 1 2 3 4 5 6 7) (50 1 1) simpleGrading (1 1 1) ); boundary diff --git a/test/tests/postprocessors/side_integrated_value/gold/main_out.csv b/test/tests/postprocessors/side_integrated_value/gold/main_out.csv index 31f72787..b79f6082 100644 --- a/test/tests/postprocessors/side_integrated_value/gold/main_out.csv +++ b/test/tests/postprocessors/side_integrated_value/gold/main_out.csv @@ -1,34 +1,34 @@ -time,U_avg_magnitude,U_avg_normal,U_avg_x,U_avg_y,U_avg_z,t_avg -0,0,0,0,0,0,0 -0.01,22.360679774998,10,20,-10,0,0.1 -0.02,22.360679774998,10,20,-10,0,0.2 -0.03,22.360679774998,10,20,-10,0,0.3 -0.04,22.360679774998,10,20,-10,0,0.4 -0.05,22.360679774998,10,20,-10,0,0.5 -0.06,22.360679774998,10,20,-10,0,0.6 -0.07,22.360679774998,10,20,-10,0,0.7 -0.08,22.360679774998,10,20,-10,0,0.8 -0.09,22.360679774998,10,20,-10,0,0.9 -0.1,22.360679774998,10,20,-10,0,1 -0.11,22.360679774998,10,20,-10,0,1.1 -0.12,22.360679774998,10,20,-10,0,1.2 -0.13,22.360679774998,10,20,-10,0,1.3 -0.14,22.360679774998,10,20,-10,0,1.4 -0.15,22.360679774998,10,20,-10,0,1.5 -0.16,22.360679774998,10,20,-10,0,1.6 -0.17,22.360679774998,10,20,-10,0,1.7 -0.18,22.360679774998,10,20,-10,0,1.8 -0.19,22.360679774998,10,20,-10,0,1.9 -0.2,22.360679774998,10,20,-10,0,2 -0.21,22.360679774998,10,20,-10,0,2.1 -0.22,22.360679774998,10,20,-10,0,2.2 -0.23,22.360679774998,10,20,-10,0,2.3 -0.24,22.360679774998,10,20,-10,0,2.4 -0.25,22.360679774998,10,20,-10,0,2.5 -0.26,22.360679774998,10,20,-10,0,2.6 -0.27,22.360679774998,10,20,-10,0,2.7 -0.28,22.360679774998,10,20,-10,0,2.8 -0.29,22.360679774998,10,20,-10,0,2.9 -0.3,22.360679774998,10,20,-10,0,3 -0.31,22.360679774998,10,20,-10,0,3.1 -0.32,22.360679774998,10,20,-10,0,3.2 +time,U_avg_magnitude,U_avg_normal,U_avg_x,U_avg_y,U_avg_z,heat_flux,t_avg +0,0,0,0,0,0,0,0 +0.01,22.360679774998,10,20,-10,0,0.01,0.5 +0.02,22.360679774998,10,20,-10,0,0.02,1 +0.03,22.360679774998,10,20,-10,0,0.03,1.5 +0.04,22.360679774998,10,20,-10,0,0.04,2 +0.05,22.360679774998,10,20,-10,0,0.05,2.5 +0.06,22.360679774998,10,20,-10,0,0.06,3 +0.07,22.360679774998,10,20,-10,0,0.07,3.5 +0.08,22.360679774998,10,20,-10,0,0.08,4 +0.09,22.360679774998,10,20,-10,0,0.09,4.5 +0.1,22.360679774998,10,20,-10,0,0.1,5 +0.11,22.360679774998,10,20,-10,0,0.11,5.5 +0.12,22.360679774998,10,20,-10,0,0.12,6 +0.13,22.360679774998,10,20,-10,0,0.13,6.5 +0.14,22.360679774998,10,20,-10,0,0.14,7 +0.15,22.360679774998,10,20,-10,0,0.15,7.5 +0.16,22.360679774998,10,20,-10,0,0.16,8 +0.17,22.360679774998,10,20,-10,0,0.17,8.5 +0.18,22.360679774998,10,20,-10,0,0.18,9 +0.19,22.360679774998,10,20,-10,0,0.19,9.5 +0.2,22.360679774998,10,20,-10,0,0.2,10 +0.21,22.360679774998,10,20,-10,0,0.21,10.5 +0.22,22.360679774998,10,20,-10,0,0.22,11 +0.23,22.360679774998,10,20,-10,0,0.23,11.5 +0.24,22.360679774998,10,20,-10,0,0.24,12 +0.25,22.360679774998,10,20,-10,0,0.25,12.5 +0.26,22.360679774998,10,20,-10,0,0.26,13 +0.27,22.360679774998,10,20,-10,0,0.27,13.5 +0.28,22.360679774998,10,20,-10,0,0.28,14 +0.29,22.360679774998,10,20,-10,0,0.29,14.5 +0.3,22.360679774998,10,20,-10,0,0.3,15 +0.31,22.360679774998,10,20,-10,0,0.31,15.5 +0.32,22.360679774998,10,20,-10,0,0.32,16 diff --git a/test/tests/postprocessors/side_integrated_value/main.i b/test/tests/postprocessors/side_integrated_value/main.i index 7587fcf6..1f36a779 100644 --- a/test/tests/postprocessors/side_integrated_value/main.i +++ b/test/tests/postprocessors/side_integrated_value/main.i @@ -67,6 +67,13 @@ component = z execute_on = TIMESTEP_END [] + [heat_flux] + type = FoamSideIntegratedValue + foam_variable = 'wallHeatFlux' + boundary = right + component = x + execute_on = TIMESTEP_END + [] [] [Outputs] From a783bd9d188df3619ebc041373f9d7cb3082a9e7 Mon Sep 17 00:00:00 2001 From: Matthew Falcone Date: Fri, 16 Jan 2026 15:53:49 +0000 Subject: [PATCH 28/43] Fix file ends in foam_modules.mk --- test/OpenFOAM/foam_modules.mk | 1 - 1 file changed, 1 deletion(-) diff --git a/test/OpenFOAM/foam_modules.mk b/test/OpenFOAM/foam_modules.mk index 5f46dcf9..80bf70a8 100644 --- a/test/OpenFOAM/foam_modules.mk +++ b/test/OpenFOAM/foam_modules.mk @@ -12,4 +12,3 @@ build_foam_tests: @$(MAKE) -s -j $(MOOSE_JOBS) test/OpenFOAM/modules/laplacianTestSolver/ @$(MAKE) -s -j $(MOOSE_JOBS) test/OpenFOAM/modules/odeTestSolver/ @$(MAKE) -s -j $(MOOSE_JOBS) test/OpenFOAM/modules/postprocessorTestSolver/ - From 111024558b3811202d810a47fe3fc821f4738820 Mon Sep 17 00:00:00 2001 From: Matthew Falcone Date: Thu, 29 Jan 2026 13:31:43 +0000 Subject: [PATCH 29/43] Incorporate initial review changes --- .../postprocessors/FoamPostprocessorBase.h | 2 +- .../postprocessors/FoamSideIntegratedValue.h | 3 ++- src/postprocessors/FoamPostprocessorBase.C | 6 ----- src/postprocessors/FoamSideAverageValue.C | 8 +++--- src/postprocessors/FoamSideIntegratedValue.C | 16 ++++++----- .../modules/functionTestSolver/Make/files | 2 +- .../modules/laplacianTestSolver/Make/files | 2 +- .../OpenFOAM/modules/odeTestSolver/Make/files | 2 +- .../postprocessorTestSolver.H | 2 +- .../postprocessors/FoamTestPostprocessor.h | 27 ------------------- 10 files changed, 21 insertions(+), 49 deletions(-) delete mode 100644 test/include/postprocessors/FoamTestPostprocessor.h diff --git a/include/postprocessors/FoamPostprocessorBase.h b/include/postprocessors/FoamPostprocessorBase.h index 7847fc1e..e3e614f0 100644 --- a/include/postprocessors/FoamPostprocessorBase.h +++ b/include/postprocessors/FoamPostprocessorBase.h @@ -21,7 +21,7 @@ class FoamPostprocessorBase : public ElementUserObject, public Postprocessor virtual void finalize() final; - virtual void threadJoin(const UserObject & uo) final; + virtual void threadJoin([[maybe_unused]] const UserObject & uo) final {}; // Compute postprocessor, to be called within FoamProblem virtual void compute() = 0; diff --git a/include/postprocessors/FoamSideIntegratedValue.h b/include/postprocessors/FoamSideIntegratedValue.h index fb29aaa1..bc221656 100644 --- a/include/postprocessors/FoamSideIntegratedValue.h +++ b/include/postprocessors/FoamSideIntegratedValue.h @@ -2,6 +2,7 @@ #include "FoamSidePostprocessor.h" #include #include +#include static MooseEnum _pp_function_objects("wallHeatFlux wallShearStress"); @@ -26,5 +27,5 @@ class FoamSideIntegratedValue : public FoamSidePostprocessor bool _is_vector; - Foam::functionObject * _function_object; + std::unique_ptr _function_object; }; diff --git a/src/postprocessors/FoamPostprocessorBase.C b/src/postprocessors/FoamPostprocessorBase.C index 636ed10f..90c2b05c 100644 --- a/src/postprocessors/FoamPostprocessorBase.C +++ b/src/postprocessors/FoamPostprocessorBase.C @@ -37,9 +37,3 @@ void FoamPostprocessorBase::finalize() { } - -void -FoamPostprocessorBase::threadJoin(const UserObject & uo) -{ - (void)uo; -} diff --git a/src/postprocessors/FoamSideAverageValue.C b/src/postprocessors/FoamSideAverageValue.C index 0b53fd28..f95041fb 100644 --- a/src/postprocessors/FoamSideAverageValue.C +++ b/src/postprocessors/FoamSideAverageValue.C @@ -16,19 +16,19 @@ FoamSideAverageValue::compute() FoamSideIntegratedValue::compute(); - Real volume = 0.; + Real area = 0.; // loop over boundary ids for (auto & boundary : _boundary) { auto & areas = _foam_mesh->boundary()[boundary].magSf(); for (int i = 0; i < areas.size(); ++i) { - volume += areas[i]; + area += areas[i]; } } // sum over ranks - gatherSum(volume); + gatherSum(area); // divide by area - _value /= volume; + _value /= area; } diff --git a/src/postprocessors/FoamSideIntegratedValue.C b/src/postprocessors/FoamSideIntegratedValue.C index cf045ebc..4e76613a 100644 --- a/src/postprocessors/FoamSideIntegratedValue.C +++ b/src/postprocessors/FoamSideIntegratedValue.C @@ -32,8 +32,7 @@ FoamSideIntegratedValue::FoamSideIntegratedValue(const InputParameters & params) { // Create function object if the foam variable matches one of the // available function objects - if (_pp_function_objects.find(_foam_variable) != _pp_function_objects.items().end()) - createFunctionObject(); + createFunctionObject(); // determine if this is a vector scalar, ahead of computation if (_foam_mesh->foundObject(_foam_variable)) @@ -45,6 +44,9 @@ FoamSideIntegratedValue::FoamSideIntegratedValue(const InputParameters & params) void FoamSideIntegratedValue::createFunctionObject() { + if (_pp_function_objects.find(_foam_variable) == _pp_function_objects.items().end()) + return; + auto fo_dict = _foam_mesh->time().controlDict().lookupOrDefault(_foam_variable, Foam::dictionary()); @@ -55,15 +57,17 @@ FoamSideIntegratedValue::createFunctionObject() if (_foam_variable == "wallHeatFlux") { - _function_object = static_cast( - new Foam::functionObjects::wallHeatFlux("wallHeatFlux", _foam_mesh->time(), fo_dict)); + _function_object.reset(static_cast( + new Foam::functionObjects::wallHeatFlux("wallHeatFlux", _foam_mesh->time(), fo_dict))); } else if (_foam_variable == "wallShearStress") { - _function_object = static_cast( - new Foam::functionObjects::wallShearStress("wallShearStress", _foam_mesh->time(), fo_dict)); + _function_object.reset( + static_cast(new Foam::functionObjects::wallShearStress( + "wallShearStress", _foam_mesh->time(), fo_dict))); } + // This is required to create scalar or vector fields at initialisation. _function_object->execute(); } diff --git a/test/OpenFOAM/modules/functionTestSolver/Make/files b/test/OpenFOAM/modules/functionTestSolver/Make/files index e586ede8..d97f57e4 100644 --- a/test/OpenFOAM/modules/functionTestSolver/Make/files +++ b/test/OpenFOAM/modules/functionTestSolver/Make/files @@ -1,3 +1,3 @@ -functionTestSolver.C +SOURCE += functionTestSolver.C LIB = $(FOAM_USER_LIBBIN)/libfunctionTestSolver diff --git a/test/OpenFOAM/modules/laplacianTestSolver/Make/files b/test/OpenFOAM/modules/laplacianTestSolver/Make/files index 8b6888f6..80aaef16 100644 --- a/test/OpenFOAM/modules/laplacianTestSolver/Make/files +++ b/test/OpenFOAM/modules/laplacianTestSolver/Make/files @@ -1,3 +1,3 @@ -laplacianTestSolver.C +SOURCE += laplacianTestSolver.C LIB = $(FOAM_USER_LIBBIN)/liblaplacianTestSolver diff --git a/test/OpenFOAM/modules/odeTestSolver/Make/files b/test/OpenFOAM/modules/odeTestSolver/Make/files index ce5757f0..467ac083 100644 --- a/test/OpenFOAM/modules/odeTestSolver/Make/files +++ b/test/OpenFOAM/modules/odeTestSolver/Make/files @@ -1,3 +1,3 @@ -odeTestSolver.C +SOURCE += odeTestSolver.C LIB = $(FOAM_USER_LIBBIN)/libodeTestSolver diff --git a/test/OpenFOAM/modules/postprocessorTestSolver/postprocessorTestSolver.H b/test/OpenFOAM/modules/postprocessorTestSolver/postprocessorTestSolver.H index 19d098f3..8a8a799c 100644 --- a/test/OpenFOAM/modules/postprocessorTestSolver/postprocessorTestSolver.H +++ b/test/OpenFOAM/modules/postprocessorTestSolver/postprocessorTestSolver.H @@ -25,7 +25,7 @@ Class Foam::solvers::postprocessorTestSolver Description - Solver module for to test transfers between OpenFOAM and MOOSE. Based on Solid + Solver module to test OpenFOAM-specifc Postprocessors. Based on Solid solver SourceFiles diff --git a/test/include/postprocessors/FoamTestPostprocessor.h b/test/include/postprocessors/FoamTestPostprocessor.h deleted file mode 100644 index 9e3d5193..00000000 --- a/test/include/postprocessors/FoamTestPostprocessor.h +++ /dev/null @@ -1,27 +0,0 @@ -#pragma once - -#include "FoamSidePostprocessor.h" -#include "InputParameters.h" -#include "MooseTypes.h" -#include "UserObject.h" - -class FoamTestPostprocessor : public FoamSidePostprocessor -{ -public: - static InputParameters validParams(); - - FoamTestPostprocessor(const InputParameters & params); - - virtual void execute() override; - - virtual void initialize() override; - - virtual void finalize() override; - - virtual void threadJoin(const UserObject & uo) override; - - virtual PostprocessorValue getValue() const override; - -protected: - Real _value; -}; From d99f673cefd1a4c47811565567f762a2e959ebc0 Mon Sep 17 00:00:00 2001 From: Matthew Falcone Date: Thu, 29 Jan 2026 15:11:46 +0000 Subject: [PATCH 30/43] Add tests for multiple boundaries for side advective flux integral --- .../gold/main_out.csv | 68 +++++++++---------- .../side_advective_flux_integral/main.i | 15 ++++ 2 files changed, 49 insertions(+), 34 deletions(-) diff --git a/test/tests/postprocessors/side_advective_flux_integral/gold/main_out.csv b/test/tests/postprocessors/side_advective_flux_integral/gold/main_out.csv index f77363ec..e82176d3 100644 --- a/test/tests/postprocessors/side_advective_flux_integral/gold/main_out.csv +++ b/test/tests/postprocessors/side_advective_flux_integral/gold/main_out.csv @@ -1,34 +1,34 @@ -time,m_dot_x1,m_dot_x2,m_dot_y1,m_dot_y2,m_dot_z1,m_dot_z2 -0,0,0,0,0,0,0 -0.01,-1,1,5,-5,-3.6347636898442e-17,0 -0.02,-1,1,5,-5,-3.6347636898442e-17,0 -0.03,-1,1,5,-5,-3.6347636898442e-17,0 -0.04,-1,1,5,-5,-3.6347636898442e-17,0 -0.05,-1,1,5,-5,-3.6347636898442e-17,0 -0.06,-1,1,5,-5,-3.6347636898442e-17,0 -0.07,-1,1,5,-5,-3.6347636898442e-17,0 -0.08,-1,1,5,-5,-3.6347636898442e-17,0 -0.09,-1,1,5,-5,-3.6347636898442e-17,0 -0.1,-1,1,5,-5,-3.6347636898442e-17,0 -0.11,-1,1,5,-5,-3.6347636898442e-17,0 -0.12,-1,1,5,-5,-3.6347636898442e-17,0 -0.13,-1,1,5,-5,-3.6347636898442e-17,0 -0.14,-1,1,5,-5,-3.6347636898442e-17,0 -0.15,-1,1,5,-5,-3.6347636898442e-17,0 -0.16,-1,1,5,-5,-3.6347636898442e-17,0 -0.17,-1,1,5,-5,-3.6347636898442e-17,0 -0.18,-1,1,5,-5,-3.6347636898442e-17,0 -0.19,-1,1,5,-5,-3.6347636898442e-17,0 -0.2,-1,1,5,-5,-3.6347636898442e-17,0 -0.21,-1,1,5,-5,-3.6347636898442e-17,0 -0.22,-1,1,5,-5,-3.6347636898442e-17,0 -0.23,-1,1,5,-5,-3.6347636898442e-17,0 -0.24,-1,1,5,-5,-3.6347636898442e-17,0 -0.25,-1,1,5,-5,-3.6347636898442e-17,0 -0.26,-1,1,5,-5,-3.6347636898442e-17,0 -0.27,-1,1,5,-5,-3.6347636898442e-17,0 -0.28,-1,1,5,-5,-3.6347636898442e-17,0 -0.29,-1,1,5,-5,-3.6347636898442e-17,0 -0.3,-1,1,5,-5,-3.6347636898442e-17,0 -0.31,-1,1,5,-5,-3.6347636898442e-17,0 -0.32,-1,1,5,-5,-3.6347636898442e-17,0 +time,m_dot_x1,m_dot_x12,m_dot_x2,m_dot_y1,m_dot_y12,m_dot_y2,m_dot_z1,m_dot_z12,m_dot_z2 +0,0,0,0,0,0,0,0,0,0 +0.01,-1,0,1,5,1.3322676295502e-15,-5,-3.6347636898442e-17,-3.6347636898442e-17,0 +0.02,-1,0,1,5,1.3322676295502e-15,-5,-3.6347636898442e-17,-3.6347636898442e-17,0 +0.03,-1,0,1,5,1.3322676295502e-15,-5,-3.6347636898442e-17,-3.6347636898442e-17,0 +0.04,-1,0,1,5,1.3322676295502e-15,-5,-3.6347636898442e-17,-3.6347636898442e-17,0 +0.05,-1,0,1,5,1.3322676295502e-15,-5,-3.6347636898442e-17,-3.6347636898442e-17,0 +0.06,-1,0,1,5,1.3322676295502e-15,-5,-3.6347636898442e-17,-3.6347636898442e-17,0 +0.07,-1,0,1,5,1.3322676295502e-15,-5,-3.6347636898442e-17,-3.6347636898442e-17,0 +0.08,-1,0,1,5,1.3322676295502e-15,-5,-3.6347636898442e-17,-3.6347636898442e-17,0 +0.09,-1,0,1,5,1.3322676295502e-15,-5,-3.6347636898442e-17,-3.6347636898442e-17,0 +0.1,-1,0,1,5,1.3322676295502e-15,-5,-3.6347636898442e-17,-3.6347636898442e-17,0 +0.11,-1,0,1,5,1.3322676295502e-15,-5,-3.6347636898442e-17,-3.6347636898442e-17,0 +0.12,-1,0,1,5,1.3322676295502e-15,-5,-3.6347636898442e-17,-3.6347636898442e-17,0 +0.13,-1,0,1,5,1.3322676295502e-15,-5,-3.6347636898442e-17,-3.6347636898442e-17,0 +0.14,-1,0,1,5,1.3322676295502e-15,-5,-3.6347636898442e-17,-3.6347636898442e-17,0 +0.15,-1,0,1,5,1.3322676295502e-15,-5,-3.6347636898442e-17,-3.6347636898442e-17,0 +0.16,-1,0,1,5,1.3322676295502e-15,-5,-3.6347636898442e-17,-3.6347636898442e-17,0 +0.17,-1,0,1,5,1.3322676295502e-15,-5,-3.6347636898442e-17,-3.6347636898442e-17,0 +0.18,-1,0,1,5,1.3322676295502e-15,-5,-3.6347636898442e-17,-3.6347636898442e-17,0 +0.19,-1,0,1,5,1.3322676295502e-15,-5,-3.6347636898442e-17,-3.6347636898442e-17,0 +0.2,-1,0,1,5,1.3322676295502e-15,-5,-3.6347636898442e-17,-3.6347636898442e-17,0 +0.21,-1,0,1,5,1.3322676295502e-15,-5,-3.6347636898442e-17,-3.6347636898442e-17,0 +0.22,-1,0,1,5,1.3322676295502e-15,-5,-3.6347636898442e-17,-3.6347636898442e-17,0 +0.23,-1,0,1,5,1.3322676295502e-15,-5,-3.6347636898442e-17,-3.6347636898442e-17,0 +0.24,-1,0,1,5,1.3322676295502e-15,-5,-3.6347636898442e-17,-3.6347636898442e-17,0 +0.25,-1,0,1,5,1.3322676295502e-15,-5,-3.6347636898442e-17,-3.6347636898442e-17,0 +0.26,-1,0,1,5,1.3322676295502e-15,-5,-3.6347636898442e-17,-3.6347636898442e-17,0 +0.27,-1,0,1,5,1.3322676295502e-15,-5,-3.6347636898442e-17,-3.6347636898442e-17,0 +0.28,-1,0,1,5,1.3322676295502e-15,-5,-3.6347636898442e-17,-3.6347636898442e-17,0 +0.29,-1,0,1,5,1.3322676295502e-15,-5,-3.6347636898442e-17,-3.6347636898442e-17,0 +0.3,-1,0,1,5,1.3322676295502e-15,-5,-3.6347636898442e-17,-3.6347636898442e-17,0 +0.31,-1,0,1,5,1.3322676295502e-15,-5,-3.6347636898442e-17,-3.6347636898442e-17,0 +0.32,-1,0,1,5,1.3322676295502e-15,-5,-3.6347636898442e-17,-3.6347636898442e-17,0 diff --git a/test/tests/postprocessors/side_advective_flux_integral/main.i b/test/tests/postprocessors/side_advective_flux_integral/main.i index d59ce430..129b2bf7 100644 --- a/test/tests/postprocessors/side_advective_flux_integral/main.i +++ b/test/tests/postprocessors/side_advective_flux_integral/main.i @@ -37,6 +37,11 @@ foam_scalar = 'rho' boundary = right [] + [m_dot_x12] + type = FoamSideAdvectiveFluxIntegral + foam_scalar = 'rho' + boundary = 'left right' + [] [m_dot_y1] type = FoamSideAdvectiveFluxIntegral foam_scalar = 'rho' @@ -47,6 +52,11 @@ foam_scalar = 'rho' boundary = top [] + [m_dot_y12] + type = FoamSideAdvectiveFluxIntegral + foam_scalar = 'rho' + boundary = 'bottom top' + [] [m_dot_z1] type = FoamSideAdvectiveFluxIntegral foam_scalar = 'rho' @@ -57,6 +67,11 @@ foam_scalar = 'rho' boundary = front [] + [m_dot_z12] + type = FoamSideAdvectiveFluxIntegral + foam_scalar = 'rho' + boundary = 'front back' + [] [] [Outputs] From 732c09287a0a1ea373aa523c79c9502a130acfe1 Mon Sep 17 00:00:00 2001 From: Matthew Falcone Date: Thu, 29 Jan 2026 15:54:15 +0000 Subject: [PATCH 31/43] Add tests for multiple boundaries for side average value --- .../side_average/gold/main_out.csv | 68 +++++++++---------- test/tests/postprocessors/side_average/main.i | 33 +++++++++ 2 files changed, 67 insertions(+), 34 deletions(-) diff --git a/test/tests/postprocessors/side_average/gold/main_out.csv b/test/tests/postprocessors/side_average/gold/main_out.csv index f050f207..6db3d692 100644 --- a/test/tests/postprocessors/side_average/gold/main_out.csv +++ b/test/tests/postprocessors/side_average/gold/main_out.csv @@ -1,34 +1,34 @@ -time,U_avg_magnitude,U_avg_normal,U_avg_x,U_avg_y,U_avg_z,t_avg -0,0,0,0,0,0,0 -0.01,2.2360679774998,2,2,-1,0,0.05 -0.02,2.2360679774998,2,2,-1,0,0.1 -0.03,2.2360679774998,2,2,-1,0,0.15 -0.04,2.2360679774998,2,2,-1,0,0.2 -0.05,2.2360679774998,2,2,-1,0,0.25 -0.06,2.2360679774998,2,2,-1,0,0.3 -0.07,2.2360679774998,2,2,-1,0,0.35 -0.08,2.2360679774998,2,2,-1,0,0.4 -0.09,2.2360679774998,2,2,-1,0,0.45 -0.1,2.2360679774998,2,2,-1,0,0.5 -0.11,2.2360679774998,2,2,-1,0,0.55 -0.12,2.2360679774998,2,2,-1,0,0.6 -0.13,2.2360679774998,2,2,-1,0,0.65 -0.14,2.2360679774998,2,2,-1,0,0.7 -0.15,2.2360679774998,2,2,-1,0,0.75 -0.16,2.2360679774998,2,2,-1,0,0.8 -0.17,2.2360679774998,2,2,-1,0,0.85 -0.18,2.2360679774998,2,2,-1,0,0.9 -0.19,2.2360679774998,2,2,-1,0,0.95 -0.2,2.2360679774998,2,2,-1,0,1 -0.21,2.2360679774998,2,2,-1,0,1.05 -0.22,2.2360679774998,2,2,-1,0,1.1 -0.23,2.2360679774998,2,2,-1,0,1.15 -0.24,2.2360679774998,2,2,-1,0,1.2 -0.25,2.2360679774998,2,2,-1,0,1.25 -0.26,2.2360679774998,2,2,-1,0,1.3 -0.27,2.2360679774998,2,2,-1,0,1.35 -0.28,2.2360679774998,2,2,-1,0,1.4 -0.29,2.2360679774998,2,2,-1,0,1.45 -0.3,2.2360679774998,2,2,-1,0,1.5 -0.31,2.2360679774998,2,2,-1,0,1.55 -0.32,2.2360679774998,2,2,-1,0,1.6 +time,U_avg_magnitude,U_avg_magnitude_multiple,U_avg_normal,U_avg_normal_multiple,U_avg_x,U_avg_x_multiple,U_avg_y,U_avg_y_multiple,U_avg_z,t_avg,t_avg_multiple +0,0,0,0,0,0,0,0,0,0,0,0 +0.01,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.05,0.05 +0.02,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.1,0.1 +0.03,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.15,0.15 +0.04,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.2,0.2 +0.05,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.25,0.25 +0.06,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.3,0.3 +0.07,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.35,0.35 +0.08,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.4,0.4 +0.09,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.45,0.45 +0.1,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.5,0.5 +0.11,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.55,0.55 +0.12,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.6,0.6 +0.13,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.65,0.65 +0.14,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.7,0.7 +0.15,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.75,0.75 +0.16,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.8,0.8 +0.17,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.85,0.85 +0.18,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.9,0.9 +0.19,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.95,0.95 +0.2,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,1,1 +0.21,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,1.05,1.05 +0.22,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,1.1,1.1 +0.23,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,1.15,1.15 +0.24,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,1.2,1.2 +0.25,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,1.25,1.25 +0.26,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,1.3,1.3 +0.27,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,1.35,1.35 +0.28,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,1.4,1.4 +0.29,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,1.45,1.45 +0.3,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,1.5,1.5 +0.31,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,1.55,1.55 +0.32,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,1.6,1.6 diff --git a/test/tests/postprocessors/side_average/main.i b/test/tests/postprocessors/side_average/main.i index 4d59b508..991cdbd1 100644 --- a/test/tests/postprocessors/side_average/main.i +++ b/test/tests/postprocessors/side_average/main.i @@ -33,12 +33,24 @@ boundary = top execute_on = TIMESTEP_END [] + [t_avg_multiple] # Should be same as t_avg + type = FoamSideAverageValue + foam_variable = 'T' + boundary = 'top bottom' + execute_on = TIMESTEP_END + [] [U_avg_magnitude] type = FoamSideAverageValue foam_variable = 'U' boundary = right execute_on = TIMESTEP_END [] + [U_avg_magnitude_multiple] # Should be the same as U_avg_multitude + type = FoamSideAverageValue + foam_variable = 'U' + boundary = 'left right' + execute_on = TIMESTEP_END + [] [U_avg_normal] type = FoamSideAverageValue foam_variable = 'U' @@ -46,6 +58,13 @@ component = normal execute_on = TIMESTEP_END [] + [U_avg_normal_multiple] # Should be zero, left and right should cancel + type = FoamSideAverageValue + foam_variable = 'U' + boundary = 'right left' + component = normal + execute_on = TIMESTEP_END + [] [U_avg_x] type = FoamSideAverageValue foam_variable = 'U' @@ -53,6 +72,13 @@ component = x execute_on = TIMESTEP_END [] + [U_avg_x_multiple] # Should be same as U_avg_x + type = FoamSideAverageValue + foam_variable = 'U' + boundary = 'left right' + component = x + execute_on = TIMESTEP_END + [] [U_avg_y] type = FoamSideAverageValue foam_variable = 'U' @@ -60,6 +86,13 @@ component = y execute_on = TIMESTEP_END [] + [U_avg_y_multiple] # Should be same as U_avg_y + type = FoamSideAverageValue + foam_variable = 'U' + boundary = 'left right' + component = y + execute_on = TIMESTEP_END + [] [U_avg_z] type = FoamSideAverageValue foam_variable = 'U' From 5cae496fbff1e56661020bfc71e915c6663c576c Mon Sep 17 00:00:00 2001 From: Matthew Falcone Date: Thu, 29 Jan 2026 16:09:02 +0000 Subject: [PATCH 32/43] Add tests for multiple boundaries for side integrated value --- .../side_integrated_value/gold/main_out.csv | 68 +++++++++---------- .../side_integrated_value/main.i | 40 +++++++++++ 2 files changed, 74 insertions(+), 34 deletions(-) diff --git a/test/tests/postprocessors/side_integrated_value/gold/main_out.csv b/test/tests/postprocessors/side_integrated_value/gold/main_out.csv index b79f6082..fc0950cc 100644 --- a/test/tests/postprocessors/side_integrated_value/gold/main_out.csv +++ b/test/tests/postprocessors/side_integrated_value/gold/main_out.csv @@ -1,34 +1,34 @@ -time,U_avg_magnitude,U_avg_normal,U_avg_x,U_avg_y,U_avg_z,heat_flux,t_avg -0,0,0,0,0,0,0,0 -0.01,22.360679774998,10,20,-10,0,0.01,0.5 -0.02,22.360679774998,10,20,-10,0,0.02,1 -0.03,22.360679774998,10,20,-10,0,0.03,1.5 -0.04,22.360679774998,10,20,-10,0,0.04,2 -0.05,22.360679774998,10,20,-10,0,0.05,2.5 -0.06,22.360679774998,10,20,-10,0,0.06,3 -0.07,22.360679774998,10,20,-10,0,0.07,3.5 -0.08,22.360679774998,10,20,-10,0,0.08,4 -0.09,22.360679774998,10,20,-10,0,0.09,4.5 -0.1,22.360679774998,10,20,-10,0,0.1,5 -0.11,22.360679774998,10,20,-10,0,0.11,5.5 -0.12,22.360679774998,10,20,-10,0,0.12,6 -0.13,22.360679774998,10,20,-10,0,0.13,6.5 -0.14,22.360679774998,10,20,-10,0,0.14,7 -0.15,22.360679774998,10,20,-10,0,0.15,7.5 -0.16,22.360679774998,10,20,-10,0,0.16,8 -0.17,22.360679774998,10,20,-10,0,0.17,8.5 -0.18,22.360679774998,10,20,-10,0,0.18,9 -0.19,22.360679774998,10,20,-10,0,0.19,9.5 -0.2,22.360679774998,10,20,-10,0,0.2,10 -0.21,22.360679774998,10,20,-10,0,0.21,10.5 -0.22,22.360679774998,10,20,-10,0,0.22,11 -0.23,22.360679774998,10,20,-10,0,0.23,11.5 -0.24,22.360679774998,10,20,-10,0,0.24,12 -0.25,22.360679774998,10,20,-10,0,0.25,12.5 -0.26,22.360679774998,10,20,-10,0,0.26,13 -0.27,22.360679774998,10,20,-10,0,0.27,13.5 -0.28,22.360679774998,10,20,-10,0,0.28,14 -0.29,22.360679774998,10,20,-10,0,0.29,14.5 -0.3,22.360679774998,10,20,-10,0,0.3,15 -0.31,22.360679774998,10,20,-10,0,0.31,15.5 -0.32,22.360679774998,10,20,-10,0,0.32,16 +time,U_avg_magnitude,U_avg_magnitude_multiple,U_avg_normal,U_avg_normal_multiple,U_avg_x,U_avg_x_multiple,U_avg_y,U_avg_y_multiple,U_avg_z,heat_flux,heat_flux_multiple,t_avg,t_avg_multiple +0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0.01,22.360679774998,44.721359549996,10,7.105427357601e-15,20,40,-10,-20,0,0.01,5.2041704279304e-18,0.5,1 +0.02,22.360679774998,44.721359549996,10,7.105427357601e-15,20,40,-10,-20,0,0.02,1.0408340855861e-17,1,2 +0.03,22.360679774998,44.721359549996,10,7.105427357601e-15,20,40,-10,-20,0,0.03,1.5612511283791e-16,1.5,3 +0.04,22.360679774998,44.721359549996,10,7.105427357601e-15,20,40,-10,-20,0,0.04,2.0816681711722e-17,2,4 +0.05,22.360679774998,44.721359549996,10,7.105427357601e-15,20,40,-10,-20,0,0.05,-1.1102230246252e-16,2.5,5 +0.06,22.360679774998,44.721359549996,10,7.105427357601e-15,20,40,-10,-20,0,0.06,3.0531133177192e-16,3,6 +0.07,22.360679774998,44.721359549996,10,7.105427357601e-15,20,40,-10,-20,0,0.07,1.6653345369377e-16,3.5,7 +0.08,22.360679774998,44.721359549996,10,7.105427357601e-15,20,40,-10,-20,0,0.08,4.1633363423443e-17,4,8 +0.09,22.360679774998,44.721359549996,10,7.105427357601e-15,20,40,-10,-20,0,0.09,-8.3266726846887e-17,4.5,9 +0.1,22.360679774998,44.721359549996,10,7.105427357601e-15,20,40,-10,-20,0,0.1,-2.2204460492503e-16,5,10 +0.11,22.360679774998,44.721359549996,10,7.105427357601e-15,20,40,-10,-20,0,0.11,-3.4694469519536e-16,5.5,11 +0.12,22.360679774998,44.721359549996,10,7.105427357601e-15,20,40,-10,-20,0,0.12,-1.5820678100908e-15,6,12 +0.13,22.360679774998,44.721359549996,10,7.105427357601e-15,20,40,-10,-20,0,0.13,1.6098233857065e-15,6.5,13 +0.14,22.360679774998,44.721359549996,10,7.105427357601e-15,20,40,-10,-20,0,0.14,3.6082248300318e-16,7,14 +0.15,22.360679774998,44.721359549996,10,7.105427357601e-15,20,40,-10,-20,0,0.15,1.3322676295502e-15,7.5,15 +0.16,22.360679774998,44.721359549996,10,7.105427357601e-15,20,40,-10,-20,0,0.16,8.3266726846887e-17,8,16 +0.17,22.360679774998,44.721359549996,10,7.105427357601e-15,20,40,-10,-20,0,0.17,1.0547118733939e-15,8.5,17 +0.18,22.360679774998,44.721359549996,10,7.105427357601e-15,20,40,-10,-20,0,0.18,-1.942890293094e-16,9,18 +0.19,22.360679774998,44.721359549996,10,7.105427357601e-15,20,40,-10,-20,0,0.19,7.7715611723761e-16,9.5,19 +0.2,22.360679774998,44.721359549996,10,7.105427357601e-15,20,40,-10,-20,0,0.2,-4.7184478546569e-16,10,20 +0.21,22.360679774998,44.721359549996,10,7.105427357601e-15,20,40,-10,-20,0,0.21,4.7184478546569e-16,10.5,21 +0.22,22.360679774998,44.721359549996,10,7.105427357601e-15,20,40,-10,-20,0,0.22,-7.7715611723761e-16,11,22 +0.23,22.360679774998,44.721359549996,10,7.105427357601e-15,20,40,-10,-20,0,0.23,2.4147350785597e-15,11.5,23 +0.24,22.360679774998,44.721359549996,10,7.105427357601e-15,20,40,-10,-20,0,0.24,1.1657341758564e-15,12,24 +0.25,22.360679774998,44.721359549996,10,7.105427357601e-15,20,40,-10,-20,0,0.25,-5.5511151231258e-17,12.5,25 +0.26,22.360679774998,44.721359549996,10,7.105427357601e-15,20,40,-10,-20,0,0.26,-1.3322676295502e-15,13,26 +0.27,22.360679774998,44.721359549996,10,7.105427357601e-15,20,40,-10,-20,0,0.27,-2.5535129566379e-15,13.5,27 +0.28,22.360679774998,44.721359549996,10,7.105427357601e-15,20,40,-10,-20,0,0.28,6.1062266354384e-16,14,28 +0.29,22.360679774998,44.721359549996,10,7.105427357601e-15,20,40,-10,-20,0,0.29,-6.1062266354384e-16,14.5,29 +0.3,22.360679774998,44.721359549996,10,7.105427357601e-15,20,40,-10,-20,0,0.3,-1.8873791418628e-15,15,30 +0.31,22.360679774998,44.721359549996,10,7.105427357601e-15,20,40,-10,-20,0,0.31,-3.1086244689504e-15,15.5,31 +0.32,22.360679774998,44.721359549996,10,7.105427357601e-15,20,40,-10,-20,0,0.32,1.6653345369377e-16,16,32 diff --git a/test/tests/postprocessors/side_integrated_value/main.i b/test/tests/postprocessors/side_integrated_value/main.i index 1f36a779..e0fbbe37 100644 --- a/test/tests/postprocessors/side_integrated_value/main.i +++ b/test/tests/postprocessors/side_integrated_value/main.i @@ -33,12 +33,24 @@ boundary = top execute_on = TIMESTEP_END [] + [t_avg_multiple] # should be double t_avg + type = FoamSideIntegratedValue + foam_variable = 'T' + boundary = 'bottom top' + execute_on = TIMESTEP_END + [] [U_avg_magnitude] type = FoamSideIntegratedValue foam_variable = 'U' boundary = back execute_on = TIMESTEP_END [] + [U_avg_magnitude_multiple] # should be double U_avg_magnitude_multiple + type = FoamSideIntegratedValue + foam_variable = 'U' + boundary = 'back front' + execute_on = TIMESTEP_END + [] [U_avg_normal] type = FoamSideIntegratedValue foam_variable = 'U' @@ -46,6 +58,13 @@ component = normal execute_on = TIMESTEP_END [] + [U_avg_normal_multiple] # should be zero + type = FoamSideIntegratedValue + foam_variable = 'U' + boundary = 'bottom top' + component = normal + execute_on = TIMESTEP_END + [] [U_avg_x] type = FoamSideIntegratedValue foam_variable = 'U' @@ -53,6 +72,13 @@ component = x execute_on = TIMESTEP_END [] + [U_avg_x_multiple] # should be double U_avg_x + type = FoamSideIntegratedValue + foam_variable = 'U' + boundary = 'front back' + component = x + execute_on = TIMESTEP_END + [] [U_avg_y] type = FoamSideIntegratedValue foam_variable = 'U' @@ -60,6 +86,13 @@ component = y execute_on = TIMESTEP_END [] + [U_avg_y_multiple] # should be double U_avg_y + type = FoamSideIntegratedValue + foam_variable = 'U' + boundary = 'back front' + component = y + execute_on = TIMESTEP_END + [] [U_avg_z] type = FoamSideIntegratedValue foam_variable = 'U' @@ -74,6 +107,13 @@ component = x execute_on = TIMESTEP_END [] + [heat_flux_multiple] # should be zero + type = FoamSideIntegratedValue + foam_variable = 'wallHeatFlux' + boundary = 'left right' + component = x + execute_on = TIMESTEP_END + [] [] [Outputs] From 4637d2012809d9c6b917bc4e24dd0c76228ad427 Mon Sep 17 00:00:00 2001 From: Matthew Falcone Date: Thu, 29 Jan 2026 17:26:22 +0000 Subject: [PATCH 33/43] Refactor integrated postprocessors to separate value from function object --- .../postprocessors/FoamSideIntegratedBase.h | 21 ++++ .../FoamSideIntegratedFunctionObject.h | 23 ++++ .../postprocessors/FoamSideIntegratedValue.h | 23 +--- src/postprocessors/FoamSideAverageValue.C | 5 +- src/postprocessors/FoamSideIntegratedBase.C | 77 +++++++++++++ .../FoamSideIntegratedFunctionObject.C | 58 ++++++++++ src/postprocessors/FoamSideIntegratedValue.C | 106 +----------------- 7 files changed, 188 insertions(+), 125 deletions(-) create mode 100644 include/postprocessors/FoamSideIntegratedBase.h create mode 100644 include/postprocessors/FoamSideIntegratedFunctionObject.h create mode 100644 src/postprocessors/FoamSideIntegratedBase.C create mode 100644 src/postprocessors/FoamSideIntegratedFunctionObject.C diff --git a/include/postprocessors/FoamSideIntegratedBase.h b/include/postprocessors/FoamSideIntegratedBase.h new file mode 100644 index 00000000..c1f52bd2 --- /dev/null +++ b/include/postprocessors/FoamSideIntegratedBase.h @@ -0,0 +1,21 @@ +#pragma once +#include "FoamSidePostprocessor.h" + +class FoamSideIntegratedBase : public FoamSidePostprocessor +{ +public: + static InputParameters validParams(); + + FoamSideIntegratedBase(const InputParameters & params); + + virtual PostprocessorValue getValue() const override; + +protected: + Real integrateValue(); + + Real _value; + + std::string _foam_variable; + + bool _is_vector; +}; diff --git a/include/postprocessors/FoamSideIntegratedFunctionObject.h b/include/postprocessors/FoamSideIntegratedFunctionObject.h new file mode 100644 index 00000000..cf78d1ad --- /dev/null +++ b/include/postprocessors/FoamSideIntegratedFunctionObject.h @@ -0,0 +1,23 @@ + +#include "FoamSideIntegratedBase.h" +#include "InputParameters.h" +#include +#include +#include +#include + +class FoamSideIntegratedFunctionObject : public FoamSideIntegratedBase +{ +public: + static InputParameters validParams(); + + FoamSideIntegratedFunctionObject(const InputParameters & params); + + virtual void compute() override; + +protected: + /// Creates function objects to be executed by compute + Foam::functionObject * createFunctionObject(); + + std::unique_ptr _function_object; +}; diff --git a/include/postprocessors/FoamSideIntegratedValue.h b/include/postprocessors/FoamSideIntegratedValue.h index bc221656..f30b2a39 100644 --- a/include/postprocessors/FoamSideIntegratedValue.h +++ b/include/postprocessors/FoamSideIntegratedValue.h @@ -1,31 +1,12 @@ #pragma once -#include "FoamSidePostprocessor.h" -#include -#include -#include +#include "FoamSideIntegratedBase.h" -static MooseEnum _pp_function_objects("wallHeatFlux wallShearStress"); - -class FoamSideIntegratedValue : public FoamSidePostprocessor +class FoamSideIntegratedValue : public FoamSideIntegratedBase { public: static InputParameters validParams(); FoamSideIntegratedValue(const InputParameters & params); - virtual PostprocessorValue getValue() const override; - virtual void compute() override; - -protected: - /// Creates function objects to be executed by compute - void createFunctionObject(); - - Real _value; - - std::string _foam_variable; - - bool _is_vector; - - std::unique_ptr _function_object; }; diff --git a/src/postprocessors/FoamSideAverageValue.C b/src/postprocessors/FoamSideAverageValue.C index f95041fb..d510e10c 100644 --- a/src/postprocessors/FoamSideAverageValue.C +++ b/src/postprocessors/FoamSideAverageValue.C @@ -1,6 +1,5 @@ #include "Field.H" #include "FoamSideAverageValue.h" -#include "FoamSideIntegratedValue.h" #include "InputParameters.h" registerMooseObject("hippoApp", FoamSideAverageValue); @@ -14,7 +13,7 @@ void FoamSideAverageValue::compute() { - FoamSideIntegratedValue::compute(); + Real value = integrateValue(); Real area = 0.; // loop over boundary ids @@ -30,5 +29,5 @@ FoamSideAverageValue::compute() gatherSum(area); // divide by area - _value /= area; + _value = value / area; } diff --git a/src/postprocessors/FoamSideIntegratedBase.C b/src/postprocessors/FoamSideIntegratedBase.C new file mode 100644 index 00000000..bea66dbb --- /dev/null +++ b/src/postprocessors/FoamSideIntegratedBase.C @@ -0,0 +1,77 @@ +#include "FoamSideIntegratedBase.h" +#include "MooseEnum.h" +#include "MooseTypes.h" +#include "FoamMesh.h" + +InputParameters +FoamSideIntegratedBase::validParams() +{ + MooseEnum components("x y z normal magnitude", "magnitude"); + auto params = FoamSidePostprocessor::validParams(); + params.addClassDescription( + "Class that calculates the average or scalar on a OpenFOAM boundary patch."); + params.addParam( + "component", components, "If foam variable is a vector, which component to output"); + return params; +} + +FoamSideIntegratedBase::FoamSideIntegratedBase(const InputParameters & params) + : FoamSidePostprocessor(params), _value(0.), _foam_variable(""), _is_vector(false) +{ +} + +PostprocessorValue +FoamSideIntegratedBase::getValue() const +{ + return _value; +} + +Real +FoamSideIntegratedBase::integrateValue() +{ + + Real value = 0.; + // loop over boundary ids + for (auto & boundary : _boundary) + { + auto & areas = _foam_mesh->boundary()[boundary].magSf(); + Foam::Field var_array; + + if (_is_vector) + { + // get vector data associated with the boundary + auto & vec_data = + _foam_mesh->boundary()[boundary].lookupPatchField( + _foam_variable); + + // get the component specified in parameters and get the + // component of the vector in that direction + auto components = parameters().get("component"); + if (components == "normal") + { + auto && normals = _foam_mesh->boundary()[boundary].nf(); + var_array = normals & vec_data; + } + else if (components == "magnitude") + var_array = Foam::mag(vec_data); + else + var_array = vec_data.component(int(components)); + } + else + { + var_array = _foam_mesh->boundary()[boundary].lookupPatchField( + _foam_variable); + } + + // Integrate + for (int i = 0; i < var_array.size(); ++i) + { + value += var_array[i] * areas[i]; + } + } + + // sum over ranks + gatherSum(value); + + return value; +} diff --git a/src/postprocessors/FoamSideIntegratedFunctionObject.C b/src/postprocessors/FoamSideIntegratedFunctionObject.C new file mode 100644 index 00000000..1a80a789 --- /dev/null +++ b/src/postprocessors/FoamSideIntegratedFunctionObject.C @@ -0,0 +1,58 @@ +#include "FoamSideIntegratedBase.h" +#include "FoamSideIntegratedFunctionObject.h" +#include "InputParameters.h" +#include "MooseEnum.h" + +static MooseEnum _pp_function_objects("wallHeatFlux wallShearStress"); + +registerMooseObject("hippoApp", FoamSideIntegratedFunctionObject); + +InputParameters +FoamSideIntegratedFunctionObject::validParams() +{ + InputParameters params = FoamSideIntegratedBase::validParams(); + params.addRequiredParam( + "function_object", _pp_function_objects, "Foam function object"); + return params; +} + +FoamSideIntegratedFunctionObject::FoamSideIntegratedFunctionObject(const InputParameters & params) + : FoamSideIntegratedBase(params), _function_object() +{ + _foam_variable = std::string(getParam("function_object")); + _function_object.reset(createFunctionObject()); +} + +Foam::functionObject * +FoamSideIntegratedFunctionObject::createFunctionObject() +{ + auto fo_dict = + _foam_mesh->time().controlDict().lookupOrDefault(_foam_variable, Foam::dictionary()); + + Foam::wordList patch_names(blocks().begin(), blocks().end()); + + fo_dict.set("patches", patch_names); + fo_dict.set("writeToFile", false); + + if (_foam_variable == "wallHeatFlux") + { + return static_cast( + new Foam::functionObjects::wallHeatFlux("wallHeatFlux", _foam_mesh->time(), fo_dict)); + } + else if (_foam_variable == "wallShearStress") + { + return static_cast( + new Foam::functionObjects::wallShearStress("wallShearStress", _foam_mesh->time(), fo_dict)); + } + else + { + mooseError("Invalid function_object. Valid options: ", _pp_function_objects.getRawNames()); + } +} + +void +FoamSideIntegratedFunctionObject::compute() +{ + _function_object->execute(); + _value = integrateValue(); +} diff --git a/src/postprocessors/FoamSideIntegratedValue.C b/src/postprocessors/FoamSideIntegratedValue.C index 4e76613a..ff37ef17 100644 --- a/src/postprocessors/FoamSideIntegratedValue.C +++ b/src/postprocessors/FoamSideIntegratedValue.C @@ -1,128 +1,32 @@ -#include "Field.H" #include "FoamSideIntegratedValue.h" #include "InputParameters.h" -#include "MooseEnum.h" #include "MooseTypes.h" #include "FoamMesh.h" -#include "functionObjects/field/wallShearStress/wallShearStress.H" -#include "volFieldsFwd.H" registerMooseObject("hippoApp", FoamSideIntegratedValue); InputParameters FoamSideIntegratedValue::validParams() { - MooseEnum components("x y z normal magnitude", "magnitude"); - auto params = FoamSidePostprocessor::validParams(); - params.addClassDescription( - "Class that calculates the average or scalar on a OpenFOAM boundary patch."); + auto params = FoamSideIntegratedBase::validParams(); params.addRequiredParam( "foam_variable", "Foam variable or function object to be averaged over a boundary patch."); - params.addParam( - "component", components, "If foam variable is a vector, which component to output"); return params; } FoamSideIntegratedValue::FoamSideIntegratedValue(const InputParameters & params) - : FoamSidePostprocessor(params), - _value(0.), - _foam_variable(params.get("foam_variable")), - _is_vector(false), - _function_object(nullptr) + : FoamSideIntegratedBase(params) { - // Create function object if the foam variable matches one of the - // available function objects - createFunctionObject(); - + _foam_variable = getParam("foam_variable"); // determine if this is a vector scalar, ahead of computation if (_foam_mesh->foundObject(_foam_variable)) _is_vector = true; else if (!_foam_mesh->foundObject(_foam_variable)) - mooseError("No Foam scalar, vector or function object called '", _foam_variable, "'."); -} - -void -FoamSideIntegratedValue::createFunctionObject() -{ - if (_pp_function_objects.find(_foam_variable) == _pp_function_objects.items().end()) - return; - - auto fo_dict = - _foam_mesh->time().controlDict().lookupOrDefault(_foam_variable, Foam::dictionary()); - - Foam::wordList patch_names(blocks().begin(), blocks().end()); - - fo_dict.set("patches", patch_names); - fo_dict.set("writeToFile", false); - - if (_foam_variable == "wallHeatFlux") - { - _function_object.reset(static_cast( - new Foam::functionObjects::wallHeatFlux("wallHeatFlux", _foam_mesh->time(), fo_dict))); - } - else if (_foam_variable == "wallShearStress") - { - _function_object.reset( - static_cast(new Foam::functionObjects::wallShearStress( - "wallShearStress", _foam_mesh->time(), fo_dict))); - } - - // This is required to create scalar or vector fields at initialisation. - _function_object->execute(); + mooseError("No Foam scalar or vector called '", _foam_variable, "'."); } void FoamSideIntegratedValue::compute() { - if (_function_object) - _function_object->execute(); - - _value = 0.; - // loop over boundary ids - for (auto & boundary : _boundary) - { - auto & areas = _foam_mesh->boundary()[boundary].magSf(); - Foam::Field var_array; - - if (_is_vector) - { - // get vector data associated with the boundary - auto & vec_data = - _foam_mesh->boundary()[boundary].lookupPatchField( - _foam_variable); - - // get the component specified in parameters and get the - // component of the vector in that direction - auto components = parameters().get("component"); - if (components == "normal") - { - auto && normals = _foam_mesh->boundary()[boundary].nf(); - var_array = normals & vec_data; - } - else if (components == "magnitude") - var_array = Foam::mag(vec_data); - else - var_array = vec_data.component(int(components)); - } - else - { - var_array = _foam_mesh->boundary()[boundary].lookupPatchField( - _foam_variable); - } - - // Integrate - for (int i = 0; i < var_array.size(); ++i) - { - _value += var_array[i] * areas[i]; - } - } - - // sum over ranks - gatherSum(_value); -} - -PostprocessorValue -FoamSideIntegratedValue::getValue() const -{ - return _value; + _value = integrateValue(); } From 521cd595db18cb0e256fb09715fbb3a1c1225bda Mon Sep 17 00:00:00 2001 From: Matthew Falcone Date: Thu, 29 Jan 2026 17:51:12 +0000 Subject: [PATCH 34/43] Add average postprocessors for function objects --- .../FoamSideAverageFunctionObject.h | 17 +++++++++++++ .../postprocessors/FoamSideIntegratedBase.h | 6 ++++- .../FoamSideIntegratedFunctionObject.h | 5 ++-- .../postprocessors/FoamSideIntegratedValue.h | 2 -- .../FoamSideAverageFunctionObject.C | 9 +++++++ src/postprocessors/FoamSideAverageValue.C | 20 +--------------- src/postprocessors/FoamSideIntegratedBase.C | 24 +++++++++++++++++++ .../FoamSideIntegratedFunctionObject.C | 6 ++--- src/postprocessors/FoamSideIntegratedValue.C | 6 ----- 9 files changed, 62 insertions(+), 33 deletions(-) create mode 100644 include/postprocessors/FoamSideAverageFunctionObject.h create mode 100644 src/postprocessors/FoamSideAverageFunctionObject.C diff --git a/include/postprocessors/FoamSideAverageFunctionObject.h b/include/postprocessors/FoamSideAverageFunctionObject.h new file mode 100644 index 00000000..70b7466d --- /dev/null +++ b/include/postprocessors/FoamSideAverageFunctionObject.h @@ -0,0 +1,17 @@ +#pragma once + +#include "FoamSideIntegratedFunctionObject.h" +#include "InputParameters.h" + +class FoamSideAverageFunctionObject : public FoamSideIntegratedFunctionObject +{ +public: + static InputParameters validParams() { return FoamSideIntegratedFunctionObject::validParams(); } + + FoamSideAverageFunctionObject(const InputParameters & params) + : FoamSideIntegratedFunctionObject(params) + { + } + + virtual void compute() override; +}; diff --git a/include/postprocessors/FoamSideIntegratedBase.h b/include/postprocessors/FoamSideIntegratedBase.h index c1f52bd2..7c7ce34f 100644 --- a/include/postprocessors/FoamSideIntegratedBase.h +++ b/include/postprocessors/FoamSideIntegratedBase.h @@ -10,8 +10,12 @@ class FoamSideIntegratedBase : public FoamSidePostprocessor virtual PostprocessorValue getValue() const override; + virtual void compute() override; + protected: - Real integrateValue(); + virtual Real integrateValue(); + + Real getArea(); Real _value; diff --git a/include/postprocessors/FoamSideIntegratedFunctionObject.h b/include/postprocessors/FoamSideIntegratedFunctionObject.h index cf78d1ad..8a932238 100644 --- a/include/postprocessors/FoamSideIntegratedFunctionObject.h +++ b/include/postprocessors/FoamSideIntegratedFunctionObject.h @@ -1,3 +1,4 @@ +#pragma once #include "FoamSideIntegratedBase.h" #include "InputParameters.h" @@ -13,9 +14,9 @@ class FoamSideIntegratedFunctionObject : public FoamSideIntegratedBase FoamSideIntegratedFunctionObject(const InputParameters & params); - virtual void compute() override; - protected: + virtual Real integrateValue() override; + /// Creates function objects to be executed by compute Foam::functionObject * createFunctionObject(); diff --git a/include/postprocessors/FoamSideIntegratedValue.h b/include/postprocessors/FoamSideIntegratedValue.h index f30b2a39..eb481440 100644 --- a/include/postprocessors/FoamSideIntegratedValue.h +++ b/include/postprocessors/FoamSideIntegratedValue.h @@ -7,6 +7,4 @@ class FoamSideIntegratedValue : public FoamSideIntegratedBase static InputParameters validParams(); FoamSideIntegratedValue(const InputParameters & params); - - virtual void compute() override; }; diff --git a/src/postprocessors/FoamSideAverageFunctionObject.C b/src/postprocessors/FoamSideAverageFunctionObject.C new file mode 100644 index 00000000..35915fc3 --- /dev/null +++ b/src/postprocessors/FoamSideAverageFunctionObject.C @@ -0,0 +1,9 @@ +#include "FoamSideAverageFunctionObject.h" + +registerMooseObject("hippoApp", FoamSideAverageFunctionObject); + +void +FoamSideAverageFunctionObject::compute() +{ + _value = integrateValue() / getArea(); +} diff --git a/src/postprocessors/FoamSideAverageValue.C b/src/postprocessors/FoamSideAverageValue.C index d510e10c..43f83130 100644 --- a/src/postprocessors/FoamSideAverageValue.C +++ b/src/postprocessors/FoamSideAverageValue.C @@ -1,4 +1,3 @@ -#include "Field.H" #include "FoamSideAverageValue.h" #include "InputParameters.h" @@ -12,22 +11,5 @@ FoamSideAverageValue::FoamSideAverageValue(const InputParameters & params) void FoamSideAverageValue::compute() { - - Real value = integrateValue(); - - Real area = 0.; - // loop over boundary ids - for (auto & boundary : _boundary) - { - auto & areas = _foam_mesh->boundary()[boundary].magSf(); - for (int i = 0; i < areas.size(); ++i) - { - area += areas[i]; - } - } - // sum over ranks - gatherSum(area); - - // divide by area - _value = value / area; + _value = integrateValue() / getArea(); } diff --git a/src/postprocessors/FoamSideIntegratedBase.C b/src/postprocessors/FoamSideIntegratedBase.C index bea66dbb..c07496b7 100644 --- a/src/postprocessors/FoamSideIntegratedBase.C +++ b/src/postprocessors/FoamSideIntegratedBase.C @@ -75,3 +75,27 @@ FoamSideIntegratedBase::integrateValue() return value; } + +void +FoamSideIntegratedBase::compute() +{ + _value = integrateValue(); +} + +Real +FoamSideIntegratedBase::getArea() +{ + Real area = 0.; + // loop over boundary ids + for (auto & boundary : _boundary) + { + auto & areas = _foam_mesh->boundary()[boundary].magSf(); + for (int i = 0; i < areas.size(); ++i) + { + area += areas[i]; + } + } + // sum over ranks + gatherSum(area); + return area; +} diff --git a/src/postprocessors/FoamSideIntegratedFunctionObject.C b/src/postprocessors/FoamSideIntegratedFunctionObject.C index 1a80a789..9624b377 100644 --- a/src/postprocessors/FoamSideIntegratedFunctionObject.C +++ b/src/postprocessors/FoamSideIntegratedFunctionObject.C @@ -50,9 +50,9 @@ FoamSideIntegratedFunctionObject::createFunctionObject() } } -void -FoamSideIntegratedFunctionObject::compute() +Real +FoamSideIntegratedFunctionObject::integrateValue() { _function_object->execute(); - _value = integrateValue(); + return FoamSideIntegratedBase::integrateValue(); } diff --git a/src/postprocessors/FoamSideIntegratedValue.C b/src/postprocessors/FoamSideIntegratedValue.C index ff37ef17..34d06e17 100644 --- a/src/postprocessors/FoamSideIntegratedValue.C +++ b/src/postprocessors/FoamSideIntegratedValue.C @@ -24,9 +24,3 @@ FoamSideIntegratedValue::FoamSideIntegratedValue(const InputParameters & params) else if (!_foam_mesh->foundObject(_foam_variable)) mooseError("No Foam scalar or vector called '", _foam_variable, "'."); } - -void -FoamSideIntegratedValue::compute() -{ - _value = integrateValue(); -} From 192dc99a662e8e5b51fddc6e2850189e78c9f1f2 Mon Sep 17 00:00:00 2001 From: Matthew Falcone Date: Thu, 29 Jan 2026 17:51:25 +0000 Subject: [PATCH 35/43] Update integrated value tests --- test/tests/postprocessors/side_integrated_value/main.i | 8 ++++---- test/tests/postprocessors/side_integrated_value/tests | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/tests/postprocessors/side_integrated_value/main.i b/test/tests/postprocessors/side_integrated_value/main.i index e0fbbe37..e7e639fc 100644 --- a/test/tests/postprocessors/side_integrated_value/main.i +++ b/test/tests/postprocessors/side_integrated_value/main.i @@ -101,15 +101,15 @@ execute_on = TIMESTEP_END [] [heat_flux] - type = FoamSideIntegratedValue - foam_variable = 'wallHeatFlux' + type = FoamSideIntegratedFunctionObject + function_object = 'wallHeatFlux' boundary = right component = x execute_on = TIMESTEP_END [] [heat_flux_multiple] # should be zero - type = FoamSideIntegratedValue - foam_variable = 'wallHeatFlux' + type = FoamSideIntegratedFunctionObject + function_object = 'wallHeatFlux' boundary = 'left right' component = x execute_on = TIMESTEP_END diff --git a/test/tests/postprocessors/side_integrated_value/tests b/test/tests/postprocessors/side_integrated_value/tests index ba09e744..59ae6d31 100644 --- a/test/tests/postprocessors/side_integrated_value/tests +++ b/test/tests/postprocessors/side_integrated_value/tests @@ -34,7 +34,7 @@ prereq = postprocessor_test/setup allow_warnings = true cli_args='Postprocessors/t_avg/foam_variable=T1' - expect_err = "No Foam scalar, vector or function object called 'T1'." + expect_err = "No Foam scalar or vector called 'T1'." [] [] [] From aaac42d42af2f56e5633479869b6f891448f2c4b Mon Sep 17 00:00:00 2001 From: Matthew Falcone Date: Thu, 29 Jan 2026 17:53:39 +0000 Subject: [PATCH 36/43] Add tests for average function object postprocessors --- .../side_average/gold/main_out.csv | 68 +++++++++---------- test/tests/postprocessors/side_average/main.i | 14 ++++ 2 files changed, 48 insertions(+), 34 deletions(-) diff --git a/test/tests/postprocessors/side_average/gold/main_out.csv b/test/tests/postprocessors/side_average/gold/main_out.csv index 6db3d692..3c317aac 100644 --- a/test/tests/postprocessors/side_average/gold/main_out.csv +++ b/test/tests/postprocessors/side_average/gold/main_out.csv @@ -1,34 +1,34 @@ -time,U_avg_magnitude,U_avg_magnitude_multiple,U_avg_normal,U_avg_normal_multiple,U_avg_x,U_avg_x_multiple,U_avg_y,U_avg_y_multiple,U_avg_z,t_avg,t_avg_multiple -0,0,0,0,0,0,0,0,0,0,0,0 -0.01,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.05,0.05 -0.02,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.1,0.1 -0.03,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.15,0.15 -0.04,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.2,0.2 -0.05,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.25,0.25 -0.06,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.3,0.3 -0.07,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.35,0.35 -0.08,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.4,0.4 -0.09,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.45,0.45 -0.1,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.5,0.5 -0.11,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.55,0.55 -0.12,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.6,0.6 -0.13,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.65,0.65 -0.14,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.7,0.7 -0.15,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.75,0.75 -0.16,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.8,0.8 -0.17,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.85,0.85 -0.18,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.9,0.9 -0.19,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.95,0.95 -0.2,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,1,1 -0.21,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,1.05,1.05 -0.22,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,1.1,1.1 -0.23,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,1.15,1.15 -0.24,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,1.2,1.2 -0.25,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,1.25,1.25 -0.26,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,1.3,1.3 -0.27,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,1.35,1.35 -0.28,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,1.4,1.4 -0.29,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,1.45,1.45 -0.3,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,1.5,1.5 -0.31,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,1.55,1.55 -0.32,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,1.6,1.6 +time,U_avg_magnitude,U_avg_magnitude_multiple,U_avg_normal,U_avg_normal_multiple,U_avg_x,U_avg_x_multiple,U_avg_y,U_avg_y_multiple,U_avg_z,heat_flux,heat_flux_multiple,t_avg,t_avg_multiple +0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0.01,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.01,7.8062556418956e-18,0.05,0.05 +0.02,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.02,1.5612511283791e-17,0.1,0.1 +0.03,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.03,2.2551405187698e-17,0.15,0.15 +0.04,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.04,3.1225022567583e-17,0.2,0.2 +0.05,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.05,-5.2041704279304e-17,0.25,0.25 +0.06,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.06,4.1633363423443e-17,0.3,0.3 +0.07,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.07,4.8572257327351e-17,0.35,0.35 +0.08,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.08,6.2450045135165e-17,0.4,0.4 +0.09,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.09,-1.0408340855861e-16,0.45,0.45 +0.1,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.1,-9.7144514654701e-17,0.5,0.5 +0.11,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.11,-8.3266726846887e-17,0.55,0.55 +0.12,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.12,-2.3592239273285e-16,0.6,0.6 +0.13,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.13,-6.9388939039072e-17,0.65,0.65 +0.14,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.14,9.7144514654701e-17,0.7,0.7 +0.15,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.15,-5.5511151231258e-17,0.75,0.75 +0.16,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.16,1.2490009027033e-16,0.8,0.8 +0.17,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.17,-5.5511151231258e-17,0.85,0.85 +0.18,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.18,1.1102230246252e-16,0.9,0.9 +0.19,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.19,-5.5511151231258e-17,0.95,0.95 +0.2,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.2,1.2490009027033e-16,1,1 +0.21,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.21,-4.1633363423443e-17,1.05,1.05 +0.22,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.22,-1.942890293094e-16,1.1,1.1 +0.23,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.23,3.0531133177192e-16,1.15,1.15 +0.24,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.24,1.2490009027033e-16,1.2,1.2 +0.25,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.25,-2.7755575615629e-17,1.25,1.25 +0.26,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.26,-1.942890293094e-16,1.3,1.3 +0.27,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.27,-3.3306690738755e-16,1.35,1.35 +0.28,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.28,1.6653345369377e-16,1.4,1.4 +0.29,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.29,-2.7755575615629e-17,1.45,1.45 +0.3,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.3,-1.942890293094e-16,1.5,1.5 +0.31,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.31,-3.6082248300318e-16,1.55,1.55 +0.32,2.2360679774998,2.2360679774998,2,0,2,2,-1,-1,0,0.32,2.4980018054066e-16,1.6,1.6 diff --git a/test/tests/postprocessors/side_average/main.i b/test/tests/postprocessors/side_average/main.i index 991cdbd1..c88a8655 100644 --- a/test/tests/postprocessors/side_average/main.i +++ b/test/tests/postprocessors/side_average/main.i @@ -100,6 +100,20 @@ component = z execute_on = TIMESTEP_END [] + [heat_flux] + type = FoamSideAverageFunctionObject + function_object = 'wallHeatFlux' + boundary = right + component = x + execute_on = TIMESTEP_END + [] + [heat_flux_multiple] # should be zero + type = FoamSideAverageFunctionObject + function_object = 'wallHeatFlux' + boundary = 'left right' + component = x + execute_on = TIMESTEP_END + [] [] [Outputs] From 2e8b293ece996c61b1270402fc84def76bcb6c9f Mon Sep 17 00:00:00 2001 From: Matthew Falcone Date: Thu, 29 Jan 2026 18:15:22 +0000 Subject: [PATCH 37/43] Add test to check function object is valid --- src/postprocessors/FoamSideIntegratedFunctionObject.C | 9 ++++----- test/tests/postprocessors/side_integrated_value/tests | 6 ++++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/postprocessors/FoamSideIntegratedFunctionObject.C b/src/postprocessors/FoamSideIntegratedFunctionObject.C index 9624b377..5efbd786 100644 --- a/src/postprocessors/FoamSideIntegratedFunctionObject.C +++ b/src/postprocessors/FoamSideIntegratedFunctionObject.C @@ -2,6 +2,7 @@ #include "FoamSideIntegratedFunctionObject.h" #include "InputParameters.h" #include "MooseEnum.h" +#include static MooseEnum _pp_function_objects("wallHeatFlux wallShearStress"); @@ -36,18 +37,16 @@ FoamSideIntegratedFunctionObject::createFunctionObject() if (_foam_variable == "wallHeatFlux") { + _is_vector = false; return static_cast( new Foam::functionObjects::wallHeatFlux("wallHeatFlux", _foam_mesh->time(), fo_dict)); } - else if (_foam_variable == "wallShearStress") + else // wallShearStress { + _is_vector = true; return static_cast( new Foam::functionObjects::wallShearStress("wallShearStress", _foam_mesh->time(), fo_dict)); } - else - { - mooseError("Invalid function_object. Valid options: ", _pp_function_objects.getRawNames()); - } } Real diff --git a/test/tests/postprocessors/side_integrated_value/tests b/test/tests/postprocessors/side_integrated_value/tests index 59ae6d31..382d954b 100644 --- a/test/tests/postprocessors/side_integrated_value/tests +++ b/test/tests/postprocessors/side_integrated_value/tests @@ -36,5 +36,11 @@ cli_args='Postprocessors/t_avg/foam_variable=T1' expect_err = "No Foam scalar or vector called 'T1'." [] + [check_valid_func_obj] + type = RunException + input = main.i + expect_err = 'Invalid option "wallHeatFlux1" in MooseEnum' + cli_args = "Postprocessors/heat_flux/function_object='wallHeatFlux1'" + [] [] [] From b180c1dbd01576326831ee3a4875de0435bd7f36 Mon Sep 17 00:00:00 2001 From: Matthew Falcone Date: Thu, 29 Jan 2026 18:25:45 +0000 Subject: [PATCH 38/43] Move Foam includes from postprocessors to fvCFD_moose.h --- include/base/foam/fvCFD_moose.h | 5 +++++ include/postprocessors/FoamPostprocessorBase.h | 3 ++- src/postprocessors/FoamSideIntegratedFunctionObject.C | 2 -- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/include/base/foam/fvCFD_moose.h b/include/base/foam/fvCFD_moose.h index 27a08f1a..1c685f15 100644 --- a/include/base/foam/fvCFD_moose.h +++ b/include/base/foam/fvCFD_moose.h @@ -44,4 +44,9 @@ #include #include +// FoamSideIntegratedFunctionObject.h +#include +#include +#include + #undef NotImplemented diff --git a/include/postprocessors/FoamPostprocessorBase.h b/include/postprocessors/FoamPostprocessorBase.h index e3e614f0..fbb6f01f 100644 --- a/include/postprocessors/FoamPostprocessorBase.h +++ b/include/postprocessors/FoamPostprocessorBase.h @@ -1,9 +1,10 @@ #pragma once +#include "fvCFD_moose.h" + #include "InputParameters.h" #include "Postprocessor.h" #include "ElementUserObject.h" -#include "fvMesh.H" class FoamPostprocessorBase : public ElementUserObject, public Postprocessor { diff --git a/src/postprocessors/FoamSideIntegratedFunctionObject.C b/src/postprocessors/FoamSideIntegratedFunctionObject.C index 5efbd786..c959fad9 100644 --- a/src/postprocessors/FoamSideIntegratedFunctionObject.C +++ b/src/postprocessors/FoamSideIntegratedFunctionObject.C @@ -1,8 +1,6 @@ -#include "FoamSideIntegratedBase.h" #include "FoamSideIntegratedFunctionObject.h" #include "InputParameters.h" #include "MooseEnum.h" -#include static MooseEnum _pp_function_objects("wallHeatFlux wallShearStress"); From 25756c4613301d199fa66eb43dbfd5884f4871d9 Mon Sep 17 00:00:00 2001 From: Matthew Falcone Date: Thu, 29 Jan 2026 18:35:42 +0000 Subject: [PATCH 39/43] Remove unnecessary includes --- include/postprocessors/FoamSideIntegratedFunctionObject.h | 4 +--- src/postprocessors/FoamSideIntegratedBase.C | 1 - src/postprocessors/FoamSideIntegratedValue.C | 1 - 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/include/postprocessors/FoamSideIntegratedFunctionObject.h b/include/postprocessors/FoamSideIntegratedFunctionObject.h index 8a932238..dbd0c070 100644 --- a/include/postprocessors/FoamSideIntegratedFunctionObject.h +++ b/include/postprocessors/FoamSideIntegratedFunctionObject.h @@ -2,9 +2,7 @@ #include "FoamSideIntegratedBase.h" #include "InputParameters.h" -#include -#include -#include + #include class FoamSideIntegratedFunctionObject : public FoamSideIntegratedBase diff --git a/src/postprocessors/FoamSideIntegratedBase.C b/src/postprocessors/FoamSideIntegratedBase.C index c07496b7..162b3fba 100644 --- a/src/postprocessors/FoamSideIntegratedBase.C +++ b/src/postprocessors/FoamSideIntegratedBase.C @@ -1,7 +1,6 @@ #include "FoamSideIntegratedBase.h" #include "MooseEnum.h" #include "MooseTypes.h" -#include "FoamMesh.h" InputParameters FoamSideIntegratedBase::validParams() diff --git a/src/postprocessors/FoamSideIntegratedValue.C b/src/postprocessors/FoamSideIntegratedValue.C index 34d06e17..604ec67a 100644 --- a/src/postprocessors/FoamSideIntegratedValue.C +++ b/src/postprocessors/FoamSideIntegratedValue.C @@ -1,7 +1,6 @@ #include "FoamSideIntegratedValue.h" #include "InputParameters.h" #include "MooseTypes.h" -#include "FoamMesh.h" registerMooseObject("hippoApp", FoamSideIntegratedValue); From b3fcc03db381894c162ce775e4b6992ad331141e Mon Sep 17 00:00:00 2001 From: Matthew Falcone Date: Fri, 30 Jan 2026 09:51:13 +0000 Subject: [PATCH 40/43] Add further comments --- src/postprocessors/FoamSideIntegratedBase.C | 2 +- .../postprocessors/side_advective_flux_integral/main.i | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/postprocessors/FoamSideIntegratedBase.C b/src/postprocessors/FoamSideIntegratedBase.C index 162b3fba..4509573b 100644 --- a/src/postprocessors/FoamSideIntegratedBase.C +++ b/src/postprocessors/FoamSideIntegratedBase.C @@ -15,7 +15,7 @@ FoamSideIntegratedBase::validParams() } FoamSideIntegratedBase::FoamSideIntegratedBase(const InputParameters & params) - : FoamSidePostprocessor(params), _value(0.), _foam_variable(""), _is_vector(false) + : FoamSidePostprocessor(params), _value(0.), _foam_variable(), _is_vector(false) { } diff --git a/test/tests/postprocessors/side_advective_flux_integral/main.i b/test/tests/postprocessors/side_advective_flux_integral/main.i index 129b2bf7..b9815796 100644 --- a/test/tests/postprocessors/side_advective_flux_integral/main.i +++ b/test/tests/postprocessors/side_advective_flux_integral/main.i @@ -37,7 +37,7 @@ foam_scalar = 'rho' boundary = right [] - [m_dot_x12] + [m_dot_x12] # should be zero type = FoamSideAdvectiveFluxIntegral foam_scalar = 'rho' boundary = 'left right' @@ -52,7 +52,7 @@ foam_scalar = 'rho' boundary = top [] - [m_dot_y12] + [m_dot_y12] # should be zero type = FoamSideAdvectiveFluxIntegral foam_scalar = 'rho' boundary = 'bottom top' @@ -67,7 +67,7 @@ foam_scalar = 'rho' boundary = front [] - [m_dot_z12] + [m_dot_z12] # should be zero type = FoamSideAdvectiveFluxIntegral foam_scalar = 'rho' boundary = 'front back' From d9cd77bd7b15a537bc2e4574437d2bea2ebca436 Mon Sep 17 00:00:00 2001 From: Matthew Falcone Date: Fri, 30 Jan 2026 10:52:06 +0000 Subject: [PATCH 41/43] Simplify integrated postprocessors --- .../postprocessors/FoamSideIntegratedBase.h | 8 +------ .../FoamSideIntegratedFunctionObject.h | 6 ++--- .../postprocessors/FoamSideIntegratedValue.h | 5 +++++ .../FoamSideAverageFunctionObject.C | 3 ++- src/postprocessors/FoamSideAverageValue.C | 2 +- src/postprocessors/FoamSideIntegratedBase.C | 20 ++++++----------- .../FoamSideIntegratedFunctionObject.C | 22 ++++++++----------- src/postprocessors/FoamSideIntegratedValue.C | 14 +++++++----- 8 files changed, 37 insertions(+), 43 deletions(-) diff --git a/include/postprocessors/FoamSideIntegratedBase.h b/include/postprocessors/FoamSideIntegratedBase.h index 7c7ce34f..d71e533c 100644 --- a/include/postprocessors/FoamSideIntegratedBase.h +++ b/include/postprocessors/FoamSideIntegratedBase.h @@ -10,16 +10,10 @@ class FoamSideIntegratedBase : public FoamSidePostprocessor virtual PostprocessorValue getValue() const override; - virtual void compute() override; - protected: - virtual Real integrateValue(); + virtual Real integrateValue(const std::string & variable); Real getArea(); Real _value; - - std::string _foam_variable; - - bool _is_vector; }; diff --git a/include/postprocessors/FoamSideIntegratedFunctionObject.h b/include/postprocessors/FoamSideIntegratedFunctionObject.h index dbd0c070..e4be5cc6 100644 --- a/include/postprocessors/FoamSideIntegratedFunctionObject.h +++ b/include/postprocessors/FoamSideIntegratedFunctionObject.h @@ -12,11 +12,11 @@ class FoamSideIntegratedFunctionObject : public FoamSideIntegratedBase FoamSideIntegratedFunctionObject(const InputParameters & params); -protected: - virtual Real integrateValue() override; + virtual void compute() override; +protected: /// Creates function objects to be executed by compute - Foam::functionObject * createFunctionObject(); + Foam::functionObject * createFunctionObject(const std::string & fo_name); std::unique_ptr _function_object; }; diff --git a/include/postprocessors/FoamSideIntegratedValue.h b/include/postprocessors/FoamSideIntegratedValue.h index eb481440..fb25bfb3 100644 --- a/include/postprocessors/FoamSideIntegratedValue.h +++ b/include/postprocessors/FoamSideIntegratedValue.h @@ -7,4 +7,9 @@ class FoamSideIntegratedValue : public FoamSideIntegratedBase static InputParameters validParams(); FoamSideIntegratedValue(const InputParameters & params); + + virtual void compute() override; + +protected: + const std::string & _foam_variable; }; diff --git a/src/postprocessors/FoamSideAverageFunctionObject.C b/src/postprocessors/FoamSideAverageFunctionObject.C index 35915fc3..8a9ee69a 100644 --- a/src/postprocessors/FoamSideAverageFunctionObject.C +++ b/src/postprocessors/FoamSideAverageFunctionObject.C @@ -5,5 +5,6 @@ registerMooseObject("hippoApp", FoamSideAverageFunctionObject); void FoamSideAverageFunctionObject::compute() { - _value = integrateValue() / getArea(); + _function_object->execute(); + _value = integrateValue(_function_object->name()) / getArea(); } diff --git a/src/postprocessors/FoamSideAverageValue.C b/src/postprocessors/FoamSideAverageValue.C index 43f83130..b7562ed6 100644 --- a/src/postprocessors/FoamSideAverageValue.C +++ b/src/postprocessors/FoamSideAverageValue.C @@ -11,5 +11,5 @@ FoamSideAverageValue::FoamSideAverageValue(const InputParameters & params) void FoamSideAverageValue::compute() { - _value = integrateValue() / getArea(); + _value = integrateValue(_foam_variable) / getArea(); } diff --git a/src/postprocessors/FoamSideIntegratedBase.C b/src/postprocessors/FoamSideIntegratedBase.C index 4509573b..c2e23376 100644 --- a/src/postprocessors/FoamSideIntegratedBase.C +++ b/src/postprocessors/FoamSideIntegratedBase.C @@ -1,6 +1,7 @@ #include "FoamSideIntegratedBase.h" #include "MooseEnum.h" #include "MooseTypes.h" +#include InputParameters FoamSideIntegratedBase::validParams() @@ -15,7 +16,7 @@ FoamSideIntegratedBase::validParams() } FoamSideIntegratedBase::FoamSideIntegratedBase(const InputParameters & params) - : FoamSidePostprocessor(params), _value(0.), _foam_variable(), _is_vector(false) + : FoamSidePostprocessor(params), _value(0.) { } @@ -26,7 +27,7 @@ FoamSideIntegratedBase::getValue() const } Real -FoamSideIntegratedBase::integrateValue() +FoamSideIntegratedBase::integrateValue(const std::string & variable) { Real value = 0.; @@ -36,12 +37,11 @@ FoamSideIntegratedBase::integrateValue() auto & areas = _foam_mesh->boundary()[boundary].magSf(); Foam::Field var_array; - if (_is_vector) + if (_foam_mesh->foundObject(variable)) { // get vector data associated with the boundary auto & vec_data = - _foam_mesh->boundary()[boundary].lookupPatchField( - _foam_variable); + _foam_mesh->boundary()[boundary].lookupPatchField(variable); // get the component specified in parameters and get the // component of the vector in that direction @@ -58,8 +58,8 @@ FoamSideIntegratedBase::integrateValue() } else { - var_array = _foam_mesh->boundary()[boundary].lookupPatchField( - _foam_variable); + var_array = + _foam_mesh->boundary()[boundary].lookupPatchField(variable); } // Integrate @@ -75,12 +75,6 @@ FoamSideIntegratedBase::integrateValue() return value; } -void -FoamSideIntegratedBase::compute() -{ - _value = integrateValue(); -} - Real FoamSideIntegratedBase::getArea() { diff --git a/src/postprocessors/FoamSideIntegratedFunctionObject.C b/src/postprocessors/FoamSideIntegratedFunctionObject.C index c959fad9..ebf5ba66 100644 --- a/src/postprocessors/FoamSideIntegratedFunctionObject.C +++ b/src/postprocessors/FoamSideIntegratedFunctionObject.C @@ -16,40 +16,36 @@ FoamSideIntegratedFunctionObject::validParams() } FoamSideIntegratedFunctionObject::FoamSideIntegratedFunctionObject(const InputParameters & params) - : FoamSideIntegratedBase(params), _function_object() + : FoamSideIntegratedBase(params), + _function_object(createFunctionObject(getParam("function_object"))) { - _foam_variable = std::string(getParam("function_object")); - _function_object.reset(createFunctionObject()); } Foam::functionObject * -FoamSideIntegratedFunctionObject::createFunctionObject() +FoamSideIntegratedFunctionObject::createFunctionObject(const std::string & fo_name) { - auto fo_dict = - _foam_mesh->time().controlDict().lookupOrDefault(_foam_variable, Foam::dictionary()); + auto fo_dict = _foam_mesh->time().controlDict().lookupOrDefault(fo_name, Foam::dictionary()); - Foam::wordList patch_names(blocks().begin(), blocks().end()); + Foam::wordList patch_names(_boundary.begin(), _boundary.end()); fo_dict.set("patches", patch_names); fo_dict.set("writeToFile", false); - if (_foam_variable == "wallHeatFlux") + if (fo_name == "wallHeatFlux") { - _is_vector = false; return static_cast( new Foam::functionObjects::wallHeatFlux("wallHeatFlux", _foam_mesh->time(), fo_dict)); } else // wallShearStress { - _is_vector = true; return static_cast( new Foam::functionObjects::wallShearStress("wallShearStress", _foam_mesh->time(), fo_dict)); } } -Real -FoamSideIntegratedFunctionObject::integrateValue() +void +FoamSideIntegratedFunctionObject::compute() { _function_object->execute(); - return FoamSideIntegratedBase::integrateValue(); + _value = integrateValue(_function_object->name()); } diff --git a/src/postprocessors/FoamSideIntegratedValue.C b/src/postprocessors/FoamSideIntegratedValue.C index 604ec67a..c6e01f8c 100644 --- a/src/postprocessors/FoamSideIntegratedValue.C +++ b/src/postprocessors/FoamSideIntegratedValue.C @@ -14,12 +14,16 @@ FoamSideIntegratedValue::validParams() } FoamSideIntegratedValue::FoamSideIntegratedValue(const InputParameters & params) - : FoamSideIntegratedBase(params) + : FoamSideIntegratedBase(params), _foam_variable(getParam("foam_variable")) { - _foam_variable = getParam("foam_variable"); // determine if this is a vector scalar, ahead of computation - if (_foam_mesh->foundObject(_foam_variable)) - _is_vector = true; - else if (!_foam_mesh->foundObject(_foam_variable)) + if (!_foam_mesh->foundObject(_foam_variable) && + !_foam_mesh->foundObject(_foam_variable)) mooseError("No Foam scalar or vector called '", _foam_variable, "'."); } + +void +FoamSideIntegratedValue::compute() +{ + _value = integrateValue(_foam_variable); +} From f39ff7c898aa3c82e473e3c66446e233149f51cb Mon Sep 17 00:00:00 2001 From: Matthew Falcone Date: Thu, 5 Feb 2026 14:27:22 +0000 Subject: [PATCH 42/43] Make minor changes in response to code review --- include/postprocessors/FoamSideAverageValue.h | 3 --- .../FoamSideIntegratedFunctionObject.h | 2 +- .../FoamSideAdvectiveFluxIntegral.C | 2 +- src/postprocessors/FoamSideIntegratedBase.C | 2 -- .../FoamSideIntegratedFunctionObject.C | 16 ++++++++-------- src/postprocessors/FoamSideIntegratedValue.C | 4 ++-- .../postprocessors/side_integrated_value/main.i | 2 +- 7 files changed, 13 insertions(+), 18 deletions(-) diff --git a/include/postprocessors/FoamSideAverageValue.h b/include/postprocessors/FoamSideAverageValue.h index dd9a3774..70313bb2 100644 --- a/include/postprocessors/FoamSideAverageValue.h +++ b/include/postprocessors/FoamSideAverageValue.h @@ -2,9 +2,6 @@ #include "FoamSideIntegratedValue.h" #include "InputParameters.h" -#include -#include - class FoamSideAverageValue : public FoamSideIntegratedValue { public: diff --git a/include/postprocessors/FoamSideIntegratedFunctionObject.h b/include/postprocessors/FoamSideIntegratedFunctionObject.h index e4be5cc6..4917a929 100644 --- a/include/postprocessors/FoamSideIntegratedFunctionObject.h +++ b/include/postprocessors/FoamSideIntegratedFunctionObject.h @@ -16,7 +16,7 @@ class FoamSideIntegratedFunctionObject : public FoamSideIntegratedBase protected: /// Creates function objects to be executed by compute - Foam::functionObject * createFunctionObject(const std::string & fo_name); + std::unique_ptr createFunctionObject(const std::string & fo_name); std::unique_ptr _function_object; }; diff --git a/src/postprocessors/FoamSideAdvectiveFluxIntegral.C b/src/postprocessors/FoamSideAdvectiveFluxIntegral.C index cca40303..2c8b35b8 100644 --- a/src/postprocessors/FoamSideAdvectiveFluxIntegral.C +++ b/src/postprocessors/FoamSideAdvectiveFluxIntegral.C @@ -11,7 +11,7 @@ FoamSideAdvectiveFluxIntegral::validParams() { auto params = FoamSidePostprocessor::validParams(); params.addClassDescription( - "Class that calculates the average or scalar on a OpenFOAM boundary patch."); + "Class that calculates the advected flux of a scalar on an OpenFOAM boundary patch."); params.addRequiredParam("foam_scalar", "Foam scalar being advected."); params.addParam("advective_velocity", "U", "Advection velocity"); return params; diff --git a/src/postprocessors/FoamSideIntegratedBase.C b/src/postprocessors/FoamSideIntegratedBase.C index c2e23376..6a76cbb1 100644 --- a/src/postprocessors/FoamSideIntegratedBase.C +++ b/src/postprocessors/FoamSideIntegratedBase.C @@ -8,8 +8,6 @@ FoamSideIntegratedBase::validParams() { MooseEnum components("x y z normal magnitude", "magnitude"); auto params = FoamSidePostprocessor::validParams(); - params.addClassDescription( - "Class that calculates the average or scalar on a OpenFOAM boundary patch."); params.addParam( "component", components, "If foam variable is a vector, which component to output"); return params; diff --git a/src/postprocessors/FoamSideIntegratedFunctionObject.C b/src/postprocessors/FoamSideIntegratedFunctionObject.C index ebf5ba66..1ff3df74 100644 --- a/src/postprocessors/FoamSideIntegratedFunctionObject.C +++ b/src/postprocessors/FoamSideIntegratedFunctionObject.C @@ -2,16 +2,16 @@ #include "InputParameters.h" #include "MooseEnum.h" -static MooseEnum _pp_function_objects("wallHeatFlux wallShearStress"); - registerMooseObject("hippoApp", FoamSideIntegratedFunctionObject); InputParameters FoamSideIntegratedFunctionObject::validParams() { InputParameters params = FoamSideIntegratedBase::validParams(); + + MooseEnum function_objects("wallHeatFlux wallShearStress"); params.addRequiredParam( - "function_object", _pp_function_objects, "Foam function object"); + "function_object", function_objects, "OpenFOAM function object"); return params; } @@ -21,7 +21,7 @@ FoamSideIntegratedFunctionObject::FoamSideIntegratedFunctionObject(const InputPa { } -Foam::functionObject * +std::unique_ptr FoamSideIntegratedFunctionObject::createFunctionObject(const std::string & fo_name) { auto fo_dict = _foam_mesh->time().controlDict().lookupOrDefault(fo_name, Foam::dictionary()); @@ -33,13 +33,13 @@ FoamSideIntegratedFunctionObject::createFunctionObject(const std::string & fo_na if (fo_name == "wallHeatFlux") { - return static_cast( - new Foam::functionObjects::wallHeatFlux("wallHeatFlux", _foam_mesh->time(), fo_dict)); + return std::make_unique( + "wallHeatFlux", _foam_mesh->time(), fo_dict); } else // wallShearStress { - return static_cast( - new Foam::functionObjects::wallShearStress("wallShearStress", _foam_mesh->time(), fo_dict)); + return std::make_unique( + "wallShearStress", _foam_mesh->time(), fo_dict); } } diff --git a/src/postprocessors/FoamSideIntegratedValue.C b/src/postprocessors/FoamSideIntegratedValue.C index c6e01f8c..512b31b9 100644 --- a/src/postprocessors/FoamSideIntegratedValue.C +++ b/src/postprocessors/FoamSideIntegratedValue.C @@ -8,8 +8,8 @@ InputParameters FoamSideIntegratedValue::validParams() { auto params = FoamSideIntegratedBase::validParams(); - params.addRequiredParam( - "foam_variable", "Foam variable or function object to be averaged over a boundary patch."); + params.addRequiredParam("foam_variable", + "Foam variable to be averaged over a boundary patch."); return params; } diff --git a/test/tests/postprocessors/side_integrated_value/main.i b/test/tests/postprocessors/side_integrated_value/main.i index e7e639fc..efdc99ba 100644 --- a/test/tests/postprocessors/side_integrated_value/main.i +++ b/test/tests/postprocessors/side_integrated_value/main.i @@ -45,7 +45,7 @@ boundary = back execute_on = TIMESTEP_END [] - [U_avg_magnitude_multiple] # should be double U_avg_magnitude_multiple + [U_avg_magnitude_multiple] # should be double U_avg_magnitude type = FoamSideIntegratedValue foam_variable = 'U' boundary = 'back front' From bde9a4b0a80eabe244e21f91a62c5b4fd8aa8b94 Mon Sep 17 00:00:00 2001 From: Matthew Falcone Date: Fri, 6 Feb 2026 14:20:29 +0000 Subject: [PATCH 43/43] Update class descriptions for postprocessors --- include/postprocessors/FoamSideAverageFunctionObject.h | 2 +- include/postprocessors/FoamSideAverageValue.h | 2 +- src/postprocessors/FoamSideAdvectiveFluxIntegral.C | 6 ++---- src/postprocessors/FoamSideAverageFunctionObject.C | 9 +++++++++ src/postprocessors/FoamSideAverageValue.C | 8 ++++++++ src/postprocessors/FoamSideIntegratedFunctionObject.C | 2 ++ src/postprocessors/FoamSideIntegratedValue.C | 1 + 7 files changed, 24 insertions(+), 6 deletions(-) diff --git a/include/postprocessors/FoamSideAverageFunctionObject.h b/include/postprocessors/FoamSideAverageFunctionObject.h index 70b7466d..c74bee38 100644 --- a/include/postprocessors/FoamSideAverageFunctionObject.h +++ b/include/postprocessors/FoamSideAverageFunctionObject.h @@ -6,7 +6,7 @@ class FoamSideAverageFunctionObject : public FoamSideIntegratedFunctionObject { public: - static InputParameters validParams() { return FoamSideIntegratedFunctionObject::validParams(); } + static InputParameters validParams(); FoamSideAverageFunctionObject(const InputParameters & params) : FoamSideIntegratedFunctionObject(params) diff --git a/include/postprocessors/FoamSideAverageValue.h b/include/postprocessors/FoamSideAverageValue.h index 70313bb2..12623583 100644 --- a/include/postprocessors/FoamSideAverageValue.h +++ b/include/postprocessors/FoamSideAverageValue.h @@ -5,7 +5,7 @@ class FoamSideAverageValue : public FoamSideIntegratedValue { public: - static InputParameters validParams() { return FoamSideIntegratedValue::validParams(); } + static InputParameters validParams(); FoamSideAverageValue(const InputParameters & params); diff --git a/src/postprocessors/FoamSideAdvectiveFluxIntegral.C b/src/postprocessors/FoamSideAdvectiveFluxIntegral.C index 2c8b35b8..0d3e1fd4 100644 --- a/src/postprocessors/FoamSideAdvectiveFluxIntegral.C +++ b/src/postprocessors/FoamSideAdvectiveFluxIntegral.C @@ -1,8 +1,6 @@ -#include "ElementUserObject.h" #include "FoamSideAdvectiveFluxIntegral.h" #include "InputParameters.h" #include "MooseTypes.h" -#include "FoamMesh.h" registerMooseObject("hippoApp", FoamSideAdvectiveFluxIntegral); @@ -10,8 +8,8 @@ InputParameters FoamSideAdvectiveFluxIntegral::validParams() { auto params = FoamSidePostprocessor::validParams(); - params.addClassDescription( - "Class that calculates the advected flux of a scalar on an OpenFOAM boundary patch."); + params.addClassDescription("Class that calculates the integrated advective flux of a scalar over " + "OpenFOAM boundary patches."); params.addRequiredParam("foam_scalar", "Foam scalar being advected."); params.addParam("advective_velocity", "U", "Advection velocity"); return params; diff --git a/src/postprocessors/FoamSideAverageFunctionObject.C b/src/postprocessors/FoamSideAverageFunctionObject.C index 8a9ee69a..4fda2118 100644 --- a/src/postprocessors/FoamSideAverageFunctionObject.C +++ b/src/postprocessors/FoamSideAverageFunctionObject.C @@ -2,6 +2,15 @@ registerMooseObject("hippoApp", FoamSideAverageFunctionObject); +InputParameters +FoamSideAverageFunctionObject::validParams() +{ + InputParameters params = FoamSideIntegratedFunctionObject::validParams(); + params.addClassDescription( + "Class that averages a function object over OpenFOAM boundary patches."); + return params; +} + void FoamSideAverageFunctionObject::compute() { diff --git a/src/postprocessors/FoamSideAverageValue.C b/src/postprocessors/FoamSideAverageValue.C index b7562ed6..60cc3894 100644 --- a/src/postprocessors/FoamSideAverageValue.C +++ b/src/postprocessors/FoamSideAverageValue.C @@ -3,6 +3,14 @@ registerMooseObject("hippoApp", FoamSideAverageValue); +InputParameters +FoamSideAverageValue::validParams() +{ + InputParameters params = FoamSideIntegratedValue::validParams(); + params.addClassDescription("Class that averages a variable over OpenFOAM boundary patches."); + return params; +} + FoamSideAverageValue::FoamSideAverageValue(const InputParameters & params) : FoamSideIntegratedValue(params) { diff --git a/src/postprocessors/FoamSideIntegratedFunctionObject.C b/src/postprocessors/FoamSideIntegratedFunctionObject.C index 1ff3df74..f14b8b3c 100644 --- a/src/postprocessors/FoamSideIntegratedFunctionObject.C +++ b/src/postprocessors/FoamSideIntegratedFunctionObject.C @@ -12,6 +12,8 @@ FoamSideIntegratedFunctionObject::validParams() MooseEnum function_objects("wallHeatFlux wallShearStress"); params.addRequiredParam( "function_object", function_objects, "OpenFOAM function object"); + params.addClassDescription( + "Class that integrates a function object over OpenFOAM boundary patches."); return params; } diff --git a/src/postprocessors/FoamSideIntegratedValue.C b/src/postprocessors/FoamSideIntegratedValue.C index 512b31b9..9609b599 100644 --- a/src/postprocessors/FoamSideIntegratedValue.C +++ b/src/postprocessors/FoamSideIntegratedValue.C @@ -10,6 +10,7 @@ FoamSideIntegratedValue::validParams() auto params = FoamSideIntegratedBase::validParams(); params.addRequiredParam("foam_variable", "Foam variable to be averaged over a boundary patch."); + params.addClassDescription("Class that integrates a variable over OpenFOAM boundary patches."); return params; }