Skip to content
Snippets Groups Projects
Commit 7dc73202 authored by Andreas Dedner's avatar Andreas Dedner
Browse files

Merge branch 'feature/exchange-troubled-cell' of...

Merge branch 'feature/exchange-troubled-cell' of ssh://gitlab.dune-project.org:22022/dune-fem/dune-fem-dg into feature/exchange-troubled-cell
parents 305254ce 2eef5454
No related branches found
No related tags found
1 merge request!15Exchange troubled cell
This commit is part of merge request !15. Comments created here will be created in the context of that merge request.
...@@ -11,8 +11,8 @@ variables: ...@@ -11,8 +11,8 @@ variables:
before_script: before_script:
- . /duneci/bin/duneci-init-job - . /duneci/bin/duneci-init-job
- python3 -m venv /duneci/modules/dune-pip #- python3 -m venv /duneci/modules/dune-pip
- source /duneci/modules/dune-pip/bin/activate #- source /duneci/modules/dune-pip/bin/activate
#- pip install --upgrade pip #- pip install --upgrade pip
#- pip install ufl numpy matplotlib mpi4py portalocker #- pip install ufl numpy matplotlib mpi4py portalocker
- duneci-install-module https://gitlab.dune-project.org/core/dune-common.git - duneci-install-module https://gitlab.dune-project.org/core/dune-common.git
...@@ -26,7 +26,7 @@ before_script: ...@@ -26,7 +26,7 @@ before_script:
debian-11-gcc-9-17: debian-11-gcc-9-17:
image: registry.dune-project.org/docker/ci/debian:11 image: registry.dune-project.org/docker/ci/debian:11
script: script:
- source /duneci/modules/dune-pip/bin/activate #- source /duneci/modules/dune-pip/bin/activate
# issue with setup-dunepy: dune-fem-dg not yet build so dependency in dune-fem-dg fails # issue with setup-dunepy: dune-fem-dg not yet build so dependency in dune-fem-dg fails
# - python /duneci/modules/dune-python/bin/setup-dunepy.py --opts=$CI_PROJECT_DIR/scripts/opts/ci-gcc.opts install # - python /duneci/modules/dune-python/bin/setup-dunepy.py --opts=$CI_PROJECT_DIR/scripts/opts/ci-gcc.opts install
- duneci-standard-test - duneci-standard-test
......
...@@ -39,12 +39,6 @@ ...@@ -39,12 +39,6 @@
#include <dune/fem-dg/operator/limiter/smoothness.hh> #include <dune/fem-dg/operator/limiter/smoothness.hh>
#include <dune/fem-dg/operator/limiter/indicatorbase.hh> #include <dune/fem-dg/operator/limiter/indicatorbase.hh>
#if HAVE_DUNE_OPTIM
#define WANT_DUNE_OPTIM 1
//#define WANT_DUNE_OPTIM 0
#endif
//************************************************************* //*************************************************************
namespace Dune namespace Dune
{ {
...@@ -257,7 +251,7 @@ namespace Fem ...@@ -257,7 +251,7 @@ namespace Fem
typedef AdaptationMethod<GridType> AdaptationMethodType; typedef AdaptationMethod<GridType> AdaptationMethodType;
//! id for choosing admissible linear functions //! id for choosing admissible linear functions
enum AdmissibleFunctions { DGFunctions = 0, ReconstructedFunctions = 1 , BothFunctions = 2 }; enum AdmissibleFunctions { DGFunctions = 0, ReconstructedFunctions = 1 , DGAndReconFunctions = 2, LPFunctions = 3 };
//! returns true if pass is currently active in the pass tree //! returns true if pass is currently active in the pass tree
using BaseType :: active ; using BaseType :: active ;
...@@ -269,7 +263,6 @@ namespace Fem ...@@ -269,7 +263,6 @@ namespace Fem
typedef TroubledCellIndicatorBase<ArgumentFunctionType> TroubledCellIndicatorType; typedef TroubledCellIndicatorBase<ArgumentFunctionType> TroubledCellIndicatorType;
protected: protected:
#if WANT_DUNE_OPTIM
typedef typename GridPartType :: GridViewType GridViewType ; typedef typename GridPartType :: GridViewType GridViewType ;
struct BoundaryValue struct BoundaryValue
...@@ -287,8 +280,6 @@ namespace Fem ...@@ -287,8 +280,6 @@ namespace Fem
}; };
typedef Dune::FV::LPReconstruction< GridViewType, RangeType, BoundaryValue > LinearProgramming; typedef Dune::FV::LPReconstruction< GridViewType, RangeType, BoundaryValue > LinearProgramming;
#endif
public: public:
//- Public methods //- Public methods
...@@ -333,11 +324,7 @@ namespace Fem ...@@ -333,11 +324,7 @@ namespace Fem
dest_(0), dest_(0),
spc_(spc), spc_(spc),
gridPart_(spc_.gridPart()), gridPart_(spc_.gridPart()),
#if WANT_DUNE_OPTIM linProg_(),
linProg_( static_cast< GridViewType > (gridPart_), BoundaryValue( *this ),
Dune::Fem::Parameter::getValue<double>("finitevolume.linearprogramming.tol", 1e-8 )
),
#endif
indexSet_( gridPart_.indexSet() ), indexSet_( gridPart_.indexSet() ),
localIdSet_( gridPart_.grid().localIdSet()), localIdSet_( gridPart_.grid().localIdSet()),
cornerPointSetContainer_(), cornerPointSetContainer_(),
...@@ -369,6 +356,12 @@ namespace Fem ...@@ -369,6 +356,12 @@ namespace Fem
? new ModalSmoothnessIndicator< ArgumentFunctionType >() : nullptr ), ? new ModalSmoothnessIndicator< ArgumentFunctionType >() : nullptr ),
counter_( 0 ) counter_( 0 )
{ {
if( admissibleFunctions_ == LPFunctions )
{
linProg_.reset( new LinearProgramming( static_cast< GridViewType > (gridPart_), BoundaryValue( *this ),
Dune::Fem::Parameter::getValue<double>("finitevolume.linearprogramming.tol", 1e-8 )) );
}
if( Parameter :: verbose () ) if( Parameter :: verbose () )
{ {
std::cout << "LimitDGPass (Grid is "; std::cout << "LimitDGPass (Grid is ";
...@@ -443,9 +436,10 @@ namespace Fem ...@@ -443,9 +436,10 @@ namespace Fem
AdmissibleFunctions getAdmissibleFunctions( const Dune::Fem::ParameterReader &parameter ) const AdmissibleFunctions getAdmissibleFunctions( const Dune::Fem::ParameterReader &parameter ) const
{ {
// default value // default value
int val = 1; //int val = 1; // reconstruction
int val = 3; // lp-reconstruction
val = parameter.getValue("femdg.limiter.admissiblefunctions", val); val = parameter.getValue("femdg.limiter.admissiblefunctions", val);
assert( val >= DGFunctions || val <= BothFunctions ); assert( val >= DGFunctions || val <= LPFunctions );
return (AdmissibleFunctions) val; return (AdmissibleFunctions) val;
} }
...@@ -661,21 +655,22 @@ namespace Fem ...@@ -661,21 +655,22 @@ namespace Fem
matrixCacheVec_.resize( numLevels ); matrixCacheVec_.resize( numLevels );
} }
#if WANT_DUNE_OPTIM if( linProg_ )
// helper class for evaluation of average value of discrete function
EvalAverage average( *this, U, discreteModel_);
values_.resize( size );
// evaluate average values on all cells
for( const auto& element : Dune::elements( gridPart_ ) )
{ {
average.evaluate( element, values_[ gridPart_.indexSet().index( element ) ] ); // helper class for evaluation of average value of discrete function
} EvalAverage average( *this, U, discreteModel_);
gradients_.resize( size ); values_.resize( size );
// get reconstructions // evaluate average values on all cells
linProg_( gridPart_.indexSet(), values_, gradients_ ); for( const auto& element : Dune::elements( gridPart_ ) )
#endif {
average.evaluate( element, values_[ gridPart_.indexSet().index( element ) ] );
}
gradients_.resize( size );
// get reconstructions
(*linProg_)( gridPart_.indexSet(), values_, gradients_ );
}
} }
//! Some management (interface version) //! Some management (interface version)
...@@ -794,8 +789,8 @@ namespace Fem ...@@ -794,8 +789,8 @@ namespace Fem
// cache geometry type // cache geometry type
const GeometryType geomType = geo.type(); const GeometryType geomType = geo.type();
// get bary center of element // get bary center of element
const LocalDomainType& x = geoInfo_.localCenter( geomType ); const LocalDomainType& wLocal = geoInfo_.localCenter( geomType );
const DomainType enBary = geo.global( x ); const DomainType enBary = geomType.isNone() ? geo.center() : geo.global( wLocal );
const IntersectionIteratorType endnit = gridPart_.iend( en ); const IntersectionIteratorType endnit = gridPart_.iend( en );
IntersectionIteratorType niter = gridPart_.ibegin(en); IntersectionIteratorType niter = gridPart_.ibegin(en);
...@@ -829,9 +824,8 @@ namespace Fem ...@@ -829,9 +824,8 @@ namespace Fem
// otherwise everything may be corrupted // otherwise everything may be corrupted
{ {
// get barycenter of entity // get barycenter of entity
const DomainType& enBaryLocal = (int(dimGrid) == int(dimDomain)) ? const DomainType& enBaryLocal = (int(dimGrid) == int(dimDomain) && ! geomType.isNone() ) ?
geoInfo_.localCenter( geomType ) : wLocal : geo.local( enBary ) ;
geo.local( enBary ) ;
// check that average value is physical // check that average value is physical
if( discreteModel_.hasPhysical() && if( discreteModel_.hasPhysical() &&
...@@ -927,14 +921,12 @@ namespace Fem ...@@ -927,14 +921,12 @@ namespace Fem
++limitedElements_; ++limitedElements_;
const unsigned int enIndex = indexSet_.index( en ); const unsigned int enIndex = indexSet_.index( en );
#if WANT_DUNE_OPTIM // use linear function from LP reconstruction
bool useLinProg = true ; if( admissibleFunctions_ == LPFunctions )
if( useLinProg )
{ {
deoMod_ = gradients_[ enIndex ]; deoMod_ = gradients_[ enIndex ];
} }
else else
#endif
{ {
// obtain combination set // obtain combination set
ComboSetType& comboSet = storedComboSets_[ nbVals_.size() ]; ComboSetType& comboSet = storedComboSets_[ nbVals_.size() ];
...@@ -1698,9 +1690,7 @@ namespace Fem ...@@ -1698,9 +1690,7 @@ namespace Fem
const DiscreteFunctionSpaceType& spc_; const DiscreteFunctionSpaceType& spc_;
GridPartType& gridPart_; GridPartType& gridPart_;
#if WANT_DUNE_OPTIM std::unique_ptr< LinearProgramming > linProg_;
mutable LinearProgramming linProg_;
#endif
const IndexSetType& indexSet_; const IndexSetType& indexSet_;
const LocalIdSetType& localIdSet_; const LocalIdSetType& localIdSet_;
...@@ -1758,8 +1748,8 @@ namespace Fem ...@@ -1758,8 +1748,8 @@ namespace Fem
mutable bool reconstruct_; mutable bool reconstruct_;
// choice of admissible linear functions // choice of admissible linear functions
const AdmissibleFunctions admissibleFunctions_; const AdmissibleFunctions admissibleFunctions_;
mutable AdmissibleFunctions usedAdmissibleFunctions_ ; mutable AdmissibleFunctions usedAdmissibleFunctions_ ;
mutable std::vector< RangeType > values_; mutable std::vector< RangeType > values_;
mutable std::vector< GradientType > gradients_; mutable std::vector< GradientType > gradients_;
......
...@@ -38,7 +38,7 @@ Model.exact = None ...@@ -38,7 +38,7 @@ Model.exact = None
run(Model, run(Model,
startLevel=0, limiter="default", startLevel=0, limiter="default",
primitive=primitive, saveStep=0.16, subsamp=2, primitive=primitive, saveStep=0.16,
dt=None,threading=False,grid="polygon", space="finitevolume", dt=None,threading=False,grid="polygon", space="finitevolume",
parameters=parameters) parameters=parameters)
......
...@@ -21,6 +21,11 @@ def run(Model, Stepper=None, ...@@ -21,6 +21,11 @@ def run(Model, Stepper=None,
exact = Model.exact exact = Model.exact
except: except:
exact = None exact = None
if grid == "polygon":
subsamp=None
print('Disabling subsampling for PolygonGrid')
print("*************************************") print("*************************************")
print("**** Running simulation",Model.name) print("**** Running simulation",Model.name)
print("*************************************") print("*************************************")
......
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