preparePar.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | cfMesh: A library for mesh generation
4  \\ / O peration |
5  \\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
6  \\/ M anipulation | Copyright (C) Creative Fields, Ltd.
7 -------------------------------------------------------------------------------
8 License
9  This file is part of cfMesh.
10 
11  cfMesh is free software; you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by the
13  Free Software Foundation; either version 3 of the License, or (at your
14  option) any later version.
15 
16  cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
23 
24 Application
25  Prepares the case for a parallel mesh generation run
26 
27 Description
28  - creates processor* directories which contain data for processors
29 
30 \*---------------------------------------------------------------------------*/
31 
32 #include "argList.H"
33 #include "polyMeshGen.H"
34 
35 #include <sstream>
36 
37 using namespace Foam;
38 
39 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
40 
41 // Main program:
42 
43 int main(int argc, char *argv[])
44 {
45 # include "setRootCase.H"
46 # include "createTime.H"
47 
48  IOdictionary meshDict
49  (
50  IOobject
51  (
52  "meshDict",
53  runTime.system(),
54  runTime,
57  )
58  );
59 
60  IOdictionary decomposeParDict
61  (
62  IOobject
63  (
64  "decomposeParDict",
65  runTime.system(),
66  runTime,
69  )
70  );
71 
72  const label nProcessors
73  (
74  readLabel(decomposeParDict.lookup("numberOfSubdomains"))
75  );
76 
77  for(label procI=0;procI<nProcessors;++procI)
78  {
79  fileName file("processor");
80  std::ostringstream ss;
81  ss << procI;
82  file += ss.str();
83  Info << "Creating " << file << endl;
84 
85  //- create a directory for processor data
86  mkDir(runTime.path()/file);
87 
88  //- copy the contents of the const directory into processor*
89  cp(runTime.path()/"constant", runTime.path()/file);
90 
91  //- generate 0 directories for
92  mkDir(runTime.path()/file/"0");
93  }
94 
95  Info << "End\n" << endl;
96  return 0;
97 }
98 
99 
100 // ************************************************************************* //
Foam::IOdictionary
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:53
Foam::IOobject
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
Foam::dictionary::lookup
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:449
Foam::IOobject::MUST_READ
@ MUST_READ
Definition: IOobject.H:108
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::cp
bool cp(const fileName &src, const fileName &dst)
Copy, recursively if necessary, the source to the destination.
Definition: POSIX.C:755
Foam::IOobject::NO_WRITE
@ NO_WRITE
Definition: IOobject.H:118
Foam::label
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
Foam::Info
messageStream Info
polyMeshGen.H
argList.H
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
setRootCase.H
main
int main(int argc, char *argv[])
Definition: preparePar.C:40
createTime.H
Foam::readLabel
label readLabel(Istream &is)
Definition: label.H:64
Foam::mkDir
bool mkDir(const fileName &, mode_t=0777)
Make a directory and return an error if it could not be created.
Definition: POSIX.C:419