Test-passiveParticle.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Application
25  testPassiveParticle
26 
27 Description
28  Test cloud of passive particles.
29 
30 \*---------------------------------------------------------------------------*/
31 
32 #include "fvCFD.H"
33 #include "passiveParticleCloud.H"
34 
35 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 
37 int main(int argc, char *argv[])
38 {
39  argList::validArgs.append("cloudName");
40  #include "setRootCase.H"
41  #include "createTime.H"
42  #include "createMesh.H"
43  runTime.functionObjects().off();
44 
45  const word cloudName = args[1];
46 
47  {
48  // Start with empty cloud
49  passiveParticleCloud particles
50  (
51  mesh,
52  cloudName,
54  );
55  Pout<< "Starting particles:" << particles.size() << endl;
56 
57  Pout<< "Adding a particle." << endl;
58  particles.addParticle(new passiveParticle(mesh, vector::zero, -1));
59 
60  forAllConstIter(passiveParticleCloud, particles, iter)
61  {
62  Pout<< " " << iter().position() << " cell:" << iter().cell()
63  << " origProc:" << iter().origProc()
64  << " origId:" << iter().origId()
65  << endl;
66  }
67 
68  Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
69  << " ClockTime = " << runTime.elapsedClockTime() << " s"
70  << nl << endl;
71 
72  runTime++;
73  Pout<< "Writing particles to time " << runTime.timeName() << endl;
74  particles.write();
75  }
76 
77  {
78  Pout<< "Rereading particles from time " << runTime.timeName()
79  << endl;
81  Pout<< "Reread particles:" << particles.size() << endl;
82 
83  forAllConstIter(passiveParticleCloud, particles, iter)
84  {
85  Pout<< " " << iter().position() << " cell:" << iter().cell()
86  << " origProc:" << iter().origProc()
87  << " origId:" << iter().origId()
88  << endl;
89  }
90  }
91 
92 
93  Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
94  << " ClockTime = " << runTime.elapsedClockTime() << " s"
95  << nl << endl;
96 
97 
98  Info<< "End\n" << endl;
99 
100  return 0;
101 }
102 
103 
104 // ************************************************************************* //
Foam::Cloud::addParticle
void addParticle(ParticleType *pPtr)
Transfer particle to cloud.
Definition: Cloud.C:162
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::passiveParticle
Copy of base particle.
Definition: passiveParticle.H:50
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
forAllConstIter
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
Definition: pEqn.H:39
Foam::IDLList
Intrusive doubly-linked list.
Definition: IDLList.H:47
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::Info
messageStream Info
Foam::Cloud::size
label size() const
Definition: Cloud.H:175
Foam::passiveParticleCloud
A Cloud of passive particles.
Definition: passiveParticleCloud.H:49
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
setRootCase.H
main
int main(int argc, char *argv[])
Definition: Test-passiveParticle.C:34
Foam::Pout
prefixOSstream Pout(cout, "Pout")
Definition: IOstreams.H:53
passiveParticleCloud.H
createMesh.H
createTime.H
cloudName
const word cloudName(propsDict.lookup("cloudName"))
fvCFD.H
args
Foam::argList args(argc, argv)