Skip to content

Commit

Permalink
Moving from old disco to tools/disco
Browse files Browse the repository at this point in the history
  • Loading branch information
whaeck committed Apr 16, 2024
1 parent f834b43 commit c9f9da6
Show file tree
Hide file tree
Showing 21 changed files with 92 additions and 78 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ target_include_directories( ENDFtk
target_link_libraries( ENDFtk
INTERFACE
njoy::tools
disco
range-v3
)

Expand Down
9 changes: 1 addition & 8 deletions cmake/develop_dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ include( FetchContent )

FetchContent_Declare( tools
GIT_REPOSITORY https://github.com/njoy/tools
GIT_TAG v0.2.0
GIT_TAG feature/disco
GIT_SHALLOW TRUE
)

Expand All @@ -17,12 +17,6 @@ FetchContent_Declare( Catch2
GIT_SHALLOW TRUE
)

FetchContent_Declare( disco
GIT_REPOSITORY https://github.com/njoy/disco
GIT_TAG origin/master
GIT_SHALLOW TRUE
)

FetchContent_Declare( range-v3
GIT_REPOSITORY https://github.com/ericniebler/range-v3
GIT_TAG 0.11.0
Expand All @@ -39,6 +33,5 @@ FetchContent_Declare( pybind11

FetchContent_MakeAvailable(
tools
disco
range-v3
)
15 changes: 5 additions & 10 deletions cmake/release_dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,14 @@ include( FetchContent )
# Declare project dependencies
#######################################################################

FetchContent_Declare( catch-adapter
GIT_REPOSITORY https://github.com/njoy/catch-adapter
GIT_TAG fb84b82ebf7a4789aa43cea560680cf745c6ee4f
)

FetchContent_Declare( Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2
GIT_TAG 3f0283de7a9c43200033da996ff9093be3ac84dc # tag: v3.3.2
)

FetchContent_Declare( disco
GIT_REPOSITORY https://github.com/njoy/disco
GIT_TAG 2606933a854bb0269c4ec37143e1236797e27838
FetchContent_Declare( fast_float
GIT_REPOSITORY https://github.com/fastfloat/fast_float
GIT_TAG f476bc713fda06fbd34dc621b466745a574b3d4c # tag: v6.1.1
)

FetchContent_Declare( pybind11
Expand All @@ -38,15 +33,15 @@ set( SPDLOG_BUILD_PIC CACHE INTERNAL BOOL ON )

FetchContent_Declare( tools
GIT_REPOSITORY https://github.com/njoy/tools
GIT_TAG 25c9273d05601a9644feea6d7539250bf1d1c0dc # tag: v0.2.0
GIT_TAG 8db01f66cd75a4ae61289fec7d6a58b562fb7913
)

#######################################################################
# Load dependencies
#######################################################################

FetchContent_MakeAvailable(
disco
fast_float
range-v3
spdlog
tools
Expand Down
4 changes: 3 additions & 1 deletion src/ENDFtk/ControlRecord/src/print.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
*/
template< typename OutputIterator >
void print( OutputIterator& it, int MAT, int MF, int MT ) const {

using namespace njoy::tools;
using Format = disco::Record< disco::ENDF, disco::ENDF,
disco::Integer< 11 >, disco::Integer< 11 >,
disco::Integer< 11 >, disco::Integer< 11 >,
disco::Integer< 4 >, disco::Integer< 2>,
disco::Integer< 3 >, disco::ColumnPosition<5> >;
disco::Integer< 3 >, disco::Column<5> >;
Format::write( it,
this->C1(), this->C2(),
this->L1(), this->L2(),
Expand Down
3 changes: 2 additions & 1 deletion src/ENDFtk/DirectoryRecord/src/print.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@
template< typename OutputIterator >
void print( OutputIterator& it, int MAT, int MF, int MT ) const {

using namespace njoy::tools;
using Format = disco::Record< disco::Integer< 33 >, disco::Integer< 11 >,
disco::Integer< 11 >, disco::Integer< 11 >,
disco::Integer< 4 >, disco::Integer< 2 >,
disco::Integer< 3 >, disco::ColumnPosition<5> >;
disco::Integer< 3 >, disco::Column<5> >;
Format::write( it, this->MF(), this->MT(),
this->NC(), this->MOD(), MAT, MF, MT );
}
10 changes: 6 additions & 4 deletions src/ENDFtk/ListRecord/src/print.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@
*/
template< typename OutputIterator >
void print( OutputIterator& it, int MAT, int MF, int MT ) const {

using namespace njoy::tools;
{
using Format = disco::Record< disco::ENDF, disco::ENDF,
disco::Integer< 11 >, disco::Integer< 11 >,
disco::Integer< 11 >, disco::Integer< 11 >,
disco::Integer< 4 >, disco::Integer< 2 >,
disco::Integer< 3 >, disco::ColumnPosition<5> >;
disco::Integer< 3 >, disco::Column<5> >;
Format::write( it,
this->C1(), this->C2(),
this->L1(), this->L2(),
Expand All @@ -26,7 +28,7 @@ void print( OutputIterator& it, int MAT, int MF, int MT ) const {
disco::ENDF, disco::ENDF,
disco::ENDF, disco::ENDF,
disco::Integer< 4 >, disco::Integer< 2 >,
disco::Integer< 3 >, disco::ColumnPosition<5> >;
disco::Integer< 3 >, disco::Column<5> >;

auto nFullLines = this->NPL() / 6;
auto partialLineEntries = this->NPL() - nFullLines * 6;
Expand All @@ -47,11 +49,11 @@ void print( OutputIterator& it, int MAT, int MF, int MT ) const {

auto blankEntries = 6 - partialLineEntries;

while ( blankEntries-- ){ disco::ColumnPosition< 11 >::write( it ); }
while ( blankEntries-- ){ disco::Column< 11 >::write( it ); }

using Format =
disco::Record< disco::Integer< 4 >, disco::Integer< 2 >,
disco::Integer< 3 >, disco::ColumnPosition< 5 > >;
disco::Integer< 3 >, disco::Column< 5 > >;

Format::write( it, MAT, MF, MT );
}
Expand Down
5 changes: 3 additions & 2 deletions src/ENDFtk/StructureDivision.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,15 @@ namespace ENDFtk {
template< typename OutputIterator >
void print( OutputIterator& it ) const {

using namespace njoy::tools;
if ( this->isHead() ) {

using Format = disco::Record< disco::ENDF, disco::ENDF,
disco::Integer< 11 >, disco::Integer< 11 >,
disco::Integer< 11 >, disco::Integer< 11 >,
disco::Integer< 4 >, disco::Integer< 2>,
disco::Integer< 3 >,
disco::ColumnPosition<5> >;
disco::Column<5> >;
Format::write( it, std::get< 0 >( this->base.fields ),
std::get< 1 >( this->base.fields ),
std::get< 2 >( this->base.fields ),
Expand All @@ -165,7 +166,7 @@ namespace ENDFtk {
using Format = disco::Record< disco::Integer< 70 >,
disco::Integer< 2 >,
disco::Integer< 3 >,
disco::ColumnPosition<5> >;
disco::Column<5> >;
Format::write( it, this->tail.MAT(), this->tail.MF(), this->tail.MT() );
}
}
Expand Down
8 changes: 5 additions & 3 deletions src/ENDFtk/TabulationRecord/src/print.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ template< typename OutputIterator >
void print( OutputIterator& it, int MAT, int MF, int MT ) const {
record::InterpolationBase::print( it, MAT, MF, MT );

using namespace njoy::tools;

using Format = disco::Record< disco::ENDF, disco::ENDF,
disco::ENDF, disco::ENDF,
disco::ENDF, disco::ENDF,
disco::Integer< 4 >, disco::Integer< 2 >,
disco::Integer< 3 >, disco::ColumnPosition< 5 > >;
disco::Integer< 3 >, disco::Column< 5 > >;

auto nFullLines = this->NP() / 3;
auto partialLineEntries = this->NP() - nFullLines * 3;
Expand All @@ -37,11 +39,11 @@ void print( OutputIterator& it, int MAT, int MF, int MT ) const {
++x; ++y;
}

while ( blankEntries-- ){ disco::ColumnPosition< 11 >::write( it ); }
while ( blankEntries-- ){ disco::Column< 11 >::write( it ); }

using Format =
disco::Record< disco::Integer< 4 >, disco::Integer< 2 >,
disco::Integer< 3 >, disco::ColumnPosition< 5 > >;
disco::Integer< 3 >, disco::Column< 5 > >;

Format::write( it, MAT, MF, MT );
}
Expand Down
5 changes: 4 additions & 1 deletion src/ENDFtk/TapeIdentification/src/print.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@
*/
template< typename OutputIterator >
void print( OutputIterator& it, int MAT, int MF, int MT ) const {

using namespace njoy::tools;

using Format = disco::Record< disco::Character< 66 >,
disco::Integer< 4 >, disco::Integer< 2 >,
disco::Integer< 3 >, disco::ColumnPosition<5> >;
disco::Integer< 3 >, disco::Column<5> >;
Format::write( it, this->text(), MAT, MF, MT );
}
5 changes: 4 additions & 1 deletion src/ENDFtk/TextRecord/src/print.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
template< typename OutputIterator >
void print( OutputIterator& it, int MAT, int MF, int MT ) const {

using namespace njoy::tools;

using Format = disco::Record< disco::Character< 66 >,
disco::Integer< 4 >, disco::Integer< 2 >,
disco::Integer< 3 >, disco::ColumnPosition< 5 > >;
disco::Integer< 3 >, disco::Column< 5 > >;
Format::write( it, this->text(), MAT, MF, MT );
}
5 changes: 3 additions & 2 deletions src/ENDFtk/record/Base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

// other includes
#include "tools/Log.hpp"
#include "tools/disco/Record.hpp"
#include "ENDFtk/record/helper.hpp"
#include "ENDFtk/record/Character.hpp"
#include "ENDFtk/record/Integer.hpp"
Expand All @@ -26,8 +27,8 @@ namespace record {

/* convenience typedefs */
using FieldTuple = std::tuple< typename Fields::Type... >;
using Format = disco::Record< typename Fields::Parser...,
disco::RetainCarriage >;
using Format = njoy::tools::disco::Record< typename Fields::Parser...,
njoy::tools::disco::RetainCarriage >;

template< int Index >
using ShouldRecurse =
Expand Down
4 changes: 2 additions & 2 deletions src/ENDFtk/record/Character.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// system includes

// other includes
#include "disco.hpp"
#include "tools/disco/Character.hpp"
#include "ENDFtk/record/helper.hpp"

namespace njoy {
Expand All @@ -15,7 +15,7 @@ namespace record {
struct Character {
static constexpr std::size_t width = w;
using Type = std::string;
using Parser = disco::Character< width >;
using Parser = njoy::tools::disco::Character< width >;

static constexpr const Type& defaultValue = helper::defaultString< w >;
};
Expand Down
4 changes: 2 additions & 2 deletions src/ENDFtk/record/Integer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// system includes

// other includes
#include "disco.hpp"
#include "tools/disco/Integer.hpp"

namespace njoy {
namespace ENDFtk {
Expand All @@ -14,7 +14,7 @@ namespace record {
struct Integer{
static constexpr std::size_t width = w;
using Type = long;
using Parser = disco::Integer< width >;
using Parser = njoy::tools::disco::Integer< width >;

static constexpr Type defaultValue = 0;
};
Expand Down
14 changes: 8 additions & 6 deletions src/ENDFtk/record/IntegerBase/src/print.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
template< typename OutputIterator >
void print( OutputIterator& it, int MAT, int MF, int MT ) const {

using namespace njoy::tools;

record::Integer< 5 >::Parser::write( this->I(), it );
record::Integer< 5 >::Parser::write( this->J(), it );

if ( NDIGIT != 6 ) { disco::ColumnPosition< 1 >::write( it ); };
if ( NDIGIT != 6 ) { disco::Column< 1 >::write( it ); };

for ( auto value : this->K() ) {

Expand All @@ -23,18 +25,18 @@ void print( OutputIterator& it, int MAT, int MF, int MT ) const {

switch ( NDIGIT ) {

case 2: { disco::ColumnPosition< 1 >::write( it ); break; }
case 3: { disco::ColumnPosition< 3 >::write( it ); break; }
case 5: { disco::ColumnPosition< 1 >::write( it ); break; }
case 2: { disco::Column< 1 >::write( it ); break; }
case 3: { disco::Column< 3 >::write( it ); break; }
case 5: { disco::Column< 1 >::write( it ); break; }
default: { /* unreachable */ break; }
}

int blankEntries = N - this->K().size();
while ( blankEntries-- ){ disco::ColumnPosition< NDIGIT + 1 >::write( it ); }
while ( blankEntries-- ){ disco::Column< NDIGIT + 1 >::write( it ); }

using Format =
disco::Record< disco::Integer< 4 >, disco::Integer< 2 >,
disco::Integer< 3 >, disco::ColumnPosition< 5 > >;
disco::Integer< 3 >, disco::Column< 5 > >;

Format::write( it, MAT, MF, MT );
}
4 changes: 4 additions & 0 deletions src/ENDFtk/record/InterpolationBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
#include <vector>

// other includes
#include "tools/disco/Integer.hpp"
#include "tools/disco/ENDF.hpp"
#include "tools/disco/Column.hpp"
#include "tools/disco/Record.hpp"
#include "range/v3/view/all.hpp"
#include "ENDFtk/record/Base.hpp"
#include "ENDFtk/record/Integer.hpp"
Expand Down
22 changes: 12 additions & 10 deletions src/ENDFtk/record/InterpolationBase/src/print.hpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
template< typename OutputIterator >
void print( OutputIterator& it, int MAT, int MF, int MT ) const {

using namespace njoy::tools;

{
using Format = disco::Record< disco::ENDF, disco::ENDF,
disco::Integer< 11 >, disco::Integer< 11 >,
disco::Integer< 11 >, disco::Integer< 11 >,
disco::Integer< 4 >, disco::Integer< 2 >,
disco::Integer< 3 >, disco::ColumnPosition< 5 > >;
disco::Integer< 3 >, disco::Column< 5 > >;
Format::write( it,
this->C1(), this->C2(),
this->L1(), this->L2(),
Expand All @@ -17,14 +20,14 @@ void print( OutputIterator& it, int MAT, int MF, int MT ) const {
disco::Integer< 11 >, disco::Integer< 11 >,
disco::Integer< 11 >, disco::Integer< 11 >,
disco::Integer< 4 >, disco::Integer< 2 >,
disco::Integer< 3 >, disco::ColumnPosition< 5 > >;
disco::Integer< 3 >, disco::Column< 5 > >;

auto nFullLines = this->NR() / 3;
auto partialLineEntries = this->NR() - nFullLines * 3;

auto boundary = this->boundaries().begin();
auto interpolant = this->interpolants().begin();

while ( nFullLines-- ){
Format::write( it,
boundary[0], interpolant[0],
Expand All @@ -33,23 +36,22 @@ void print( OutputIterator& it, int MAT, int MF, int MT ) const {
MAT, MF, MT );
boundary += 3; interpolant += 3;
}

if ( partialLineEntries ){
auto blankEntries = 2 * ( 3 - partialLineEntries );
while ( partialLineEntries-- ){
disco::Integer<11>::write( *boundary, it );
disco::Integer<11>::write( *interpolant, it );
++boundary; ++interpolant;
}
while ( blankEntries-- ){ disco::ColumnPosition< 11 >::write( it ); }

while ( blankEntries-- ){ disco::Column< 11 >::write( it ); }

using Format =
disco::Record< disco::Integer< 4 >, disco::Integer< 2 >,
disco::Integer< 3 >, disco::ColumnPosition< 5 > >;
disco::Integer< 3 >, disco::Column< 5 > >;

Format::write( it, MAT, MF, MT );
}
}
}
}
}

Loading

0 comments on commit c9f9da6

Please sign in to comment.