-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from njoy/feature/initial-v2
Feature/initial v2
- Loading branch information
Showing
70 changed files
with
3,593 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#include "NDItk/multigroup/Metadata.hpp" | ||
#include "NDItk/multigroup/Structure.hpp" | ||
#include "NDItk/multigroup/FluxWeights.hpp" | ||
#include "NDItk/multigroup/CrossSection.hpp" | ||
#include "NDItk/multigroup/ReactionCrossSections.hpp" | ||
|
||
#include "NDItk/MultigroupTable.hpp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
#ifndef NJOY_NDITK_MULTIGROUP | ||
#define NJOY_NDITK_MULTIGROUP | ||
|
||
// system includes | ||
|
||
// other includes | ||
#include "tools/Log.hpp" | ||
#include "NDItk/multigroup/Metadata.hpp" | ||
#include "NDItk/multigroup/Structure.hpp" | ||
#include "NDItk/multigroup/FluxWeights.hpp" | ||
#include "NDItk/multigroup/ReactionCrossSections.hpp" | ||
|
||
namespace njoy { | ||
namespace NDItk { | ||
|
||
/** | ||
* @brief A multigroup NDI table | ||
*/ | ||
class MultigroupTable { | ||
|
||
/* fields */ | ||
|
||
multigroup::Metadata metadata_; | ||
multigroup::Structure structure_; | ||
multigroup::FluxWeights weights_; | ||
multigroup::ReactionCrossSections xs_; | ||
|
||
/* auxiliary functions */ | ||
|
||
#include "NDItk/MultigroupTable/src/readRecord.hpp" | ||
#include "NDItk/MultigroupTable/src/verify.hpp" | ||
|
||
public: | ||
|
||
/* constructor */ | ||
|
||
#include "NDItk/MultigroupTable/src/ctor.hpp" | ||
|
||
/* methods */ | ||
|
||
/** | ||
* @brief Return the metadata of the table | ||
*/ | ||
const multigroup::Metadata& metadata() const { return this->metadata_; } | ||
|
||
/** | ||
* @brief Return the primary group structure record | ||
*/ | ||
const multigroup::Structure& structure() const { return this->structure_; } | ||
|
||
/** | ||
* @brief Return the flux weight record | ||
*/ | ||
const multigroup::FluxWeights& flux() const { return this->weights_; } | ||
|
||
/** | ||
* @brief Return the reaction cross section record | ||
*/ | ||
const multigroup::ReactionCrossSections& reactionCrossSections() const { | ||
|
||
return this->xs_; | ||
} | ||
|
||
#include "NDItk/MultigroupTable/src/read.hpp" | ||
|
||
/** | ||
* @brief Print the NDI table | ||
* | ||
* @param[in] iter the current position in the output | ||
*/ | ||
template< typename OutputIterator > | ||
void print( OutputIterator& iter ) const { | ||
|
||
this->metadata_.print( iter ); | ||
this->structure_.print( iter ); | ||
this->weights_.print( iter ); | ||
this->xs_.print( iter ); | ||
*iter++ = 'e'; | ||
*iter++ = 'n'; | ||
*iter++ = 'd'; | ||
*iter++ = '\n'; | ||
}; | ||
}; | ||
|
||
} // NDItk namespace | ||
} // njoy namespace | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** | ||
* @brief Default constructor | ||
*/ | ||
MultigroupTable() : metadata_(), structure_(), weights_(), xs_() {} | ||
|
||
/** | ||
* @brief Constructor | ||
* | ||
* @param[in] zaid the zaid of the table | ||
* @param[in] libname the library name | ||
* @param[in] source the source date | ||
* @param[in] process the processing date | ||
* @param[in] awr the atomic weight ratio of the target | ||
* (with respect to the neutron mass) | ||
* @param[in] weight the atomic weight of the target | ||
* @param[in] temperature the temperature of the target | ||
* @param[in] dilution the dilution (aka sigma0) | ||
* @param[in] structure the primary group structure | ||
* @param[in] weights the flux weights | ||
* @param[in] xs the reaction cross section data | ||
*/ | ||
MultigroupTable( std::string zaid, std::string libname, std::string source, | ||
std::string process, double awr, double weight, double temperature, | ||
double dilution, | ||
multigroup::Structure structure, | ||
multigroup::FluxWeights weigths, | ||
multigroup::ReactionCrossSections xs ) : | ||
metadata_( std::move( zaid ), std::move( libname ), std::move( source ), | ||
std::move( process ), awr, weight, temperature, dilution, | ||
xs.numberGroups(), xs.numberReactions() ), | ||
structure_( std::move( structure ) ), | ||
weights_( std::move( weigths ) ), | ||
xs_( std::move( xs ) ) { | ||
|
||
this->verify(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/** | ||
* @brief Read the table data | ||
* | ||
* @param[in] iter the current position in the input | ||
*/ | ||
template< typename Iterator > | ||
void read( Iterator& iter, const Iterator& end ) { | ||
|
||
std::string keyword; | ||
while ( ( keyword != "end" ) && ( iter != end ) ) { | ||
|
||
keyword = njoy::tools::disco::FreeFormatCharacter::read< std::string >( iter, end ); | ||
|
||
if ( this->metadata_.isMetadataKey( keyword ) ) { | ||
|
||
this->metadata_.read( keyword, iter, end ); | ||
} | ||
else if ( keyword == this->structure_.keyword() ) { | ||
|
||
if ( this->metadata_.numberGroups().has_value() ) { | ||
|
||
readRecord( this->structure_, iter, end, | ||
this->metadata_.numberGroups().value() + 1 ); | ||
} | ||
else { | ||
|
||
Log::error( "Metadata required for the \'\' record was not found", keyword ); | ||
Log::info( "Required metadata is missing: number of groups in the primary group structure" ); | ||
throw std::exception(); | ||
} | ||
} | ||
else if ( keyword == this->weights_.keyword() ) { | ||
|
||
if ( this->metadata_.numberGroups().has_value() ) { | ||
|
||
readRecord( this->weights_, iter, end, this->metadata_.numberGroups().value() ); | ||
} | ||
else { | ||
|
||
Log::error( "Metadata required for the \'\' record was not found", keyword ); | ||
Log::info( "Required metadata is missing: number of groups in the primary group structure" ); | ||
throw std::exception(); | ||
} | ||
} | ||
else if ( keyword == this->xs_.keyword() ) { | ||
|
||
if ( this->metadata_.numberGroups().has_value() && this->metadata_.numberReactions().has_value() ) { | ||
|
||
readRecord( this->xs_, iter, end, this->metadata_.numberReactions().value(), this->metadata_.numberGroups().value() ); | ||
} | ||
else { | ||
|
||
Log::error( "Metadata required for the \'\' record was not found", keyword ); | ||
if ( ! this->metadata_.numberGroups().has_value() ) { | ||
|
||
Log::info( "Required metadata is missing: number of groups in the primary group structure" ); | ||
} | ||
if ( ! this->metadata_.numberReactions().has_value() ) { | ||
|
||
Log::info( "Required metadata is missing: number of reactions" ); | ||
} | ||
throw std::exception(); | ||
} | ||
} | ||
else { | ||
|
||
if ( keyword != "end" ) { | ||
|
||
Log::error( "Unknown keyword found: \'{}\'", keyword ); | ||
throw std::exception(); | ||
} | ||
} | ||
|
||
while ( std::isspace( *iter ) && iter != end ) { | ||
|
||
++iter; | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* @brief A helper function to read a data record | ||
*/ | ||
template < typename Record, typename Iterator, typename... Arguments > | ||
static void readRecord( Record& record, Iterator& iter, const Iterator& end, | ||
Arguments... arguments ) { | ||
|
||
if ( ! record.empty() ) { | ||
|
||
Log::error( "Duplicate keyword found: \'{}\'", record.keyword() ); | ||
throw std::exception(); | ||
} | ||
record.read( iter, end, arguments... ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* @brief Verify the multigroup data | ||
* | ||
* The following verification tests are performed: | ||
* - the number of groups accross the data is consistent | ||
*/ | ||
void verify() { | ||
|
||
// consistent group structure | ||
const auto groups = this->metadata().numberGroups().value(); | ||
if ( ( this->structure().numberGroups() != groups ) || | ||
( this->flux().numberGroups() != groups ) || | ||
( this->reactionCrossSections().numberGroups() != groups ) ) { | ||
|
||
Log::error( "Found inconsistent number of primary groups across the table" ); | ||
Log::info( "Number of primary groups in the metadata: {}", this->metadata().numberGroups().value() ); | ||
Log::info( "Number of primary groups in the structure: {}", this->structure().numberGroups() ); | ||
Log::info( "Number of primary groups in the flux weights: {}", this->flux().numberGroups() ); | ||
Log::info( "Number of primary groups in the reaction cross section data: {}", | ||
this->reactionCrossSections().numberGroups() ); | ||
throw std::exception(); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
add_cpp_test( MultigroupTable MultigroupTable.test.cpp ) |
Oops, something went wrong.