Commit 45c3c394 authored by steffen.schotthoefer's avatar steffen.schotthoefer
Browse files

small change in error log entropy optimizer, commented out realizability adaption

parent 7edfa15a
......@@ -12,7 +12,7 @@ class NewtonOptimizer : public OptimizerBase
inline ~NewtonOptimizer() {}
void Solve( Vector& lambda, Vector& u, VectorVector& moments ) override;
void Solve( Vector& lambda, Vector& u, VectorVector& moments, unsigned idx_cell ) override;
private:
/*! @brief: Computes gradient of objective function and stores it in grad
......
......@@ -19,7 +19,7 @@ class OptimizerBase
/*! @brief : Computes the optimal Lagrange multilpiers for the dual entropy minimization problem
* @param : Vector u = pointer to vector of given moments. // Maybe use pointer for performance?
* @return : Vector alpha = optimal lagrange multipliers. Has the same length as Vector u. */
virtual void Solve( Vector& lambda, Vector& u, VectorVector& moments ) = 0;
virtual void Solve( Vector& lambda, Vector& u, VectorVector& moments, unsigned idx_cell ) = 0;
protected:
EntropyBase* _entropy; /*! @brief: Class to handle entropy functional evaluations */
......
......@@ -59,7 +59,7 @@ void NewtonOptimizer::ComputeHessian( Vector& alpha, VectorVector& moments, Matr
}
}
void NewtonOptimizer::Solve( Vector& lambda, Vector& sol, VectorVector& moments ) {
void NewtonOptimizer::Solve( Vector& lambda, Vector& sol, VectorVector& moments, unsigned idx_cell ) {
/* solve the problem argmin ( <eta(alpha*m)>-alpha*u))
* where alpha = Lagrange multiplier
......@@ -68,10 +68,10 @@ void NewtonOptimizer::Solve( Vector& lambda, Vector& sol, VectorVector& moments
*/
// if we have quadratic entropy, then alpha = u;
// if( _settings->GetEntropyName() == QUADRATIC && _settings->GetNewtonFastMode() ) {
// lambda = sol;
// return;
//}
if( _settings->GetEntropyName() == QUADRATIC && _settings->GetNewtonFastMode() ) {
lambda = sol;
return;
}
// Start Newton Algorithm
......@@ -138,7 +138,7 @@ void NewtonOptimizer::Solve( Vector& lambda, Vector& sol, VectorVector& moments
return;
}
else if( ++lineSearchCounter > _maxLineSearches ) {
ErrorMessages::Error( "Newton needed too many refinement steps!", CURRENT_FUNCTION );
ErrorMessages::Error( "Newton needed too many refinement steps! at cell " + std::to_string( idx_cell ), CURRENT_FUNCTION );
}
}
lambda = lambdaNew;
......@@ -147,5 +147,7 @@ void NewtonOptimizer::Solve( Vector& lambda, Vector& sol, VectorVector& moments
return;
}
}
ErrorMessages::Error( "Newton did not converge!", CURRENT_FUNCTION );
ErrorMessages::Error( "Newton did not converge! Norm of gradient is: " + std::to_string( norm( dlambdaNew ) ) + " at cell " +
std::to_string( idx_cell ),
CURRENT_FUNCTION );
}
......@@ -101,15 +101,19 @@ Vector MNSolver::ConstructFlux( unsigned idx_cell ) {
entropyFlux += _g->Flux( _quadPoints[idx_quad], entropyL, entropyR, _normals[idx_cell][idx_neigh] );
}
flux += _moments[idx_quad] * ( _weights[idx_quad] * entropyFlux );
// ------- Relizablity Reconstruction Step ----
}
return flux;
}
void MNSolver::ComputeRealizableSolution( unsigned idx_cell ) {
double entropyReconstruction = 0.0;
_sol[idx_cell] = 0;
for( unsigned idx_quad = 0; idx_quad < _nq; idx_quad++ ) {
// Make entropyReconstruction a member vector, s.t. it does not have to be re-evaluated in ConstructFlux
entropyReconstruction = _entropy->EntropyPrimeDual( blaze::dot( _alpha[idx_cell], _moments[idx_quad] ) );
_sol[idx_cell] += _moments[idx_quad] * ( _weights[idx_quad] * entropyReconstruction );
}
}
......@@ -153,11 +157,11 @@ void MNSolver::Solve() {
// ------- Reconstruction Step ----------------
_optimizer->Solve( _alpha[idx_cell], _sol[idx_cell], _moments );
_optimizer->Solve( _alpha[idx_cell], _sol[idx_cell], _moments, idx_cell );
// ------- Relizablity Reconstruction Step ----
ComputeRealizableSolution( idx_cell );
// ComputeRealizableSolution( idx_cell );
// ------- Flux Computation Step --------------
......
Markdown is supported
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