/*---------------------------------------------------------------------------*\
========= |
\\ / 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-2024 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 .
\*---------------------------------------------------------------------------*/
#include "STARCDedgeFormat.H"
#include "ListOps.H"
#include "clock.H"
#include "bitSet.H"
#include "StringStream.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
inline void Foam::fileFormats::STARCDedgeFormat::writeLines
(
Ostream& os,
const edgeList& edges,
label starCellId
)
{
starCellId = max(1, starCellId); // Enforce 1-based cellId
for (const edge& e : edges)
{
os << starCellId
<< ' ' << starcdLine // 2(line) shape
<< ' ' << e.size()
<< ' ' << 401 // arbitrary value
<< ' ' << starcdLineType; // 5(line)
os << nl
<< " " << starCellId << " "
<< (e[0]+1) << " " << (e[1]+1) << nl;
++starCellId;
}
}
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
void Foam::fileFormats::STARCDedgeFormat::writeCase
(
Ostream& os,
const pointField& pointLst,
const label nEdges
)
{
const word caseName = os.name().stem();
os << "! STARCD file written " << clock::dateTime().c_str() << nl
<< "! " << pointLst.size() << " points, " << nEdges << " lines" << nl
<< "! case " << caseName << nl
<< "! ------------------------------" << nl;
// forAll(zoneLst, zoneI)
// {
// os << "ctable " << zoneI + 1 << " line" << nl
// << "ctname " << zoneI + 1 << " "
// << zoneLst[zoneI].name() << nl;
// }
os << "! ------------------------------" << nl
<< "*set icvo mxv - 1" << nl
<< "vread " << caseName << ".vrt icvo,,,coded" << nl
<< "cread " << caseName << ".cel icvo,,,add,coded" << nl
<< "*set icvo" << nl
<< "! end" << nl;
os.flush();
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::fileFormats::STARCDedgeFormat::STARCDedgeFormat
(
const fileName& filename
)
{
read(filename);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::fileFormats::STARCDedgeFormat::read
(
const fileName& filename
)
{
clear();
const fileName prefix(filename.lessExt());
// STARCD index of points
List