Quinoa all test code coverage report
Current view: top level - Inciter - Discretization.hpp (source / functions) Hit Total Coverage
Commit: -128-NOTFOUND Lines: 85 86 98.8 %
Date: 2024-04-22 13:03:21 Functions: 7 7 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 34 58 58.6 %

           Branch data     Line data    Source code
       1                 :            : // *****************************************************************************
       2                 :            : /*!
       3                 :            :   \file      src/Inciter/Discretization.hpp
       4                 :            :   \copyright 2012-2015 J. Bakosi,
       5                 :            :              2016-2018 Los Alamos National Security, LLC.,
       6                 :            :              2019-2021 Triad National Security, LLC.
       7                 :            :              All rights reserved. See the LICENSE file for details.
       8                 :            :   \details   Data and functionality common to all discretization schemes
       9                 :            :      The Discretization class contains data and functionality common to all
      10                 :            :      discretization schemes.
      11                 :            : */
      12                 :            : // *****************************************************************************
      13                 :            : #ifndef Discretization_h
      14                 :            : #define Discretization_h
      15                 :            : 
      16                 :            : #include <brigand/algorithms/for_each.hpp>
      17                 :            : 
      18                 :            : #include "Types.hpp"
      19                 :            : #include "Timer.hpp"
      20                 :            : #include "Fields.hpp"
      21                 :            : #include "PUPUtil.hpp"
      22                 :            : #include "PDFReducer.hpp"
      23                 :            : #include "UnsMesh.hpp"
      24                 :            : #include "CommMap.hpp"
      25                 :            : #include "History.hpp"
      26                 :            : #include "Inciter/InputDeck/InputDeck.hpp"
      27                 :            : 
      28                 :            : #include "NoWarning/discretization.decl.h"
      29                 :            : #include "NoWarning/refiner.decl.h"
      30                 :            : 
      31                 :            : namespace inciter {
      32                 :            : 
      33                 :            : extern ctr::InputDeck g_inputdeck;
      34                 :            : 
      35                 :            : //! \brief Discretization Charm++ chare array holding common functinoality to
      36                 :            : //!   all discretization schemes
      37                 :            : class Discretization : public CBase_Discretization {
      38                 :            : 
      39                 :            :   public:
      40                 :            :     #if defined(__clang__)
      41                 :            :       #pragma clang diagnostic push
      42                 :            :       #pragma clang diagnostic ignored "-Wunused-parameter"
      43                 :            :       #pragma clang diagnostic ignored "-Wdeprecated-declarations"
      44                 :            :     #elif defined(STRICT_GNUC)
      45                 :            :       #pragma GCC diagnostic push
      46                 :            :       #pragma GCC diagnostic ignored "-Wunused-parameter"
      47                 :            :       #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
      48                 :            :     #elif defined(__INTEL_COMPILER)
      49                 :            :       #pragma warning( push )
      50                 :            :       #pragma warning( disable: 1478 )
      51                 :            :     #endif
      52                 :            :     // Include Charm++ SDAG code. See http://charm.cs.illinois.edu/manuals/html/
      53                 :            :     // charm++/manual.html, Sec. "Structured Control Flow: Structured Dagger".
      54                 :            :     Discretization_SDAG_CODE
      55                 :            :     #if defined(__clang__)
      56                 :            :       #pragma clang diagnostic pop
      57                 :            :     #elif defined(STRICT_GNUC)
      58                 :            :       #pragma GCC diagnostic pop
      59                 :            :     #elif defined(__INTEL_COMPILER)
      60                 :            :       #pragma warning( pop )
      61                 :            :     #endif
      62                 :            : 
      63                 :            :     //! Constructor
      64                 :            :     explicit
      65                 :            :       Discretization(
      66                 :            :         std::size_t meshid,
      67                 :            :         const std::vector< CProxy_Discretization >& disc,
      68                 :            :         const CProxy_ALE& aleproxy,
      69                 :            :         const tk::CProxy_ConjugateGradients& conjugategradientsproxy,
      70                 :            :         const CProxy_Transporter& transporter,
      71                 :            :         const tk::CProxy_MeshWriter& meshwriter,
      72                 :            :         const tk::UnsMesh::CoordMap& coordmap,
      73                 :            :         const tk::UnsMesh::Chunk& el,
      74                 :            :         const tk::CommMaps& msum,
      75                 :            :         const std::map< int, std::vector< std::size_t > >& bface,
      76                 :            :         const std::vector< std::size_t >& triinpoel,
      77                 :            :         const std::unordered_map< std::size_t, std::set< std::size_t > >&
      78                 :            :           elemblockid,
      79                 :            :         int nc );
      80                 :            : 
      81                 :            :     #if defined(__clang__)
      82                 :            :       #pragma clang diagnostic push
      83                 :            :       #pragma clang diagnostic ignored "-Wundefined-func-template"
      84                 :            :     #endif
      85                 :            :     //! Migrate constructor
      86                 :            :     // cppcheck-suppress uninitMemberVar
      87                 :      15696 :     explicit Discretization( CkMigrateMessage* ) {}
      88                 :            :     #if defined(__clang__)
      89                 :            :       #pragma clang diagnostic pop
      90                 :            :     #endif
      91                 :            : 
      92                 :            :     //! Configure Charm++ reduction types
      93                 :            :     static void registerReducers();
      94                 :            : 
      95                 :            :     //! Start computing new mesh veloctity for ALE mesh motion
      96                 :            :     void meshvelStart(
      97                 :            :       const tk::UnsMesh::Coords vel,
      98                 :            :       const std::vector< tk::real >& soundspeed,
      99                 :            :       const std::unordered_map< int,
     100                 :            :         std::unordered_map< std::size_t, std::array< tk::real, 4 > > >& bnorm,
     101                 :            :       tk::real adt,
     102                 :            :       CkCallback done ) const;
     103                 :            : 
     104                 :            :     //! Query the mesh velocity
     105                 :            :     const tk::Fields& meshvel() const;
     106                 :            : 
     107                 :            :    //! \brief Query ALE mesh velocity boundary condition node lists and node
     108                 :            :    //!   lists at which ALE moves boundaries
     109                 :            :    void meshvelBnd(
     110                 :            :      const std::map< int, std::vector< std::size_t > >& bface,
     111                 :            :      const std::map< int, std::vector< std::size_t > >& bnode,
     112                 :            :      const std::vector< std::size_t >& triinpoel ) const;
     113                 :            : 
     114                 :            :     //! Assess and record mesh velocity linear solver convergence
     115                 :            :     void meshvelConv();
     116                 :            : 
     117                 :            :     //! \brief Our mesh has been registered with the mesh-to-mesh transfer
     118                 :            :     //!   library (if coupled to other solver)
     119                 :            :     void transferInit();
     120                 :            : 
     121                 :            :     //! Finish setting up communication maps and solution transfer callbacks
     122                 :            :     void comfinal();
     123                 :            : 
     124                 :            :     //! Start solution transfer (if coupled)
     125                 :            :     void transfer(
     126                 :            :       tk::Fields& u,
     127                 :            :       std::size_t dirn,
     128                 :            :       CkCallback cb );
     129                 :            : 
     130                 :            :     //! Solution transfer from background to overset mesh completed (from ExaM2M)
     131                 :            :     void to_complete();
     132                 :            : 
     133                 :            :     //! Solution transfer from overset to background mesh completed (from ExaM2M)
     134                 :            :     void from_complete();
     135                 :            : 
     136                 :            :     //! Solution transfer completed (from dest Discretization)
     137                 :            :     void transfer_complete_from_dest();
     138                 :            : 
     139                 :            :     //! Solution transfer completed (one-way)
     140                 :            :     void transfer_complete();
     141                 :            : 
     142                 :            :     //! Resize mesh data structures after mesh refinement
     143                 :            :     void resizePostAMR(
     144                 :            :       const tk::UnsMesh::Chunk& chunk,
     145                 :            :       const tk::UnsMesh::Coords& coord,
     146                 :            :       const std::unordered_map< std::size_t, std::size_t >& amrNodeMap,
     147                 :            :       const tk::NodeCommMap& nodeCommMap,
     148                 :            :       const std::set< std::size_t >& removedNodes,
     149                 :            :       const std::unordered_map< std::size_t, std::set< std::size_t > >&
     150                 :            :         elemblockid );
     151                 :            : 
     152                 :            :     //! Get ready for (re-)computing/communicating nodal volumes
     153                 :            :     void startvol();
     154                 :            : 
     155                 :            :     //! Sum mesh volumes to nodes, start communicating them on chare-boundaries
     156                 :            :     void vol();
     157                 :            : 
     158                 :            :     //! Set Refiner Charm++ proxy
     159                 :            :     void setRefiner( const CProxy_Refiner& ref );
     160                 :            : 
     161                 :            :     //! Collect nodal volumes across chare boundaries
     162                 :            :     void comvol( const std::vector< std::size_t >& gid,
     163                 :            :                  const std::vector< tk::real >& nodevol );
     164                 :            : 
     165                 :            :     //! Sum mesh volumes and contribute own mesh volume to total volume
     166                 :            :     void totalvol();
     167                 :            : 
     168                 :            :     //! Compute mesh cell statistics
     169                 :            :     void stat( tk::real mesh_volume );
     170                 :            : 
     171                 :            :     //! Compute total box IC volume
     172                 :            :     void
     173                 :            :     boxvol( const std::vector< std::unordered_set< std::size_t > >& nodes,
     174                 :            :       const std::unordered_map< std::size_t, std::set< std::size_t > >& nodeblk,
     175                 :            :       std::size_t nuserblk );
     176                 :            : 
     177                 :            :     /** @name Accessors */
     178                 :            :     ///@{
     179                 :            :     //! Coordinates accessor as const-ref
     180                 :            :     const tk::UnsMesh::Coords& Coord() const { return m_coord; }
     181                 :            :     //! Coordinates accessor as reference
     182 [ +  + ][ -  - ]:      79373 :     tk::UnsMesh::Coords& Coord() { return m_coord; }
     183                 :            :     //! Coordinates at time n accessor as const-ref
     184                 :            :     const tk::UnsMesh::Coords& Coordn() const { return m_coordn; }
     185                 :            : 
     186                 :            :     //! Global ids accessors as const-ref
     187                 :            :     const std::vector< std::size_t >& Gid() const { return m_gid; }
     188                 :            : 
     189                 :            :     //! Local ids accessors as const-ref
     190                 :            :      const std::unordered_map< std::size_t, std::size_t >& Lid() const
     191                 :            :     { return m_lid; }
     192                 :            : 
     193                 :            :     //! Tetrahedron element connectivity (with local ids) accessors as const-ref
     194                 :            :     const std::vector< std::size_t >& Inpoel() const { return m_inpoel; }
     195                 :            : 
     196                 :            :     //! Mesh chunk accessor as const-ref
     197         [ +  - ]:       2169 :     const tk::UnsMesh::Chunk& Chunk() const { return m_el; }
     198                 :            : 
     199                 :            :     //! Mesh block id accessor as const-ref
     200                 :            :     const std::unordered_map< std::size_t, std::set< std::size_t > >&
     201                 :       3612 :       ElemBlockId() const { return m_elemblockid; }
     202                 :            : 
     203                 :            :     //! Total mesh volume accessor
     204                 :            :     tk::real meshvol() const { return m_meshvol; }
     205                 :            : 
     206                 :            :     //! Nodal mesh volume accessors const-ref
     207                 :            :     const std::vector< tk::real >& V() const { return m_v; }
     208                 :            : 
     209                 :            :     //! Nodal mesh volumes at current time step accessors as const-ref
     210 [ +  - ][ +  - ]:     364671 :     const std::vector< tk::real >& Vol() const { return m_vol; }
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
     211                 :            :     //! Nodal mesh volumes at previous time step accessors as const-ref
     212                 :            :     const std::vector< tk::real >& Voln() const { return m_voln; }
     213                 :            :     //! Nodal mesh volumes at previous time step accessors as ref
     214                 :      38179 :     std::vector< tk::real >& Voln() { return m_voln; }
     215                 :            :     //! Element mesh volumes at t=t0 accessors as const-ref
     216                 :            :     const std::vector< tk::real >& Vol0() const { return m_vol0; }
     217                 :            :     //! Element mesh velocity accessor as const-ref
     218                 :            :     const tk::Fields& MeshVel() const { return m_meshvel; }
     219                 :            :     //! Element mesh velocity accessor as ref
     220                 :      13584 :     tk::Fields& MeshVel() { return m_meshvel; }
     221                 :            : 
     222                 :            :     //! Set 'initial' flag
     223                 :            :     //! \param[in] i Value to put in 'initial'
     224                 :        844 :     void Initial( std::size_t i ) { m_initial = i; }
     225                 :            :     //! Query 'initial' flag
     226                 :            :     //! \return True during setup, false durign time stepping
     227                 :            :     bool Initial() const { return m_initial; }
     228                 :            : 
     229                 :            :     //! Update coordinates at time n
     230                 :            :     void UpdateCoordn() { m_coordn = m_coord; }
     231                 :            : 
     232                 :            :     //! History points data accessor as const-ref
     233         [ +  - ]:        254 :     const std::vector< HistData >& Hist() const { return m_histdata; }
     234                 :            : 
     235                 :            :     //! Box volume accessor
     236                 :            :     tk::real& Boxvol() { return m_boxvol; }
     237                 :            : 
     238                 :            :     //! Block volume accessor
     239                 :        844 :     std::vector< tk::real >& MeshBlkVol() { return m_meshblkvol; }
     240                 :            : 
     241                 :            :     //! Mesh ID accessor
     242                 :            :     std::size_t MeshId() const { return m_meshid; }
     243                 :            : 
     244                 :            :     //! Time step size accessor
     245                 :            :     tk::real Dt() const { return m_dt; }
     246                 :            :     //! Time step size at previous time step accessor
     247                 :            :     tk::real Dtn() const { return m_dtn; }
     248                 :            :     //! Physical time accessor
     249                 :            :     tk::real T() const { return m_t; }
     250                 :            :     //! Iteration count accessor
     251                 :            :     uint64_t It() const { return m_it; }
     252                 :            : 
     253                 :            :     //! Non-const-ref refinement iteration count accessor
     254                 :            :     uint64_t& Itr() { return m_itr; }
     255                 :            :     //! Non-const-ref field-output iteration count accessor
     256                 :            :     uint64_t& Itf() { return m_itf; }
     257                 :            : 
     258                 :            :     //! Non-const-ref number of restarts accessor
     259                 :            :     int& Nrestart() { return m_nrestart; }
     260                 :            : 
     261                 :            :     //! Timer accessor as const-ref
     262                 :            :     const tk::Timer& Timer() const { return m_timer; }
     263                 :            :     //! Timer accessor as non-const-ref
     264                 :       1994 :     tk::Timer& Timer() { return m_timer; }
     265                 :            : 
     266                 :            :     //! Accessor to flag indicating if the mesh was refined as a value
     267                 :            :     int refined() const { return m_refined; }
     268                 :            :     //! Accessor to flag indicating if the mesh was refined as non-const-ref
     269                 :            :     int& refined() { return m_refined; }
     270                 :            : 
     271                 :            :     //! Transporter proxy accessor as const-ref
     272                 :            :     const CProxy_Transporter& Tr() const { return m_transporter; }
     273                 :            :     //! Transporter proxy accessor as non-const-ref
     274         [ -  - ]:          0 :     CProxy_Transporter& Tr() { return m_transporter; }
     275                 :            : 
     276                 :            :     //! Access bound Refiner class pointer
     277                 :         33 :     Refiner* Ref() const {
     278                 :            :       Assert( m_refiner[ thisIndex ].ckLocal() != nullptr,
     279                 :            :               "Refiner ckLocal() null" );
     280                 :         66 :       return m_refiner[ thisIndex ].ckLocal();
     281                 :            :     }
     282                 :            : 
     283                 :            :     //! Access Discretization proxy for a mesh
     284                 :            :     CProxy_Discretization coupled( std::size_t meshid ) const {
     285                 :            :       Assert( meshid < m_disc.size(),
     286                 :            :               "No proxy for mesh ID " + std::to_string(meshid) );
     287                 :            :       return m_disc[ meshid ];
     288                 :            :     }
     289                 :            : 
     290                 :            :     //! Const-ref accessor to solver/mesh transfer configuration
     291                 :            :     const std::vector< Transfer >& Transfers() const { return m_transfer; }
     292                 :            : 
     293                 :            :     //! Boundary node ids accessor as const-ref
     294                 :            :     const std::unordered_map< std::size_t, std::size_t >& Bid() const
     295                 :     151314 :     { return m_bid; }
     296                 :            : 
     297                 :            :     //! Node communication map accessor as const-ref
     298         [ +  - ]:       2169 :     const tk::NodeCommMap& NodeCommMap() const { return m_nodeCommMap; }
     299                 :            : 
     300                 :            :     //! Edge communication map accessor as const-ref
     301                 :            :     const tk::EdgeCommMap& EdgeCommMap() const { return m_edgeCommMap; }
     302                 :            :     //@}
     303                 :            : 
     304                 :            :     //! Set time step size
     305                 :            :     void setdt( tk::real newdt );
     306                 :            : 
     307                 :            :     //! Prepare for next step
     308                 :            :     void next();
     309                 :            : 
     310                 :            :     //! Otput one-liner status report
     311                 :            :     void status();
     312                 :            : 
     313                 :            :     //! Construct history output filename
     314                 :            :     std::string histfilename( const std::string& id,
     315                 :            :                               std::streamsize precision );
     316                 :            : 
     317                 :            :     //! Output headers for time history files (one for each point)
     318                 :            :     void histheader( std::vector< std::string >&& names );
     319                 :            : 
     320                 :            :     //! Output time history for a time step
     321                 :            :     void history( std::vector< std::vector< tk::real > >&& data );
     322                 :            : 
     323                 :            :     //! Output mesh and fields data (solution dump) to file(s)
     324                 :            :     void write( const std::vector< std::size_t >& inpoel,
     325                 :            :                 const tk::UnsMesh::Coords& coord,
     326                 :            :                 const std::map< int, std::vector< std::size_t > >& bface,
     327                 :            :                 const std::map< int, std::vector< std::size_t > >& bnode,
     328                 :            :                 const std::vector< std::size_t >& triinpoel,
     329                 :            :                 const std::vector< std::string>& elemfieldnames,
     330                 :            :                 const std::vector< std::string>& nodefieldnames,
     331                 :            :                 const std::vector< std::string>& elemsurfnames,
     332                 :            :                 const std::vector< std::string>& nodesurfnames,
     333                 :            :                 const std::vector< std::vector< tk::real > >& elemfields,
     334                 :            :                 const std::vector< std::vector< tk::real > >& nodefields,
     335                 :            :                 const std::vector< std::vector< tk::real > >& elemsurfs,
     336                 :            :                 const std::vector< std::vector< tk::real > >& nodesurfs,
     337                 :            :                 CkCallback c );
     338                 :            : 
     339                 :            :     //! Zero grind-timer
     340                 :            :     void grindZero();
     341                 :            : 
     342                 :            :     //! Detect if just returned from a checkpoint and if so, zero timers
     343                 :            :     bool restarted( int nrestart );
     344                 :            : 
     345                 :            :     //! Remap mesh data due to new local ids
     346                 :            :     void remap( const std::unordered_map< std::size_t, std::size_t >& map );
     347                 :            : 
     348                 :            :     //! \brief Function object for querying the node ids that belong to side
     349                 :            :     //!   sets of the same type, called for each PDE type
     350                 :            :     template< typename... tags >
     351                 :            :     struct SidesetNodes {
     352                 :            : 
     353                 :            :       const std::map< int, std::vector< std::size_t > >& m_bface;
     354                 :            :       const std::vector< std::size_t >& m_triinpoel;
     355                 :            :       std::unordered_map< int, std::unordered_set< std::size_t > >& m_nodes;
     356                 :            :       std::size_t m_mid;
     357                 :            : 
     358                 :            :       explicit
     359                 :      92746 :         SidesetNodes( const std::map< int, std::vector< std::size_t > >& bface,
     360                 :            :                       const std::vector< std::size_t >& triinpoel,
     361                 :            :                       std::unordered_map< int,
     362                 :            :                         std::unordered_set< std::size_t > >& nodes,
     363                 :            :                       std::size_t mid )
     364                 :      92746 :         : m_bface(bface), m_triinpoel(triinpoel), m_nodes(nodes), m_mid(mid)
     365                 :            :       {
     366                 :            :         const auto& bc =
     367                 :            :           g_inputdeck.template get< tag::bc >();
     368                 :            :         std::vector< std::size_t > ss;
     369         [ +  + ]:     186460 :         for (const auto& bci : bc) {
     370                 :            :           const auto& bcm = bci.get< tag::mesh >();
     371         [ +  + ]:     167038 :           for (const auto& im : bcm) {
     372                 :            :             // only if this bc is meant for current mesh
     373                 :            :             // collect sidesets for this mesh with this bc type
     374         [ +  + ]:      73324 :             if (im-1 == m_mid) {
     375 [ +  - ][ -  - ]:      72356 :               ss.insert( ss.end(), bci.template get< tags... >().begin(),
     376                 :            :                 bci.template get< tags... >().end() );
     377                 :            :             }
     378                 :            :           }
     379                 :            :         }
     380         [ +  + ]:     119632 :         for (const auto& s : ss) {
     381                 :      26886 :           auto k = m_bface.find(static_cast<int>(s));
     382         [ +  + ]:      26886 :           if (k != end(m_bface)) {
     383         [ +  - ]:      20608 :             auto& n = m_nodes[ k->first ];  // associate set id
     384         [ +  + ]:    5082076 :             for (auto f : k->second) {      // face ids on side set
     385         [ +  - ]:    5061468 :               n.insert( m_triinpoel[f*3+0] );
     386         [ +  - ]:    5061468 :               n.insert( m_triinpoel[f*3+1] );
     387         [ +  - ]:    5061468 :               n.insert( m_triinpoel[f*3+2] );
     388                 :            :             }
     389                 :            :           }
     390                 :            :         }
     391                 :      92746 :       }
     392                 :            :     };
     393                 :            : 
     394                 :            :     //! \brief Query nodes that belong to side sets of the same type for all
     395                 :            :     //!   PDE types
     396                 :            :     //! \tparam tags Tags addressing the location of a vector of vectors of
     397                 :            :     //!   side set ids in the input deck
     398                 :            :     //! \param[in] bface Boundary-faces mapped to side set ids
     399                 :            :     //! \param[in] triinpoel Boundary-face connectivity
     400                 :            :     //! \return Node ids that belong side sets of the same type (value),
     401                 :            :     //!    associated to sides set id (key)
     402                 :            :     template< typename... tags >
     403                 :            :     std::unordered_map< int, std::unordered_set< std::size_t > >
     404         [ +  - ]:      92746 :     bcnodes( const std::map< int, std::vector< std::size_t > >& bface,
     405                 :            :              const std::vector< std::size_t >& triinpoel ) const
     406                 :            :     {
     407                 :            :       std::unordered_map< int, std::unordered_set< std::size_t > > nodes;
     408         [ +  - ]:      92746 :       SidesetNodes< tags... >( bface, triinpoel, nodes, this->MeshId() );
     409                 :      92746 :       return nodes;
     410                 :            :     }
     411                 :            : 
     412                 :            :     //! Find elements along our mesh chunk boundary
     413                 :            :     std::vector< std::size_t > bndel() const;
     414                 :            : 
     415                 :            :     //! Decide if field output iteration count interval is hit
     416                 :            :     bool fielditer() const;
     417                 :            : 
     418                 :            :     //! Decide if field output physics time interval is hit
     419                 :            :     bool fieldtime() const;
     420                 :            : 
     421                 :            :     //! Decide if physics time falls into a field output time range
     422                 :            :     bool fieldrange() const;
     423                 :            : 
     424                 :            :     //! Decide if history output iteration count interval is hit
     425                 :            :     bool histiter() const;
     426                 :            : 
     427                 :            :     //! Decide if history output physics time interval is hit
     428                 :            :     bool histtime() const;
     429                 :            : 
     430                 :            :     //! Decide if physics time falls into a history output time range
     431                 :            :     bool histrange() const;
     432                 :            : 
     433                 :            :     //! Decide if this is the last time step
     434                 :            :     bool finished() const;
     435                 :            : 
     436                 :            :     /** @name Charm++ pack/unpack serializer member functions */
     437                 :            :     ///@{
     438                 :            :     //! \brief Pack/Unpack serialize member function
     439                 :            :     //! \param[in,out] p Charm++'s PUP::er serializer object reference
     440                 :      24365 :     void pup( PUP::er &p ) override {
     441                 :      24365 :       p | m_meshid;
     442                 :      24365 :       p | m_transfer_complete;
     443                 :      24365 :       p | m_transfer;
     444                 :      24365 :       p | m_mytransfer;
     445                 :      24365 :       p | m_disc;
     446                 :      24365 :       p | m_nchare;
     447                 :      24365 :       p | m_it;
     448                 :      24365 :       p | m_itr;
     449                 :      24365 :       p | m_itf;
     450                 :      24365 :       p | m_initial;
     451                 :      24365 :       p | m_t;
     452                 :      24365 :       p | m_lastDumpTime;
     453                 :      24365 :       p | m_physFieldFloor;
     454                 :      24365 :       p | m_physHistFloor;
     455                 :      24365 :       p | m_rangeFieldFloor;
     456                 :      24365 :       p | m_rangeHistFloor;
     457                 :      24365 :       p | m_dt;
     458                 :      24365 :       p | m_dtn;
     459                 :      24365 :       p | m_nvol;
     460                 :      24365 :       p | m_nxfer;
     461                 :      24365 :       p | m_ale;
     462                 :      24365 :       p | m_transporter;
     463                 :      24365 :       p | m_meshwriter;
     464                 :      24365 :       p | m_refiner;
     465                 :      24365 :       p | m_el;
     466         [ +  + ]:      24365 :       if (p.isUnpacking()) {
     467                 :       7848 :         m_inpoel = std::get< 0 >( m_el );
     468                 :       7848 :         m_gid = std::get< 1 >( m_el );
     469         [ -  + ]:       7848 :         m_lid = std::get< 2 >( m_el );
     470                 :            :       }
     471                 :            :       p | m_coord;
     472                 :            :       p | m_coordn;
     473                 :            :       p | m_nodeCommMap;
     474                 :      24365 :       p | m_edgeCommMap;
     475                 :      24365 :       p | m_meshvol;
     476                 :      24365 :       p | m_v;
     477                 :      24365 :       p | m_vol;
     478                 :      24365 :       p | m_volc;
     479                 :      24365 :       p | m_voln;
     480                 :      24365 :       p | m_vol0;
     481                 :      24365 :       p | m_boxvol;
     482                 :      24365 :       p | m_meshblkvol;
     483                 :      24365 :       p | m_bid;
     484                 :            :       p | m_timer;
     485                 :      24365 :       p | m_refined;
     486                 :      24365 :       p( reinterpret_cast<char*>(&m_prevstatus), sizeof(Clock::time_point) );
     487                 :      24365 :       p | m_nrestart;
     488                 :      24365 :       p | m_histdata;
     489                 :      24365 :       p | m_nsrc;
     490                 :      24365 :       p | m_ndst;
     491                 :      24365 :       p | m_meshvel;
     492                 :      24365 :       p | m_meshvel_converged;
     493                 :      24365 :       p | m_bface;
     494                 :      24365 :       p | m_triinpoel;
     495                 :      24365 :       p | m_elemblockid;
     496                 :      24365 :     }
     497                 :            :     //! \brief Pack/Unpack serialize operator|
     498                 :            :     //! \param[in,out] p Charm++'s PUP::er serializer object reference
     499                 :            :     //! \param[in,out] i Discretization object reference
     500                 :            :     friend void operator|( PUP::er& p, Discretization& i ) { i.pup(p); }
     501                 :            :     //@}
     502                 :            : 
     503                 :            :   private:
     504                 :            :     // Shorthand for clock, setting an internal clock type
     505                 :            :     using Clock = std::chrono::high_resolution_clock;
     506                 :            : 
     507                 :            :     //! Mesh ID
     508                 :            :     std::size_t m_meshid;
     509                 :            :     //! \brief Charm++ callback of the function to call after a mesh-to-mesh
     510                 :            :     //!   solution transfer (to-and-fro) is complete
     511                 :            :     CkCallback m_transfer_complete;
     512                 :            :     //! Solution/mesh transfer (coupling) information coordination propagation
     513                 :            :     //! \details This has the same size with the same src/dst information on
     514                 :            :     //!   all solvers.
     515                 :            :     std::vector< Transfer > m_transfer;
     516                 :            :     //! My solution transfer/mesh (coupling) information
     517                 :            :     //! \details This is a subset of m_transfer, holding only those entries
     518                 :            :     //!   that this solver is involved in (either a source or a destination).
     519                 :            :     std::vector< Transfer > m_mytransfer;
     520                 :            :     //! Discretization proxies (one per mesh)
     521                 :            :     std::vector< CProxy_Discretization > m_disc;
     522                 :            :     //! Total number of Discretization chares
     523                 :            :     int m_nchare;
     524                 :            :     //! Iteration count
     525                 :            :     uint64_t m_it;
     526                 :            :     //! Iteration count with mesh refinement
     527                 :            :     //! \details Used as the restart sequence number {RS} in saving output in
     528                 :            :     //!    an ExodusII sequence
     529                 :            :     //! \see https://www.paraview.org/Wiki/Restarted_Simulation_Readers
     530                 :            :     uint64_t m_itr;
     531                 :            :     //! Field output iteration count without mesh refinement
     532                 :            :     //! \details Counts the number of field outputs to file during two
     533                 :            :     //!   time steps with mesh efinement
     534                 :            :     uint64_t m_itf;
     535                 :            :     //! Flag that is nonzero during setup and zero during time stepping
     536                 :            :     std::size_t m_initial;
     537                 :            :     //! Physical time
     538                 :            :     tk::real m_t;
     539                 :            :     //! Physics time at last field output
     540                 :            :     tk::real m_lastDumpTime;
     541                 :            :     //! Recent floor of physics time divided by field output interval time
     542                 :            :     tk::real m_physFieldFloor;
     543                 :            :     //! Recent floor of physics time divided by history output interval time
     544                 :            :     tk::real m_physHistFloor;
     545                 :            :     //! Recent floors of physics time divided by field output time for ranges
     546                 :            :     tk::real m_rangeFieldFloor;
     547                 :            :     //! Recent floors of physics time divided by history output time for ranges
     548                 :            :     tk::real m_rangeHistFloor;
     549                 :            :     //! Physical time step size
     550                 :            :     tk::real m_dt;
     551                 :            :     //! Physical time step size at the previous time step
     552                 :            :     tk::real m_dtn;
     553                 :            :     //! \brief Number of chares from which we received nodal volume
     554                 :            :     //!   contributions on chare boundaries
     555                 :            :     std::size_t m_nvol;
     556                 :            :     //! \brief Number of chares from which we received solution transfers
     557                 :            :     //!   contributions on chare boundaries
     558                 :            :     std::size_t m_nxfer;
     559                 :            :     //! Distributed ALE proxy
     560                 :            :     CProxy_ALE m_ale;
     561                 :            :     //! Transporter proxy
     562                 :            :     CProxy_Transporter m_transporter;
     563                 :            :     //! Mesh writer proxy
     564                 :            :     tk::CProxy_MeshWriter m_meshwriter;
     565                 :            :     //! Mesh refiner proxy
     566                 :            :     CProxy_Refiner m_refiner;
     567                 :            :     //! \brief Elements of the mesh chunk we operate on
     568                 :            :     //! \details Initialized by the constructor. The first vector is the element
     569                 :            :     //!   connectivity (local IDs), the second vector is the global node IDs of
     570                 :            :     //!   owned elements, while the third one is a map of global->local node
     571                 :            :     //!   IDs.
     572                 :            :     tk::UnsMesh::Chunk m_el;
     573                 :            :     //! Alias to element connectivity
     574                 :            :     std::vector< std::size_t >& m_inpoel = std::get<0>( m_el );
     575                 :            :     //! Alias to global node IDs of owned elements
     576                 :            :     std::vector< std::size_t >& m_gid = std::get<1>( m_el );
     577                 :            :     //! \brief Alias to local node ids associated to the global ones of owned
     578                 :            :     //!    elements
     579                 :            :     std::unordered_map< std::size_t, std::size_t >& m_lid = std::get<2>( m_el );
     580                 :            :     //! Mesh point coordinates
     581                 :            :     tk::UnsMesh::Coords m_coord;
     582                 :            :     //! Mesh coordinates at the time n for ALE
     583                 :            :     tk::UnsMesh::Coords m_coordn;
     584                 :            :     //! \brief Global mesh node IDs bordering the mesh chunk held by fellow
     585                 :            :     //!   Discretization chares associated to their chare IDs
     586                 :            :     tk::NodeCommMap m_nodeCommMap;
     587                 :            :     //! \brief Edges with global node IDs bordering the mesh chunk held by
     588                 :            :     //!   fellow Discretization chares associated to their chare IDs
     589                 :            :     tk::EdgeCommMap m_edgeCommMap;
     590                 :            :     //! Total mesh volume
     591                 :            :     tk::real m_meshvol;
     592                 :            :     //! Nodal mesh volumes
     593                 :            :     //! \details This is the volume of the mesh associated to nodes of owned
     594                 :            :     //!   elements (sum of surrounding cell volumes / 4) without contributions
     595                 :            :     //!   from other chares on chare-boundaries
     596                 :            :     std::vector< tk::real > m_v;
     597                 :            :     //! Volume of nodes
     598                 :            :     //! \details This is the volume of the mesh associated to nodes of owned
     599                 :            :     //!   elements (sum of surrounding cell volumes / 4) with contributions from
     600                 :            :     //!   other chares on chare-boundaries
     601                 :            :     std::vector< tk::real > m_vol;
     602                 :            :     //! Receive buffer for volume of nodes (with global node id as key)
     603                 :            :     //! \details This is a communication buffer used to compute the volume of
     604                 :            :     //!   the mesh associated to nodes of owned elements (sum of surrounding
     605                 :            :     //!   cell volumes / 4) with contributions from other chares on
     606                 :            :     //!   chare-boundaries.
     607                 :            :     std::unordered_map< std::size_t, tk::real > m_volc;
     608                 :            :     //! Volume of nodes at previous time step
     609                 :            :     //! \details This is the volume of the mesh associated to nodes of owned
     610                 :            :     //!   elements (sum of surrounding cell volumes / 4) with contributions from
     611                 :            :     //!   other chares on chare-boundaries at the previous time step stage
     612                 :            :     std::vector< tk::real > m_voln;
     613                 :            :     //! Mesh element volumes at t=t0
     614                 :            :     std::vector< tk::real > m_vol0;
     615                 :            :     //! Volume of user-defined box IC
     616                 :            :     tk::real m_boxvol;
     617                 :            :     //! Volumes of mesh-blocks with user-defined ICs
     618                 :            :     std::vector< tk::real > m_meshblkvol;
     619                 :            :     //! \brief Local chare-boundary mesh node IDs at which we receive
     620                 :            :     //!   contributions associated to global mesh node IDs of elements we
     621                 :            :     //!   contribute to
     622                 :            :     std::unordered_map< std::size_t, std::size_t > m_bid;
     623                 :            :     //! Timer measuring a time step
     624                 :            :     tk::Timer m_timer;
     625                 :            :     //! 1 if mesh was refined in a time step, 0 if it was not
     626                 :            :     int m_refined;
     627                 :            :     //! Time point storing clock state at status()
     628                 :            :     Clock::time_point m_prevstatus;
     629                 :            :     //! Number of times restarted
     630                 :            :     int m_nrestart;
     631                 :            :     //! Data at history point locations
     632                 :            :     std::vector< HistData > m_histdata;
     633                 :            :     //! Number of transfers requested as a source
     634                 :            :     std::size_t m_nsrc;
     635                 :            :     //! Number of transfers requested as a destination
     636                 :            :     std::size_t m_ndst;
     637                 :            :     //! Mesh velocity if ALE is not enabled
     638                 :            :     tk::Fields m_meshvel;
     639                 :            :     //! \brief True if all stages of the time step converged the mesh velocity
     640                 :            :     //!   linear solve in ALE
     641                 :            :     bool m_meshvel_converged;
     642                 :            :     //! Boundary faces side-set information
     643                 :            :     std::map< int, std::vector< std::size_t > > m_bface;
     644                 :            :     //! Triangle face connecitivity
     645                 :            :     std::vector< std::size_t > m_triinpoel;
     646                 :            :     //! Local tet ids associated with mesh block ids
     647                 :            :     std::unordered_map< std::size_t, std::set< std::size_t > > m_elemblockid;
     648                 :            : 
     649                 :            :     //! Generate the Bid data-structure based on the node communication-map
     650                 :            :     std::unordered_map< std::size_t, std::size_t > genBid();
     651                 :            : 
     652                 :            :     //! Generate {A,x,b} for Laplacian mesh velocity smoother
     653                 :            :     std::tuple< tk::CSR, std::vector< tk::real >, std::vector< tk::real > >
     654                 :            :     Laplacian( std::size_t ncomp ) const;
     655                 :            : 
     656                 :            :     //! Set mesh coordinates based on coordinates map
     657                 :            :     tk::UnsMesh::Coords setCoord( const tk::UnsMesh::CoordMap& coordmap );
     658                 :            : 
     659                 :            :     //! Determine if communication of mesh transfer callbacks is complete
     660                 :            :     bool transferCallbacksComplete() const;
     661                 :            : };
     662                 :            : 
     663                 :            : } // inciter::
     664                 :            : 
     665                 :            : #endif // Discretization_h

Generated by: LCOV version 1.14