dsmcInitialise.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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2015 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Application
27  dsmcInitialise
28 
29 Group
30  grpPreProcessingUtilities
31 
32 Description
33  Initialise a case for dsmcFoam by reading the initialisation dictionary
34  system/dsmcInitialise.
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #include "fvCFD.H"
39 #include "dsmcCloud.H"
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 int main(int argc, char *argv[])
44 {
45  argList::addNote
46  (
47  "Initialise a case for dsmcFoam from the system/dsmcInitialise"
48  " dictionary"
49  );
50 
51  #include "setRootCase.H"
52  #include "createTime.H"
53  #include "createNamedMesh.H"
54 
55  // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
56 
57  IOdictionary dsmcInitialiseDict
58  (
59  IOobject
60  (
61  "dsmcInitialiseDict",
62  mesh.time().system(),
63  mesh,
64  IOobject::MUST_READ_IF_MODIFIED,
65  IOobject::NO_WRITE
66  )
67  );
68 
69  Info<< "Initialising dsmc for Time = " << runTime.timeName() << nl << endl;
70 
71  dsmcCloud dsmc("dsmc", mesh, dsmcInitialiseDict);
72 
73  label totalMolecules = dsmc.size();
74 
75  if (Pstream::parRun())
76  {
77  reduce(totalMolecules, sumOp<label>());
78  }
79 
80  Info<< nl << "Total number of molecules added: " << totalMolecules
81  << nl << endl;
82 
83  IOstream::defaultPrecision(15);
84 
85  if (!mesh.write())
86  {
88  << "Failed writing dsmcCloud."
89  << nl << exit(FatalError);
90  }
91 
92  Info<< nl;
93  runTime.printExecutionTime(Info);
94 
95  Info<< "End\n" << endl;
96 
97  return 0;
98 }
99 
100 
101 // ************************************************************************* //
runTime
engineTime & runTime
Definition: createEngineTime.H:13
dsmcCloud
Cloud class to simulate dsmc parcels.
dsmcCloud.H
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:350
Foam::Info
messageStream Info
Information stream (uses stdout - output is on the master only)
Foam::FatalError
error FatalError
createNamedMesh.H
reduce
reduce(hasMovingMesh, orOp< bool >())
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
setRootCase.H
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:381
Foam::nl
constexpr char nl
Definition: Ostream.H:385
createTime.H
fvCFD.H