lumpedPointZones.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) 2016-2021 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Application
27  lumpedPointZones
28 
29 Description
30  Produce a VTK PolyData file \c lumpedPointZones.vtp in which the
31  segmentation of the pressure integration zones can be visualized
32  for diagnostic purposes. Does not use external coupling.
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #include "argList.H"
37 #include "Time.H"
38 #include "timeSelector.H"
39 
40 #include "lumpedPointTools.H"
41 #include "lumpedPointIOMovement.H"
42 #include "fvMesh.H"
43 
44 using namespace Foam;
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 int main(int argc, char *argv[])
49 {
51  (
52  "Create lumpedPointZones.vtp to verify the segmentation of"
53  " pressure integration zones used by lumpedPoint BC."
54  );
55 
56  argList::noFunctionObjects(); // Never use function objects
57 
59  (
60  "Test initial lumped points state without a mesh"
61  );
63  (
64  "visual-length",
65  "len",
66  "Visualization length for planes (visualized as triangles)"
67  );
68 
70  (
71  "no-interpolate",
72  "Suppress calculation/display of point interpolators"
73  );
74 
76 
77  #include "addRegionOption.H"
78  #include "setRootCase.H"
79  #include "createTime.H"
80 
81  const bool noInterpolate = args.found("no-interpolate");
82 
84 
85  if (args.dryRun())
86  {
87  // Create without a mesh
90 
91  if (!movement)
92  {
93  Info<< "No valid movement found" << endl;
94  return 1;
95  }
96 
97  const word outputName("state.vtp");
98 
99  Info<< "dry-run: writing " << outputName << nl;
100 
101  movement().writeStateVTP(movement().state0(), outputName);
102 
103  Info<< "\nEnd\n" << endl;
104 
105  return 0;
106  }
107 
108 
110 
111  #include "createNamedMesh.H"
112 
114 
115  if (!movement)
116  {
117  Info<< "No valid movement found" << endl;
118  return 1;
119  }
120 
121  // Initial positions/rotations
122  movement().writeStateVTP("state.vtp");
123 
125 
127  if (!nPatches)
128  {
129  Info<< "No point patches with lumped movement found" << endl;
130  return 2;
131  }
132 
133  Info<<"Lumped point patch controls set on "
134  << nPatches << " patches" << nl;
135 
136  Info<<"Areas per point: " << flatOutput(movement().areas(mesh)) << nl;
137 
138  if (noInterpolate)
139  {
140  // Initial geometry, with zones
141  movement().writeZonesVTP("lumpedPointZones.vtp", mesh, points0);
142  }
143  else
144  {
146 
147  // Initial geometry, with zones and interpolations
148  movement().writeVTP("lumpedPointZones.vtp", mesh, points0);
149  }
150 
151  Info<< nl
152  << "wrote 'state.vtp' (reference state)" << nl
153  << "wrote 'lumpedPointZones.vtp'" << nl
154  << "\nEnd\n" << endl;
155 
156  return 0;
157 }
158 
159 // ************************************************************************* //
label nPatches
Definition: readKivaGrid.H:396
static void noFunctionObjects(bool addWithOption=false)
Remove &#39;-noFunctionObjects&#39; option and ignore any occurrences.
Definition: argList.C:547
static void addNote(const string &note)
Add extra notes for the usage information.
Definition: argList.C:462
static scalar visLength
The length for visualization triangles.
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:50
pointIOField points0Field(const polyMesh &mesh)
Return the 0 or constant points field.
engineTime & runTime
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:531
Required Classes.
static void addBoolOption(const word &optName, const string &usage="", bool advanced=false)
Add a bool option to validOptions with usage information.
Definition: argList.C:374
Required Classes.
word outputName("finiteArea-edges.obj")
dynamicFvMesh & mesh
A class for handling words, derived from Foam::string.
Definition: word.H:63
static void addDryRunOption(const string &usage, bool advanced=false)
Enable a &#39;dry-run&#39; bool option, with usage information.
Definition: argList.C:504
int dryRun() const noexcept
Return the dry-run flag.
Definition: argListI.H:109
static void addOption(const word &optName, const string &param="", const string &usage="", bool advanced=false)
Add an option to validOptions with usage information.
Definition: argList.C:385
virtual void setTime(const Time &t)
Reset the time and time-index to those of the given time.
Definition: Time.C:935
static void addVerboseOption(const string &usage="", bool advanced=false)
Enable a &#39;verbose&#39; bool option, with usage information.
Definition: argList.C:520
const word & constant() const noexcept
Return constant name.
Definition: TimePathsI.H:112
An instant of time. Contains the time value and name. Uses Foam::Time when formatting the name...
Definition: instant.H:53
pointField points0(pointIOField(IOobject("points", mesh.time().constant(), polyMesh::meshSubDir, mesh, IOobject::MUST_READ, IOobject::NO_WRITE, IOobject::NO_REGISTER)))
label setPatchControls(const pointVectorField &pvf, const pointField &points0)
Return the patch-ids associated with a "lumpedPointDisplacement" type.
static autoPtr< lumpedPointIOMovement > New(const objectRegistry &obr, label ownerId=-1)
Create a movement object in the registry by reading system dictionary.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
bool readIfPresent(const word &optName, T &val) const
Read a value from the named option if present.
Definition: argListI.H:316
Foam::argList args(argc, argv)
label setInterpolators(const pointVectorField &pvf, const pointField &points0)
Return the patch-ids associated with a "lumpedPointDisplacement" type.
A primitive field of type <T> with automated input and output.
bool found(const word &optName) const
Return true if the named option is found.
Definition: argListI.H:171
Namespace for OpenFOAM.
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
Definition: FlatOutput.H:225