/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016 Shell Research Ltd.
Copyright (C) 2019 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 .
\*---------------------------------------------------------------------------*/
// Read spec that resemble this:
//
// xmesh
// (
// ( -8.18 14 0.83 )
// ( -0.69 11 1.00 )
// ( 0.69 14 1.20 )
// ( 8.18 0 )
// )
//
// ymesh
// (
// ...
// )
#include "PDRlegacy.H"
// OpenFOAM includes
#include "error.H"
#include "IFstream.H"
#include "stringOps.H"
#include "OSspecific.H"
#define XMESH_TAG "xmesh"
#define YMESH_TAG "ymesh"
#define ZMESH_TAG "zmesh"
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
namespace Foam
{
namespace PDRlegacy
{
namespace Detail
{
//- Simple structure for processing a mesh spec entry
// Handles an entry with (float), (float int), or (float int float)
//
// This is for handling a sub-spec that resembles this:
//
// (
// ( -8.18 14 0.83 )
// ( -0.69 11 1.00 )
// ( 0.69 14 1.20 )
// ( 8.18 0 )
// )
struct pdrMeshSpecLine
{
scalar knot;
label ndiv;
scalar factor;
pdrMeshSpecLine() : knot(0), ndiv(0), factor(0) {}
//- Cheap means to avoid uniform list output
bool operator!=(const pdrMeshSpecLine&) const
{
return false;
}
};
// Read mesh-spec entry
Istream& operator>>(Istream& is, pdrMeshSpecLine& spec)
{
spec.knot = 0;
spec.ndiv = 0;
spec.factor = 0;
is.readBegin("pdrMeshSpecLine");
// Must have a point
is >> spec.knot;
token tok(is);
if (tok.isLabel())
{
spec.ndiv = tok.labelToken();
if (spec.ndiv)
{
is >> spec.factor;
}
}
else
{
is.putBack(tok);
}
is.readEnd("pdrMeshSpecLine");
is.check(FUNCTION_NAME);
return is;
}
#ifdef FULLDEBUG
// Write mesh-spec entry
Ostream& operator<<(Ostream& os, const pdrMeshSpecLine& spec)
{
os << token::BEGIN_LIST << spec.knot;
if (spec.ndiv)
{
os << token::SPACE << spec.ndiv
<< token::SPACE << spec.factor;
}
os << token::END_LIST;
return os;
}
#endif
void read_spec(ISstream& is, const direction cmpt, List& gridPoint)
{
if (!gridPoint.empty())
{
FatalErrorInFunction
<< "Duplicate specification of "
<< vector::componentNames[cmpt]
<< " grid"
<< exit(FatalError);
}
List specs(is);
if (specs.size() < 2)
{
FatalErrorInFunction
<< "Grid specification for " << vector::componentNames[cmpt]
<< " is too small. Need at least two points!" << nl
<< exit(FatalError);
}
specs.last().ndiv = 0; // safety
DynamicList knots;
DynamicList