surfaceLocation.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) 2011-2016 OpenFOAM Foundation
9 Copyright (C) 2020 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 "surfaceLocation.H"
30#include "triSurface.H"
31
32// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
33
35{
36 const vectorField& n = s.faceNormals();
37
38 if (elementType_ == triPointRef::NONE)
39 {
40 return n[index()];
41 }
42 else if (elementType_ == triPointRef::EDGE)
43 {
44 const labelList& eFaces = s.edgeFaces()[index()];
45
46 if (eFaces.size() == 1)
47 {
48 return n[eFaces[0]];
49 }
50 else
51 {
52 // Average edge normal
53 vector edgeNormal(Zero);
54
55 for (const label facei : eFaces)
56 {
57 edgeNormal += n[facei];
58 }
59
60 return edgeNormal/(mag(edgeNormal) + VSMALL);
61 }
62 }
63 else // triPointRef::POINT
64 {
65 return s.pointNormals()[index()];
66 }
67}
68
69
70// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
71
73{
74 if (elementType_ == triPointRef::NONE)
75 {
76 os << "trianglecoords:" << s[index()].tri(s.points());
77 }
78 else if (elementType() == triPointRef::EDGE)
79 {
80 const edge& e = s.edges()[index()];
81
82 os << "edgecoords:" << e.line(s.localPoints());
83 }
84 else // triPointRef::POINT
85 {
86 os << "pointcoord:" << s.localPoints()[index()];
87 }
88}
89
90
92{
93 label elType;
94 is >> static_cast<pointIndexHit&>(sl)
95 >> elType >> sl.triangle_;
96
97 sl.elementType_ = triPointRef::proxType(elType);
98 return is;
99}
100
101
103{
104 return os
105 << static_cast<const pointIndexHit&>(sl)
106 << token::SPACE << label(sl.elementType_)
107 << token::SPACE << sl.triangle_;
108}
109
110
111Foam::Ostream& Foam::operator<<
112(
113 Ostream& os,
115)
116{
117 const surfaceLocation& sl = ip.t_;
118
119 os << "coord:" << sl.point();
120
121 if (sl.elementType() == triPointRef::NONE)
122 {
123 os << " inside triangle:";
124 }
125 else if (sl.elementType() == triPointRef::EDGE)
126 {
127 os << " on edge:";
128 }
129 else // triPointRef::POINT
130 {
131 os << " on point:";
132 }
133
134 os << sl.index()
135 << " excludeTriangle:" << sl.triangle();
136
137 if (sl.hit())
138 {
139 os << " (hit)";
140 }
141 else
142 {
143 os << " (miss)";
144 }
145
146 return os;
147}
148
149
150// ************************************************************************* //
label n
A helper class for outputting values to Ostream.
Definition: InfoProxy.H:52
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
Definition: PointIndexHit.H:66
label index() const noexcept
Return the hit index.
bool hit() const noexcept
Is there a hit?
const point_type & point() const noexcept
Return point, no checks.
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
Particle-size distribution model wherein random samples are drawn from the doubly-truncated univariat...
Definition: normal.H:251
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Definition: edge.H:66
virtual bool write()
Write the output fields.
Contains information about location on a triSurface.
triPointRef::proxType & elementType() noexcept
label & triangle() noexcept
@ SPACE
Space [isspace].
Definition: token.H:125
Triangulated surface description with patch information.
Definition: triSurface.H:79
proxType
The proximity classifications.
Definition: triangle.H:94
@ EDGE
Close to edge.
Definition: triangle.H:97
@ NONE
Unknown proximity.
Definition: triangle.H:95
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))
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Istream & operator>>(Istream &, directionInfo &)
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
volScalarField & e
Definition: createFields.H:11