Back to home page

EIC code displayed by LXR

 
 

    


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

0001 //----------------------------------*-C++-*----------------------------------//
0002 // Copyright 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/TwodGridBuilder.hh
0007 //---------------------------------------------------------------------------//
0008 #pragma once
0009 
0010 #include "corecel/data/Collection.hh"
0011 #include "corecel/data/CollectionBuilder.hh"
0012 #include "corecel/data/DedupeCollectionBuilder.hh"
0013 #include "corecel/grid/TwodGridData.hh"
0014 
0015 namespace celeritas
0016 {
0017 //---------------------------------------------------------------------------//
0018 /*!
0019  * Construct a generic 2D grid.
0020  *
0021  * This uses a deduplicating inserter for real values to improve cacheing.
0022  */
0023 class TwodGridBuilder
0024 {
0025   public:
0026     //!@{
0027     //! \name Type aliases
0028     template<class T>
0029     using Items = Collection<T, Ownership::value, MemSpace::host>;
0030     using TwodGrid = TwodGridData;
0031     using SpanConstFlt = Span<float const>;
0032     using SpanConstDbl = Span<double const>;
0033     //!@}
0034 
0035   public:
0036     // Construct with pointers to data that will be modified
0037     explicit TwodGridBuilder(Items<real_type>* reals);
0038 
0039     // Add a 2D grid of generic data with linear interpolation
0040     TwodGrid
0041     operator()(SpanConstFlt grid_x, SpanConstFlt grid_y, SpanConstFlt values);
0042 
0043     // Add a 2D grid of generic data with linear interpolation
0044     TwodGrid
0045     operator()(SpanConstDbl grid_x, SpanConstDbl grid_y, SpanConstDbl values);
0046 
0047   private:
0048     DedupeCollectionBuilder<real_type> reals_;
0049 
0050     // Insert with floating point conversion if needed
0051     template<class T>
0052     TwodGrid insert_impl(Span<T const> grid_x,
0053                          Span<T const> grid_y,
0054                          Span<T const> values);
0055 };
0056 
0057 //---------------------------------------------------------------------------//
0058 }  // namespace celeritas