/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify i
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 "cellCellStencil.H"
#include "addToRunTimeSelectionTable.H"
#include "volFields.H"
#include "syncTools.H"
#include "globalIndex.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(cellCellStencil, 0);
defineRunTimeSelectionTable(cellCellStencil, mesh);
}
const Foam::Enum
<
Foam::cellCellStencil::cellType
>
Foam::cellCellStencil::cellTypeNames_
{
{ cellType::CALCULATED, "calculated" },
{ cellType::INTERPOLATED, "interpolated" },
{ cellType::HOLE, "hole" },
};
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::cellCellStencil::cellCellStencil(const fvMesh& mesh)
:
mesh_(mesh)
{}
Foam::autoPtr Foam::cellCellStencil::New
(
const fvMesh& mesh,
const dictionary& dict
)
{
if (debug)
{
InfoInFunction << "Constructing cellCellStencil" << endl;
}
const word stencilType(dict.get("method"));
auto cstrIter = meshConstructorTablePtr_->cfind(stencilType);
if (!cstrIter.found())
{
FatalErrorInFunction
<< "Unknown cellCellStencil type "
<< stencilType << nl << nl
<< "Valid cellCellStencil types :" << endl
<< meshConstructorTablePtr_->sortedToc()
<< abort(FatalError);
}
return autoPtr(cstrIter()(mesh, dict, true));
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::cellCellStencil::~cellCellStencil()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::labelIOList& Foam::cellCellStencil::zoneID(const fvMesh& mesh)
{
if (!mesh.foundObject("zoneID"))
{
labelIOList* zoneIDPtr = new labelIOList
(
IOobject
(
"zoneID",
mesh.facesInstance(),
polyMesh::meshSubDir,
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh.nCells()
);
labelIOList& zoneID = *zoneIDPtr;
volScalarField volZoneID
(
IOobject
(
"zoneID",
mesh.time().findInstance(mesh.dbDir(), "zoneID"),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
),
mesh
);
forAll(volZoneID, cellI)
{
zoneID[cellI] = label(volZoneID[cellI]);
}
zoneIDPtr->store();
}
return mesh.lookupObject("zoneID");
}
Foam::labelList Foam::cellCellStencil::count
(
const label size,
const labelUList& lst
)
{
labelList count(size, 0);
forAll(lst, i)
{
count[lst[i]]++;
}
Pstream::listCombineGather(count, plusEqOp