From a13e00b5c469e21a6b91f783f021419a8fdc8e40 Mon Sep 17 00:00:00 2001 From: Andrew Heather <> Date: Thu, 7 Mar 2019 20:25:23 +0000 Subject: [PATCH] ENH: AMI - multiple updates - start of work to create a 1-to-1 face mapping across AMI patches - faces are inserted according to the AMI addressing based on Horacio's method - removed 'updated' flag and reworked some demand driven updates - updated to handle 'walking' through baffles - use bitSet instead of boolList - moved update of meshPhi to movePoints() functions at fvPatch level - moved scaling of areas to movePoints() functions at fvPatch level - rehomed topology change code to own file - added warning re: geometry construction ACMI - split srcMask into srcMask and srcAreaMask - former in range 0-1, and latter has bounding or tol to (1-tol) to avoid sigFpe's --- src/OpenFOAM/meshes/polyMesh/polyMeshUpdate.C | 1 + .../polyPatches/polyPatch/polyPatch.C | 1 + .../polyPatches/polyPatch/polyPatch.H | 14 + src/dynamicFvMesh/Make/files | 5 + .../dynamicMotionSolverFvMesh.C | 3 + .../dynamicMotionSolverFvMeshAMI.C | 216 ++++++ .../dynamicMotionSolverFvMeshAMI.H | 121 ++++ src/finiteVolume/Make/options | 3 +- .../cyclicACMI/cyclicACMIFvPatchField.H | 2 +- src/finiteVolume/fvMesh/fvMesh.C | 21 +- src/finiteVolume/fvMesh/fvMesh.H | 2 + .../constraint/cyclicACMI/cyclicACMIFvPatch.C | 143 ++-- .../constraint/cyclicACMI/cyclicACMIFvPatch.H | 24 +- .../constraint/cyclicAMI/cyclicAMIFvPatch.C | 77 +- .../constraint/cyclicAMI/cyclicAMIFvPatch.H | 3 + .../surfaceInterpolation.C | 1 - .../AMIInterpolation/AMIInterpolation.C | 142 +++- .../AMIInterpolation/AMIInterpolation.H | 35 +- .../AMIInterpolation/AMIInterpolationI.H | 16 + .../AMIMethod/AMIMethod/AMIMethod.C | 18 +- .../AMIMethod/AMIMethod/AMIMethod.H | 12 +- .../AMIMethod/directAMI/directAMI.C | 8 +- .../AMIMethod/directAMI/directAMI.H | 3 +- .../faceAreaWeightAMI/faceAreaWeightAMI.C | 300 ++++---- .../faceAreaWeightAMI/faceAreaWeightAMI.H | 21 +- .../AMIMethod/mapNearestAMI/mapNearestAMI.C | 8 +- .../AMIMethod/mapNearestAMI/mapNearestAMI.H | 3 +- .../partialFaceAreaWeightAMI.C | 16 +- .../partialFaceAreaWeightAMI.H | 30 +- .../AMIInterpolation/findNearestMaskedOp.H | 62 ++ .../faceAreaIntersect/faceAreaIntersect.C | 135 ++-- .../faceAreaIntersect/faceAreaIntersect.H | 19 +- .../faceAreaIntersect/faceAreaIntersectI.H | 9 + .../cyclicACMIPolyPatch/cyclicACMIPolyPatch.C | 379 +++++----- .../cyclicACMIPolyPatch/cyclicACMIPolyPatch.H | 54 +- .../cyclicACMIPolyPatchI.H | 18 +- .../cyclicAMIPolyPatch/cyclicAMIPolyPatch.C | 299 +++++--- .../cyclicAMIPolyPatch/cyclicAMIPolyPatch.H | 95 ++- .../cyclicAMIPolyPatch/cyclicAMIPolyPatchI.H | 63 ++ .../cyclicAMIPolyPatchTopologyChange.C | 676 ++++++++++++++++++ src/meshTools/Make/files | 1 + src/meshTools/Make/options | 3 +- src/meshTools/polyTopoChange/polyTopoChange.H | 27 +- 43 files changed, 2435 insertions(+), 654 deletions(-) create mode 100644 src/dynamicFvMesh/dynamicMotionSolverFvMeshAMI/dynamicMotionSolverFvMeshAMI.C create mode 100644 src/dynamicFvMesh/dynamicMotionSolverFvMeshAMI/dynamicMotionSolverFvMeshAMI.H create mode 100644 src/meshTools/AMIInterpolation/AMIInterpolation/findNearestMaskedOp.H create mode 100644 src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatchTopologyChange.C diff --git a/src/OpenFOAM/meshes/polyMesh/polyMeshUpdate.C b/src/OpenFOAM/meshes/polyMesh/polyMeshUpdate.C index 80232d4498..e5818171d5 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyMeshUpdate.C +++ b/src/OpenFOAM/meshes/polyMesh/polyMeshUpdate.C @@ -45,6 +45,7 @@ void Foam::polyMesh::updateMesh(const mapPolyMesh& mpm) << "Updating addressing and (optional) pointMesh/pointFields" << endl; // Update boundaryMesh (note that patches themselves already ok) +// boundary_.updateMesh(mpm); boundary_.updateMesh(); // Update zones diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.C index 3e915b3e7e..6db7dc22fc 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.C +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.C @@ -63,6 +63,7 @@ void Foam::polyPatch::movePoints(PstreamBuffers&, const pointField& p) primitivePatch::movePoints(p); } + void Foam::polyPatch::updateMesh(PstreamBuffers&) { primitivePatch::clearGeom(); diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.H b/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.H index 08bbf0c732..f7f01abb09 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.H +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.H @@ -55,6 +55,7 @@ namespace Foam // Forward declarations class polyBoundaryMesh; class polyPatch; +class polyTopoChange; class PstreamBuffers; Ostream& operator<<(Ostream&, const polyPatch&); @@ -419,6 +420,19 @@ public: labelList& rotation ) const; + //- For dynamic mesh cases - return true if this patch will change the + //- topology + virtual bool changeTopology() const + { + return false; + } + + //- Collect topology changes in a polyTopoChange object + virtual bool setTopology(polyTopoChange&) + { + return false; + } + // Member operators diff --git a/src/dynamicFvMesh/Make/files b/src/dynamicFvMesh/Make/files index b8432c07c9..794af6f3d0 100644 --- a/src/dynamicFvMesh/Make/files +++ b/src/dynamicFvMesh/Make/files @@ -10,4 +10,9 @@ dynamicMotionSolverListFvMesh/dynamicMotionSolverListFvMesh.C simplifiedDynamicFvMesh/simplifiedDynamicFvMeshes.C simplifiedDynamicFvMesh/simplifiedDynamicFvMesh.C + + +dynamicMotionSolverFvMeshAMI/dynamicMotionSolverFvMeshAMI.C + + LIB = $(FOAM_LIBBIN)/libdynamicFvMesh diff --git a/src/dynamicFvMesh/dynamicMotionSolverFvMesh/dynamicMotionSolverFvMesh.C b/src/dynamicFvMesh/dynamicMotionSolverFvMesh/dynamicMotionSolverFvMesh.C index ba1d636969..5b7a90cddc 100644 --- a/src/dynamicFvMesh/dynamicMotionSolverFvMesh/dynamicMotionSolverFvMesh.C +++ b/src/dynamicFvMesh/dynamicMotionSolverFvMesh/dynamicMotionSolverFvMesh.C @@ -92,6 +92,9 @@ const Foam::motionSolver& Foam::dynamicMotionSolverFvMesh::motion() const bool Foam::dynamicMotionSolverFvMesh::update() { + // Scan through AMI patches and update + + fvMesh::movePoints(motionPtr_->newPoints()); volVectorField* Uptr = getObjectPtr("U"); diff --git a/src/dynamicFvMesh/dynamicMotionSolverFvMeshAMI/dynamicMotionSolverFvMeshAMI.C b/src/dynamicFvMesh/dynamicMotionSolverFvMeshAMI/dynamicMotionSolverFvMeshAMI.C new file mode 100644 index 0000000000..5de3713a53 --- /dev/null +++ b/src/dynamicFvMesh/dynamicMotionSolverFvMeshAMI/dynamicMotionSolverFvMeshAMI.C @@ -0,0 +1,216 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2019-2020 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 "dynamicMotionSolverFvMeshAMI.H" +#include "addToRunTimeSelectionTable.H" +#include "motionSolver.H" +#include "volFields.H" +#include "surfaceFields.H" +#include "cyclicAMIPolyPatch.H" +#include "polyTopoChange.H" +#include "MeshObject.H" +#include "lduMesh.H" + +#include "processorFvPatch.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(dynamicMotionSolverFvMeshAMI, 0); + addToRunTimeSelectionTable + ( + dynamicFvMesh, + dynamicMotionSolverFvMeshAMI, + IOobject + ); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::dynamicMotionSolverFvMeshAMI::dynamicMotionSolverFvMeshAMI +( + const IOobject& io +) +: + dynamicFvMesh(io), + motionPtr_(motionSolver::New(*this)) +{} + + +Foam::dynamicMotionSolverFvMeshAMI::dynamicMotionSolverFvMeshAMI +( + const IOobject& io, + pointField&& points, + faceList&& faces, + labelList&& allOwner, + labelList&& allNeighbour, + const bool syncPar +) +: + dynamicFvMesh + ( + io, + std::move(points), + std::move(faces), + std::move(allOwner), + std::move(allNeighbour), + syncPar + ), + motionPtr_(motionSolver::New(*this)) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +const Foam::motionSolver& Foam::dynamicMotionSolverFvMeshAMI::motion() const +{ + return *motionPtr_; +} + + +bool Foam::dynamicMotionSolverFvMeshAMI::update() +{ + // Mesh not moved/changed yet + moving(false); + topoChanging(false); + + if (debug) + { + for (const fvPatch& fvp : boundary()) + { + if (!isA(fvp)) + { + Info<< "1 --- patch:" << fvp.patch().name() + << " area:" << gSum(fvp.magSf()) << endl; + } + } + } + + pointField newPoints(motionPtr_->curPoints()); + + polyBoundaryMesh& pbm = const_cast(boundaryMesh()); + + // Scan all patches and see if we want to apply a mesh topology update + bool changeRequired = false; + for (polyPatch& pp : pbm) + { + DebugInfo + << "pre-topology change: patch " << pp.name() + << " size:" << returnReduce(pp.size(), sumOp