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-------------------------------------------------------------------------------
11License
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
27Application
28 createExternalCoupledPatchGeometry.
29
30Group
31 grpPreProcessingUtilities
32
33Description
34 Generate the patch geometry (points and faces) for use
35 with the externalCoupled functionObject.
36
37Usage
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
57Note:
58 The addressing is patch-local, i.e. point indices for each patch point
59 used for face addressing starts at index 0.
60
61See 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
73int 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 (
137 runTime.timeName(),
138 runTime,
140 )
141 )
142 );
143 }
144
145
146 functionObjects::externalCoupled::writeGeometry
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// ************************************************************************* //
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
const T * set(const label i) const
Definition: PtrList.H:138
T get(const label index) const
Get a value from the argument at index.
Definition: argListI.H:278
bool readIfPresent(const word &optName, T &val) const
Read a value from the named option if present.
Definition: argListI.H:323
engineTime & runTime
Foam::word regionName(Foam::polyMesh::defaultRegion)
Foam::PtrList< Foam::fvMesh > meshes(regionNames.size())
wordList regionNames
List< word > wordList
A List of words.
Definition: fileName.H:63
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
void stableSort(UList< T > &list)
Stable sort the list.
Definition: UList.C:356
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
Foam::argList args(argc, argv)
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333