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 -------------------------------------------------------------------------------
11 License
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 
33 Foam::cv2DControls::cv2DControls
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 
133 void Foam::cv2DControls::write(Ostream& os) const
134 {
135  const auto oldLevel = os.indentLevel(1);
136  os.precision(2);
138 
139  os << nl << "Outputting CV2D Mesher controls:" << nl
140  << token::BEGIN_BLOCK << 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
148  << token::END_BLOCK << endl;
149 
150  os.indentLevel(oldLevel);
151 }
152 
153 
154 // * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * * * //
155 
156 Foam::Ostream& Foam::operator<<(Ostream& os, const cv2DControls& s)
157 {
158  s.write(os);
159  return os;
160 }
161 
162 
163 
164 // ************************************************************************* //
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
Begin block [isseparator].
Definition: token.H:162
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:449
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
virtual int precision() const
Get precision of output field.
Definition: OSstream.C:305
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:40
dimensionedSymmTensor sqr(const dimensionedVector &dv)
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:49
virtual ios_base::fmtflags flags() const
Get stream flags.
Definition: OSstream.H:149
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:487
scalar y
void write(Ostream &os) const
Write controls to output stream.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:26
runTime controlDict().readEntry("adjustTimeStep"
The central control dictionary, the contents of which are either taken directly from the FOAM_CONTROL...
Definition: debug.C:142
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:55
OBJstream os(runTime.globalPath()/outputName)
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:76
unsigned short indentLevel() const noexcept
Return the indent level.
Definition: Ostream.H:242
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))
End block [isseparator].
Definition: token.H:163
IOstream & scientific(IOstream &io)
Definition: IOstream.H:563
Namespace for OpenFOAM.