Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-22 10:31:24

0001 //----------------------------------*-C++-*----------------------------------//
0002 // Copyright 2022-2024 UT-Battelle, LLC, and other Celeritas developers.
0003 // See the top-level COPYRIGHT file for details.
0004 // SPDX-License-Identifier: (Apache-2.0 OR MIT)
0005 //---------------------------------------------------------------------------//
0006 //! \file celeritas/io/ImportedElementalMapLoader.hh
0007 //---------------------------------------------------------------------------//
0008 #pragma once
0009 
0010 #include <map>
0011 
0012 #include "corecel/Assert.hh"
0013 #include "celeritas/phys/AtomicNumber.hh"
0014 
0015 namespace celeritas
0016 {
0017 //---------------------------------------------------------------------------//
0018 /*!
0019  * Load ImportT data, mapped by integers for each element.
0020  *
0021  * This is used for Seltzer-Berger, LivermorePE, and other data stored by
0022  * element in \c ImportData.
0023  */
0024 template<class T>
0025 struct ImportedElementalMapLoader
0026 {
0027     std::map<int, T> const& tables;
0028 
0029     inline T operator()(AtomicNumber z) const;
0030 };
0031 
0032 //---------------------------------------------------------------------------//
0033 // INLINE HELPER FUNCTIONS
0034 //---------------------------------------------------------------------------//
0035 /*!
0036  * Helper function to construct an ImportedElementalMapLoader.
0037  */
0038 template<class T>
0039 inline ImportedElementalMapLoader<T>
0040 make_imported_element_loader(std::map<int, T> const& data)
0041 {
0042     return {data};
0043 }
0044 
0045 //---------------------------------------------------------------------------//
0046 // INLINE DEFINITIONS
0047 //---------------------------------------------------------------------------//
0048 /*!
0049  * Construct with defaults.
0050  */
0051 template<class T>
0052 T ImportedElementalMapLoader<T>::operator()(AtomicNumber z) const
0053 {
0054     CELER_EXPECT(z);
0055     auto iter = tables.find(z.unchecked_get());
0056     CELER_VALIDATE(iter != tables.end(),
0057                    << "missing imported data for Z=" << z.get());
0058     return iter->second;
0059 }
0060 
0061 //---------------------------------------------------------------------------//
0062 }  // namespace celeritas