Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
GIDI_flux.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 "GIDI.hpp"
11#include <HAPI.hpp>
12
13namespace GIDI {
14
15/* *********************************************************************************************************//**
16 * @param a_construction [in] Used to pass user options for parsing.
17 * @param a_node [in] The **HAPI::Node** to be parsed and used to construct the Protare.
18 * @param a_setupInfo [in] Information create my the Protare constructor to help in parsing.
19 ***********************************************************************************************************/
20
21Flux::Flux( Construction::Settings const &a_construction, HAPI::Node const &a_node, SetupInfo &a_setupInfo ) :
22 Form( a_node, a_setupInfo, FormType::flux ),
23 m_flux( data2dParse( a_construction, a_node.first_child( ), a_setupInfo, nullptr ) ) {
24
25 if( m_flux != nullptr ) m_flux->setAncestor( this );
26}
27
28/* *********************************************************************************************************//**
29 ***********************************************************************************************************/
30
32
33 delete m_flux;
34}
35
36/* *********************************************************************************************************//**
37 * Fills the argument *a_writeInfo* with the XML lines that represent *this*. Recursively enters each sub-node.
38 *
39 * @param a_writeInfo [in/out] Instance containing incremental indentation and other information and stores the appended lines.
40 * @param a_indent [in] The amount to indent *this* node.
41 ***********************************************************************************************************/
42
43void Flux::toXMLList( GUPI::WriteInfo &a_writeInfo, std::string const &a_indent ) const {
44
45 std::string indent2 = a_writeInfo.incrementalIndent( a_indent );
46 std::string attributes = a_writeInfo.addAttribute( GIDI_labelChars, label( ) );
47
48 a_writeInfo.addNodeStarter( a_indent, moniker( ), attributes );
49 if( m_flux != nullptr ) m_flux->toXMLList( a_writeInfo, indent2 );
50 a_writeInfo.addNodeEnder( moniker( ) );
51}
52
53/*! \class Fluxes
54 * Class for the GNDS <**fluxes**> node that contains a list of flux nodes each as a 3d function.
55 */
56
57/* *********************************************************************************************************//**
58 ***********************************************************************************************************/
59
64
65/* *********************************************************************************************************//**
66 * @param a_fileName [in] File containing a fluxes node to be parsed.
67 ***********************************************************************************************************/
68
69Fluxes::Fluxes( std::string const &a_fileName ) :
71
72 addFile( a_fileName );
73}
74
75/* *********************************************************************************************************//**
76* Adds the contents of the specified file to *this*.
77 *
78 ***********************************************************************************************************/
79
80void Fluxes::addFile( std::string const &a_fileName ) {
81
82 HAPI::File *doc = new HAPI::PugiXMLFile( a_fileName.c_str( ), "Fluxes::addFile" );
83
85
86 std::string name( fluxes.name( ) );
88
89 SetupInfo setupInfo( nullptr );
90
91 std::string formatVersionString = fluxes.attribute_as_string( GIDI_formatChars );
92 if( formatVersionString == "" ) formatVersionString = GNDS_formatVersion_1_10Chars;
93 LUPI::FormatVersion formatVersion;
94 formatVersion.setFormat( formatVersionString );
95 if( !formatVersion.supported( ) ) throw Exception( "unsupport GND format version" );
96 setupInfo.m_formatVersion = formatVersion;
97
98 for( HAPI::Node child = fluxes.first_child( ); !child.empty( ); child.to_next_sibling( ) ) {
99 Functions::Function3dForm *function3d = data3dParse( construction, child, setupInfo, nullptr );
100
101 add( function3d );
102 }
103 delete doc;
104}
105
106}
#define GIDI_labelChars
Definition GIDI.hpp:438
#define GIDI_formatChars
Definition GIDI.hpp:167
#define GIDI_fluxesChars
Definition GIDI.hpp:238
#define GNDS_formatVersion_1_10Chars
Definition LUPI.hpp:48
void toXMLList(GUPI::WriteInfo &a_writeInfo, std::string const &a_indent) const
Definition GIDI_flux.cc:43
Flux(Construction::Settings const &a_construction, HAPI::Node const &a_node, SetupInfo &a_setupInfo)
Definition GIDI_flux.cc:21
void addFile(std::string const &a_fileName)
Definition GIDI_flux.cc:80
std::string const & label() const
Definition GIDI.hpp:658
Form(FormType a_type)
Definition GIDI_form.cc:25
LUPI::FormatVersion m_formatVersion
Definition GIDI.hpp:599
Suite(std::string const &a_keyName=GIDI_labelChars)
Definition GIDI_suite.cc:22
void add(Form *a_form)
std::string const & moniker() const
Definition GUPI.hpp:102
void addNodeEnder(std::string const &a_moniker)
Definition GUPI.hpp:59
std::string incrementalIndent(std::string const &indent)
Definition GUPI.hpp:52
void addNodeStarter(std::string const &indent, std::string const &a_moniker, std::string const &a_attributes="")
Definition GUPI.hpp:55
std::string addAttribute(std::string const &a_name, std::string const &a_value) const
Definition GUPI.hpp:60
virtual Node first_child()=0
bool empty() const
Definition HAPI_Node.cc:150
Node first_child() const
Definition HAPI_Node.cc:82
bool setFormat(std::string const &a_formatVersion)
Definition GIDI.hpp:32
FormType
Definition GIDI.hpp:118
Functions::Function2dForm * data2dParse(Construction::Settings const &a_construction, HAPI::Node const &a_node, SetupInfo &a_setupInfo, Suite *parent)
Functions::Function3dForm * data3dParse(Construction::Settings const &a_construction, HAPI::Node const &a_node, SetupInfo &a_setupInfo, Suite *parent)