Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .github/workflows/c-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
OMP_NUM_THREADS: 1
OMP_DYNAMIC: FALSE
OPENBLAS_NUM_THREADS: 1
MKL_NUM_THREADS: 1

steps:
- uses: actions/checkout@v2
Expand All @@ -30,8 +34,6 @@ jobs:
cd build
./unit_tests
OMP_NUM_THREADS=1 ./unit_tests -r junit > unit_tests_report.xml
- name: Code coverage
run: |
cpp-coveralls -r . -b "build/" -i "src/" -i "include/" --exclude "ext/" --gcov-options "\-lp" --verbose
cpp-coveralls -r . -b "build/" -i "src/" -i "include/" --exclude "ext/" --gcov-options "\-lp" --verbose
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ include_directories( ${LAPACK_INCLUDE_DIR} )

find_package( BLAS )

find_package( VTK COMPONENTS vtkIOGeometry vtkFiltersCore REQUIRED )
find_package( VTK COMPONENTS IOGeometry FiltersCore REQUIRED )

add_compile_definitions( KITRT_PYTHON_PATH="${CMAKE_SOURCE_DIR}/python" )
add_compile_definitions( BLAZE_USE_SHARED_MEMORY_PARALLELIZATION=0 )
Expand Down
2 changes: 1 addition & 1 deletion include/common/mesh.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class Mesh
* @return cell_idxs: std::vector<unsigned> */
std::vector<unsigned> GetCellsofBall( const double x, const double y, const double r ) const;

/*! @brief Returns index of cells contained in the rectangle with specified corner coordinates/*
/*! @brief Returns index of cells contained in the rectangle with specified corner coordinates
* @return cell_idxs: std::vector<unsigned> */
std::vector<unsigned> GetCellsofRectangle( const std::vector<std::vector<double>>& cornercoordinates ) const;

Expand Down
6 changes: 3 additions & 3 deletions include/optimizers/neuralnetworkoptimizer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,15 @@ class NeuralNetworkOptimizer : public OptimizerBase

inline ~NeuralNetworkOptimizer();

inline void Solve( Vector& alpha, const Vector& u, const VectorVector& moments, unsigned idx_cell = 0 ) override{};
inline void Solve( Vector&, const Vector&, const VectorVector&, unsigned = 0 ) override{};

inline void SolveMultiCell( VectorVector& alpha, const VectorVector& u, const VectorVector& moments, Vector& alpha_norms ) override{};
inline void SolveMultiCell( VectorVector&, const VectorVector&, const VectorVector&, Vector& ) override{};

/*! @brief Reconstruct the moment sol from the Lagrange multiplier alpha
* @param sol moment vector
* @param alpha Lagrange multipliers
* @param moments Moment basis */
inline void ReconstructMoments( Vector& sol, const Vector& alpha, const VectorVector& moments ) override{};
inline void ReconstructMoments( Vector&, const Vector&, const VectorVector& ) override{};
};
#endif
#endif // MLOPTIMIZER_H
3 changes: 2 additions & 1 deletion include/solvers/snsolver_hpc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ class SNSolverHPC

void IterPostprocessing();

void SetGhostCells(); /*!< @brief Sets vector of ghost cells for
/*! @brief Sets vector of ghost cell values according to boundary conditions */
void SetGhostCells();

