Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
GIDI_array3d.cc
Go to the documentation of this file.
1/*
2# <<BEGIN-copyright>>
3# Copyright 2019, Lawrence Livermore National Security, LLC.
4# This file is part of the gidiplus package (https://github.com/LLNL/gidiplus).
5# gidiplus is licensed under the MIT license (see https://opensource.org/licenses/MIT).
6# SPDX-License-Identifier: MIT
7# <<END-copyright>>
8*/
9
10#include <stdlib.h>
11#include <algorithm>
12
13#include "GIDI.hpp"
14#include <HAPI.hpp>
15
16namespace GIDI {
17
18/*! \class Array3d
19 * Class to store a 3d array.
20 */
21
22/* *********************************************************************************************************//**
23 *
24 * @param a_node [in] The **HAPI::Node** to be parsed and used to construct the Array3d.
25 * @param a_setupInfo [in] Information create my the Protare constructor to help in parsing.
26 * @param a_useSystem_strtod [in] Flag passed to the function nfu_stringToListOfDoubles.
27 ***********************************************************************************************************/
28
29Array3d::Array3d( HAPI::Node const &a_node, SetupInfo &a_setupInfo, int a_useSystem_strtod ) :
30 Form( a_node, a_setupInfo, FormType::array3d ),
31 m_array( a_node, a_setupInfo, 3, a_useSystem_strtod ) {
32
33}
34
35/* *********************************************************************************************************//**
36 ***********************************************************************************************************/
37
41
42/* *********************************************************************************************************//**
43 * Only for internal use. Called by ProtareTNSL instance to zero the lower energy multi-group data covered by the ProtareSingle that
44 * contains the TNSL data covers the lower energy multi-group data.
45 *
46 * @param a_maxTNSL_index [in] All elements up to "row" *a_maxTNSL_index* exclusive are zero-ed.
47 ***********************************************************************************************************/
48
49void Array3d::modifiedMultiGroupElasticForTNSL( std::size_t a_maxTNSL_index ) {
50
51 auto const &m_shape = m_array.shape( );
52 std::size_t maxFlatIndex = a_maxTNSL_index * m_shape[1] * m_shape[2];
53
54 m_array.setToValueInFlatRange( 0, maxFlatIndex, 0.0 );
55}
56
57
58/* *********************************************************************************************************//**
59 * Returns the matrix that represents the specified 3rd dimension. That is the matrix M[i][j] for all i, j of A2d[i][j][*a_index*].
60 * This is mainly used for multi-group, Legendre expanded transfer matrices where a specific Legendre order is requested. This is,
61 * the matrix represent the *energy_in* as rows and the *energy_outp* as columns for a specific Legendre order.
62 *
63 * @param a_index [in] The requested *index* for the 3rd dimension.
64 ***********************************************************************************************************/
65
66Matrix Array3d::matrix( std::size_t a_index ) const {
67
68 if( size( ) <= a_index ) {
69 Matrix matrix( 0, 0 );
70 return( matrix );
71 }
72
73 std::size_t numberOfOrders = static_cast<std::size_t>( m_array.m_shape[2] );
74 std::size_t rows = static_cast<std::size_t>( m_array.m_shape[0] );
75 std::size_t columns = static_cast<std::size_t>( m_array.m_shape[1] );
76 Matrix matrix( rows, columns );
77
78 std::size_t lengthSum = 0;
79 for( std::size_t i1 = 0; i1 < m_array.m_numberOfStarts; ++i1 ) {
80 std::size_t start = static_cast<std::size_t>( m_array.m_starts[i1] );
81 std::size_t length = static_cast<std::size_t>( m_array.m_lengths[i1] );
82
83 std::size_t energyInIndex = start / ( numberOfOrders * columns );
84 std::size_t energyOutIndex = start % ( numberOfOrders * columns );
85 std::size_t orderIndex = energyOutIndex % numberOfOrders;
86 energyOutIndex /= numberOfOrders;
87
88 std::size_t step = a_index - orderIndex;
89 if( orderIndex > a_index ) {
90 ++energyOutIndex;
91 if( energyOutIndex >= columns ) {
92 energyOutIndex = 0;
93 ++energyInIndex;
94 }
95 step += numberOfOrders;
96 }
97 std::size_t dataIndex = lengthSum + step;
98 for( ; step < length; step += numberOfOrders ) {
99 matrix.set( energyInIndex, energyOutIndex, m_array.m_dValues[dataIndex] );
100 ++energyOutIndex;
101 if( energyOutIndex >= columns ) {
102 energyOutIndex = 0;
103 ++energyInIndex;
104 }
105 dataIndex += numberOfOrders;
106 }
107 lengthSum += length;
108 }
109
110 return( matrix );
111}
112
113}
std::size_t size() const
Definition GIDI.hpp:974
Array3d(HAPI::Node const &a_node, SetupInfo &a_setupInfo, int a_useSystem_strtod)
void modifiedMultiGroupElasticForTNSL(std::size_t maxTNSL_index)
Matrix matrix(std::size_t a_index) const
Form(FormType a_type)
Definition GIDI_form.cc:25
Definition GIDI.hpp:32
FormType
Definition GIDI.hpp:118