Commit da639a2d authored by steffen.schotthoefer's avatar steffen.schotthoefer
Browse files

start and general structure of entropy solver

parent c6a2ce77
#ifndef DUMMYDRIVER_H
#define DUMMYDRIVER_H
class DummyDriver
{
public:
DummyDriver();
};
#endif // DUMMYDRIVER_H
/*!
* \file entropyclosuredriver.h
* \brief The main subroutines for driving entropyclosure routines.
* \author S. Schotthöfer
*
*/
#ifndef ENTROPYCLOSUREDRIVER_H
#define ENTROPYCLOSUREDRIVER_H
#include "settings/config.h"
#include "solvers/advectionsolver.h"
#include "optimizers/newtonoptimizer.h"
class EntropyClosureDriver{
public:
EntropyClosureDriver(Config* settings);
/*!
* \brief Launch the computation.
*/
void StartSolver();
protected:
Config* _driverSettings;
double _startTime; /*! \brief: Wall time at start of computation */
double _stopTime; /*! \brief: Wall time at end of computation */
unsigned long _timeIter; /*! \brief: Physical time iteration */
double _nInnerIter; /*! \brief: Maximum amount of inner Iterations */
std::vector *_kineticDensity; /*! \brief: pointer to kinetic density (for each cell) */
std::vector<std::vector<double>> *_moments; /*! \brief: pointer to moment vector (for each cell), i.e solution of _solver */
std::vector<std::vector<double>> *_lambda; /*! \brief: pointer to vector of lagrange multipliers (for each cell), i.e. solution of _optimizer */
NewtonOptimizer* _optimizer; /*! \brief optimizer to reconstruct the entropy density */
AdvectionSolver* _solver; /*! \brief solver to solve the entropy moment system */
/*!
* \brief Preprocess the iteration
*/
void Preprocess(unsigned long timeIter);
/*!
* \brief Run the physical time iteration of the solver.
*/
void Run();
/*!
* \brief Postprocess the iteration.
*/
void Postprocess();
/*!
* \brief Output the solution in solution file.
*/
void Output(unsigned long timeIter);
/*!
* \brief Monitor Convergence of the solution.
*/
bool Monitor(unsigned long timeIter);
}
#endif // ENTROPYCLOSUREDRIVER_H
#ifndef NEWTONOPTIMIZER_H
#define NEWTONOPTIMIZER_H
#include <vector>
#include "settings/config.h"
class NewtonOptimizer
{
public:
NewtonOptimizer();
/*! \brief: Solves the optimization problem for given moments*/
Solve(std::vector<std::vector<double>> moments);
/*! \brief Get pointer to solution vector for each cell */
std::vector<std::vector<double>> * GetSolution(){return &_lambda};
protected:
std::vector<std::vector<double>> _lambda; /*! \brief: Solution of the optimization problem */
};
#endif // NEWTONOPTIMIZER_H
/*!
* \file advectionsolver.h
* \brief solver for entropy closure of advection equation.
* \author S. Schotthöfer
*/
#ifndef ADVECTIONSOLVER_H
#define ADVECTIONSOLVER_H
#include <vector>
#include "settings/config.h"
class AdvectionSolver{
public:
AdvectionSolver(Config* settings);
/*! \brief: Solves the advection problem for given lambda */
void Solve(std::vector<std::vector<double>> lambda);
/*! \brief: Reconstructs kintec density from given lambda and legendre dual of the entropy functional */
std::vector<double> * ReconstructKineticDensity(std::vector<std::vector<double>> lambda);
/* ---- Getter ---- */
/*! \brief Get pointer to solution vector for each cell (moments) */
std::vector<std::vector<double>> * GetSolution(void){return &_moments};
protected:
std::vector<std::vector<double>> _moments; /*! \brief: Solution of the moment advection problem */
std::vector<std::vector<double>> _kineticDensity; /*! \brief: Reconstructed kinetic Density from given lamnda */
}
#endif // ADVECTIONSOLVER_H_H
#ifndef ENTROPYSOLVER_H
#define ENTROPYSOLVER_H
class EntropySolver
{
public:
EntropySolver();
};
#endif // ENTROPYSOLVER_H
......@@ -38,6 +38,12 @@ inline std::vector<std::string> Split(const std::string& s, char delimiter)
return tokens;
}
/*!
* \brief utility function for getting walltime
* \param
*/
//TODO
}
#endif // TEXTPROCESSINGTOOLBOX_H
#include "dummydriver.h"
DummyDriver::DummyDriver()
{
}
/*!
* \file entropyclosuredriver.cpp
* \brief The main subroutines for driving entropyclosure routines.
* \author S. Schotthöfer
*
*/
#include <iostream>
#include "drivers/entropyclosuredriver.h"
using namespace std;
EntropyClosureDriver::EntropyClosureDriver(Config *settings){
_driverSettings = settings;
_startTime = 0.0;
_timeIter = 0;
}
void EntropyClosureDriver::StartSolver(){
//_startTime = //Get StartTime
// _settings->Set_StartTime(StartTime);
/*--- Main external loop of the solver. Runs for the number of time steps required. ---*/
//if (rank == MASTER_NODE) Later for MPI
cout << endl <<"------------------------------ Begin Solver -----------------------------" << endl;
//if (rank == MASTER_NODE) Later for MPI
{
cout << endl <<"Simulation Run using the Entropy Closure Driver" << endl;
}
/*--- Run the problem until the number of time iterations required is reached. ---*/
//Currently only steady state
{
/*--- Perform some preprocessing before starting the time-step simulation. ---*/
Preprocess(_timeIter);
/*--- Run a time-step iteration of the single-zone problem. ---*/
Run();
/*--- Perform some postprocessing on the solution before the update ---*/
Postprocess();
/*--- Monitor the computations after each iteration. ---*/
Monitor(_timeIter);
/*--- Output the solution in files. ---*/
Output(_timeIter);
/*--- If the physical time convergence criteria has been met, terminate the simulation. ---*/
//if (StopCalc) break; Comes with physical time implementation
_timeIter++;
}
}
void EntropyClosureDriver::Run(){
/* ---- Solve dual problem ---- */
_optimizer->Solve(_moments);
_lambda = _optimizer->GetSolution();
/* ---- Reconstruct kineticDensity ---- */
_kineticDensity = _solver->ReconstructKineticDensity(_lambda);
/* ---- Solve Moment System ---- */
_solver->Solve(_lambda);
_moments = _solver->GetSolution();
}
#include "newtonoptimizer.h"
NewtonOptimizer::NewtonOptimizer()
{
}
#include "solvers/advectionsolver.h"h"
AdvectionSolver::AdvectionSolver()
{
}
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