/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ 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 .
\*---------------------------------------------------------------------------*/
#include "foamVtkTools.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template
bool Foam::functionObjects::runTimePostPro::geometryCloud::addField
(
vtkDataSet* piece,
const Field& fld,
const word& fieldName
) const
{
if (!piece) return false;
auto vtkfield = Foam::vtk::Tools::convertFieldToVTK(fieldName, fld);
// Only has verts
piece->GetPointData()->AddArray(vtkfield);
return true;
}
template
bool Foam::functionObjects::runTimePostPro::geometryCloud::addCloudField
(
vtkMultiPieceDataSet* multiPiece,
const IOField* fldptr,
const word& fieldName
) const
{
if (!multiPiece)
{
return false;
}
if (!needsCollective())
{
// Simple case (serial-serial, parallel-parallel)
return fldptr &&
addField
(
multiPiece->GetPiece(Pstream::myProcNo()),
*fldptr,
fieldName
);
}
// Gather fields
const bool ok = returnReduce((fldptr != nullptr), orOp());
if (!ok)
{
return false;
}
if (Pstream::master())
{
if (fldptr)
{
// My field data
addField
(
multiPiece->GetPiece(Pstream::myProcNo()),
*fldptr,
fieldName
);
}
// Receive field data
Field recv;
for
(
int slave=Pstream::firstSlave();
slave<=Pstream::lastSlave();
++slave
)
{
IPstream fromSlave(Pstream::commsTypes::scheduled, slave);
recv.clear();
fromSlave
>> recv;
if (recv.size())
{
addField
(
multiPiece->GetPiece(slave),
recv,
fieldName
);
}
}
}
else
{
// Slave - send field data
OPstream toMaster
(
Pstream::commsTypes::scheduled,
Pstream::masterNo()
);
if (fldptr)
{
toMaster
<< *fldptr;
}
else
{
toMaster
<< List();
}
}
return ok;
}
template
bool Foam::functionObjects::runTimePostPro::geometryCloud::addCloudField
(
vtkMultiPieceDataSet* multiPiece,
const regIOobject* ioptr,
const word& fieldName
) const
{
return addCloudField
(
multiPiece,
dynamic_cast*>(ioptr),
fieldName
);
}
// ************************************************************************* //