Skip to content

Commit

Permalink
Merge branch 'new_radiation_test_cases' of https://github.com/CSMMLab…
Browse files Browse the repository at this point in the history
…/KiT-RT into new_radiation_test_cases
  • Loading branch information
ScSteffen committed Jan 2, 2024
2 parents 1ead3a1 + 45fafdb commit bc40e88
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/common/io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ Mesh* LoadSU2MeshFromFile( const Config* settings ) {
ErrorMessages::Error( "Cannot open mesh file '" + settings->GetMeshFile() + "!", CURRENT_FUNCTION );
}
ifs.close();
// log->info( "| Mesh imported." );
log->info( "| Mesh imported." );
return new Mesh( nodes, cells, boundaries );
}

Expand Down
1 change: 1 addition & 0 deletions src/common/mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ void Mesh::ComputeConnectivity() {

// assign boundary types to all cells
_cellBoundaryTypes.resize( _numCells, BOUNDARY_TYPE::NONE );
#pragma omp parallel for
for( unsigned i = 0; i < _numCells; ++i ) {
if( std::any_of( _cellNeighbors[i].begin(), _cellNeighbors[i].end(), [this]( unsigned i ) {
return i == _ghostCellID;
Expand Down
17 changes: 9 additions & 8 deletions src/optimizers/neuralnetworkoptimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,19 @@ NeuralNetworkOptimizer::NeuralNetworkOptimizer( Config* settings ) : OptimizerBa
_tfModel = new cppflow::model( tfModelPath ); // load model
unsigned servingSize = _settings->GetNCells();
if( _settings->GetEnforceNeuralRotationalSymmetry() ) {
if( _settings->GetMaxMomentDegree() > 2 ) {
if( _settings->GetMaxMomentDegree() > 3 ) {
ErrorMessages::Error( "This postprocessing step is currently only for M1 and M2 models available.", CURRENT_FUNCTION );
}
servingSize *= 2; // Double number of vectors, since we mirror the rotated vector
_rotationMats.resize( _settings->GetNCells() );
_rotationMatsT.resize( _settings->GetNCells() );
}

if (_settings->GetMaxMomentDegree() == 1 && _settings->GetDim() ==2 && _settings->GetEnforceNeuralRotationalSymmetry()){
if( _settings->GetMaxMomentDegree() == 1 && _settings->GetDim() == 2 && _settings->GetEnforceNeuralRotationalSymmetry() ) {
_modelServingVectorU.resize( servingSize * ( _nSystem - 2 ) ); // reserve size for model servitor
}
else
{
_modelServingVectorU.resize( servingSize * ( _nSystem - 1 ) ); // reserve size for model servitor
else {
_modelServingVectorU.resize( servingSize * ( _nSystem - 1 ) ); // reserve size for model servitor
}
// Specify model input name
// Call Model (change call depending on model mk) (Seems to be randomly assigned by tensorflow)
Expand Down Expand Up @@ -367,7 +366,7 @@ void NeuralNetworkOptimizer::InferenceMonomial( VectorVector& alpha, const Vecto
}
servingSize *= 2;
}
else { // No Preprocessing
else { // No Postprocessing
#pragma omp parallel for
for( unsigned idx_cell = 0; idx_cell < _settings->GetNCells(); idx_cell++ ) {
for( unsigned idx_sys = 0; idx_sys < _nSystem - 1; idx_sys++ ) {
Expand Down Expand Up @@ -402,6 +401,7 @@ void NeuralNetworkOptimizer::InferenceMonomial( VectorVector& alpha, const Vecto
// Mirror order 1 Moments
alphaRedMirror[idx_sys] =
-1 * (double)_modelServingVectorAlpha[( _settings->GetNCells() + idx_cell ) * ( _nSystem - 1 ) + idx_sys];

alphaRed[idx_sys] = ( alphaRed[idx_sys] + alphaRedMirror[idx_sys] ) / 2; // average (and store in alphaRed)
// alphaCorr[idx_sys+1] = alphaRed[idx_sys];
}
Expand Down Expand Up @@ -460,6 +460,7 @@ void NeuralNetworkOptimizer::InferenceMonomial( VectorVector& alpha, const Vecto
}
alphaRed[idx_sys] = ( alphaRed[idx_sys] + alphaRedMirror[idx_sys] ) / 2; // average (and store in alphaRed)
}
alpha_norms[idx_cell] = norm( alphaRed ) * norm( alphaRed );

// Rotate Back
Vector alpha1{ alphaRed[0], alphaRed[1] };
Expand Down Expand Up @@ -594,7 +595,7 @@ void NeuralNetworkOptimizer::InferenceSphericalHarmonics2D( VectorVector& alpha,
Vector alphaTempFull = Vector( _nSystem, 0.0 ); // local reduced mirrored alpha (with dummy entry at 0)
Vector alphaTempMirror = Vector( _nSystem, 0.0 ); // local reduced mirrored alpha (with dummy entry at 0)

if( _settings->GetMaxMomentDegree() == 1 ) { // Using this
if( _settings->GetMaxMomentDegree() == 1 ) { // Using this
for( unsigned idx_sys = 0; idx_sys < _nSystem - 2; idx_sys++ ) {
alphaTempFull[idx_sys + 1] = (double)_modelServingVectorAlpha[idx_cell * ( _nSystem - 2 ) + idx_sys];
alphaTempMirror[idx_sys + 1] =
Expand Down Expand Up @@ -754,7 +755,7 @@ void NeuralNetworkOptimizer::InferenceSphericalHarmonics( VectorVector& alpha,
alpha_P_Mirror[idx_sys + 1] = (double)_modelServingVectorAlpha[( _settings->GetNCells() + idx_cell ) * ( _nSystem - 1 ) + idx_sys];
}
alpha_P_Mirror = rot180 * alpha_P_Mirror;
alpha[idx_cell] = ( alphaP + alpha_P_Mirror ) / 2; // average (and store in alpha)
alpha[idx_cell] = ( alphaP + alpha_P_Mirror ) / 2; // average (and store in alpha)

alpha[idx_cell] = _rotationMatsT[idx_cell] * alpha[idx_cell]; // Rotate back
// alpha[idx_cell][2] = 0.0; //manually enforce slab geometry
Expand Down
2 changes: 1 addition & 1 deletion tools/docker/docker_run_interactive_specify_cores.sh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
docker run -i -t --rm --cpuset-cpus=0-12 -v $(pwd)/../..:/mnt kitrt/test_ml:latest /bin/bash
docker run -i -t --rm --cpuset-cpus=0-23 -v $(pwd)/../..:/mnt kitrt/test_ml:latest /bin/bash

0 comments on commit bc40e88

Please sign in to comment.