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  "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 
87 
88  if (args.dryRun())
89  {
90  // Create without a mesh
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 
113 
114  #include "createNamedMesh.H"
115 
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 
128 
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  {
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 // ************************************************************************* //
runTime
engineTime & runTime
Definition: createEngineTime.H:13
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:63
Foam::IOField
A primitive field of type <T> with automated input and output.
Definition: foamVtkLagrangianWriter.H:57
Foam::lumpedPointTools::setPatchControls
label setPatchControls(const pointVectorField &pvf, const pointField &points0)
Definition: lumpedPointTools.C:172
Foam::argList::addNote
static void addNote(const string &note)
Definition: argList.C:405
Foam::endl
Ostream & endl(Ostream &os)
Definition: Ostream.H:381
Foam::argList::readIfPresent
bool readIfPresent(const word &optName, T &val) const
Definition: argListI.H:316
outputName
word outputName("finiteArea-edges.obj")
Foam::argList::noFunctionObjects
static void noFunctionObjects(bool addWithOption=false)
Definition: argList.C:466
nPatches
const label nPatches
Definition: printMeshSummary.H:24
lumpedPointTools.H
Foam::argList::dryRun
int dryRun() const noexcept
Definition: argListI.H:109
Foam::Info
messageStream Info
argList.H
addRegionOption.H
Foam::lumpedPointTools::setInterpolators
label setInterpolators(const pointVectorField &pvf, const pointField &points0)
Definition: lumpedPointTools.C:225
createNamedMesh.H
Required Variables.
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
fvMesh.H
Foam
Definition: atmBoundaryLayer.C:26
Foam::flatOutput
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Definition: FlatOutput.H:217
lumpedPointIOMovement.H
Foam::argList::addDryRunOption
static void addDryRunOption(const string &usage, bool advanced=false)
Definition: argList.C:447
Foam::argList::addBoolOption
static void addBoolOption(const word &optName, const string &usage="", bool advanced=false)
Definition: argList.C:317
Time.H
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:49
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:424
Foam::Time::setTime
virtual void setTime(const Time &t)
Definition: Time.C:996
timeSelector.H
createTime.H
Foam::lumpedPointTools::points0Field
pointIOField points0Field(const polyMesh &mesh)
Definition: lumpedPointTools.C:131
Foam::instant
An instant of time. Contains the time value and name.
Definition: instant.H:48
Foam::TimePaths::constant
const word & constant() const
Definition: TimePathsI.H:89
Foam::argList::addOption
static void addOption(const word &optName, const string &param="", const string &usage="", bool advanced=false)
Definition: argList.C:328
args
Foam::argList args(argc, argv)
Foam::lumpedPointState::visLength
static scalar visLength
Definition: lumpedPointState.H:167
Foam::lumpedPointIOMovement::New
static autoPtr< lumpedPointIOMovement > New(const objectRegistry &obr, label ownerId=-1)
Definition: lumpedPointIOMovement.C:46
Foam::argList::addVerboseOption
static void addVerboseOption(const string &usage, bool advanced=false)
Definition: argList.C:457
Foam::argList::found
bool found(const word &optName) const
Definition: argListI.H:171