|
|
|||
File indexing completed on 2026-01-09 09:41:07
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 accel/CartMapMagneticField.hh 0006 //---------------------------------------------------------------------------// 0007 #pragma once 0008 0009 #include <memory> 0010 #include <G4MagneticField.hh> 0011 0012 #include "corecel/Types.hh" 0013 #include "celeritas/field/CartMapFieldInput.hh" 0014 #include "celeritas/field/CartMapFieldParams.hh" 0015 0016 namespace celeritas 0017 { 0018 //---------------------------------------------------------------------------// 0019 //! POD struct for CartMap field grid parameters 0020 struct CartMapFieldGridParams 0021 { 0022 AxisGrid<real_type> x{}; //!< X-axis grid specification 0023 AxisGrid<real_type> y{}; //!< Y-axis grid specification 0024 AxisGrid<real_type> z{}; //!< Z-axis grid specification 0025 0026 //! Check if parameters are valid for field generation 0027 explicit operator bool() const { return x && y && z; } 0028 }; 0029 0030 //---------------------------------------------------------------------------// 0031 // Generate field input with user-defined uniform grid 0032 CartMapFieldParams::Input 0033 MakeCartMapFieldInput(CartMapFieldGridParams const& params); 0034 0035 //---------------------------------------------------------------------------// 0036 /*! 0037 * A user magnetic field equivalent to celeritas::CartMapField. 0038 */ 0039 class CartMapMagneticField : public G4MagneticField 0040 { 0041 public: 0042 //!@{ 0043 //! \name Type aliases 0044 using SPConstFieldParams = std::shared_ptr<CartMapFieldParams const>; 0045 //!@} 0046 0047 // Construct with CartMapFieldParams 0048 explicit CartMapMagneticField(SPConstFieldParams field_params); 0049 0050 // Calculate values of the magnetic field vector 0051 void GetFieldValue(G4double const point[3], G4double* field) const override; 0052 0053 private: 0054 // Forward declaration for pImpl 0055 struct Impl; 0056 0057 // Custom deleter for pImpl 0058 struct ImplDeleter 0059 { 0060 void operator()(Impl* ptr) const; 0061 }; 0062 std::unique_ptr<Impl, ImplDeleter> pimpl_; 0063 }; 0064 0065 //---------------------------------------------------------------------------// 0066 0067 //---------------------------------------------------------------------------// 0068 } // namespace celeritas
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|