Loading...
Searching...
No Matches
projectVertex.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 OpenFOAM Foundation
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
26\*---------------------------------------------------------------------------*/
27
28#include "projectVertex.H"
29#include "unitConversion.H"
32#include "pointConstraint.H"
34// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35
36namespace Foam
37{
38namespace blockVertices
39{
42}
43}
44
45
46// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
47
48Foam::blockVertices::projectVertex::projectVertex
49(
50 const dictionary& dict,
51 const label index,
52 const searchableSurfaces& geometry,
53 Istream& is
54)
55:
56 pointVertex(dict, index, geometry, is),
57 geometry_(geometry)
58{
59 wordList names(is);
60 surfaces_.setSize(names.size());
61 forAll(names, i)
62 {
63 surfaces_[i] = geometry_.findSurfaceID(names[i]);
64
65 if (surfaces_[i] == -1)
66 {
68 << "Cannot find surface " << names[i] << " in geometry"
70 }
71 }
72}
73
74
75// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
76
77Foam::blockVertices::projectVertex::operator point() const
78{
79 pointField start(1, pointVertex::operator point());
80
81 pointField boundaryNear(start);
82 List<pointConstraint> boundaryConstraint;
83
84
85 // Note: how far do we need to search? Probably not further than
86 // span of surfaces themselves. Make sure to limit in case
87 // of e.g. searchablePlane which has infinite bb.
88 boundBox bb(searchableSurfacesQueries::bounds(geometry_, surfaces_));
89 bb.min() = max(bb.min(), point(-GREAT, -GREAT, -GREAT));
90 bb.max() = min(bb.max(), point(GREAT, GREAT, GREAT));
91
93 (
94 geometry_,
95 surfaces_,
96 start,
97 scalarField(start.size(), bb.magSqr()),
98 boundaryNear,
99 boundaryConstraint
100 );
101
102 return boundaryNear[0];
103}
104
105
106// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition Istream.H:60
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition List.H:72
void setSize(label n)
Alias for resize().
Definition List.H:536
void size(const label n)
Older name for setAddressableSize.
Definition UList.H:118
Define a block vertex.
Definition blockVertex.H:48
blockVertex() noexcept=default
Default construct.
pointVertex(const dictionary &dict, const label index, const searchableSurfaces &geometry, Istream &is)
Construct from Istream setting pointsList.
Definition pointVertex.C:39
Projects the vertex onto the selected surfacees of the geometry provided as a searchableSurfaces obje...
A bounding box defined in terms of min/max extrema points.
Definition boundBox.H:71
const point & max() const noexcept
Maximum describing the bounding box.
Definition boundBoxI.H:168
const point & min() const noexcept
Minimum describing the bounding box.
Definition boundBoxI.H:162
scalar magSqr() const
The magnitude/length squared of bounding box diagonal.
Definition boundBoxI.H:204
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
static void findNearest(const PtrList< searchableSurface > &, const labelList &surfacesToTest, const pointField &, const scalarField &nearestDistSqr, labelList &surfaces, List< pointIndexHit > &)
Find nearest. Return -1 (and a miss()) or surface and nearest.
static boundBox bounds(const PtrList< searchableSurface > &allSurfaces, const labelUList &surfacesToTest)
Find the boundBox of the selected surfaces.
Container for searchableSurfaces. The collection is specified as a dictionary. For example,...
label findSurfaceID(const word &name) const
Find index of surface. Return -1 if not found.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition className.H:142
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition error.H:629
auto & names
Namespace for OpenFOAM.
List< word > wordList
List of word.
Definition fileName.H:60
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition hashSets.C:40
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition hashSets.C:26
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
vector point
Point is a vector.
Definition point.H:37
vectorField pointField
pointField is a vectorField.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition errorManip.H:125
dictionary dict
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299
Unit conversion functions.