mdInitialise.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2023 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 Description
25  Initialises fields for a molecular dynamics (MD) simulation.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "argList.H"
30 #include "md.H"
31 
32 using namespace Foam;
33 
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 
36 int main(int argc, char *argv[])
37 {
38  #include "setRootCase.H"
39  #include "createTime.H"
40  #include "createMeshNoChangers.H"
41 
42  IOdictionary mdInitialiseDict
43  (
44  IOobject
45  (
46  "mdInitialiseDict",
47  runTime.system(),
48  runTime,
51  false
52  )
53  );
54 
55  IOdictionary idListDict
56  (
57  IOobject
58  (
59  "idList",
60  mesh.time().constant(),
61  mesh,
64  )
65  );
66 
67  potential pot(mesh, mdInitialiseDict, idListDict);
68 
69  moleculeCloud molecules(mesh, pot, mdInitialiseDict);
70 
71  label totalMolecules = molecules.size();
72 
73  if (Pstream::parRun())
74  {
75  reduce(totalMolecules, sumOp<label>());
76  }
77 
78  Info<< nl << "Total number of molecules added: " << totalMolecules
79  << nl << endl;
80 
82 
83  if (!mesh.write())
84  {
86  << "Failed writing moleculeCloud."
87  << nl << exit(FatalError);
88  }
89 
90  Info<< nl << "ClockTime = " << runTime.elapsedClockTime() << " s"
91  << nl << endl;
92 
93  Info<< "\nEnd\n" << endl;
94 
95  return 0;
96 }
97 
98 
99 // ************************************************************************* //
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:57
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
@ MUST_READ_IF_MODIFIED
Definition: IOobject.H:119
static unsigned int defaultPrecision()
Return the default precision.
Definition: IOstream.H:458
static bool & parRun()
Is this a parallel run?
Definition: UPstream.H:399
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:306
int main(int argc, char *argv[])
Definition: financialFoam.C:44
Namespace for OpenFOAM.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
messageStream Info
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
error FatalError
static const char nl
Definition: Ostream.H:260