Branch data Line data Source code
1 : : // *****************************************************************************
2 : : /*!
3 : : \file src/Transfer/Transfer.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 transfer between 3D meshes
8 : : */
9 : : // *****************************************************************************
10 : :
11 : : #include "NoWarning/transfer.decl.h"
12 : : #include "NoWarning/collidecharm.h"
13 : : #include "Fields.hpp"
14 : :
15 : : namespace transfer {
16 : :
17 : : //! Single Charm++ chare used to initialize mesh-to-mesh transfer
18 : : class LibTransfer : public CBase_LibTransfer {
19 : : public:
20 : : //! Constructor: initialize mesh-to-mesh transfer
21 : : explicit LibTransfer( CkArgMsg* msg );
22 : : };
23 : :
24 : : //! Mesh configuration for a mesh involved in solution transfer
25 : : //! \details Lightweight data structure identifing a mesh
26 : : class MeshData {
27 : : public:
28 : : //! Host proxy of mesh
29 : : CProxy_NodeSearch proxy;
30 : : //! Starting chare ID of mesh partition
31 : : int firstchunk;
32 : : //! Number of mesh partitions
33 : : int nchare;
34 : : //! Pack/Unpack serialize member function
35 : : //! \param[in,out] p Charm++'s PUP::er serializer object reference
36 : 0 : void pup( PUP::er& p ) {
37 : 0 : p | proxy;
38 : 0 : p | firstchunk;
39 : 0 : p | nchare;
40 : 0 : }
41 : : };
42 : :
43 : : //! API for registering a mesh to be part of mesh-to-mesh transfer
44 : : void addMesh( CkArrayID p, int nchare, CkCallback cb );
45 : :
46 : : //! API for configuring source mesh
47 : : void setSourceTets( CkArrayID p,
48 : : int chare,
49 : : const std::vector< std::size_t >& inpoel,
50 : : const std::array< std::vector< double >, 3 >& coord,
51 : : const tk::Fields& u,
52 : : const std::vector< double >& flag,
53 : : bool dir,
54 : : CkCallback cb );
55 : :
56 : : //! API for configuring destination mesh
57 : : void setDestPoints( CkArrayID p,
58 : : int chare,
59 : : const std::array< std::vector< double >, 3 >& coord,
60 : : tk::Fields& u,
61 : : std::vector< double >& flag,
62 : : bool trflag,
63 : : bool dir,
64 : : CkCallback cb );
65 : :
66 : : //! ...
67 : : class Transfer : public CBase_Transfer {
68 : :
69 : : public:
70 : : //! Constructor
71 : 774 : explicit Transfer() = default;
72 : :
73 : : #if defined(__clang__)
74 : : #pragma clang diagnostic push
75 : : #pragma clang diagnostic ignored "-Wundefined-func-template"
76 : : #endif
77 : : //! ...
78 : 30 : explicit Transfer( CkMigrateMessage* m ) : CBase_Transfer( m ) {}
79 : : #if defined(__clang__)
80 : : #pragma clang diagnostic pop
81 : : #endif
82 : :
83 : : //! Register a mesh to be part of mesh-to-mesh transfer
84 : : void addMesh( CkArrayID p, int nchare, CkCallback cb );
85 : :
86 : : //! ...
87 : : void setMesh( CkArrayID p, const MeshData& d );
88 : :
89 : : //! Configure source mesh
90 : : void setSourceTets( CkArrayID p,
91 : : int chare,
92 : : const std::vector< std::size_t >& inpoel,
93 : : const std::array< std::vector< double >, 3 >& coord,
94 : : const tk::Fields& u,
95 : : const std::vector< double >& flag,
96 : : bool dir,
97 : : CkCallback cb );
98 : :
99 : : //! Configure destination mesh
100 : : void setDestPoints( CkArrayID p,
101 : : int chare,
102 : : const std::array< std::vector< double >, 3 >& coord,
103 : : tk::Fields& u,
104 : : std::vector< double >& flag,
105 : : bool trflag,
106 : : bool dir,
107 : : CkCallback cb );
108 : :
109 : : //! ...
110 : : void distributeCollisions( int nColl, Collision* colls );
111 : :
112 : : private:
113 : : //! Mesh configuration for each mesh involved in solution transfer
114 : : std::unordered_map< CmiUInt8, MeshData > m_proxyMap;
115 : : //! ...
116 : : int m_current_chunk = 0;
117 : : //! Source mesh id
118 : : CmiUInt8 m_src;
119 : : //! Destination mesh id
120 : : CmiUInt8 m_dst;
121 : : };
122 : :
123 : : } // transfer::
|