|
|
|||
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/RZMapFieldInput.hh 0006 //---------------------------------------------------------------------------// 0007 #pragma once 0008 0009 #include <iosfwd> 0010 #include <vector> 0011 0012 #include "corecel/Config.hh" 0013 0014 #include "corecel/Assert.hh" 0015 #include "corecel/Macros.hh" 0016 0017 #include "FieldDriverOptions.hh" 0018 0019 namespace celeritas 0020 { 0021 //---------------------------------------------------------------------------// 0022 /*! 0023 * Input data for an magnetic R-Z vector field stored on an R-Z grid. 0024 * 0025 * The magnetic field is discretized at nodes on an R-Z grid, and each point 0026 * the field vector is approximated by a 2-D vector in R-Z. The input units of 0027 * this field are in *NATIVE UNITS* (cm/gauss when CGS). An optional \c _units 0028 * field in the input can specify whether the input is in SI or CGS 0029 * units, with allowable values of "si", "cgs", or "clhep". The native CLHEP 0030 * unit strength is 1000*tesla. 0031 * 0032 * The field values are all indexed with R having stride 1: [Z][R] 0033 * 0034 * \todo Use C indexing instead of Fortran? Or rename to ZR field? 0035 */ 0036 struct RZMapFieldInput 0037 { 0038 unsigned int num_grid_z{}; 0039 unsigned int num_grid_r{}; 0040 double min_z{}; //!< Lower z coordinate [len] 0041 double max_z{}; //!< Last z coordinate [len] 0042 double min_r{}; //!< Lower r coordinate [len] 0043 double max_r{}; //!< Last r coordinate [len] 0044 std::vector<double> field_z; //!< Flattened Z field component [bfield] 0045 std::vector<double> field_r; //!< Flattened R field component [bfield] 0046 0047 // TODO: remove from field input; should be a separate input 0048 FieldDriverOptions driver_options; 0049 0050 //! Whether all data are assigned and valid 0051 explicit CELER_FUNCTION operator bool() const 0052 { 0053 // clang-format off 0054 return (num_grid_z >= 2) 0055 && (num_grid_r >= 2) 0056 && (min_r >= 0) 0057 && (max_z > min_z) 0058 && (max_r > min_r) 0059 && (field_z.size() == num_grid_z * num_grid_r) 0060 && (field_r.size() == field_z.size()); 0061 // clang-format on 0062 } 0063 }; 0064 0065 //---------------------------------------------------------------------------// 0066 /*! 0067 * Helper to read the field from a file or stream. 0068 * 0069 * Example to read from a file: 0070 * \code 0071 RZMapFieldInput inp; 0072 std::ifstream("foo.json") >> inp; 0073 * \endcode 0074 */ 0075 std::istream& operator>>(std::istream& is, RZMapFieldInput&); 0076 0077 //---------------------------------------------------------------------------// 0078 /*! 0079 * Helper to write the field to a file or stream. 0080 */ 0081 std::ostream& operator<<(std::ostream& os, RZMapFieldInput const&); 0082 0083 //---------------------------------------------------------------------------// 0084 } // 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 |
|