Merge remote-tracking branch 'origin/master' into develop

This commit is contained in:
Andrew Heather
2021-09-07 10:14:29 +01:00
9 changed files with 124 additions and 109 deletions

View File

@ -49,7 +49,7 @@
<!-- <!--
Providing details of your set-up can help us identify any issues, e.g. Providing details of your set-up can help us identify any issues, e.g.
OpenFOAM version : v1806|v1812|v1906 etc OpenFOAM version : v1806|v1812|v1906|v1912|v2006|v2012|v2106 etc
Operating system : ubuntu|openSUSE|centos etc Operating system : ubuntu|openSUSE|centos etc
Hardware info : any info that may help? Hardware info : any info that may help?
Compiler : gcc|intel|clang etc Compiler : gcc|intel|clang etc

View File

@ -1,3 +1,10 @@
## Getting the code
Links to all code packs are available on https://dl.openfoam.com. For OpenFOAM-v2106:
- Source: https://dl.openfoam.com/source/v2106/OpenFOAM-v2106.tgz
- ThirdParty: https://dl.openfoam.com/source/v2106/ThirdParty-v2106.tgz
## OpenFOAM&reg; Quick Build Guide ## OpenFOAM&reg; Quick Build Guide
Prior to building, ensure that the [system requirements][link openfoam-require] Prior to building, ensure that the [system requirements][link openfoam-require]

View File

