Back to home page

EIC code displayed by LXR

 
 

    


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

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/optical/ImportedModelAdapter.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include <memory>
0010 #include <set>
0011 #include <vector>
0012 
0013 #include "corecel/OpaqueId.hh"
0014 #include "corecel/cont/EnumArray.hh"
0015 #include "celeritas/Types.hh"
0016 #include "celeritas/io/ImportOpticalModel.hh"
0017 
0018 namespace celeritas
0019 {
0020 struct ImportData;
0021 
0022 namespace optical
0023 {
0024 //---------------------------------------------------------------------------//
0025 /*!
0026  * A collection of imported optical models.
0027  *
0028  * Constructs a map of built-in optical model classes to their imported model
0029  * IDs.
0030  */
0031 class ImportedModels
0032 {
0033   public:
0034     //!@{
0035     //! \name Type aliases
0036     using IMC = ImportModelClass;
0037     using ImportedModelId = OpaqueId<ImportOpticalModel>;
0038     //!@}
0039 
0040   public:
0041     // Construct from imported data
0042     static std::shared_ptr<ImportedModels> from_import(ImportData const&);
0043 
0044     // Construct directly from imported models
0045     ImportedModels(std::vector<ImportOpticalModel> models);
0046 
0047     // Get model by identifier
0048     ImportOpticalModel const& model(ImportedModelId mid) const;
0049 
0050     // Get number of imported models
0051     ImportedModelId::size_type num_models() const;
0052 
0053     // Get imported model ID for the given built-in model class
0054     ImportedModelId builtin_model_id(IMC imc) const;
0055 
0056   private:
0057     EnumArray<IMC, ImportedModelId> builtin_id_map_;
0058     std::vector<ImportOpticalModel> models_;
0059 };
0060 
0061 //---------------------------------------------------------------------------//
0062 /*!
0063  * An adapter for imported model data corresponding to a specific identifier.
0064  */
0065 class ImportedModelAdapter
0066 {
0067   public:
0068     //!@{
0069     //! \name Type aliases
0070     using ImportedModelId = ImportedModels::ImportedModelId;
0071     using SPConstImported = std::shared_ptr<ImportedModels const>;
0072     //!@}
0073 
0074   public:
0075     // Create an adapter for the given model identifier
0076     ImportedModelAdapter(ImportedModelId id, SPConstImported imported);
0077 
0078     // Create an adapter for the given model class
0079     ImportedModelAdapter(ImportModelClass imc, SPConstImported imported);
0080 
0081     // Get MFP grid for the optical material
0082     inp::Grid const& mfp(OptMatId id) const;
0083 
0084     // Get number of optical materials
0085     OptMatId::size_type num_materials() const;
0086 
0087   private:
0088     // Get imported model referred to by this adapter
0089     ImportOpticalModel const& model() const;
0090 
0091     ImportedModelId model_id_;
0092     SPConstImported imported_;
0093 };
0094 
0095 //---------------------------------------------------------------------------//
0096 }  // namespace optical
0097 }  // namespace celeritas