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