Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-17 08:53:40

0001 //------------------------------- -*- C++ -*- -------------------------------//
0002 // Copyright Celeritas contributors: see top-level COPYRIGHT file for details
0003 // SPDX-License-Identifier: (Apache-2.0 OR MIT)
0004 //---------------------------------------------------------------------------//
0005 //! \file celeritas/io/ImportDataTrimmer.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include <map>
0010 #include <vector>
0011 
0012 #include "corecel/math/NumericLimits.hh"
0013 #include "celeritas/inp/Grid.hh"
0014 
0015 #include "ImportData.hh"
0016 
0017 namespace celeritas
0018 {
0019 //---------------------------------------------------------------------------//
0020 /*!
0021  * Reduce the amount of imported/exported data for testing.
0022  */
0023 class ImportDataTrimmer
0024 {
0025   public:
0026     struct Input
0027     {
0028         //! Maximum number of elements in a vector (approximate)
0029         std::size_t max_size{numeric_limits<std::size_t>::max()};
0030 
0031         //! Remove materials/elements which might affect the problem
0032         bool materials{false};
0033         //! Reduce the number of physics models and processes
0034         bool physics{false};
0035         //! Reduce the MuPPET table fidelity
0036         bool mupp{false};
0037     };
0038 
0039   public:
0040     // Construct with a unit system
0041     explicit ImportDataTrimmer(Input const& inp);
0042 
0043     //!@{
0044     //! Trim imported data
0045     void operator()(ImportData& data);
0046     void operator()(ImportElement& data);
0047     void operator()(ImportGeoMaterial& data);
0048     void operator()(ImportModel& data);
0049     void operator()(ImportModelMaterial& data);
0050     void operator()(ImportMscModel& data);
0051     void operator()(ImportLivermorePE& data);
0052     void operator()(ImportLivermoreSubshell& data);
0053     void operator()(ImportAtomicRelaxation& data);
0054     void operator()(ImportMuPairProductionTable& data);
0055     void operator()(ImportOpticalMaterial& data);
0056     void operator()(ImportOpticalModel& data);
0057     void operator()(ImportParticle& data);
0058     void operator()(ImportPhysMaterial& data);
0059     void operator()(ImportProcess& data);
0060     //!@}
0061 
0062     //!@{
0063     //! Trim objects
0064     void operator()(inp::Grid& data);
0065     void operator()(inp::UniformGrid& data);
0066     void operator()(ImportPhysicsTable& data);
0067     void operator()(inp::TwodGrid& data);
0068     //!@}
0069 
0070   private:
0071     //// TYPES ////
0072 
0073     using size_type = std::size_t;
0074     struct GridFilterer;
0075 
0076     //// DATA ////
0077 
0078     Input options_;
0079 
0080     //// HELPERS ////
0081 
0082     GridFilterer make_filterer(size_type vec_size) const;
0083 
0084     template<class T>
0085     void operator()(std::vector<T>& vec);
0086 
0087     template<class K, class T, class C, class A>
0088     void operator()(std::map<K, T, C, A>& m);
0089 
0090     template<class T>
0091     void for_each(std::vector<T>& vec);
0092 
0093     template<class K, class T, class C, class A>
0094     void for_each(std::map<K, T, C, A>& m);
0095 };
0096 
0097 //---------------------------------------------------------------------------//
0098 }  // namespace celeritas