/usr/include/dune/istl/paamg/parameters.hh is in libdune-istl-dev 2.2.1-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 | #ifndef DUNE_AMG_PARAMETERS_HH
#define DUNE_AMG_PARAMETERS_HH
#include<cstddef>
namespace Dune
{
namespace Amg
{
/**
* @addtogroup ISTL_PAAMG
*
* @{
*/
/** @file
* @author Markus Blatt
* @brief Parameter classes for customizing AMG
*
* All parameters of the AMG can be set by using the class Parameter, which
* can be provided to CoarsenCriterion via its constructor.
*/
/**
* @brief Parameters needed to check whether a node depends on another.
*/
class DependencyParameters
{
public:
/** @brief Constructor */
DependencyParameters()
: alpha_(1.0/3.0), beta_(1.0E-5)
{}
/**
* @brief Set threshold for marking nodes as isolated.
* The default value is 1.0E-5.
*/
void setBeta(double b)
{
beta_ = b;
}
/**
* @brief Get the threshold for marking nodes as isolated.
* The default value is 1.0E-5.
* @return beta
*/
double beta() const
{
return beta_;
}
/**
* @brief Set the scaling value for marking connections as strong.
* Default value is 1/3
*/
void setAlpha(double a)
{
alpha_ = a;
}
/**
* @brief Get the scaling value for marking connections as strong.
* Default value is 1/3
*/
double alpha() const
{
return alpha_;
}
private:
double alpha_, beta_;
};
/**
* @brief Parameters needed for the aggregation process,
*/
class AggregationParameters :
public DependencyParameters
{
public:
/**
* @brief Constructor.
*
* The paramters will be initialized with default values suitable
* for 2D isotropic problems.
*
* If that does not fit your needs either use setDefaultValuesIsotropic
* setDefaultValuesAnisotropic or setup the values by hand
*/
AggregationParameters()
: maxDistance_(2), minAggregateSize_(4), maxAggregateSize_(6),
connectivity_(15), skipiso_(false)
{}
/**
* @brief Sets reasonable default values for an isotropic problem.
*
* Reasonable means that we should end up with cube aggregates of
* diameter 2.
*
* @param dim The dimension of the problem.
* @param diameter The preferred diameter for the aggregation.
*/
void setDefaultValuesIsotropic(std::size_t dim, std::size_t diameter=2)
{
maxDistance_=diameter-1;
std::size_t csize=1;
for(;dim>0;dim--){
csize*=diameter;
maxDistance_+=diameter-1;
}
minAggregateSize_=csize;
maxAggregateSize_=static_cast<std::size_t>(csize*1.5);
}
/**
* @brief Sets reasonable default values for an aisotropic problem.
*
* Reasonable means that we should end up with cube aggregates with
* sides of diameter 2 and sides in one dimension that are longer
* (e.g. for 3D: 2x2x3).
*
* @param dim The dimension of the problem.
* @param diameter The preferred diameter for the aggregation.
*/
void setDefaultValuesAnisotropic(std::size_t dim,std::size_t diameter=2)
{
setDefaultValuesIsotropic(dim, diameter);
maxDistance_+=dim-1;
}
/**
* @brief Get the maximal distance allowed between to nodes in a aggregate.
*
* The distance between two nodes in a aggregate is the minimal number of edges
* it takes to travel from one node to the other without leaving the aggregate.
* @return The maximum distance allowed.
*/
std::size_t maxDistance() const { return maxDistance_;}
/**
* @brief Set the maximal distance allowed between to nodes in a aggregate.
*
* The distance between two nodes in a aggregate is the minimal number of edges
* it takes to travel from one node to the other without leaving the aggregate.
* The default value is 2.
* @param distance The maximum distance allowed.
*/
void setMaxDistance(std::size_t distance) { maxDistance_ = distance;}
/**
* @brief Whether isolated aggregates will not be represented on
* the coarse level.
* @return True if these aggregates will be skipped.
*/
bool skipIsolated() const
{
return skipiso_;
}
/**
* @brief Set whether isolated aggregates will not be represented on
* the coarse level.
* @param skip True if these aggregates will be skipped.
*/
void setSkipIsolated(bool skip)
{
skipiso_=skip;
}
/**
* @brief Get the minimum number of nodes a aggregate has to consist of.
* @return The minimum number of nodes.
*/
std::size_t minAggregateSize() const { return minAggregateSize_;}
/**
* @brief Set the minimum number of nodes a aggregate has to consist of.
*
* the default value is 4.
* @return The minimum number of nodes.
*/
void setMinAggregateSize(std::size_t size){ minAggregateSize_=size;}
/**
* @brief Get the maximum number of nodes a aggregate is allowed to have.
* @return The maximum number of nodes.
*/
std::size_t maxAggregateSize() const{ return maxAggregateSize_;}
/**
* @brief Set the maximum number of nodes a aggregate is allowed to have.
*
* The default values is 6.
* @param size The maximum number of nodes.
*/
void setMaxAggregateSize(std::size_t size){ maxAggregateSize_ = size;}
/**
* @brief Get the maximum number of connections a aggregate is allowed to have.
*
* This limit exists to achieve sparsity of the coarse matrix. the default value is 15.
*
* @return The maximum number of connections a aggregate is allowed to have.
*/
std::size_t maxConnectivity() const{ return connectivity_;}
/**
* @brief Set the maximum number of connections a aggregate is allowed to have.
*
* This limit exists to achieve sparsity of the coarse matrix. the default value is 15.
*
* @param connectivity The maximum number of connections a aggregate is allowed to have.
*/
void setMaxConnectivity(std::size_t connectivity){ connectivity_ = connectivity;}
private:
std::size_t maxDistance_, minAggregateSize_, maxAggregateSize_, connectivity_;
bool skipiso_;
};
/**
* @brief Identifiers for the different accumulation modes.
*/
enum AccumulationMode{
/**
* @brief No data accumulution.
*
* The coarse level data will be distributed to all processes.
*/
noAccu = 0,
/**
* @brief Accumulate data to on process at once
*
* Once no further coarsening is possible all data will be accumulated to one process
*/
atOnceAccu=1,
/**
* @brief Successively accumulate to fewer processes.
*/
successiveAccu=2
};
/**
* @brief Parameters for the complete coarsening process.
*/
class CoarseningParameters : public AggregationParameters
{
public:
/**
* @brief Set the maximum number of levels allowed in the hierarchy.
*/
void setMaxLevel(int l)
{
maxLevel_ = l;
}
/**
* @brief Get the maximum number of levels allowed in the hierarchy.
*/
int maxLevel() const
{
return maxLevel_;
}
/**
* @brief Set the maximum number of unknowns allowed on the coarsest level.
*/
void setCoarsenTarget(int nodes)
{
coarsenTarget_ = nodes;
}
/**
* @brief Get the maximum number of unknowns allowed on the coarsest level.
*/
int coarsenTarget() const
{
return coarsenTarget_;
}
/**
* @brief Set the minimum coarsening rate to be achieved in each coarsening.
*
* The default value is 1.2
*/
void setMinCoarsenRate(double rate)
{
minCoarsenRate_ = rate;
}
/**
* @brief Get the minimum coarsening rate to be achieved.
*/
double minCoarsenRate() const
{
return minCoarsenRate_;
}
/**
* @brief Whether the data should be accumulated on fewer processes on coarser levels.
*/
AccumulationMode accumulate() const
{
return accumulate_;
}
/**
* @brief Set whether he data should be accumulated on fewer processes on coarser levels.
*/
void setAccumulate(AccumulationMode accu)
{
accumulate_=accu;
}
void setAccumulate(bool accu){
accumulate_=accu?successiveAccu:noAccu;
}
/**
* @brief Set the damping factor for the prolongation.
*
* @param d The new damping factor.
*/
void setProlongationDampingFactor(double d)
{
dampingFactor_ = d;
}
/**
* @brief Get the damping factor for the prolongation.
*
* @return d The damping factor.
*/
double getProlongationDampingFactor() const
{
return dampingFactor_;
}
/**
* @brief Constructor
* @param maxLevel The maximum number of levels allowed in the matrix hierarchy (default: 100).
* @param coarsenTarget If the number of nodes in the matrix is below this threshold the
* coarsening will stop (default: 1000).
* @param minCoarsenRate If the coarsening rate falls below this threshold the
* coarsening will stop (default: 1.2)
* @param prolongDamp The damping factor to apply to the prolongated update (default: 1.6)
* @param accumulate Whether to accumulate the data onto fewer processors on coarser levels.
*/
CoarseningParameters(int maxLevel=100, int coarsenTarget=1000, double minCoarsenRate=1.2,
double prolongDamp=1.6, AccumulationMode accumulate=successiveAccu)
: maxLevel_(maxLevel), coarsenTarget_(coarsenTarget), minCoarsenRate_(minCoarsenRate),
dampingFactor_(prolongDamp), accumulate_( accumulate)
{}
private:
/**
* @brief The maximum number of levels allowed in the hierarchy.
*/
int maxLevel_;
/**
* @brief The maximum number of unknowns allowed on the coarsest level.
*/
int coarsenTarget_;
/**
* @brief The minimum coarsening rate to be achieved.
*/
double minCoarsenRate_;
/**
* @brief The damping factor to apply to the prologated correction.
*/
double dampingFactor_;
/**
* @brief Whether the data should be agglomerated to fewer processor on
* coarser levels.
*/
AccumulationMode accumulate_;
};
/**
* @brief All parameters for AMG.
*
* Instances of this class can be provided to CoarsenCriterion via its
* constructor.
*/
class Parameters : public CoarseningParameters
{
public:
/**
* @brief Set the debugging level.
*
* @param level If 0 no debugging output will be generated.
* @warning In parallel the level has to be consistent over all procceses.
*/
void setDebugLevel(int level)
{
debugLevel_ = level;
}
/**
* @brief Get the debugging Level.
*
* @return 0 if no debugging output will be generated.
*/
int debugLevel() const
{
return debugLevel_;
}
/**
* @brief Set the number of presmoothing steps to apply
* @param steps The number of steps:
*/
void setNoPreSmoothSteps(std::size_t steps)
{
preSmoothSteps_=steps;
}
/**
* @brief Get the number of presmoothing steps to apply
* @return The number of steps:
*/
std::size_t getNoPreSmoothSteps() const
{
return preSmoothSteps_;
}
/**
* @brief Set the number of postsmoothing steps to apply
* @param steps The number of steps:
*/
void setNoPostSmoothSteps(std::size_t steps)
{
postSmoothSteps_=steps;
}
/**
* @brief Get the number of postsmoothing steps to apply
* @return The number of steps:
*/
std::size_t getNoPostSmoothSteps() const
{
return postSmoothSteps_;
}
/**
* @brief Set the value of gamma; 1 for V-cycle, 2 for W-cycle
*/
void setGamma(std::size_t gamma)
{
gamma_=gamma;
}
/**
* @brief Get the value of gamma; 1 for V-cycle, 2 for W-cycle
*/
std::size_t getGamma() const
{
return gamma_;
}
/**
* @brief Set whether to use additive multigrid.
* @param additive True if multigrid should be additive.
*/
void setAdditive(bool additive)
{
additive_=additive;
}
/**
* @brief Get whether to use additive multigrid.
* @return True if multigrid should be additive.
*/
bool getAdditive() const
{
return additive_;
}
/**
* @brief Constructor
* @param maxLevel The maximum number of levels allowed in the matrix hierarchy (default: 100).
* @param coarsenTarget If the number of nodes in the matrix is below this threshold the
* coarsening will stop (default: 1000).
* @param minCoarsenRate If the coarsening rate falls below this threshold the
* coarsening will stop (default: 1.2)
* @param prolongDamp The damping factor to apply to the prolongated update (default: 1.6)
* @param accumulate Whether to accumulate the data onto fewer processors on coarser levels.
*/
Parameters(int maxLevel=100, int coarsenTarget=1000, double minCoarsenRate=1.2,
double prolongDamp=1.6, AccumulationMode accumulate=successiveAccu)
: CoarseningParameters(maxLevel, coarsenTarget, minCoarsenRate, prolongDamp, accumulate)
, debugLevel_(2), preSmoothSteps_(2), postSmoothSteps_(2), gamma_(1),
additive_(false)
{}
private:
int debugLevel_;
std::size_t preSmoothSteps_;
std::size_t postSmoothSteps_;
std::size_t gamma_;
bool additive_;
};
}//namespace AMG
}//namespace Dune
#endif
|