@ -52,8 +52,12 @@ Description
typedef autoPtr<baseType> (*argNames##ConstructorPtr)argList; \ typedef autoPtr<baseType> (*argNames##ConstructorPtr)argList; \
\ \
/* Construct from argList function table type */ \ /* Construct from argList function table type */ \
typedef HashTable<argNames##ConstructorPtr, word> \ typedef HashTable \
argNames##ConstructorTable; \ < \
argNames##ConstructorPtr, \
::Foam::word, \
::Foam::string::hasher \
> argNames##ConstructorTable; \
\ \
/* Construct from argList function pointer table pointer */ \ /* Construct from argList function pointer table pointer */ \
static argNames##ConstructorTable* argNames##ConstructorTablePtr_; \ static argNames##ConstructorTable* argNames##ConstructorTablePtr_; \
@ -77,7 +81,7 @@ Description
\ \
explicit add##argNames##ConstructorToTable \ explicit add##argNames##ConstructorToTable \
( \ ( \
const word& lookup = baseType##Type::typeName \ const ::Foam::word& lookup = baseType##Type::typeName \
) \ ) \
{ \ { \
construct##argNames##ConstructorTables(); \ construct##argNames##ConstructorTables(); \
@ -109,7 +113,7 @@ Description
{ \ { \
public: \ public: \
\ \
const word name; /* Lookup name for later removal */ \ const ::Foam::word name; /* Lookup name for later removal */ \
\ \
static autoPtr<baseType> New argList \ static autoPtr<baseType> New argList \
{ \ { \
@ -118,7 +122,7 @@ Description
\ \
explicit addRemovable##argNames##ConstructorToTable \ explicit addRemovable##argNames##ConstructorToTable \
( \ ( \
const word& lookup = baseType##Type::typeName \ const ::Foam::word& lookup = baseType##Type::typeName \
) \ ) \
: \ : \
name(lookup) \ name(lookup) \
@ -152,8 +156,12 @@ Description
typedef autoPtr<baseType> (*argNames##ConstructorPtr)argList; \ typedef autoPtr<baseType> (*argNames##ConstructorPtr)argList; \
\ \
/* Construct from argList function table type */ \ /* Construct from argList function table type */ \
typedef HashTable<argNames##ConstructorPtr, word> \ typedef HashTable \
argNames##ConstructorTable; \ < \
argNames##ConstructorPtr, \
::Foam::word, \
::Foam::string::hasher \
> argNames##ConstructorTable; \
\ \
/* Construct from argList function pointer table pointer */ \ /* Construct from argList function pointer table pointer */ \
static argNames##ConstructorTable* argNames##ConstructorTablePtr_; \ static argNames##ConstructorTable* argNames##ConstructorTablePtr_; \
@ -177,7 +185,7 @@ Description
\ \
explicit add##argNames##ConstructorToTable \ explicit add##argNames##ConstructorToTable \
( \ ( \
const word& lookup = baseType##Type::typeName \ const ::Foam::word& lookup = baseType##Type::typeName \
) \ ) \
{ \ { \
construct##argNames##ConstructorTables(); \ construct##argNames##ConstructorTables(); \
@ -215,7 +223,7 @@ Description
{ \ { \
public: \ public: \
\ \
const word name; /* Lookup name for later removal */ \ const ::Foam::word name; /* Lookup name for later removal */ \
\ \
static autoPtr<baseType> New##baseType argList \ static autoPtr<baseType> New##baseType argList \
{ \ { \
@ -224,7 +232,7 @@ Description
\ \
explicit addRemovable##argNames##ConstructorToTable \ explicit addRemovable##argNames##ConstructorToTable \
( \ ( \
const word& lookup = baseType##Type::typeName \ const ::Foam::word& lookup = baseType##Type::typeName \
) \ ) \
: \ : \
name(lookup) \ name(lookup) \

View File

@ -46,8 +46,12 @@ Description
typedef returnType (*memberFunction##argNames##MemberFunctionPtr)argList; \ typedef returnType (*memberFunction##argNames##MemberFunctionPtr)argList; \
\ \
/* Construct from argList function table type */ \ /* Construct from argList function table type */ \
typedef HashTable<memberFunction##argNames##MemberFunctionPtr, word> \ typedef HashTable \
memberFunction##argNames##MemberFunctionTable; \ < \
memberFunction##argNames##MemberFunctionPtr, \
::Foam::word, \
::Foam::string::hasher \
> memberFunction##argNames##MemberFunctionTable; \
\ \
/* Construct from argList function pointer table pointer */ \ /* Construct from argList function pointer table pointer */ \
static memberFunction##argNames##MemberFunctionTable* \ static memberFunction##argNames##MemberFunctionTable* \
@ -61,7 +65,7 @@ Description
\ \
explicit add##memberFunction##argNames##MemberFunctionToTable \ explicit add##memberFunction##argNames##MemberFunctionToTable \
( \ ( \
const word& lookup = baseType##Type::typeName \ const ::Foam::word& lookup = baseType##Type::typeName \
) \ ) \
{ \ { \
construct##memberFunction##argNames##MemberFunctionTables(); \ construct##memberFunction##argNames##MemberFunctionTables(); \

View File

@ -48,15 +48,16 @@ Foam::Istream& Foam::operator>>(Istream& is, word& val)
{ {
val = tok.wordToken(); val = tok.wordToken();
} }
else if (tok.isQuotedString()) else if (tok.isQuotedString() || tok.isVariable())
{ {
// Try a bit harder and convert string to word // Try a bit harder, convert some string types to word
val = tok.stringToken(); // - accept "quoted" or $tag, but not verbatim/expression
const auto oldLen = val.length();
string::stripInvalid<word>(val); const auto& str = tok.stringToken();
val = word::validate(str);
// Flag empty strings and bad chars as an error // Flag empty strings and bad chars as an error
if (val.empty() || val.length() != oldLen) if (val.empty() || val.length() != str.length())
{ {
FatalIOErrorInFunction(is) FatalIOErrorInFunction(is)
<< "Empty word or non-word characters " << "Empty word or non-word characters "

View File

@ -213,11 +213,11 @@ bool Foam::functionObjects::Curle::execute()
forAll(observerPositions_, pointi) forAll(observerPositions_, pointi)
{ {
const vectorField r(Cfp - observerPositions_[pointi]); const vectorField r(observerPositions_[pointi] - Cfp);
const scalarField invMagR(1/(mag(r) + ROOTVSMALL)); const scalarField invMagR(1/(mag(r) + ROOTVSMALL));
pDash[pointi] += pDash[pointi] +=
sum((pp*sqr(invMagR) + invMagR/c0_*dpdtp)*(Sfp & r)); sum((pp*sqr(invMagR) + invMagR/c0_*dpdtp)*(Sfp & (r*invMagR)));
} }
} }

View File

@ -419,8 +419,6 @@ void Foam::ParticleCollector<CloudType>::write()
massTotal_[facei] += mass_[facei]; massTotal_[facei] += mass_[facei];
} }
const label proci = Pstream::myProcNo();
Info<< type() << " output:" << nl; Info<< type() << " output:" << nl;
Field<scalar> faceMassTotal(mass_.size(), Zero); Field<scalar> faceMassTotal(mass_.size(), Zero);
@ -434,15 +432,11 @@ void Foam::ParticleCollector<CloudType>::write()
scalar sumAverageMFR = 0.0; scalar sumAverageMFR = 0.0;
forAll(faces_, facei) forAll(faces_, facei)
{ {
scalarList allProcMass(Pstream::nProcs()); faceMassTotal[facei] +=
allProcMass[proci] = massTotal_[facei]; returnReduce(massTotal_[facei], sumOp<scalar>());
Pstream::gatherList(allProcMass);
faceMassTotal[facei] += sum(allProcMass);
scalarList allProcMassFlowRate(Pstream::nProcs()); faceMassFlowRate[facei] +=
allProcMassFlowRate[proci] = massFlowRate_[facei]; returnReduce(massFlowRate_[facei], sumOp<scalar>());
Pstream::gatherList(allProcMassFlowRate);
faceMassFlowRate[facei] += sum(allProcMassFlowRate);
sumTotalMass += faceMassTotal[facei]; sumTotalMass += faceMassTotal[facei];
sumAverageMFR += faceMassFlowRate[facei]; sumAverageMFR += faceMassFlowRate[facei];

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2015 OpenFOAM Foundation Copyright (C) 2015 OpenFOAM Foundation
Copyright (C) 2015-2020 OpenCFD Ltd. Copyright (C) 2015-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -108,6 +108,57 @@ Foam::surfaceWriters::boundaryDataWriter::boundaryDataWriter
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::surfaceWriters::boundaryDataWriter::serialWriteGeometry
(
const regIOobject& iopts,
const meshedSurf& surf
)
{
const pointField& points = surf.points();
const faceList& faces = surf.faces();
if (verbose_)
{
if (this->isPointData())
{
Info<< "Writing points: " << iopts.objectPath() << endl;
}
else
{
Info<< "Writing face centres: " << iopts.objectPath() << endl;
}
}
// Like regIOobject::writeObject without instance() adaptation
// since this would write to e.g. 0/ instead of postProcessing/
OFstream osGeom(iopts.objectPath(), streamOpt_);
if (header_)
{
iopts.writeHeader(osGeom);
}
if (this->isPointData())
{
// Just like writeData, but without copying beforehand
osGeom << points;
}
else
{
primitivePatch pp(SubList<face>(faces), points);
// Just like writeData, but without copying beforehand
osGeom << pp.faceCentres();
}
if (header_)
{
iopts.writeEndDivider(osGeom);
}
}
Foam::fileName Foam::surfaceWriters::boundaryDataWriter::write() Foam::fileName Foam::surfaceWriters::boundaryDataWriter::write()
{ {
checkOpen(); checkOpen();
@ -129,6 +180,7 @@ Foam::fileName Foam::surfaceWriters::boundaryDataWriter::write()
mkDir(surfaceDir); mkDir(surfaceDir);
} }
// Write sample locations
pointIOField iopts pointIOField iopts
( (
IOobject IOobject
@ -140,30 +192,9 @@ Foam::fileName Foam::surfaceWriters::boundaryDataWriter::write()
false false
) )
); );
iopts.note() = (this->isPointData() ? "point data" : "face data");
if (verbose_) serialWriteGeometry(iopts, surf);
{
Info<< "Writing points: " << iopts.objectPath() << endl;
}
// Like regIOobject::writeObject without instance() adaptation
// since this would write to e.g. 0/ instead of postProcessing/
OFstream osGeom(iopts.objectPath(), streamOpt_);
if (header_)
{
iopts.writeHeader(osGeom);
}
// Just like writeData, but without copying beforehand
osGeom << surf.points();
if (header_)
{
iopts.writeEndDivider(osGeom);
}
} }
wroteGeom_ = true; wroteGeom_ = true;
@ -212,67 +243,29 @@ Foam::fileName Foam::surfaceWriters::boundaryDataWriter::writeTemplate
if (Pstream::master() || !parallel_) if (Pstream::master() || !parallel_)
{ {
const pointField& points = surf.points();
const faceList& faces = surf.faces();
if (!isDir(outputFile.path())) if (!isDir(outputFile.path()))
{ {
mkDir(outputFile.path()); mkDir(outputFile.path());
} }
pointIOField iopts // Write sample locations
( {
IOobject pointIOField iopts
( (
surfaceDir/"points", IOobject
*dummyTimePtr, (
IOobject::NO_READ, surfaceDir/"points",
IOobject::NO_WRITE, *dummyTimePtr,
false IOobject::NO_READ,
) IOobject::NO_WRITE,
); false
)
);
iopts.note() = (this->isPointData() ? "point data" : "face data");
if (verbose_) serialWriteGeometry(iopts, surf);
{
if (this->isPointData())
{
Info<< "Writing points: " << iopts.objectPath() << endl;
}
else
{
Info<< "Writing face centres: " << iopts.objectPath() << endl;
}
} }
// Like regIOobject::writeObject without instance() adaptation
// since this would write to e.g. 0/ instead of postProcessing/
OFstream osGeom(iopts.objectPath(), streamOpt_);
if (header_)
{
iopts.writeHeader(osGeom);
}
if (this->isPointData())
{
// Just like writeData, but without copying beforehand
osGeom << points;
}
else
{
primitivePatch pp(SubList<face>(faces), points);
// Just like writeData, but without copying beforehand
osGeom << pp.faceCentres();
}
if (header_)
{
iopts.writeEndDivider(osGeom);
}
// Write field // Write field
{ {
IOField<Type> iofld IOField<Type> iofld
@ -286,6 +279,7 @@ Foam::fileName Foam::surfaceWriters::boundaryDataWriter::writeTemplate
false false
) )
); );
iofld.note() = (this->isPointData() ? "point data" : "face data");
OFstream osField(iofld.objectPath(), streamOpt_); OFstream osField(iofld.objectPath(), streamOpt_);

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2015-2020 OpenCFD Ltd. Copyright (C) 2015-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -134,6 +134,10 @@ SourceFiles
namespace Foam namespace Foam
{ {
// Forward Declarations
class regIOobject;
namespace surfaceWriters namespace surfaceWriters
{ {
@ -159,6 +163,9 @@ class boundaryDataWriter
// Private Member Functions // Private Member Functions
//- Write serial surface geometry to "points" file.
void serialWriteGeometry(const regIOobject&, const meshedSurf& surf);
//- Templated write field operation //- Templated write field operation
template<class Type> template<class Type>
fileName writeTemplate fileName writeTemplate