/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2021 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 .
\*---------------------------------------------------------------------------*/
#include "STARCDsurfaceFormat.H"
#include "ListOps.H"
#include "polygonTriangulate.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template
inline void Foam::fileFormats::STARCDsurfaceFormat::writeShell
(
Ostream& os,
const Face& f,
const label cellId,
const label cellTableId
)
{
os << cellId // includes 1 offset
<< ' ' << starcdShellShape_ // 3(shell) shape
<< ' ' << f.size()
<< ' ' << cellTableId
<< ' ' << starcdShellType_; // 4(shell)
// primitives have <= 8 vertices, but prevent overrun anyhow
// indent following lines for ease of reading
label count = 0;
forAll(f, fp)
{
if ((count % 8) == 0)
{
os << nl << " " << cellId;
}
os << ' ' << f[fp] + 1;
count++;
}
os << endl;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template
Foam::fileFormats::STARCDsurfaceFormat::STARCDsurfaceFormat
(
const fileName& filename
)
{
read(filename);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template
bool Foam::fileFormats::STARCDsurfaceFormat::read
(
const fileName& filename
)
{
const bool mustTriangulate = this->isTri();
this->clear();
fileName baseName = filename.lessExt();
// read cellTable names (if possible)
Map cellTableLookup;
{
IFstream is(baseName + ".inp");
if (is.good())
{
cellTableLookup = readInpCellTable(is);
}
}
// STAR-CD index of points
List