LCOV - code coverage report
Current view: top level - EnergyPlus - DataVectorTypes.hh (source / functions) Coverage Total Hit
Test: lcov.output.filtered Lines: 75.0 % 4 3
Test Date: 2025-05-22 16:09:37 Functions: 75.0 % 4 3

            Line data    Source code
       1              : // EnergyPlus, Copyright (c) 1996-2025, The Board of Trustees of the University of Illinois,
       2              : // The Regents of the University of California, through Lawrence Berkeley National Laboratory
       3              : // (subject to receipt of any required approvals from the U.S. Dept. of Energy), Oak Ridge
       4              : // National Laboratory, managed by UT-Battelle, Alliance for Sustainable Energy, LLC, and other
       5              : // contributors. All rights reserved.
       6              : //
       7              : // NOTICE: This Software was developed under funding from the U.S. Department of Energy and the
       8              : // U.S. Government consequently retains certain rights. As such, the U.S. Government has been
       9              : // granted for itself and others acting on its behalf a paid-up, nonexclusive, irrevocable,
      10              : // worldwide license in the Software to reproduce, distribute copies to the public, prepare
      11              : // derivative works, and perform publicly and display publicly, and to permit others to do so.
      12              : //
      13              : // Redistribution and use in source and binary forms, with or without modification, are permitted
      14              : // provided that the following conditions are met:
      15              : //
      16              : // (1) Redistributions of source code must retain the above copyright notice, this list of
      17              : //     conditions and the following disclaimer.
      18              : //
      19              : // (2) Redistributions in binary form must reproduce the above copyright notice, this list of
      20              : //     conditions and the following disclaimer in the documentation and/or other materials
      21              : //     provided with the distribution.
      22              : //
      23              : // (3) Neither the name of the University of California, Lawrence Berkeley National Laboratory,
      24              : //     the University of Illinois, U.S. Dept. of Energy nor the names of its contributors may be
      25              : //     used to endorse or promote products derived from this software without specific prior
      26              : //     written permission.
      27              : //
      28              : // (4) Use of EnergyPlus(TM) Name. If Licensee (i) distributes the software in stand-alone form
      29              : //     without changes from the version obtained under this License, or (ii) Licensee makes a
      30              : //     reference solely to the software portion of its product, Licensee must refer to the
      31              : //     software as "EnergyPlus version X" software, where "X" is the version number Licensee
      32              : //     obtained under this License and may not use a different name for the software. Except as
      33              : //     specifically required in this Section (4), Licensee shall not use in a company name, a
      34              : //     product name, in advertising, publicity, or other promotional activities any name, trade
      35              : //     name, trademark, logo, or other designation of "EnergyPlus", "E+", "e+" or confusingly
      36              : //     similar designation, without the U.S. Department of Energy's prior written consent.
      37              : //
      38              : // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
      39              : // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
      40              : // AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
      41              : // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
      42              : // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
      43              : // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
      44              : // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
      45              : // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
      46              : // POSSIBILITY OF SUCH DAMAGE.
      47              : 
      48              : #ifndef DataVectorTypes_hh_INCLUDED
      49              : #define DataVectorTypes_hh_INCLUDED
      50              : 
      51              : // C++ Headers
      52              : #include <cassert>
      53              : #include <cmath>
      54              : 
      55              : // ObjexxFCL Headers
      56              : #include <ObjexxFCL/Array1D.hh>
      57              : #include <ObjexxFCL/Vector3.hh>
      58              : 
      59              : // EnergyPlus Headers
      60              : #include <EnergyPlus/EnergyPlus.hh>
      61              : 
      62              : namespace EnergyPlus {
      63              : 
      64              : namespace DataVectorTypes {
      65              : 
      66              :     // Using/Aliasing
      67              : 
      68              :     // Data
      69              :     // -only module should be available to other modules and routines.
      70              :     // Thus, all variables in this module must be PUBLIC.
      71              : 
      72              :     // MODULE PARAMETER DEFINITIONS:
      73              :     // na
      74              : 
      75              :     // DERIVED TYPE DEFINITIONS
      76              : 
      77              :     // the following two derived types are used in triangulation (for DXF outputs)
      78              :     //'Points (Vertices)
      79              : 
      80              :     //'Created Triangles, vv# are the vertex pointers
      81              : 
      82              :     // Types
      83              : 
      84              :     // Vector2/3 are integrated with Array and offer additional capabilities such as
      85              :     //  subscript lookup and are templates so we are using them as plug replacements
      86              :     //  for consistent API and to avoid cost of copying them
      87              :     // Note: For vectorization contexts std::array is a better choice
      88              :     using Vector = ObjexxFCL::Vector3<Real64>;
      89              :     using Vector_2d = ObjexxFCL::Vector2<Real64>;
      90              :     using ObjexxFCL::cross;
      91              : 
      92              :     struct Vector2dCount : Vector_2d
      93              :     {
      94              :         int count{};
      95          742 :         Vector2dCount() = default;
      96              :     };
      97              : 
      98              :     //    struct Vector // This is used to specify a point in 3D space
      99              :     //    {
     100              :     //        // Members
     101              :     //        // Right Handed Coordinate system is used
     102              :     //        Real64 x;
     103              :     //        Real64 y;
     104              :     //        Real64 z;
     105              :     //
     106              :     //        // Default Constructor
     107              :     //        Vector()
     108              :     //        {}
     109              :     //
     110              :     //
     111              :     //        // Uniform Real64 Constructor
     112              :     //        Vector( Real64 const v ) :
     113              :     //            x( v ),
     114              :     //            y( v ),
     115              :     //            z( v )
     116              :     //        {}
     117              :     //
     118              :     //        // Array Assignment
     119              :     //        inline
     120              :     //        Vector &
     121              :     //        operator =( Array1D< Real64 > const & a )
     122              :     //        {
     123              :     //            assert( ( a.l() == 1 ) && ( a.u() == 3 ) );
     124              :     //            x = a( 1 );
     125              :     //            y = a( 2 );
     126              :     //            z = a( 3 );
     127              :     //            return *this;
     128              :     //        }
     129              :     //
     130              :     //        // Array Assignment
     131              :     //        inline
     132              :     //        Vector &
     133              :     //        operator =( Array1A< Real64 > const a )
     134              :     //        {
     135              :     //            a.dim( 3 );
     136              :     //            x = a( 1 );
     137              :     //            y = a( 2 );
     138              :     //            z = a( 3 );
     139              :     //            return *this;
     140              :     //        }
     141              :     //
     142              :     //        // Array Assignment
     143              :     //        inline
     144              :     //        Vector &
     145              :     //        operator =( Array1S< Real64 > const & a )
     146              :     //        {
     147              :     //            assert( ( a.l() == 1 ) && ( a.u() == 3 ) );
     148              :     //            x = a( 1 );
     149              :     //            y = a( 2 );
     150              :     //            z = a( 3 );
     151              :     //            return *this;
     152              :     //        }
     153              :     //
     154              :     //        // Vector3 Assignment
     155              :     //        inline
     156              :     //        Vector &
     157              :     //        operator =( Vector3< Real64 > const & v )
     158              :     //        {
     159              :     //            x = v.x;
     160              :     //            y = v.y;
     161              :     //            z = v.z;
     162              :     //            return *this;
     163              :     //        }
     164              :     //
     165              :     //        // Real64 Assignment
     166              :     //        inline
     167              :     //        Vector &
     168              :     //        operator =( Real64 const v )
     169              :     //        {
     170              :     //            x = v;
     171              :     //            y = v;
     172              :     //            z = v;
     173              :     //            return *this;
     174              :     //        }
     175              :     //
     176              :     //        // += Vector
     177              :     //        inline
     178              :     //        Vector &
     179              :     //        operator +=( Vector const & a )
     180              :     //        {
     181              :     //            x += a.x;
     182              :     //            y += a.y;
     183              :     //            z += a.z;
     184              :     //            return *this;
     185              :     //        }
     186              :     //
     187              :     //        // -= Vector
     188              :     //        inline
     189              :     //        Vector &
     190              :     //        operator -=( Vector const & a )
     191              :     //        {
     192              :     //            x -= a.x;
     193              :     //            y -= a.y;
     194              :     //            z -= a.z;
     195              :     //            return *this;
     196              :     //        }
     197              :     //
     198              :     //        // += Real64
     199              :     //        inline
     200              :     //        Vector &
     201              :     //        operator +=( Real64 const v )
     202              :     //        {
     203              :     //            x += v;
     204              :     //            y += v;
     205              :     //            z += v;
     206              :     //            return *this;
     207              :     //        }
     208              :     //
     209              :     //        // -= Real64
     210              :     //        inline
     211              :     //        Vector &
     212              :     //        operator -=( Real64 const v )
     213              :     //        {
     214              :     //            x -= v;
     215              :     //            y -= v;
     216              :     //            z -= v;
     217              :     //            return *this;
     218              :     //        }
     219              :     //
     220              :     //        // *= Real64
     221              :     //        inline
     222              :     //        Vector &
     223              :     //        operator *=( Real64 const v )
     224              :     //        {
     225              :     //            x *= v;
     226              :     //            y *= v;
     227              :     //            z *= v;
     228              :     //            return *this;
     229              :     //        }
     230              :     //
     231              :     //        // /= Real64
     232              :     //        inline
     233              :     //        Vector &
     234              :     //        operator /=( Real64 const v )
     235              :     //        {
     236              :     //            assert( v != Real64( 0.0 ) );
     237              :     //            x /= v;
     238              :     //            y /= v;
     239              :     //            z /= v;
     240              :     //            return *this;
     241              :     //        }
     242              :     //
     243              :     //        // Array Conversion
     244              :     //        inline
     245              :     //        operator Array1D< Real64 >() const
     246              :     //        {
     247              :     //            return Array1D< Real64 >( 3, { x, y, z } );
     248              :     //        }
     249              :     //
     250              :     //        // Length
     251              :     //        inline
     252              :     //        Real64
     253              :     //        length() const
     254              :     //        {
     255              :     //            return std::sqrt( ( x * x ) + ( y * y ) + ( z * z ) );
     256              :     //        }
     257              :     //
     258              :     //        // Length
     259              :     //        inline
     260              :     //        Real64
     261              :     //        length_squared() const
     262              :     //        {
     263              :     //            return ( x * x ) + ( y * y ) + ( z * z );
     264              :     //        }
     265              :     //
     266              :     //        // Negated
     267              :     //        inline
     268              :     //        friend
     269              :     //        Vector
     270              :     //        operator -( Vector const & a )
     271              :     //        {
     272              :     //            return Vector( -a.x, -a.y, -a.z );
     273              :     //        }
     274              :     //
     275              :     //        // Vector + Vector
     276              :     //        inline
     277              :     //        friend
     278              :     //        Vector
     279              :     //        operator +( Vector const & a, Vector const & b )
     280              :     //        {
     281              :     //            Vector r;
     282              :     //            r.x = a.x + b.x;
     283              :     //            r.y = a.y + b.y;
     284              :     //            r.z = a.z + b.z;
     285              :     //            return r;
     286              :     //        }
     287              :     //
     288              :     //        // Vector - Vector
     289              :     //        inline
     290              :     //        friend
     291              :     //        Vector
     292              :     //        operator -( Vector const & a, Vector const & b )
     293              :     //        {
     294              :     //            Vector r;
     295              :     //            r.x = a.x - b.x;
     296              :     //            r.y = a.y - b.y;
     297              :     //            r.z = a.z - b.z;
     298              :     //            return r;
     299              :     //        }
     300              :     //
     301              :     //        // Vector * Vector: Cross Product //Autodesk Suggest migrating to cross function to avoid confusion
     302              :     //        inline
     303              :     //        friend
     304              :     //        Vector
     305              :     //        operator *( Vector const & a, Vector const & b )
     306              :     //        {
     307              :     //            Vector c;
     308              :     //            c.x = ( a.y * b.z ) - ( a.z * b.y );
     309              :     //            c.y = ( a.z * b.x ) - ( a.x * b.z );
     310              :     //            c.z = ( a.x * b.y ) - ( a.y * b.x );
     311              :     //            return c;
     312              :     //        }
     313              :     //
     314              :     //        // Vector * Real64
     315              :     //        inline
     316              :     //        friend
     317              :     //        Vector
     318              :     //        operator *( Vector const & a, Real64 const b )
     319              :     //        {
     320              :     //            Vector r;
     321              :     //            r.x = a.x * b;
     322              :     //            r.y = a.y * b;
     323              :     //            r.z = a.z * b;
     324              :     //            return r;
     325              :     //        }
     326              :     //
     327              :     //        // Real64 * Vector
     328              :     //        inline
     329              :     //        friend
     330              :     //        Vector
     331              :     //        operator *( Real64 const b, Vector const & a )
     332              :     //        {
     333              :     //            Vector r;
     334              :     //            r.x = a.x * b;
     335              :     //            r.y = a.y * b;
     336              :     //            r.z = a.z * b;
     337              :     //            return r;
     338              :     //        }
     339              :     //
     340              :     //        // Vector * Integer
     341              :     //        inline
     342              :     //        friend
     343              :     //        Vector
     344              :     //        operator *( Vector const & a, int const b )
     345              :     //        {
     346              :     //            Vector r;
     347              :     //            r.x = a.x * b;
     348              :     //            r.y = a.y * b;
     349              :     //            r.z = a.z * b;
     350              :     //            return r;
     351              :     //        }
     352              :     //
     353              :     //        // Integer * Vector
     354              :     //        inline
     355              :     //        friend
     356              :     //        Vector
     357              :     //        operator *( int const b, Vector const & a )
     358              :     //        {
     359              :     //            Vector r;
     360              :     //            r.x = a.x * b;
     361              :     //            r.y = a.y * b;
     362              :     //            r.z = a.z * b;
     363              :     //            return r;
     364              :     //        }
     365              :     //
     366              :     //        // Vector / Real64
     367              :     //        inline
     368              :     //        friend
     369              :     //        Vector
     370              :     //        operator /( Vector const & a, Real64 const b )
     371              :     //        {
     372              :     //            assert( b != 0.0 );
     373              :     //            Vector r;
     374              :     //            r.x = a.x / b;
     375              :     //            r.y = a.y / b;
     376              :     //            r.z = a.z / b;
     377              :     //            return r;
     378              :     //        }
     379              :     //
     380              :     //        // Vector / Integer
     381              :     //        inline
     382              :     //        friend
     383              :     //        Vector
     384              :     //        operator /( Vector const & a, int const b )
     385              :     //        {
     386              :     //            assert( b != 0 );
     387              :     //            Vector r;
     388              :     //            r.x = a.x / b;
     389              :     //            r.y = a.y / b;
     390              :     //            r.z = a.z / b;
     391              :     //            return r;
     392              :     //        }
     393              :     //
     394              :     //        // Magnitude
     395              :     //        inline
     396              :     //        friend
     397              :     //        Real64
     398              :     //        magnitude( Vector const & a )
     399              :     //        {
     400              :     //            return std::sqrt( square( a.x ) + square( a.y ) + square( a.z ) );
     401              :     //        }
     402              :     //
     403              :     //        // Magnitude Squared
     404              :     //        inline
     405              :     //        friend
     406              :     //        Real64
     407              :     //        magnitude_squared( Vector const & a )
     408              :     //        {
     409              :     //            return square( a.x ) + square( a.y ) + square( a.z );
     410              :     //        }
     411              :     //
     412              :     //        // Distance
     413              :     //        inline
     414              :     //        friend
     415              :     //        Real64
     416              :     //        distance( Vector const & a, Vector const & b )
     417              :     //        {
     418              :     //            return std::sqrt( square( a.x - b.x ) + square( a.y - b.y ) + square( a.z - b.z ) );
     419              :     //        }
     420              :     //
     421              :     //        // Distance Squared
     422              :     //        inline
     423              :     //        friend
     424              :     //        Real64
     425              :     //        distance_squared( Vector const & a, Vector const & b )
     426              :     //        {
     427              :     //            return square( a.x - b.x ) + square( a.y - b.y ) + square( a.z - b.z );
     428              :     //        }
     429              :     //
     430              :     //        // Dot Product
     431              :     //        inline
     432              :     //        friend
     433              :     //        Real64
     434              :     //        dot( Vector const & a, Vector const & b )
     435              :     //        {
     436              :     //            return ( a.x * b.x ) + ( a.y * b.y ) + ( a.z * b.z );
     437              :     //        }
     438              :     //
     439              :     //        // Dot Product
     440              :     //        inline
     441              :     //        friend
     442              :     //        Real64
     443              :     //        dot( Vector const & a, Vector3< Real64 > const & b )
     444              :     //        {
     445              :     //            return ( a.x * b.x ) + ( a.y * b.y ) + ( a.z * b.z );
     446              :     //        }
     447              :     //
     448              :     //        // Dot Product
     449              :     //        inline
     450              :     //        friend
     451              :     //        Real64
     452              :     //        dot( Vector3< Real64 > const & a, Vector const & b )
     453              :     //        {
     454              :     //            return ( a.x * b.x ) + ( a.y * b.y ) + ( a.z * b.z );
     455              :     //        }
     456              :     //
     457              :     //        // Cross Product
     458              :     //        inline
     459              :     //        friend
     460              :     //        Vector
     461              :     //        cross( Vector const & a, Vector const & b )
     462              :     //        {
     463              :     //            Vector c;
     464              :     //            c.x = ( a.y * b.z ) - ( a.z * b.y );
     465              :     //            c.y = ( a.z * b.x ) - ( a.x * b.z );
     466              :     //            c.z = ( a.x * b.y ) - ( a.y * b.x );
     467              :     //            return c;
     468              :     //        }
     469              :     //
     470              :     //        // Cross Product
     471              :     //        inline
     472              :     //        friend
     473              :     //        Vector
     474              :     //        cross( Vector const & a, Vector3< Real64 > const & b )
     475              :     //        {
     476              :     //            Vector c;
     477              :     //            c.x = ( a.y * b.z ) - ( a.z * b.y );
     478              :     //            c.y = ( a.z * b.x ) - ( a.x * b.z );
     479              :     //            c.z = ( a.x * b.y ) - ( a.y * b.x );
     480              :     //            return c;
     481              :     //        }
     482              :     //
     483              :     //        // Cross Product
     484              :     //        inline
     485              :     //        friend
     486              :     //        Vector
     487              :     //        cross( Vector3< Real64 > const & a, Vector const & b )
     488              :     //        {
     489              :     //            Vector c;
     490              :     //            c.x = ( a.y * b.z ) - ( a.z * b.y );
     491              :     //            c.y = ( a.z * b.x ) - ( a.x * b.z );
     492              :     //            c.z = ( a.x * b.y ) - ( a.y * b.x );
     493              :     //            return c;
     494              :     //        }
     495              :     //
     496              :     //        // Array Generator
     497              :     //        inline
     498              :     //        Array1D< Real64 >
     499              :     //        Array() const
     500              :     //        {
     501              :     //            return Array1D< Real64 >( 3, { x, y, z } );
     502              :     //        }
     503              :     //
     504              :     //        // Vector3 Generator
     505              :     //        inline
     506              :     //        Vector3< Real64 >
     507              :     //        Vec3() const
     508              :     //        {
     509              :     //            return Vector3< Real64 >( x, y, z );
     510              :     //        }
     511              :     //
     512              :     //        // Assign to an Array
     513              :     //        inline
     514              :     //        void
     515              :     //        assign_to( Array1D< Real64 > & a ) const
     516              :     //        {
     517              :     //            a.dimension( 3 );
     518              :     //            a( 1 ) = x;
     519              :     //            a( 2 ) = y;
     520              :     //            a( 3 ) = z;
     521              :     //        }
     522              :     //
     523              :     //        // Assign to a Vector3
     524              :     //        inline
     525              :     //        void
     526              :     //        assign_to( Vector3< Real64 > & v ) const
     527              :     //        {
     528              :     //            v.x = x;
     529              :     //            v.y = y;
     530              :     //            v.z = z;
     531              :     //        }
     532              :     //
     533              :     //    private: // Static Functions
     534              :     //
     535              :     //        // Square
     536              :     //        inline
     537              :     //        static
     538              :     //        Real64
     539              :     //        square( Real64 const x )
     540              :     //        {
     541              :     //            return x * x;
     542              :     //        }
     543              :     //
     544              :     //    };
     545              : 
     546              :     struct PlaneEq // This is used to specify a plane based on vectors in that plane
     547              :     {
     548              :         // Members
     549              :         Real64 x{};
     550              :         Real64 y{};
     551              :         Real64 z{};
     552              :         Real64 w{};
     553              : 
     554              :         // Default Constructor
     555              :         PlaneEq() = default;
     556              :     };
     557              : 
     558              :     struct Face // Used to specify the face of a polyhedron
     559              :     {
     560              :         // Members
     561              :         int NSides{};  // Number of Sides for this Face
     562              :         int SurfNum{}; // ALLOCATABLE to actual surface number
     563              :         Array1D<Vector> FacePoints;
     564              :         Vector NewellAreaVector;
     565              : 
     566              :         // Default Constructor
     567         1714 :         Face() = default;
     568              :     };
     569              : 
     570              :     struct Polyhedron // This is used to specify a polyhedron based on the vectors that comprise it (a zone).
     571              :     {
     572              :         // Members
     573              :         int NumSurfaceFaces{};
     574              :         Array1D<Face> SurfaceFace;
     575              : 
     576              :         // Default Constructor
     577          210 :         Polyhedron() = default;
     578              :     };
     579              : 
     580              :     //    struct Vector_2d
     581              :     //    {
     582              :     //        // Members
     583              :     //        Real64 x;
     584              :     //        Real64 y;
     585              :     //
     586              :     //        // Default Constructor
     587              :     //        Vector_2d()
     588              :     //        {}
     589              :     //
     590              :     //
     591              :     //        // Dot Product
     592              :     //        inline
     593              :     //        friend
     594              :     //        Real64
     595              :     //        dot( Vector_2d const & a, Vector_2d const & b )
     596              :     //        {
     597              :     //            return ( a.x * b.x ) + ( a.y * b.y );
     598              :     //        }
     599              :     //
     600              :     //        // Cross Product
     601              :     //        inline
     602              :     //        friend
     603              :     //        Real64
     604              :     //        cross( Vector_2d const & a, Vector_2d const & b )
     605              :     //        {
     606              :     //            return ( a.x * b.y ) - ( a.y * b.x );
     607              :     //        }
     608              :     //
     609              :     //    };
     610              : 
     611              :     struct dTriangle
     612              :     {
     613              :         // Members
     614              :         int vv0{};
     615              :         int vv1{};
     616              :         int vv2{};
     617              : 
     618              :         // Default Constructor
     619            0 :         dTriangle() = default;
     620              :     };
     621              : 
     622              : } // namespace DataVectorTypes
     623              : 
     624              : } // namespace EnergyPlus
     625              : 
     626              : #endif
        

Generated by: LCOV version 2.0-1