/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2021-2022 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::patchToPatches::intersection
Description
Class to generate patchToPatch coupling geometry. A full geometric
intersection is done between a face and those opposite, and coupling
geometry is calculated accordingly.
SourceFiles
intersection.C
\*---------------------------------------------------------------------------*/
#ifndef intersectionPatchToPatch_H
#define intersectionPatchToPatch_H
#include "patchToPatch.H"
#include "polygonTriangulate.H"
#include "triFaceList.H"
#include "triIntersectLocation.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace patchToPatches
{
/*---------------------------------------------------------------------------*\
Class intersection Declaration
\*---------------------------------------------------------------------------*/
class intersection
:
public patchToPatch
{
public:
// Public Structures
//- Structure to store the geometry associated with part of a patch
// face
struct part
{
//- The area of this part
vector area;
//- The centre of this part
point centre;
//- Default construct
part()
:
area(Zero),
centre(NaN())
{}
//- Default construct
part(const zero&)
:
part()
{}
//- Construct from an area and a centre
part(const vector& a, const point& c)
:
area(a),
centre(c)
{}
//- Construct from a polygon
template
part(const PointField& ps)
:
area(face::area(ps)),
centre(face::centre(ps))
{}
//- Negate this part
part operator-() const
{
return part(- area, centre);
}
//- Add another part to this one
void operator+=(const part& p)
{
const scalar magArea = mag(area);
const scalar magPArea = mag(p.area);
area = area + p.area;
centre =
magArea == 0 ? p.centre
: magPArea == 0 ? centre
: (magArea*centre + magPArea*p.centre)/(magArea + magPArea);
}
//- Subtract another part from this one
void operator-=(const part& p)
{
this->operator+=(-p);
}
//- Equality comparison
friend bool operator==(const part& a, const part& b)
{
return a.area == b.area && a.centre == b.centre;
}
//- Inequality comparison
friend bool operator!=(const part& a, const part& b)
{
return !(a == b);
}
//- Output stream operator
friend Ostream& operator<<(Ostream& os, const part& p)
{
return os << p.area << p.centre;
}
//- Input stream operator
friend Istream& operator>>(Istream& is, part& p)
{
return is >> p.area >> p.centre;
}
};
//- Structure to store the geometry associated with the coupling
// between parts of two patch faces
struct couple
:
public part
{
//- The neighbour part
part nbr;
//- Default construct
couple()
:
part(),
nbr()
{}
//- Construct from a coupled pair of parts
couple(const part& p, const part& nbrP)
:
part(p),
nbr(nbrP)
{}
//- Equality comparison
friend bool operator==(const couple& a, const couple& b)
{
return
static_cast(a) == static_cast(b)
&& a.nbr == b.nbr;
}
//- Inequality comparison
friend bool operator!=(const couple& a, const couple& b)
{
return !(a == b);
}
//- Output stream operator
friend Ostream& operator<<(Ostream& os, const couple& c)
{
return os << static_cast(c) << c.nbr;
}
//- Input stream operator
friend Istream& operator>>(Istream& is, couple& c)
{
return is >> static_cast(c) >> c.nbr;
}
};
private:
// Private Member Data
// Geometry
//- The coupling geometry for for each source face
List> srcCouples_;
//- The proportion of the source faces that are coupled
List srcCoverage_;
//- The non-coupled geometry associated with each source edge
List srcEdgeParts_;
//- The non-coupled geometry associated with mismatch in each
// source face's couplings
List srcErrorParts_;
//- The coupling geometry for for each target face
List> tgtCouples_;
//- The proportion of the target faces that are coupled
List tgtCoverage_;
//- Triangulation engine
mutable polygonTriangulate triEngine_;
// Workspace
//- Source face triangulation points
mutable List srcTriPoints_;
//- Source face triangulation edges
mutable List>> srcTriFaceEdges_;
//- Target face triangulation points
mutable List tgtTriPoints_;
//- Target face triangulation edges
mutable List>> tgtTriFaceEdges_;
//- Source intersection points
mutable DynamicList ictSrcPoints_;
//- Source intersection point normals
mutable DynamicList ictSrcPointNormals_;
//- Target intersection points
mutable DynamicList ictTgtPoints_;
//- Intersection locations
mutable DynamicList ictPointLocations_;
//- Source face edge parts
DynamicList srcFaceEdgePart_;
//- Target face edge parts
DynamicList tgtFaceEdgePart_;
//- Source face edge parts
List> srcFaceEdgeParts_;
// Debugging
//- Intersection points
mutable DynamicList debugPoints_;
//- Intersection faces
mutable DynamicList debugFaces_;
//- The source face associated with each intersection face
mutable DynamicList