1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
// *****************************************************************************
/*!
  \file      src/Transfer/NodeSearch.hpp
  \copyright 2020-2021 Charmworks, Inc.,
             2022-2025 J. Bakosi
             All rights reserved. See the LICENSE file for details.
  \brief     Declarations pertaining to node search between 3d meshes
*/
// *****************************************************************************
#pragma once

#include "Fields.hpp"
#include "NoWarning/nodesearch.decl.h"

namespace transfer {

//! ...
class PotentialCollision {
  public:
    std::size_t src, dst;
    CkVector3d point;
    void pup( PUP::er& p ) {<--- Parameter 'p' can be declared as reference to const
      p | src;
      p | dst;
      p | point;
    }
};

//! Solution data interpolated from src to dst mesh
class SolutionData {
  public:
    std::size_t dst;
    std::vector< double > sol;
    void pup( PUP::er& p ) {<--- Parameter 'p' can be declared as reference to const
      p | dst;
      p | sol;
    }
};

//! NodeSearch chare array holding part of a mesh
class NodeSearch : public CBase_NodeSearch {

  public:
    //! Constructor
    explicit NodeSearch( CkArrayID p, MeshData mesh, CkCallback cb );

    #if defined(__clang__)
      #pragma clang diagnostic push
      #pragma clang diagnostic ignored "-Wundefined-func-template"
    #endif
    //! Migrate constructor
    explicit NodeSearch( CkMigrateMessage* m ) : CBase_NodeSearch( m ) {}<--- Member variable 'NodeSearch::m_firstchunk' is not initialized in the constructor.<--- Member variable 'NodeSearch::m_inpoel' is not initialized in the constructor.<--- Member variable 'NodeSearch::m_coord' is not initialized in the constructor.<--- Member variable 'NodeSearch::m_u' is not initialized in the constructor.<--- Member variable 'NodeSearch::m_flag' is not initialized in the constructor.<--- Member variable 'NodeSearch::m_trflag' is not initialized in the constructor.<--- Member variable 'NodeSearch::m_dir' is not initialized in the constructor.<--- Member variable 'NodeSearch::m_numsent' is not initialized in the constructor.<--- Member variable 'NodeSearch::m_numreceived' is not initialized in the constructor.
    #if defined(__clang__)
      #pragma clang diagnostic pop
    #endif

    //! Set the source mesh data
    void setSourceTets( const std::vector< std::size_t >& inpoel,
                        const std::array< std::vector< double >, 3 >& coord,
                        const tk::Fields& u,
                        const std::vector< double >& flag,
                        bool dir,
                        CkCallback cb );

    //! Set the destination mesh data
    void setDestPoints( const std::array< std::vector< double >, 3 >& coord,
                        tk::Fields& u,
                        std::vector< double >& flag,
                        bool trflag,
                        bool dir,
                        CkCallback cb );

    //! Process potential collisions in the destination mesh
    void processCollisions( const MeshData& src,
                            int nColls,
                            Collision* colls );

    //! Identify actual collisions in the source mesh
    void determineActualCollisions( CProxy_NodeSearch proxy,
                                    int index,
                                    int nColls,
                                    PotentialCollision* colls );

    //! Transfer the interpolated solution data to destination mesh
    void transferSolution( const std::vector< SolutionData >& sol );

    /** @name Charm++ pack/unpack serializer member functions */
    ///@{
    //! \brief Pack/Unpack serialize member function
    //! \param[in,out] p Charm++'s PUP::er serializer object reference
    void pup( PUP::er &p ) override {
      p | m_firstchunk;
    }
    //! \brief Pack/Unpack serialize operator|
    //! \param[in,out] p Charm++'s PUP::er serializer object reference
    //! \param[in,out] i NodeSearch object reference
    friend void operator|( PUP::er& p, NodeSearch& i ) { i.pup(p); }
    //@}

  private:
    //! The ID of my first chunk (used for collision detection library)
    int m_firstchunk;
    //! Pointer to element connectivity
    std::vector< std::size_t >* m_inpoel;
    //! Pointer to point coordinates
    std::array< std::vector< double >, 3 >* m_coord;
    //! Pointer to solution in mesh nodes
    tk::Fields* m_u;
    //! Pointer to transfer flags
    std::vector< double >* m_flag;
    //! Transfer flags if true
    bool m_trflag;
    //! Transfer direction: 0: background to overset, 1: overset to background
    bool m_dir;
    //! The number of messages sent by the dest mesh
    int m_numsent;
    //! The number of messages received by the dest mesh
    int m_numreceived;
    //! Set to nonzero once source mesh is notified that source side is done
    int m_srcnotified = 0;
    //! Callback to call when transfer is done
    CkCallback m_done;

    //! Initialize dest mesh solution with background data
    void background();

    //! Contribute vertex information to the collsion detection library
    void collideVertices();

    //! Contribute tet information to the collision detection library
    void collideTets() const;
};

} // transfer::