primitives/direction: Changed from "char" to "int8_t" and added IO operators
to avoid problems when writing "nComponents"
This commit is contained in:
@ -38,7 +38,7 @@ void Foam::patchWriter::write
|
|||||||
{
|
{
|
||||||
const GeometricField<Type, fvPatchField, volMesh>& fld = flds[fieldi];
|
const GeometricField<Type, fvPatchField, volMesh>& fld = flds[fieldi];
|
||||||
|
|
||||||
os_ << fld.name() << ' ' << int(pTraits<Type>::nComponents) << ' '
|
os_ << fld.name() << ' ' << pTraits<Type>::nComponents << ' '
|
||||||
<< nFaces_ << " float" << std::endl;
|
<< nFaces_ << " float" << std::endl;
|
||||||
|
|
||||||
DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nFaces_);
|
DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nFaces_);
|
||||||
@ -74,7 +74,7 @@ void Foam::patchWriter::write
|
|||||||
const GeometricField<Type, pointPatchField, pointMesh>& fld =
|
const GeometricField<Type, pointPatchField, pointMesh>& fld =
|
||||||
flds[fieldi];
|
flds[fieldi];
|
||||||
|
|
||||||
os_ << fld.name() << ' ' << int(pTraits<Type>::nComponents) << ' '
|
os_ << fld.name() << ' ' << pTraits<Type>::nComponents << ' '
|
||||||
<< nPoints_ << " float" << std::endl;
|
<< nPoints_ << " float" << std::endl;
|
||||||
|
|
||||||
DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nPoints_);
|
DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nPoints_);
|
||||||
@ -103,7 +103,7 @@ void Foam::patchWriter::write
|
|||||||
{
|
{
|
||||||
const GeometricField<Type, fvPatchField, volMesh>& fld = flds[fieldi];
|
const GeometricField<Type, fvPatchField, volMesh>& fld = flds[fieldi];
|
||||||
|
|
||||||
os_ << fld.name() << ' ' << int(pTraits<Type>::nComponents) << ' '
|
os_ << fld.name() << ' ' << pTraits<Type>::nComponents << ' '
|
||||||
<< nPoints_ << " float" << std::endl;
|
<< nPoints_ << " float" << std::endl;
|
||||||
|
|
||||||
DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nPoints_);
|
DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nPoints_);
|
||||||
|
|||||||
@ -74,7 +74,7 @@ void Foam::writeFuns::write
|
|||||||
|
|
||||||
label nValues = mesh.nCells() + superCells.size();
|
label nValues = mesh.nCells() + superCells.size();
|
||||||
|
|
||||||
os << vvf.name() << ' ' << int(pTraits<Type>::nComponents) << ' '
|
os << vvf.name() << ' ' << pTraits<Type>::nComponents << ' '
|
||||||
<< nValues << " float" << std::endl;
|
<< nValues << " float" << std::endl;
|
||||||
|
|
||||||
DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nValues);
|
DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nValues);
|
||||||
@ -106,7 +106,7 @@ void Foam::writeFuns::write
|
|||||||
const labelList& addPointCellLabels = topo.addPointCellLabels();
|
const labelList& addPointCellLabels = topo.addPointCellLabels();
|
||||||
const label nTotPoints = mesh.nPoints() + addPointCellLabels.size();
|
const label nTotPoints = mesh.nPoints() + addPointCellLabels.size();
|
||||||
|
|
||||||
os << pvf.name() << ' ' << int(pTraits<Type>::nComponents) << ' '
|
os << pvf.name() << ' ' << pTraits<Type>::nComponents << ' '
|
||||||
<< nTotPoints << " float" << std::endl;
|
<< nTotPoints << " float" << std::endl;
|
||||||
|
|
||||||
DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nTotPoints);
|
DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nTotPoints);
|
||||||
@ -139,7 +139,7 @@ void Foam::writeFuns::write
|
|||||||
const labelList& addPointCellLabels = topo.addPointCellLabels();
|
const labelList& addPointCellLabels = topo.addPointCellLabels();
|
||||||
const label nTotPoints = mesh.nPoints() + addPointCellLabels.size();
|
const label nTotPoints = mesh.nPoints() + addPointCellLabels.size();
|
||||||
|
|
||||||
os << vvf.name() << ' ' << int(pTraits<Type>::nComponents) << ' '
|
os << vvf.name() << ' ' << pTraits<Type>::nComponents << ' '
|
||||||
<< nTotPoints << " float" << std::endl;
|
<< nTotPoints << " float" << std::endl;
|
||||||
|
|
||||||
DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nTotPoints);
|
DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nTotPoints);
|
||||||
|
|||||||
@ -15,6 +15,8 @@ chars = primitives/chars
|
|||||||
$(chars)/char/charIO.C
|
$(chars)/char/charIO.C
|
||||||
$(chars)/wchar/wcharIO.C
|
$(chars)/wchar/wcharIO.C
|
||||||
|
|
||||||
|
primitives/direction/directionIO.C
|
||||||
|
|
||||||
ints = primitives/ints
|
ints = primitives/ints
|
||||||
$(ints)/uint32/uint32.C
|
$(ints)/uint32/uint32.C
|
||||||
$(ints)/uint32/uint32IO.C
|
$(ints)/uint32/uint32IO.C
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -21,20 +21,21 @@ License
|
|||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
Description
|
|
||||||
Reads a char from an input stream, for a given version
|
|
||||||
number and File format. If an ascii File is being read, then the line
|
|
||||||
numbers are counted and an erroneous read is reported.
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "error.H"
|
|
||||||
|
|
||||||
#include "char.H"
|
#include "char.H"
|
||||||
#include "IOstreams.H"
|
#include "IOstreams.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
char Foam::readChar(Istream& is)
|
||||||
|
{
|
||||||
|
char c;
|
||||||
|
is.read(c);
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::Istream& Foam::operator>>(Istream& is, char& c)
|
Foam::Istream& Foam::operator>>(Istream& is, char& c)
|
||||||
{
|
{
|
||||||
is.read(c);
|
is.read(c);
|
||||||
@ -51,14 +52,6 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const char c)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char Foam::readChar(Istream& is)
|
|
||||||
{
|
|
||||||
char c;
|
|
||||||
is.read(c);
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Foam::Ostream& Foam::operator<<(Ostream& os, const char* s)
|
Foam::Ostream& Foam::operator<<(Ostream& os, const char* s)
|
||||||
{
|
{
|
||||||
os.write(s);
|
os.write(s);
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -25,23 +25,38 @@ Primitive
|
|||||||
direction
|
direction
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Direction is an integer type used to represent the Cartesian directions
|
Direction is an 8-bit unsigned integer type used to represent the Cartesian
|
||||||
etc. Currently it is a typedef to char which is limited to the range
|
directions etc.
|
||||||
(0, 255) which should be adequate.
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef direction_H
|
#ifndef direction_H
|
||||||
#define direction_H
|
#define direction_H
|
||||||
|
|
||||||
#include "char.H"
|
#define __STDC_LIMIT_MACROS
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
typedef unsigned char direction;
|
|
||||||
}
|
class Istream;
|
||||||
|
class Ostream;
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
typedef uint8_t direction;
|
||||||
|
|
||||||
|
direction readDirection(Istream&);
|
||||||
|
Istream& operator>>(Istream&, direction&);
|
||||||
|
Ostream& operator<<(Ostream&, const direction);
|
||||||
|
std::ostream& operator<<(std::ostream&, const direction);
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|||||||
86
src/OpenFOAM/primitives/direction/directionIO.C
Normal file
86
src/OpenFOAM/primitives/direction/directionIO.C
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 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 <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "direction.H"
|
||||||
|
#include "IOstreams.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::direction Foam::readDirection(Istream& is)
|
||||||
|
{
|
||||||
|
direction val;
|
||||||
|
is >> val;
|
||||||
|
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::Istream& Foam::operator>>(Istream& is, direction& d)
|
||||||
|
{
|
||||||
|
token t(is);
|
||||||
|
|
||||||
|
if (!t.good())
|
||||||
|
{
|
||||||
|
is.setBad();
|
||||||
|
return is;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (t.isLabel())
|
||||||
|
{
|
||||||
|
d = direction(t.labelToken());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
is.setBad();
|
||||||
|
FatalIOErrorInFunction(is)
|
||||||
|
<< "wrong token type - expected direction, found " << t.info()
|
||||||
|
<< exit(FatalIOError);
|
||||||
|
|
||||||
|
return is;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check state of Istream
|
||||||
|
is.check("Istream& operator>>(Istream&, direction&)");
|
||||||
|
|
||||||
|
return is;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::Ostream& Foam::operator<<(Ostream& os, const direction d)
|
||||||
|
{
|
||||||
|
os.write(label(d));
|
||||||
|
os.check("Ostream& operator<<(Ostream&, const direction)");
|
||||||
|
return os;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::ostream& Foam::operator<<(std::ostream& os, const direction d)
|
||||||
|
{
|
||||||
|
os << int(d);
|
||||||
|
return os;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2014-2015 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2014-2016 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -23,8 +23,6 @@ License
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "error.H"
|
|
||||||
|
|
||||||
#include "int32.H"
|
#include "int32.H"
|
||||||
#include "IOstreams.H"
|
#include "IOstreams.H"
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2014-2015 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2014-2016 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -23,8 +23,6 @@ License
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "error.H"
|
|
||||||
|
|
||||||
#include "int64.H"
|
#include "int64.H"
|
||||||
#include "IOstreams.H"
|
#include "IOstreams.H"
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2014-2015 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2014-2016 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -23,8 +23,6 @@ License
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "error.H"
|
|
||||||
|
|
||||||
#include "uint32.H"
|
#include "uint32.H"
|
||||||
#include "IOstreams.H"
|
#include "IOstreams.H"
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2014-2015 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2014-2016 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -23,8 +23,6 @@ License
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "error.H"
|
|
||||||
|
|
||||||
#include "uint64.H"
|
#include "uint64.H"
|
||||||
#include "IOstreams.H"
|
#include "IOstreams.H"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user