4 #ifndef DUNE_PDELAB_ADAPTIVITY_HH
5 #define DUNE_PDELAB_ADAPTIVITY_HH
7 #include<dune/common/exceptions.hh>
12 #include<dune/common/dynmatrix.hh>
13 #include<dune/geometry/quadraturerules.hh>
24 #include<dune/grid/io/file/vtk/subsamplingvtkwriter.hh>
30 template<
typename GFS>
34 typedef typename GFS::Traits::GridView::template Codim<0>::Entity
Cell;
39 typedef array<std::size_t,TypeTree::TreeInfo<GFS>::leafCount + 1>
LeafOffsets;
45 assert(leaf_offsets.back() > 0);
52 if (leaf_offsets.back() == 0)
57 std::partial_sum(leaf_offsets.begin(),leaf_offsets.end(),leaf_offsets.begin());
59 assert(leaf_offsets.back() ==
_lfs.
size());
76 template<
typename MassMatrices,
typename Cell>
77 struct inverse_mass_matrix_calculator
78 :
public TypeTree::TreeVisitor
79 ,
public TypeTree::DynamicTraversal
82 static const int dim = Cell::Geometry::dimension;
83 typedef std::size_t size_type;
84 typedef typename MassMatrices::value_type MassMatrix;
85 typedef typename MassMatrix::field_type DF;
86 typedef typename Dune::QuadratureRule<DF,dim>::const_iterator QRIterator;
88 template<
typename GFS,
typename TreePath>
89 void leaf(
const GFS& gfs, TreePath treePath)
91 typedef typename GFS::Traits::FiniteElementMap FEM;
92 const FEM& fem = gfs.finiteElementMap();
93 typedef typename FEM::Traits::FiniteElement FiniteElement;
94 const FiniteElement& fe = fem.find(
_element);
95 size_type local_size = fe.localBasis().size();
98 mass_matrix.resize(local_size,local_size);
101 std::vector<typename FiniteElement::Traits::LocalBasisType::Traits::RangeType> phi;
102 phi.resize(std::max(phi.size(),local_size));
107 fe.localBasis().evaluateFunction(it->position(),phi);
108 const DF factor = it->weight();
110 for (
int i = 0; i < local_size; ++i)
111 for (
int j = 0; j < local_size; ++j)
112 mass_matrix[i][j] += phi[i] * phi[j] * factor;
115 mass_matrix.invert();
120 inverse_mass_matrix_calculator(MassMatrices& mass_matrices,
const Cell& element, size_type intorder)
144 template<
class GFS,
class U>
147 typedef typename GFS::Traits::GridViewType::Grid Grid;
148 typedef typename Grid::template Codim<0>::Entity Element;
150 typedef typename U::ElementType DF;
155 typedef array<MassMatrix,TypeTree::TreeInfo<GFS>::leafCount>
MassMatrices;
163 , _intorder(intorder)
164 , _inverse_mass_matrices(GlobalGeometryTypeIndex::size(Element::dimension))
174 const GeometryType gt = e.geometry().type();
175 MassMatrices& inverse_mass_matrices = _inverse_mass_matrices[GlobalGeometryTypeIndex::index(gt)];
177 if (inverse_mass_matrices[0].N() > 0)
178 return inverse_mass_matrices;
180 inverse_mass_matrix_calculator<MassMatrices,Element> calculate_mass_matrices(
181 inverse_mass_matrices,
186 TypeTree::applyToTree(_gfs,calculate_mass_matrices);
188 return inverse_mass_matrices;
195 std::vector<MassMatrices> _inverse_mass_matrices;
199 template<
typename GFS,
typename DOFVector,
typename TransferMap>
201 :
public TypeTree::TreeVisitor
202 ,
public TypeTree::DynamicTraversal
209 typedef typename GFS::Traits::GridView::Grid::LocalIdSet
IDSet;
210 typedef typename GFS::Traits::GridView::template Codim<0>::Entity
Cell;
211 typedef typename GFS::Traits::GridView::template Codim<0>::EntityPointer
CellPointer;
213 static const int dim = Geometry::dimension;
215 typedef typename DOFVector::ElementType
RF;
224 typedef typename GFS::Traits::GridView::ctype
DF;
226 template<
typename LFSLeaf,
typename TreePath>
227 void leaf(
const LFSLeaf& leaf_lfs, TreePath treePath)
230 typedef typename LFSLeaf::Traits::GridFunctionSpace::Traits::FiniteElementMap FEM;
231 typedef typename FEM::Traits::FiniteElement FE;
232 const FEM& fem = leaf_lfs.gridFunctionSpace().finiteElementMap();
236 typedef typename FE::Traits::LocalBasisType::Traits::RangeType Range;
240 std::vector<Range> coarse_phi;
241 std::vector<Range> fine_phi;
246 const QuadratureRule<DF,dim>& rule = QuadratureRules<DF,dim>::rule(
_current->type(),
_int_order);
248 for (
typename QuadratureRule<DF,dim>::const_iterator it=rule.begin(); it!=rule.end(); ++it)
250 typename Geometry::LocalCoordinate coarse_local = coarse_geometry.local(fine_geometry.global(it->position()));
251 const FE* fe = &fem.find(*
_current);
252 fe->localBasis().evaluateFunction(it->position(),fine_phi);
254 fe->localBasis().evaluateFunction(coarse_local,coarse_phi);
255 const DF factor = it->weight()
256 * fine_geometry.integrationElement(it->position())
257 / coarse_geometry.integrationElement(coarse_local);
260 for (
size_type i = 0; i < fine_phi.size(); ++i)
262 val.axpy(
_u_fine[fine_offset + i],fine_phi[i]);
265 for (
size_type i = 0; i < coarse_phi.size(); ++i)
268 for (
size_type j = 0; j < inverse_mass_matrix.M(); ++j)
269 x.axpy(inverse_mass_matrix[i][j],coarse_phi[j]);
270 (*_u_coarse)[coarse_offset + i] += factor * (x * val);
294 while (ancestor->mightVanish())
297 if (!ancestor->hasFather())
300 ancestor = ancestor->father();
330 TypeTree::applyToTree(
_lfs,*
this);
340 TransferMap& transfer_map,
341 std::size_t int_order = 2)
344 ,
_id_set(gfs.gridView().grid().localIdSet())
364 typename DOFVector::template ConstLocalView<LFSCache>
_u_view;
376 template<
typename GFS,
typename DOFVector,
typename CountVector>
378 :
public TypeTree::TreeVisitor
379 ,
public TypeTree::DynamicTraversal
386 typedef typename LFS::Traits::GridFunctionSpace::Traits::GridView::template Codim<0>::Entity
Cell;
388 typedef typename DOFVector::ElementType
RF;
394 template<
typename FiniteElement>
398 template<
typename X,
typename Y>
420 mutable std::vector<typename FiniteElement::Traits::LocalBasisType::Traits::RangeType>
_phi;
426 template<
typename LeafLFS,
typename TreePath>
427 void leaf(
const LeafLFS& leaf_lfs, TreePath treePath)
430 typedef typename LeafLFS::Traits::GridFunctionSpace::Traits::FiniteElementMap FEM;
431 const FEM& fem = leaf_lfs.gridFunctionSpace().finiteElementMap();
436 const typename FEM::Traits::FiniteElement& fe = fem.find(*
_element);
438 _u_tmp.resize(fe.localBasis().size());
440 fe.localInterpolation().interpolate(
f,
_u_tmp);
468 TypeTree::applyToTree(
_lfs,*
this);
494 typename DOFVector::template LocalView<LFSCache>
_u_view;
495 typename CountVector::template LocalView<LFSCache>
_uc_view;
519 template<
class Gr
id,
class GFSU,
class U,
class Projection>
522 typedef typename Grid::LeafGridView LeafGridView;
523 typedef typename LeafGridView::template Codim<0>
524 ::template Partition<Dune::Interior_Partition>::Iterator LeafIterator;
525 typedef typename Grid::template Codim<0>::Entity Element;
526 typedef typename Grid::template Codim<0>::EntityPointer ElementPointer;
527 typedef typename Grid::LocalIdSet IDSet;
528 typedef typename IDSet::IdType ID;
541 : _leaf_offset_cache(gfs)
553 Visitor visitor(gfsu,projection,u,_leaf_offset_cache,transfer_map);
556 LeafGridView leafView = grid.leafGridView();
557 for (LeafIterator it = leafView.template begin<0,Dune::Interior_Partition>();
558 it!=leafView.template end<0,Dune::Interior_Partition>(); ++it)
569 void replayData(Grid& grid, GFSU& gfsu, Projection& projection, U& u,
const MapType& transfer_map)
571 const IDSet& id_set = grid.globalIdSet();
574 CountVector uc(gfsu,0);
577 Visitor visitor(gfsu,u,uc,_leaf_offset_cache);
580 LeafGridView leafView = grid.leafGridView();
581 for (LeafIterator it = leafView.template begin<0,Dune::Interior_Partition>();
582 it!=leafView.template end<0,Dune::Interior_Partition>(); ++it)
584 const Element&
e = *it;
586 ElementPointer ancestor(e);
588 typename MapType::const_iterator map_it;
589 while ((map_it = transfer_map.find(id_set.id(*ancestor))) == transfer_map.end())
591 if (!ancestor->hasFather())
593 "transferMap of GridAdaptor didn't contain ancestor of element with id " << id_set.id(*ancestor));
594 ancestor = ancestor->father();
597 visitor(e,*ancestor,map_it->second);
601 DOFHandle addHandle1(gfsu,u);
602 leafView.communicate (addHandle1,
603 Dune::InteriorBorder_InteriorBorder_Interface,Dune::ForwardCommunication);
605 CountHandle addHandle2(gfsu,uc);
606 leafView.communicate (addHandle2,
607 Dune::InteriorBorder_InteriorBorder_Interface,Dune::ForwardCommunication);
610 typename CountVector::iterator ucit = uc.begin();
611 for (
typename U::iterator uit = u.begin(), uend = u.end(); uit != uend; ++uit, ++ucit)
612 (*uit) /= ((*ucit) > 0 ? (*ucit) : 1.0);
631 template<
class Gr
id,
class GFS,
class X>
635 Projection projection(gfs,int_order);
644 grid_adaptor.
backupData(grid,gfs,projection,x1,transferMap1);
654 grid_adaptor.
replayData(grid,gfs,projection,x1,transferMap1);
671 template<
class Gr
id,
class GFS,
class X>
672 void adapt_grid (Grid& grid, GFS& gfs, X& x1, X& x2,
int int_order)
675 Projection projection(gfs,int_order);
684 grid_adaptor.
backupData(grid,gfs,projection,x1,transferMap1);
686 grid_adaptor.
backupData(grid,gfs,projection,x2,transferMap2);
696 grid_adaptor.
replayData(grid,gfs,projection,x1,transferMap1);
698 grid_adaptor.
replayData(grid,gfs,projection,x2,transferMap2);
707 template<
class Gr
id,
class GFS,
class X>
708 void adapt_grid (Grid& grid, GFS& gfs, X& x1) DUNE_DEPRECATED_MSG(
"Please use the version of adapt_grid() that explicity specifies the integration order instead");
710 template<
class Gr
id,
class GFS,
class X>
711 void adapt_grid (Grid& grid, GFS& gfs, X& x1, X& x2) DUNE_DEPRECATED_MSG(
"Please use the version of adapt_grid() that explicity specifies the integration order instead");
713 template<
class Gr
id,
class GFS,
class X>
719 template<
class Gr
id,
class GFS,
class X>
728 void error_fraction(
const T& x,
typename T::ElementType alpha,
typename T::ElementType beta,
729 typename T::ElementType& eta_alpha,
typename T::ElementType& eta_beta,
int verbose=0)
732 std::cout <<
"+++ error fraction: alpha=" << alpha <<
" beta=" << beta << std::endl;
734 typedef typename T::ElementType NumberType;
735 NumberType total_error = x.one_norm();
736 NumberType max_error = x.infinity_norm();
737 NumberType eta_alpha_left = 0.0;
738 NumberType eta_alpha_right = max_error;
739 NumberType eta_beta_left = 0.0;
740 NumberType eta_beta_right = max_error;
741 for (
int j=1; j<=steps; j++)
743 eta_alpha = 0.5*(eta_alpha_left+eta_alpha_right);
744 eta_beta = 0.5*(eta_beta_left+eta_beta_right);
745 NumberType sum_alpha=0.0;
746 NumberType sum_beta=0.0;
747 unsigned int alpha_count = 0;
748 unsigned int beta_count = 0;
749 for (
typename T::const_iterator it = x.begin(),
754 if (*it >=eta_alpha) { sum_alpha += *it; alpha_count++;}
755 if (*it < eta_beta) { sum_beta += *it; beta_count++;}
759 std::cout <<
"+++ " << j <<
" eta_alpha=" << eta_alpha <<
" alpha_fraction=" << sum_alpha/total_error
760 <<
" elements: " << alpha_count <<
" of " << x.N() << std::endl;
761 std::cout <<
"+++ " << j <<
" eta_beta=" << eta_beta <<
" beta_fraction=" << sum_beta/total_error
762 <<
" elements: " << beta_count <<
" of " << x.N() << std::endl;
764 if (std::abs(alpha-sum_alpha/total_error) <= 0.01 && std::abs(beta-sum_beta/total_error) <= 0.01)
break;
765 if (sum_alpha>alpha*total_error)
766 eta_alpha_left = eta_alpha;
768 eta_alpha_right = eta_alpha;
769 if (sum_beta>beta*total_error)
770 eta_beta_right = eta_beta;
772 eta_beta_left = eta_beta;
776 std::cout <<
"+++ refine_threshold=" << eta_alpha
777 <<
" coarsen_threshold=" << eta_beta << std::endl;
783 void element_fraction(
const T& x,
typename T::ElementType alpha,
typename T::ElementType beta,
784 typename T::ElementType& eta_alpha,
typename T::ElementType& eta_beta,
int verbose=0)
787 typedef typename T::ElementType NumberType;
788 NumberType total_error =x.N();
789 NumberType max_error = x.infinity_norm();
790 NumberType eta_alpha_left = 0.0;
791 NumberType eta_alpha_right = max_error;
792 NumberType eta_beta_left = 0.0;
793 NumberType eta_beta_right = max_error;
794 for (
int j=1; j<=steps; j++)
796 eta_alpha = 0.5*(eta_alpha_left+eta_alpha_right);
797 eta_beta = 0.5*(eta_beta_left+eta_beta_right);
798 NumberType sum_alpha=0.0;
799 NumberType sum_beta=0.0;
800 unsigned int alpha_count = 0;
801 unsigned int beta_count = 0;
803 for (
typename T::const_iterator it = x.begin(),
808 if (*it>=eta_alpha) { sum_alpha += 1.0; alpha_count++;}
809 if (*it< eta_beta) { sum_beta +=1.0; beta_count++;}
813 std::cout << j <<
" eta_alpha=" << eta_alpha <<
" alpha_fraction=" << sum_alpha/total_error
814 <<
" elements: " << alpha_count <<
" of " << x.N() << std::endl;
815 std::cout << j <<
" eta_beta=" << eta_beta <<
" beta_fraction=" << sum_beta/total_error
816 <<
" elements: " << beta_count <<
" of " << x.N() << std::endl;
818 if (std::abs(alpha-sum_alpha/total_error) <= 0.01 && std::abs(beta-sum_beta/total_error) <= 0.01)
break;
819 if (sum_alpha>alpha*total_error)
820 eta_alpha_left = eta_alpha;
822 eta_alpha_right = eta_alpha;
823 if (sum_beta>beta*total_error)
824 eta_beta_right = eta_beta;
826 eta_beta_left = eta_beta;
830 std::cout <<
"+++ refine_threshold=" << eta_alpha
831 <<
" coarsen_threshold=" << eta_beta << std::endl;
841 typedef typename T::ElementType NumberType;
842 NumberType total_error = x.one_norm();
843 NumberType total_elements = x.N();
844 NumberType max_error = x.infinity_norm();
845 std::vector<NumberType> left(bins,0.0);
846 std::vector<NumberType> right(bins,max_error*(1.0+1
e-8));
847 std::vector<NumberType> eta(bins);
848 std::vector<NumberType> target(bins);
849 for (
unsigned int k=0; k<bins; k++)
850 target[k]= (k+1)/((NumberType)bins);
851 for (
int j=1; j<=steps; j++)
853 for (
unsigned int k=0; k<bins; k++)
854 eta[k]= 0.5*(left[k]+right[k]);
855 std::vector<NumberType> sum(bins,0.0);
856 std::vector<int> count(bins,0);
858 for (
typename T::const_iterator it = x.begin(),
863 for (
unsigned int k=0; k<bins; k++)
875 for (
unsigned int k=0; k<bins; k++)
876 if (sum[k]<=target[k]*total_error)
881 std::vector<NumberType> sum(bins,0.0);
882 std::vector<int> count(bins,0);
883 for (
unsigned int i=0; i<x.N(); i++)
884 for (
unsigned int k=0; k<bins; k++)
890 std::cout <<
"+++ error distribution" << std::endl;
891 std::cout <<
"+++ number of elements: " << x.N() << std::endl;
892 std::cout <<
"+++ max element error: " << max_error << std::endl;
893 std::cout <<
"+++ total error: " << total_error << std::endl;
894 std::cout <<
"+++ bin #elements eta sum/total " << std::endl;
895 for (
unsigned int k=0; k<bins; k++)
896 std::cout <<
"+++ " << k+1 <<
" " << count[k] <<
" " << eta[k] <<
" " << sum[k]/total_error << std::endl;
899 template<
typename Gr
id,
typename X>
900 void mark_grid (Grid &grid,
const X& x,
typename X::ElementType refine_threshold,
901 typename X::ElementType coarsen_threshold,
int min_level = 0,
int max_level = std::numeric_limits<int>::max(),
int verbose=0)
905 typedef typename Grid::template Partition<Dune::All_Partition>::LeafGridView GV;
906 typedef typename GV::template Codim<0>::Iterator Iterator;
908 const GV& gv=grid.template leafGridView<Dune::All_Partition>();
911 Iterator it = gv.template begin<0>();
912 Iterator eit = gv.template end<0>();
914 unsigned int refine_cnt=0;
915 unsigned int coarsen_cnt=0;
917 typedef typename X::GridFunctionSpace GFS;
920 typedef typename X::template ConstLocalView<LFSCache> XView;
922 LFS lfs(x.gridFunctionSpace());
923 LFSCache lfs_cache(lfs);
930 x_view.bind(lfs_cache);
932 if (x_view[0]>=refine_threshold && it->level() < max_level)
937 if (x_view[0]<=coarsen_threshold && it->level() > min_level)
945 std::cout <<
"+++ mark_grid: " << refine_cnt <<
" marked for refinement, "
946 << coarsen_cnt <<
" marked for coarsening" << std::endl;
950 template<
typename Gr
id,
typename X>
952 typename X::ElementType coarsen_threshold,
int verbose=0)
954 typedef typename Grid::template Codim<0>::template Partition<Dune::All_Partition>::LeafIterator
956 typedef typename Grid::LeafGridView GV;
957 typedef typename GV::IndexSet IndexSet;
959 const GV& gv=grid.leafGridView();
960 const IndexSet& is(gv.indexSet());
961 Iterator it = grid.template leafbegin<0,Dune::All_Partition>();
962 Iterator eit = grid.template leafend<0,Dune::All_Partition>();
964 unsigned int coarsen_cnt=0;
966 typedef typename X::GridFunctionSpace GFS;
969 typedef typename X::template ConstLocalView<LFSCache> XView;
971 LFS lfs(x.gridFunctionSpace());
972 LFSCache lfs_cache(lfs);
979 x_view.bind(lfs_cache);
981 if (x_view[0]>=refine_threshold)
986 if (x_view[0]<=coarsen_threshold)
993 std::cout <<
"+++ mark_grid_for_coarsening: "
994 << coarsen_cnt <<
" marked for coarsening" << std::endl;
1002 double optimistic_factor;
1003 double coarsen_limit;
1004 double balance_limit;
1009 double refine_fraction_while_refinement;
1010 double coarsen_fraction_while_refinement;
1011 double coarsen_fraction_while_coarsening;
1012 double timestep_decrease_factor;
1013 double timestep_increase_factor;
1023 bool have_decreased_time_step;
1024 bool have_refined_grid;
1027 double accumulated_estimated_error_squared;
1028 double minenergy_rate;
1032 : scaling(16.0), optimistic_factor(1.0), coarsen_limit(0.5), balance_limit(0.33333),
1033 tol(tol_), T(T_), verbose(verbose_), no_adapt(false),
1034 refine_fraction_while_refinement(0.7),
1035 coarsen_fraction_while_refinement(0.2),
1036 coarsen_fraction_while_coarsening(0.2),
1037 timestep_decrease_factor(0.5), timestep_increase_factor(1.5),
1038 accept(false), adapt_dt(false), adapt_grid(false), newdt(1.0),
1039 have_decreased_time_step(false), have_refined_grid(false),
1040 accumulated_estimated_error_squared(0.0),
1047 timestep_decrease_factor=
s;
1052 timestep_increase_factor=
s;
1057 refine_fraction_while_refinement=
s;
1062 coarsen_fraction_while_refinement=
s;
1067 coarsen_fraction_while_coarsening=
s;
1092 optimistic_factor=
s;
1142 return accumulated_estimated_error_squared;
1148 have_decreased_time_step =
false;
1149 have_refined_grid =
false;
1152 template<
typename GM,
typename X>
1153 void evaluate_estimators (GM& grid,
double time,
double dt,
const X& eta_space,
const X& eta_time,
double energy_timeslab)
1160 double spatial_error = eta_space.one_norm();
1161 double temporal_error = scaling*eta_time.one_norm();
1162 double sum = spatial_error + temporal_error;
1164 double allowed = tol*tol*(energy_timeslab+minenergy_rate*dt);
1165 q_s = spatial_error/sum;
1166 q_t = temporal_error/sum;
1173 <<
" sum/allowed=" << sum/allowed
1175 <<
" estimated error=" << sqrt(accumulated_estimated_error_squared+sum)
1176 <<
" energy_rate=" << energy_timeslab/dt
1183 accumulated_estimated_error_squared += sum;
1184 if (verbose>1) std::cout <<
"+++ no adapt mode" << std::endl;
1193 if (verbose>1) std::cout <<
"+++ accepting time step" << std::endl;
1194 accumulated_estimated_error_squared += sum;
1197 if (sum<coarsen_limit*allowed)
1200 if (q_t<balance_limit)
1203 newdt = timestep_increase_factor*dt;
1205 if (verbose>1) std::cout <<
"+++ spatial error dominates: increase time step" << std::endl;
1209 if (q_s>balance_limit)
1212 newdt = timestep_increase_factor*dt;
1214 if (verbose>1) std::cout <<
"+++ increasing time step" << std::endl;
1217 double eta_refine, eta_coarsen;
1218 if (verbose>1) std::cout <<
"+++ mark grid for coarsening" << std::endl;
1221 coarsen_fraction_while_coarsening,eta_refine,eta_coarsen);
1229 if (q_t<balance_limit)
1232 newdt = timestep_increase_factor*dt;
1234 if (verbose>1) std::cout <<
"+++ spatial error dominates: increase time step" << std::endl;
1241 if (verbose>1) std::cout <<
"+++ will redo time step" << std::endl;
1242 if (q_t>1-balance_limit)
1245 newdt = timestep_decrease_factor*dt;
1247 have_decreased_time_step =
true;
1248 if (verbose>1) std::cout <<
"+++ decreasing time step only" << std::endl;
1252 if (q_t<balance_limit)
1254 if (!have_decreased_time_step)
1257 newdt = timestep_increase_factor*dt;
1259 if (verbose>1) std::cout <<
"+++ increasing time step" << std::endl;
1265 newdt = timestep_decrease_factor*dt;
1267 have_decreased_time_step =
true;
1268 if (verbose>1) std::cout <<
"+++ decreasing time step" << std::endl;
1271 double eta_refine, eta_coarsen;
1272 if (verbose>1) std::cout <<
"+++ BINGO mark grid for refinement and coarsening" << std::endl;
1275 coarsen_fraction_while_refinement,eta_refine,eta_coarsen,0);
const LocalDOFVector & _dofs
Definition: adaptivity.hh:419
LocalDOFVector _u_fine
Definition: adaptivity.hh:499
size_type _offset
Definition: adaptivity.hh:421
LocalCountVector _counts
Definition: adaptivity.hh:501
const IDSet & _id_set
Definition: adaptivity.hh:359
double qt() const
Definition: adaptivity.hh:1130
const Cell * _ancestor
Definition: adaptivity.hh:493
const Cell * _ancestor
Definition: adaptivity.hh:361
TimeAdaptationStrategy(double tol_, double T_, int verbose_=0)
Definition: adaptivity.hh:1031
LFSCache _lfs_cache
Definition: adaptivity.hh:358
const Cell * _element
Definition: adaptivity.hh:360
DOFVector::template LocalView< LFSCache > _u_view
Definition: adaptivity.hh:494
void setTemporalScaling(double s)
Definition: adaptivity.hh:1085
void operator()(const Cell &element, const Cell &ancestor, const LocalDOFVector &u_coarse)
Definition: adaptivity.hh:446
TransferMap::mapped_type LocalDOFVector
Definition: adaptivity.hh:216
void setTimeStepIncreaseFactor(double s)
Definition: adaptivity.hh:1050
void setMinEnergyRate(double s)
Definition: adaptivity.hh:1070
Cell::Geometry Geometry
Definition: adaptivity.hh:212
Geometry _fine_geometry
Definition: adaptivity.hh:418
Projection::MassMatrices MassMatrices
Definition: adaptivity.hh:220
LocalDOFVector _u_fine
Definition: adaptivity.hh:370
void update()
Definition: lfsindexcache.hh:300
TransferMap & _transfer_map
Definition: adaptivity.hh:365
bool acceptTimeStep() const
Definition: adaptivity.hh:1105
DOFVector::ElementType RF
Definition: adaptivity.hh:388
Definition: adaptivity.hh:395
LocalFunctionSpace< GFS > LFS
Definition: adaptivity.hh:205
double endT() const
Definition: adaptivity.hh:1135
std::size_t size_type
Definition: adaptivity.hh:392
unordered_map< ID, std::vector< typename U::ElementType > > MapType
Definition: adaptivity.hh:531
GFS::Traits::GridView::template Codim< 0 >::Entity Cell
Definition: adaptivity.hh:210
double newDT() const
Definition: adaptivity.hh:1120
Dune::PDELab::LeafOffsetCache< GFS > LeafOffsetCache
Definition: adaptivity.hh:384
void error_distribution(const T &x, int bins)
Definition: adaptivity.hh:838
std::vector< LeafOffsets > _leaf_offset_cache
Definition: adaptivity.hh:69
double accumulatedErrorSquared() const
Definition: adaptivity.hh:1140
LeafOffsetCache(const GFS &gfs)
Definition: adaptivity.hh:63
LFSIndexCache< LFS > LFSCache
Definition: adaptivity.hh:206
Definition: adaptivity.hh:377
static const int dim
Definition: adaptivity.hh:82
MassMatrices & _mass_matrices
Definition: adaptivity.hh:128
void backupData(Grid &grid, GFSU &gfsu, Projection &projection, U &u, MapType &transfer_map)
Definition: adaptivity.hh:549
size_type _int_order
Definition: adaptivity.hh:368
GFS::Traits::GridView::template Codim< 0 >::EntityPointer CellPointer
Definition: adaptivity.hh:211
const std::size_t offset
Definition: localfunctionspace.hh:74
replay_visitor(const GFS &gfs, DOFVector &u, CountVector &uc, LeafOffsetCache &leaf_offset_cache)
Definition: adaptivity.hh:479
void evaluate(const X &x, Y &y) const
Definition: adaptivity.hh:399
Iterator extract_lfs_leaf_sizes(const LFS &lfs, Iterator it)
Definition: lfsindexcache.hh:165
Definition: adaptivity.hh:998
const MassMatrices & inverseMassMatrices(const Element &e)
Calculate the inverse local mass matrix, used in the local L2 projection.
Definition: adaptivity.hh:172
const LocalDOFVector * _u_coarse
Definition: adaptivity.hh:496
DOFVector::ElementType RF
Definition: adaptivity.hh:215
Dune::PDELab::LeafOffsetCache< GFS > LeafOffsetCache
Definition: adaptivity.hh:207
array< MassMatrix, TypeTree::TreeInfo< GFS >::leafCount > MassMatrices
Definition: adaptivity.hh:155
DOFVector::template ConstLocalView< LFSCache > _u_view
Definition: adaptivity.hh:364
Cell::Geometry Geometry
Definition: adaptivity.hh:387
std::size_t size_type
Definition: adaptivity.hh:223
double qs() const
Definition: adaptivity.hh:1125
DynamicMatrix< typename U::ElementType > MassMatrix
Definition: adaptivity.hh:154
std::vector< typename CountVector::ElementType > LocalCountVector
Definition: adaptivity.hh:390
backup_visitor(const GFS &gfs, Projection &projection, const DOFVector &u, LeafOffsetCache &leaf_offset_cache, TransferMap &transfer_map, std::size_t int_order=2)
Definition: adaptivity.hh:336
LeafOffsetCache & _leaf_offset_cache
Definition: adaptivity.hh:367
void startTimeStep()
Definition: adaptivity.hh:1146
Projection & _projection
Definition: adaptivity.hh:363
Definition: adaptivity.hh:200
void leaf(const LeafLFS &leaf_lfs, TreePath treePath)
Definition: adaptivity.hh:427
GFS::Traits::GridView::Grid::LocalIdSet IDSet
Definition: adaptivity.hh:209
Definition: adaptivity.hh:145
void adapt_grid(Grid &grid, GFS &gfs, X &x1, int int_order)
adapt a grid, corresponding function space and solution vectors
Definition: adaptivity.hh:632
LocalFunctionSpace< GFS > LFS
Definition: adaptivity.hh:35
Definition: genericdatahandle.hh:623
std::vector< typename FiniteElement::Traits::LocalBasisType::Traits::RangeType > _phi
Definition: adaptivity.hh:420
LocalDOFVector * _u_coarse
Definition: adaptivity.hh:366
void setAdaptationOn()
Definition: adaptivity.hh:1095
Traits::IndexContainer::size_type size() const
get current size
Definition: localfunctionspace.hh:206
void update(const Cell &e)
Definition: adaptivity.hh:49
void evaluate_estimators(GM &grid, double time, double dt, const X &eta_space, const X &eta_time, double energy_timeslab)
Definition: adaptivity.hh:1153
void leaf(const LFSLeaf &leaf_lfs, TreePath treePath)
Definition: adaptivity.hh:227
LFSIndexCache< LFS > LFSCache
Definition: adaptivity.hh:383
BackendVectorSelectorHelper< Backend, GridFunctionSpace, FieldType >::Type Type
Definition: backendselector.hh:14
GFS::Traits::GridView::template Codim< 0 >::Entity Cell
Definition: adaptivity.hh:34
LFS _lfs
Definition: adaptivity.hh:68
const FiniteElement & _finite_element
Definition: adaptivity.hh:416
size_type _leaf_index
Definition: adaptivity.hh:130
const Cell * _current
Definition: adaptivity.hh:362
const LeafOffsets & operator[](GeometryType gt) const
Definition: adaptivity.hh:41
Definition: unordered_map.hh:46
LFSCache _lfs_cache
Definition: adaptivity.hh:491
std::vector< RF > LocalDOFVector
Definition: adaptivity.hh:389
CountVector::template LocalView< LFSCache > _uc_view
Definition: adaptivity.hh:495
const F & f
Definition: common/constraints.hh:145
void setBalanceLimit(double s)
Definition: adaptivity.hh:1080
void setCoarsenFractionWhileRefinement(double s)
Definition: adaptivity.hh:1060
const GFS & gridFunctionSpace() const
Returns the GridFunctionSpace underlying this LocalFunctionSpace.
Definition: localfunctionspace.hh:264
void setRefineFractionWhileRefinement(double s)
Definition: adaptivity.hh:1055
static const int dim
Definition: adaptivity.hh:213
LFS _lfs
Definition: adaptivity.hh:490
size_type _leaf_index
Definition: adaptivity.hh:498
Cell::HierarchicIterator HierarchicIterator
Definition: adaptivity.hh:214
array< std::size_t, TypeTree::TreeInfo< GFS >::leafCount+1 > LeafOffsets
Definition: adaptivity.hh:39
void setOptimisticFactor(double s)
Definition: adaptivity.hh:1090
coarse_function(const FiniteElement &finite_element, Geometry coarse_geometry, Geometry fine_geometry, const LocalDOFVector &dofs, size_type offset)
Definition: adaptivity.hh:408
bool adaptGrid() const
Definition: adaptivity.hh:1115
size_type _leaf_index
Definition: adaptivity.hh:369
const Cell & _element
Definition: adaptivity.hh:127
void replayData(Grid &grid, GFSU &gfsu, Projection &projection, U &u, const MapType &transfer_map)
Definition: adaptivity.hh:569
void error_fraction(const T &x, typename T::ElementType alpha, typename T::ElementType beta, typename T::ElementType &eta_alpha, typename T::ElementType &eta_beta, int verbose=0)
Definition: adaptivity.hh:728
LeafOffsetCache & _leaf_offset_cache
Definition: adaptivity.hh:497
LocalFunctionSpace< GFS > LFS
Definition: adaptivity.hh:382
void setAdaptationOff()
Definition: adaptivity.hh:1100
void setCoarsenLimit(double s)
Definition: adaptivity.hh:1075
LocalDOFVector _u_tmp
Definition: adaptivity.hh:500
void mark_grid(Grid &grid, const X &x, typename X::ElementType refine_threshold, typename X::ElementType coarsen_threshold, int min_level=0, int max_level=std::numeric_limits< int >::max(), int verbose=0)
Definition: adaptivity.hh:900
Geometry _coarse_geometry
Definition: adaptivity.hh:417
void operator()(const Cell &element)
Definition: adaptivity.hh:277
L2Projection(const GFS &gfs, int intorder=2)
The constructor.
Definition: adaptivity.hh:161
L2Projection< typename LFS::Traits::GridFunctionSpace, DOFVector > Projection
Definition: adaptivity.hh:219
const Cell * _element
Definition: adaptivity.hh:492
GFS::Traits::GridView::ctype DF
Definition: adaptivity.hh:224
void setCoarsenFractionWhileCoarsening(double s)
Definition: adaptivity.hh:1065
Base class for all PDELab exceptions.
Definition: exceptions.hh:17
LFS _lfs
Definition: adaptivity.hh:357
Class for automatic adaptation of the grid.
Definition: adaptivity.hh:520
const E & e
Definition: interpolate.hh:172
void element_fraction(const T &x, typename T::ElementType alpha, typename T::ElementType beta, typename T::ElementType &eta_alpha, typename T::ElementType &eta_beta, int verbose=0)
Definition: adaptivity.hh:783
GridAdaptor(const GFSU &gfs)
The constructor.
Definition: adaptivity.hh:540
void setTimeStepDecreaseFactor(double s)
Definition: adaptivity.hh:1045
Projection::MassMatrix MassMatrix
Definition: adaptivity.hh:221
size_type size() const
Definition: lfsindexcache.hh:423
void mark_grid_for_coarsening(Grid &grid, const X &x, typename X::ElementType refine_threshold, typename X::ElementType coarsen_threshold, int verbose=0)
Definition: adaptivity.hh:951
LFS::Traits::GridFunctionSpace::Traits::GridView::template Codim< 0 >::Entity Cell
Definition: adaptivity.hh:386
bool adaptDT() const
Definition: adaptivity.hh:1110
Definition: adaptivity.hh:31
const std::string s
Definition: function.hh:1103
const QuadratureRule< DF, dim > & _quadrature_rule
Definition: adaptivity.hh:129