-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathline_kernel.cpp
More file actions
275 lines (235 loc) · 7.71 KB
/
line_kernel.cpp
File metadata and controls
275 lines (235 loc) · 7.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
/*---------------------------------------------------------------------------*\
*
* bitpit
*
* Copyright (C) 2015-2021 OPTIMAD engineering Srl
*
* -------------------------------------------------------------------------
* License
* This file is part of bitpit.
*
* bitpit is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License v3 (LGPL)
* as published by the Free Software Foundation.
*
* bitpit is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with bitpit. If not, see <http://www.gnu.org/licenses/>.
*
\*---------------------------------------------------------------------------*/
#include "line_kernel.hpp"
namespace bitpit {
#if BITPIT_ENABLE_MPI==1
/*!
Creates a patch.
If a null comunicator is provided, a serial patch will be created, this
means that each processor will be unaware of the existence of the other
processes.
\param communicator is the communicator to be used for exchanging data
among the processes. If a null comunicator is provided, a serial patch
will be created
\param haloSize is the size, expressed in number of layers, of the ghost
cells halo
\param adaptionMode is the adaption mode that will be used for the patch
\param partitioningMode is the partitioning mode that will be used for the
patch
*/
LineKernel::LineKernel(MPI_Comm communicator, std::size_t haloSize,
AdaptionMode adaptionMode, PartitioningMode partitioningMode)
: PatchKernel(communicator, haloSize, adaptionMode, partitioningMode)
#else
/*!
Creates a patch.
\param adaptionMode is the adaption mode that will be used for the patch
*/
LineKernel::LineKernel(AdaptionMode adaptionMode)
: PatchKernel(adaptionMode)
#endif
{
initialize();
}
#if BITPIT_ENABLE_MPI==1
/*!
Creates a patch.
If a null comunicator is provided, a serial patch will be created, this
means that each processor will be unaware of the existence of the other
processes.
\param dimension is the dimension of the patch
\param communicator is the communicator to be used for exchanging data
among the processes. If a null comunicator is provided, a serial patch
will be created
\param haloSize is the size, expressed in number of layers, of the ghost
cells halo
\param adaptionMode is the adaption mode that will be used for the patch
\param partitioningMode is the partitioning mode that will be used for the
patch
*/
LineKernel::LineKernel(int dimension, MPI_Comm communicator, std::size_t haloSize,
AdaptionMode adaptionMode, PartitioningMode partitioningMode)
: PatchKernel(dimension, communicator, haloSize, adaptionMode, partitioningMode)
#else
/*!
Creates a patch.
\param dimension is the dimension of the patch
\param adaptionMode is the adaption mode that will be used for the patch
*/
LineKernel::LineKernel(int dimension, AdaptionMode adaptionMode)
: PatchKernel(dimension, adaptionMode)
#endif
{
initialize();
}
#if BITPIT_ENABLE_MPI==1
/*!
Creates a patch.
If a null comunicator is provided, a serial patch will be created, this
means that each processor will be unaware of the existence of the other
processes.
\param id is the id that will be assigned to the patch
\param dimension is the dimension of the patch
\param communicator is the communicator to be used for exchanging data
among the processes. If a null comunicator is provided, a serial patch
will be created
\param haloSize is the size, expressed in number of layers, of the ghost
cells halo
\param adaptionMode is the adaption mode that will be used for the patch
\param partitioningMode is the partitioning mode that will be used for the
patch
*/
LineKernel::LineKernel(int id, int dimension, MPI_Comm communicator, std::size_t haloSize,
AdaptionMode adaptionMode, PartitioningMode partitioningMode)
: PatchKernel(id, dimension, communicator, haloSize, adaptionMode, partitioningMode)
#else
/*!
Creates a patch.
\param id is the id that will be assigned to the patch
\param dimension is the dimension of the patch
\param adaptionMode is the adaption mode that will be used for the patch
*/
LineKernel::LineKernel(int id, int dimension, AdaptionMode adaptionMode)
: PatchKernel(id, dimension, adaptionMode)
#endif
{
}
/*!
Initialize the patch
*/
void LineKernel::initialize()
{
// Nothing to do
}
/*!
Get the codimension of the patch in the volume space.
\result The codimension of the patch in the volume space.
*/
int LineKernel::getVolumeCodimension() const
{
return 2;
}
/*!
Get the codimension of the patch in the surface space.
\result The codimension of the patch in the surface space.
*/
int LineKernel::getSurfaceCodimension() const
{
return 1;
}
/*!
Get the codimension of the patch in the line space.
\result The codimension of the patch in the line space.
*/
int LineKernel::getLineCodimension() const
{
return 0;
}
/*!
Get the codimension of the patch in the point space.
\result The codimension of the patch in the point space.
*/
int LineKernel::getPointCodimension() const
{
return -1;
}
/*!
Extracts the external envelope and appends it to the given patch.
The external envelope is composed by all the free faces of the patch.
\param[in,out] envelope is the patch to which the external envelope
will be appended
*/
void LineKernel::extractEnvelope(PointKernel &envelope) const
{
PatchKernel::extractEnvelope(envelope);
}
/*!
* Evaluates the characteristic size of the specified cell.
*
* \param id is the id of the cell
* \result The characteristic size of the specified cell.
*/
double LineKernel::evalCellSize(long id) const
{
return evalCellLength(id);
}
/*!
* Evaluate the length of the specified cell.
*
* If cell is of type ElementType::VERTEX, the function returns 0.0
*
* \param id is the id of the cell
* \result The length of the specified cell.
*/
double LineKernel::evalCellLength(long id) const
{
const Cell &cell = m_cells[id];
switch (cell.getType()) {
case ElementType::LINE:
{
ConstProxyVector<long> cellVertexIds = cell.getVertexIds();
const Vertex &vertex_0 = getVertex(cellVertexIds[0]);
const Vertex &vertex_1 = getVertex(cellVertexIds[1]);
double length = norm2(vertex_1.getCoords() - vertex_0.getCoords());
return length;
}
default:
{
return 0.;
}
}
}
/*!
* Evaluate the normal of the specified cell.
*
* If cell is of type ElementType::VERTEX or ElementType::LINE, returns 0.0
*
* \param id is the id of the cell
* \param orientation is a vector carring the additional information needed
* to un-ambigously define a normal to the element (e.g., when evaluating
* the normal of a one-dimensional element, this versor is perpendicular to
* the plane where the normal should lie)
* \result The normal of the specified cell.
*/
std::array<double, 3> LineKernel::evalCellNormal(long id, const std::array<double, 3> &orientation) const
{
const Cell &cell = m_cells[id];
switch (cell.getType()) {
case ElementType::LINE:
{
ConstProxyVector<long> cellVertexIds = cell.getVertexIds();
const Vertex &vertex_0 = getVertex(cellVertexIds[0]);
const Vertex &vertex_1 = getVertex(cellVertexIds[1]);
std::array<double, 3> normal = vertex_1.getCoords() - vertex_0.getCoords();
normal = crossProduct(normal, orientation);
normal = normal / norm2(normal);
return normal;
}
default:
{
return {{0., 0., 0.}};
}
}
}
}