1 // Copyright (c) 2017-2021, Lawrence Livermore National Security, LLC and
2 // other Axom Project Developers. See the top-level LICENSE file for details.
3 //
4 // SPDX-License-Identifier: (BSD-3-Clause)
5 #ifndef MINT_MESH_HELPERS_HPP_
6 #define MINT_MESH_HELPERS_HPP_
7
8 #include "axom/core/Macros.hpp" // for AXOM_UNUSED_PARAM
9 #include "axom/core/Types.hpp" // for nullptr
10 #include "axom/mint/config.hpp" // for mint compile-time type
11 #include "axom/mint/mesh/CellTypes.hpp" // for CellType
12
13 #include <string>
14
15 namespace axom
16 {
17 namespace mint
18 {
19 class Mesh; // forward declaration
20
21 namespace internal
22 {
dim(const double * AXOM_UNUSED_PARAM (x),const double * y,const double * z)23 inline int dim(const double* AXOM_UNUSED_PARAM(x), const double* y, const double* z)
24 {
25 return ((z != nullptr) ? 3 : ((y != nullptr) ? 2 : 1));
26 }
27
28 std::string join_ints_into_string(int vcount, IndexType* values, char sep);
29
30 std::string make_face_key(int vcount, IndexType* values, char sep);
31
32 /*! \brief Record a Mesh's face-to-cell, cell-to-face, and face-to-node
33 * relations.
34 *
35 * \param [in] m pointer to a Mesh.
36 * \param [out] facecount the number of unique faces of m's cells.
37 * \param [out] f2c the relation between face f and its two incident cells
38 * with cellIDs at f2c[2*f] and f2c[2*f+1].
39 * \param [out] c2f the relation between cell c and its n faces with faceIDs
40 * stored contiguously starting at c2f[c2foffsets[c]].
41 * \param [out] c2n the relation between cell c and its n neighbors with
42 * cellIDs stored contiguously starting at c2n[c2foffsets[c]].
43 * \param [out] c2foffsets the offset in c2f of the first face of each cell.
44 * \param [out] f2n the relation between face f and its nodes stored
45 * contiguously starting at f2n[f2noffsets[f]].
46 * \param [out] f2noffsets the offset in f2n of the first node of each face.
47 * \param [out] f2ntypes the CellType of each face.
48 *
49 * \returns success true if each face has one or two incident cells.
50 *
51 * \note The seven output arrays f2c, c2f, c2n, c2foffsets, f2n, f2noffsets,
52 * and f2ntypes are allocated in this routine if the routine is successful.
53 * It is the caller's responsibility to free this memory. If the routine
54 * returns false, the output arrays are set to nullptr and facecount is set
55 * to 0.
56 *
57 * This routine visits each of the cells of the mesh. For each cell face, it
58 * retrieves the face's nodes and joins the sorted node IDs to make a unique
59 * hash key. The incident cells are recorded in a list for each face's hash
60 * key. The final face-cell and cell-face relations are constructed from this
61 * data structure.
62 *
63 * This routine is intended to be used in constructing an UnstructuredMesh's
64 * face relations, though it will give correct results for any Mesh.
65 */
66 bool initFaces(Mesh* m,
67 IndexType& facecount,
68 IndexType*& f2c,
69 IndexType*& c2f,
70 IndexType*& c2n,
71 IndexType*& c2foffsets,
72 IndexType*& f2n,
73 IndexType*& f2noffsets,
74 CellType*& f2ntypes);
75
76 } /* namespace internal */
77 } /* namespace mint */
78 } /* namespace axom */
79
80 #endif /* MINT_MESH_HELPERS_HPP_ */
81