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-2020 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  "dry-run",
61  "Test initial lumped points state without a mesh"
62  );
64  (
65  "visual-length",
66  "len",
67  "Visualization length for planes (visualized as triangles)"
68  );
69 
71  (
72  "no-interpolate",
73  "Suppress calculation/display of point interpolators"
74  );
75 
77  (
78  "verbose",
79  "Additional verbosity"
80  );
81 
82  #include "addRegionOption.H"
83 
84  #include "setRootCase.H"
85 
86  const bool noInterpolate = args.found("no-interpolate");
87 
88  const bool dryrun = args.found("dry-run");
89 
90  // const bool verbose = args.found("verbose");
91 
93 
94  #include "createTime.H"
95 
96  if (dryrun)
97  {
98  // Create without a mesh
101 
102  if (!movement.valid())
103  {
104  Info<< "No valid movement found" << endl;
105  return 1;
106  }
107 
108  const word outputName("state.vtp");
109 
110  Info<< "dry-run: writing " << outputName << nl;
111 
112  movement().writeStateVTP(movement().state0(), outputName);
113 
114  Info<< "\nEnd\n" << endl;
115 
116  return 0;
117  }
118 
119 
121 
122  #include "createNamedMesh.H"
123 
125 
126  if (!movement.valid())
127  {
128  Info<< "No valid movement found" << endl;
129  return 1;
130  }
131 
132  // Initial positions/rotations
133  movement().writeStateVTP("state.vtp");
134 
136 
138  if (!nPatches)
139  {
140  Info<< "No point patches with lumped movement found" << endl;
141  return 2;
142  }
143 
144  Info<<"Lumped point patch controls set on "
145  << nPatches << " patches" << nl;
146 
147  Info<<"Areas per point: " << flatOutput(movement().areas(mesh)) << nl;
148 
149  if (noInterpolate)
150  {
151  // Initial geometry, with zones
152  movement().writeZonesVTP("lumpedPointZones.vtp", mesh, points0);
153  }
154  else
155  {
157 
158  // Initial geometry, with zones and interpolations
159  movement().writeVTP("lumpedPointZones.vtp", mesh, points0);
160  }
161 
162  Info<< nl
163  << "wrote 'state.vtp' (reference state)" << nl
164  << "wrote 'lumpedPointZones.vtp'" << nl
165  << "\nEnd\n" << endl;
166 
167  return 0;
168 }
169 
170 // ************************************************************************* //
runTime
engineTime & runTime
Definition: createEngineTime.H:13
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::IOField
A primitive field of type <T> with automated input and output.
Definition: foamVtkLagrangianWriter.H:61
Foam::lumpedPointTools::setPatchControls
label setPatchControls(const pointVectorField &pvf, const pointField &points0)
Return the patch-ids associated with a "lumpedPointDisplacement" type.
Definition: lumpedPointTools.C:179
nPatches
label nPatches
Definition: readKivaGrid.H:396
Foam::argList::addNote
static void addNote(const string &note)
Add extra notes for the usage information.
Definition: argList.C:413
Foam::autoPtr::valid
bool valid() const noexcept
True if the managed pointer is non-null.
Definition: autoPtr.H:148
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:350
Foam::argList::readIfPresent
bool readIfPresent(const word &optName, T &val) const
Read a value from the named option if present.
Definition: argListI.H:302
Foam::argList::noFunctionObjects
static void noFunctionObjects(bool addWithOption=false)
Remove '-noFunctionObjects' option and ignore any occurrences.
Definition: argList.C:454
lumpedPointTools.H
Foam::Info
messageStream Info
Information stream (uses stdout - output is on the master only)
argList.H
addRegionOption.H
Foam::lumpedPointTools::setInterpolators
label setInterpolators(const pointVectorField &pvf, const pointField &points0)
Return the patch-ids associated with a "lumpedPointDisplacement" type.
Definition: lumpedPointTools.C:232
createNamedMesh.H
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
fvMesh.H
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
lumpedPointIOMovement.H
Foam::argList::addBoolOption
static void addBoolOption(const word &optName, const string &usage="", bool advanced=false)
Add a bool option to validOptions with usage information.
Definition: argList.C:325
Time.H
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
points0
pointField points0(pointIOField(IOobject("points", mesh.time().constant(), polyMesh::meshSubDir, mesh, IOobject::MUST_READ, IOobject::NO_WRITE, false)))
setRootCase.H
Foam::nl
constexpr char nl
Definition: Ostream.H:385
Foam::flatOutput
FlatOutput< Container > flatOutput(const Container &obj, label len=0)
Global flatOutput function.
Definition: FlatOutput.H:85
Foam::Time::setTime
virtual void setTime(const Time &t)
Reset the time and time-index to those of the given time.
Definition: Time.C:1006
timeSelector.H
createTime.H
Foam::lumpedPointTools::points0Field
pointIOField points0Field(const polyMesh &mesh)
Return the 0 or constant points field.
Definition: lumpedPointTools.C:138
Foam::instant
An instant of time. Contains the time value and name.
Definition: instant.H:52
Foam::TimePaths::constant
const word & constant() const
Return constant name.
Definition: TimePathsI.H:88
Foam::argList::addOption
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:336
args
Foam::argList args(argc, argv)
Foam::lumpedPointState::visLength
static scalar visLength
The length for visualization triangles.
Definition: lumpedPointState.H:171
Foam::lumpedPointIOMovement::New
static autoPtr< lumpedPointIOMovement > New(const objectRegistry &obr, label ownerId=-1)
Definition: lumpedPointIOMovement.C:53
Foam::argList::found
bool found(const word &optName) const
Return true if the named option is found.
Definition: argListI.H:157