Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-15 10:10:55

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/CartMapFieldInput.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include <vector>
0010 
0011 #include "corecel/Types.hh"
0012 #include "geocel/Types.hh"
0013 #include "celeritas/Types.hh"
0014 
0015 #include "FieldDriverOptions.hh"
0016 
0017 namespace celeritas
0018 {
0019 //---------------------------------------------------------------------------//
0020 /*!
0021  * Input data for a magnetic X-Y-Z vector field stored on an X-Y-Z grid.
0022  *
0023  * The magnetic field is discretized at nodes on an X-Y-Z grid, and at each
0024  * point the field vector is approximated by a 3-D vector in X-Y-Z. The input
0025  * units of this field are in *NATIVE UNITS* (cm/gauss when CGS).
0026  *
0027  * The field values are all indexed with Z having stride 3, for the
0028  * 3-dimensional vector at that position, Y having stride (num_grid_z * 3), and
0029  * X having stride (num_grid_y * num_grid_z * 3): [X][Y][Z][3]
0030  */
0031 struct CartMapFieldInput
0032 {
0033     real_type min_x;  //!< Minimum X grid point [len]
0034     real_type max_x;  //!< Maximum X grid point [len]
0035     size_type num_x;  //!< Number of X grid points
0036 
0037     real_type min_y;  //!< Minimum Y grid point [len]
0038     real_type max_y;  //!< Maximum Y grid point [len]
0039     size_type num_y;  //!< Number of Y grid points
0040 
0041     real_type min_z;  //!< Minimum Z grid point [len]
0042     real_type max_z;  //!< Maximum Z grid point [len]
0043     size_type num_z;  //!< Number of Z grid points
0044 
0045     std::vector<real_type> field;  //!< Flattened X-Y-Z field component
0046                                    //!< [bfield]
0047 
0048     // TODO: remove from field input; should be a separate input
0049     FieldDriverOptions driver_options;
0050 
0051     //! Whether all data are assigned and valid
0052     explicit operator bool() const
0053     {
0054         // clang-format off
0055         return 
0056              (max_x >= min_x)
0057             && (num_x >= 2)
0058             && (max_y >= min_y)
0059             && (num_y >= 2)
0060             && (max_z >= min_z)
0061             && (num_z >= 2)
0062             && (field.size() == static_cast<size_type>(Axis::size_) * num_x * num_y * num_z);
0063         // clang-format on
0064     }
0065 };
0066 
0067 //---------------------------------------------------------------------------//
0068 }  // namespace celeritas