createExternalCoupledPatchGeometry.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 | Copyright (C) 2013-2015 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 Application
25  createExternalCoupledPatchGeometry.
26 
27 Description
28  Application to generate the patch geometry (points and faces) for use
29  with the externalCoupled functionObject.
30 
31 Usage
32  - createExternalCoupledPatchGeometry <patchGroup> [OPTION]
33 
34  \param -commsDir <commsDir> \n
35  Specify an alternative communications directory (default is comms
36  in the case directory)
37 
38  \param -region <name> \n
39  Specify an alternative mesh region.
40 
41  \param -regions (<name1> <name2> .. <namen>) \n
42  Specify alternative mesh regions. The region names will be sorted
43  alphabetically and a single composite name will be created
44  <nameX>_<nameY>.._<nameZ>
45 
46  On execution, the combined patch geometry (points and faces) are output
47  to the communications directory.
48 
49 Note:
50  The addressing is patch-local, i.e. point indices for each patch point
51  used for face addressing starts at index 0.
52 
53 SeeAlso
54  externalCoupledFunctionObject
55 
56 \*---------------------------------------------------------------------------*/
57 
58 #include "fvCFD.H"
60 #include "IOobjectList.H"
61 
62 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
63 
64 int main(int argc, char *argv[])
65 {
66  #include "addRegionOption.H"
67  #include "addRegionsOption.H"
68  argList::validArgs.append("patchGroup");
69  argList::addOption
70  (
71  "commsDir",
72  "dir",
73  "specify alternate communications directory. default is 'comms'"
74  );
75  #include "setRootCase.H"
76  #include "createTime.H"
77 
78  wordList regionNames(1, fvMesh::defaultRegion);
79  if (!args.optionReadIfPresent("region", regionNames[0]))
80  {
81  args.optionReadIfPresent("regions", regionNames);
82  }
83 
84  const wordRe patchGroup(args.argRead<wordRe>(1));
85 
86  fileName commsDir(runTime.path()/"comms");
87  args.optionReadIfPresent("commsDir", commsDir);
88 
89 
90  // Make sure region names are in canonical order
91  stableSort(regionNames);
92 
93 
94  PtrList<const fvMesh> meshes(regionNames.size());
95  forAll(regionNames, i)
96  {
97  Info<< "Create mesh " << regionNames[i] << " for time = "
98  << runTime.timeName() << nl << endl;
99 
100  meshes.set
101  (
102  i,
103  new fvMesh
104  (
106  (
107  regionNames[i],
108  runTime.timeName(),
109  runTime,
111  )
112  )
113  );
114  }
115 
116 
117  externalCoupledFunctionObject::writeGeometry
118  (
119  UPtrList<const fvMesh>(meshes),
120  commsDir,
121  patchGroup
122  );
123 
124  Info<< "\nEnd\n" << endl;
125 
126  return 0;
127 }
128 
129 
130 // ************************************************************************* //
Foam::IOobject
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::IOobject::MUST_READ
@ MUST_READ
Definition: IOobject.H:108
IOobjectList.H
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
addRegionsOption.H
Foam::wordList
List< word > wordList
A List of words.
Definition: fileName.H:54
Foam::stableSort
void stableSort(UList< T > &)
Definition: UList.C:121
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::Info
messageStream Info
addRegionOption.H
main
int main(int argc, char *argv[])
Definition: postCalc.C:54
setRootCase.H
createTime.H
Foam::argList::argRead
T argRead(const label index) const
Read a value from the argument at index.
Definition: argListI.H:177
fvCFD.H
args
Foam::argList args(argc, argv)
Foam::argList::optionReadIfPresent
bool optionReadIfPresent(const word &opt, T &) const
Read a value from the named option if present.
Definition: argListI.H:198
externalCoupledFunctionObject.H