/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation \\/ 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 "parLagrangianRedistributor.H" #include "Time.H" #include "IOobjectList.H" #include "mapDistributePolyMesh.H" #include "cloud.H" #include "CompactIOField.H" #include "passivePositionParticleCloud.H" // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template Foam::wordList Foam::parLagrangianRedistributor::filterObjects ( const IOobjectList& objects, const HashSet& selectedFields ) { const word fieldClassName(Container::typeName); // Parallel synchronise wordList fieldNames(objects.names(fieldClassName)); Pstream::combineGather(fieldNames, ListUniqueEqOp()); Pstream::combineScatter(fieldNames); if (!selectedFields.empty()) { DynamicList selectedNames(fieldNames.size()); forAll(fieldNames, i) { if (selectedFields.found(fieldNames[i])) { selectedNames.append(fieldNames[i]); } } fieldNames.transfer(selectedNames); } return fieldNames; } template void Foam::parLagrangianRedistributor::redistributeLagrangianFields ( const mapDistributeBase& map, const word& cloudName, const IOobjectList& objects, const HashSet& selectedFields ) const { const wordList objectNames ( filterObjects> ( objects, selectedFields ) ); if (objectNames.size()) { const word fieldClassName(IOField::typeName); Info<< " Redistributing lagrangian " << fieldClassName << "s\n" << endl; forAll(objectNames, i) { Info<< " " << objectNames[i] << endl; // Read if present IOField field ( IOobject ( objectNames[i], srcMesh_.time().timeName(), cloud::prefix/cloudName, srcMesh_, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false ), label(0) ); map.distribute(field); if (field.size()) { IOField ( IOobject ( objectNames[i], tgtMesh_.time().timeName(), cloud::prefix/cloudName, tgtMesh_, IOobject::NO_READ, IOobject::NO_WRITE, false ), xferMove>(field) ).write(); } } Info<< endl; } } template void Foam::parLagrangianRedistributor::redistributeLagrangianFieldFields ( const mapDistributeBase& map, const word& cloudName, const IOobjectList& objects, const HashSet& selectedFields ) const { wordList objectNames ( filterObjects, Type>> ( objects, selectedFields ) ); // Append IOField names { const wordList ioFieldNames ( filterObjects>> ( objects, selectedFields ) ); objectNames.append(ioFieldNames); } if (objectNames.size()) { const word fieldClassName(CompactIOField, Type>::typeName); Info<< " Redistributing lagrangian " << fieldClassName << "s\n" << endl; forAll(objectNames, i) { Info<< " " << objectNames[i] << endl; // Read if present CompactIOField, Type> field ( IOobject ( objectNames[i], srcMesh_.time().timeName(), cloud::prefix/cloudName, srcMesh_, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false ), label(0) ); // Distribute map.distribute(field); // Write if (field.size()) { CompactIOField, Type> ( IOobject ( objectNames[i], tgtMesh_.time().timeName(), cloud::prefix/cloudName, tgtMesh_, IOobject::NO_READ, IOobject::NO_WRITE, false ), xferMove>>(field) ).write(); } } } } template void Foam::parLagrangianRedistributor::readLagrangianFields ( const passivePositionParticleCloud& cloud, const IOobjectList& objects, const HashSet& selectedFields ) { const wordList objectNames ( filterObjects ( objects, selectedFields ) ); if (objectNames.size()) { const word fieldClassName(Container::typeName); Info<< " Reading lagrangian " << fieldClassName << "s\n" << endl; forAll(objectNames, i) { Info<< " " << objectNames[i] << endl; // Read if present Container* fieldPtr = new Container ( IOobject ( objectNames[i], cloud.time().timeName(), cloud, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE ), label(0) ); fieldPtr->store(); } } } template void Foam::parLagrangianRedistributor::redistributeStoredLagrangianFields ( const mapDistributeBase& map, passivePositionParticleCloud& cloud ) const { HashTable fields ( cloud.lookupClass() ); if (fields.size()) { const word fieldClassName(Container::typeName); Info<< " Redistributing lagrangian " << fieldClassName << "s\n" << endl; forAllIter(typename HashTable, fields, iter) { Container& field = *iter(); Info<< " " << field.name() << endl; map.distribute(field); if (field.size()) { Container ( IOobject ( field.name(), tgtMesh_.time().timeName(), cloud::prefix/cloud.name(), tgtMesh_, IOobject::NO_READ, IOobject::NO_WRITE, false ), xferMove>(field) ).write(); } } } } // ************************************************************************* //