triSurfaceCurvatureEstimator.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | cfMesh: A library for mesh generation
4  \\ / O peration |
5  \\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
6  \\/ M anipulation | Copyright (C) Creative Fields, Ltd.
7 -------------------------------------------------------------------------------
8 License
9  This file is part of cfMesh.
10 
11  cfMesh is free software; you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by the
13  Free Software Foundation; either version 3 of the License, or (at your
14  option) any later version.
15 
16  cfMesh is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with cfMesh. If not, see <http://www.gnu.org/licenses/>.
23 
24 Description
25 
26 \*---------------------------------------------------------------------------*/
27 
29 #include "demandDrivenData.H"
30 
31 //#define DEBUGMorph
32 
33 # ifdef DEBUGMorph
34 #include <sstream>
35 # endif
36 
37 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 
39 namespace Foam
40 {
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
45 (
46  const triSurf& surface
47 )
48 :
49  surface_(surface),
50  edgePointCurvature_(),
51  patchPositions_(),
52  gaussianCurvature_(),
53  meanCurvature_(),
54  maxCurvature_(),
55  minCurvature_(),
56  maxCurvatureVector_(),
57  minCurvatureVector_()
58 {
59  calculateEdgeCurvature();
60  calculateSurfaceCurvatures();
61  //calculateGaussianCurvature();
62  //calculateMeanCurvature();
63  //calculateMinAndMaxCurvature();
64 }
65 
67 {}
68 
69 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
70 
72 {
73  return edgePointCurvature_[pI];
74 }
75 
77 {
78  const edge& edg = surface_.edges()[edgeI];
79 
80  const scalar k1 = edgePointCurvature_[edg.start()];
81  const scalar k2 = edgePointCurvature_[edg.end()];
82 
83  return (k1 + k2) / 2.0;
84 }
85 
87 (
88  const label triI
89 ) const
90 {
91  const labelledTri& tri = surface_[triI];
92 
93  scalar curv(0.0);
94  for(label i=0;i<3;++i)
95  curv += gaussianCurvature_[tri[i]][patchPositions_(triI, i)];
96  curv /= 3.0;
97 
98  return curv;
99 }
100 
102 (
103  const label triI
104 ) const
105 {
106  const labelledTri& tri = surface_[triI];
107 
108  scalar curv(0.0);
109  for(label i=0;i<3;++i)
110  curv += meanCurvature_[tri[i]][patchPositions_(triI, i)];
111  curv /= 3.0;
112 
113  return curv;
114 }
115 
117 (
118  const label triI
119 ) const
120 {
121  const labelledTri& tri = surface_[triI];
122 
123  scalar curv(0.0);
124  for(label i=0;i<3;++i)
125  curv += maxCurvature_[tri[i]][patchPositions_(triI, i)];
126  curv /= 3.0;
127 
128  return curv;
129 }
130 
132 (
133  const label triI
134 ) const
135 {
136  const labelledTri& tri = surface_[triI];
137 
138  scalar curv(0.0);
139  for(label i=0;i<3;++i)
140  curv += minCurvature_[tri[i]][patchPositions_(triI, i)];
141  curv /= 3.0;
142 
143  return curv;
144 }
145 
147 (
148  const label triI
149 ) const
150 {
151  const labelledTri& tri = surface_[triI];
152 
153  vector curv(vector::zero);
154  for(label i=0;i<3;++i)
155  curv += maxCurvatureVector_[tri[i]][patchPositions_(triI, i)];
156  curv /= 3.0;
157 
158  return curv;
159 }
160 
162 (
163  const label triI
164 ) const
165 {
166  const labelledTri& tri = surface_[triI];
167 
168  vector curv(vector::zero);
169  for(label i=0;i<3;++i)
170  curv += minCurvatureVector_[tri[i]][patchPositions_(triI, i)];
171  curv /= 3.0;
172 
173  return curv;
174 }
175 
176 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
177 
178 } // End namespace Foam
179 
180 // ************************************************************************* //
Foam::triSurfaceCurvatureEstimator::minCurvatureAtTriangle
scalar minCurvatureAtTriangle(const label) const
Definition: triSurfaceCurvatureEstimator.C:132
Foam::triSurfaceCurvatureEstimator::edgePointCurvature
scalar edgePointCurvature(const label) const
return curvature of points at feature edges
Definition: triSurfaceCurvatureEstimator.C:71
Foam::Vector< scalar >::zero
static const Vector zero
Definition: Vector.H:80
Foam::triSurfaceCurvatureEstimator::minCurvatureVectorAtTriangle
vector minCurvatureVectorAtTriangle(const label) const
Definition: triSurfaceCurvatureEstimator.C:162
Foam::triSurfaceCurvatureEstimator::gaussianCurvatureAtTriangle
scalar gaussianCurvatureAtTriangle(const label) const
return average curvature on a surface triangle
Definition: triSurfaceCurvatureEstimator.C:87
demandDrivenData.H
Template functions to aid in the implementation of demand driven data.
Foam::edge
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Definition: edge.H:58
triSurfaceCurvatureEstimator.H
Foam::edge::end
label end() const
Return end vertex label.
Definition: edgeI.H:92
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Foam::triSurfaceCurvatureEstimator::meanCurvatureAtTriangle
scalar meanCurvatureAtTriangle(const label) const
Definition: triSurfaceCurvatureEstimator.C:102
Foam::triSurfaceCurvatureEstimator::surface_
const triSurf & surface_
reference to triSurface
Definition: triSurfaceCurvatureEstimator.H:55
Foam::triSurfaceCurvatureEstimator::~triSurfaceCurvatureEstimator
~triSurfaceCurvatureEstimator()
Definition: triSurfaceCurvatureEstimator.C:66
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::edge::start
label start() const
Return start vertex label.
Definition: edgeI.H:81
Foam::Vector< scalar >
Foam::surface
Definition: surface.H:55
Foam::triSurfAddressing::edges
const LongList< edge > & edges() const
return edges
Definition: triSurfAddressingI.H:61
Foam::triSurfaceCurvatureEstimator::curvatureAtEdge
scalar curvatureAtEdge(const label) const
Definition: triSurfaceCurvatureEstimator.C:76
Foam::triSurfaceCurvatureEstimator::triSurfaceCurvatureEstimator
triSurfaceCurvatureEstimator(const triSurfaceCurvatureEstimator &)
Disallow default bitwise copy construct.
Foam::triSurfaceCurvatureEstimator::maxCurvatureAtTriangle
scalar maxCurvatureAtTriangle(const label) const
Definition: triSurfaceCurvatureEstimator.C:117
Foam::labelledTri
Triangle with additional region number.
Definition: labelledTri.H:49
Foam::triSurfaceCurvatureEstimator::maxCurvatureVectorAtTriangle
vector maxCurvatureVectorAtTriangle(const label) const
Definition: triSurfaceCurvatureEstimator.C:147
Foam::triSurf
Definition: triSurf.H:59
Foam::triSurfaceCurvatureEstimator::edgePointCurvature_
scalarField edgePointCurvature_
curvature of points at feature edges
Definition: triSurfaceCurvatureEstimator.H:58