LCOV - code coverage report
Current view: top level - include/other - ThreadedRecoilLoopBase.h (source / functions) Hit Total Coverage
Test: idaholab/magpie: 5710af Lines: 2 2 100.0 %
Date: 2025-07-21 23:34:39 Functions: 1 2 50.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /**********************************************************************/
       2             : /*                     DO NOT MODIFY THIS HEADER                      */
       3             : /* MAGPIE - Mesoscale Atomistic Glue Program for Integrated Execution */
       4             : /*                                                                    */
       5             : /*            Copyright 2017 Battelle Energy Alliance, LLC            */
       6             : /*                        ALL RIGHTS RESERVED                         */
       7             : /**********************************************************************/
       8             : 
       9             : #pragma once
      10             : 
      11             : #include "MooseMyTRIMMaterial.h"
      12             : #include "MyTRIMRasterizer.h"
      13             : #include "ParallelUniqueId.h"
      14             : #include "PointListAdaptor.h"
      15             : 
      16             : #include "mytrim/simconf.h"
      17             : 
      18             : #include "libmesh/point_locator_base.h"
      19             : #include "libmesh/nanoflann.hpp"
      20             : 
      21             : class MooseMesh;
      22             : 
      23             : typedef StoredRange<std::vector<MyTRIM_NS::IonBase>::const_iterator, MyTRIM_NS::IonBase> PKARange;
      24             : 
      25             : /**
      26             :  * MyTRIM simulation threaded loop for recoil calculation. Results are stored as
      27             :  * point lists for use with DiracKernel objects.
      28             :  */
      29             : class ThreadedRecoilLoopBase
      30             : {
      31             : public:
      32             :   ThreadedRecoilLoopBase(const MyTRIMRasterizer &, const MooseMesh &);
      33             : 
      34             :   /// Splitting constructor
      35             :   ThreadedRecoilLoopBase(const ThreadedRecoilLoopBase & x, Threads::split split);
      36             : 
      37         396 :   virtual ~ThreadedRecoilLoopBase() {}
      38             : 
      39             :   /// parens operator with the code that is executed in threads
      40             :   void operator()(const PKARange & range);
      41             : 
      42             :   struct MyTRIMDefectBufferItem
      43             :   {
      44             :     MyTRIMDefectBufferItem(Point pt, unsigned int var, Real w = 1)
      45     8589414 :       : point(pt), variable_id(var), weight(w)
      46             :     {
      47             :     }
      48             : 
      49             :     Point point;
      50             :     unsigned int variable_id;
      51             :     Real weight;
      52             :   };
      53             : 
      54             : #ifdef GSL_ENABLED
      55             :   /// adds an NRT entry using provided number densities
      56             :   unsigned int addNRTEntry(const std::vector<Real> & number_fractions);
      57             : 
      58             :   /// given a vector of number densities finds the index of the NRT entry w/ smallest distance
      59             :   void findBestNRTMatch(const std::vector<Real> & number_fractions,
      60             :                         unsigned int & index,
      61             :                         Real & distance) const;
      62             : #endif // GSL_ENABLED
      63             : 
      64             :   /// defect type enum (vacancies, interstitials, incoming and outgoing replacements, and energy deposition)
      65             :   enum DefectType
      66             :   {
      67             :     NONE = -1,
      68             :     VACANCY = 0,
      69             :     INTERSTITIAL,
      70             :     REPLACEMENT_IN,
      71             :     REPLACEMENT_OUT,
      72             :     N_DEFECTS,
      73             :     ENERGY_DEPOSITION = 5
      74             :   };
      75             : 
      76             : protected:
      77             :   /// add an interstitial or vacancy to the result list
      78             :   virtual void
      79             :   addDefectToResult(const Point & p, unsigned int var, Real weight, DefectType type) = 0;
      80             : 
      81             :   /// add deposited energy to the result list
      82             :   virtual void addEnergyToResult(const Point & p, Real edep) = 0;
      83             : 
      84             :   /// rasterizer to manage the sample data
      85             :   const MyTRIMRasterizer & _rasterizer;
      86             : 
      87             :   /// trim simulation parameters
      88             :   const MyTRIMRasterizer::TrimParameters & _trim_parameters;
      89             : 
      90             :   /// number of elements in the TRIM simulation
      91             :   unsigned int _nvars;
      92             : 
      93             :   /// The Mesh we're using
      94             :   const MooseMesh & _mesh;
      95             : 
      96             :   /// dimension of the mesh
      97             :   const unsigned int _dim;
      98             : 
      99             :   /// point locator to use
     100             :   std::unique_ptr<PointLocatorBase> _pl;
     101             : 
     102             :   /// internal TRIM simulation status object
     103             :   MyTRIM_NS::SimconfType _simconf;
     104             : 
     105             :   /// ID number of the current thread
     106             :   THREAD_ID _tid;
     107             : 
     108             : #ifdef GSL_ENABLED
     109             :   /// polyatomic NRT data
     110             :   std::vector<std::unique_ptr<PolyatomicDisplacementFunction>> _pa_nrt;
     111             : 
     112             :   /// derivative information for NRT data
     113             :   std::vector<std::unique_ptr<PolyatomicDisplacementDerivativeFunction>> _pa_derivative_nrt;
     114             : #endif // GSL_ENABLED
     115             : 
     116             : private:
     117             :   ///@{ Buffer vacancies and interstitials from the same cascade for instantaneous recombination
     118             :   std::vector<MyTRIMDefectBufferItem> _vacancy_buffer;
     119             :   std::vector<MyTRIMDefectBufferItem> _interstitial_buffer;
     120             :   ///@}
     121             : 
     122             :   /// add an interstitial to the defect buffer
     123             :   void addInterstitialToBuffer(const Point & p, unsigned int var);
     124             : 
     125             :   /// add a vacancy to the defect buffer
     126             :   void addVacancyToBuffer(const Point & p, unsigned int var);
     127             : 
     128             :   using KDTreeType = nanoflann::KDTreeSingleIndexAdaptor<
     129             :       nanoflann::L2_Simple_Adaptor<Real, PointListAdaptor<MyTRIMDefectBufferItem>>,
     130             :       PointListAdaptor<MyTRIMDefectBufferItem>,
     131             :       LIBMESH_DIM,
     132             :       std::size_t>;
     133             : };

Generated by: LCOV version 1.14