Foam utility to check particle positions are in the domain
This commit is contained in:
commit
c4bb8c516d
4 changed files with 232 additions and 0 deletions
72
.gitignore
vendored
Normal file
72
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
# git-ls-files --others --exclude-from=.git/info/exclude
|
||||
# Lines that start with '#' are comments.
|
||||
|
||||
# Editor and misc backup files - anywhere
|
||||
*~
|
||||
.*~
|
||||
*.bak
|
||||
*.bak[0-9][0-9]
|
||||
\#*\#
|
||||
|
||||
# File-browser settings - anywhere
|
||||
.directory
|
||||
|
||||
# CVS recovered versions - anywhere
|
||||
.#*
|
||||
|
||||
# Objects and archives - anywhere
|
||||
*.[oa]
|
||||
*.la
|
||||
*.so
|
||||
|
||||
# Derived files
|
||||
lex.yy.c
|
||||
|
||||
# Corefiles
|
||||
core
|
||||
|
||||
# Dependency files - anywhere
|
||||
*.dep
|
||||
|
||||
# lnInclude (symlink) directories - anywhere
|
||||
lnInclude
|
||||
|
||||
# Build directories - anywhere
|
||||
linux*Clang*/
|
||||
linux*Gcc*/
|
||||
linux*Icc*/
|
||||
solaris*Gcc*/
|
||||
SunOS*Gcc*/
|
||||
platforms/
|
||||
|
||||
# Generated files in the main directory (e.g. ReleaseNotes-?.?.html)
|
||||
# and in the doc directory
|
||||
/*.html
|
||||
/doc/*.html
|
||||
|
||||
# Source packages - anywhere
|
||||
*.tar.bz2
|
||||
*.tar.gz
|
||||
*.tar
|
||||
*.tgz
|
||||
*.gtgz
|
||||
|
||||
# Ignore the persistent .build tag in the main directory
|
||||
/.build
|
||||
|
||||
# Ignore .timeStamp in the main directory
|
||||
/.timeStamp
|
||||
|
||||
# Ignore .tags in the main directory
|
||||
/.tags
|
||||
|
||||
# Ignore project files in the main directory
|
||||
/.cproject
|
||||
/.project
|
||||
/.dir-locals.el
|
||||
|
||||
# Ignore the test directory
|
||||
/tutorialsTest
|
||||
|
||||
.*.swp
|
||||
*.gz
|
||||
3
Make/files
Normal file
3
Make/files
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
checkParticles.C
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/checkParticles
|
||||
7
Make/options
Normal file
7
Make/options
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
EXE_INC = \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lfiniteVolume \
|
||||
-lmeshTools
|
||||
150
checkParticles.C
Normal file
150
checkParticles.C
Normal file
|
|
@ -0,0 +1,150 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
Loading…
Add table
Reference in a new issue