mdInitialise.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 |
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2015 OpenFOAM Foundation
9-------------------------------------------------------------------------------
10License
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
26Application
27 mdInitialise
28
29Group
30 grpPreProcessingUtilities
31
32Description
33 Initialises fields for a molecular dynamics (MD) simulation.
34
35\*---------------------------------------------------------------------------*/
36
37#include "md.H"
38#include "fvCFD.H"
39
40// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41
42int main(int argc, char *argv[])
43{
44 argList::addNote
45 (
46 "Initialises fields for a molecular dynamics (MD) simulation"
47 );
48 #include "setRootCase.H"
49 #include "createTime.H"
50 #include "createNamedMesh.H"
51
52 IOdictionary mdInitialiseDict
53 (
54 IOobject
55 (
56 "mdInitialiseDict",
57 runTime.system(),
58 runTime,
59 IOobject::MUST_READ_IF_MODIFIED,
60 IOobject::NO_WRITE,
61 false
62 )
63 );
64
65 IOdictionary idListDict
66 (
67 IOobject
68 (
69 "idList",
70 mesh.time().constant(),
71 mesh,
72 IOobject::NO_READ,
73 IOobject::AUTO_WRITE
74 )
75 );
76
77 potential pot(mesh, mdInitialiseDict, idListDict);
78
79 moleculeCloud molecules(mesh, pot, mdInitialiseDict);
80
81 label totalMolecules = molecules.size();
82
83 if (Pstream::parRun())
84 {
85 reduce(totalMolecules, sumOp<label>());
86 }
87
88 Info<< nl << "Total number of molecules added: " << totalMolecules
89 << nl << endl;
90
91 IOstream::defaultPrecision(15);
92
93 if (!mesh.write())
94 {
96 << "Failed writing moleculeCloud."
97 << nl << exit(FatalError);
98 }
99
100 Info<< nl;
101 runTime.printExecutionTime(Info);
102
103 Info<< "\nEnd\n" << endl;
104
105 return 0;
106}
107
108
109// ************************************************************************* //
reduce(hasMovingMesh, orOp< bool >())
dynamicFvMesh & mesh
engineTime & runTime
Required Variables.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53