Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
GIDI::Array::Array Class Reference

#include <GIDI.hpp>

Inheritance diagram for GIDI::Array::Array:

Public Member Functions

 Array (HAPI::Node const &a_node, SetupInfo &a_setupInfo, int a_useSystem_strtod)
 ~Array ()
std::size_t dimension () const
std::size_t size () const
std::vector< std::size_t > const & shape () const
FullArray constructArray () const
void toXMLList (GUPI::WriteInfo &a_writeInfo, std::string const &a_indent) const
Public Member Functions inherited from GIDI::Form
 Form (FormType a_type)
 Form (std::string const &a_moniker, FormType a_type, std::string const &a_label)
 Form (HAPI::Node const &a_node, SetupInfo &a_setupInfo, FormType a_type, Suite *a_suite=nullptr)
 Form (Form const &a_form)
virtual ~Form ()
Formoperator= (Form const &a_rhs)
Suiteparent () const
std::string const & label () const
void setLabel (std::string const &a_label)
virtual std::string actualMoniker () const
std::string const & keyName () const
void setKeyName (std::string const &a_keyName)
std::string const & keyValue () const
virtual void setKeyValue (std::string const &a_keyName) const
FormType type () const
Form const * sibling (std::string a_label) const
GUPI::AncestryfindInAncestry3 (LUPI_maybeUnused std::string const &a_item)
GUPI::Ancestry const * findInAncestry3 (LUPI_maybeUnused std::string const &a_item) const
std::string xlinkItemKey () const
Public Member Functions inherited from GUPI::Ancestry
 Ancestry (std::string const &a_moniker, std::string const &a_attribute="")
virtual ~Ancestry ()
Ancestryoperator= (Ancestry const &a_ancestry)
std::string const & moniker () const
void setMoniker (std::string const &a_moniker)
Ancestryancestor ()
Ancestry const * ancestor () const
void setAncestor (Ancestry *a_ancestor)
std::string attribute () const
Ancestryroot ()
Ancestry const * root () const
bool isChild (Ancestry *a_instance)
bool isParent (Ancestry *a_parent)
bool isRoot () const
AncestryfindInAncestry (std::string const &a_href)
Ancestry const * findInAncestry (std::string const &a_href) const
virtual AncestryfindInAncestry3 (std::string const &a_item)=0
virtual Ancestry const * findInAncestry3 (std::string const &a_item) const =0
virtual LUPI_HOST void serialize (LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode)
std::string toXLink () const
void printXML () const

Additional Inherited Members

Static Public Member Functions inherited from GUPI::Ancestry
static std::string buildXLinkItemKey (std::string const &a_name, std::string const &a_key)

Detailed Description

The class for storing any GNDS array.

Definition at line 909 of file GIDI.hpp.

Constructor & Destructor Documentation

◆ Array()

GIDI::Array::Array::Array ( HAPI::Node const & a_node,
SetupInfo & a_setupInfo,
int a_useSystem_strtod )
Parameters
a_node[in] The HAPI::Node to be parsed and used to construct the Array2d.
a_setupInfo[in] Information create my the Protare constructor to help in parsing.
a_useSystem_strtod[in] Flag passed to the function nfu_stringToListOfDoubles.

Definition at line 90 of file GIDI_arrays.cc.

