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

#include <GIDI.hpp>

Inheritance diagram for GIDI::Functions::Regions2d:

Public Member Functions

 Regions2d (Construction::Settings const &a_construction, HAPI::Node const &a_node, SetupInfo &a_setupInfo, Suite *a_parent)
 ~Regions2d ()
double domainMin () const
double domainMax () const
void append (Function2dForm *a_function)
double evaluate (double a_x2, double a_x1) const
std::vector< double > const & Xs () const
std::vector< Function2dForm * > const & function2ds () const
void toXMLList_func (GUPI::WriteInfo &a_writeInfo, std::string const &a_indent, bool a_embedded, bool a_inRegions) const
Public Member Functions inherited from GIDI::Functions::Function2dForm
 Function2dForm (std::string const &a_moniker, FormType a_type, ptwXY_interpolation a_interpolation, int a_index, double a_outerDomainValue)
 Function2dForm (std::string const &a_moniker, FormType a_type, Axes const &a_axes, ptwXY_interpolation a_interpolation, int a_index, double a_outerDomainValue)
 Function2dForm (Construction::Settings const &a_construction, HAPI::Node const &a_node, SetupInfo &a_setupInfo, FormType a_type, Suite *a_suite=nullptr)
 Function2dForm (Function2dForm const &a_form)
 ~Function2dForm ()
Public Member Functions inherited from GIDI::Functions::FunctionForm
 FunctionForm (std::string const &a_moniker, FormType a_type, int a_dimension, ptwXY_interpolation a_interpolation, int a_index, double a_outerDomainValue)
 FunctionForm (std::string const &a_moniker, FormType a_type, int a_dimension, Axes const &a_axes, ptwXY_interpolation a_interpolation, int a_index, double a_outerDomainValue)
 FunctionForm (Construction::Settings const &a_construction, HAPI::Node const &a_node, SetupInfo &a_setupInfo, FormType a_type, int a_dimension, Suite *a_suite=nullptr)
 FunctionForm (FunctionForm const &a_form)
 ~FunctionForm ()
FunctionFormoperator= (FunctionForm const &a_rhs)
int dimension () const
int index () const
double outerDomainValue () const
void setOuterDomainValue (double a_outerDomainValue)
Axes const & axes () const
Axesaxes ()
ptwXY_interpolation interpolation () const
void setInterpolation (ptwXY_interpolation a_interpolation)
std::string interpolationString () 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

Class for the GNDS <regions2d> node.

Definition at line 1864 of file GIDI.hpp.

Constructor & Destructor Documentation

◆ Regions2d()

GIDI::Functions::Regions2d::Regions2d ( Construction::Settings const & a_construction,
HAPI::Node const & a_node,
SetupInfo & a_setupInfo,
Suite * a_parent )
Parameters
a_construction[in] Used to pass user options to the constructor.
a_node[in] The HAPI::Node to be parsed and used to construct the XYs2d.
a_setupInfo[in] Information create my the Protare constructor to help in parsing.
a_parent[in] The parent GIDI::Suite.

Definition at line 29 of file GIDI_regions2d.cc.

29 :
30 Function2dForm( a_construction, a_node, a_setupInfo, FormType::regions2d, a_parent ) {
31
32 if( a_setupInfo.m_formatVersion.format( ) != GNDS_formatVersion_1_10Chars ) {
33 data2dListParse( a_construction, a_node.child( GIDI_function2dsChars ), a_setupInfo, m_function2ds );
34 checkSequentialDomainLimits2d( m_function2ds, m_Xs );
35 return; // Need to add uncertainty parsing.
36 }
37
38 for( HAPI::Node child = a_node.first_child( ); !child.empty( ); child.to_next_sibling( ) ) {
39 std::string name( child.name( ) );
40
41 if( name == GIDI_axesChars ) continue;
42 if( name == GIDI_uncertaintyChars ) continue;
43
44 Function2dForm *_form = data2dParse( a_construction, child, a_setupInfo, nullptr );
45 if( _form == nullptr ) throw Exception( "Regions2d::Regions2d: data2dParse returned nullptr." );
46 append( _form );
47 }
48}
#define GIDI_function2dsChars
Definition GIDI.hpp:388
#define GIDI_axesChars
Definition GIDI.hpp:382
#define GIDI_uncertaintyChars
Definition GIDI.hpp:389
#define GNDS_formatVersion_1_10Chars
Definition LUPI.hpp:48
Function2dForm(std::string const &a_moniker, FormType a_type, ptwXY_interpolation a_interpolation, int a_index, double a_outerDomainValue)
Definition GIDI_form.cc:476
void append(Function2dForm *a_function)
const char * name(G4int ptype)
void data2dListParse(Construction::Settings const &a_construction, HAPI::Node const &a_node, SetupInfo &a_setupInfo, std::vector< Functions::Function2dForm * > &a_function2ds)
Functions::Function2dForm * data2dParse(Construction::Settings const &a_construction, HAPI::Node const &a_node, SetupInfo &a_setupInfo, Suite *parent)
void checkSequentialDomainLimits2d(std::vector< Functions::Function2dForm * > &a_functions, std::vector< double > &a_Xs)

◆ ~Regions2d()

GIDI::Functions::Regions2d::~Regions2d ( )

Definition at line 53 of file GIDI_regions2d.cc.

53 {
54
55 for( std::vector<Function2dForm *>::iterator iter = m_function2ds.begin( ); iter < m_function2ds.end( ); ++iter ) delete *iter;
56}

Member Function Documentation

◆ append()

void GIDI::Functions::Regions2d::append ( Function2dForm * a_function)

