|
||||
File indexing completed on 2025-01-30 10:03:42
0001 //----------------------------------*-C++-*----------------------------------// 0002 // Copyright 2021-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/TwodGridData.hh 0007 //---------------------------------------------------------------------------// 0008 #pragma once 0009 0010 #include "corecel/Assert.hh" 0011 #include "corecel/Types.hh" 0012 #include "corecel/data/Collection.hh" 0013 0014 namespace celeritas 0015 { 0016 //---------------------------------------------------------------------------// 0017 /*! 0018 * Definition of a structured nonuniform 2D grid with node-centered data. 0019 * 0020 * This relies on an external Collection of reals. Data is indexed as `[x][y]`, 0021 * C-style row-major. 0022 */ 0023 struct TwodGridData 0024 { 0025 ItemRange<real_type> x; //!< x grid definition 0026 ItemRange<real_type> y; //!< y grid definition 0027 ItemRange<real_type> values; //!< [x][y] 0028 0029 //! True if assigned and valid 0030 explicit CELER_FUNCTION operator bool() const 0031 { 0032 return x.size() >= 2 && y.size() >= 2 0033 && values.size() == x.size() * y.size(); 0034 } 0035 0036 //! Get the data location for a specified x-y coordinate. 0037 CELER_FUNCTION ItemId<real_type> at(size_type ix, size_type iy) const 0038 { 0039 CELER_EXPECT(ix < this->x.size()); 0040 CELER_EXPECT(iy < this->y.size()); 0041 size_type index = ix * this->y.size() + iy; 0042 0043 CELER_ENSURE(index < this->x.size() * this->y.size()); 0044 return ItemId<real_type>{index + this->values.front().get()}; 0045 } 0046 }; 0047 0048 //---------------------------------------------------------------------------// 0049 } // 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 |