|
||||
File indexing completed on 2025-01-18 09:54:48
0001 //----------------------------------*-C++-*----------------------------------// 0002 // Copyright 2020-2024 UT-Battelle, LLC, and other Celeritas developers. 0003 // See the top-level COPYRIGHT file for details. 0004 // SPDX-License-Identifier: (Apache-2.0 OR MIT) 0005 //---------------------------------------------------------------------------// 0006 //! \file corecel/grid/UniformGridData.hh 0007 //---------------------------------------------------------------------------// 0008 #pragma once 0009 0010 #include "corecel/Assert.hh" 0011 #include "corecel/Types.hh" 0012 0013 namespace celeritas 0014 { 0015 //---------------------------------------------------------------------------// 0016 /*! 0017 * Data input for a uniform increasing grid. 0018 * 0019 * The four parameters are overconstrained -- we could omit back by calculating 0020 * from the front, delta, and size. In practice, though, that can introduce an 0021 * inconsistency into the "find" function. 0022 */ 0023 struct UniformGridData 0024 { 0025 using value_type = ::celeritas::real_type; 0026 0027 size_type size{}; //!< Number of grid edges/points 0028 value_type front{}; //!< Value of first grid point 0029 value_type back{}; //!< Value of last grid point 0030 value_type delta{}; //!< Grid cell width 0031 0032 //! True if assigned and valid 0033 CELER_FUNCTION operator bool() const 0034 { 0035 return size >= 2 && delta > 0 && front < back; 0036 } 0037 0038 //// HELPER FUNCTIONS //// 0039 0040 // Construct on host from front/back 0041 inline static UniformGridData 0042 from_bounds(value_type front, value_type back, size_type size); 0043 }; 0044 0045 //---------------------------------------------------------------------------// 0046 /*! 0047 * Construct from min/max and number of grid points. 0048 */ 0049 UniformGridData 0050 UniformGridData::from_bounds(value_type front, value_type back, size_type size) 0051 { 0052 CELER_EXPECT(size >= 2); 0053 CELER_EXPECT(front < back); 0054 UniformGridData result; 0055 result.size = size; 0056 result.front = front; 0057 result.back = back; 0058 result.delta = (back - front) / (size - 1); 0059 CELER_ENSURE(result); 0060 return result; 0061 } 0062 0063 //---------------------------------------------------------------------------// 0064 } // 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 |