7#include <arcane/geometry/euclidian/Euclidian3Geometry.h>
12#include <arcane/utils/FatalErrorException.h>
13#include <arcane/utils/NotImplementedException.h>
18namespace Arcane::Numerics
27 Real3 orientation, center;
30 switch (item.
type()) {
32 ComputeLine2(
this).computeOrientedMeasureAndCenter(item, orientation, center);
35 ComputeTriangle3(
this).computeOrientedMeasureAndCenter(item, orientation, center);
38 ComputeQuad4(
this).computeOrientedMeasureAndCenter(item, orientation, center);
41 ComputePentagon5(
this).computeOrientedMeasureAndCenter(item, orientation, center);
44 ComputeHexagon6(
this).computeOrientedMeasureAndCenter(item, orientation, center);
50 ComputePyramid5(
this).computeOrientedMeasureAndCenter(item, measure, center);
53 ComputePentaedron6(
this).computeOrientedMeasureAndCenter(item, measure, center);
56 ComputeHexaedron8(
this).computeOrientedMeasureAndCenter(item, measure, center);
72 Real3 orientation, center;
74 switch (item.
type()) {
76 ComputeLine2(
this).computeOrientedMeasureAndCenter(item, orientation, center);
79 ComputeTriangle3(
this).computeOrientedMeasureAndCenter(item, orientation, center);
82 ComputeQuad4(
this).computeOrientedMeasureAndCenter(item, orientation, center);
85 ComputePentagon5(
this).computeOrientedMeasureAndCenter(item, orientation, center);
88 ComputeHexagon6(
this).computeOrientedMeasureAndCenter(item, orientation, center);
92 return Real3(0, 0, measure);
94 ComputePyramid5(
this).computeOrientedMeasureAndCenter(item, measure, center);
95 return Real3(0, 0, measure);
97 ComputePentaedron6(
this).computeOrientedMeasureAndCenter(item, measure, center);
98 return Real3(0, 0, measure);
100 ComputeHexaedron8(
this).computeOrientedMeasureAndCenter(item, measure, center);
101 return Real3(0, 0, measure);
102 case IT_Heptaedron10:
104 return Real3(0, 0, measure);
107 return Real3(0, 0, measure);
116 Real3 orientation, center;
119 switch (item.
type()) {
121 ComputeLine2(
this).computeOrientedMeasureAndCenter(item, orientation, center);
124 ComputeTriangle3(
this).computeOrientedMeasureAndCenter(item, orientation, center);
127 ComputeQuad4(
this).computeOrientedMeasureAndCenter(item, orientation, center);
130 ComputePentagon5(
this).computeOrientedMeasureAndCenter(item, orientation, center);
133 ComputeHexagon6(
this).computeOrientedMeasureAndCenter(item, orientation, center);
139 ComputePyramid5(
this).computeOrientedMeasureAndCenter(item, measure, center);
142 ComputePentaedron6(
this).computeOrientedMeasureAndCenter(item, measure, center);
145 ComputeHexaedron8(
this).computeOrientedMeasureAndCenter(item, measure, center);
147 case IT_Heptaedron10:
168 Real3 orientation, center;
170 switch (item.
type()) {
174 ComputeTriangle3(
this).computeOrientedMeasureAndCenter(item, orientation, center);
177 ComputeQuad4(
this).computeOrientedMeasureAndCenter(item, orientation, center);
180 ComputePentagon5(
this).computeOrientedMeasureAndCenter(item, orientation, center);
183 ComputeHexagon6(
this).computeOrientedMeasureAndCenter(item, orientation, center);
189 case IT_Heptaedron10:
194 case IT_AntiWedgeLeft6:
195 case IT_AntiWedgeRight6:
209 switch (item.
type()) {
222 ComputePyramid5(
this).computeOrientedMeasureAndCenter(item, measure, center);
225 ComputePentaedron6(
this).computeOrientedMeasureAndCenter(item, measure, center);
228 ComputeHexaedron8(
this).computeOrientedMeasureAndCenter(item, measure, center);
230 case IT_Heptaedron10:
237 ComputeHemiHexa7(
this).computeOrientedMeasureAndCenter(item, measure, center);
240 ComputeHemiHexa6(
this).computeOrientedMeasureAndCenter(item, measure, center);
243 ComputeHemiHexa5(
this).computeOrientedMeasureAndCenter(item, measure, center);
245 case IT_AntiWedgeLeft6:
246 ComputeAntiWedgeLeft6(
this).computeOrientedMeasureAndCenter(item, measure, center);
248 case IT_AntiWedgeRight6:
249 ComputeAntiWedgeRight6(
this).computeOrientedMeasureAndCenter(item, measure, center);
252 ComputeDiTetra5(
this).computeOrientedMeasureAndCenter(item, measure, center);
263 return computeTriangleCenter(coords[0], coords[1], coords[2]);
265 Real3 center(0, 0, 0);
267 for (
Integer i = 1; i < n - 1; ++i) {
268 Real local_area =
math::normeR3(computeTriangleNormal(coords[0], coords[i], coords[i + 1]));
269 center += local_area * computeTriangleCenter(coords[0], coords[i], coords[i + 1]);
272 return center / area;
278 Real3 normal(0., 0., 0.);
279 for (
Integer i = 1; i < n - 1; ++i)
280 normal += computeTriangleNormal(coords[0], coords[i], coords[i + 1]);
287 const Real3 d = m - n;
293void Euclidian3Geometry::ComputeLine2::
296 orientation = m_coords[item.
node(1)] - m_coords[item.
node(0)];
297 center = 0.5 * (m_coords[item.
node(1)] + m_coords[item.
node(0)]);
300void Euclidian3Geometry::ComputeTriangle3::
304 computeTriangleNormal(m_coords[item.
node(0)],
305 m_coords[item.
node(1)],
306 m_coords[item.
node(2)]);
309 computeTriangleCenter(m_coords[item.
node(0)],
310 m_coords[item.
node(1)],
311 m_coords[item.
node(2)]);
314void Euclidian3Geometry::ComputeQuad4::
318 computeTriangleNormal(m_coords[item.
node(0)],
319 m_coords[item.
node(1)],
320 m_coords[item.
node(2)]) +
321 computeTriangleNormal(m_coords[item.
node(0)],
322 m_coords[item.
node(2)],
323 m_coords[item.
node(3)]);
326 computeQuadrilateralCenter(m_coords[item.
node(0)],
327 m_coords[item.
node(1)],
328 m_coords[item.
node(2)],
329 m_coords[item.
node(3)]);
332void Euclidian3Geometry::ComputePentagon5::
333computeOrientedMeasureAndCenter(
const ItemWithNodes& item, Real3& orientation, Real3& center)
336 computeTriangleNormal(m_coords[item.
node(0)],
337 m_coords[item.
node(1)],
338 m_coords[item.
node(2)]) +
339 computeTriangleNormal(m_coords[item.
node(0)],
340 m_coords[item.
node(2)],
341 m_coords[item.
node(3)]) +
342 computeTriangleNormal(m_coords[item.
node(0)],
343 m_coords[item.
node(3)],
344 m_coords[item.
node(4)]);
347 computePentagonalCenter(m_coords[item.
node(0)],
348 m_coords[item.
node(1)],
349 m_coords[item.
node(2)],
350 m_coords[item.
node(3)],
351 m_coords[item.
node(4)]);
354void Euclidian3Geometry::ComputeHexagon6::
355computeOrientedMeasureAndCenter(
const ItemWithNodes& item, Real3& orientation, Real3& center)
358 computeTriangleNormal(m_coords[item.
node(0)],
359 m_coords[item.
node(1)],
360 m_coords[item.
node(2)]) +
361 computeTriangleNormal(m_coords[item.
node(0)],
362 m_coords[item.
node(2)],
363 m_coords[item.
node(3)]) +
364 computeTriangleNormal(m_coords[item.
node(0)],
365 m_coords[item.
node(3)],
366 m_coords[item.
node(4)]) +
367 computeTriangleNormal(m_coords[item.
node(0)],
368 m_coords[item.
node(4)],
369 m_coords[item.
node(5)]);
372 computeHexagonalCenter(m_coords[item.
node(0)],
373 m_coords[item.
node(1)],
374 m_coords[item.
node(2)],
375 m_coords[item.
node(3)],
376 m_coords[item.
node(4)],
377 m_coords[item.
node(5)]);
380void Euclidian3Geometry::ComputeTetraedron4::
381computeOrientedMeasureAndCenter(
const ItemWithNodes& item,
Real& measure, Real3& center)
383 ARCANE_ASSERT((item.
type() == IT_Tetraedron4), (
"Bad item type: %d vs %d (Tetra4)", item.
type(), IT_Tetraedron4));
384 measure = computeTetraedronVolume(m_coords[item.
node(0)],
385 m_coords[item.
node(1)],
386 m_coords[item.
node(2)],
387 m_coords[item.
node(3)]);
388 center = computeTetraedronCenter(m_coords[item.
node(0)],
389 m_coords[item.
node(1)],
390 m_coords[item.
node(2)],
391 m_coords[item.
node(3)]);
394void Euclidian3Geometry::ComputeTetraedron4::
395computeVolumeArea(
const ItemWithNodes& item,
Real& area)
397 ARCANE_ASSERT((item.
type() == IT_Tetraedron4), (
"Bad item type: %d vs %d (Tetra4)", item.
type(), IT_Tetraedron4));
399 for (
Integer i = 0; i < 4; ++i) {
400 const Face face = cell.
face(i);
401 area += math::abs(computeTriangleSurface(m_coords[face.
node(0)],
402 m_coords[face.
node(1)],
403 m_coords[face.
node(2)]));
409void Euclidian3Geometry::ComputeGenericVolume::
410computeOrientedMeasureAndCenter(
const ItemWithNodes& item,
Real& measure, Real3& center)
413 Real3 vcenter(0, 0, 0);
415 vcenter += m_coords[item.
node(i)];
420 center = Real3(0, 0, 0);
425 const Face face = cell.
face(i);
426 const Real orientation = (face.
frontCell() == cell) ? 1 : -1;
429 Real v = orientation * computeTetraedronVolume(m_coords[face.
node(0)], m_coords[face.
node(1)], m_coords[face.
node(2)], vcenter);
430 center += v * computeTetraedronCenter(m_coords[face.
node(0)], m_coords[face.
node(1)], m_coords[face.
node(2)], vcenter);
433 else if (face.
nbNode() == 4) {
435 const Real3 coords[5] = { m_coords[face.
node(0)],
436 m_coords[face.
node(1)],
437 m_coords[face.
node(2)],
438 m_coords[face.
node(3)],
439 m_coords[face.
node(0)] };
440 const Real3 fcenter = computeQuadrilateralCenter(coords[0], coords[1], coords[2], coords[3]);
441 for (
Integer j = 0; j < 4; ++j) {
442 const Real v = orientation * computeTetraedronVolume(coords[j], coords[j + 1], fcenter, vcenter);
443 center += v * computeTetraedronCenter(coords[j], coords[j + 1], fcenter, vcenter);
448 throw NotImplementedException(A_FUNCINFO,
"Not implemented for face with more than 4 nodes");
458void Euclidian3Geometry::ComputeGenericVolume::
459computeVolumeArea(
const ItemWithNodes& item,
Real& area)
463 const Face face = cell.
face(i);
465 area += math::abs(computeTriangleSurface(m_coords[face.
node(0)],
466 m_coords[face.
node(1)],
467 m_coords[face.
node(2)]));
469 else if (face.
nbNode() == 4) {
470 area += math::abs(computeTriangleSurface(m_coords[item.
node(0)],
471 m_coords[item.
node(1)],
472 m_coords[item.
node(2)])) +
473 math::abs(computeTriangleSurface(m_coords[item.
node(0)],
474 m_coords[item.
node(3)],
475 m_coords[item.
node(3)]));
478 throw NotImplementedException(A_FUNCINFO,
"Not implemented for face with more than 4 nodes");
#define ARCANE_THROW(exception_class,...)
Macro for throwing an exception with formatting.
Face face(Int32 i) const
i-th face of the cell
Int32 nbFace() const
Number of faces of the cell.
Cell frontCell() const
Cell in front of the face (null cell if none).
Exception when a fatal error has occurred.
Mesh element based on nodes (Edge,Face,Cell).
Node node(Int32 i) const
i-th node of the entity
Int32 nbNode() const
Number of nodes of the entity.
Cell toCell() const
Converts the entity to the Cell kind.
Int16 type() const
Entity type.
Exception when a function is not implemented.
Exception when an operation is not supported.
Real3 computeCenter(const ItemWithNodes &item)
Calculation of the center of mass.
Real computeVolume(const ItemWithNodes &item)
Calculation of the volume.
Real3 computeSurfaceCenter(Integer n, const Real3 *coords)
Calculation of the center.
Real3 computeOrientedArea(Integer n, const Real3 *coords)
Calculation of the oriented area (i.e., normal).
Real3 computeOrientedMeasure(const ItemWithNodes &item)
Calculation of the oriented measure.
Real computeArea(const ItemWithNodes &item)
Calculation of the area.
Real computeLength(const ItemWithNodes &item)
Calculation of the length.
Real computeMeasure(const ItemWithNodes &item)
Calculation of the measure (without orientation).
Class managing a 3-dimensional real vector.
__host__ __device__ Real scaMul(Real2 u, Real2 v)
Dot product of u by v in .
__host__ __device__ double sqrt(double v)
Square root of v.
Real normeR3(Real3 v1)
Norm of a vector.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Int32 Integer
Type representing an integer.
double Real
Type representing a real number.
@ Cell
The mesh is AMR by cell.