90 :
91 Form( a_node, a_setupInfo, FormType::array ),
92 m_shape( parseArrayShape( a_node ) ),
93 m_compression( a_node.attribute_as_string( GIDI_compressionChars ) ),
94 m_symmetry( a_node.attribute_as_string( GIDI_symmetryChars ) ),
95 m_permutation( a_node.attribute_as_string( GIDI_permutationChars ) ),
96 m_storageOrder( a_node.attribute_as_string( GIDI_storageOrderChars ) ) {
97
98 if( m_compression == "" ) m_compression = GIDI_noneChars;
99
100 if( ( m_compression == GIDI_noneChars ) || ( m_compression == GIDI_diagonalChars ) || ( m_compression == GIDI_flattenedChars ) ) {
101 for( HAPI::Node child = a_node.first_child( ); !child.empty( ); child.to_next_sibling( ) ) {
102 std::string name( child.name( ) );
103 if( name != GIDI_valuesChars ) throw Exception( "For '" + moniker( ) + "' array, child node not 'values' but '" + name + "'." );
104
105 std::string label1( child.attribute_as_string( GIDI_labelChars ) );
106 if( label1 == "" ) {
107 parseValuesOfDoubles( child, a_setupInfo, m_values, a_useSystem_strtod ); }
108 else if( label1 == GIDI_startingIndices ) {
109 if( m_compression != GIDI_diagonalChars ) throw Exception( "Invalid values' label '" + label1 + "'." );
110 parseValuesOfInts( child, a_setupInfo, m_starts ); }
111 else if( label1 == GIDI_startsChars ) {
112 if( m_compression != GIDI_flattenedChars ) throw Exception( "Invalid values' label " + label1 + "." );
113 parseValuesOfInts( child, a_setupInfo, m_starts ); }
114 else if( label1 == GIDI_lengthsChars ) {
115 if( m_compression != GIDI_flattenedChars ) throw Exception( "Invalid values' label '" + label1 + "'." );
116 parseValuesOfInts( child, a_setupInfo, m_length ); }
117 else {
118 throw Exception( "Invalid values' label '" + label1 + "'." );
119 }
120 } }
121 else { // m_compression == GIDI_embeddedChars
122 for( HAPI::Node child = a_node.first_child( ); !child.empty( ); child.to_next_sibling( ) ) {
123 std::string name( child.name( ) );
124 if( name != GIDI_arrayChars ) throw Exception( "For 'embedded' array, child node not 'array' but '" + name + "'." );
125
126 m_array.push_back( new Array( child, a_setupInfo, a_useSystem_strtod ) );
127 }
128 }
129}
#define GIDI_startingIndices
Definition GIDI.hpp:265
#define GIDI_permutationChars
Definition GIDI.hpp:275
#define GIDI_valuesChars
Definition GIDI.hpp:260
#define GIDI_diagonalChars
Definition GIDI.hpp:264
#define GIDI_labelChars
Definition GIDI.hpp:438
#define GIDI_startsChars
Definition GIDI.hpp:267
#define GIDI_arrayChars
Definition GIDI.hpp:258
#define GIDI_storageOrderChars
Definition GIDI.hpp:279
#define GIDI_symmetryChars
Definition GIDI.hpp:271
#define GIDI_flattenedChars
Definition GIDI.hpp:266
#define GIDI_noneChars
Definition GIDI.hpp:259
#define GIDI_compressionChars
Definition GIDI.hpp:263
#define GIDI_lengthsChars
Definition GIDI.hpp:268
Array(HAPI::Node const &a_node, SetupInfo &a_setupInfo, int a_useSystem_strtod)
Form(FormType a_type)
Definition GIDI_form.cc:25
std::string const & moniker() const
Definition GUPI.hpp:102
const char * name(G4int ptype)
void parseValuesOfDoubles(Construction::Settings const &a_construction, HAPI::Node const &a_node, SetupInfo &a_setupInfo, nf_Buffer< double > &a_vector)
Definition GIDI_misc.cc:88
void parseValuesOfInts(Construction::Settings const &a_construction, HAPI::Node const &a_node, SetupInfo &a_setupInfo, std::vector< int > &a_vector)

Referenced by Array().

◆ ~Array()

GIDI::Array::Array::~Array ( )

Definition at line 134 of file GIDI_arrays.cc.

134 {
135
136 for( auto iter = m_array.begin( ); iter != m_array.end( ); ++iter ) delete *iter;
137}

Member Function Documentation

◆ constructArray()

FullArray GIDI::Array::Array::constructArray ( ) const

Returns an array that is a FullArray instance of this. Note, this does not currently handle symmetry, permutation or storageOrder.

Returns
Return a FullArray of this.

Definition at line 160 of file GIDI_arrays.cc.

160 {
161
162 std::vector<double> values( size( ) );
163
164 if( m_compression == GIDI_noneChars ) {
165 values = m_values.vector( ); }
166 else if( m_compression == GIDI_diagonalChars ) {
167 throw Exception( "Array::constructArray: compression '" + m_compression + "' not supported." ); }
168 else if( m_compression == GIDI_flattenedChars ) {
169 std::size_t index = 0;
170 for( std::size_t index1 = 0; index1 < m_starts.size( ); ++index1 ) {
171 std::size_t length = static_cast<std::size_t>( m_length[index1] );
172 std::size_t start = static_cast<std::size_t>( m_starts[index1] );
173
174 for( std::size_t index2 = 0; index2 < length; ++index2, ++index ) values[start+index2] = m_values[index];
175 } }
176 else {
177 throw Exception( "Array::constructArray: compression '" + m_compression + "' not supported." );
178 }
179
180 FullArray fullArray( m_shape, values );
181 return( fullArray );
182}
std::size_t size() const

◆ dimension()

std::size_t GIDI::Array::Array::dimension ( ) const
inline

Returns the dimension of the array.

Definition at line 927 of file GIDI.hpp.

◆ shape()

std::vector< std::size_t > const & GIDI::Array::Array::shape ( ) const
inline

Returns a const reference to member m_shape.

Definition at line 929 of file GIDI.hpp.

◆ size()

std::size_t GIDI::Array::Array::size ( ) const

Calculates the size of this which is the product of all the m_shape values.

Returns
The product of the m_shape values.

Definition at line 145 of file GIDI_arrays.cc.

145 {
146
147 std::size_t size1 = 1;
148 for( auto iter = m_shape.begin( ); iter != m_shape.end( ); ++iter ) size1 *= *iter;
149
150 return( size1 );
151}

Referenced by constructArray().

◆ toXMLList()

void GIDI::Array::Array::toXMLList ( GUPI::WriteInfo & a_writeInfo,
std::string const & a_indent ) const
virtual

Fills the argument a_writeInfo with the XML lines that represent this. Recursively enters each sub-node. Currently does nothing.

Parameters
a_writeInfo[in/out] Instance containing incremental indentation and other information and stores the appended lines.
a_indent[in] The amount to indent this node.

Reimplemented from GUPI::Ancestry.

Definition at line 192 of file GIDI_arrays.cc.

192 {
193
194}

The documentation for this class was generated from the following files: