dune-istl
2.2.0
|
00001 #ifndef DUNE_AMG_PARAMETERS_HH 00002 #define DUNE_AMG_PARAMETERS_HH 00003 00004 #include<cstddef> 00005 00006 namespace Dune 00007 { 00008 namespace Amg 00009 { 00026 class DependencyParameters 00027 { 00028 public: 00030 DependencyParameters() 00031 : alpha_(1.0/3.0), beta_(1.0E-5) 00032 {} 00033 00038 void setBeta(double b) 00039 { 00040 beta_ = b; 00041 } 00042 00048 double beta() const 00049 { 00050 return beta_; 00051 } 00052 00057 void setAlpha(double a) 00058 { 00059 alpha_ = a; 00060 } 00061 00066 double alpha() const 00067 { 00068 return alpha_; 00069 } 00070 00071 private: 00072 double alpha_, beta_; 00073 }; 00074 00078 class AggregationParameters : 00079 public DependencyParameters 00080 { 00081 public: 00091 AggregationParameters() 00092 : maxDistance_(2), minAggregateSize_(4), maxAggregateSize_(6), 00093 connectivity_(15), skipiso_(false) 00094 {} 00095 00105 void setDefaultValuesIsotropic(std::size_t dim, std::size_t diameter=2) 00106 { 00107 maxDistance_=diameter-1; 00108 std::size_t csize=1; 00109 00110 for(;dim>0;dim--){ 00111 csize*=diameter; 00112 maxDistance_+=diameter-1; 00113 } 00114 minAggregateSize_=csize; 00115 maxAggregateSize_=static_cast<std::size_t>(csize*1.5); 00116 } 00117 00128 void setDefaultValuesAnisotropic(std::size_t dim,std::size_t diameter=2) 00129 { 00130 setDefaultValuesIsotropic(dim, diameter); 00131 maxDistance_+=dim-1; 00132 } 00140 std::size_t maxDistance() const { return maxDistance_;} 00141 00150 void setMaxDistance(std::size_t distance) { maxDistance_ = distance;} 00151 00157 bool skipIsolated() const 00158 { 00159 return skipiso_; 00160 } 00161 00167 void setSkipIsolated(bool skip) 00168 { 00169 skipiso_=skip; 00170 } 00171 00176 std::size_t minAggregateSize() const { return minAggregateSize_;} 00177 00184 void setMinAggregateSize(std::size_t size){ minAggregateSize_=size;} 00185 00190 std::size_t maxAggregateSize() const{ return maxAggregateSize_;} 00191 00198 void setMaxAggregateSize(std::size_t size){ maxAggregateSize_ = size;} 00199 00207 std::size_t maxConnectivity() const{ return connectivity_;} 00208 00216 void setMaxConnectivity(std::size_t connectivity){ connectivity_ = connectivity;} 00217 00218 private: 00219 std::size_t maxDistance_, minAggregateSize_, maxAggregateSize_, connectivity_; 00220 bool skipiso_; 00221 00222 }; 00223 00224 00228 enum AccumulationMode{ 00234 noAccu = 0, 00240 atOnceAccu=1, 00244 successiveAccu=2 00245 }; 00246 00247 00248 00249 00253 class CoarseningParameters : public AggregationParameters 00254 { 00255 public: 00259 void setMaxLevel(int l) 00260 { 00261 maxLevel_ = l; 00262 } 00266 int maxLevel() const 00267 { 00268 return maxLevel_; 00269 } 00270 00274 void setCoarsenTarget(int nodes) 00275 { 00276 coarsenTarget_ = nodes; 00277 } 00278 00282 int coarsenTarget() const 00283 { 00284 return coarsenTarget_; 00285 } 00286 00292 void setMinCoarsenRate(double rate) 00293 { 00294 minCoarsenRate_ = rate; 00295 } 00296 00300 double minCoarsenRate() const 00301 { 00302 return minCoarsenRate_; 00303 } 00304 00308 AccumulationMode accumulate() const 00309 { 00310 return accumulate_; 00311 } 00315 void setAccumulate(AccumulationMode accu) 00316 { 00317 accumulate_=accu; 00318 } 00319 00320 void setAccumulate(bool accu){ 00321 accumulate_=accu?successiveAccu:noAccu; 00322 } 00328 void setProlongationDampingFactor(double d) 00329 { 00330 dampingFactor_ = d; 00331 } 00332 00338 double getProlongationDampingFactor() const 00339 { 00340 return dampingFactor_; 00341 } 00352 CoarseningParameters(int maxLevel=100, int coarsenTarget=1000, double minCoarsenRate=1.2, 00353 double prolongDamp=1.6, AccumulationMode accumulate=successiveAccu) 00354 : maxLevel_(maxLevel), coarsenTarget_(coarsenTarget), minCoarsenRate_(minCoarsenRate), 00355 dampingFactor_(prolongDamp), accumulate_( accumulate) 00356 {} 00357 00358 private: 00362 int maxLevel_; 00366 int coarsenTarget_; 00370 double minCoarsenRate_; 00374 double dampingFactor_; 00379 AccumulationMode accumulate_; 00380 }; 00381 00388 class Parameters : public CoarseningParameters 00389 { 00390 public: 00397 void setDebugLevel(int level) 00398 { 00399 debugLevel_ = level; 00400 } 00401 00407 int debugLevel() const 00408 { 00409 return debugLevel_; 00410 } 00411 00416 void setNoPreSmoothSteps(std::size_t steps) 00417 { 00418 preSmoothSteps_=steps; 00419 } 00424 std::size_t getNoPreSmoothSteps() const 00425 { 00426 return preSmoothSteps_; 00427 } 00428 00433 void setNoPostSmoothSteps(std::size_t steps) 00434 { 00435 postSmoothSteps_=steps; 00436 } 00441 std::size_t getNoPostSmoothSteps() const 00442 { 00443 return postSmoothSteps_; 00444 } 00445 00449 void setGamma(std::size_t gamma) 00450 { 00451 gamma_=gamma; 00452 } 00456 std::size_t getGamma() const 00457 { 00458 return gamma_; 00459 } 00460 00465 void setAdditive(bool additive) 00466 { 00467 additive_=additive; 00468 } 00469 00474 bool getAdditive() const 00475 { 00476 return additive_; 00477 } 00478 00489 Parameters(int maxLevel=100, int coarsenTarget=1000, double minCoarsenRate=1.2, 00490 double prolongDamp=1.6, AccumulationMode accumulate=successiveAccu) 00491 : CoarseningParameters(maxLevel, coarsenTarget, minCoarsenRate, prolongDamp, accumulate) 00492 , debugLevel_(2), preSmoothSteps_(2), postSmoothSteps_(2), gamma_(1), 00493 additive_(false) 00494 {} 00495 private: 00496 int debugLevel_; 00497 std::size_t preSmoothSteps_; 00498 std::size_t postSmoothSteps_; 00499 std::size_t gamma_; 00500 bool additive_; 00501 }; 00502 00503 }//namespace AMG 00504 00505 }//namespace Dune 00506 #endif