Commit 938f4e77 authored by jannick.wolters's avatar jannick.wolters
Browse files

added save function to solver in order to output results

parent 6b123632
Pipeline #84011 passed with stages
in 4 minutes and 30 seconds
...@@ -485,3 +485,11 @@ code/build/* ...@@ -485,3 +485,11 @@ code/build/*
code/input/* code/input/*
code/result/* code/result/*
code/ext/* code/ext/*
# vscode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history
{
"files.associations": {
"array": "cpp",
"atomic": "cpp",
"*.tcc": "cpp",
"bitset": "cpp",
"cctype": "cpp",
"chrono": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"codecvt": "cpp",
"complex": "cpp",
"condition_variable": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"deque": "cpp",
"list": "cpp",
"unordered_map": "cpp",
"vector": "cpp",
"exception": "cpp",
"algorithm": "cpp",
"filesystem": "cpp",
"functional": "cpp",
"iterator": "cpp",
"map": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"optional": "cpp",
"random": "cpp",
"ratio": "cpp",
"regex": "cpp",
"set": "cpp",
"string": "cpp",
"string_view": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"fstream": "cpp",
"future": "cpp",
"initializer_list": "cpp",
"iomanip": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"limits": "cpp",
"mutex": "cpp",
"new": "cpp",
"ostream": "cpp",
"shared_mutex": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"thread": "cpp",
"cinttypes": "cpp",
"typeinfo": "cpp",
"variant": "cpp",
"bit": "cpp"
}
}
\ No newline at end of file
...@@ -16,6 +16,10 @@ class SNSolver : public Solver ...@@ -16,6 +16,10 @@ class SNSolver : public Solver
* @brief Solve functions runs main time loop * @brief Solve functions runs main time loop
*/ */
virtual void Solve(); virtual void Solve();
/**
* @brief Output solution to VTK file
*/
virtual void Save() const;
void SolveMPI(); // can be deleated later void SolveMPI(); // can be deleated later
}; };
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
// include Matrix, Vector definitions // include Matrix, Vector definitions
#include "typedef.h" #include "typedef.h"
#include "io.h"
#include "numericalflux.h" #include "numericalflux.h"
#include "settings.h" #include "settings.h"
#include <string> #include <string>
...@@ -85,6 +86,11 @@ class Solver ...@@ -85,6 +86,11 @@ class Solver
* @brief Solve functions runs main time loop * @brief Solve functions runs main time loop
*/ */
virtual void Solve() = 0; virtual void Solve() = 0;
/**
* @brief Output solution to VTK file
*/
virtual void Save() const = 0;
}; };
#endif // SOLVER_H #endif // SOLVER_H
...@@ -466,7 +466,7 @@ Settings* ReadInputFile( std::string inputFile ) { ...@@ -466,7 +466,7 @@ Settings* ReadInputFile( std::string inputFile ) {
validConfig = false; validConfig = false;
} }
auto tEnd = solver->get_as<double>( "tEnd" ); auto tEnd = solver->get_as<double>( "tEnd" );
if( tEnd ) { if( tEnd ) {
settings->_tEnd = *tEnd; settings->_tEnd = *tEnd;
} }
...@@ -475,14 +475,14 @@ Settings* ReadInputFile( std::string inputFile ) { ...@@ -475,14 +475,14 @@ Settings* ReadInputFile( std::string inputFile ) {
validConfig = false; validConfig = false;
} }
auto quadType = solver->get_as<std::string>( "quadType" ); auto quadType = solver->get_as<std::string>( "quadType" );
if( quadType ) { if( quadType ) {
std::string quadTypeString = *quadType; std::string quadTypeString = *quadType;
try{ try {
settings->_quadName = Quadrature_Map.at(quadTypeString); settings->_quadName = Quadrature_Map.at( quadTypeString );
}catch (const std::exception& e) { } catch( const std::exception& e ) {
spdlog::error("Error: '{0}' is not a feasible quadrature type. Please check the config template!", quadTypeString); spdlog::error( "Error: '{0}' is not a feasible quadrature type. Please check the config template!", quadTypeString );
exit(EXIT_FAILURE); // Quit RTSN exit( EXIT_FAILURE ); // Quit RTSN
} }
} }
else { else {
......
...@@ -14,6 +14,7 @@ int main( int argc, char** argv ) { ...@@ -14,6 +14,7 @@ int main( int argc, char** argv ) {
// build solver // build solver
Solver* solver = Solver::Create( settings ); Solver* solver = Solver::Create( settings );
solver->Solve(); solver->Solve();
solver->Save();
// TODO: call solver // TODO: call solver
MPI_Finalize(); MPI_Finalize();
......
...@@ -32,10 +32,6 @@ void SNSolver::Solve() { ...@@ -32,10 +32,6 @@ void SNSolver::Solve() {
_psi = psiNew; _psi = psiNew;
// psiNew.reset(); // psiNew.reset();
} }
std::vector<std::string> fieldNames;
fieldNames.push_back( "test" );
// ExportVTK( "test", _psi, fieldNames, _settings, _mesh );
} }
void SNSolver::SolveMPI() { void SNSolver::SolveMPI() {
...@@ -96,3 +92,14 @@ void SNSolver::SolveMPI() { ...@@ -96,3 +92,14 @@ void SNSolver::SolveMPI() {
// psiNew.reset(); // psiNew.reset();
}*/ }*/
} }
void SNSolver::Save() const {
std::vector<std::string> fieldNames{ "flux" };
std::vector<double> flux( _nCells, 0.0 );
for( unsigned i = 0; i < _nCells; ++i ) {
flux[i] = dot( _psi[i], _weights );
}
std::vector<std::vector<double>> scalarField( 1, flux );
std::vector<std::vector<std::vector<double>>> results{ scalarField };
ExportVTK( _settings->GetOutputFile(), results, fieldNames, _settings, _mesh );
}
...@@ -4,10 +4,10 @@ ...@@ -4,10 +4,10 @@
#include "mesh.h" #include "mesh.h"
#include "snsolver.h" #include "snsolver.h"
Solver::Solver( Settings* settings ) { Solver::Solver( Settings* settings ) : _settings( settings ) {
// @TODO save parameters from settings class // @TODO save parameters from settings class
std::cout << "In Solver..." << std::endl; // std::cout << "In Solver..." << std::endl;
// build quadrature object and store quadrature points and weights // build quadrature object and store quadrature points and weights
Quadrature* q = Quadrature::CreateQuadrature( settings->GetQuadName(), settings->GetQuadOrder() ); Quadrature* q = Quadrature::CreateQuadrature( settings->GetQuadName(), settings->GetQuadOrder() );
...@@ -17,13 +17,13 @@ Solver::Solver( Settings* settings ) { ...@@ -17,13 +17,13 @@ Solver::Solver( Settings* settings ) {
// build mesh and store all relevant information // build mesh and store all relevant information
Mesh* mesh = LoadSU2MeshFromFile( settings ); _mesh = LoadSU2MeshFromFile( settings );
_areas = mesh->GetCellAreas(); _areas = _mesh->GetCellAreas();
_neighbors = mesh->GetNeighbours(); _neighbors = _mesh->GetNeighbours();
_normals = mesh->GetNormals(); _normals = _mesh->GetNormals();
_nCells = mesh->GetNumCells(); _nCells = _mesh->GetNumCells();
std::cout << "After Mesh..." << std::endl; // std::cout << "After Mesh..." << std::endl;
// setup angular flux array (maybe directly call SetupIC() from physics class? ) // setup angular flux array (maybe directly call SetupIC() from physics class? )
_psi = std::vector( _nCells, Vector( _nq, 0.0 ) ); _psi = std::vector( _nCells, Vector( _nq, 0.0 ) );
...@@ -45,17 +45,17 @@ Solver::Solver( Settings* settings ) { ...@@ -45,17 +45,17 @@ Solver::Solver( Settings* settings ) {
_g = NumericalFlux::Create( settings ); _g = NumericalFlux::Create( settings );
// boundary type // boundary type
_boundaryCells = mesh->GetBoundaryCellArray(); _boundaryCells = _mesh->GetBoundaryCellArray();
} }
double Solver::ComputeTimeStep( double cfl ) const { double Solver::ComputeTimeStep( double cfl ) const {
double maxEdge = -1.0; double maxEdge = -1.0;
std::cout << _nCells << std::endl; // std::cout << _nCells << std::endl;
std::cout << _areas.size() << std::endl; // std::cout << _areas.size() << std::endl;
std::cout << _normals.size() << std::endl; // std::cout << _normals.size() << std::endl;
for( unsigned j = 0; j < _nCells; ++j ) { for( unsigned j = 0; j < _nCells; ++j ) {
std::cout << j; // std::cout << j;
std::cout << " " << _areas[j] << " " << _normals[j].size() << std::endl; // std::cout << " " << _areas[j] << " " << _normals[j].size() << std::endl;
for( unsigned l = 0; l < _normals[j].size(); ++l ) { for( unsigned l = 0; l < _normals[j].size(); ++l ) {
// std::cout << _normals[j][l] << std::endl; // std::cout << _normals[j][l] << std::endl;
double currentEdge = _areas[j] / norm( _normals[j][l] ); double currentEdge = _areas[j] / norm( _normals[j][l] );
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment