/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2016-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 .
Application
createPatch
Group
grpMeshManipulationUtilities
Description
Create patches out of selected boundary faces, which are either
from existing patches or from a faceSet.
More specifically it:
- creates new patches (from selected boundary faces).
Synchronise faces on coupled patches.
- synchronises points on coupled boundaries
- remove patches with 0 faces in them
\*---------------------------------------------------------------------------*/
#include "cyclicPolyPatch.H"
#include "syncTools.H"
#include "argList.H"
#include "Time.H"
#include "OFstream.H"
#include "meshTools.H"
#include "faceSet.H"
#include "IOPtrList.H"
#include "polyTopoChange.H"
#include "polyModifyFace.H"
#include "wordRes.H"
#include "processorMeshes.H"
#include "IOdictionary.H"
#include "regionProperties.H"
#include "faceAreaWeightAMI2D.H"
#include "fvMeshTools.H"
#include "ReadFields.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
defineTemplateTypeNameAndDebug(IOPtrList, 0);
}
word patchName(const word& name, const fvMesh& mesh0, const fvMesh& mesh1)
{
word pName(name != "none" ? name : word::null);
pName += mesh0.name();
pName += "_to_";
pName += mesh1.name();
return pName;
}
void matchPatchFaces
(
const word& entryName,
const word& AMIMethod,
const dictionary& AMIDict,
const PtrList& meshes,
const label meshi,
const label nSourcei,
const label sourcei,
const labelList& patchesi,
const label meshj,
const label nSourcej,
const label sourcej,
const labelList& patchesj,
DynamicList& interfaceMesh0,
DynamicList& interfacePatch0,
DynamicList& interfaceNames0,
DynamicList>>& interfaceFaces0,
DynamicList& interfaceMesh1,
DynamicList& interfacePatch1,
DynamicList& interfaceNames1,
DynamicList>>& interfaceFaces1
)
{
// Now we have:
// - meshi, sourcei, patchesi
// - meshj, sourcej, patchesj
// Attempt to match patches
forAll(patchesi, i)
{
const auto& ppi = meshes[meshi].boundaryMesh()[patchesi[i]];
forAll(patchesj, j)
{
const auto& ppj = meshes[meshj].boundaryMesh()[patchesj[j]];
// Use AMI to try and find matches
auto AMPtr(AMIInterpolation::New(AMIMethod, AMIDict));
AMPtr->calculate(ppi, ppj, nullptr);
if
(
gAverage(AMPtr->tgtWeightsSum()) > SMALL
|| gAverage(AMPtr->srcWeightsSum()) > SMALL
)
{
const label inti = interfaceMesh0.size();
Info<< "Introducing interface " << inti << " between"
<< " mesh " << meshes[meshi].name()
<< " patch " << ppi.name()
<< " and mesh " << meshes[meshj].name()
<< " patch " << ppj.name()
<< endl;
// Mesh 0
//~~~~~~~
interfaceMesh0.append(labelList());
auto& intMesh0 = interfaceMesh0.last();
intMesh0.setSize(nSourcei, -1);
intMesh0[sourcei] = meshi;
interfacePatch0.append(labelList());
auto& intPatch0 = interfacePatch0.last();
intPatch0.setSize(nSourcei, -1);
intPatch0[sourcei] = ppi.index();
interfaceNames0.append(wordList());
auto& intNames0 = interfaceNames0.last();
intNames0.setSize(nSourcei);
//intNames0[sourcei] =
// meshes[meshi].name()
// + "_to_"
// + meshes[meshj].name();
intNames0[sourcei] =
patchName(entryName, meshes[meshi], meshes[meshj]);
// Mesh 0
//~~~~~~~
interfaceMesh1.append(labelList());
auto& intMesh1 = interfaceMesh1.last();
intMesh1.setSize(nSourcej, -1);
intMesh1[sourcej] = meshj;
interfacePatch1.append(labelList());
auto& intPatch1 = interfacePatch1.last();
intPatch1.setSize(nSourcej, -1);
intPatch1[sourcej] = ppj.index();
interfaceNames1.append(wordList());
auto& intNames1 = interfaceNames1.last();
intNames1.setSize(nSourcej);
//intNames1[sourcej] =
// meshes[meshj].name()
// + "_to_"
// + meshes[meshi].name();
intNames1[sourcej] =
patchName(entryName, meshes[meshj], meshes[meshi]);
interfaceFaces0.append(List>());
auto& intFaces0 = interfaceFaces0.last();
intFaces0.setSize(nSourcei);
DynamicList