Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/orange/OrangeInput.hh was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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 orange/OrangeInput.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include <algorithm>
0010 #include <iosfwd>
0011 #include <map>
0012 #include <variant>
0013 #include <vector>
0014 
0015 #include "corecel/io/Label.hh"
0016 #include "geocel/BoundingBox.hh"
0017 
0018 #include "OrangeData.hh"
0019 #include "OrangeTypes.hh"
0020 #include "surf/VariantSurface.hh"
0021 #include "transform/VariantTransform.hh"
0022 
0023 namespace celeritas
0024 {
0025 //---------------------------------------------------------------------------//
0026 /*!
0027  * Input definition for a single oriented bounding zone.
0028  */
0029 struct OrientedBoundingZoneInput
0030 {
0031     //! Inner bounding box
0032     BBox inner;
0033     //! Outer bounding box
0034     BBox outer;
0035     //! Local to global transformation
0036     TransformId trans_id;
0037 
0038     //! Whether the obz definition is valid
0039     explicit operator bool() const { return inner && outer && trans_id; }
0040 };
0041 
0042 //---------------------------------------------------------------------------//
0043 /*!
0044  * Input definition for a single volume.
0045  */
0046 struct VolumeInput
0047 {
0048     using Flags = VolumeRecord::Flags;
0049 
0050     //! Volume label
0051     Label label{};
0052 
0053     //! Sorted list of surface IDs in this volume
0054     std::vector<LocalSurfaceId> faces{};
0055     //! RPN region definition for this volume, using local surface index
0056     std::vector<logic_int> logic{};
0057     //! Axis-aligned bounding box
0058     BBox bbox{};
0059     //! OrientedBoundingZone
0060     OrientedBoundingZoneInput obz;
0061 
0062     //! Special flags
0063     logic_int flags{0};
0064     //! Masking priority
0065     ZOrder zorder{};
0066 
0067     //! Whether the volume definition is valid
0068     explicit operator bool() const
0069     {
0070         return (!logic.empty() || (flags & Flags::implicit_vol))
0071                && zorder != ZOrder::invalid;
0072     }
0073 };
0074 
0075 //---------------------------------------------------------------------------//
0076 /*!
0077  * Input definition a daughter universe embedded in a parent cell.
0078  */
0079 struct DaughterInput
0080 {
0081     UniverseId universe_id;
0082     VariantTransform transform;
0083 };
0084 
0085 //---------------------------------------------------------------------------//
0086 /*!
0087  * Input definition for a unit.
0088  *
0089  * \todo Add a CsgTree object and \c vector<NodeId> volumes;
0090  */
0091 struct UnitInput
0092 {
0093     using MapVolumeDaughter = std::map<LocalVolumeId, DaughterInput>;
0094 
0095     std::vector<VariantSurface> surfaces;
0096     std::vector<VolumeInput> volumes;
0097     BBox bbox;  //!< Outer bounding box
0098     MapVolumeDaughter daughter_map;
0099 
0100     // Unit metadata
0101     std::vector<Label> surface_labels;
0102     Label label;
0103 
0104     //! Whether the unit definition is valid
0105     explicit operator bool() const { return !volumes.empty(); }
0106 };
0107 
0108 //---------------------------------------------------------------------------//
0109 /*!
0110  * Input definition for a rectangular array universe.
0111  */
0112 struct RectArrayInput
0113 {
0114     // Grid boundaries in x, y, and z
0115     Array<std::vector<double>, 3> grid;
0116 
0117     // Daughters in each cell [x][y][z]
0118     std::vector<DaughterInput> daughters;
0119 
0120     // Unit metadata
0121     Label label;
0122 
0123     //! Whether the universe definition is valid
0124     explicit operator bool() const
0125     {
0126         return !daughters.empty()
0127                && std::all_of(grid.begin(), grid.end(), [](auto& v) {
0128                       return v.size() >= 2;
0129                   });
0130     }
0131 };
0132 
0133 //---------------------------------------------------------------------------//
0134 //! Possible types of universe inputs
0135 using VariantUniverseInput = std::variant<UnitInput, RectArrayInput>;
0136 
0137 //---------------------------------------------------------------------------//
0138 /*!
0139  * Construction definition for a full ORANGE geometry.
0140  */
0141 struct OrangeInput
0142 {
0143     std::vector<VariantUniverseInput> universes;
0144 
0145     //! Relative and absolute error for construction and transport
0146     Tolerance<> tol;
0147 
0148     //! Whether the unit definition is valid
0149     explicit operator bool() const { return !universes.empty() && tol; }
0150 };
0151 
0152 //---------------------------------------------------------------------------//
0153 // Helper to read the input from a file or stream
0154 std::istream& operator>>(std::istream& is, OrangeInput&);
0155 
0156 //---------------------------------------------------------------------------//
0157 // Helper to write the input to a file or stream
0158 std::ostream& operator<<(std::ostream& os, OrangeInput const&);
0159 
0160 //---------------------------------------------------------------------------//
0161 }  // namespace celeritas