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-------------------------------------------------------------------------------
10License
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
26Application
27 lumpedPointZones
28
29Description
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"
42#include "fvMesh.H"
43
44using namespace Foam;
45
46// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47
48int main(int argc, char *argv[])
49{
50 argList::addNote
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
58 argList::addDryRunOption
59 (
60 "Test initial lumped points state without a mesh"
61 );
62 argList::addOption
63 (
64 "visual-length",
65 "len",
66 "Visualization length for planes (visualized as triangles)"
67 );
68
69 argList::addBoolOption
70 (
71 "no-interpolate",
72 "Suppress calculation/display of point interpolators"
73 );
74
75 argList::addVerboseOption
76 (
77 "Additional verbosity"
78 );
79
80 #include "addRegionOption.H"
81 #include "setRootCase.H"
82 #include "createTime.H"
83
84 const bool noInterpolate = args.found("no-interpolate");
85
86 args.readIfPresent("visual-length", lumpedPointState::visLength);
87
88 if (args.dryRun())
89 {
90 // Create without a mesh
92 lumpedPointIOMovement::New(runTime);
93
94 if (!movement)
95 {
96 Info<< "No valid movement found" << endl;
97 return 1;
98 }
99
100 const word outputName("state.vtp");
101
102 Info<< "dry-run: writing " << outputName << nl;
103
104 movement().writeStateVTP(movement().state0(), outputName);
105
106 Info<< "\nEnd\n" << endl;
107
108 return 0;
109 }
110
111
112 runTime.setTime(instant(runTime.constant()), 0);
113
114 #include "createNamedMesh.H"
115
116 autoPtr<lumpedPointIOMovement> movement = lumpedPointIOMovement::New(mesh);
117
118 if (!movement)
119 {
120 Info<< "No valid movement found" << endl;
121 return 1;
122 }
123
124 // Initial positions/rotations
125 movement().writeStateVTP("state.vtp");
126
127 pointIOField points0(lumpedPointTools::points0Field(mesh));
128
129 const label nPatches = lumpedPointTools::setPatchControls(mesh, points0);
130 if (!nPatches)
131 {
132 Info<< "No point patches with lumped movement found" << endl;
133 return 2;
134 }
135
136 Info<<"Lumped point patch controls set on "
137 << nPatches << " patches" << nl;
138
139 Info<<"Areas per point: " << flatOutput(movement().areas(mesh)) << nl;
140
141 if (noInterpolate)
142 {
143 // Initial geometry, with zones
144 movement().writeZonesVTP("lumpedPointZones.vtp", mesh, points0);
145 }
146 else
147 {
148 lumpedPointTools::setInterpolators(mesh, points0);
149
150 // Initial geometry, with zones and interpolations
151 movement().writeVTP("lumpedPointZones.vtp", mesh, points0);
152 }
153
154 Info<< nl
155 << "wrote 'state.vtp' (reference state)" << nl
156 << "wrote 'lumpedPointZones.vtp'" << nl
157 << "\nEnd\n" << endl;
158
159 return 0;
160}
161
162// ************************************************************************* //
A primitive field of type <T> with automated input and output.
Definition: IOField.H:58
int dryRun() const noexcept
Return the dry-run flag.
Definition: argListI.H:116
bool found(const word &optName) const
Return true if the named option is found.
Definition: argListI.H:178
bool readIfPresent(const word &optName, T &val) const
Read a value from the named option if present.
Definition: argListI.H:323
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
An instant of time. Contains the time value and name. Uses Foam::Time when formatting the name.
Definition: instant.H:56
A class for handling words, derived from Foam::string.
Definition: word.H:68
dynamicFvMesh & mesh
engineTime & runTime
Required Variables.
word outputName("finiteArea-edges.obj")
const label nPatches
Namespace for OpenFOAM.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
Definition: FlatOutput.H:215
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
Foam::argList args(argc, argv)
pointField points0(pointIOField(IOobject("points", mesh.time().constant(), polyMesh::meshSubDir, mesh, IOobject::MUST_READ, IOobject::NO_WRITE, false)))