Initial commit for version 2.0.x patch release
[OpenFOAM-2.0.x.git] / applications / test / passiveParticle / Test-passiveParticle.C
blobad04d436794db368d4b916c9c2bdfbccabb8b3bd
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2004-2011 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
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.
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.
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/>.
24 Application
25     testPassiveParticle
27 Description
28     Test cloud of passive particles.
30 \*---------------------------------------------------------------------------*/
32 #include "fvCFD.H"
33 #include "passiveParticleCloud.H"
35 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 int main(int argc, char *argv[])
39     argList::validArgs.append("cloudName");
40     #include "setRootCase.H"
41     #include "createTime.H"
42     #include "createMesh.H"
43     runTime.functionObjects().off();
45     const word cloudName = args[1];
47     {
48         // Start with empty cloud
49         passiveParticleCloud particles
50         (
51             mesh,
52             cloudName,
53             IDLList<passiveParticle>()
54         );
55         Pout<< "Starting particles:" << particles.size() << endl;
57         Pout<< "Adding a particle." << endl;
58         particles.addParticle(new passiveParticle(mesh, vector::zero, -1));
60         forAllConstIter(passiveParticleCloud, particles, iter)
61         {
62             Pout<< "    " << iter().position() << " cell:" << iter().cell()
63                 << " origProc:" << iter().origProc()
64                 << " origId:" << iter().origId()
65                 << endl;
66         }
68         Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
69             << "  ClockTime = " << runTime.elapsedClockTime() << " s"
70             << nl << endl;
72         runTime++;
73         Pout<< "Writing particles to time " << runTime.timeName() << endl;
74         particles.write();
75     }
77     {
78         Pout<< "Rereading particles from time " << runTime.timeName()
79             << endl;
80         passiveParticleCloud particles(mesh, cloudName);
81         Pout<< "Reread particles:" << particles.size() << endl;
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     }
93     Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
94         << "  ClockTime = " << runTime.elapsedClockTime() << " s"
95         << nl << endl;
98     Info<< "End\n" << endl;
100     return 0;
104 // ************************************************************************* //