Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
GeometryKernelSurfaceInternalUtils.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7#ifndef ARCGEOSIM_SURFACEUTILS_GEOMETRYKERNELSURFACETOOLS_GEOMETRYKERNELSURFACEINTERNALUTILS_H
8#define ARCGEOSIM_SURFACEUTILS_GEOMETRYKERNELSURFACETOOLS_GEOMETRYKERNELSURFACEINTERNALUTILS_H
9/* Author : havep at Wed Apr 1 14:31:35 2009
10 * Generated by createNew
11 */
12
13#include "arcane/utils/Array.h"
14#include "arcane/utils/Real3.h"
15
16#include "arcane/core/Item.h"
17#include "arcane/core/VariableTypes.h"
18#include "arcane/core/ItemGroup.h"
19#include "arcane/core/IMeshSubMeshTransition.h"
20
21#include <GeometryKernel/datamodel/micro/surface/triangulation-data-structure.h>
22#include <GeometryKernel/datamodel/geometry/vector.h>
23
24#include <map>
25
26/*---------------------------------------------------------------------------*/
27/*---------------------------------------------------------------------------*/
28
29namespace Arcane::Numerics
30{
31using namespace Arcane;
32
33/*---------------------------------------------------------------------------*/
34/*---------------------------------------------------------------------------*/
35
37void buildFaceGroupSurface(FaceGroup group,
38 GeometryKernel::TriangulationDataStructurePtr m_triangulation,
39 Array<Node>& m_node_array,
40 Array<Face>& m_face_array,
41 Array<bool>& m_face_reorient,
42 Real3& m_mean_normal);
44void saveSurface(const char* filename, GeometryKernel::TriangulationDataStructure& tr);
46void loadSurface(const char* filename, GeometryKernel::TriangulationDataStructure& tr);
48inline Real3 convertGKVector(const GeometryKernel::Vector& v)
49{
50 return Real3(v.getX(), v.getY(), v.getZ());
51}
52inline GeometryKernel::Vector convertGKVector(const Real3& v)
53{
54 return GeometryKernel::Vector(v.x, v.y, v.z);
55}
56
57/*---------------------------------------------------------------------------*/
58/*---------------------------------------------------------------------------*/
59
60class NodeMapping
61{
62 public:
63
64 NodeMapping(IMesh* mesh,
65 Array<Node>& node_array,
66 GeometryKernel::TriangulationDataStructure& triangulation)
67 : m_nodes_coordinates(PRIMARYMESH_CAST(mesh)->nodesCoordinates())
68 , m_node_array(node_array)
69 , m_triangulation(triangulation)
70 {
71 ;
72 }
73
74 GeometryKernel::TObjectId getNodeId(const Node node)
75 {
76 const Integer inode = node.localId();
77 std::pair<KnownNodes::iterator, bool> inserter = m_known_nodes.insert(KnownNodes::value_type(inode, NULL_ID));
78 if (inserter.second) { // New value
79 const Real3 coords = m_nodes_coordinates[node];
80 const GeometryKernel::TObjectId new_id = m_triangulation.newVertex(GeometryKernel::Vector(coords.x, coords.y, coords.z));
81 ARCANE_ASSERT(((Integer)m_node_array.size() == (Integer)new_id), ("Non-synchronized GeometryKernel with internal SurfaceImpl [%d vs %d]", new_id, m_node_array.size()));
82 m_node_array.add(node);
83 return (inserter.first->second = new_id);
84 }
85 else { // Already existing value
86 return inserter.first->second;
87 }
88 }
89
90 Real3 computeNormal(const Node node1, const Node node2, const Node node3)
91 {
92 const Real3 node1_coord = m_nodes_coordinates[node1];
93 const Real3 node2_coord = m_nodes_coordinates[node2];
94 const Real3 node3_coord = m_nodes_coordinates[node3];
95 return math::vecMul(node2_coord - node1_coord, node3_coord - node1_coord);
96 }
97
98 private:
99
100 const VariableNodeReal3& m_nodes_coordinates;
101 Array<Node>& m_node_array;
102 GeometryKernel::TriangulationDataStructure& m_triangulation;
103
104 typedef std::map<Integer, GeometryKernel::TObjectId> KnownNodes;
105 KnownNodes m_known_nodes;
106};
107
108/*---------------------------------------------------------------------------*/
109/*---------------------------------------------------------------------------*/
110
111} // namespace Arcane::Numerics
112
113/*---------------------------------------------------------------------------*/
114/*---------------------------------------------------------------------------*/
115
116#endif
Base class for 1D data vectors.
constexpr Int32 localId() const
Local identifier of the entity in the processor subdomain.
Definition Item.h:233
Node of a mesh.
Definition Item.h:598
Class managing a 3-dimensional real vector.
Definition Real3.h:132
__host__ __device__ Real3 vecMul(Real3 u, Real3 v)
Vector cross product of u by v in .
Definition MathUtils.h:48
ItemGroupT< Face > FaceGroup
Group of faces.
Definition ItemTypes.h:179
MeshVariableScalarRefT< Node, Real3 > VariableNodeReal3
Coordinate type quantity at node.
Int32 Integer
Type representing an integer.
Real y
second component of the triplet
Definition Real3.h:36
Real z
third component of the triplet
Definition Real3.h:37
Real x
first component of the triplet
Definition Real3.h:35