Line data Source code
1 : // *****************************************************************************
2 : /*!
3 : \file src/Transfer/NodeSearch.hpp
4 : \copyright 2020-2021 Charmworks, Inc.,
5 : 2022-2025 J. Bakosi
6 : All rights reserved. See the LICENSE file for details.
7 : \brief Declarations pertaining to node search between 3d meshes
8 : */
9 : // *****************************************************************************
10 : #pragma once
11 :
12 : #include "Fields.hpp"
13 : #include "NoWarning/nodesearch.decl.h"
14 :
15 : namespace transfer {
16 :
17 : //! ...
18 : class PotentialCollision {
19 : public:
20 : std::size_t src, dst;
21 : CkVector3d point;
22 0 : void pup( PUP::er& p ) {
23 0 : p | src;
24 0 : p | dst;
25 0 : p | point;
26 0 : }
27 : };
28 :
29 : //! Solution data interpolated from src to dst mesh
30 : class SolutionData {
31 : public:
32 : std::size_t dst;
33 : std::vector< double > sol;
34 0 : void pup( PUP::er& p ) {
35 0 : p | dst;
36 0 : p | sol;
37 0 : }
38 : };
39 :
40 : //! NodeSearch chare array holding part of a mesh
41 : class NodeSearch : public CBase_NodeSearch {
42 :
43 : public:
44 : //! Constructor
45 : explicit NodeSearch( CkArrayID p, MeshData mesh, CkCallback cb );
46 :
47 : #if defined(__clang__)
48 : #pragma clang diagnostic push
49 : #pragma clang diagnostic ignored "-Wundefined-func-template"
50 : #endif
51 : //! Migrate constructor
52 0 : explicit NodeSearch( CkMigrateMessage* m ) : CBase_NodeSearch( m ) {}
53 : #if defined(__clang__)
54 : #pragma clang diagnostic pop
55 : #endif
56 :
57 : //! Set the source mesh data
58 : void setSourceTets( const std::vector< std::size_t >& inpoel,
59 : const std::array< std::vector< double >, 3 >& coord,
60 : const tk::Fields& u,
61 : const std::vector< double >& flag,
62 : bool dir,
63 : CkCallback cb );
64 :
65 : //! Set the destination mesh data
66 : void setDestPoints( const std::array< std::vector< double >, 3 >& coord,
67 : tk::Fields& u,
68 : std::vector< double >& flag,
69 : bool trflag,
70 : bool dir,
71 : CkCallback cb );
72 :
73 : //! Process potential collisions in the destination mesh
74 : void processCollisions( const MeshData& src,
75 : int nColls,
76 : Collision* colls );
77 :
78 : //! Identify actual collisions in the source mesh
79 : void determineActualCollisions( CProxy_NodeSearch proxy,
80 : int index,
81 : int nColls,
82 : PotentialCollision* colls );
83 :
84 : //! Transfer the interpolated solution data to destination mesh
85 : void transferSolution( const std::vector< SolutionData >& sol );
86 :
87 : /** @name Charm++ pack/unpack serializer member functions */
88 : ///@{
89 : //! \brief Pack/Unpack serialize member function
90 : //! \param[in,out] p Charm++'s PUP::er serializer object reference
91 0 : void pup( PUP::er &p ) override {
92 0 : p | m_firstchunk;
93 0 : }
94 : //! \brief Pack/Unpack serialize operator|
95 : //! \param[in,out] p Charm++'s PUP::er serializer object reference
96 : //! \param[in,out] i NodeSearch object reference
97 : friend void operator|( PUP::er& p, NodeSearch& i ) { i.pup(p); }
98 : //@}
99 :
100 : private:
101 : //! The ID of my first chunk (used for collision detection library)
102 : int m_firstchunk;
103 : //! Pointer to element connectivity
104 : std::vector< std::size_t >* m_inpoel;
105 : //! Pointer to point coordinates
106 : std::array< std::vector< double >, 3 >* m_coord;
107 : //! Pointer to solution in mesh nodes
108 : tk::Fields* m_u;
109 : //! Pointer to transfer flags
110 : std::vector< double >* m_flag;
111 : //! Transfer flags if true
112 : bool m_trflag;
113 : //! Transfer direction: 0: background to overset, 1: overset to background
114 : bool m_dir;
115 : //! The number of messages sent by the dest mesh
116 : int m_numsent;
117 : //! The number of messages received by the dest mesh
118 : int m_numreceived;
119 : //! Set to nonzero once source mesh is notified that source side is done
120 : int m_srcnotified = 0;
121 : //! Callback to call when transfer is done
122 : CkCallback m_done;
123 :
124 : //! Initialize dest mesh solution with background data
125 : void background();
126 :
127 : //! Contribute vertex information to the collsion detection library
128 : void collideVertices();
129 :
130 : //! Contribute tet information to the collision detection library
131 : void collideTets() const;
132 : };
133 :
134 : } // transfer::
|