Skip to content
Snippets Groups Projects
Commit d5b5dc92 authored by Robert K's avatar Robert K
Browse files

ns works with flop count

parent f898b3f4
No related branches found
No related tags found
No related merge requests found
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <config.h> #include <config.h>
#if defined USE_BASEFUNCTIONSET_CODEGEN || defined BASEFUNCTIONSET_CODEGEN_GENERATE #if defined USE_BASEFUNCTIONSET_CODEGEN || defined BASEFUNCTIONSET_CODEGEN_GENERATE
#warning "Codegen enabled!"
#define USE_FEMDG_BASISFUNCTIONSET #define USE_FEMDG_BASISFUNCTIONSET
#endif #endif
......
#ifndef DUNE_FEM_DG_MAINHEADER_HH #ifndef DUNE_FEM_DG_MAINHEADER_HH
#define DUNE_FEM_DG_MAINHEADER_HH #define DUNE_FEM_DG_MAINHEADER_HH
//#ifdef COUNT_FLOPS
#include <dune/fem/misc/double.hh>
//#endif
// streams for backup // streams for backup
#include <dune/fem-dg/misc/streams.hh> #include <dune/fem-dg/misc/streams.hh>
......
...@@ -27,6 +27,7 @@ void setupAdditionalVariables( const TimeProvider& tp, ...@@ -27,6 +27,7 @@ void setupAdditionalVariables( const TimeProvider& tp,
const ModelType& model, const ModelType& model,
PrimDiscreteFunctionType& primDF ) PrimDiscreteFunctionType& primDF )
{ {
#if 0
typedef typename ConsDiscreteFunctionType::Traits::DiscreteFunctionSpaceType typedef typename ConsDiscreteFunctionType::Traits::DiscreteFunctionSpaceType
ConsDiscreteFunctionSpaceType; ConsDiscreteFunctionSpaceType;
typedef typename PrimDiscreteFunctionType::Traits::DiscreteFunctionSpaceType typedef typename PrimDiscreteFunctionType::Traits::DiscreteFunctionSpaceType
...@@ -78,6 +79,7 @@ void setupAdditionalVariables( const TimeProvider& tp, ...@@ -78,6 +79,7 @@ void setupAdditionalVariables( const TimeProvider& tp,
primLF.axpy( quad[qP] , prim ); primLF.axpy( quad[qP] , prim );
} }
} }
#endif
} }
#endif #endif
...@@ -20,7 +20,7 @@ namespace Dune ...@@ -20,7 +20,7 @@ namespace Dune
template<class K, int ROWS, int COLS> template<class K, int ROWS, int COLS>
class BlockCRSMatrix class BlockCRSMatrix
{ {
std::vector< double > data_; std::vector< K > data_;
std::vector< int > rows_; std::vector< int > rows_;
std::vector< int > cols_; std::vector< int > cols_;
public: public:
......
...@@ -95,7 +95,7 @@ inline ...@@ -95,7 +95,7 @@ inline
EulerAnalyticalFlux<2>::FieldType EulerAnalyticalFlux<2>::rhoeps(const RangeType& u) const EulerAnalyticalFlux<2>::FieldType EulerAnalyticalFlux<2>::rhoeps(const RangeType& u) const
{ {
assert( u[0] >= 1e-10 ); assert( u[0] >= 1e-10 );
return u[e]-0.5*(u[1]*u[1]+u[2]*u[2])/u[0]; return u[e] -(0.5*((u[1]*u[1])+(u[2]*u[2]))/u[0]);
} }
template <> template <>
...@@ -105,7 +105,7 @@ EulerAnalyticalFlux<2>::FieldType EulerAnalyticalFlux<2>::pressure(const FieldTy ...@@ -105,7 +105,7 @@ EulerAnalyticalFlux<2>::FieldType EulerAnalyticalFlux<2>::pressure(const FieldTy
{ {
const FieldType re = rhoeps(u); const FieldType re = rhoeps(u);
assert(re>=1e-10); assert(re>=1e-10);
return (gamma-1)*re; return (gamma-1.0)*re;
} }
template <> template <>
...@@ -222,12 +222,14 @@ EulerAnalyticalFlux<2>::maxSpeed(const FieldType gamma, ...@@ -222,12 +222,14 @@ EulerAnalyticalFlux<2>::maxSpeed(const FieldType gamma,
const DomainType& n, const DomainType& n,
const RangeType& u) const const RangeType& u) const
{ {
assert( u[0] > 1e-10 ); assert( u[0] > FieldType( 1e-10 ) );
FieldType u_normal = (u[1]*n[0]+u[2]*n[1]) / u[0]; FieldType u_normal = FieldType(u[1]*n[0]+u[2]*n[1]) / u[0];
FieldType p = pressure(gamma,u); FieldType p = pressure(gamma,u);
FieldType c2 = gamma * p/ u[0] * n.two_norm2(); FieldType c2 = gamma * p/ u[0] * n.two_norm2();
assert( c2 > 1e-10 ); assert( c2 > FieldType( 1e-10 ) );
return std::abs(u_normal) + std::sqrt(c2); FieldType maxspd = std::abs(double(u_normal)) + std::sqrt(double(c2));
//std::cout << maxspd << " maxspd" << std::endl;
return maxspd;
} }
template <> template <>
......
...@@ -12,7 +12,7 @@ namespace Dune { ...@@ -12,7 +12,7 @@ namespace Dune {
struct SmartOdeSolverParameters : public DuneODE :: ODEParameters struct SmartOdeSolverParameters : public DuneODE :: ODEParameters
{ {
SmartOdeSolverParameters( const std::string keyPrefix = "fem.ode." ) SmartOdeSolverParameters( const std::string keyPrefix = "fem.ode." )
: DuneODE :: ODEParameters( keyPrefix ) : DuneODE :: ODEParameters()
{} {}
using DuneODE :: ODEParameters :: keyPrefix_; using DuneODE :: ODEParameters :: keyPrefix_;
......
...@@ -71,16 +71,18 @@ struct AdvectionDiffusionStepper ...@@ -71,16 +71,18 @@ struct AdvectionDiffusionStepper
using BaseType :: space; using BaseType :: space;
using BaseType :: problem; using BaseType :: problem;
using BaseType :: adaptationHandler_ ; using BaseType :: adaptationHandler_ ;
using BaseType :: adaptParam_;
using BaseType :: adaptive ; using BaseType :: adaptive ;
using BaseType :: doEstimateMarkAdapt ; using BaseType :: doEstimateMarkAdapt ;
using BaseType :: name ;
AdvectionDiffusionStepper( GridType& grid, const std::string name = "" ) : AdvectionDiffusionStepper( GridType& grid, const std::string name = "" ) :
BaseType( grid, name ), BaseType( grid, name ),
dgOperator_( gridPart_, problem(), name ), dgOperator_( gridPart_, problem(), name ),
dgAdvectionOperator_( gridPart_, problem(), name ), dgAdvectionOperator_( gridPart_, problem(), name ),
dgDiffusionOperator_( gridPart_, problem(), name ), dgDiffusionOperator_( gridPart_, problem(), name ),
dgIndicator_( gridPart_, problem(), name ) dgIndicator_( gridPart_, problem(), name ),
// gradientIndicator_( space(), problem(), adaptParam_ ) gradientIndicator_( space(), problem(), adaptParam_ )
{ {
} }
...@@ -102,8 +104,11 @@ struct AdvectionDiffusionStepper ...@@ -102,8 +104,11 @@ struct AdvectionDiffusionStepper
} }
// one of them is not zero, // one of them is not zero,
size_t advSize = dgAdvectionOperator_.numberOfElements();
size_t diffSize = dgDiffusionOperator_.numberOfElements();
size_t dgIndSize = gradientIndicator_.numberOfElements();
size_t dgSize = dgOperator_.numberOfElements(); size_t dgSize = dgOperator_.numberOfElements();
UInt64Type grSize = dgSize; // std::max( std::max(advSize, dgSize ), std::max( diffSize, dgIndSize ) ); UInt64Type grSize = std::max( std::max(advSize, dgSize ), std::max( diffSize, dgIndSize ) );
double minMax[ 2 ] = { double(grSize), 1.0/double(grSize) } ; double minMax[ 2 ] = { double(grSize), 1.0/double(grSize) } ;
grid_.comm().max( &minMax[ 0 ], 2 ); grid_.comm().max( &minMax[ 0 ], 2 );
if( Dune::Fem::Parameter :: verbose () ) if( Dune::Fem::Parameter :: verbose () )
...@@ -118,7 +123,7 @@ struct AdvectionDiffusionStepper ...@@ -118,7 +123,7 @@ struct AdvectionDiffusionStepper
// create adaptation handler in case of apost indicator // create adaptation handler in case of apost indicator
if( adaptive() ) if( adaptive() )
{ {
if( ! adaptationHandler_ ) // && adaptParam_.aposterioriIndicator() ) if( ! adaptationHandler_ && adaptParam_.aposterioriIndicator() )
{ {
adaptationHandler_ = new AdaptationHandlerType( grid_, tp ); adaptationHandler_ = new AdaptationHandlerType( grid_, tp );
dgIndicator_.setAdaptation( *adaptationHandler_ ); dgIndicator_.setAdaptation( *adaptationHandler_ );
...@@ -130,19 +135,20 @@ struct AdvectionDiffusionStepper ...@@ -130,19 +135,20 @@ struct AdvectionDiffusionStepper
LinearInverseOperatorType > OdeSolverImpl; LinearInverseOperatorType > OdeSolverImpl;
return new OdeSolverImpl( tp, dgOperator_, return new OdeSolverImpl( tp, dgOperator_,
dgAdvectionOperator_, dgAdvectionOperator_,
dgDiffusionOperator_ ); dgDiffusionOperator_,
name() );
} }
//! estimate and mark solution //! estimate and mark solution
virtual void initialEstimateMarkAdapt( ) virtual void initialEstimateMarkAdapt( )
{ {
// doEstimateMarkAdapt( dgIndicator_, gradientIndicator_, true ); doEstimateMarkAdapt( dgIndicator_, gradientIndicator_, true );
} }
//! estimate and mark solution //! estimate and mark solution
virtual void estimateMarkAdapt( ) virtual void estimateMarkAdapt( )
{ {
// doEstimateMarkAdapt( dgIndicator_, gradientIndicator_, false ); doEstimateMarkAdapt( dgIndicator_, gradientIndicator_, false );
} }
const ModelType& model() const { return dgOperator_.model(); } const ModelType& model() const { return dgOperator_.model(); }
...@@ -152,6 +158,6 @@ protected: ...@@ -152,6 +158,6 @@ protected:
ExplicitOperatorType dgAdvectionOperator_; ExplicitOperatorType dgAdvectionOperator_;
ImplicitOperatorType dgDiffusionOperator_; ImplicitOperatorType dgDiffusionOperator_;
DGIndicatorType dgIndicator_; DGIndicatorType dgIndicator_;
//GradientIndicatorType gradientIndicator_; GradientIndicatorType gradientIndicator_;
}; };
#endif // FEMHOWTO_STEPPER_HH #endif // FEMHOWTO_STEPPER_HH
...@@ -122,6 +122,9 @@ struct StepperBase ...@@ -122,6 +122,9 @@ struct StepperBase
using BaseType :: grid_ ; using BaseType :: grid_ ;
using BaseType :: limitSolution ; using BaseType :: limitSolution ;
using BaseType :: adaptParam_ ;
using BaseType :: eocParam_;
using BaseType :: param_;
// constructor taking grid // constructor taking grid
StepperBase(GridType& grid, const std::string name = "" ) : StepperBase(GridType& grid, const std::string name = "" ) :
...@@ -183,12 +186,10 @@ struct StepperBase ...@@ -183,12 +186,10 @@ struct StepperBase
return IOTupleType( &solution_, additionalVariables_, indicator() ); return IOTupleType( &solution_, additionalVariables_, indicator() );
} }
/*
bool checkDofsValid ( TimeProviderType& tp, const int loop ) const bool checkDofsValid ( TimeProviderType& tp, const int loop ) const
{ {
return solution_.dofsValid(); return solution_.dofsValid();
} }
*/
void writeData( TimeProviderType& tp, const bool writeAnyway = false ) void writeData( TimeProviderType& tp, const bool writeAnyway = false )
{ {
...@@ -207,7 +208,7 @@ struct StepperBase ...@@ -207,7 +208,7 @@ struct StepperBase
problem().postProcessTimeStep( grid_, solution(), tp.time() ); problem().postProcessTimeStep( grid_, solution(), tp.time() );
} }
bool adaptive () const { return false; } bool adaptive () const { return adaptParam_.adaptive(); }
// function creating the ode solvers // function creating the ode solvers
virtual OdeSolverType* createOdeSolver( TimeProviderType& ) = 0; virtual OdeSolverType* createOdeSolver( TimeProviderType& ) = 0;
...@@ -290,10 +291,10 @@ struct StepperBase ...@@ -290,10 +291,10 @@ struct StepperBase
{ {
// copy data tuple // copy data tuple
dataTuple_ = dataTuple () ; dataTuple_ = dataTuple () ;
//dataWriter_ = new DataWriterType( grid_, dataTuple_, tp ); //, dataWriter_ = new DataWriterType( grid_, dataTuple_, tp,
// eocParam_.dataOutputParameters( loop, problem_->dataPrefix() ) ); eocParam_.dataOutputParameters( loop, problem_->dataPrefix() ) );
//assert( dataWriter_ );
} }
assert( dataWriter_ );
typedef typename InitialDataType :: TimeDependentFunctionType typedef typename InitialDataType :: TimeDependentFunctionType
TimeDependentFunctionType; TimeDependentFunctionType;
...@@ -357,8 +358,7 @@ struct StepperBase ...@@ -357,8 +358,7 @@ struct StepperBase
inline double error(TimeProviderType& tp, DiscreteFunctionType& u) inline double error(TimeProviderType& tp, DiscreteFunctionType& u)
{ {
// const int order = eocParam_.quadOrder() < 0 ? 2*u.space().order()+4 : eocParam_.quadOrder(); const int order = eocParam_.quadOrder() < 0 ? 2*u.space().order()+4 : eocParam_.quadOrder();
const int order = 2*u.space().order()+4 ;
Fem :: L2Norm< GridPartType > l2norm( u.space().gridPart(), order ); Fem :: L2Norm< GridPartType > l2norm( u.space().gridPart(), order );
return l2norm.distance( problem().fixedTimeFunction( tp.time() ), u ); return l2norm.distance( problem().fixedTimeFunction( tp.time() ), u );
} }
...@@ -421,7 +421,7 @@ protected: ...@@ -421,7 +421,7 @@ protected:
GradientIndicator& gradientIndicator, GradientIndicator& gradientIndicator,
const bool initialAdaptation = false ) const bool initialAdaptation = false )
{ {
if( adaptive() ) if( adaptParam_.adaptive() )
{ {
// get grid sequence before adaptation // get grid sequence before adaptation
const int sequence = space().sequence(); const int sequence = space().sequence();
...@@ -434,7 +434,6 @@ protected: ...@@ -434,7 +434,6 @@ protected:
// do marking and adaptation // do marking and adaptation
adaptationHandler_->adapt( adaptationManager(), initialAdaptation ); adaptationHandler_->adapt( adaptationManager(), initialAdaptation );
} }
/*
else if( adaptParam_.gradientBasedIndicator() ) else if( adaptParam_.gradientBasedIndicator() )
{ {
gradientIndicator.estimateAndMark( solution_ ); gradientIndicator.estimateAndMark( solution_ );
...@@ -445,7 +444,7 @@ protected: ...@@ -445,7 +444,7 @@ protected:
// marking has been done by limiter // marking has been done by limiter
adaptationManager().adapt(); adaptationManager().adapt();
} }
*/
// if grid has changed then limit solution again // if grid has changed then limit solution again
if( sequence != space().sequence() ) if( sequence != space().sequence() )
{ {
......
...@@ -3,7 +3,7 @@ DGF ...@@ -3,7 +3,7 @@ DGF
Interval Interval
0 0 0 0
2 2 2 2
16 16 32 32
# #
GridParameter GridParameter
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
fem.prefix: data fem.prefix: data
fem.io.datafileprefix: NS fem.io.datafileprefix: NS
fem.io.outputformat: vtk-cell fem.io.outputformat: none
fem.io.savestep: 0.01 # SaveStep (write data every `saveStep' time period, <=0 deactivates) fem.io.savestep: 0.01 # SaveStep (write data every `saveStep' time period, <=0 deactivates)
fem.io.savecount: -1 # SaveCount (write data every saveCount time steps, <=0 deactivates) fem.io.savecount: -1 # SaveCount (write data every saveCount time steps, <=0 deactivates)
femdg.stepper.printcount: 1000 femdg.stepper.printcount: 1000
......
...@@ -143,7 +143,7 @@ class Thermodynamics ...@@ -143,7 +143,7 @@ class Thermodynamics
assert( p > 1e-12 ); assert( p > 1e-12 );
assert( theta > 1e-12 ); assert( theta > 1e-12 );
const Field rho = std::pow( p/p0_ , gamma_inv_ ) * p0_ * R_d_inv_ / theta ; const Field rho = std::pow( double(p/p0_) , double(gamma_inv_) ) * p0_ * R_d_inv_ / theta ;
assert( rho > 0.0 ); assert( rho > 0.0 );
return rho; return rho;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment