diff --git a/applications/utilities/preProcessing/faceAgglomerate/faceAgglomerate.C b/applications/utilities/preProcessing/faceAgglomerate/faceAgglomerate.C index 5efc025508..99caaf375b 100644 --- a/applications/utilities/preProcessing/faceAgglomerate/faceAgglomerate.C +++ b/applications/utilities/preProcessing/faceAgglomerate/faceAgglomerate.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -69,7 +69,6 @@ int main(int argc, char *argv[]) bool writeAgglom = readBool(agglomDict.lookup("writeFacesAgglomeration")); - const polyBoundaryMesh& boundary = mesh.boundaryMesh(); labelListIOList finalAgglom @@ -95,15 +94,20 @@ int main(int argc, char *argv[]) { label patchi = patchids[i]; const polyPatch& pp = boundary[patchi]; + if (!pp.coupled()) { Info << "\nAgglomerating patch : " << pp.name() << endl; + pairPatchAgglomeration agglomObject ( - pp, + pp.localFaces(), + pp.localPoints(), agglomDict.subDict(pp.name()) ); + agglomObject.agglomerate(); + finalAgglom[patchi] = agglomObject.restrictTopBottomAddressing(); @@ -116,42 +120,42 @@ int main(int argc, char *argv[]) } - // - All patches which are not agglomarated are identity for finalAgglom - forAll(boundary, patchid) + // All patches which are not agglomerated are identity for finalAgglom + forAll(boundary, patchi) { - if (finalAgglom[patchid].size() == 0) + if (finalAgglom[patchi].size() == 0) { - finalAgglom[patchid] = identity(boundary[patchid].size()); + finalAgglom[patchi] = identity(boundary[patchi].size()); } } // Sync agglomeration across coupled patches labelList nbrAgglom(mesh.nFaces() - mesh.nInternalFaces(), -1); - forAll(boundary, patchid) + forAll(boundary, patchi) { - const polyPatch& pp = boundary[patchid]; + const polyPatch& pp = boundary[patchi]; if (pp.coupled()) { - finalAgglom[patchid] = identity(pp.size()); + finalAgglom[patchi] = identity(pp.size()); forAll(pp, i) { - nbrAgglom[pp.start() - mesh.nInternalFaces() + i] = - finalAgglom[patchid][i]; + const label agglomi = pp.start() - mesh.nInternalFaces() + i; + nbrAgglom[agglomi] = finalAgglom[patchi][i]; } } } syncTools::swapBoundaryFaceList(mesh, nbrAgglom); - forAll(boundary, patchid) + forAll(boundary, patchi) { - const polyPatch& pp = boundary[patchid]; + const polyPatch& pp = boundary[patchi]; if (pp.coupled() && !refCast(pp).owner()) { forAll(pp, i) { - finalAgglom[patchid][i] = - nbrAgglom[pp.start() - mesh.nInternalFaces() + i]; + const label agglomi = pp.start() - mesh.nInternalFaces() + i; + finalAgglom[patchi][i] = nbrAgglom[agglomi]; } } } @@ -179,13 +183,13 @@ int main(int argc, char *argv[]) facesAgglomeration.boundaryFieldRef(); label coarsePatchIndex = 0; - forAll(boundary, patchid) + forAll(boundary, patchi) { - const polyPatch& pp = boundary[patchid]; + const polyPatch& pp = boundary[patchi]; if (pp.size() > 0) { fvPatchScalarField& bFacesAgglomeration = - facesAgglomerationBf[patchid]; + facesAgglomerationBf[patchi]; forAll(bFacesAgglomeration, j) { @@ -193,11 +197,11 @@ int main(int argc, char *argv[]) index.toGlobal ( Pstream::myProcNo(), - finalAgglom[patchid][j] + coarsePatchIndex + finalAgglom[patchi][j] + coarsePatchIndex ); } - coarsePatchIndex += max(finalAgglom[patchid]) + 1; + coarsePatchIndex += max(finalAgglom[patchi]) + 1; } } diff --git a/src/OpenFOAM/containers/Lists/ListOps/ListOps.H b/src/OpenFOAM/containers/Lists/ListOps/ListOps.H index 684d0859bf..47cb900fea 100644 --- a/src/OpenFOAM/containers/Lists/ListOps/ListOps.H +++ b/src/OpenFOAM/containers/Lists/ListOps/ListOps.H @@ -208,7 +208,7 @@ template label findMin(const ListType&, const label start=0); -//- Find first occurence of given element in sorted list and return index, +//- Find first occurrence of given element in sorted list and return index, // return -1 if not found. Binary search. template label findSortedIndex diff --git a/src/OpenFOAM/db/functionObjects/writeFile/writeFile.C b/src/OpenFOAM/db/functionObjects/writeFile/writeFile.C index 3d7b6d707a..02a7261bfa 100644 --- a/src/OpenFOAM/db/functionObjects/writeFile/writeFile.C +++ b/src/OpenFOAM/db/functionObjects/writeFile/writeFile.C @@ -182,7 +182,7 @@ Foam::functionObjects::writeFile::~writeFile() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::writeFile::read(const dictionary& dict) +bool Foam::functionObjects::writeFile::read(const dictionary& dict) { writePrecision_ = dict.lookupOrDefault("writePrecision", IOstream::defaultPrecision()); @@ -190,6 +190,8 @@ void Foam::functionObjects::writeFile::read(const dictionary& dict) // Only write on master process writeToFile_ = dict.lookupOrDefault("writeToFile", true); writeToFile_ = writeToFile_ && Pstream::master(); + + return true; } diff --git a/src/OpenFOAM/db/functionObjects/writeFile/writeFile.H b/src/OpenFOAM/db/functionObjects/writeFile/writeFile.H index 269504d9c9..c05a1ffe4d 100644 --- a/src/OpenFOAM/db/functionObjects/writeFile/writeFile.H +++ b/src/OpenFOAM/db/functionObjects/writeFile/writeFile.H @@ -148,28 +148,28 @@ public: // Member Functions //- Read - void read(const dictionary& dict); + virtual bool read(const dictionary& dict); //- Return access to the file (if only 1) - OFstream& file(); + virtual OFstream& file(); //- Flag to allow writing to file - bool writeToFile() const; + virtual bool writeToFile() const; //- Return width of character stream output - label charWidth() const; + virtual label charWidth() const; //- Write a commented string to stream - void writeCommented(Ostream& os, const string& str) const; + virtual void writeCommented(Ostream& os, const string& str) const; //- Write a tabbed string to stream - void writeTabbed(Ostream& os, const string& str) const; + virtual void writeTabbed(Ostream& os, const string& str) const; //- Write a commented header to stream - void writeHeader(Ostream& os, const string& str) const; + virtual void writeHeader(Ostream& os, const string& str) const; //- Write the current time to stream - void writeTime(Ostream& os) const; + virtual void writeTime(Ostream& os) const; //- Write a (commented) header property and value pair template diff --git a/src/OpenFOAM/fields/cloud/cloud.C b/src/OpenFOAM/fields/cloud/cloud.C index 69cba912e0..172d6aac74 100644 --- a/src/OpenFOAM/fields/cloud/cloud.C +++ b/src/OpenFOAM/fields/cloud/cloud.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -36,7 +36,6 @@ namespace Foam word cloud::defaultName("defaultCloud"); } - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::cloud::cloud(const objectRegistry& obr, const word& cloudName) @@ -70,4 +69,10 @@ void Foam::cloud::autoMap(const mapPolyMesh&) } +void Foam::cloud::writeObjects(objectRegistry& obr) const +{ + NotImplemented; +} + + // ************************************************************************* // diff --git a/src/OpenFOAM/fields/cloud/cloud.H b/src/OpenFOAM/fields/cloud/cloud.H index 9b7aa43291..844cb9db4e 100644 --- a/src/OpenFOAM/fields/cloud/cloud.H +++ b/src/OpenFOAM/fields/cloud/cloud.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -36,6 +36,7 @@ SourceFiles #define cloud_H #include "objectRegistry.H" +#include "IOField.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -92,6 +93,24 @@ public: //- Remap the cells of particles corresponding to the // mesh topology change virtual void autoMap(const mapPolyMesh&); + + + // I-O + + //- Read particle fields from objects in the obr registry + //virtual void readObjects(objectRegistry& obr); + + //- Write particle fields as objects into the obr registry + virtual void writeObjects(objectRegistry& obr) const; + + //- Helper to construct IOField on a supplied object registry + template + static IOField& createIOField + ( + const word& fieldName, + const label nParticle, + objectRegistry& obr + ); }; @@ -101,6 +120,12 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +#ifdef NoRepository + #include "cloudTemplates.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + #endif // ************************************************************************* // diff --git a/src/OpenFOAM/fields/cloud/cloudTemplates.C b/src/OpenFOAM/fields/cloud/cloudTemplates.C new file mode 100644 index 0000000000..1b5b2ee8b2 --- /dev/null +++ b/src/OpenFOAM/fields/cloud/cloudTemplates.C @@ -0,0 +1,60 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2016 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 "Time.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +template +Foam::IOField& Foam::cloud::createIOField +( + const word& fieldName, + const label nParticle, + objectRegistry& obr +) +{ + IOField* fieldPtr + ( + new IOField + ( + IOobject + ( + fieldName, + obr.time().timeName(), + obr, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + nParticle + ) + ); + + fieldPtr->store(); + + return *fieldPtr; +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/primitives/subModelBase/subModelBase.C b/src/OpenFOAM/primitives/subModelBase/subModelBase.C index dae1123696..9a220797de 100644 --- a/src/OpenFOAM/primitives/subModelBase/subModelBase.C +++ b/src/OpenFOAM/primitives/subModelBase/subModelBase.C @@ -167,6 +167,34 @@ bool Foam::subModelBase::writeTime() const } +bool Foam::subModelBase::getModelDict +( + const word& entryName, + dictionary& dict +) const +{ + if (properties_.found(baseName_)) + { + const dictionary& baseDict = properties_.subDict(baseName_); + + if (inLine() && baseDict.found(modelName_)) + { + const dictionary& modelDict = baseDict.subDict(modelName_); + dict = modelDict.subOrEmptyDict(entryName); + return true; + } + else if (baseDict.found(modelType_)) + { + const dictionary& modelDict = baseDict.subDict(modelType_); + dict = modelDict.subOrEmptyDict(entryName); + return true; + } + } + + return false; +} + + void Foam::subModelBase::write(Ostream& os) const { os << coeffDict_; diff --git a/src/OpenFOAM/primitives/subModelBase/subModelBase.H b/src/OpenFOAM/primitives/subModelBase/subModelBase.H index da29dcbca2..a2c194ac2b 100644 --- a/src/OpenFOAM/primitives/subModelBase/subModelBase.H +++ b/src/OpenFOAM/primitives/subModelBase/subModelBase.H @@ -179,6 +179,13 @@ public: // Model properties + //- Retrieve dictionary, return true if set + bool getModelDict + ( + const word& entryName, + dictionary& dict + ) const; + //- Retrieve generic property from the sub-model template void getModelProperty(const word& entryName, Type& value) const; diff --git a/src/functionObjects/field/Make/files b/src/functionObjects/field/Make/files index f23259eb67..f1e9aad995 100644 --- a/src/functionObjects/field/Make/files +++ b/src/functionObjects/field/Make/files @@ -69,13 +69,19 @@ streamFunction/streamFunction.C valueAverage/valueAverage.C fluxSummary/fluxSummary.C mapFields/mapFields.C -reactionSensitivityAnalysis/reactionsSensitivityAnalysisObjects.C +reactionSensitivityAnalysis/reactionsSensitivityAnalysisObjects.C DESModelRegions/DESModelRegions.C externalCoupled/externalCoupled.C externalCoupled/externalCoupledMixed/externalCoupledMixedFvPatchFields.C externalCoupled/externalCoupledTemperatureMixed/externalCoupledTemperatureMixedFvPatchScalarField.C +extractEulerianParticles/extractEulerianParticles/extractEulerianParticles.C +extractEulerianParticles/eulerianParticle/eulerianParticle.C + +particleDistribution/particleDistribution.C + + ddt2/ddt2.C zeroGradient/zeroGradient.C diff --git a/src/functionObjects/field/Make/options b/src/functionObjects/field/Make/options index ea32eb29ff..efaea7c1b8 100644 --- a/src/functionObjects/field/Make/options +++ b/src/functionObjects/field/Make/options @@ -2,6 +2,7 @@ EXE_INC = \ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/lagrangian/basic/lnInclude \ + -I$(LIB_SRC)/lagrangian/distributionModels/lnInclude \ -I$(LIB_SRC)/fileFormats/lnInclude \ -I$(LIB_SRC)/sampling/lnInclude \ -I$(LIB_SRC)/surfMesh/lnInclude \ @@ -19,18 +20,22 @@ EXE_INC = \ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/sampling/lnInclude \ - -I$(LIB_SRC)/surfMesh/lnInclude + -I$(LIB_SRC)/surfMesh/lnInclude \ + -I$(LIB_SRC)/fvAgglomerationMethods/pairPatchAgglomeration/lnInclude LIB_LIBS = \ -lfiniteVolume \ + -lmeshTools \ + -llagrangian \ + -ldistributionModels \ + -lsampling \ + -lsurfMesh \ -lfluidThermophysicalModels \ -lincompressibleTransportModels \ -lturbulenceModels \ -lcompressibleTransportModels \ -lincompressibleTurbulenceModels \ -lcompressibleTurbulenceModels \ - -lmeshTools \ - -lsampling \ - -lsurfMesh \ -lchemistryModel \ - -lreactionThermophysicalModels + -lreactionThermophysicalModels \ + -lpairPatchAgglomeration diff --git a/src/functionObjects/field/extractEulerianParticles/eulerianParticle/eulerianParticle.C b/src/functionObjects/field/extractEulerianParticles/eulerianParticle/eulerianParticle.C new file mode 100644 index 0000000000..49c2b61433 --- /dev/null +++ b/src/functionObjects/field/extractEulerianParticles/eulerianParticle/eulerianParticle.C @@ -0,0 +1,109 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2015-2016 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 "eulerianParticle.H" +#include "mathematicalConstants.H" + +using namespace Foam::constant; + +// * * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * * // + +Foam::functionObjects::eulerianParticle::eulerianParticle() +: + faceIHit(-1), + VC(vector::zero), + VU(vector::zero), + V(0), + time(0) +{} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +Foam::Ostream& Foam::operator<< +( + Ostream& os, + const functionObjects::eulerianParticle& p +) +{ + os << p.faceIHit << token::SPACE + << p.VC << token::SPACE + << p.VU << token::SPACE + << p.V << token::SPACE + << p.time; + + return os; +} + + +Foam::Istream& Foam::operator>> +( + Istream& is, + functionObjects::eulerianParticle& p +) +{ + is >> p.faceIHit + >> p.VC + >> p.VU + >> p.V + >> p.time; + + return is; +} + + +void Foam::functionObjects::eulerianParticle::write(Ostream& os) const +{ + scalar pDiameter = cbrt(6*V/constant::mathematical::pi); + vector U = VU/(V + ROOTVSMALL); + vector C = VC/(V + ROOTVSMALL); + + os << time << token::SPACE + << faceIHit << token::SPACE + << C << token::SPACE + << pDiameter << token::SPACE + << U << token::SPACE + << endl; +} + + +Foam::dictionary Foam::functionObjects::eulerianParticle::writeDict() const +{ + scalar pDiameter = cbrt(6*V/constant::mathematical::pi); + vector U = VU/(V + ROOTVSMALL); + vector C = VC/(V + ROOTVSMALL); + + dictionary dict; + dict.add("time", time); + dict.add("meshFace", faceIHit); + dict.add("position", C); + dict.add("diameter", pDiameter); + dict.add("U", U); + + return dict; +} + + +// ************************************************************************* // diff --git a/src/functionObjects/field/extractEulerianParticles/eulerianParticle/eulerianParticle.H b/src/functionObjects/field/extractEulerianParticles/eulerianParticle/eulerianParticle.H new file mode 100644 index 0000000000..2a65297a42 --- /dev/null +++ b/src/functionObjects/field/extractEulerianParticles/eulerianParticle/eulerianParticle.H @@ -0,0 +1,151 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2015-2016 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 . + +Class + Foam::eulerianParticle + +Description + Lightweight class to store particle data derived from VOF calculations, + with special handling for input, output and parallel reduction. + +SourceFiles + eulerianParticle.H + eulerianParticle.C + eulerianParticleTemplates.C + +\*---------------------------------------------------------------------------*/ + +#ifndef functionObjects_eulerianParticle_H +#define functionObjects_eulerianParticle_H + +#include "label.H" +#include "scalar.H" +#include "vector.H" +#include "dictionary.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +// Forward declaration of classes +class Istream; +class Ostream; + +namespace functionObjects +{ + class eulerianParticle; +} + +// Forward declaration of friend functions and operators +Istream& operator>>(Istream&, functionObjects::eulerianParticle&); +Ostream& operator<<(Ostream&, const functionObjects::eulerianParticle&); + +namespace functionObjects +{ + +/*---------------------------------------------------------------------------*\ + Class eulerianParticle Declaration +\*---------------------------------------------------------------------------*/ + +class eulerianParticle +{ + +public: + + // Public data + + //- Index of face in faceZone that this particle hits. Also used to + // identify the index of the coarse face of the surface agglomeration + // Note: value of -1 used to indicate that the particle has not + // been initialised + label faceIHit; + + //- Volume multiplied by face centres [m4] + vector VC; + + //- Volume multiplied by velocity [m4/s] + vector VU; + + //- Volume [m3] + scalar V; + + //- Injection time - set at collection [s] + scalar time; + + + //- Constructor + eulerianParticle(); + + + // Public Member Functions + + //- Write to stream + void write(Ostream& os) const; + + //- Write to dictionary + Foam::dictionary writeDict() const; + + + // Operators + + friend bool operator== + ( + const eulerianParticle& a, + const eulerianParticle& b + ) + { + return + a.faceIHit == b.faceIHit + && a.VC == b.VC + && a.VU == b.VU + && a.V == b.V + && a.time == b.time; + } + + friend bool operator!= + ( + const eulerianParticle& a, + const eulerianParticle& b + ) + { + return !(a == b); + } +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace functionObjects +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository + #include "eulerianParticleTemplates.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/functionObjects/field/extractEulerianParticles/eulerianParticle/eulerianParticleTemplates.C b/src/functionObjects/field/extractEulerianParticles/eulerianParticle/eulerianParticleTemplates.C new file mode 100644 index 0000000000..c4f525e091 --- /dev/null +++ b/src/functionObjects/field/extractEulerianParticles/eulerianParticle/eulerianParticleTemplates.C @@ -0,0 +1,88 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2015-2016 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 . + +\*---------------------------------------------------------------------------*/ + +namespace Foam +{ +namespace functionObjects +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template +class sumParticleOp +{ + public: + eulerianParticle operator() + ( + const eulerianParticle& p0, + const eulerianParticle& p1 + ) const + { + if ((p0.faceIHit != -1) && (p1.faceIHit == -1)) + { + return p0; + } + else if ((p0.faceIHit == -1) && (p1.faceIHit != -1)) + { + return p1; + } + else if ((p0.faceIHit != -1) && (p1.faceIHit != -1)) + { + // Choose particle with the largest collected volume and + // accumulate total volume + if (p0.V > p1.V) + { + eulerianParticle p = p0; + p.V = p0.V + p1.V; + p.VC = p0.VC + p1.VC; + p.VU = p0.VU + p1.VU; + return p; + } + else + { + eulerianParticle p = p1; + p.V = p0.V + p1.V; + p.VC = p0.VC + p1.VC; + p.VU = p0.VU + p1.VU; + return p; + } + } + else + { + eulerianParticle p; + return p; + } + } +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace functionObjects +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +// ************************************************************************* // diff --git a/src/functionObjects/field/extractEulerianParticles/extractEulerianParticles/extractEulerianParticles.C b/src/functionObjects/field/extractEulerianParticles/extractEulerianParticles/extractEulerianParticles.C new file mode 100644 index 0000000000..f71fcbeef4 --- /dev/null +++ b/src/functionObjects/field/extractEulerianParticles/extractEulerianParticles/extractEulerianParticles.C @@ -0,0 +1,681 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2015-2016 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 "extractEulerianParticles.H" +#include "regionSplit2D.H" +#include "mathematicalConstants.H" +#include "volFields.H" +#include "surfaceFields.H" +#include "surfaceInterpolate.H" +#include "pairPatchAgglomeration.H" +#include "emptyPolyPatch.H" +#include "coupledPolyPatch.H" +#include "binned.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace functionObjects +{ + defineTypeNameAndDebug(extractEulerianParticles, 0); + + addToRunTimeSelectionTable + ( + functionObject, + extractEulerianParticles, + dictionary + ); +} +} + +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +Foam::fileName +Foam::functionObjects::extractEulerianParticles::dictBaseFileDir() const +{ + fileName baseDir(".."); // = mesh_.time().path(); + + if (Pstream::parRun()) + { + // Put in undecomposed case (Note: gives problems for + // distributed data running) + baseDir = baseDir/".."/"postProcessing"; + } + else + { + baseDir = baseDir/"postProcessing"; + } + + return baseDir; +} + + +void Foam::functionObjects::extractEulerianParticles::checkFaceZone() +{ + DebugInFunction << endl; + + zoneID_ = mesh_.faceZones().findZoneID(faceZoneName_); + if (zoneID_ == -1) + { + FatalErrorInFunction + << "Unable to find faceZone " << faceZoneName_ + << ". Available faceZones are: " << mesh_.faceZones().names() + << exit(FatalError); + } + + const faceZone& fz = mesh_.faceZones()[zoneID_]; + const label nFaces = fz.size(); + const label allFaces = returnReduce(nFaces, sumOp