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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2013-2015 OpenFOAM Foundation
9  Copyright (C) 2016-2021 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Application
28  createExternalCoupledPatchGeometry.
29 
30 Group
31  grpPreProcessingUtilities
32 
33 Description
34  Generate the patch geometry (points and faces) for use
35  with the externalCoupled functionObject.
36 
37 Usage
38  \verbatim
39  createExternalCoupledPatchGeometry <patchGroup> [OPTION]
40  \endverbatim
41 
42  \param -commsDir <commsDir> \n
43  Specify an alternative communications directory (default is comms
44  in the case directory)
45 
46  \param -region <name> \n
47  Specify an alternative mesh region.
48 
49  \param -regions (<name1> .. <nameN>) \n
50  Specify alternative mesh regions. The region names will be sorted
51  alphabetically and a single composite name will be created
52  <nameX>_<nameY>.._<nameZ>
53 
54  On execution, the combined patch geometry (points and faces) are output
55  to the communications directory.
56 
57 Note:
58  The addressing is patch-local, i.e. point indices for each patch point
59  used for face addressing starts at index 0.
60 
61 See also
62  functionObjects::externalCoupled
63 
64 \*---------------------------------------------------------------------------*/
65 
66 #include "fvCFD.H"
67 #include "externalCoupled.H"
68 #include "regionProperties.H"
69 #include "IOobjectList.H"
70 
71 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
72 
73 int main(int argc, char *argv[])
74 {
75  argList::addNote
76  (
77  "Generate the patch geometry (points and faces) for use"
78  " with the externalCoupled functionObject."
79  );
80 
81  argList::addOption
82  (
83  "region",
84  "name",
85  "Specify alternative mesh region"
86  );
87  argList::addOption
88  (
89  "regions",
90  "(name1 .. nameN)",
91  "Specify alternative mesh regions"
92  );
93 
94  argList::addArgument("patchGroup");
95  argList::addOption
96  (
97  "commsDir",
98  "dir",
99  "Specify communications directory (default is 'comms')"
100  );
101  #include "setRootCase.H"
102  #include "createTime.H"
103 
104  wordList regionNames(1, polyMesh::defaultRegion);
105  if (!args.readIfPresent("region", regionNames.first()))
106  {
107  args.readIfPresent("regions", regionNames);
108  }
109 
110  const wordRe patchGroup(args.get<wordRe>(1));
111 
112  fileName commsDir(runTime.path()/"comms");
113  args.readIfPresent("commsDir", commsDir);
114 
115 
116  // Make sure region names are in canonical order
118 
119 
120  PtrList<const fvMesh> meshes(regionNames.size());
121  forAll(regionNames, regioni)
122  {
123  const word& regionName = regionNames[regioni];
124 
125  Info<< "Create mesh " << regionName
126  << " for time = "
127  << runTime.timeName() << nl << endl;
128 
129  meshes.set
130  (
131  regioni,
132  new fvMesh
133  (
135  (
136  regionName,
137  runTime.timeName(),
138  runTime,
140  )
141  )
142  );
143  }
144 
145 
147  (
148  UPtrList<const fvMesh>(meshes),
149  commsDir,
150  patchGroup
151  );
152 
153  Info<< "\nEnd\n" << endl;
154 
155  return 0;
156 }
157 
158 
159 // ************************************************************************* //
runTime
engineTime & runTime
Definition: createEngineTime.H:13
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:165
regionProperties.H
IOobjectList.H
Foam::endl
Ostream & endl(Ostream &os)
Definition: Ostream.H:381
Foam::PtrList::set
const T * set(const label i) const
Definition: PtrList.H:134
Foam::argList::get
T get(const label index) const
Definition: argListI.H:271
Foam::argList::readIfPresent
bool readIfPresent(const word &optName, T &val) const
Definition: argListI.H:316
externalCoupled.H
regionNames
wordList regionNames
Definition: getAllRegionOptions.H:31
writeGeometry
writer writeGeometry()
forAll
#define forAll(list, i)
Definition: stdFoam.H:349
Foam::stableSort
void stableSort(UList< T > &a)
Definition: UList.C:268
Foam::wordList
List< word > wordList
A List of words.
Definition: fileName.H:58
regionName
Foam::word regionName
Definition: createNamedDynamicFvMesh.H:1
Foam::Info
messageStream Info
meshes
Foam::PtrList< Foam::fvMesh > meshes(regionNames.size())
setRootCase.H
Foam::nl
constexpr char nl
Definition: Ostream.H:424
createTime.H
fvCFD.H
args
Foam::argList args(argc, argv)
Foam::IOobject::MUST_READ
@ MUST_READ
Definition: IOobject.H:181