Merge branch 'master' into develop-v1906

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

View File

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

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2017 OpenCFD Ltd. Copyright (C) 2017-2019 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -105,7 +105,7 @@ class CSV
void read(); void read();
//- Read the next value from the splitted string //- Read the next value from the splitted string
Type readValue(const List<string>&); Type readValue(const List<string>& splitted) const;
//- No copy assignment //- No copy assignment
void operator=(const CSV<Type>&) = delete; void operator=(const CSV<Type>&) = delete;
@ -138,7 +138,7 @@ public:
//- Destructor //- Destructor
virtual ~CSV(); virtual ~CSV() = default;
// Member Functions // Member Functions
@ -151,11 +151,12 @@ public:
}; };
// Template specialisations
template<> template<>
label CSV<label>::readValue(const List<string>& splitted); label CSV<label>::readValue(const List<string>& splitted) const;
template<> 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 \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2016 OpenCFD Ltd. Copyright (C) 2016-2019 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -56,25 +56,37 @@ Foam::Istream& Foam::ensightReadFile::read(string& value)
{ {
if (format() == IOstream::BINARY) 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); if (!iss)
const size_t iEnd = strBuf.find('\0', 0);
if (iEnd == string::npos)
{ {
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 else
{ {
value = ""; value.clear();
while (value.empty() && !eof()) while (value.empty() && !eof())
{ {
getLine(value); getLine(value);

View File

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

View File

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

View File

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

View File

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

View File

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