Merge branch 'master' into develop

This commit is contained in:
Mark Olesen
2018-01-23 16:11:28 +01:00
14 changed files with 345 additions and 150 deletions

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -74,7 +74,7 @@ bool writeCloudField
template<class Type>
bool writeCloudField
(
const IOobject& fieldObject,
IOobject& fieldObject,
const bool exists,
autoPtr<ensightFile>& output
);

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -36,8 +36,8 @@ License
template<class Type>
bool Foam::ensightCloud::writeCloudField
(
const Foam::IOField<Type>& field,
Foam::ensightFile& os
const IOField<Type>& field,
ensightFile& os
)
{
const bool exists = (returnReduce(field.size(), sumOp<label>()) > 0);
@ -125,14 +125,23 @@ bool Foam::ensightCloud::writeCloudField
template<class Type>
bool Foam::ensightCloud::writeCloudField
(
const Foam::IOobject& fieldObject,
IOobject& fieldObject,
const bool exists,
Foam::autoPtr<Foam::ensightFile>& output
autoPtr<ensightFile>& output
)
{
if (exists)
{
// when exists == true, it exists globally,
// but can still be missing on the local processor.
// Handle this by READ_IF_PRESENT instead.
const IOobject::readOption rOpt = fieldObject.readOpt();
fieldObject.readOpt() = IOobject::READ_IF_PRESENT;
IOField<Type> field(fieldObject);
fieldObject.readOpt() = rOpt;
writeCloudField(field, output.rawRef());
}

View File

@ -7,7 +7,7 @@ HashTable<HashTable<word>> cloudFields;
if (timeDirs.size() && !noLagrangian)
{
const fileName& baseDir = mesh.time().path();
const fileName& cloudPrefix = regionPrefix/cloud::prefix;
const fileName cloudPrefix(regionPrefix/cloud::prefix);
Info<< "Searching for lagrangian ... " << flush;
@ -35,11 +35,12 @@ if (timeDirs.size() && !noLagrangian)
cloudPrefix/cloudName
);
// Clouds always have "positions" (v1706 and lower) or "coordinates"
if (cloudObjs.found("positions") || cloudObjs.found("coordinates"))
// Clouds require "coordinates".
// The "positions" are for v1706 and lower.
if (cloudObjs.found("coordinates") || cloudObjs.found("positions"))
{
// Save the cloud fields on a per cloud basis
auto fieldsPerCloud = cloudFields(cloudName);
auto& fieldsPerCloud = cloudFields(cloudName);
forAllConstIters(cloudObjs, fieldIter)
{
@ -59,6 +60,12 @@ if (timeDirs.size() && !noLagrangian)
cloudIter().erase("positions");
}
if (Pstream::parRun())
{
Pstream::mapCombineGather(cloudFields, HashTablePlusEqOp<word>());
Pstream::mapCombineScatter(cloudFields);
}
if (cloudFields.empty())
{
Info<< "none detected." << endl;

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -72,6 +72,8 @@ Note
#include "IOobjectList.H"
#include "IOmanip.H"
#include "OFstream.H"
#include "PstreamCombineReduceOps.H"
#include "HashTableOps.H"
#include "fvc.H"
#include "volFields.H"
@ -622,8 +624,13 @@ int main(int argc, char *argv[])
Info<< "Write " << cloudName << " (";
bool cloudExists = currentCloudDirs.found(cloudName);
reduce(cloudExists, orOp<bool>());
const bool cloudExists =
returnReduce
(
currentCloudDirs.found(cloudName),
orOp<bool>()
);
{
autoPtr<ensightFile> os = ensCase.newCloud(cloudName);
@ -643,10 +650,10 @@ int main(int argc, char *argv[])
}
}
forAllConstIter(HashTable<word>, theseCloudFields, fieldIter)
forAllConstIters(theseCloudFields, fieldIter)
{
const word& fieldName = fieldIter.key();
const word& fieldType = fieldIter();
const word& fieldType = fieldIter.object();
IOobject fieldObject
(
@ -657,10 +664,13 @@ int main(int argc, char *argv[])
IOobject::MUST_READ
);
// cannot have field without cloud positions
bool fieldExists = cloudExists;
bool fieldExists = cloudExists; // No field without positions
if (cloudExists)
{
// Want MUST_READ (globally) and valid=false (locally),
// but that combination does not work.
// So check the header and sync globally
fieldExists =
fieldObject.typeHeaderOk<IOField<scalar>>(false);