// Helper
/*! @brief ComputeTimeStep calculates the maximal stable time step using the
Expand Down
6 changes: 3 additions & 3 deletions src/common/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ void Config::SetPostprocessing() {
_dataDir = std::filesystem::path( _inputDir ).append( _dataDir ).lexically_normal();

// create directories if they dont exist
if( !std::filesystem::exists( _outputDir ) ) std::filesystem::create_directory( _outputDir );
if( !std::filesystem::exists( _outputDir ) ) std::filesystem::create_directories( _outputDir );

// init logger
InitLogger();
Expand Down Expand Up @@ -1249,7 +1249,7 @@ void Config::InitLogger() {

// create log dir if not existent
if( !std::filesystem::exists( _logDir ) ) {
std::filesystem::create_directory( _logDir );
std::filesystem::create_directories( _logDir );
}

if( !spdlog::get( "event" ) ) {
Expand Down Expand Up @@ -1398,4 +1398,4 @@ template <typename K, typename V> K Config::findKey( const std::map<K, V>& myMap
}
// If the value is not found, you can return a default value or throw an exception
throw std::out_of_range( "Value not found in the map" );
}
}
13 changes: 8 additions & 5 deletions src/common/io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,9 @@ void ExportVTK( const std::string fileName,
const std::vector<std::vector<std::vector<double>>>& outputFields,
const std::vector<std::vector<std::string>>& outputFieldNames,
const Mesh* mesh ) {
int rank = 0;
int nprocs = 1;
int rank = 0;
#ifdef IMPORT_MPI
// Initialize MPI
MPI_Comm_size( MPI_COMM_WORLD, &nprocs );
MPI_Comm_rank( MPI_COMM_WORLD, &rank );
#endif
if( rank == 0 ) {
Expand Down Expand Up @@ -152,7 +150,8 @@ void ExportVTK( const std::string fileName,
Mesh* LoadSU2MeshFromFile( const Config* settings ) {
auto log = spdlog::get( "event" );
// log->info( "| Importing mesh. This may take a while for large meshes." );
unsigned dim;
unsigned dim = settings->GetDim();
bool foundDim = false;
std::vector<Vector> nodes;
std::vector<std::vector<unsigned>> cells;
std::vector<std::pair<BOUNDARY_TYPE, std::vector<unsigned>>> boundaries;
Expand All @@ -166,12 +165,16 @@ Mesh* LoadSU2MeshFromFile( const Config* settings ) {
while( getline( ifs, line ) ) {
if( line.find( "NDIME", 0 ) != std::string::npos ) {
dim = static_cast<unsigned>( TextProcessingToolbox::GetTrailingNumber( line ) );
foundDim = true;
// if( settings->GetDim() != dim ) {
// log->info( "Warning: Mesh dimension does not coinside with problem dimension! Proceed with caution!" );
// }
break;
}
}
if( !foundDim ) {
ErrorMessages::Error( "Invalid mesh file detected! Missing NDIME entry.", CURRENT_FUNCTION );
}
ifs.clear();
ifs.seekg( 0, std::ios::beg );
while( getline( ifs, line ) ) {
Expand Down Expand Up @@ -682,4 +685,4 @@ Matrix createSU2MeshFromImage( std::string imageName, std::string SU2Filename )

return gsImage.transpose();
}
*/
*/
7 changes: 0 additions & 7 deletions src/common/mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@ Mesh::Mesh( const Config* settings,
else {
ErrorMessages::Error( "Unsupported mesh dimension!", CURRENT_FUNCTION );
}
int nprocs = 1;
int rank = 0;
#ifdef IMPORT_MPI
MPI_Comm_size( MPI_COMM_WORLD, &nprocs );
MPI_Comm_rank( MPI_COMM_WORLD, &rank );
#endif
if( rank == 0 ) {
Expand Down Expand Up @@ -93,18 +91,13 @@ Mesh::Mesh( const Config* settings,
Mesh::~Mesh() {}

void Mesh::ComputeConnectivity() {
int nprocs = 1;
int rank = 0;
#ifdef IMPORT_MPI
MPI_Comm_size( MPI_COMM_WORLD, &nprocs );
MPI_Comm_rank( MPI_COMM_WORLD, &rank );
#endif

unsigned comm_size = 1; // No MPI implementation right now
// determine number/chunk size and indices of cells treated by each mpi thread (deactivated for now)
unsigned chunkSize = _numCells; // std::ceil( static_cast<float>( _numCells ) / static_cast<float>( comm_size ) );
unsigned mpiCellStart = 0; // comm_rank * chunkSize;
unsigned mpiCellEnd = _numCells; // std::min( ( comm_rank + 1 ) * chunkSize, _numCells );

// 'flat' vectors are a flattened representation of the neighbors numCells<numNodesPerCell> nested vectors; easier for MPI
// 'part' vectors store information for each single MPI thread
Expand Down
4 changes: 3 additions & 1 deletion src/datagenerator/datageneratorbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,10 @@ DataGeneratorBase::DataGeneratorBase( Config* settings ) {
}

DataGeneratorBase::~DataGeneratorBase() {
delete _quadrature;
delete _entropy;
delete _optimizer;
delete _basisGenerator;
delete _quadrature;
}

DataGeneratorBase* DataGeneratorBase::Create( Config* settings ) {
Expand Down
2 changes: 1 addition & 1 deletion src/solvers/mnsolver_normalized.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ MNSolverNormalized::MNSolverNormalized( Config* settings ) : MNSolver( settings
_sol2 = VectorVector( _nCells, Vector( _nSystem, 0.0 ) );
}

MNSolverNormalized::~MNSolverNormalized() {}
MNSolverNormalized::~MNSolverNormalized() { delete _optimizer2; }

void MNSolverNormalized::IterPreprocessing( unsigned /*idx_pseudotime*/ ) {
Vector alpha_norm_per_cell( _nCells, 0 ); // ONLY FOR DEBUGGING! THIS SLOWS DOWN THE CODE
Expand Down
16 changes: 4 additions & 12 deletions src/solvers/snsolver_hpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ SNSolverHPC::SNSolverHPC( Config* settings ) {
_nq = static_cast<unsigned long>( quad->GetNq() );
_nSys = _nq;

if( _numProcs > _nq ) {
if( static_cast<unsigned long>( _numProcs ) > _nq ) {
ErrorMessages::Error( "The number of processors must be less than or equal to the number of quadrature points.", CURRENT_FUNCTION );
}

Expand Down Expand Up @@ -287,7 +287,7 @@ void SNSolverHPC::Solve() {
DrawPreSolverOutput();
}
_curSimTime = 0.0;
auto start = std::chrono::high_resolution_clock::now(); // Start timing
auto start = std::chrono::high_resolution_clock::now(); // Start timing

std::chrono::duration<double> duration;
// Loop over energies (pseudo-time of continuous slowing down approach)
Expand Down Expand Up @@ -1487,7 +1487,6 @@ void SNSolverHPC::SetProbingCellsLineGreen() {
double horizontalLineWidth = std::abs( p1[0] - p2[0] );

double pt_ratio_h = horizontalLineWidth / ( horizontalLineWidth + verticalLineWidth );
double pt_ratio_v = verticalLineWidth / ( horizontalLineWidth + verticalLineWidth );

unsigned nHorizontalProbingCells = (unsigned)std::ceil( _nProbingCellsLineGreen / 2 * pt_ratio_h );
unsigned nVerticalProbingCells = _nProbingCellsLineGreen / 2 - nHorizontalProbingCells;
Expand Down Expand Up @@ -1591,20 +1590,13 @@ void SNSolverHPC::SetProbingCellsLineGreen() {
}

// Compute the probing cells for each block
for( int i = 0; i < _nProbingCellsBlocksGreen; i++ ) {
for( unsigned i = 0; i < _nProbingCellsBlocksGreen; i++ ) {
_probingCellsBlocksGreen.push_back( _mesh->GetCellsofRectangle( block_corners[i] ) );
}
}
}

void SNSolverHPC::ComputeQOIsGreenProbingLine() {
double verticalLineWidth = std::abs( _cornerUpperLeftGreen[1] - _cornerLowerLeftGreen[1] - _thicknessGreen );
double horizontalLineWidth = std::abs( _cornerUpperLeftGreen[0] - _cornerUpperRightGreen[0] - _thicknessGreen );

double dl = 2 * ( horizontalLineWidth + verticalLineWidth ) / ( (double)_nProbingCellsLineGreen );
double area = dl * _thicknessGreen;
double l_max = _nProbingCellsLineGreen * dl;

#pragma omp parallel for
for( unsigned i = 0; i < _nProbingCellsLineGreen; i++ ) { // Loop over probing cells
_absorptionValsLineSegment[i] =
Expand Down Expand Up @@ -1694,4 +1686,4 @@ void SNSolverHPC::ComputeCellsPerimeterLattice() {
}
}
}
}
}
Empty file.
Empty file.
Empty file.
45 changes: 45 additions & 0 deletions tests/input/validation_tests/SN_solver_hpc/lattice_hpc_200.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Lattice Validation SN-HPC %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% ---- File specifications ----
%
OUTPUT_DIR = ../../../result
OUTPUT_FILE = lattice_hpc_200
LOG_DIR = ../../../result/logs
LOG_FILE = lattice_hpc_200_output
MESH_FILE = lattice_hpc_200.mesh
FORCE_CONNECTIVITY_RECOMPUTE = YES
%
% ---- Problem specifications ----
%
PROBLEM = LATTICE
SPATIAL_DIM = 2
SOURCE_MAGNITUDE = 1.0
%
% ---- Solver specifications ----
%
HPC_SOLVER = YES
SOLVER = SN_SOLVER
CFL_NUMBER = 0.5
TIME_FINAL = 0.5
RECONS_ORDER = 2
TIME_INTEGRATION_ORDER = 2
%
% ---- Boundary Conditions ----
%
BC_NEUMANN = ( void )
%
% ---- Quadrature ----
%
QUAD_TYPE = GAUSS_LEGENDRE_TENSORIZED_2D
QUAD_ORDER = 6
%
% ----- Output ----
%
VOLUME_OUTPUT = (MINIMAL)
VOLUME_OUTPUT_FREQUENCY = 0
SCREEN_OUTPUT = (ITER, WALL_TIME, MASS, RMS_FLUX, VTK_OUTPUT, CSV_OUTPUT)
SCREEN_OUTPUT_FREQUENCY = 1
HISTORY_OUTPUT = (ITER, SIM_TIME, WALL_TIME, MASS, RMS_FLUX, VTK_OUTPUT, CSV_OUTPUT, CUR_OUTFLOW, TOTAL_OUTFLOW, CUR_OUTFLOW_P1, TOTAL_OUTFLOW_P1, CUR_OUTFLOW_P2, TOTAL_OUTFLOW_P2, MAX_OUTFLOW, CUR_PARTICLE_ABSORPTION, TOTAL_PARTICLE_ABSORPTION, MAX_PARTICLE_ABSORPTION)
HISTORY_OUTPUT_FREQUENCY = 1
Loading