mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: Added reg expression handling for patches lookup in cloud models
This commit is contained in:
@ -48,6 +48,7 @@ $(RADIATION)/absorptionEmission/cloudAbsorptionEmission/cloudAbsorptionEmission.
|
||||
$(RADIATION)/scatter/cloudScatter/cloudScatter.C
|
||||
|
||||
submodels/Kinematic/PatchInteractionModel/LocalInteraction/patchInteractionData.C
|
||||
submodels/Kinematic/PatchInteractionModel/LocalInteraction/patchInteractionDataList.C
|
||||
|
||||
KINEMATICINJECTION=submodels/Kinematic/InjectionModel
|
||||
$(KINEMATICINJECTION)/KinematicLookupTableInjection/kinematicParcelInjectionData.C
|
||||
|
||||
@ -33,9 +33,9 @@ Foam::label Foam::LocalInteraction<CloudType>::applyToPatch
|
||||
const label globalPatchI
|
||||
) const
|
||||
{
|
||||
forAll(patchIds_, patchI)
|
||||
forAll(patchIDs_, patchI)
|
||||
{
|
||||
if (patchIds_[patchI] == globalPatchI)
|
||||
if (patchIDs_[patchI] == globalPatchI)
|
||||
{
|
||||
return patchI;
|
||||
}
|
||||
@ -130,8 +130,8 @@ Foam::LocalInteraction<CloudType>::LocalInteraction
|
||||
)
|
||||
:
|
||||
PatchInteractionModel<CloudType>(dict, cloud, typeName),
|
||||
patchData_(this->coeffDict().lookup("patches")),
|
||||
patchIds_(patchData_.size()),
|
||||
patchData_(cloud.mesh(), this->coeffDict().lookup("patches")),
|
||||
patchIDs_(patchData_.size()),
|
||||
nEscape0_(patchData_.size(), 0),
|
||||
massEscape0_(patchData_.size(), 0.0),
|
||||
nStick0_(patchData_.size(), 0),
|
||||
@ -141,44 +141,6 @@ Foam::LocalInteraction<CloudType>::LocalInteraction
|
||||
nStick_(patchData_.size(), 0),
|
||||
massStick_(patchData_.size(), 0.0)
|
||||
{
|
||||
const polyMesh& mesh = cloud.mesh();
|
||||
const polyBoundaryMesh& bMesh = mesh.boundaryMesh();
|
||||
|
||||
// check that user patches are valid region patches
|
||||
forAll(patchData_, patchI)
|
||||
{
|
||||
const word& patchName = patchData_[patchI].patchName();
|
||||
patchIds_[patchI] = bMesh.findPatchID(patchName);
|
||||
if (patchIds_[patchI] < 0)
|
||||
{
|
||||
FatalErrorIn("LocalInteraction(const dictionary&, CloudType&)")
|
||||
<< "Patch " << patchName << " not found. Available patches "
|
||||
<< "are: " << bMesh.names() << nl << exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
// check that all walls are specified
|
||||
DynamicList<word> badWalls;
|
||||
forAll(bMesh, patchI)
|
||||
{
|
||||
if
|
||||
(
|
||||
isA<wallPolyPatch>(bMesh[patchI])
|
||||
&& applyToPatch(bMesh[patchI].index()) < 0
|
||||
)
|
||||
{
|
||||
badWalls.append(bMesh[patchI].name());
|
||||
}
|
||||
}
|
||||
|
||||
if (badWalls.size() > 0)
|
||||
{
|
||||
FatalErrorIn("LocalInteraction(const dictionary&, CloudType&)")
|
||||
<< "All wall patches must be specified when employing local patch "
|
||||
<< "interaction. Please specify data for patches:" << nl
|
||||
<< badWalls << nl << exit(FatalError);
|
||||
}
|
||||
|
||||
// check that interactions are valid/specified
|
||||
forAll(patchData_, patchI)
|
||||
{
|
||||
@ -211,7 +173,7 @@ Foam::LocalInteraction<CloudType>::LocalInteraction
|
||||
:
|
||||
PatchInteractionModel<CloudType>(pim),
|
||||
patchData_(pim.patchData_),
|
||||
patchIds_(pim.patchIds_),
|
||||
patchIDs_(pim.patchIDs_),
|
||||
nEscape0_(pim.nEscape0_),
|
||||
massEscape0_(pim.massEscape0_),
|
||||
nStick0_(pim.nStick0_),
|
||||
|
||||
@ -33,7 +33,7 @@ Description
|
||||
#define LocalInteraction_H
|
||||
|
||||
#include "PatchInteractionModel.H"
|
||||
#include "patchInteractionData.H"
|
||||
#include "patchInteractionDataList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -51,10 +51,10 @@ class LocalInteraction
|
||||
// Private data
|
||||
|
||||
//- List of participating patches
|
||||
const List<patchInteractionData> patchData_;
|
||||
const patchInteractionDataList patchData_;
|
||||
|
||||
//- List of participating patch ids
|
||||
List<label> patchIds_;
|
||||
List<label> patchIDs_;
|
||||
|
||||
|
||||
// Counters for initial particle fates
|
||||
|
||||
@ -0,0 +1,130 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2011 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "patchInteractionDataList.H"
|
||||
#include "stringListOps.H"
|
||||
#include "wallPolyPatch.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::patchInteractionDataList::patchInteractionDataList()
|
||||
:
|
||||
List<patchInteractionData>(),
|
||||
patchGroupIDs_()
|
||||
{}
|
||||
|
||||
|
||||
Foam::patchInteractionDataList::patchInteractionDataList
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
List<patchInteractionData>(dict.lookup("patches")),
|
||||
patchGroupIDs_(this->size())
|
||||
{
|
||||
const polyBoundaryMesh& bMesh = mesh.boundaryMesh();
|
||||
const wordList allPatchNames = bMesh.names();
|
||||
|
||||
const List<patchInteractionData>& items = *this;
|
||||
forAllReverse(items, i)
|
||||
{
|
||||
const word& patchName = items[i].patchName();
|
||||
labelList patchIDs = findStrings(patchName, allPatchNames);
|
||||
|
||||
if (patchIDs.empty())
|
||||
{
|
||||
WarningIn
|
||||
(
|
||||
"Foam::patchInteractionDataList::patchInteractionDataList"
|
||||
"("
|
||||
"const polyMesh&, "
|
||||
"const dictionary&"
|
||||
")"
|
||||
) << "Cannot find any patch names matching " << patchName
|
||||
<< endl;
|
||||
}
|
||||
|
||||
patchGroupIDs_[i].transfer(patchIDs);
|
||||
}
|
||||
|
||||
// check that all walls are specified
|
||||
DynamicList<word> badWalls;
|
||||
forAll(bMesh, patchI)
|
||||
{
|
||||
const polyPatch& pp = bMesh[patchI];
|
||||
if (isA<wallPolyPatch>(pp) && applyToPatch(pp.index()) < 0)
|
||||
{
|
||||
badWalls.append(pp.name());
|
||||
}
|
||||
}
|
||||
|
||||
if (badWalls.size() > 0)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"Foam::patchInteractionDataList::patchInteractionDataList"
|
||||
"("
|
||||
"const polyMesh&, "
|
||||
"const dictionary&"
|
||||
")"
|
||||
) << "All wall patches must be specified when employing local patch "
|
||||
<< "interaction. Please specify data for patches:" << nl
|
||||
<< badWalls << nl << exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::patchInteractionDataList::patchInteractionDataList
|
||||
(
|
||||
const patchInteractionDataList& pidl
|
||||
)
|
||||
:
|
||||
List<patchInteractionData>(pidl),
|
||||
patchGroupIDs_(pidl.patchGroupIDs_)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::label Foam::patchInteractionDataList::applyToPatch(const label id) const
|
||||
{
|
||||
forAll(patchGroupIDs_, groupI)
|
||||
{
|
||||
const labelList& patchIDs = patchGroupIDs_[groupI];
|
||||
forAll(patchIDs, patchI)
|
||||
{
|
||||
if (patchIDs[patchI] == id)
|
||||
{
|
||||
return groupI;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,90 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2011 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::patchInteractionDataList
|
||||
|
||||
Description
|
||||
List container for patchInteractionData class
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef patchInteractionDataList_H
|
||||
#define patchInteractionDataList_H
|
||||
|
||||
#include "patchInteractionData.H"
|
||||
#include "polyMesh.H"
|
||||
#include "dictionary.H"
|
||||
#include "labelList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class patchInteractionDataList Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class patchInteractionDataList
|
||||
:
|
||||
public List<patchInteractionData>
|
||||
{
|
||||
private:
|
||||
|
||||
// Private data
|
||||
|
||||
//- List of patch IDs for each patch group
|
||||
labelListList patchGroupIDs_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructor
|
||||
|
||||
//- Construct null
|
||||
patchInteractionDataList();
|
||||
|
||||
//- Construct copy
|
||||
patchInteractionDataList(const patchInteractionDataList& pidl);
|
||||
|
||||
//- Construct from Istream
|
||||
patchInteractionDataList(const polyMesh& mesh, const dictionary& dict);
|
||||
|
||||
|
||||
// Member functions
|
||||
|
||||
//- Return label of group containing patch id
|
||||
// Returns -1 if patch id is not present
|
||||
label applyToPatch(const label id) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2008-2010 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -25,6 +25,7 @@ License
|
||||
|
||||
#include "PatchPostProcessing.H"
|
||||
#include "Pstream.H"
|
||||
#include "stringListOps.H"
|
||||
#include "ListListOps.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
@ -35,12 +36,15 @@ Foam::label Foam::PatchPostProcessing<CloudType>::applyToPatch
|
||||
const label globalPatchI
|
||||
) const
|
||||
{
|
||||
forAll(patchIds_, patchI)
|
||||
label patchI = 0;
|
||||
forAllConstIter(labelHashSet, patchIDs_, iter)
|
||||
{
|
||||
if (patchIds_[patchI] == globalPatchI)
|
||||
if (iter.key() == globalPatchI)
|
||||
{
|
||||
return patchI;
|
||||
}
|
||||
|
||||
patchI++;
|
||||
}
|
||||
|
||||
return -1;
|
||||
@ -52,16 +56,18 @@ Foam::label Foam::PatchPostProcessing<CloudType>::applyToPatch
|
||||
template<class CloudType>
|
||||
void Foam::PatchPostProcessing<CloudType>::write()
|
||||
{
|
||||
forAll(patchData_, patchI)
|
||||
forAll(patchData_, i)
|
||||
{
|
||||
List<List<string> > procData(Pstream::nProcs());
|
||||
procData[Pstream::myProcNo()] = patchData_[patchI];
|
||||
procData[Pstream::myProcNo()] = patchData_[i];
|
||||
|
||||
Pstream::gatherList(procData);
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
fileName outputDir = this->owner().time().path();
|
||||
const fvMesh& mesh = this->owner().mesh();
|
||||
|
||||
fileName outputDir = mesh.time().path();
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
@ -69,24 +75,26 @@ void Foam::PatchPostProcessing<CloudType>::write()
|
||||
// distributed data running)
|
||||
outputDir =
|
||||
outputDir/".."/"postProcessing"/cloud::prefix/
|
||||
this->owner().name()/this->owner().time().timeName();
|
||||
this->owner().name()/mesh.time().timeName();
|
||||
}
|
||||
else
|
||||
{
|
||||
outputDir =
|
||||
outputDir/"postProcessing"/cloud::prefix/
|
||||
this->owner().name()/this->owner().time().timeName();
|
||||
this->owner().name()/mesh.time().timeName();
|
||||
}
|
||||
|
||||
// Create directory if it doesn't exist
|
||||
mkDir(outputDir);
|
||||
|
||||
const word& patchName = mesh.boundaryMesh()[patchIDs_[i]].name();
|
||||
|
||||
OFstream patchOutFile
|
||||
(
|
||||
outputDir/patchNames_[patchI] + ".post",
|
||||
outputDir/patchName + ".post",
|
||||
IOstream::ASCII,
|
||||
IOstream::currentVersion,
|
||||
this->owner().time().writeCompression()
|
||||
mesh.time().writeCompression()
|
||||
);
|
||||
|
||||
List<string> globalData;
|
||||
@ -99,13 +107,13 @@ void Foam::PatchPostProcessing<CloudType>::write()
|
||||
|
||||
patchOutFile<< "# Time " + parcelType::propHeader << nl;
|
||||
|
||||
forAll(globalData, i)
|
||||
forAll(globalData, dataI)
|
||||
{
|
||||
patchOutFile<< globalData[i].c_str() << nl;
|
||||
patchOutFile<< globalData[dataI].c_str() << nl;
|
||||
}
|
||||
}
|
||||
|
||||
patchData_[patchI].clearStorage();
|
||||
patchData_[i].clearStorage();
|
||||
}
|
||||
}
|
||||
|
||||
@ -121,29 +129,36 @@ Foam::PatchPostProcessing<CloudType>::PatchPostProcessing
|
||||
:
|
||||
PostProcessingModel<CloudType>(dict, owner, typeName),
|
||||
maxStoredParcels_(readLabel(this->coeffDict().lookup("maxStoredParcels"))),
|
||||
patchNames_(this->coeffDict().lookup("patches")),
|
||||
patchData_(patchNames_.size()),
|
||||
patchIds_(patchNames_.size())
|
||||
patchIDs_(),
|
||||
patchData_()
|
||||
{
|
||||
const polyBoundaryMesh& bMesh = this->owner().mesh().boundaryMesh();
|
||||
forAll(patchNames_, patchI)
|
||||
const wordList allPatchNames = owner.mesh().boundaryMesh().names();
|
||||
wordList patchName(this->coeffDict().lookup("patches"));
|
||||
|
||||
forAllReverse(patchName, i)
|
||||
{
|
||||
const label id = bMesh.findPatchID(patchNames_[patchI]);
|
||||
if (id < 0)
|
||||
labelList patchIDs = findStrings(patchName[i], allPatchNames);
|
||||
|
||||
if (patchIDs.empty())
|
||||
{
|
||||
FatalErrorIn
|
||||
WarningIn
|
||||
(
|
||||
"PatchPostProcessing<CloudType>::PatchPostProcessing"
|
||||
"Foam::PatchPostProcessing<CloudType>::PatchPostProcessing"
|
||||
"("
|
||||
"const dictionary&, "
|
||||
"CloudType& owner"
|
||||
"CloudType& "
|
||||
")"
|
||||
)<< "Requested patch " << patchNames_[patchI] << " not found" << nl
|
||||
<< "Available patches are: " << bMesh.names() << nl
|
||||
<< exit(FatalError);
|
||||
) << "Cannot find any patch names matching " << patchName[i]
|
||||
<< endl;
|
||||
}
|
||||
|
||||
forAll(patchIDs, j)
|
||||
{
|
||||
patchIDs_.insert(patchIDs[j]);
|
||||
}
|
||||
patchIds_[patchI] = id;
|
||||
}
|
||||
|
||||
patchData_.setSize(patchIDs_.size());
|
||||
}
|
||||
|
||||
|
||||
@ -155,9 +170,8 @@ Foam::PatchPostProcessing<CloudType>::PatchPostProcessing
|
||||
:
|
||||
PostProcessingModel<CloudType>(ppm),
|
||||
maxStoredParcels_(ppm.maxStoredParcels_),
|
||||
patchNames_(ppm.patchNames_),
|
||||
patchData_(ppm.patchData_),
|
||||
patchIds_(ppm.patchIds_)
|
||||
patchIDs_(ppm.patchIDs_),
|
||||
patchData_(ppm.patchData_)
|
||||
{}
|
||||
|
||||
|
||||
@ -177,8 +191,8 @@ void Foam::PatchPostProcessing<CloudType>::postPatch
|
||||
const label patchI
|
||||
)
|
||||
{
|
||||
label localPatchI = applyToPatch(patchI);
|
||||
if (localPatchI >= 0 && patchData_[localPatchI].size() < maxStoredParcels_)
|
||||
const label localPatchI = applyToPatch(patchI);
|
||||
if (localPatchI != -1 && patchData_[localPatchI].size() < maxStoredParcels_)
|
||||
{
|
||||
OStringStream data;
|
||||
data<< this->owner().time().timeName() << ' ' << p;
|
||||
|
||||
@ -58,15 +58,12 @@ class PatchPostProcessing
|
||||
//- Maximum number of parcels to store
|
||||
label maxStoredParcels_;
|
||||
|
||||
//- List of patch names
|
||||
wordList patchNames_;
|
||||
//- List of patch indices to post-process
|
||||
labelHashSet patchIDs_;
|
||||
|
||||
//- List of output data per patch
|
||||
List<DynamicList<string> > patchData_;
|
||||
|
||||
//- Mapping from local to global patch ids
|
||||
labelList patchIds_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
@ -117,11 +114,8 @@ public:
|
||||
//- Return maximum number of parcels to store per patch
|
||||
inline label maxStoredParcels() const;
|
||||
|
||||
//- Return const access to the list of patch names
|
||||
inline const wordList& patchNames() const;
|
||||
|
||||
//- Return const mapping from local to global patch ids
|
||||
inline const labelList& patchIds() const;
|
||||
inline const labelList& patchIDs() const;
|
||||
|
||||
|
||||
// Evaluation
|
||||
|
||||
@ -31,17 +31,9 @@ Foam::label Foam::PatchPostProcessing<CloudType>::maxStoredParcels() const
|
||||
|
||||
|
||||
template<class CloudType>
|
||||
const Foam::wordList& Foam::PatchPostProcessing<CloudType>::patchNames() const
|
||||
const Foam::labelList& Foam::PatchPostProcessing<CloudType>::patchIDs() const
|
||||
{
|
||||
return patchNames_;
|
||||
}
|
||||
|
||||
|
||||
template<class CloudType>
|
||||
const Foam::labelList&
|
||||
Foam::PatchPostProcessing<CloudType>::patchIds() const
|
||||
{
|
||||
return patchIds_;
|
||||
return patchIDs_;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user