Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-15 08:54:43

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/field/UniformFieldData.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include "corecel/Types.hh"
0010 #include "corecel/cont/Array.hh"
0011 #include "corecel/data/Collection.hh"
0012 #include "corecel/math/ArrayUtils.hh"
0013 
0014 #include "FieldDriverOptions.hh"
0015 
0016 namespace celeritas
0017 {
0018 //---------------------------------------------------------------------------//
0019 /*!
0020  * Data and options for a uniform field.
0021  *
0022  * If \c has_field is non-empty, the field will only be present in those
0023  * volumes.
0024  */
0025 template<Ownership W, MemSpace M>
0026 struct UniformFieldParamsData
0027 {
0028     using Real3 = Array<real_type, 3>;
0029     template<class T>
0030     using VolumeItems = celeritas::Collection<T, W, M, VolumeId>;
0031 
0032     Real3 field{0, 0, 0};  //!< Field strength (native units)
0033     FieldDriverOptions options;
0034     VolumeItems<char> has_field;  //!< Volumes where field is present
0035 
0036     //! Check whether the data is assigned
0037     explicit inline CELER_FUNCTION operator bool() const
0038     {
0039         return options && norm(field) > 0;
0040     }
0041 
0042     //! Assign from another set of data
0043     template<Ownership W2, MemSpace M2>
0044     UniformFieldParamsData&
0045     operator=(UniformFieldParamsData<W2, M2> const& other)
0046     {
0047         CELER_EXPECT(other);
0048         field = other.field;
0049         options = other.options;
0050         has_field = other.has_field;
0051         return *this;
0052     }
0053 };
0054 
0055 //---------------------------------------------------------------------------//
0056 }  // namespace celeritas