Merge branch 'master' into develop-v1906

This commit is contained in:
Andrew Heather 2019-12-06 12:05:32 +00:00
commit 9a7adf3606
9 changed files with 114 additions and 90 deletions

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2016-2017 OpenCFD Ltd.
Copyright (C) 2016-2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -28,7 +28,6 @@ License
#include "CSV.H"
#include "DynamicList.H"
//#include "IFstream.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@ -36,7 +35,7 @@ template<>
Foam::label Foam::Function1Types::CSV<Foam::label>::readValue
(
const List<string>& splitted
)
) const
{
if (componentColumns_[0] >= splitted.size())
{
@ -54,7 +53,7 @@ template<>
Foam::scalar Foam::Function1Types::CSV<Foam::scalar>::readValue
(
const List<string>& splitted
)
) const
{
if (componentColumns_[0] >= splitted.size())
{
@ -69,7 +68,10 @@ Foam::scalar Foam::Function1Types::CSV<Foam::scalar>::readValue
template<class Type>
Type Foam::Function1Types::CSV<Type>::readValue(const List<string>& splitted)
Type Foam::Function1Types::CSV<Type>::readValue
(
const List<string>& splitted
) const
{
Type result;
@ -94,7 +96,6 @@ template<class Type>
void Foam::Function1Types::CSV<Type>::read()
{
fileName expandedFile(fName_);
//IFstream is(expandedFile.expand());
autoPtr<ISstream> isPtr(fileHandler().NewIFstream(expandedFile.expand()));
ISstream& is = isPtr();
@ -214,17 +215,24 @@ Foam::Function1Types::CSV<Type>::CSV
TableBase<Type>(entryName, dict),
nHeaderLine_(dict.get<label>("nHeaderLine")),
refColumn_(dict.get<label>("refColumn")),
componentColumns_(dict.lookup("componentColumns")),
separator_(dict.lookupOrDefault<string>("separator", ",")[0]),
componentColumns_(),
separator_(dict.getOrDefault<string>("separator", ",")[0]),
mergeSeparators_(dict.get<bool>("mergeSeparators")),
fName_(fName.empty() ? dict.get<fileName>("file") : fName)
{
// Writing of "componentColumns" was forced to be ASCII,
// do the same when reading
ITstream& is = dict.lookup("componentColumns");
is.format(IOstream::ASCII);
is >> componentColumns_;
dict.checkITstream(is, "componentColumns");
if (componentColumns_.size() != pTraits<Type>::nComponents)
{
FatalErrorInFunction
FatalIOErrorInFunction(dict)
<< componentColumns_ << " does not have the expected length of "
<< pTraits<Type>::nComponents << endl
<< exit(FatalError);
<< pTraits<Type>::nComponents << nl
<< exit(FatalIOError);
}
read();
@ -246,13 +254,6 @@ Foam::Function1Types::CSV<Type>::CSV(const CSV<Type>& csv)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class Type>
Foam::Function1Types::CSV<Type>::~CSV()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2017 OpenCFD Ltd.
Copyright (C) 2017-2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -105,7 +105,7 @@ class CSV
void read();
//- Read the next value from the splitted string
Type readValue(const List<string>&);
Type readValue(const List<string>& splitted) const;
//- No copy assignment
void operator=(const CSV<Type>&) = delete;
@ -138,7 +138,7 @@ public:
//- Destructor
virtual ~CSV();
virtual ~CSV() = default;
// Member Functions
@ -151,11 +151,12 @@ public:
};
// Template specialisations
template<>
label CSV<label>::readValue(const List<string>& splitted);
label CSV<label>::readValue(const List<string>& splitted) const;
template<>
Foam::scalar CSV<scalar>::readValue(const List<string>& splitted);
Foam::scalar CSV<scalar>::readValue(const List<string>& splitted) const;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016 OpenCFD Ltd.
Copyright (C) 2016-2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -56,25 +56,37 @@ Foam::Istream& Foam::ensightReadFile::read(string& value)
{
if (format() == IOstream::BINARY)
{
char buf[80];
auto& iss = stdStream();
read(reinterpret_cast<char*>(buf), sizeof(buf));
// Binary string is *exactly* 80 characters
value.resize(80, '\0');
iss.read(&value[0], 80);
string strBuf(value);
const size_t iEnd = strBuf.find('\0', 0);
if (iEnd == string::npos)
if (!iss)
{
value = buf;
// Truncated - could also exit here, but no real advantage
value.erase(iss.gcount());
}
else
// Truncate at the first embedded '\0'
auto endp = value.find('\0');
if (endp != std::string::npos)
{
value = strBuf.substr(0, iEnd - 1);
value.erase(endp);
}
// May have been padded with trailing spaces - remove those
endp = value.find_last_not_of(" \t\f\v\n\r");
if (endp != std::string::npos)
{
value.erase(endp + 1);
}
}
else
{
value = "";
value.clear();
while (value.empty() && !eof())
{
getLine(value);

View File

@ -41,7 +41,7 @@ adjointWallVelocityLowReFvPatchVectorField
)
:
fixedValueFvPatchVectorField(p, iF),
adjointBoundaryCondition(p, iF, "Ua")
adjointBoundaryCondition(p, iF, word::null)
{}
@ -55,7 +55,7 @@ adjointWallVelocityLowReFvPatchVectorField
)
:
fixedValueFvPatchVectorField(ptf, p, iF, mapper),
adjointBoundaryCondition(p, iF, "Ua")
adjointBoundaryCondition(p, iF, ptf.adjointSolverName_)
{}
@ -68,7 +68,7 @@ adjointWallVelocityLowReFvPatchVectorField
)
:
fixedValueFvPatchVectorField(p, iF),
adjointBoundaryCondition(p, iF, "Ua")
adjointBoundaryCondition(p, iF, dict.get<word>("solverName"))
{
fvPatchField<vector>::operator=
(

View File

@ -28,6 +28,7 @@ License
\*---------------------------------------------------------------------------*/
#include "SpalartAllmaras.H"
#include "wallDist.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -77,7 +78,7 @@ SpalartAllmaras::SpalartAllmaras
nutPtr_ = mesh_.getObjectPtr<volScalarField>("nut");
hasDist_ = true;
dPtr_ = mesh_.getObjectPtr<volScalarField>("yWall");
dPtr_ = &(const_cast<volScalarField&>(wallDist::New(mesh_).y()));
allocateInitValues();
allocateMeanFields();

View File

@ -69,7 +69,7 @@ void Foam::arraySet::calcSamples
for (label i=1; i<=pointsDensity_.x(); ++i)
{
// Local Cartesian
point pt(i*dx*i , j*dy, k*dz);
point pt(i*dx, j*dy, k*dz);
// Global Cartesian
pt = csys_.globalPosition(pt);

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2015-2016 OpenCFD Ltd.
Copyright (C) 2015-2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -101,23 +101,23 @@ void Foam::ensightSurfaceReader::readGeometryHeader(ensightReadFile& is) const
// Ensight Geometry File
is.read(buffer);
DebugInfo<< "buffer: " << buffer << nl;
DebugInfo<< "buffer [" << buffer.length() << "] " << buffer << nl;
// Description - 1
is.read(buffer);
DebugInfo<< "buffer: " << buffer << nl;
DebugInfo<< "buffer [" << buffer.length() << "] " << buffer << nl;
// Node info
is.read(buffer);
DebugInfo<< "buffer: " << buffer << nl;
DebugInfo<< "buffer [" << buffer.length() << "] " << buffer << nl;
// Element info
is.read(buffer);
DebugInfo<< "buffer: " << buffer << nl;
DebugInfo<< "buffer [" << buffer.length() << "] " << buffer << nl;
// Part
is.read(buffer);
DebugInfo<< "buffer: " << buffer << nl;
DebugInfo<< "buffer [" << buffer.length() << "] " << buffer << nl;
// Part number
label ibuffer;
@ -126,11 +126,11 @@ void Foam::ensightSurfaceReader::readGeometryHeader(ensightReadFile& is) const
// Description - 2
is.read(buffer);
DebugInfo<< "buffer: " << buffer << nl;
DebugInfo<< "buffer [" << buffer.length() << "] " << buffer << nl;
// Coordinates
is.read(buffer);
DebugInfo<< "buffer: " << buffer << nl;
DebugInfo<< "buffer [" << buffer.length() << "] " << buffer << nl;
}
@ -280,29 +280,30 @@ const Foam::meshedSurface& Foam::ensightSurfaceReader::geometry()
streamFormat_ = IOstream::BINARY;
{
istream& is = isBinary.stdStream();
istream& iss = isBinary.stdStream();
char buffer[80];
is.read(buffer, 80);
// Binary string is *exactly* 80 characters
string buf(size_t(80), '\0');
iss.read(&buf[0], 80);
char test[80];
label nChar = 0;
for (label i = 0; i < 80; ++i)
if (!iss)
{
if (buffer[i] == '\0')
{
break;
}
test[i] = buffer[i];
nChar++;
// Truncated?
buf.erase(iss.gcount());
}
string testStr(test, nChar);
// Truncate at the first embedded '\0'
const auto endp = buf.find('\0');
if (endp != std::string::npos)
{
buf.erase(endp);
}
// Contains "C Binary" ?
if
(
(testStr.find("binary", 0) == string::npos)
&& (testStr.find("Binary", 0) == string::npos)
(buf.find("binary") == std::string::npos)
&& (buf.find("Binary") == std::string::npos)
)
{
streamFormat_ = IOstream::ASCII;
@ -354,8 +355,7 @@ const Foam::meshedSurface& Foam::ensightSurfaceReader::geometry()
// Read faces - may be a mix of tris, quads and polys
DynamicList<face> faces(ceil(nPoints/3));
DynamicList<Tuple2<string, label>> schema(faces.size());
string faceType = "";
label nFace = 0;
string faceType;
while (is.good()) // (is.peek() != EOF)
{
is.read(faceType);
@ -365,20 +365,22 @@ const Foam::meshedSurface& Foam::ensightSurfaceReader::geometry()
break;
}
DebugInfo
<< "faceType: " << faceType << endl;
label nFace = 0;
if (faceType == "tria3")
{
is.read(nFace);
const label np = 3;
for (label faceI = 0; faceI < nFace; ++faceI)
DebugInfo
<< "faceType <" << faceType.c_str() << "> count: "
<< nFace << nl;
face f(3);
for (label facei = 0; facei < nFace; ++facei)
{
face f(np);
for (label fpI = 0; fpI < np; fpI++)
for (label& fp : f)
{
is.read(f[fpI]);
is.read(fp);
}
faces.append(f);
@ -388,13 +390,16 @@ const Foam::meshedSurface& Foam::ensightSurfaceReader::geometry()
{
is.read(nFace);
const label np = 4;
for (label faceI = 0; faceI < nFace; ++faceI)
DebugInfo
<< "faceType <" << faceType.c_str() << "> count: "
<< nFace << nl;
face f(4);
for (label facei = 0; facei < nFace; ++facei)
{
face f(np);
for (label fpI = 0; fpI < np; fpI++)
for (label& fp : f)
{
is.read(f[fpI]);
is.read(fp);
}
faces.append(f);
@ -404,17 +409,21 @@ const Foam::meshedSurface& Foam::ensightSurfaceReader::geometry()
{
is.read(nFace);
DebugInfo
<< "faceType <" << faceType.c_str() << "> count: "
<< nFace << nl;
labelList np(nFace);
for (label faceI = 0; faceI < nFace; ++faceI)
for (label facei = 0; facei < nFace; ++facei)
{
is.read(np[faceI]);
is.read(np[facei]);
}
for (label faceI = 0; faceI < nFace; ++faceI)
for (label facei = 0; facei < nFace; ++facei)
{
face f(np[faceI]);
for (label fpI = 0; fpI < f.size(); ++fpI)
face f(np[facei]);
for (label& fp : f)
{
is.read(f[fpI]);
is.read(fp);
}
faces.append(f);
@ -425,11 +434,10 @@ const Foam::meshedSurface& Foam::ensightSurfaceReader::geometry()
if (debug)
{
WarningInFunction
<< "Unknown face type: " << faceType
<< ". Aborting read and continuing with current "
<< "Unknown face type: <" << faceType.c_str()
<< ">. Stopping read and continuing with current "
<< "elements only" << endl;
}
break;
}
schema.append(Tuple2<string, label>(faceType, nFace));

View File

@ -113,10 +113,11 @@ Foam::tmp<Foam::Field<Type>> Foam::ensightSurfaceReader::readField
if (primitiveType != pTraits<Type>::typeName)
{
FatalIOErrorInFunction(is)
<< "Expected " << pTraits<Type>::typeName << "values "
<< "but found type " << primitiveType
<< exit(FatalIOError);
IOWarningInFunction(is)
<< "Expected '" << pTraits<Type>::typeName
<< "' values but found type " << primitiveType << nl
<< " This may be okay, but could also indicate an error"
<< nl << nl;
}
scalar value;

View File

@ -33,7 +33,7 @@ writeInterval 0.02;
purgeWrite 0;
writeFormat ascii;
writeFormat binary;
writePrecision 10;