Back to home page

EIC code displayed by LXR

 
 

    


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

0001 //----------------------------------*-C++-*----------------------------------//
0002 // Copyright 2021-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/grid/ValueGridInserter.hh
0007 //---------------------------------------------------------------------------//
0008 #pragma once
0009 
0010 #include <utility>
0011 #include <vector>
0012 
0013 #include "corecel/Types.hh"
0014 #include "corecel/cont/Span.hh"
0015 #include "corecel/data/Collection.hh"
0016 #include "corecel/data/CollectionBuilder.hh"
0017 #include "corecel/grid/UniformGridData.hh"
0018 #include "celeritas/Types.hh"
0019 
0020 #include "XsGridData.hh"
0021 
0022 namespace celeritas
0023 {
0024 //---------------------------------------------------------------------------//
0025 /*!
0026  * Manage data and help construction of physics value grids.
0027  *
0028  * Currently this only constructs a single value grid datatype, the
0029  * XsGridData, but with this framework (virtual \c
0030  * ValueGridXsBuilder::build method taking an instance of this class) it can be
0031  * extended to build additional grid types as well.
0032  *
0033  * \code
0034     ValueGridInserter insert(&data.host.values, &data.host.grids);
0035     insert(uniform_grid, values);
0036     store.push_back(host_ptrs);
0037     store.copy_to_device();
0038    \endcode
0039  */
0040 class ValueGridInserter
0041 {
0042   public:
0043     //!@{
0044     //! \name Type aliases
0045     using RealCollection
0046         = Collection<real_type, Ownership::value, MemSpace::host>;
0047     using XsGridCollection
0048         = Collection<XsGridData, Ownership::value, MemSpace::host>;
0049     using SpanConstDbl = Span<double const>;
0050     using XsIndex = ItemId<XsGridData>;
0051     //!@}
0052 
0053   public:
0054     // Construct with a reference to mutable host data
0055     ValueGridInserter(RealCollection* real_data, XsGridCollection* xs_grid);
0056 
0057     // Add a grid of xs-like data
0058     XsIndex operator()(UniformGridData const& log_grid,
0059                        size_type prime_index,
0060                        SpanConstDbl values);
0061 
0062     // Add a grid of uniform log-grid data
0063     XsIndex operator()(UniformGridData const& log_grid, SpanConstDbl values);
0064 
0065   private:
0066     CollectionBuilder<real_type, MemSpace::host, ItemId<real_type>> values_;
0067     CollectionBuilder<XsGridData, MemSpace::host, ItemId<XsGridData>> xs_grids_;
0068 };
0069 
0070 //---------------------------------------------------------------------------//
0071 }  // namespace celeritas