Appends the 2d function a_function to the region.

Definition at line 87 of file GIDI_regions2d.cc.

87 {
88
89 if( dimension( ) != a_function->dimension( ) ) throw Exception( "Regions2d::append: dimensions differ." );
90
91 double _domainMin = a_function->domainMin( ), _domainMax = a_function->domainMax( );
92
93 if( m_Xs.size( ) == 0 ) {
94 m_Xs.push_back( _domainMin ); }
95 else {
96 if( m_Xs.back( ) != _domainMin ) throw Exception( "Regions2d::append: regions do not abut." );
97 }
98
99 m_Xs.push_back( _domainMax );
100 m_function2ds.push_back( a_function );
101}

◆ domainMax()

double GIDI::Functions::Regions2d::domainMax ( ) const
virtual

Returns the domain maximum for the instance.

Returns
The domain maximum for the instance.

Implements GIDI::Functions::FunctionForm.

Definition at line 76 of file GIDI_regions2d.cc.

76 {
77
78 if( m_Xs.size( ) == 0 ) throw Exception( "Regions2d::domainMax: Regions2d has no regions" );
79 return( m_Xs[m_Xs.size( )-1] );
80}

◆ domainMin()

double GIDI::Functions::Regions2d::domainMin ( ) const
virtual

Returns the domain minimum for the instance.

Returns
The domain minimum for the instance.

Implements GIDI::Functions::FunctionForm.

Definition at line 64 of file GIDI_regions2d.cc.

64 {
65
66 if( m_Xs.size( ) == 0 ) throw Exception( "Regions2d::domainMin: Regions2d has no regions" );
67 return( m_Xs[0] );
68}

◆ evaluate()

double GIDI::Functions::Regions2d::evaluate ( double a_x2,
double a_x1 ) const
virtual

The value of y(x2,x1) at the point a_x2, a_x1.

Parameters
a_x2[in] The point for the x2 axis.
a_x1[in] The point for the x1 axis.
Returns
The value of the function at the point a_x2, a_x1.

Implements GIDI::Functions::Function2dForm.

Definition at line 111 of file GIDI_regions2d.cc.

111 {
112
113 if( m_Xs.size( ) == 0 ) throw Exception( "Regions2d::evaluate: regions2d has no regions" );
114
115 long iX1 = binarySearchVector( a_x1, m_Xs );
116
117 if( iX1 < 0 ) {
118 if( iX1 == -1 ) { /* x1 > last value of Xs. */
119 return( m_function2ds.back( )->evaluate( a_x2, a_x1 ) );
120 }
121 iX1 = 0; /* x1 < last value of Xs. */
122 }
123
124 return( m_function2ds[static_cast<std::size_t>(iX1)]->evaluate( a_x2, a_x1 ) );
125}
double evaluate(double a_x2, double a_x1) const
long binarySearchVector(double a_x, std::vector< double > const &a_Xs)
Definition GIDI_misc.cc:33

Referenced by evaluate().

◆ function2ds()

std::vector< Function2dForm * > const & GIDI::Functions::Regions2d::function2ds ( ) const
inline

Returns the value of the m_function2ds member.

Definition at line 1881 of file GIDI.hpp.

Referenced by MCGIDI::Probabilities::Regions2d::Regions2d().

◆ toXMLList_func()

void GIDI::Functions::Regions2d::toXMLList_func ( GUPI::WriteInfo & a_writeInfo,
std::string const & a_indent,
bool a_embedded,
bool a_inRegions ) const
virtual

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

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.
a_embedded[in] If true, this function is embedded in a higher dimensional function.
a_inRegions[in] If true, this is in a Regions2d container.

Reimplemented from GIDI::Functions::FunctionForm.

Definition at line 136 of file GIDI_regions2d.cc.

136 {
137
138 std::string indent2 = a_writeInfo.incrementalIndent( a_indent );
139 std::string attributes;
140
141 if( a_embedded ) {
143 else {
144 if( a_inRegions ) {
145 attributes = a_writeInfo.addAttribute( GIDI_indexChars, intToString( index( ) ) ); }
146 else {
147 if( label( ) != "" ) attributes = a_writeInfo.addAttribute( GIDI_labelChars, label( ) );
148 }
149 }
150
151 a_writeInfo.addNodeStarter( a_indent, moniker( ), attributes );
152 axes( ).toXMLList( a_writeInfo, indent2 );
153 for( std::vector<Function2dForm *>::const_iterator iter = m_function2ds.begin( ); iter != m_function2ds.end( ); ++iter ) (*iter)->toXMLList_func( a_writeInfo, indent2, false, true );
154 a_writeInfo.addNodeEnder( moniker( ) );
155}
#define GIDI_outerDomainValueChars
Definition GIDI.hpp:436
#define GIDI_labelChars
Definition GIDI.hpp:438
#define GIDI_indexChars
Definition GIDI.hpp:437
void toXMLList(GUPI::WriteInfo &a_writeInfo, std::string const &a_indent="") const
Definition GIDI_axes.cc:113
std::string const & label() const
Definition GIDI.hpp:658
Axes const & axes() const
Definition GIDI.hpp:1012
double outerDomainValue() const
Definition GIDI.hpp:1010
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
std::string intToString(int a_value)
Definition GIDI_misc.cc:415
std::string doubleToShortestString(double a_value, int a_significantDigits=15, int a_favorEFormBy=0)
Definition LUPI_misc.cc:349

◆ Xs()

std::vector< double > const & GIDI::Functions::Regions2d::Xs ( ) const
inline

Returns the value of the m_Xs member.

Definition at line 1880 of file GIDI.hpp.


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