cv2DControls.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) 2020-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
27\*----------------------------------------------------------------------------*/
28
29#include "cv2DControls.H"
30
31// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32
34(
35 const dictionary& controlDict,
36 const boundBox& bb
37)
38:
39 motionControl_(controlDict.subDict("motionControl")),
40 conformationControl_(controlDict.subDict("surfaceConformation")),
41
42 minCellSize_(motionControl_.get<scalar>("minCellSize")),
43 minCellSize2_(Foam::sqr(minCellSize_)),
44
45 maxQuadAngle_(conformationControl_.get<scalar>("maxQuadAngle")),
46
47 nearWallAlignedDist_
48 (
49 motionControl_.get<scalar>("nearWallAlignedDist") * minCellSize_
50 ),
51 nearWallAlignedDist2_(Foam::sqr(nearWallAlignedDist_)),
52
53 insertSurfaceNearestPointPairs_
54 (
55 conformationControl_.get<Switch>
56 (
57 "insertSurfaceNearestPointPairs"
58 )
59 ),
60 mirrorPoints_
61 (
62 conformationControl_.get<Switch>
63 (
64 "mirrorPoints"
65 )
66 ),
67 insertSurfaceNearPointPairs_
68 (
69 conformationControl_.get<Switch>
70 (
71 "insertSurfaceNearPointPairs"
72 )
73 ),
74
75 objOutput_
76 (
77 motionControl_.getOrDefault<Switch>("objOutput", false)
78 ),
79
80 meshedSurfaceOutput_
81 (
82 motionControl_.getOrDefault<Switch>("meshedSurfaceOutput", false)
83 ),
84
85 randomiseInitialGrid_
86 (
87 conformationControl_.get<Switch>("randomiseInitialGrid")
88 ),
89 randomPerturbation_
90 (
91 conformationControl_.get<scalar>("randomPerturbation")
92 ),
93
94 maxBoundaryConformingIter_
95 (
96 conformationControl_.get<label>("maxBoundaryConformingIter")
97 ),
98
99 span_
100 (
101 max(mag(bb.max().x()), mag(bb.min().x()))
102 + max(mag(bb.max().y()), mag(bb.min().y()))
103 ),
104 span2_(Foam::sqr(span_)),
105
106 minEdgeLen_
107 (
108 conformationControl_.get<scalar>("minEdgeLenCoeff") * minCellSize_
109 ),
110 minEdgeLen2_(Foam::sqr(minEdgeLen_)),
111
112 maxNotchLen_
113 (
114 conformationControl_.get<scalar>("maxNotchLenCoeff") * minCellSize_
115 ),
116 maxNotchLen2_(Foam::sqr(maxNotchLen_)),
117
118 minNearPointDist_
119 (
120 conformationControl_.get<scalar>("minNearPointDistCoeff")*minCellSize_
121 ),
122 minNearPointDist2_(Foam::sqr(minNearPointDist_)),
123
124 ppDist_
125 (
126 conformationControl_.get<scalar>("pointPairDistanceCoeff")*minCellSize_
127 )
128{}
129
130
131// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
132
133void Foam::cv2DControls::write(Ostream& os) const
134{
135 const auto oldLevel = os.indentLevel(1);
136 os.precision(2);
137 os.flags(ios_base::scientific);
138
139 os << nl << "Outputting CV2D Mesher controls:" << nl
141 << indent << "minCellSize2_ : " << minCellSize2_ << nl
142 << indent << "span_ / span2_ : " << span_ << " / " << span2_ << nl
143 << indent << "maxNotchLen2_ : " << maxNotchLen2_ << nl
144 << indent << "minNearPointDist2_ : " << minNearPointDist2_ << nl
145 << indent << "nearWallAlignedDist2_ : " << nearWallAlignedDist2_ << nl
146 << indent << "ppDist_ : " << ppDist_ << nl
147 << indent << "minEdgeLen2_ : " << minEdgeLen2_ << nl
149
150 os.indentLevel(oldLevel);
151}
152
153
154// * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * * * //
155
156Foam::Ostream& Foam::operator<<(Ostream& os, const cv2DControls& s)
157{
158 s.write(os);
159 return os;
160}
161
162
163
164// ************************************************************************* //
scalar y
Y[inertIndex] max(0.0)
virtual int precision() const
Get precision of output field.
Definition: OSstream.C:326
virtual ios_base::fmtflags flags() const
Get stream flags.
Definition: OSstream.C:288
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
unsigned short indentLevel() const noexcept
Return the indent level.
Definition: Ostream.H:191
Controls for the 2D CV mesh generator.
Definition: cv2DControls.H:61
scalar minEdgeLen2_
Square of minEdgeLen.
Definition: cv2DControls.H:134
scalar minCellSize2_
Square of minCellSize.
Definition: cv2DControls.H:89
scalar maxNotchLen2_
Square of maxNotchLen.
Definition: cv2DControls.H:141
scalar span_
Maximum cartesian span of the geometry.
Definition: cv2DControls.H:124
scalar span2_
Square of span.
Definition: cv2DControls.H:127
scalar minNearPointDist2_
Square of minNearPoint.
Definition: cv2DControls.H:148
scalar nearWallAlignedDist2_
Square of nearWallAlignedDist.
Definition: cv2DControls.H:99
scalar ppDist_
Distance between boundary conforming point-pairs.
Definition: cv2DControls.H:151
virtual bool write()
Write the output fields.
@ BEGIN_BLOCK
Begin block [isseparator].
Definition: token.H:159
@ END_BLOCK
End block [isseparator].
Definition: token.H:160
runTime controlDict().readEntry("adjustTimeStep"
OBJstream os(runTime.globalPath()/outputName)
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
Namespace for OpenFOAM.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:342
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:33
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53