150 lines
4.3 KiB
C
150 lines
4.3 KiB
C
/*---------------------------------------------------------------------------*\
|
|
========= |
|
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
\\ / O peration |
|
|
\\ / A nd | Copyright (C) 2011-2016 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 <http://www.gnu.org/licenses/>.
|
|
|
|
Application
|
|
checkParticles
|
|
|
|
Description
|
|
Utility for checking position of manually injected particles
|
|
|
|
\*---------------------------------------------------------------------------*/
|
|
|
|
#include "fvCFD.H"
|
|
|
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
argList::addOption
|
|
(
|
|
"cloud",
|
|
"cloudPrefix",
|
|
"cloudPrefix := { kinematic, reacting, ... }, default is reacting"
|
|
);
|
|
|
|
#include "setRootCase.H"
|
|
#include "createTime.H"
|
|
#include "createMesh.H"
|
|
|
|
const word modExt ("valid");
|
|
|
|
word cloudKind ("reacting");
|
|
args.optionReadIfPresent("cloud", cloudKind);
|
|
|
|
IOdictionary cloudProp
|
|
(
|
|
IOobject
|
|
(
|
|
cloudKind + "CloudProperties",
|
|
runTime.constant(),
|
|
mesh,
|
|
IOobject::MUST_READ_IF_MODIFIED,
|
|
IOobject::NO_WRITE
|
|
)
|
|
);
|
|
|
|
dictionary injDict (cloudProp.subDict("subModels").subDict("injectionModels"));
|
|
|
|
for (dictionary::iterator i = injDict.begin(); i != injDict.end(); ++i)
|
|
{
|
|
Info << "Checking " << (*i).name().name() << endl;
|
|
|
|
Info << *i;
|
|
|
|
word injectionType ((*i).dict().lookup("type"));
|
|
|
|
if (injectionType == "manualInjection")
|
|
{
|
|
word posFileName ((*i).dict().lookup("positionsFile"));
|
|
|
|
vectorIOField positions_
|
|
(
|
|
IOobject
|
|
(
|
|
posFileName,
|
|
runTime.constant(),
|
|
mesh,
|
|
IOobject::MUST_READ,
|
|
IOobject::NO_WRITE
|
|
)
|
|
);
|
|
|
|
vectorIOField oldPositions
|
|
(
|
|
IOobject
|
|
(
|
|
posFileName + ".old",
|
|
runTime.constant(),
|
|
mesh,
|
|
IOobject::NO_READ,
|
|
IOobject::NO_WRITE
|
|
),
|
|
positions_
|
|
);
|
|
|
|
// Info << vectorIOField::subField(positions_, 10);
|
|
|
|
labelList validIndices (positions_.size(), -1);
|
|
label validCount = 0;
|
|
|
|
forAll (positions_, pI)
|
|
{
|
|
label celli, tfi, tpi;
|
|
point pos (positions_[pI]);
|
|
mesh.findCellFacePt (pos, celli, tfi, tpi);
|
|
|
|
if (celli < 0)
|
|
{
|
|
Info << "Particle " << pI
|
|
<< " at " << pos << " not in the domain"
|
|
<< endl;
|
|
}
|
|
else
|
|
{
|
|
validIndices[validCount] = pI;
|
|
validCount++;
|
|
}
|
|
}
|
|
|
|
Info << (positions_.size() - validCount) << " particles are in bad position" << endl;
|
|
|
|
if (validCount < positions_.size())
|
|
{
|
|
Info << "Update positions file " << posFileName << endl;
|
|
|
|
vectorField newPositions_ (positions_, labelList::subList(validIndices, validCount));
|
|
positions_.transfer(newPositions_);
|
|
|
|
positions_.write();
|
|
oldPositions.write();
|
|
}
|
|
}
|
|
}
|
|
|
|
Info<< "End\n" << endl;
|
|
|
|
return 0;
|
|
}
|
|
|
|
|
|
// ************************************************************************* //
|