Quinoa all test code coverage report
Current view: top level - Inciter - Transporter.cpp (source / functions) Hit Total Coverage
Commit: -128-NOTFOUND Lines: 575 609 94.4 %
Date: 2024-04-22 13:03:21 Functions: 42 44 95.5 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 748 1696 44.1 %

           Branch data     Line data    Source code
       1                 :            : // *****************************************************************************
       2                 :            : /*!
       3                 :            :   \file      src/Inciter/Transporter.cpp
       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                 :            :   \brief     Transporter drives the time integration of transport equations
       9                 :            :   \details   Transporter drives the time integration of transport equations.
      10                 :            :     The implementation uses the Charm++ runtime system and is fully asynchronous,
      11                 :            :     overlapping computation, communication as well as I/O. The algorithm
      12                 :            :     utilizes the structured dagger (SDAG) Charm++ functionality. The high-level
      13                 :            :     overview of the algorithm structure and how it interfaces with Charm++ is
      14                 :            :     discussed in the Charm++ interface file src/Inciter/transporter.ci.
      15                 :            : */
      16                 :            : // *****************************************************************************
      17                 :            : 
      18                 :            : #include <string>
      19                 :            : #include <iostream>
      20                 :            : #include <cstddef>
      21                 :            : #include <unordered_set>
      22                 :            : #include <limits>
      23                 :            : #include <cmath>
      24                 :            : 
      25                 :            : #include <brigand/algorithms/for_each.hpp>
      26                 :            : 
      27                 :            : #include "Macro.hpp"
      28                 :            : #include "Transporter.hpp"
      29                 :            : #include "Fields.hpp"
      30                 :            : #include "PDEStack.hpp"
      31                 :            : #include "UniPDF.hpp"
      32                 :            : #include "PDFWriter.hpp"
      33                 :            : #include "ContainerUtil.hpp"
      34                 :            : #include "LoadDistributor.hpp"
      35                 :            : #include "MeshReader.hpp"
      36                 :            : #include "Inciter/InputDeck/InputDeck.hpp"
      37                 :            : #include "NodeDiagnostics.hpp"
      38                 :            : #include "ElemDiagnostics.hpp"
      39                 :            : #include "DiagWriter.hpp"
      40                 :            : #include "Callback.hpp"
      41                 :            : #include "CartesianProduct.hpp"
      42                 :            : 
      43                 :            : #include "NoWarning/inciter.decl.h"
      44                 :            : #include "NoWarning/partitioner.decl.h"
      45                 :            : 
      46                 :            : extern CProxy_Main mainProxy;
      47                 :            : 
      48                 :            : namespace inciter {
      49                 :            : 
      50                 :            : extern ctr::InputDeck g_inputdeck_defaults;
      51                 :            : extern ctr::InputDeck g_inputdeck;
      52                 :            : extern std::vector< CGPDE > g_cgpde;
      53                 :            : extern std::vector< DGPDE > g_dgpde;
      54                 :            : extern std::vector< FVPDE > g_fvpde;
      55                 :            : 
      56                 :            : }
      57                 :            : 
      58                 :            : using inciter::Transporter;
      59                 :            : 
      60                 :        193 : Transporter::Transporter() :
      61                 :            :   m_input( input() ),
      62                 :            :   m_nchare( m_input.size() ),
      63                 :            :   m_meshid(),
      64         [ +  - ]:        193 :   m_ncit( m_nchare.size(), 0 ),
      65                 :            :   m_nload( 0 ),
      66                 :            :   m_ntrans( 0 ),
      67                 :            :   m_ndtmsh( 0 ),
      68                 :            :   m_dtmsh(),
      69                 :            :   m_npart( 0 ),
      70                 :            :   m_nstat( 0 ),
      71                 :            :   m_ndisc( 0 ),
      72                 :            :   m_nchk( 0 ),
      73                 :            :   m_ncom( 0 ),
      74         [ +  - ]:        193 :   m_nt0refit( m_nchare.size(), 0 ),
      75                 :        386 :   m_ndtrefit( m_nchare.size(), 0 ),
      76                 :        386 :   m_noutrefit( m_nchare.size(), 0 ),
      77                 :        386 :   m_noutderefit( m_nchare.size(), 0 ),
      78                 :            :   m_scheme(),
      79                 :            :   m_partitioner(),
      80                 :            :   m_refiner(),
      81                 :            :   m_meshwriter(),
      82                 :            :   m_sorter(),
      83                 :            :   m_nelem( m_nchare.size() ),
      84                 :            :   m_npoin(),
      85         [ +  - ]:        193 :   m_finished( m_nchare.size(), 0 ),
      86                 :            :   m_meshvol( m_nchare.size() ),
      87                 :            :   m_minstat( m_nchare.size() ),
      88                 :            :   m_maxstat( m_nchare.size() ),
      89                 :            :   m_avgstat( m_nchare.size() ),
      90                 :            :   m_timer(),
      91         [ +  - ]:        193 :   m_progMesh( g_inputdeck.get< tag::cmd, tag::feedback >(),
      92                 :            :               ProgMeshPrefix, ProgMeshLegend ),
      93                 :        193 :   m_progWork( g_inputdeck.get< tag::cmd, tag::feedback >(),
      94 [ +  - ][ +  - ]:        965 :               ProgWorkPrefix, ProgWorkLegend )
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  + ][ +  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
                 [ -  - ]
      95                 :            : // *****************************************************************************
      96                 :            : //  Constructor
      97                 :            : // *****************************************************************************
      98                 :            : {
      99                 :            :   // Echo configuration to screen
     100 [ +  - ][ +  - ]:        193 :   info( printer() );
     101                 :            : 
     102                 :        193 :   const auto nstep = g_inputdeck.get< tag::nstep >();
     103                 :        193 :   const auto t0 = g_inputdeck.get< tag::t0 >();
     104                 :        193 :   const auto term = g_inputdeck.get< tag::term >();
     105                 :        193 :   const auto constdt = g_inputdeck.get< tag::dt >();
     106                 :            : 
     107                 :            :   // If the desired max number of time steps is larger than zero, and the
     108                 :            :   // termination time is larger than the initial time, and the constant time
     109                 :            :   // step size (if that is used) is smaller than the duration of the time to be
     110                 :            :   // simulated, we have work to do, otherwise, finish right away. If a constant
     111                 :            :   // dt is not used, that part of the logic is always true as the default
     112                 :            :   // constdt is zero, see inciter::ctr::InputDeck::InputDeck().
     113 [ +  - ][ +  - ]:        193 :   if ( nstep != 0 && term > t0 && constdt < term-t0 ) {
                 [ +  - ]
     114                 :            : 
     115                 :            :     // Enable SDAG waits for collecting mesh statistics
     116         [ +  - ]:        193 :     thisProxy.wait4stat();
     117                 :            : 
     118                 :            :     // Configure and write diagnostics file header
     119         [ +  - ]:        193 :     diagHeader();
     120                 :            : 
     121                 :            :     // Create mesh partitioner AND boundary condition object group
     122         [ +  - ]:        193 :     createPartitioner();
     123                 :            : 
     124         [ -  - ]:          0 :   } else finish();      // stop if no time stepping requested
     125                 :        193 : }
     126                 :            : 
     127                 :          2 : Transporter::Transporter( CkMigrateMessage* m ) :
     128                 :            :   CBase_Transporter( m ),
     129         [ +  - ]:          2 :   m_progMesh( g_inputdeck.get< tag::cmd, tag::feedback >(),
     130                 :            :               ProgMeshPrefix, ProgMeshLegend ),
     131                 :          2 :   m_progWork( g_inputdeck.get< tag::cmd, tag::feedback >(),
     132 [ +  - ][ +  + ]:         10 :               ProgWorkPrefix, ProgWorkLegend )
                 [ +  - ]
     133                 :            : // *****************************************************************************
     134                 :            : //  Migrate constructor: returning from a checkpoint
     135                 :            : //! \param[in] m Charm++ migrate message
     136                 :            : // *****************************************************************************
     137                 :            : {
     138         [ +  - ]:          2 :    auto print = printer();
     139 [ +  - ][ +  - ]:          2 :    print.diag( "Restarted from checkpoint" );
     140         [ +  - ]:          2 :    info( print );
     141         [ +  - ]:          2 :    inthead( print );
     142                 :          2 : }
     143                 :            : 
     144                 :            : std::vector< std::string >
     145                 :        193 : Transporter::input()
     146                 :            : // *****************************************************************************
     147                 :            : // Generate list of input mesh filenames configured by the user
     148                 :            : //! \return List of input mesh filenames configured by the user
     149                 :            : //! \details If the input file is given on the command line, a single solver
     150                 :            : //!   will be instantiated on the single mesh, solving potentially multiple
     151                 :            : //!   systems of (potentially coupled) equations. If the input file is not given
     152                 :            : //!   on the command line, the mesh files are expected to be configured in the
     153                 :            : //!   control/input file, associating a potentially different mesh to each
     154                 :            : //!   solver. Both configurations allow the solution of coupled systems, but the
     155                 :            : //!   first one solves all equations on the same mesh, while the latter can
     156                 :            : //!   couple solutions computed on multiple different meshes.
     157                 :            : // *****************************************************************************
     158                 :            : {
     159                 :            :   // Query input mesh filename specified on the command line
     160                 :            :   const auto& cmdinput = g_inputdeck.get< tag::cmd, tag::io, tag::input >();
     161                 :            : 
     162                 :            :   // Extract mesh filenames specified in the control file (assigned to solvers)
     163                 :        193 :   std::vector< std::string > ctrinput;
     164         [ +  + ]:        388 :   for (const auto& im : g_inputdeck.get< tag::mesh >()) {
     165         [ +  - ]:        195 :     ctrinput.push_back(im.get< tag::filename >());
     166                 :            :   }
     167                 :            : 
     168 [ +  + ][ -  + ]:        193 :   ErrChk( not cmdinput.empty() or not ctrinput.empty(),
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
     169                 :            :     "Either a single input mesh must be given on the command line or multiple "
     170                 :            :     "meshes must be configured in the control file." );
     171                 :            : 
     172                 :            :    // Prepend control file path to mesh filenames in given in control file
     173         [ +  - ]:        193 :   if (not ctrinput.empty()) {
     174                 :            :      const auto& ctr = g_inputdeck.get< tag::cmd, tag::io, tag::control >();
     175         [ +  - ]:        193 :      auto path = ctr.substr( 0, ctr.find_last_of("/")+1 );
     176 [ +  + ][ +  - ]:        388 :      for (auto& f : ctrinput) f = path + f;
     177                 :            :   }
     178                 :            : 
     179 [ +  + ][ -  + ]:        559 :   if (cmdinput.empty()) return ctrinput; else return { cmdinput };
         [ +  + ][ +  + ]
         [ -  - ][ -  - ]
     180                 :            : }
     181                 :            : 
     182                 :            : void
     183                 :        195 : Transporter::info( const InciterPrint& print )
     184                 :            : // *****************************************************************************
     185                 :            : // Echo configuration to screen
     186                 :            : //! \param[in] print Pretty printer object to use for printing
     187                 :            : // *****************************************************************************
     188                 :            : {
     189 [ +  - ][ +  - ]:        390 :   print.part( "Factory" );
     190                 :            : 
     191                 :            :   // Print out info data layout
     192 [ +  - ][ +  - ]:        390 :   print.list( "Unknowns data layout (CMake: FIELD_DATA_LAYOUT)",
     193 [ +  - ][ +  + ]:        585 :               std::list< std::string >{ tk::Fields::layout() } );
         [ -  + ][ -  - ]
                 [ -  - ]
     194                 :            : 
     195                 :            :   // Re-create partial differential equations stack for output
     196                 :        390 :   PDEStack stack;
     197                 :            : 
     198                 :            :   // Print out information on PDE factories
     199 [ +  - ][ +  - ]:        390 :   print.eqlist( "Registered PDEs using continuous Galerkin (CG) methods",
                 [ +  - ]
     200                 :            :                 stack.cgfactory(), stack.cgntypes() );
     201 [ +  - ][ +  - ]:        390 :   print.eqlist( "Registered PDEs using discontinuous Galerkin (DG) methods",
                 [ +  - ]
     202                 :            :                 stack.dgfactory(), stack.dgntypes() );
     203 [ +  - ][ +  - ]:        390 :   print.eqlist( "Registered PDEs using finite volume (DG) methods",
                 [ +  - ]
     204                 :            :                 stack.fvfactory(), stack.fvntypes() );
     205                 :            :   print.endpart();
     206                 :            : 
     207                 :            :   // Print out information on problem
     208 [ +  - ][ +  - ]:        390 :   print.part( "Problem" );
                 [ +  - ]
     209                 :            : 
     210                 :            :   // Print out info on problem title
     211         [ +  - ]:        195 :   if ( !g_inputdeck.get< tag::title >().empty() )
     212         [ +  - ]:        195 :     print.title( g_inputdeck.get< tag::title >() );
     213                 :            : 
     214                 :        195 :   const auto nstep = g_inputdeck.get< tag::nstep >();
     215                 :        195 :   const auto t0 = g_inputdeck.get< tag::t0 >();
     216                 :        195 :   const auto term = g_inputdeck.get< tag::term >();
     217                 :        195 :   const auto constdt = g_inputdeck.get< tag::dt >();
     218                 :        195 :   const auto cfl = g_inputdeck.get< tag::cfl >();
     219                 :        195 :   const auto scheme = g_inputdeck.get< tag::scheme >();
     220                 :            : 
     221                 :            :   // Print discretization parameters
     222 [ +  - ][ +  - ]:        195 :   print.section( "Discretization parameters" );
     223         [ +  - ]:        195 :   print.Item< ctr::Scheme, tag::scheme >();
     224                 :            : 
     225 [ +  - ][ +  + ]:        195 :   if (g_inputdeck.centering() == tk::Centering::ELEM)
     226                 :            :   {
     227         [ +  - ]:        109 :     print.Item< ctr::Limiter, tag::limiter >();
     228                 :            : 
     229 [ +  - ][ +  - ]:        109 :     print.item("Shock detection based limiting",
     230                 :            :       g_inputdeck.get< tag::shock_detector_coeff >());
     231                 :            : 
     232         [ -  + ]:        109 :     if (g_inputdeck.get< tag::accuracy_test >())
     233                 :            :     {
     234 [ -  - ][ -  - ]:          0 :       print.item("WARNING: order-of-accuracy testing enabled",
     235                 :            :         "robustness corrections inactive");
     236                 :            :     }
     237                 :            : 
     238         [ +  - ]:        218 :     print.item("Limited solution projection",
     239         [ +  - ]:        109 :       g_inputdeck.get< tag::limsol_projection >());
     240                 :            :   }
     241         [ +  - ]:        195 :   print.item( "PE-locality mesh reordering",
     242         [ +  - ]:        195 :               g_inputdeck.get< tag::pelocal_reorder >() );
     243         [ +  - ]:        195 :   print.item( "Operator-access mesh reordering",
     244         [ +  - ]:        195 :               g_inputdeck.get< tag::operator_reorder >() );
     245                 :        195 :   auto steady = g_inputdeck.get< tag::steady_state >();
     246 [ +  - ][ +  - ]:        195 :   print.item( "Local time stepping", steady );
     247         [ +  + ]:        195 :   if (steady) {
     248 [ +  - ][ +  - ]:          2 :     print.item( "L2-norm residual convergence criterion",
     249                 :            :                 g_inputdeck.get< tag::residual >() );
     250 [ +  - ][ +  - ]:          4 :     print.item( "Convergence criterion component index",
     251                 :            :                 g_inputdeck.get< tag::rescomp >() );
     252                 :            :   }
     253 [ +  - ][ +  - ]:        195 :   print.item( "Number of time steps", nstep );
     254 [ +  - ][ +  - ]:        195 :   print.item( "Start time", t0 );
     255 [ +  - ][ +  - ]:        195 :   print.item( "Terminate time", term );
     256                 :            : 
     257         [ +  + ]:        195 :   if (constdt > std::numeric_limits< tk::real >::epsilon())
     258 [ +  - ][ +  - ]:        246 :     print.item( "Constant time step size", constdt );
     259         [ +  - ]:         72 :   else if (cfl > std::numeric_limits< tk::real >::epsilon())
     260                 :            :   {
     261 [ +  - ][ +  - ]:        144 :     print.item( "CFL coefficient", cfl );
     262                 :            :   }
     263                 :            : 
     264                 :            :   const auto& meshes = g_inputdeck.get< tag::mesh >();
     265                 :            :   const auto& depvars = g_inputdeck.get< tag::depvar >();
     266         [ +  + ]:        392 :   for (std::size_t i=0; i<meshes.size(); ++i) {
     267 [ +  - ][ +  - ]:        788 :     print.item( "Dependent var name and assoc. mesh", std::string{depvars[i]}
         [ +  - ][ +  + ]
     268 [ +  - ][ +  - ]:        394 :       + " - " + meshes[i].get< tag::filename >() );
         [ -  + ][ -  + ]
         [ -  - ][ -  - ]
     269                 :            :   }
     270                 :            : 
     271                 :            :   // Print out info on settings of selected partial differential equations
     272 [ +  - ][ +  - ]:        390 :   print.pdes( "Partial differential equations integrated", stack.info() );
                 [ +  - ]
     273                 :            : 
     274                 :            :   // Print out adaptive polynomial refinement configuration
     275         [ +  + ]:        195 :   if (scheme == ctr::SchemeType::PDG) {
     276 [ +  - ][ +  - ]:         12 :     print.section( "Polynomial refinement (p-ref)" );
     277         [ +  - ]:         12 :     print.item( "p-refinement",
     278         [ +  - ]:         12 :                 g_inputdeck.get< tag::pref, tag::pref >() );
     279         [ +  - ]:         12 :     print.Item< ctr::PrefIndicator, tag::pref, tag::indicator >();
     280 [ +  - ][ +  - ]:         12 :     print.item( "Max degrees of freedom",
     281                 :            :                 g_inputdeck.get< tag::pref, tag::ndofmax >() );
     282 [ +  - ][ +  - ]:         24 :     print.item( "Tolerance",
     283                 :            :                 g_inputdeck.get< tag::pref, tag::tolref >() );
     284                 :            :   }
     285                 :            : 
     286                 :            :   // Print out adaptive mesh refinement configuration
     287                 :        195 :   const auto amr = g_inputdeck.get< tag::amr, tag::amr >();
     288         [ +  + ]:        195 :   if (amr) {
     289 [ +  - ][ +  - ]:         20 :     print.section( "Mesh refinement (h-ref)" );
     290                 :         20 :     auto maxlevels = g_inputdeck.get< tag::amr, tag::maxlevels >();
     291 [ +  - ][ +  - ]:         20 :     print.item( "Maximum mesh refinement levels", maxlevels );
     292         [ +  - ]:         20 :     print.Item< ctr::AMRError, tag::amr, tag::error >();
     293                 :         20 :     auto t0ref = g_inputdeck.get< tag::amr, tag::t0ref >();
     294 [ +  - ][ +  - ]:         20 :     print.item( "Refinement at t<0 (t0ref)", t0ref );
     295         [ +  - ]:         20 :     if (t0ref) {
     296                 :            :       const auto& initref = g_inputdeck.get< tag::amr, tag::initial >();
     297 [ +  - ][ +  - ]:         20 :       print.item( "Initial refinement steps", initref.size() );
     298                 :            : 
     299                 :            :       auto eps = std::numeric_limits< tk::real >::epsilon();
     300                 :            : 
     301                 :            :       const auto& amr_coord = g_inputdeck.get< tag::amr, tag::coords >();
     302                 :            :       const auto& amr_defcoord = g_inputdeck_defaults.get< tag::amr, tag::coords >();
     303                 :            : 
     304                 :         20 :       auto xminus = amr_coord.get< tag::xminus >();
     305                 :         20 :       auto xminus_default = amr_defcoord.get< tag::xminus >();
     306         [ +  + ]:         20 :       if (std::abs( xminus - xminus_default ) > eps)
     307 [ +  - ][ +  - ]:          2 :         print.item( "Initial refinement x-", xminus );
     308                 :         20 :       auto xplus = amr_coord.get< tag::xplus >();
     309                 :         20 :       auto xplus_default = amr_defcoord.get< tag::xplus >();
     310         [ -  + ]:         20 :       if (std::abs( xplus - xplus_default ) > eps)
     311 [ -  - ][ -  - ]:          0 :         print.item( "Initial refinement x+", xplus );
     312                 :            : 
     313                 :         20 :       auto yminus = amr_coord.get< tag::yminus >();
     314                 :         20 :       auto yminus_default = amr_defcoord.get< tag::yminus >();
     315         [ -  + ]:         20 :       if (std::abs( yminus - yminus_default ) > eps)
     316 [ -  - ][ -  - ]:          0 :         print.item( "Initial refinement y-", yminus );
     317                 :         20 :       auto yplus = amr_coord.get< tag::yplus >();
     318                 :         20 :       auto yplus_default = amr_defcoord.get< tag::yplus >();
     319         [ -  + ]:         20 :       if (std::abs( yplus - yplus_default ) > eps)
     320 [ -  - ][ -  - ]:          0 :         print.item( "Initial refinement y+", yplus );
     321                 :            : 
     322                 :         20 :       auto zminus = amr_coord.get< tag::zminus >();
     323                 :         20 :       auto zminus_default = amr_defcoord.get< tag::zminus >();
     324         [ -  + ]:         20 :       if (std::abs( zminus - zminus_default ) > eps)
     325 [ -  - ][ -  - ]:          0 :         print.item( "Initial refinement z-", zminus );
     326                 :         20 :       auto zplus = amr_coord.get< tag::zplus >();
     327                 :         20 :       auto zplus_default = amr_defcoord.get< tag::zplus >();
     328         [ -  + ]:         20 :       if (std::abs( zplus - zplus_default ) > eps)
     329 [ -  - ][ -  - ]:          0 :         print.item( "Initial refinement z+", zplus );
     330                 :            :     }
     331                 :         20 :     auto dtref = g_inputdeck.get< tag::amr, tag::dtref >();
     332 [ +  - ][ +  - ]:         20 :     print.item( "Refinement at t>0 (dtref)", dtref );
     333         [ -  + ]:         20 :     if (dtref) {
     334                 :          0 :       auto dtfreq = g_inputdeck.get< tag::amr, tag::dtfreq >();
     335 [ -  - ][ -  - ]:          0 :       print.item( "Mesh refinement frequency, t>0", dtfreq );
     336         [ -  - ]:          0 :       print.item( "Uniform-only mesh refinement, t>0",
     337         [ -  - ]:          0 :                   g_inputdeck.get< tag::amr, tag::dtref_uniform >() );
     338                 :            :     }
     339 [ +  - ][ +  - ]:         20 :     print.item( "Refinement tolerance",
     340                 :            :                 g_inputdeck.get< tag::amr, tag::tol_refine >() );
     341 [ +  - ][ +  - ]:         40 :     print.item( "De-refinement tolerance",
     342                 :            :                 g_inputdeck.get< tag::amr, tag::tol_derefine >() );
     343                 :            :   }
     344                 :            : 
     345                 :            :   // Print out ALE configuration
     346                 :        195 :   const auto ale = g_inputdeck.get< tag::ale, tag::ale >();
     347         [ +  + ]:        195 :   if (ale) {
     348 [ +  - ][ +  - ]:         10 :     print.section( "Arbitrary Lagrangian-Eulerian (ALE) mesh motion" );
     349                 :         10 :     auto dvcfl = g_inputdeck.get< tag::ale, tag::dvcfl >();
     350 [ +  - ][ +  - ]:         10 :     print.item( "Volume-change CFL coefficient", dvcfl );
     351         [ +  - ]:         10 :     print.Item< ctr::MeshVelocity, tag::ale, tag::mesh_velocity >();
     352         [ +  - ]:         10 :     print.Item< ctr::MeshVelocitySmoother, tag::ale, tag::smoother >();
     353 [ +  - ][ +  - ]:         20 :     print.item( "Mesh motion dimensions", tk::parameters(
         [ +  - ][ -  + ]
     354                 :            :                 g_inputdeck.get< tag::ale, tag::mesh_motion >() ) );
     355                 :            :     const auto& meshforce = g_inputdeck.get< tag::ale, tag::meshforce >();
     356 [ +  - ][ +  - ]:         20 :     print.item( "Mesh velocity force coefficients", tk::parameters(meshforce) );
         [ +  - ][ -  + ]
     357 [ +  - ][ +  - ]:         10 :     print.item( "Vorticity multiplier",
     358                 :            :                 g_inputdeck.get< tag::ale, tag::vortmult >() );
     359 [ +  - ][ +  - ]:         10 :     print.item( "Mesh velocity linear solver tolerance",
     360                 :            :                 g_inputdeck.get< tag::ale, tag::tolerance >() );
     361 [ +  - ][ +  - ]:         20 :     print.item( "Mesh velocity linear solver maxit",
                 [ +  + ]
     362                 :            :                 g_inputdeck.get< tag::ale, tag::maxit >() );
     363                 :            :     const auto& dir = g_inputdeck.get< tag::ale, tag::dirichlet >();
     364         [ +  + ]:         10 :     if (not dir.empty())
     365 [ +  - ][ +  - ]:         10 :       print.item( "Mesh velocity Dirichlet BC sideset(s)",
                 [ -  + ]
     366         [ +  - ]:         10 :                   tk::parameters( dir ) );
     367                 :            :     const auto& sym = g_inputdeck.get< tag::ale, tag::symmetry >();
     368         [ +  + ]:         10 :     if (not sym.empty())
     369 [ +  - ][ +  - ]:          6 :       print.item( "Mesh velocity symmetry BC sideset(s)",
                 [ -  + ]
     370         [ +  - ]:          6 :                   tk::parameters( sym ) );
     371                 :            :     std::size_t i = 1;
     372         [ +  + ]:         12 :     for (const auto& m : g_inputdeck.get< tag::ale, tag::move >()) {
     373         [ +  - ]:          2 :        tk::ctr::UserTable opt;
     374 [ +  - ][ +  - ]:          4 :        print.item( opt.group() + ' ' + std::to_string(i) + " interpreted as",
         [ +  - ][ +  - ]
         [ -  + ][ -  + ]
         [ -  + ][ +  - ]
         [ -  - ][ -  - ]
                 [ -  - ]
     375                 :          2 :                    opt.name( m.get< tag::fntype >() ) );
     376                 :            :        const auto& s = m.get< tag::sideset >();
     377         [ +  - ]:          2 :        if (not s.empty())
     378 [ +  - ][ +  - ]:          4 :          print.item( "Moving sideset(s) with table " + std::to_string(i),
         [ -  + ][ -  + ]
         [ -  - ][ -  - ]
     379         [ +  - ]:          4 :                      tk::parameters(s));
     380                 :          2 :        ++i;
     381                 :            :     }
     382                 :            :   }
     383                 :            : 
     384                 :            :   // Print I/O filenames
     385 [ +  - ][ +  - ]:        195 :   print.section( "Input/Output filenames and directories" );
     386 [ +  - ][ +  - ]:        390 :   print.item( "Input mesh(es)", tk::parameters( m_input ) );
         [ +  - ][ +  + ]
     387                 :            :   const auto& of = g_inputdeck.get< tag::cmd, tag::io, tag::output >();
     388 [ +  - ][ +  - ]:        390 :   print.item( "Volume field output file(s)",
                 [ +  - ]
     389         [ +  - ]:        195 :               of + ".e-s.<meshid>.<numchares>.<chareid>" );
     390 [ +  - ][ +  - ]:        390 :   print.item( "Surface field output file(s)",
                 [ +  - ]
     391         [ +  - ]:        195 :               of + "-surf.<surfid>.e-s.<meshid>.<numchares>.<chareid>" );
     392 [ +  - ][ +  - ]:        390 :   print.item( "History output file(s)", of + ".hist.{pointid}" );
         [ +  - ][ +  - ]
     393 [ +  - ][ +  - ]:        195 :   print.item( "Diagnostics file",
     394                 :            :               g_inputdeck.get< tag::cmd, tag::io, tag::diag >() );
     395 [ +  - ][ +  - ]:        390 :   print.item( "Checkpoint/restart directory",
                 [ -  + ]
     396         [ +  - ]:        195 :               g_inputdeck.get< tag::cmd, tag::io, tag::restart >() + '/' );
     397                 :            : 
     398                 :            :   // Print output intervals
     399 [ +  - ][ +  - ]:        195 :   print.section( "Output intervals (in units of iteration count)" );
     400 [ +  - ][ +  - ]:        195 :   print.item( "TTY", g_inputdeck.get< tag::ttyi>() );
     401 [ +  - ][ +  - ]:        195 :   print.item( "Field and surface",
     402                 :            :               g_inputdeck.get< tag::field_output, tag::interval >() );
     403 [ +  - ][ +  - ]:        195 :   print.item( "History",
     404                 :            :               g_inputdeck.get< tag::history_output, tag::interval >() );
     405 [ +  - ][ +  - ]:        195 :   print.item( "Diagnostics",
     406                 :            :               g_inputdeck.get< tag::diagnostics, tag::interval >() );
     407 [ +  - ][ +  - ]:        195 :   print.item( "Checkpoint/restart",
     408                 :            :               g_inputdeck.get< tag::cmd, tag::rsfreq >() );
     409                 :        195 :   auto tf = g_inputdeck.get< tag::field_output, tag::time_interval >();
     410                 :        195 :   auto th = g_inputdeck.get< tag::history_output, tag::time_interval >();
     411 [ -  + ][ -  - ]:        195 :   if (tf>0.0 || th>0.0) {
     412 [ +  - ][ +  - ]:        195 :     print.section( "Output intervals (in units of physics time)" );
     413 [ +  - ][ +  - ]:        390 :     if (tf > 0.0) print.item( "Field and surface", tf );
                 [ +  - ]
     414 [ +  - ][ +  - ]:        390 :     if (th > 0.0) print.item( "History", th );
                 [ +  - ]
     415                 :            :   }
     416                 :            :   const auto& rf = g_inputdeck.get< tag::field_output, tag::time_range >();
     417                 :            :   const auto& rh = g_inputdeck.get< tag::history_output, tag::time_range >();
     418 [ +  - ][ -  + ]:        195 :   if (not rf.empty() or not rh.empty()) {
     419 [ -  - ][ -  - ]:          0 :     print.section( "Output time ranges (in units of physics time)" );
     420 [ -  - ][ -  - ]:          0 :     print.item("Field output { mintime, maxtime, dt }", tk::parameters(rf));
         [ -  - ][ -  - ]
     421 [ -  - ][ -  - ]:          0 :     print.item("History output { mintime, maxtime, dt }", tk::parameters(rh));
         [ -  - ][ -  - ]
     422                 :            :   }
     423                 :            : 
     424                 :            :   //// Print output variables: fields and surfaces
     425                 :            :   //const auto nodeoutvars = g_inputdeck.outvars( tk::Centering::NODE );
     426                 :            :   //const auto elemoutvars = g_inputdeck.outvars( tk::Centering::ELEM );
     427                 :            :   //const auto outsets = g_inputdeck.outsets();
     428                 :            :   //if (!nodeoutvars.empty() || !elemoutvars.empty() || !outsets.empty())
     429                 :            :   //   print.section( "Output fields" );
     430                 :            :   //if (!nodeoutvars.empty())
     431                 :            :   //  print.item( "Node field(s)", tk::parameters(nodeoutvars) );
     432                 :            :   //if (!elemoutvars.empty())
     433                 :            :   //  print.item( "Elem field(s)", tk::parameters(elemoutvars) );
     434                 :            :   //if (!aliases.empty())
     435                 :            :   //  print.item( "Alias(es)", tk::parameters(aliases) );
     436                 :            :   //if (!outsets.empty())
     437                 :            :   //  print.item( "Surface side set(s)", tk::parameters(outsets) );
     438                 :            : 
     439                 :            :   // Print output variables: history
     440                 :            :   const auto& pt = g_inputdeck.get< tag::history_output, tag::point >();
     441         [ +  + ]:        195 :   if (!pt.empty()) {
     442 [ +  - ][ +  - ]:         10 :     print.section( "Output time history" );
     443         [ +  + ]:         14 :     for (std::size_t p=0; p<pt.size(); ++p) {
     444                 :            :       const auto& id = pt[p].get< tag::id >();
     445         [ +  - ]:          9 :       std::stringstream ss;
     446                 :          9 :       auto prec = g_inputdeck.get< tag::history_output, tag::precision >();
     447         [ +  - ]:          9 :       ss << std::setprecision( static_cast<int>(prec) );
     448                 :            :       ss << of << ".hist." << id;
     449 [ +  - ][ +  - ]:         18 :       print.longitem( "At point " + id + ' ' +
         [ +  - ][ +  - ]
         [ -  + ][ -  + ]
         [ -  + ][ -  - ]
         [ -  - ][ -  - ]
     450 [ +  - ][ -  + ]:         18 :         tk::parameters(pt[p].get<tag::coord>()), ss.str() );
                 [ -  - ]
     451                 :            :     }
     452                 :            :   }
     453                 :            : 
     454                 :            :   print.endsubsection();
     455                 :        195 : }
     456                 :            : 
     457                 :            : bool
     458         [ +  - ]:        281 : Transporter::matchBCs( std::map< int, std::vector< std::size_t > >& bnd )
     459                 :            : // *****************************************************************************
     460                 :            :  // Verify that side sets specified in the control file exist in mesh file
     461                 :            :  //! \details This function does two things: (1) it verifies that the side
     462                 :            :  //!   sets used in the input file (either to which boundary conditions (BC)
     463                 :            :  //!   are assigned or listed as field output by the user in the
     464                 :            :  //!   input file) all exist among the side sets read from the input mesh
     465                 :            :  //!   file and errors out if at least one does not, and (2) it matches the
     466                 :            :  //!   side set ids at which the user has configured BCs (or listed as an output
     467                 :            :  //!   surface) to side set ids read from the mesh file and removes those face
     468                 :            :  //!   and node lists associated to side sets that the user did not set BCs or
     469                 :            :  //!   listed as field output on (as they will not need processing further since
     470                 :            :  //!   they will not be used).
     471                 :            :  //! \param[in,out] bnd Node or face lists mapped to side set ids
     472                 :            :  //! \return True if sidesets have been used and found in mesh
     473                 :            : // *****************************************************************************
     474                 :            : {
     475                 :            :   // Query side set ids at which BCs assigned for all BC types for all PDEs
     476                 :            :   using bclist = ctr::bclist::Keys;
     477                 :            :   std::unordered_set< int > usedsets;
     478         [ +  - ]:        281 :   brigand::for_each< bclist >( UserBC( g_inputdeck, usedsets ) );
     479                 :            : 
     480                 :            :   // Query side sets of time dependent BCs (since tag::bctimedep is not a part
     481                 :            :   // of tag::bc)
     482                 :            :   const auto& bcs = g_inputdeck.get< tag::bc >();
     483         [ +  + ]:        570 :   for (const auto& bci : bcs) {
     484         [ +  + ]:        293 :     for (const auto& b : bci.get< tag::timedep >()) {
     485         [ +  + ]:          8 :       for (auto i : b.get< tag::sideset >())
     486         [ +  - ]:          4 :         usedsets.insert(static_cast<int>(i));
     487                 :            :     }
     488                 :            :   }
     489                 :            : 
     490                 :            :   // Query side sets of boundaries prescribed as moving with ALE
     491         [ +  + ]:        285 :   for (const auto& move : g_inputdeck.get< tag::ale, tag::move >())
     492         [ +  + ]:          8 :     for (auto i : move.get< tag::sideset >())
     493         [ +  - ]:          4 :       usedsets.insert(static_cast<int>(i));
     494                 :            : 
     495                 :            :   // Add sidesets requested for field output
     496                 :            :   const auto& ss = g_inputdeck.get< tag::cmd, tag::io, tag::surface >();
     497         [ -  + ]:        281 :   for (const auto& s : ss) {
     498         [ -  - ]:          0 :     std::stringstream conv( s );
     499                 :            :     int num;
     500         [ -  - ]:          0 :     conv >> num;
     501                 :            :     usedsets.insert( num );
     502                 :            :   }
     503                 :            : 
     504                 :            :   // Find user-configured side set ids among side sets read from mesh file
     505                 :            :   std::unordered_set< int > sidesets_used;
     506         [ +  + ]:       1189 :   for (auto i : usedsets) {       // for all side sets used in control file
     507         [ +  + ]:        908 :     if (bnd.find(i) != end(bnd))  // used set found among side sets in file
     508                 :            :       sidesets_used.insert( i );  // store side set id configured as BC
     509                 :            :     //else {
     510                 :            :     //  Throw( "Boundary conditions specified on side set " +
     511                 :            :     //    std::to_string(i) + " which does not exist in mesh file" );
     512                 :            :     //}
     513                 :            :   }
     514                 :            : 
     515                 :            :   // Remove sidesets not used (will not process those further)
     516                 :        281 :   tk::erase_if( bnd, [&]( auto& item ) {
     517                 :       1376 :     return sidesets_used.find( item.first ) == end(sidesets_used);
     518                 :            :   });
     519                 :            : 
     520                 :        562 :   return !bnd.empty();
     521                 :            : }
     522                 :            : 
     523                 :            : void
     524                 :        193 : Transporter::createPartitioner()
     525                 :            : // *****************************************************************************
     526                 :            : // Create mesh partitioner AND boundary conditions group
     527                 :            : // *****************************************************************************
     528                 :            : {
     529                 :        193 :   auto scheme = g_inputdeck.get< tag::scheme >();
     530         [ +  - ]:        193 :   auto centering = ctr::Scheme().centering( scheme );
     531                 :        193 :   auto print = printer();
     532                 :            : 
     533                 :            :   // Create partitioner callbacks (order important)
     534                 :            :   tk::PartitionerCallback cbp {{
     535 [ +  - ][ +  - ]:        386 :       CkCallback( CkReductionTarget(Transporter,load), thisProxy )
     536         [ +  - ]:        386 :     , CkCallback( CkReductionTarget(Transporter,partitioned), thisProxy )
     537         [ +  - ]:        386 :     , CkCallback( CkReductionTarget(Transporter,distributed), thisProxy )
     538         [ +  - ]:        386 :     , CkCallback( CkReductionTarget(Transporter,refinserted), thisProxy )
     539         [ +  - ]:        386 :     , CkCallback( CkReductionTarget(Transporter,refined), thisProxy )
     540                 :        193 :   }};
     541                 :            : 
     542                 :            :   // Create refiner callbacks (order important)
     543                 :            :   tk::RefinerCallback cbr {{
     544 [ +  - ][ +  - ]:        386 :       CkCallback( CkReductionTarget(Transporter,queriedRef), thisProxy )
     545         [ +  - ]:        386 :     , CkCallback( CkReductionTarget(Transporter,respondedRef), thisProxy )
     546         [ +  - ]:        386 :     , CkCallback( CkReductionTarget(Transporter,compatibility), thisProxy )
     547         [ +  - ]:        386 :     , CkCallback( CkReductionTarget(Transporter,bndint), thisProxy )
     548         [ +  - ]:        386 :     , CkCallback( CkReductionTarget(Transporter,matched), thisProxy )
     549         [ +  - ]:        386 :     , CkCallback( CkReductionTarget(Transporter,refined), thisProxy )
     550                 :        193 :   }};
     551                 :            : 
     552                 :            :   // Create sorter callbacks (order important)
     553                 :            :   tk::SorterCallback cbs {{
     554         [ +  - ]:        193 :       CkCallback( CkReductionTarget(Transporter,queried), thisProxy )
     555         [ +  - ]:        386 :     , CkCallback( CkReductionTarget(Transporter,responded), thisProxy )
     556         [ +  - ]:        386 :     , CkCallback( CkReductionTarget(Transporter,discinserted), thisProxy )
     557         [ +  - ]:        386 :     , CkCallback( CkReductionTarget(Transporter,workinserted), thisProxy )
     558                 :        193 :   }};
     559                 :            : 
     560                 :            :   // Start timer measuring preparation of mesh(es) for partitioning
     561         [ +  - ]:        193 :   m_timer[ TimerTag::MESH_READ ];
     562                 :            : 
     563                 :            :   // Start preparing mesh(es)
     564 [ +  - ][ +  - ]:        386 :   print.diag( "Reading mesh(es)" );
     565                 :            : 
     566                 :            :   // Create (discretization) Scheme chare worker arrays for all meshes
     567         [ +  + ]:        388 :   for ([[maybe_unused]] const auto& filename : m_input)
     568                 :            :     m_scheme.emplace_back( g_inputdeck.get< tag::scheme >(),
     569                 :            :                            g_inputdeck.get< tag::ale, tag::ale >(),
     570                 :        195 :                            need_linearsolver(),
     571 [ +  - ][ +  - ]:        195 :                            centering );
     572                 :            : 
     573 [ -  + ][ -  - ]:        193 :   ErrChk( !m_input.empty(), "No input mesh" );
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
                 [ -  - ]
     574                 :            : 
     575                 :            :   // Read boundary (side set) data from a list of input mesh files
     576                 :        193 :   std::size_t meshid = 0;
     577         [ +  + ]:        388 :   for (const auto& filename : m_input) {
     578                 :            :     // Create mesh reader for reading side sets from file
     579         [ +  - ]:        195 :     tk::MeshReader mr( filename );
     580                 :            : 
     581                 :            :     // Read out total number of mesh points from mesh file
     582 [ +  - ][ +  - ]:        195 :     m_npoin.push_back( mr.npoin() );
         [ +  - ][ -  - ]
     583                 :            : 
     584                 :            :     std::map< int, std::vector< std::size_t > > bface;
     585                 :            :     std::map< int, std::vector< std::size_t > > faces;
     586                 :            :     std::map< int, std::vector< std::size_t > > bnode;
     587                 :            : 
     588                 :            :     // Read boundary-face connectivity on side sets
     589                 :            :     mr.readSidesetFaces( bface, faces );
     590                 :            : 
     591                 :            :     bool bcs_set = false;
     592         [ +  + ]:        195 :     if (centering == tk::Centering::ELEM) {
     593                 :            : 
     594                 :            :       // Verify boundarty condition (BC) side sets used exist in mesh file
     595         [ +  - ]:        109 :       bcs_set = matchBCs( bface );
     596                 :            : 
     597         [ +  - ]:         86 :     } else if (centering == tk::Centering::NODE) {
     598                 :            : 
     599                 :            :       // Read node lists on side sets
     600                 :         86 :       bnode = mr.readSidesetNodes();
     601                 :            :       // Verify boundarty condition (BC) side sets used exist in mesh file
     602         [ +  - ]:         86 :       bool bcnode_set = matchBCs( bnode );
     603         [ +  - ]:         86 :       bool bcface_set = matchBCs( bface );
     604                 :         86 :       bcs_set = bcface_set or bcnode_set;
     605                 :            :     }
     606                 :            : 
     607                 :            :     // Warn on no BCs
     608         [ +  + ]:        195 :     if (!bcs_set) print << "\n>>> WARNING: No boundary conditions set\n\n";
     609                 :            : 
     610         [ +  - ]:        195 :     auto opt = m_scheme[meshid].arrayoptions();
     611                 :            :     // Create empty mesh refiner chare array (bound to workers)
     612 [ +  - ][ +  - ]:        390 :     m_refiner.push_back( CProxy_Refiner::ckNew(opt) );
     613                 :            :     // Create empty mesh sorter Charm++ chare array (bound to workers)
     614 [ +  - ][ +  - ]:        390 :     m_sorter.push_back( CProxy_Sorter::ckNew(opt) );
     615                 :            : 
     616                 :            :     // Create MeshWriter chare group for mesh
     617                 :        390 :     m_meshwriter.push_back(
     618                 :            :       tk::CProxy_MeshWriter::ckNew(
     619                 :            :         g_inputdeck.get< tag::field_output, tag::filetype >(),
     620                 :            :         centering,
     621                 :            :         g_inputdeck.get< tag::cmd, tag::benchmark >(),
     622         [ +  - ]:        195 :         m_input.size() ) );
     623                 :            : 
     624                 :            :     // Create mesh partitioner Charm++ chare nodegroup for all meshes
     625                 :          0 :     m_partitioner.push_back(
     626                 :            :       CProxy_Partitioner::ckNew( meshid, filename, cbp, cbr, cbs,
     627         [ +  - ]:        195 :         thisProxy, m_refiner.back(), m_sorter.back(), m_meshwriter.back(),
     628         [ +  - ]:        195 :         m_scheme, bface, faces, bnode ) );
     629                 :            : 
     630                 :        195 :     ++meshid;
     631                 :            :   }
     632                 :        193 : }
     633                 :            : 
     634                 :            : void
     635                 :        195 : Transporter::load( std::size_t meshid, std::size_t nelem )
     636                 :            : // *****************************************************************************
     637                 :            : // Reduction target: the mesh has been read from file on all PEs
     638                 :            : //! \param[in] meshid Mesh id (summed accross all compute nodes)
     639                 :            : //! \param[in] nelem Number of mesh elements per mesh (summed across all
     640                 :            : //!    compute nodes)
     641                 :            : // *****************************************************************************
     642                 :            : {
     643                 :        195 :   meshid /= static_cast< std::size_t >( CkNumNodes() );
     644                 :            :   Assert( meshid < m_nelem.size(), "MeshId indexing out" );
     645                 :        195 :   m_nelem[meshid] = nelem;
     646                 :            : 
     647                 :            :   // Compute load distribution given total work (nelem) and user-specified
     648                 :            :   // virtualization
     649                 :            :   uint64_t chunksize, remainder;
     650                 :        195 :   m_nchare[meshid] = static_cast<int>(
     651                 :        195 :     tk::linearLoadDistributor(
     652                 :            :        g_inputdeck.get< tag::cmd, tag::virtualization >(),
     653                 :        195 :        m_nelem[meshid], CkNumPes(), chunksize, remainder ) );
     654                 :            : 
     655                 :            :   // Store sum of meshids (across all chares, key) for each meshid (value).
     656                 :            :   // This is used to look up the mesh id after collectives that sum their data.
     657                 :        195 :   m_meshid[ static_cast<std::size_t>(m_nchare[meshid])*meshid ] = meshid;
     658                 :            :   Assert( meshid < m_nelem.size(), "MeshId indexing out" );
     659                 :            : 
     660                 :            :   // Tell the meshwriter for this mesh the total number of its chares
     661                 :        195 :   m_meshwriter[meshid].nchare( meshid, m_nchare[meshid] );
     662                 :            : 
     663         [ +  + ]:        195 :   if (++m_nload == m_nelem.size()) {     // all meshes have been loaded
     664                 :        193 :     m_nload = 0;
     665                 :        193 :     auto print = printer();
     666                 :            : 
     667                 :            :     // Start timer measuring preparation of the mesh for partitioning
     668                 :            :     const auto& timer = tk::cref_find( m_timer, TimerTag::MESH_READ );
     669 [ +  - ][ +  - ]:        386 :     print.diag( "Mesh read time: " + std::to_string( timer.dsec() ) + " sec" );
         [ +  - ][ -  + ]
         [ -  + ][ -  - ]
                 [ -  - ]
     670                 :            : 
     671                 :            :     // Print out mesh partitioning configuration
     672 [ +  - ][ +  - ]:        193 :     print.section( "Mesh partitioning" );
     673         [ +  - ]:        193 :     print.Item< tk::ctr::PartitioningAlgorithm, tag::partitioning >();
     674 [ +  - ][ +  - ]:        193 :     print.item( "Virtualization [0.0...1.0]",
     675                 :            :                 g_inputdeck.get< tag::cmd, tag::virtualization >() );
     676                 :            :     // Print out initial mesh statistics
     677 [ +  - ][ +  - ]:        193 :     meshstat( "Initial load distribution" );
     678                 :            : 
     679                 :            :     // Query number of initial mesh refinement steps
     680                 :            :     int nref = 0;
     681         [ +  + ]:        193 :     if (g_inputdeck.get< tag::amr, tag::t0ref >())
     682                 :         20 :       nref = static_cast<int>(g_inputdeck.get< tag::amr,
     683                 :         20 :         tag::initial >().size());
     684                 :            : 
     685         [ +  - ]:        193 :     m_progMesh.start( print, "Preparing mesh", {{ CkNumPes(), CkNumPes(), nref,
     686         [ +  - ]:        193 :       m_nchare[0], m_nchare[0], m_nchare[0], m_nchare[0] }} );
     687                 :            : 
     688                 :            :     // Partition first mesh
     689         [ +  - ]:        193 :     m_partitioner[0].partition( m_nchare[0] );
     690                 :            :   }
     691                 :        195 : }
     692                 :            : 
     693                 :            : void
     694                 :        195 : Transporter::partitioned( std::size_t meshid )
     695                 :            : // *****************************************************************************
     696                 :            : // Reduction target: a mesh has been partitioned
     697                 :            : //! \param[in] meshid Mesh id
     698                 :            : // *****************************************************************************
     699                 :            : {
     700         [ +  + ]:        195 :   if (++m_npart == m_nelem.size()) {     // all meshes have been partitioned
     701                 :        193 :     m_npart = 0;
     702                 :            :   } else { // partition next mesh
     703                 :          2 :     m_partitioner[meshid+1].partition( m_nchare[meshid+1] );
     704                 :            :   }
     705                 :        195 : }
     706                 :            : 
     707                 :            : void
     708                 :        195 : Transporter::distributed( std::size_t meshid )
     709                 :            : // *****************************************************************************
     710                 :            : // Reduction target: all compute nodes have distributed their mesh after
     711                 :            : // partitioning
     712                 :            : //! \param[in] meshid Mesh id
     713                 :            : // *****************************************************************************
     714                 :            : {
     715                 :        195 :   m_partitioner[meshid].refine();
     716                 :        195 : }
     717                 :            : 
     718                 :            : void
     719                 :        195 : Transporter::refinserted( std::size_t meshid, std::size_t error )
     720                 :            : // *****************************************************************************
     721                 :            : // Reduction target: all compute nodes have created the mesh refiners
     722                 :            : //! \param[in] meshid Mesh id (aggregated across all compute nodes with operator
     723                 :            : //!   max)
     724                 :            : //! \param[in] error Error code (aggregated across all compute nodes with
     725                 :            : //!   operator max)
     726                 :            : // *****************************************************************************
     727                 :            : {
     728         [ -  + ]:        195 :   if (error) {
     729                 :            : 
     730                 :          0 :     printer() << "\n>>> ERROR: A worker chare was not assigned any mesh "
     731 [ -  - ][ -  - ]:          0 :               "elements after distributing mesh " + std::to_string(meshid) +
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
     732                 :            :               ". This can happen in SMP-mode with a large +ppn "
     733                 :            :               "parameter (number of worker threads per logical node) and is "
     734                 :            :               "most likely the fault of the mesh partitioning algorithm not "
     735                 :            :               "tolerating the case when it is asked to divide the "
     736                 :            :               "computational domain into a number of partitions different "
     737                 :            :               "than the number of ranks it is called on, i.e., in case of "
     738                 :            :               "overdecomposition and/or calling the partitioner in SMP mode "
     739                 :            :               "with +ppn larger than 1. Solution 1: Try a different "
     740                 :            :               "partitioning algorithm (e.g., rcb instead of mj). Solution 2: "
     741                 :            :               "Decrease +ppn.";
     742                 :          0 :     finish( meshid );
     743                 :            : 
     744                 :            :   } else {
     745                 :            : 
     746                 :        195 :      m_refiner[meshid].doneInserting();
     747                 :            : 
     748                 :            :   }
     749                 :        195 : }
     750                 :            : 
     751                 :            : void
     752                 :         87 : Transporter::queriedRef( std::size_t meshid )
     753                 :            : // *****************************************************************************
     754                 :            : // Reduction target: all Refiner chares have queried their boundary edges
     755                 :            : //! \param[in] meshid Mesh id
     756                 :            : // *****************************************************************************
     757                 :            : {
     758                 :         87 :   m_refiner[meshid].response();
     759                 :         87 : }
     760                 :            : 
     761                 :            : void
     762                 :         87 : Transporter::respondedRef( std::size_t meshid )
     763                 :            : // *****************************************************************************
     764                 :            : // Reduction target: all Refiner chares have setup their boundary edges
     765                 :            : //! \param[in] meshid Mesh id
     766                 :            : // *****************************************************************************
     767                 :            : {
     768                 :         87 :   m_refiner[meshid].refine();
     769                 :         87 : }
     770                 :            : 
     771                 :            : void
     772                 :         48 : Transporter::compatibility( std::size_t meshid )
     773                 :            : // *****************************************************************************
     774                 :            : // Reduction target: all Refiner chares have received a round of edges,
     775                 :            : // and have run their compatibility algorithm
     776                 :            : //! \param[in] meshid Mesh id (aggregated across all chares using operator max)
     777                 :            : //! \details This is called iteratively, until convergence by Refiner. At this
     778                 :            : //!   point all Refiner chares have received a round of edge data (tags whether
     779                 :            : //!   an edge needs to be refined, etc.), and applied the compatibility
     780                 :            : //!   algorithm independent of other Refiner chares. We keep going until the
     781                 :            : //!   mesh is no longer modified by the compatibility algorithm, based on a new
     782                 :            : //!   round of edge data communication started in Refiner::comExtra().
     783                 :            : // *****************************************************************************
     784                 :            : {
     785                 :         48 :   m_refiner[meshid].correctref();
     786                 :         48 : }
     787                 :            : 
     788                 :            : void
     789                 :         89 : Transporter::matched( std::size_t summeshid,
     790                 :            :                       std::size_t nextra,
     791                 :            :                       std::size_t nref,
     792                 :            :                       std::size_t nderef,
     793                 :            :                       std::size_t sumrefmode )
     794                 :            : // *****************************************************************************
     795                 :            : // Reduction target: all Refiner chares have matched/corrected the tagging
     796                 :            : // of chare-boundary edges, all chares are ready to perform refinement.
     797                 :            : //! \param[in] summeshid Mesh id (summed across all chares)
     798                 :            : //! \param[in] nextra Sum (across all chares) of the number of edges on each
     799                 :            : //!   chare that need correction along chare boundaries
     800                 :            : //! \param[in] nref Sum of number of refined tetrahedra across all chares.
     801                 :            : //! \param[in] nderef Sum of number of derefined tetrahedra across all chares.
     802                 :            : //! \param[in] sumrefmode Sum of contributions from all chares, encoding
     803                 :            : //!   refinement mode of operation.
     804                 :            : // *****************************************************************************
     805                 :            : {
     806                 :         89 :   auto meshid = tk::cref_find( m_meshid, summeshid );
     807                 :            : 
     808                 :            :   // If at least a single edge on a chare still needs correction, do correction,
     809                 :            :   // otherwise, this mesh refinement step is complete
     810         [ +  + ]:         89 :   if (nextra > 0) {
     811                 :            : 
     812                 :          2 :     ++m_ncit[meshid];
     813                 :          2 :     m_refiner[meshid].comExtra();
     814                 :            : 
     815                 :            :   } else {
     816                 :            : 
     817                 :         87 :     auto print = printer();
     818                 :            : 
     819                 :            :     // decode refmode
     820                 :            :     auto refmode = static_cast< Refiner::RefMode >(
     821         [ +  + ]:         87 :                      sumrefmode / static_cast<std::size_t>(m_nchare[meshid]) );
     822                 :            : 
     823         [ +  + ]:         87 :     if (refmode == Refiner::RefMode::T0REF) {
     824                 :            : 
     825         [ +  - ]:         57 :       if (!g_inputdeck.get< tag::cmd, tag::feedback >()) {
     826         [ +  - ]:         57 :         ctr::AMRInitial opt;
     827 [ +  - ][ +  - ]:        798 :         print.diag( { "meshid", "t0ref", "type", "nref", "nderef", "ncorr" },
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  + ][ -  + ]
         [ +  + ][ -  + ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
     828                 :            :                     { std::to_string(meshid),
     829         [ +  - ]:         57 :                       std::to_string(m_nt0refit[meshid]),
     830                 :            :                       "initial",
     831                 :            :                       std::to_string(nref),
     832                 :            :                       std::to_string(nderef),
     833         [ +  - ]:         57 :                       std::to_string(m_ncit[meshid]) } );
     834                 :         57 :         ++m_nt0refit[meshid];
     835                 :            :       }
     836         [ +  - ]:         57 :       m_progMesh.inc< REFINE >( print );
     837                 :            : 
     838         [ -  + ]:         30 :     } else if (refmode == Refiner::RefMode::DTREF) {
     839                 :            : 
     840         [ -  - ]:          0 :       auto dtref_uni = g_inputdeck.get< tag::amr, tag::dtref_uniform >();
     841 [ -  - ][ -  - ]:          0 :       print.diag( { "meshid", "dtref", "type", "nref", "nderef", "ncorr" },
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
                 [ -  - ]
     842                 :            :                   { std::to_string(meshid),
     843         [ -  - ]:          0 :                     std::to_string(++m_ndtrefit[meshid]),
     844                 :            :                     (dtref_uni?"uniform":"error"),
     845                 :            :                     std::to_string(nref),
     846                 :            :                     std::to_string(nderef),
     847         [ -  - ]:          0 :                     std::to_string(m_ncit[meshid]) },
     848                 :            :                   false );
     849                 :            : 
     850         [ +  + ]:         30 :     } else if (refmode == Refiner::RefMode::OUTREF) {
     851                 :            : 
     852 [ +  - ][ +  - ]:        180 :       print.diag( { "meshid", "outref", "nref", "nderef", "ncorr" },
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  + ][ -  + ]
         [ +  + ][ -  + ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
     853                 :            :                   { std::to_string(meshid),
     854         [ +  - ]:         15 :                     std::to_string(++m_noutrefit[meshid]),
     855                 :            :                     std::to_string(nref),
     856                 :            :                     std::to_string(nderef),
     857         [ +  - ]:         15 :                     std::to_string(m_ncit[meshid]) }, false );
     858                 :            : 
     859         [ +  - ]:         15 :     } else if (refmode == Refiner::RefMode::OUTDEREF) {
     860                 :            : 
     861 [ +  - ][ +  - ]:        180 :       print.diag( { "meshid", "outderef", "nref", "nderef", "ncorr" },
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  + ][ -  + ]
         [ +  + ][ -  + ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
     862                 :            :                   { std::to_string(meshid),
     863         [ +  - ]:         15 :                     std::to_string(++m_noutderefit[meshid]),
     864                 :            :                     std::to_string(nref),
     865                 :            :                     std::to_string(nderef),
     866         [ +  - ]:         15 :                     std::to_string(m_ncit[meshid]) },
     867                 :            :                   false );
     868                 :            : 
     869 [ -  - ][ -  - ]:          0 :     } else Throw( "RefMode not implemented" );
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
     870                 :            : 
     871         [ +  - ]:         87 :     m_ncit[meshid] = 0;
     872         [ +  - ]:         87 :     m_refiner[meshid].perform();
     873                 :            : 
     874                 :            :   }
     875                 :         89 : }
     876                 :            : 
     877                 :            : void
     878                 :        109 : Transporter::bndint( tk::real sx, tk::real sy, tk::real sz, tk::real cb,
     879                 :            :                      tk::real summeshid )
     880                 :            : // *****************************************************************************
     881                 :            : // Compute surface integral across the whole problem and perform leak-test
     882                 :            : //! \param[in] sx X component of vector summed
     883                 :            : //! \param[in] sy Y component of vector summed
     884                 :            : //! \param[in] sz Z component of vector summed
     885                 :            : //! \param[in] cb Invoke callback if positive
     886                 :            : //! \param[in] summeshid Mesh id (summed accross all chares)
     887                 :            : //! \details This function aggregates partial surface integrals across the
     888                 :            : //!   boundary faces of the whole problem. After this global sum a
     889                 :            : //!   non-zero vector result indicates a leak, e.g., a hole in the boundary,
     890                 :            : //!   which indicates an error in the boundary face data structures used to
     891                 :            : //!   compute the partial surface integrals.
     892                 :            : // *****************************************************************************
     893                 :            : {
     894                 :        109 :   auto meshid = tk::cref_find( m_meshid, static_cast<std::size_t>(summeshid) );
     895                 :            : 
     896                 :        218 :   std::stringstream err;
     897         [ -  + ]:        109 :   if (cb < 0.0) {
     898                 :            :     err << "Mesh boundary leaky after mesh refinement step; this is due to a "
     899                 :            :      "problem with updating the side sets used to specify boundary conditions "
     900         [ -  - ]:          0 :      "on faces: ";
     901         [ +  - ]:        109 :   } else if (cb > 0.0) {
     902                 :            :     err << "Mesh boundary leaky during initialization; this is due to "
     903                 :            :     "incorrect or incompletely specified boundary conditions for a given input "
     904         [ +  - ]:        109 :     "mesh: ";
     905                 :            :   }
     906                 :            : 
     907                 :            :   auto eps = 1.0e-10;
     908 [ +  - ][ +  - ]:        109 :   if (std::abs(sx) > eps || std::abs(sy) > eps || std::abs(sz) > eps) {
                 [ -  + ]
     909                 :            :     err << "Integral result must be a zero vector: " << std::setprecision(12) <<
     910                 :            :            std::abs(sx) << ", " << std::abs(sy) << ", " << std::abs(sz) <<
     911                 :            :            ", eps = " << eps;
     912 [ -  - ][ -  - ]:          0 :     Throw( err.str() );
         [ -  - ][ -  - ]
     913                 :            :   }
     914                 :            : 
     915 [ +  - ][ +  - ]:        109 :   if (cb > 0.0) m_scheme[meshid].ghosts().resizeComm();
     916                 :        109 : }
     917                 :            : 
     918                 :            : void
     919                 :        195 : Transporter::refined( std::size_t summeshid,
     920                 :            :                       std::size_t nelem,
     921                 :            :                       std::size_t npoin )
     922                 :            : // *****************************************************************************
     923                 :            : // Reduction target: all chares have refined their mesh
     924                 :            : //! \param[in] summeshid Mesh id (summed accross all Refiner chares)
     925                 :            : //! \param[in] nelem Total number of elements in mesh summed across the
     926                 :            : //!   distributed mesh
     927                 :            : //! \param[in] npoin Total number of mesh points summed across the distributed
     928                 :            : //!   mesh. Note that in parallel this is larger than the number of points in
     929                 :            : //!   the mesh, because the boundary nodes are multi-counted. But we only need
     930                 :            : //!   an equal or larger than npoin for Sorter::setup, so this is okay.
     931                 :            : // *****************************************************************************
     932                 :            : {
     933                 :        195 :   auto meshid = tk::cref_find( m_meshid, summeshid );
     934                 :            : 
     935                 :            :   // Store new number of elements for initially refined mesh
     936                 :        195 :   m_nelem[meshid] = nelem;
     937                 :            : 
     938                 :        195 :   m_sorter[meshid].doneInserting();
     939                 :        195 :   m_sorter[meshid].setup( npoin );
     940                 :        195 : }
     941                 :            : 
     942                 :            : void
     943                 :        195 : Transporter::queried( std::size_t meshid )
     944                 :            : // *****************************************************************************
     945                 :            : // Reduction target: all Sorter chares have queried their boundary edges
     946                 :            : //! \param[in] meshid Mesh id
     947                 :            : // *****************************************************************************
     948                 :            : {
     949                 :        195 :   m_sorter[meshid].response();
     950                 :        195 : }
     951                 :            : 
     952                 :            : void
     953                 :        195 : Transporter::responded( std::size_t meshid )
     954                 :            : // *****************************************************************************
     955                 :            : // Reduction target: all Sorter chares have responded with their boundary edges
     956                 :            : //! \param[in] meshid Mesh id
     957                 :            : // *****************************************************************************
     958                 :            : {
     959                 :        195 :   m_sorter[meshid].start();
     960                 :        195 : }
     961                 :            : 
     962                 :            : void
     963                 :        360 : Transporter::resized( std::size_t meshid )
     964                 :            : // *****************************************************************************
     965                 :            : // Reduction target: all worker chares have resized their own mesh data after
     966                 :            : // AMR or ALE
     967                 :            : //! \param[in] meshid Mesh id
     968                 :            : //! \note Only used for nodal schemes
     969                 :            : // *****************************************************************************
     970                 :            : {
     971                 :        360 :   m_scheme[meshid].disc().vol();
     972                 :        360 :   m_scheme[meshid].bcast< Scheme::lhs >();
     973                 :        360 : }
     974                 :            : 
     975                 :            : void
     976                 :        109 : Transporter::startEsup( std::size_t meshid )
     977                 :            : // *****************************************************************************
     978                 :            : // Reduction target: all worker chares have generated their own esup
     979                 :            : //! \param[in] meshid Mesh id
     980                 :            : //! \note Only used for cell-centered schemes
     981                 :            : // *****************************************************************************
     982                 :            : {
     983                 :        109 :   m_scheme[meshid].ghosts().nodeNeighSetup();
     984                 :        109 : }
     985                 :            : 
     986                 :            : void
     987                 :        195 : Transporter::discinserted( std::size_t meshid )
     988                 :            : // *****************************************************************************
     989                 :            : // Reduction target: all Discretization chares have been inserted
     990                 :            : //! \param[in] meshid Mesh id
     991                 :            : // *****************************************************************************
     992                 :            : {
     993                 :        195 :   m_scheme[meshid].disc().doneInserting();
     994                 :        195 : }
     995                 :            : 
     996                 :            : void
     997                 :        213 : Transporter::meshstat( const std::string& header ) const
     998                 :            : // *****************************************************************************
     999                 :            : // Print out mesh statistics
    1000                 :            : //! \param[in] header Section header
    1001                 :            : // *****************************************************************************
    1002                 :            : {
    1003                 :        213 :   auto print = printer();
    1004                 :            : 
    1005         [ +  - ]:        213 :   print.section( header );
    1006                 :            : 
    1007         [ +  + ]:        213 :   if (m_nelem.size() > 1) {
    1008 [ +  - ][ +  - ]:          4 :     print.item( "Number of tetrahedra (per mesh)",tk::parameters(m_nelem) );
         [ +  - ][ -  + ]
    1009 [ +  - ][ +  - ]:          4 :     print.item( "Number of points (per mesh)", tk::parameters(m_npoin) );
         [ +  - ][ -  + ]
    1010 [ +  - ][ +  - ]:          4 :     print.item( "Number of work units (per mesh)", tk::parameters(m_nchare) );
         [ +  - ][ -  + ]
    1011                 :            :   }
    1012                 :            : 
    1013         [ +  - ]:        213 :   print.item( "Total number of tetrahedra",
    1014         [ +  - ]:        426 :               std::accumulate( begin(m_nelem), end(m_nelem), 0UL ) );
    1015         [ +  - ]:        213 :   print.item( "Total number of points",
    1016         [ +  - ]:        426 :               std::accumulate( begin(m_npoin), end(m_npoin), 0UL ) );
    1017         [ +  - ]:        213 :   print.item( "Total number of work units",
    1018 [ +  - ][ +  - ]:        426 :               std::accumulate( begin(m_nchare), end(m_nchare), 0 ) );
    1019                 :            : 
    1020                 :            :   print.endsubsection();
    1021                 :        213 : }
    1022                 :            : 
    1023                 :            : bool
    1024                 :        390 : Transporter::need_linearsolver() const
    1025                 :            : // *****************************************************************************
    1026                 :            : //  Decide if we need a linear solver for ALE
    1027                 :            : //! \return True if ALE will neeed a linear solver
    1028                 :            : // *****************************************************************************
    1029                 :            : {
    1030                 :        390 :   auto smoother = g_inputdeck.get< tag::ale, tag::smoother >();
    1031                 :            : 
    1032         [ +  + ]:        390 :   if ( g_inputdeck.get< tag::ale, tag::ale >() and
    1033         [ +  + ]:         20 :        (smoother == ctr::MeshVelocitySmootherType::LAPLACE ||
    1034                 :            :         smoother == ctr::MeshVelocitySmootherType::HELMHOLTZ) )
    1035                 :            :   {
    1036                 :            :      return true;
    1037                 :            :   } else {
    1038                 :        378 :      return false;
    1039                 :            :   }
    1040                 :            : }
    1041                 :            : 
    1042                 :            : void
    1043                 :        195 : Transporter::disccreated( std::size_t summeshid, std::size_t npoin )
    1044                 :            : // *****************************************************************************
    1045                 :            : // Reduction target: all Discretization constructors have been called
    1046                 :            : //! \param[in] summeshid Mesh id (summed accross all chares)
    1047                 :            : //! \param[in] npoin Total number of mesh points (summed across all chares)
    1048                 :            : //!  Note that as opposed to npoin in refined(), this npoin is not
    1049                 :            : //!  multi-counted, and thus should be correct in parallel.
    1050                 :            : // *****************************************************************************
    1051                 :            : {
    1052                 :        195 :   auto meshid = tk::cref_find( m_meshid, summeshid );
    1053                 :            :   //std::cout << "Trans: " << meshid << " Transporter::disccreated()\n";
    1054                 :            : 
    1055                 :            :   // Update number of mesh points for mesh, since it may have been refined
    1056         [ +  + ]:        195 :   if (g_inputdeck.get< tag::amr, tag::t0ref >()) m_npoin[meshid] = npoin;
    1057                 :            : 
    1058         [ +  + ]:        195 :   if (++m_ndisc == m_nelem.size()) { // all Disc arrays have been created
    1059                 :        193 :     m_ndisc = 0;
    1060                 :        193 :     auto print = printer();
    1061         [ +  - ]:        193 :     m_progMesh.end( print );
    1062         [ +  + ]:        193 :     if (g_inputdeck.get< tag::amr, tag::t0ref >())
    1063 [ +  - ][ +  - ]:         40 :       meshstat( "Initially (t<0) refined mesh graph statistics" );
    1064                 :            :   }
    1065                 :            : 
    1066                 :        195 :   m_refiner[meshid].sendProxy();
    1067                 :            : 
    1068         [ +  + ]:        195 :   if (g_inputdeck.get< tag::ale, tag::ale >())
    1069                 :         10 :     m_scheme[meshid].ale().doneInserting();
    1070                 :            : 
    1071         [ +  + ]:        195 :   if (need_linearsolver())
    1072                 :          6 :     m_scheme[meshid].conjugategradients().doneInserting();
    1073                 :            : 
    1074                 :        195 :   m_scheme[meshid].disc().vol();
    1075                 :        195 : }
    1076                 :            : 
    1077                 :            : void
    1078                 :        195 : Transporter::workinserted( std::size_t meshid )
    1079                 :            : // *****************************************************************************
    1080                 :            : // Reduction target: all worker (derived discretization) chares have been
    1081                 :            : // inserted
    1082                 :            : //! \param[in] meshid Mesh id
    1083                 :            : // *****************************************************************************
    1084                 :            : {
    1085                 :        195 :   m_scheme[meshid].bcast< Scheme::doneInserting >();
    1086                 :        195 : }
    1087                 :            : 
    1088                 :            : void
    1089                 :        193 : Transporter::diagHeader()
    1090                 :            : // *****************************************************************************
    1091                 :            : // Configure and write diagnostics file header
    1092                 :            : // *****************************************************************************
    1093                 :            : {
    1094         [ +  + ]:        388 :   for (std::size_t m=0; m<m_input.size(); ++m) {
    1095                 :            : 
    1096                 :            :    // Output header for diagnostics output file
    1097 [ +  + ][ +  - ]:        199 :     auto mid = m_input.size() > 1 ? std::string( '.' + std::to_string(m) ) : "";
         [ -  + ][ +  - ]
                 [ -  - ]
    1098 [ +  + ][ -  - ]:        195 :     tk::DiagWriter dw( g_inputdeck.get< tag::cmd, tag::io, tag::diag >() + mid,
    1099                 :            :       g_inputdeck.get< tag::diagnostics, tag::format >(),
    1100 [ +  - ][ +  - ]:        195 :       g_inputdeck.get< tag::diagnostics, tag::precision >() );
    1101                 :            : 
    1102                 :            :     // Collect variables names for integral/diagnostics output
    1103                 :        195 :     std::vector< std::string > var;
    1104                 :        195 :     const auto scheme = g_inputdeck.get< tag::scheme >();
    1105         [ +  + ]:        195 :     if ( scheme == ctr::SchemeType::ALECG ||
    1106                 :            :          scheme == ctr::SchemeType::OversetFE )
    1107 [ +  + ][ +  - ]:        176 :       for (const auto& eq : g_cgpde) varnames( eq, var );
    1108                 :        109 :     else if ( scheme == ctr::SchemeType::DG ||
    1109                 :            :               scheme == ctr::SchemeType::P0P1 ||
    1110                 :            :               scheme == ctr::SchemeType::DGP1 ||
    1111         [ +  + ]:        109 :               scheme == ctr::SchemeType::DGP2 ||
    1112                 :            :               scheme == ctr::SchemeType::PDG )
    1113 [ +  + ][ +  - ]:        178 :       for (const auto& eq : g_dgpde) varnames( eq, var );
    1114         [ +  - ]:         20 :     else if (scheme == ctr::SchemeType::FV)
    1115 [ +  + ][ +  - ]:         40 :       for (const auto& eq : g_fvpde) varnames( eq, var );
    1116 [ -  - ][ -  - ]:          0 :     else Throw( "Diagnostics header not handled for discretization scheme" );
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
    1117                 :            : 
    1118         [ +  - ]:        195 :     const tk::ctr::Error opt;
    1119                 :        195 :     auto nv = var.size() / m_input.size();
    1120                 :        195 :     std::vector< std::string > d;
    1121                 :            : 
    1122                 :            :     // Add 'L2(var)' for all variables as those are always computed
    1123                 :            :     const auto& l2name = opt.name( tk::ctr::ErrorType::L2 );
    1124 [ +  + ][ +  - ]:        998 :     for (std::size_t i=0; i<nv; ++i) d.push_back( l2name + '(' + var[i] + ')' );
         [ +  - ][ +  - ]
         [ -  + ][ -  + ]
         [ -  - ][ -  - ]
    1125                 :            : 
    1126                 :            :     // Query user-requested diagnostics and augment diagnostics file header by
    1127                 :            :     // 'err(var)', where 'err' is the error type  configured, and var is the
    1128                 :            :     // variable computed, for all variables and all error types configured.
    1129                 :            :     const auto& err = g_inputdeck.get< tag::diagnostics, tag::error >();
    1130                 :        195 :     const auto& errname = opt.name( err );
    1131         [ +  + ]:        998 :     for (std::size_t i=0; i<nv; ++i)
    1132 [ +  - ][ +  - ]:       1606 :       d.push_back( errname + '(' + var[i] + "-IC)" );
         [ +  - ][ -  + ]
         [ -  + ][ -  - ]
                 [ -  - ]
    1133                 :            : 
    1134                 :            :     // Augment diagnostics variables by L2-norm of the residual and total energy
    1135                 :        195 :     if ( scheme == ctr::SchemeType::ALECG ||
    1136                 :        195 :          scheme == ctr::SchemeType::OversetFE ||
    1137         [ +  + ]:        195 :          scheme == ctr::SchemeType::FV )
    1138                 :            :     {
    1139 [ +  + ][ +  - ]:        562 :       for (std::size_t i=0; i<nv; ++i) d.push_back( "L2(d" + var[i] + ')' );
         [ +  - ][ -  + ]
                 [ -  - ]
    1140                 :            :     }
    1141         [ +  - ]:        195 :     d.push_back( "mE" );
    1142                 :            : 
    1143                 :            :     // Write diagnostics header
    1144         [ +  - ]:        195 :     dw.header( d );
    1145                 :            : 
    1146                 :            :   }
    1147                 :        193 : }
    1148                 :            : 
    1149                 :            : void
    1150                 :        109 : Transporter::doneInsertingGhosts(std::size_t meshid)
    1151                 :            : // *****************************************************************************
    1152                 :            : // Reduction target indicating all "ghosts" insertions are done
    1153                 :            : //! \param[in] meshid Mesh id
    1154                 :            : // *****************************************************************************
    1155                 :            : {
    1156                 :        109 :   m_scheme[meshid].ghosts().doneInserting();
    1157                 :        109 :   m_scheme[meshid].ghosts().startCommSetup();
    1158                 :        109 : }
    1159                 :            : 
    1160                 :            : void
    1161                 :        195 : Transporter::comfinal( std::size_t initial, std::size_t summeshid )
    1162                 :            : // *****************************************************************************
    1163                 :            : // Reduction target indicating that communication maps have been setup
    1164                 :            : //! \param[in] initial Sum of contributions from all chares. If larger than
    1165                 :            : //!    zero, we are during time stepping and if zero we are during setup.
    1166                 :            : //! \param[in] summeshid Mesh id (summed accross the distributed mesh)
    1167                 :            : // *****************************************************************************
    1168                 :            : // [Discretization-specific communication maps]
    1169                 :            : {
    1170                 :        195 :   auto meshid = tk::cref_find( m_meshid, static_cast<std::size_t>(summeshid) );
    1171                 :            : 
    1172         [ +  - ]:        195 :   if (initial > 0) {
    1173                 :        195 :     m_scheme[meshid].bcast< Scheme::setup >();
    1174                 :            :     // Turn on automatic load balancing
    1175         [ +  + ]:        195 :     if (++m_ncom == m_nelem.size()) { // all worker arrays have finished
    1176                 :        193 :       m_ncom = 0;
    1177                 :        193 :       auto print = printer();
    1178         [ +  - ]:        193 :       m_progWork.end( print );
    1179         [ +  - ]:        193 :       tk::CProxy_LBSwitch::ckNew();
    1180 [ +  - ][ +  - ]:        386 :       print.diag( "Load balancing on (if enabled in Charm++)" );
    1181                 :            :     }
    1182                 :            :   } else {
    1183                 :          0 :     m_scheme[meshid].bcast< Scheme::lhs >();
    1184                 :            :   }
    1185                 :        195 : }
    1186                 :            : // [Discretization-specific communication maps]
    1187                 :            : 
    1188                 :            : void
    1189                 :        555 : Transporter::totalvol( tk::real v, tk::real initial, tk::real summeshid )
    1190                 :            : // *****************************************************************************
    1191                 :            : // Reduction target summing total mesh volume across all workers
    1192                 :            : //! \param[in] v Mesh volume summed across the distributed mesh
    1193                 :            : //! \param[in] initial Sum of contributions from all chares. If larger than
    1194                 :            : //!    zero, we are during setup, if zero, during time stepping.
    1195                 :            : //! \param[in] summeshid Mesh id (summed accross the distributed mesh)
    1196                 :            : // *****************************************************************************
    1197                 :            : {
    1198                 :        555 :   auto meshid = tk::cref_find( m_meshid, static_cast<std::size_t>(summeshid) );
    1199                 :            : 
    1200         [ +  + ]:        555 :   m_meshvol[meshid] = v;
    1201                 :            : 
    1202         [ +  + ]:        555 :   if (initial > 0.0)   // during initialization
    1203                 :        195 :     m_scheme[meshid].disc().stat( v );
    1204                 :            :   else                  // during ALE or AMR
    1205                 :        360 :     m_scheme[meshid].bcast< Scheme::resized >();
    1206                 :        555 : }
    1207                 :            : 
    1208                 :            : void
    1209                 :        195 : Transporter::minstat( tk::real d0, tk::real d1, tk::real d2, tk::real rmeshid )
    1210                 :            : // *****************************************************************************
    1211                 :            : // Reduction target yielding minimum mesh statistcs across all workers
    1212                 :            : //! \param[in] d0 Minimum mesh statistics collected over all chares
    1213                 :            : //! \param[in] d1 Minimum mesh statistics collected over all chares
    1214                 :            : //! \param[in] d2 Minimum mesh statistics collected over all chares
    1215                 :            : //! \param[in] rmeshid Mesh id as a real
    1216                 :            : // *****************************************************************************
    1217                 :            : {
    1218                 :        195 :   auto meshid = static_cast<std::size_t>(rmeshid);
    1219                 :            : 
    1220                 :        195 :   m_minstat[meshid][0] = d0;  // minimum edge length
    1221                 :        195 :   m_minstat[meshid][1] = d1;  // minimum cell volume cubic root
    1222                 :        195 :   m_minstat[meshid][2] = d2;  // minimum number of cells on chare
    1223                 :            : 
    1224                 :        195 :   minstat_complete(meshid);
    1225                 :        195 : }
    1226                 :            : 
    1227                 :            : void
    1228                 :        195 : Transporter::maxstat( tk::real d0, tk::real d1, tk::real d2, tk::real rmeshid )
    1229                 :            : // *****************************************************************************
    1230                 :            : // Reduction target yielding the maximum mesh statistics across all workers
    1231                 :            : //! \param[in] d0 Maximum mesh statistics collected over all chares
    1232                 :            : //! \param[in] d1 Maximum mesh statistics collected over all chares
    1233                 :            : //! \param[in] d2 Maximum mesh statistics collected over all chares
    1234                 :            : //! \param[in] rmeshid Mesh id as a real
    1235                 :            : // *****************************************************************************
    1236                 :            : {
    1237                 :        195 :   auto meshid = static_cast<std::size_t>(rmeshid);
    1238                 :            : 
    1239                 :        195 :   m_maxstat[meshid][0] = d0;  // maximum edge length
    1240                 :        195 :   m_maxstat[meshid][1] = d1;  // maximum cell volume cubic root
    1241                 :        195 :   m_maxstat[meshid][2] = d2;  // maximum number of cells on chare
    1242                 :            : 
    1243                 :        195 :   maxstat_complete(meshid);
    1244                 :        195 : }
    1245                 :            : 
    1246                 :            : void
    1247                 :        195 : Transporter::sumstat( tk::real d0, tk::real d1, tk::real d2, tk::real d3,
    1248                 :            :                       tk::real d4, tk::real d5, tk::real summeshid )
    1249                 :            : // *****************************************************************************
    1250                 :            : // Reduction target yielding the sum mesh statistics across all workers
    1251                 :            : //! \param[in] d0 Sum mesh statistics collected over all chares
    1252                 :            : //! \param[in] d1 Sum mesh statistics collected over all chares
    1253                 :            : //! \param[in] d2 Sum mesh statistics collected over all chares
    1254                 :            : //! \param[in] d3 Sum mesh statistics collected over all chares
    1255                 :            : //! \param[in] d4 Sum mesh statistics collected over all chares
    1256                 :            : //! \param[in] d5 Sum mesh statistics collected over all chares
    1257                 :            : //! \param[in] summeshid Mesh id (summed accross the distributed mesh)
    1258                 :            : // *****************************************************************************
    1259                 :            : {
    1260                 :        195 :   auto meshid = tk::cref_find( m_meshid, static_cast<std::size_t>(summeshid) );
    1261                 :            : 
    1262                 :        195 :   m_avgstat[meshid][0] = d1 / d0;      // average edge length
    1263                 :        195 :   m_avgstat[meshid][1] = d3 / d2;      // average cell volume cubic root
    1264                 :        195 :   m_avgstat[meshid][2] = d5 / d4;      // average number of cells per chare
    1265                 :            : 
    1266                 :        195 :   sumstat_complete(meshid);
    1267                 :        195 : }
    1268                 :            : 
    1269                 :            : void
    1270         [ +  - ]:        195 : Transporter::pdfstat( CkReductionMsg* msg )
    1271                 :            : // *****************************************************************************
    1272                 :            : // Reduction target yielding PDF of mesh statistics across all workers
    1273                 :            : //! \param[in] msg Serialized PDF
    1274                 :            : // *****************************************************************************
    1275                 :            : {
    1276                 :            :   std::size_t meshid;
    1277                 :        195 :   std::vector< tk::UniPDF > pdf;
    1278                 :            : 
    1279                 :            :   // Deserialize final PDF
    1280         [ +  - ]:        195 :   PUP::fromMem creator( msg->getData() );
    1281                 :            :   creator | meshid;
    1282                 :            :   creator | pdf;
    1283                 :            :   delete msg;
    1284                 :            : 
    1285         [ +  - ]:        195 :   auto id = std::to_string(meshid);
    1286                 :            : 
    1287                 :            :   // Create new PDF file (overwrite if exists)
    1288 [ +  - ][ +  - ]:        390 :   tk::PDFWriter pdfe( "mesh_edge_pdf." + id + ".txt" );
         [ +  - ][ -  + ]
         [ -  - ][ -  - ]
    1289                 :            :   // Output edgelength PDF
    1290                 :            :   // cppcheck-suppress containerOutOfBounds
    1291                 :        195 :   pdfe.writeTxt( pdf[0],
    1292 [ +  - ][ +  - ]:        585 :                  tk::ctr::PDFInfo{ {"PDF"}, {}, {"edgelength"}, 0, 0.0 } );
         [ +  - ][ +  - ]
         [ +  + ][ -  + ]
         [ -  + ][ -  + ]
         [ -  - ][ -  - ]
                 [ -  - ]
    1293                 :            : 
    1294                 :            :   // Create new PDF file (overwrite if exists)
    1295 [ +  - ][ +  - ]:        390 :   tk::PDFWriter pdfv( "mesh_vol_pdf." + id + ".txt" );
         [ +  - ][ -  + ]
                 [ -  - ]
    1296                 :            :   // Output cell volume cubic root PDF
    1297                 :        195 :   pdfv.writeTxt( pdf[1],
    1298 [ +  - ][ +  - ]:        585 :                  tk::ctr::PDFInfo{ {"PDF"}, {}, {"V^{1/3}"}, 0, 0.0 } );
         [ +  - ][ +  - ]
         [ +  + ][ -  + ]
         [ -  + ][ -  + ]
         [ -  - ][ -  - ]
                 [ -  - ]
    1299                 :            : 
    1300                 :            :   // Create new PDF file (overwrite if exists)
    1301 [ +  - ][ +  - ]:        390 :   tk::PDFWriter pdfn( "mesh_ntet_pdf." + id + ".txt" );
         [ +  - ][ -  + ]
                 [ -  - ]
    1302                 :            :   // Output number of cells PDF
    1303                 :        195 :   pdfn.writeTxt( pdf[2],
    1304 [ +  - ][ +  - ]:        585 :                  tk::ctr::PDFInfo{ {"PDF"}, {}, {"ntets"}, 0, 0.0 } );
         [ +  - ][ +  - ]
         [ +  + ][ -  + ]
         [ -  + ][ -  + ]
         [ -  - ][ -  - ]
                 [ -  - ]
    1305                 :            : 
    1306         [ +  - ]:        195 :   pdfstat_complete(meshid);
    1307                 :        195 : }
    1308                 :            : 
    1309                 :            : void
    1310                 :        195 : Transporter::stat()
    1311                 :            : // *****************************************************************************
    1312                 :            : // Echo diagnostics on mesh statistics
    1313                 :            : // *****************************************************************************
    1314                 :            : {
    1315                 :        195 :   auto print = printer();
    1316                 :            : 
    1317         [ +  + ]:        195 :   if (++m_nstat == m_nelem.size()) {     // stats from all meshes have arrived
    1318                 :        193 :     m_nstat = 0;
    1319         [ +  + ]:        388 :     for (std::size_t i=0; i<m_nelem.size(); ++i) {
    1320         [ +  - ]:        195 :       print.diag(
    1321 [ +  - ][ +  - ]:        390 :         "Mesh " + std::to_string(i) +
         [ -  + ][ -  + ]
         [ -  + ][ -  - ]
         [ -  - ][ -  - ]
    1322 [ +  - ][ -  + ]:        390 :         " distribution statistics: min/max/avg(edgelength) = " +
                 [ -  - ]
    1323 [ +  - ][ +  - ]:        780 :         std::to_string( m_minstat[i][0] ) + " / " +
         [ +  - ][ -  + ]
         [ -  + ][ -  + ]
         [ -  - ][ -  - ]
                 [ -  - ]
    1324 [ +  - ][ +  - ]:        780 :         std::to_string( m_maxstat[i][0] ) + " / " +
         [ +  - ][ -  + ]
         [ -  + ][ -  + ]
         [ -  - ][ -  - ]
                 [ -  - ]
    1325 [ +  - ][ +  - ]:        780 :         std::to_string( m_avgstat[i][0] ) + ", " +
         [ +  - ][ -  + ]
         [ -  + ][ -  + ]
         [ -  - ][ -  - ]
                 [ -  - ]
    1326 [ +  - ][ -  + ]:        390 :         "min/max/avg(V^{1/3}) = " +
                 [ -  - ]
    1327 [ +  - ][ +  - ]:        780 :         std::to_string( m_minstat[i][1] ) + " / " +
         [ +  - ][ -  + ]
         [ -  + ][ -  + ]
         [ -  - ][ -  - ]
                 [ -  - ]
    1328 [ +  - ][ +  - ]:        780 :         std::to_string( m_maxstat[i][1] ) + " / " +
         [ +  - ][ -  + ]
         [ -  + ][ -  + ]
         [ -  - ][ -  - ]
                 [ -  - ]
    1329 [ +  - ][ +  - ]:        780 :         std::to_string( m_avgstat[i][1] ) + ", " +
         [ +  - ][ -  + ]
         [ -  + ][ -  + ]
         [ -  - ][ -  - ]
                 [ -  - ]
    1330 [ +  - ][ -  + ]:        390 :         "min/max/avg(ntets) = " +
                 [ -  - ]
    1331 [ +  - ][ +  - ]:        780 :         std::to_string( static_cast<std::size_t>(m_minstat[i][2]) ) + " / " +
         [ +  - ][ -  + ]
         [ -  + ][ -  + ]
         [ -  - ][ -  - ]
                 [ -  - ]
    1332 [ +  - ][ +  - ]:        780 :         std::to_string( static_cast<std::size_t>(m_maxstat[i][2]) ) + " / " +
         [ +  - ][ -  + ]
         [ -  + ][ -  + ]
         [ -  - ][ -  - ]
                 [ -  - ]
    1333         [ +  - ]:        390 :         std::to_string( static_cast<std::size_t>(m_avgstat[i][2]) ) );
    1334                 :            :     }
    1335                 :            : 
    1336                 :            :     // Print out time integration header to screen
    1337         [ +  - ]:        193 :     inthead( print );
    1338                 :            : 
    1339                 :        193 :     m_progWork.start( print, "Preparing workers",
    1340         [ +  - ]:        193 :       {{ m_nchare[0], m_nchare[0], m_nchare[0], m_nchare[0], m_nchare[0] }} );
    1341                 :            : 
    1342                 :            :     // Create "derived-class" workers
    1343 [ +  + ][ +  - ]:        388 :     for (std::size_t i=0; i<m_nelem.size(); ++i) m_sorter[i].createWorkers();
    1344                 :            :   }
    1345                 :        195 : }
    1346                 :            : 
    1347                 :            : void
    1348                 :        195 : Transporter::boxvol( tk::real* meshdata, int n )
    1349                 :            : // *****************************************************************************
    1350                 :            : // Reduction target computing total volume of IC mesh blocks and box
    1351                 :            : //! \param[in] meshdata Vector containing volumes of all IC mesh blocks,
    1352                 :            : //!   volume of IC box, and mesh id as a real summed across the distributed mesh
    1353                 :            : //! \param[in] n Size of vector, automatically computed by Charm
    1354                 :            : // *****************************************************************************
    1355                 :            : {
    1356                 :            :   Assert(n>=2, "mesh data size incorrect");
    1357                 :            : 
    1358                 :            :   // extract summed mesh id from vector
    1359                 :        195 :   tk::real summeshid = meshdata[n-1];
    1360                 :        195 :   auto meshid = tk::cref_find( m_meshid, static_cast<std::size_t>(summeshid) );
    1361                 :            : 
    1362                 :            :   // extract summed box volume from vector
    1363                 :        195 :   tk::real v = meshdata[n-2];
    1364 [ +  + ][ +  - ]:        199 :   if (v > 0.0) printer().diag( "Box IC volume: " + std::to_string(v) );
         [ +  - ][ +  - ]
         [ -  + ][ -  - ]
    1365                 :            : 
    1366                 :            :   // extract summed mesh block volumes from the vector
    1367                 :            :   std::vector< tk::real > blockvols;
    1368         [ -  + ]:        195 :   for (std::size_t blid=0; blid<(static_cast<std::size_t>(n)-2); ++blid) {
    1369         [ -  - ]:          0 :     blockvols.push_back(meshdata[blid]);
    1370         [ -  - ]:          0 :     if (blockvols[blid] > 0.0)
    1371 [ -  - ][ -  - ]:          0 :       printer().diag( "Mesh block " + std::to_string(blid) +
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
                 [ -  - ]
    1372 [ -  - ][ -  - ]:          0 :         " discrete volume: " + std::to_string(blockvols[blid]) );
         [ -  - ][ -  - ]
    1373                 :            :   }
    1374                 :            : 
    1375         [ +  - ]:        195 :   m_scheme[meshid].bcast< Scheme::box >( v, blockvols );
    1376                 :        195 : }
    1377                 :            : 
    1378                 :            : void
    1379                 :        310 : Transporter::solutionTransferred()
    1380                 :            : // *****************************************************************************
    1381                 :            : // Reduction target broadcasting to Schemes after mesh transfer
    1382                 :            : // *****************************************************************************
    1383                 :            : {
    1384         [ +  + ]:        310 :   if (++m_ntrans == m_nelem.size()) {    // all meshes have been loaded
    1385                 :        155 :     m_ntrans = 0;
    1386         [ +  + ]:        465 :     for (auto& m : m_scheme) m.bcast< Scheme::transferSol >();
    1387                 :            :   }
    1388                 :        310 : }
    1389                 :            : 
    1390                 :            : void
    1391                 :        352 : Transporter::minDtAcrossMeshes( tk::real* reducndata, [[maybe_unused]] int n )
    1392                 :            : // *****************************************************************************
    1393                 :            : // Reduction target that computes minimum timestep across all meshes
    1394                 :            : //! \param[in] reducndata Vector containing minimum values of dt and mesh-moved
    1395                 :            : //!   flags, collected across all meshes
    1396                 :            : //! \param[in] n Size of vector, automatically computed by Charm
    1397                 :            : // *****************************************************************************
    1398                 :            : {
    1399                 :            :   Assert(static_cast<std::size_t>(n-1) == m_nelem.size(),
    1400                 :            :     "Incorrectly sized reduction vector");
    1401                 :        352 :   m_dtmsh.push_back(reducndata[0]);
    1402                 :            : 
    1403         [ +  + ]:        352 :   if (++m_ndtmsh == m_nelem.size()) {    // all meshes have been loaded
    1404                 :            :     Assert(m_dtmsh.size() == m_nelem.size(), "Incorrect size of dtmsh");
    1405                 :            : 
    1406                 :            :     // compute minimum dt across meshes
    1407                 :        301 :     tk::real dt = std::numeric_limits< tk::real >::max();
    1408 [ +  + ][ +  + ]:        653 :     for (auto idt : m_dtmsh) dt = std::min(dt, idt);
    1409                 :            : 
    1410                 :            :     // clear dt-vector and counter
    1411                 :            :     m_dtmsh.clear();
    1412                 :        301 :     m_ndtmsh = 0;
    1413                 :            : 
    1414                 :            :     // broadcast to advance time step
    1415                 :            :     std::size_t ic(0);
    1416         [ +  + ]:        653 :     for (auto& m : m_scheme) {
    1417                 :        352 :       m.bcast< Scheme::advance >( dt, reducndata[ic+1] );
    1418                 :            :       ++ic;
    1419                 :            :     }
    1420                 :            :   }
    1421                 :        352 : }
    1422                 :            : 
    1423                 :            : void
    1424                 :        195 : Transporter::inthead( const InciterPrint& print )
    1425                 :            : // *****************************************************************************
    1426                 :            : // Print out time integration header to screen
    1427                 :            : //! \param[in] print Pretty printer object to use for printing
    1428                 :            : // *****************************************************************************
    1429                 :            : {
    1430                 :        195 :   auto refined = g_inputdeck.get< tag::field_output, tag::refined >();
    1431                 :        195 :   const auto scheme = g_inputdeck.get< tag::scheme >();
    1432         [ -  + ]:        195 :   if (refined && scheme == ctr::SchemeType::DG) {
    1433                 :          0 :     printer() << "\n>>> WARNING: Ignoring refined field output for DG(P0)\n\n";
    1434                 :            :     refined = false;
    1435                 :            :   }
    1436                 :            : 
    1437 [ +  - ][ +  - ]:        780 :   print.inthead( "Time integration", "Navier-Stokes solver",
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
    1438                 :            :   "Legend: it - iteration count\n"
    1439                 :            :   "         t - physics time\n"
    1440                 :            :   "        dt - physics time step size\n"
    1441                 :            :   "       ETE - estimated wall-clock time elapsed (h:m:s)\n"
    1442                 :            :   "       ETA - estimated wall-clock time for accomplishment (h:m:s)\n"
    1443                 :            :   "       EGT - estimated grind wall-clock time (ms/timestep)\n"
    1444                 :            :   "       flg - status flags, legend:\n"
    1445 [ +  + ][ +  - ]:        582 :   "             f - " + std::string(refined ? "refined " : "")
         [ +  - ][ -  + ]
         [ +  - ][ -  - ]
    1446 [ +  - ][ -  + ]:        390 :                       + "field (volume and surface)\n"
                 [ -  - ]
    1447                 :            :   "             d - diagnostics\n"
    1448                 :            :   "             t - physics time history\n"
    1449                 :            :   "             h - h-refinement\n"
    1450                 :            :   "             l - load balancing\n"
    1451                 :            :   "             r - checkpoint\n"
    1452                 :            :   "             a - ALE mesh velocity linear solver did not converge\n",
    1453                 :            :   "\n      it             t            dt        ETE        ETA        EGT  flg\n"
    1454                 :            :     " -------------------------------------------------------------------------\n" );
    1455                 :        195 : }
    1456                 :            : 
    1457                 :            : void
    1458         [ +  - ]:       3373 : Transporter::diagnostics( CkReductionMsg* msg )
    1459                 :            : // *****************************************************************************
    1460                 :            : // Reduction target optionally collecting diagnostics, e.g., residuals
    1461                 :            : //! \param[in] msg Serialized diagnostics vector aggregated across all PEs
    1462                 :            : //! \note Only used for nodal schemes
    1463                 :            : // *****************************************************************************
    1464                 :            : {
    1465                 :            :   std::size_t meshid, ncomp;
    1466                 :       3373 :   std::vector< std::vector< tk::real > > d;
    1467                 :            : 
    1468                 :            :   // Deserialize diagnostics vector
    1469         [ +  - ]:       3373 :   PUP::fromMem creator( msg->getData() );
    1470                 :            :   creator | meshid;
    1471                 :            :   creator | ncomp;
    1472                 :            :   creator | d;
    1473                 :            :   delete msg;
    1474                 :            : 
    1475         [ +  - ]:       3373 :   auto id = std::to_string(meshid);
    1476                 :            : 
    1477                 :            :   Assert( ncomp > 0, "Number of scalar components must be positive");
    1478                 :            :   Assert( d.size() == NUMDIAG, "Diagnostics vector size mismatch" );
    1479                 :            : 
    1480         [ +  + ]:      30357 :   for (std::size_t i=0; i<d.size(); ++i)
    1481                 :            :      Assert( d[i].size() == ncomp, "Size mismatch at final stage of "
    1482                 :            :              "diagnostics aggregation for mesh " + id );
    1483                 :            : 
    1484                 :            :   // Allocate storage for those diagnostics that are always computed
    1485 [ +  - ][ -  - ]:       3373 :   std::vector< tk::real > diag( ncomp, 0.0 );
    1486                 :            : 
    1487                 :            :   // Finish computing diagnostics
    1488         [ +  + ]:      18273 :   for (std::size_t i=0; i<d[L2SOL].size(); ++i)
    1489                 :      14900 :     diag[i] = sqrt( d[L2SOL][i] / m_meshvol[meshid] );
    1490                 :            :   
    1491                 :            :   // Query user-requested error types to output
    1492                 :            :   const auto& error = g_inputdeck.get< tag::diagnostics, tag::error >();
    1493                 :            : 
    1494                 :            :   decltype(ncomp) n = 0;
    1495                 :            :   n += ncomp;
    1496         [ +  + ]:       3373 :   if (error == tk::ctr::ErrorType::L2) {
    1497                 :            :    // Finish computing the L2 norm of the numerical - analytical solution
    1498         [ +  + ]:      18249 :    for (std::size_t i=0; i<d[L2ERR].size(); ++i)
    1499         [ +  - ]:      14888 :      diag.push_back( sqrt( d[L2ERR][i] / m_meshvol[meshid] ) );
    1500         [ +  - ]:         12 :   } else if (error == tk::ctr::ErrorType::LINF) {
    1501                 :            :     // Finish computing the Linf norm of the numerical - analytical solution
    1502         [ +  + ]:         24 :     for (std::size_t i=0; i<d[LINFERR].size(); ++i)
    1503         [ +  - ]:         12 :       diag.push_back( d[LINFERR][i] );
    1504                 :            :   }
    1505                 :            : 
    1506                 :            :   // Finish computing the L2 norm of the residual and append
    1507                 :       3373 :   const auto scheme = g_inputdeck.get< tag::scheme >();
    1508 [ +  - ][ -  - ]:       3373 :   std::vector< tk::real > l2res( d[L2RES].size(), 0.0 );
    1509         [ +  + ]:       3373 :   if (scheme == ctr::SchemeType::ALECG || scheme == ctr::SchemeType::OversetFE) {
    1510         [ +  + ]:       6514 :     for (std::size_t i=0; i<d[L2RES].size(); ++i) {
    1511                 :       5029 :       l2res[i] = std::sqrt( d[L2RES][i] / m_meshvol[meshid] );
    1512         [ +  - ]:       5029 :       diag.push_back( l2res[i] );
    1513                 :            :     }
    1514                 :            :   }
    1515         [ +  + ]:       1888 :   else if (scheme == ctr::SchemeType::FV) {
    1516         [ +  + ]:        828 :     for (std::size_t i=0; i<d[L2RES].size(); ++i) {
    1517                 :        756 :       l2res[i] = std::sqrt( d[L2RES][i] );
    1518         [ +  - ]:        756 :       diag.push_back( l2res[i] );
    1519                 :            :     }
    1520                 :            :   }
    1521                 :            : 
    1522                 :            :   // Append total energy
    1523         [ +  - ]:       3373 :   diag.push_back( d[TOTALSOL][0] );
    1524                 :            : 
    1525                 :            :   // Append diagnostics file at selected times
    1526                 :            :   auto filename = g_inputdeck.get< tag::cmd, tag::io, tag::diag >();
    1527 [ +  + ][ +  - ]:       3385 :   if (m_nelem.size() > 1) filename += '.' + id;
                 [ -  - ]
    1528                 :            :   tk::DiagWriter dw( filename,
    1529                 :            :     g_inputdeck.get< tag::diagnostics, tag::format >(),
    1530                 :            :     g_inputdeck.get< tag::diagnostics, tag::precision >(),
    1531         [ +  - ]:       3373 :     std::ios_base::app );
    1532         [ +  - ]:       3373 :   dw.diag( static_cast<uint64_t>(d[ITER][0]), d[TIME][0], d[DT][0], diag );
    1533                 :            : 
    1534                 :            :   // Continue time step
    1535         [ +  - ]:       3373 :   m_scheme[meshid].bcast< Scheme::refine >( l2res );
    1536                 :       3373 : }
    1537                 :            : 
    1538                 :            : void
    1539                 :        197 : Transporter::resume()
    1540                 :            : // *****************************************************************************
    1541                 :            : // Resume execution from checkpoint/restart files
    1542                 :            : //! \details This is invoked by Charm++ after the checkpoint is done, as well as
    1543                 :            : //!   when the restart (returning from a checkpoint) is complete
    1544                 :            : // *****************************************************************************
    1545                 :            : {
    1546         [ +  + ]:        197 :   if (std::any_of(begin(m_finished), end(m_finished), [](auto f){return !f;})) {
    1547                 :            :     // If just restarted from a checkpoint, Main( CkMigrateMessage* msg ) has
    1548                 :            :     // increased nrestart in g_inputdeck, but only on PE 0, so broadcast.
    1549                 :          2 :     auto nrestart = g_inputdeck.get< tag::cmd, tag::io, tag::nrestart >();
    1550         [ +  + ]:          4 :     for (std::size_t i=0; i<m_nelem.size(); ++i)
    1551                 :          2 :       m_scheme[i].bcast< Scheme::evalLB >( nrestart );
    1552                 :            :   } else
    1553                 :        195 :     mainProxy.finalize();
    1554                 :        197 : }
    1555                 :            : 
    1556                 :            : void
    1557                 :        197 : Transporter::checkpoint( std::size_t finished, std::size_t meshid )
    1558                 :            : // *****************************************************************************
    1559                 :            : // Save checkpoint/restart files
    1560                 :            : //! \param[in] finished Nonzero if finished with time stepping
    1561                 :            : //! \param[in] meshid Mesh id
    1562                 :            : // *****************************************************************************
    1563                 :            : {
    1564         [ +  + ]:        197 :   m_finished[meshid] = finished;
    1565                 :            : 
    1566         [ +  + ]:        197 :   if (++m_nchk == m_nelem.size()) { // all worker arrays have checkpointed
    1567                 :        195 :     m_nchk = 0;
    1568         [ +  + ]:        195 :     if (not g_inputdeck.get< tag::cmd, tag::benchmark >()) {
    1569                 :            :       const auto& restart = g_inputdeck.get< tag::cmd, tag::io, tag::restart >();
    1570                 :        123 :       CkCallback res( CkIndex_Transporter::resume(), thisProxy );
    1571         [ +  - ]:        123 :       CkStartCheckpoint( restart.c_str(), res );
    1572                 :            :     } else {
    1573                 :         72 :       resume();
    1574                 :            :     }
    1575                 :            :   }
    1576                 :        197 : }
    1577                 :            : 
    1578                 :            : void
    1579                 :        197 : Transporter::finish( std::size_t meshid )
    1580                 :            : // *****************************************************************************
    1581                 :            : // Normal finish of time stepping
    1582                 :            : //! \param[in] meshid Mesh id
    1583                 :            : // *****************************************************************************
    1584                 :            : {
    1585                 :        197 :   checkpoint( /* finished = */ 1, meshid );
    1586                 :        197 : }
    1587                 :            : 
    1588                 :            : #include "NoWarning/transporter.def.h"

Generated by: LCOV version 1.14