/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 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 .
Description
boundary faces
- use pointCells when searching for connectivity
- initialize the cell connectivity with '-1'
- find both cell faces corresponding to the baffles and mark them
to prevent a connection
- standard connectivity checks
- added baffle and monitoring support
\*---------------------------------------------------------------------------*/
#include "meshReader.H"
#include "Time.H"
#include "polyPatch.H"
#include "emptyPolyPatch.H"
#include "preservePatchTypes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void Foam::meshReader::addPolyBoundaryFace
(
const label cellId,
const label cellFaceId,
const label nCreatedFaces
)
{
#ifdef DEBUG_BOUNDARY
Info<< nCreatedFaces
<< " add bnd for cell " << cellId
<< " face " << cellFaceId
<< " (original cell " << origCellId_[cellId] << ")"
<< endl;
#endif
// standard case: volume cells
const face& thisFace = cellFaces_[cellId][cellFaceId];
// Debugging
if (cellPolys_[cellId][cellFaceId] > nInternalFaces_)
{
InfoInFunction
<< "Problem with face: " << thisFace << endl
<< "Probably multiple definitions "
<< "of a single boundary face." << endl
<< endl;
}
else if (cellPolys_[cellId][cellFaceId] >= 0)
{
InfoInFunction
<< "Problem with face: " << thisFace << endl
<< "Probably trying to define a boundary face "
<< "on a previously matched internal face." << endl
<< "Internal face: "
<< meshFaces_[cellPolys_[cellId][cellFaceId]]
<< endl;
}
meshFaces_[nCreatedFaces] = thisFace;
cellPolys_[cellId][cellFaceId] = nCreatedFaces;
}
void Foam::meshReader::addPolyBoundaryFace
(
const cellFaceIdentifier& identifier,
const label nCreatedFaces
)
{
addPolyBoundaryFace(identifier.cell, identifier.face, nCreatedFaces);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void Foam::meshReader::createPolyBoundary()
{
label nBoundaryFaces = 0;
label nMissingFaces = 0;
label nInterfaces = 0;
const faceListList& cFaces = cellFaces();
// determine number of non-patched faces:
forAll(cellPolys_, cellI)
{
cell& curCell = cellPolys_[cellI];
forAll(curCell, fI)
{
if (curCell[fI] < 0)
{
nMissingFaces++;
}
}
}
forAll(boundaryIds_, patchI)
{
nBoundaryFaces += boundaryIds_[patchI].size();
}
Info<< nl
<< "There are " << nMissingFaces
<< " faces to be patched and " << nBoundaryFaces
<< " specified - collect missed boundaries to final patch" << endl;
patchStarts_.setSize(boundaryIds_.size());
patchSizes_.setSize(boundaryIds_.size());
label nCreatedFaces = nInternalFaces_;
label baffleOffset = cFaces.size();
interfaces_.setSize(baffleIds_.size());
nBoundaryFaces = 0;
forAll(boundaryIds_, patchI)
{
const List& idList = boundaryIds_[patchI];
patchStarts_[patchI] = nCreatedFaces;
// write each baffle side separately
if (patchPhysicalTypes_[patchI] == "baffle")
{
label count = 0;
for (label side = 0; side < 2; ++side)
{
label position = nInterfaces;
forAll(idList, bndI)
{
label baffleI = idList[bndI].cell - baffleOffset;
if
(
baffleI >= 0
&& baffleI < baffleFaces_.size()
&& baffleIds_[baffleI].size()
)
{
addPolyBoundaryFace
(
baffleIds_[baffleI][side],
nCreatedFaces
);
// remove applied boundaries (2nd pass)
if (side == 1)
{
baffleIds_[baffleI].clear();
}
interfaces_[position][side] = nCreatedFaces;
nBoundaryFaces++;
nCreatedFaces++;
position++;
count++;
}
}
}
nInterfaces += (count - (count % 2)) / 2;
}
else if (patchPhysicalTypes_[patchI] == "monitoring")
{
// translate the "monitoring" pseudo-boundaries to face sets
List