From 6a8ddbb296f5680c39b9630cad379149b1639e3c Mon Sep 17 00:00:00 2001 From: Andrew Heather <> Date: Wed, 16 Mar 2022 19:32:44 +0000 Subject: [PATCH] ENH: Added new solidBodyFvGeometryScheme Geometry calculation scheme that performs geometry updates only in regions where the mesh has changed, identified by comparing current and old points. Example usage in fvSchemes: geometry { type solidBody; // Optional entries // If set to false, update the entire mesh partialUpdate yes; // Cache the motion addressing (changed points, faces, cells etc) cacheMotion yes; } --- src/finiteVolume/Make/files | 1 + .../solidBody/solidBodyFvGeometryScheme.C | 341 ++++++++++++++++++ .../solidBody/solidBodyFvGeometryScheme.H | 141 ++++++++ 3 files changed, 483 insertions(+) create mode 100644 src/finiteVolume/fvMesh/fvGeometryScheme/solidBody/solidBodyFvGeometryScheme.C create mode 100644 src/finiteVolume/fvMesh/fvGeometryScheme/solidBody/solidBodyFvGeometryScheme.H diff --git a/src/finiteVolume/Make/files b/src/finiteVolume/Make/files index 44c72d11ae..00124f2636 100644 --- a/src/finiteVolume/Make/files +++ b/src/finiteVolume/Make/files @@ -8,6 +8,7 @@ $(fvGeometryScheme)/highAspectRatio/highAspectRatioFvGeometryScheme.C $(fvGeometryScheme)/highAspectRatio/cellAspectRatio.C $(fvGeometryScheme)/averageNeighbour/averageNeighbourFvGeometryScheme.C $(fvGeometryScheme)/stabilised/stabilisedFvGeometryScheme.C +$(fvGeometryScheme)/solidBody/solidBodyFvGeometryScheme.C surfaceInterpolation = interpolation/surfaceInterpolation $(surfaceInterpolation)/surfaceInterpolation/surfaceInterpolation.C diff --git a/src/finiteVolume/fvMesh/fvGeometryScheme/solidBody/solidBodyFvGeometryScheme.C b/src/finiteVolume/fvMesh/fvGeometryScheme/solidBody/solidBodyFvGeometryScheme.C new file mode 100644 index 0000000000..7c48fb9fb6 --- /dev/null +++ b/src/finiteVolume/fvMesh/fvGeometryScheme/solidBody/solidBodyFvGeometryScheme.C @@ -0,0 +1,341 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2021-2022 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 "solidBodyFvGeometryScheme.H" +#include "addToRunTimeSelectionTable.H" +#include "surfaceFields.H" +#include "primitiveMeshTools.H" +#include "emptyPolyPatch.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(solidBodyFvGeometryScheme, 0); + addToRunTimeSelectionTable + ( + fvGeometryScheme, + solidBodyFvGeometryScheme, + dict + ); +} + + +void Foam::solidBodyFvGeometryScheme::setMeshMotionData() +{ + if (!cacheInitialised_ || !cacheMotion_) + { + DebugInFunction << "Creating cache" << endl; + + changedFaceIDs_.clear(); // used for face areas, meshPhi + changedPatchIDs_.clear(); // used for meshPhi + changedCellIDs_.clear(); // used for cell volumes + + const pointField& oldPoints = mesh_.oldPoints(); + const pointField& currPoints = mesh_.points(); + + if (oldPoints.size() != currPoints.size()) + { + FatalErrorInFunction + << "Old and current points sizes must be the same. " + << "Old points:" << oldPoints.size() + << " Current points:" << currPoints.size() + << abort(FatalError); + } + + bitSet changedPoints(oldPoints.size()); + + // Check for non-identical points + forAll(changedPoints, pointi) + { + changedPoints.set(pointi, oldPoints[pointi] != currPoints[pointi]); + } + + DebugInfo + << "SBM --- Changed points:" + << returnReduce(changedPoints.count(), sumOp