33 #ifndef __H__UG__LIB_DISC__MULTI_GRID_SOLVER__MG_SOLVER__
34 #define __H__UG__LIB_DISC__MULTI_GRID_SOLVER__MG_SOLVER__
81 template <
typename TDomain,
typename TAlgebra>
162 else {
UG_THROW(
"GMG::set_cycle_type: option '"<<type<<
"' not supported.");}
219 virtual const char*
name()
const {
return "Geometric MultiGrid";}
273 void lmgc(
int lev,
int cycleType);
341 static const int _F_ = -1;
402 template <
typename TElem>
487 template <
typename TElem>
497 const std::vector<size_t>& vMapPatchToGlobal);
502 const std::vector<size_t>& vMapPatchToGlobal);
507 const std::vector<size_t>& vMapPatchToGlobal);
551 const GF& rTo,
const GF& rFrom);
Definition: smart_pointer.h:108
Performs communication between interfaces on different processes.
Definition: pcl_interface_communicator.h:68
base class for approximation spaces without type of algebra or dof distribution
Definition: approximation_space.h:279
geometric multi grid preconditioner
Definition: mg_solver.h:84
std::vector< SmartPtr< ITransferPostProcess< TDomain, TAlgebra > > > m_vspProlongationPostProcess
prototpe for transfer post process
Definition: mg_solver.h:383
void init_transfer()
initializes the transfers
Definition: mg_solver_impl.hpp:1078
static const int _W_
operator to invert (surface grid)
Definition: mg_solver.h:340
void write_debug(ConstSmartPtr< GF > spGF, std::string name, int cycleNo=-1)
writes debug output for a level vector only on smooth path
Definition: mg_solver_impl.hpp:2144
void leave_debug_writer_section(GridLevel &orig_gl)
leaves the current debugger section
Definition: mg_solver_impl.hpp:2224
int m_cycleType
cylce type (1 = V-cycle, 2 = W-cylcle, ...)
Definition: mg_solver.h:338
SmartPtr< ILinearIterator< vector_type > > m_spPreSmootherPrototype
prototype for pre-smoother
Definition: mg_solver.h:368
static const int _F_
operator to invert (surface grid)
Definition: mg_solver.h:341
SmartPtr< MatrixOperator< matrix_type, vector_type > > spGatheredBaseMat
Matrix for gathered base solver.
Definition: mg_solver.h:474
bool m_bUseRAP
using RAP-Product (assemble coarse-grid matrices otherwise)
Definition: mg_solver.h:356
void set_rap(bool bRAP)
sets if RAP - Product used to build coarse grid matrices
Definition: mg_solver.h:149
void set_transfer(SmartPtr< ITransferOperator< TDomain, TAlgebra > > P)
sets the transfer operator
Definition: mg_solver.h:187
bool gathered_base_master() const
returns if gathered base master
Definition: mg_solver_impl.hpp:1667
SmartPtr< ApproximationSpace< TDomain > > m_spApproxSpace
approximation space for level and surface grid
Definition: mg_solver.h:327
GF * m_pC
current surface correction
Definition: mg_solver.h:483
void clear_transfer_post_process()
clears all transfer post process
Definition: mg_solver.h:203
void base_solve(int lev)
compute base solver
Definition: mg_solver_impl.hpp:1969
void init_rap_rim_cpl()
operator to invert (surface grid)
Definition: mg_solver_impl.hpp:1017
GridFunction< TDomain, TAlgebra > GF
Grid Function type.
Definition: mg_solver.h:99
void assemble_level_operator()
initializes the coarse grid matrices
Definition: mg_solver_impl.hpp:528
bool m_bSmoothOnSurfaceRim
flag if smoothing on surface rim
Definition: mg_solver.h:359
void set_cycle_type(int type)
sets the cycle type (1 = V-cycle, 2 = W-cycle, ...)
Definition: mg_solver.h:155
void set_surface_level(int topLevel)
sets the surface level (default is top-surface)
Definition: mg_solver.h:133
algebra_type::vector_type vector_type
Vector type.
Definition: mg_solver.h:93
MGStats< TDomain, TAlgebra > mg_stats_type
MGStats type.
Definition: mg_solver.h:102
void set_num_postsmooth(int num)
sets the number of post-smoothing steps to be performed
Definition: mg_solver.h:172
SmartPtr< ILinearIterator< vector_type > > m_spPostSmootherPrototype
prototype for post-smoother
Definition: mg_solver.h:371
void set_restriction(SmartPtr< ITransferOperator< TDomain, TAlgebra > > P)
sets the restriction operator
Definition: mg_solver.h:195
void set_approximation_space(SmartPtr< ApproximationSpace< TDomain > > approxSpace)
sets the approximation space
Definition: mg_solver_impl.hpp:128
void set_smooth_on_surface_rim(bool bSmooth)
sets if smoothing is performed on surface rim
Definition: mg_solver.h:152
virtual std::string config_string() const
returns information about configuration parameters
Definition: mg_solver_impl.hpp:2306
bool m_ignoreInitForBaseSolver
flag indicating whether the base-solver shall be initialized during a call to init()
Definition: mg_solver.h:468
SmartPtr< mg_stats_type > m_mgstats
MGStats are used for debugging to record statistics on individual iterations.
Definition: mg_solver.h:573
int m_dbgIterCnt
counter for debug, to distinguish the iterations
Definition: mg_solver.h:570
void set_base_solver(SmartPtr< ILinearOperatorInverse< vector_type > > baseSolver)
sets the base solver that is used
Definition: mg_solver.h:136
void set_base_level(int baseLevel)
sets the level where exact solving is performed in the mg cycle
Definition: mg_solver.h:130
void init()
initializes common part
Definition: mg_solver_impl.hpp:380
void set_matrix_structure_is_const(bool b)
Definition: mg_solver.h:254
void add_restriction_post_process(SmartPtr< ITransferPostProcess< TDomain, TAlgebra > > PP)
add restriction post process
Definition: mg_solver.h:211
bool m_bMatrixStructureIsConst
flag indicating whether the matrix structure is supposed to stay the same in the next init phase
Definition: mg_solver.h:471
SmartPtr< GF > spGatheredBaseCorr
vector for gathered base solver
Definition: mg_solver.h:477
void init_smoother()
initializes the smoother and base solver
Definition: mg_solver_impl.hpp:1137
void init_rap_operator()
operator to invert (surface grid)
Definition: mg_solver_impl.hpp:830
void init_index_mappings()
operator to invert (surface grid)
Definition: mg_solver_impl.hpp:1234
int m_topLev
Definition: mg_solver.h:331
void init_base_solver()
initializes the smoother and base solver
Definition: mg_solver_impl.hpp:1173
void set_postsmoother(SmartPtr< ILinearIterator< vector_type > > smoother)
sets the post-smoother that is used
Definition: mg_solver.h:183
std::vector< SmartPtr< LevData > > m_vLevData
storage for all level
Definition: mg_solver.h:459
SmartPtr< ITransferOperator< TDomain, TAlgebra > > m_spProjectionPrototype
prototype for projection operator
Definition: mg_solver.h:374
void init_level_memory(int baseLev, int topLev)
allocates the memory
Definition: mg_solver_impl.hpp:1529
virtual const char * name() const
name
Definition: mg_solver.h:219
int m_numPostSmooth
number of Postsmooth steps
Definition: mg_solver.h:347
int m_LocalFullRefLevel
lowest level containing surface geom obj (proc-locally)
Definition: mg_solver.h:350
SmartPtr< ILinearOperatorInverse< vector_type > > m_spBaseSolver
base solver for the coarse problem
Definition: mg_solver.h:387
int m_baseLev
base level (where exact inverse is computed)
Definition: mg_solver.h:335
void set_presmoother(SmartPtr< ILinearIterator< vector_type > > smoother)
sets the pre-smoother that is used
Definition: mg_solver.h:179
void copy_ghost_to_noghost(SmartPtr< GF > spVecTo, ConstSmartPtr< GF > spVecFrom, const std::vector< size_t > &vMapPatchToGlobal)
copies vector to smoothing patch using cached mapping
Definition: mg_solver_impl.hpp:1429
std::vector< SmartPtr< ITransferPostProcess< TDomain, TAlgebra > > > m_vspRestrictionPostProcess
operator to invert (surface grid)
Definition: mg_solver.h:384
virtual bool ignore_init_for_base_solver() const
operator to invert (surface grid)
Definition: mg_solver_impl.hpp:512
void set_debug(SmartPtr< GridFunctionDebugWriter< TDomain, TAlgebra > > spDebugWriter)
set debug output
Definition: mg_solver.h:522
void add_prolongation_post_process(SmartPtr< ITransferPostProcess< TDomain, TAlgebra > > PP)
add prolongation post process
Definition: mg_solver.h:207
int m_surfaceLev
operator to invert (surface grid)
Definition: mg_solver.h:332
void log_debug_data(int lvl, int cycleNo, std::string name)
logs a level-data-struct to the terminal
Definition: mg_solver_impl.hpp:2233
void mg_stats_defect(GF &gf, int lvl, typename mg_stats_type::Stage stage)
Calls MGStats::set_defect (if available) with the given parameters.
Definition: mg_solver_impl.hpp:2297
void set_num_presmooth(int num)
sets the number of pre-smoothing steps to be performed
Definition: mg_solver.h:169
virtual bool apply_update_defect(vector_type &c, vector_type &d)
Compute new correction c = B*d and return new defect d := d - A*c.
Definition: mg_solver_impl.hpp:279
void init_projection()
initializes the prolongation
Definition: mg_solver_impl.hpp:1117
void set_smoother(SmartPtr< ILinearIterator< vector_type > > smoother)
sets the smoother that is used
Definition: mg_solver.h:175
ConstSmartPtr< matrix_type > m_spSurfaceMat
operator to invert (surface grid)
Definition: mg_solver.h:318
~AssembledMultiGridCycle()
Destructor.
Definition: mg_solver_impl.hpp:167
virtual bool supports_parallel() const
returns if parallel solving is supported
Definition: mg_solver.h:222
void set_mg_stats(SmartPtr< mg_stats_type > mgstats)
sets MGStats, an object which records statistics for individual iterations
Definition: mg_solver.h:119
void enter_debug_writer_section(GridLevel &orig_gl, const char *sec_name, int lev, int cycleNo=-1, int callNo=-1)
enters a new debugger section for smoothers, base solver etc
Definition: mg_solver_impl.hpp:2204
TAlgebra algebra_type
Algebra type.
Definition: mg_solver.h:90
void init_noghost_to_ghost_mapping(std::vector< size_t > &vNoGhostToGhostMap, ConstSmartPtr< DoFDistribution > spNoGhostDD, ConstSmartPtr< DoFDistribution > spGhostDD)
Definition: mg_solver_impl.hpp:1374
int m_numPreSmooth
number of Presmooth steps
Definition: mg_solver.h:344
SmartPtr< ITransferOperator< TDomain, TAlgebra > > m_spProlongationPrototype
prototype for prolongation operator
Definition: mg_solver.h:377
SmartPtr< GridFunctionDebugWriter< TDomain, TAlgebra > > m_spDebugWriter
Debug Writer.
Definition: mg_solver.h:567
void set_gathered_base_solver_if_ambiguous(bool bGathered)
sets if the base solver is applied in parallel
Definition: mg_solver.h:140
AssembledMultiGridCycle()
constructor without arguments
Definition: mg_solver_impl.hpp:79
void set_projection(SmartPtr< ITransferOperator< TDomain, TAlgebra > > P)
sets the projection operator
Definition: mg_solver.h:199
algebra_type::matrix_type matrix_type
Matrix type.
Definition: mg_solver.h:96
SmartPtr< ITransferOperator< TDomain, TAlgebra > > m_spRestrictionPrototype
prototype for restriction operator
Definition: mg_solver.h:380
pcl::InterfaceCommunicator< IndexLayout > m_Com
communicator
Definition: mg_solver.h:511
void set_prolongation(SmartPtr< ITransferOperator< TDomain, TAlgebra > > P)
sets the prolongation operator
Definition: mg_solver.h:191
void assemble_rim_cpl(const vector_type *u)
Definition: mg_solver_impl.hpp:756
void presmooth_and_restriction(int lev)
performs presmoothing on the given level
Definition: mg_solver_impl.hpp:1687
SmartPtr< ILinearIterator< vector_type > > clone()
Clone.
Definition: mg_solver_impl.hpp:137
void set_cycle_type(const std::string &type)
sets the cycle type (1 = V-cycle, 2 = W-cycle, ...)
Definition: mg_solver.h:158
bool m_bGatheredBaseIfAmbiguous
flag, if to solve base problem in parallel when gathered and (!) parallel possible
Definition: mg_solver.h:462
void force_reinit()
reinit transfer operators
Definition: mg_solver_impl.hpp:520
SmartPtr< IAssemble< TAlgebra > > m_spAss
assembling routine for coarse grid matrices
Definition: mg_solver.h:324
static const int _V_
operator to invert (surface grid)
Definition: mg_solver.h:339
void set_discretization(SmartPtr< IAssemble< TAlgebra > > spAss)
sets the assembling procedure that is used to compute coarse grid matrices
Definition: mg_solver.h:126
std::vector< LevelIndex > m_vSurfToLevelMap
operator to invert (surface grid)
Definition: mg_solver.h:400
RevisionCounter m_ApproxSpaceRevision
approximation space revision of cached values
Definition: mg_solver.h:365
void prolongation_and_postsmooth(int lev)
performs prolongation to the level above
Definition: mg_solver_impl.hpp:1820
GridLevel::ViewType m_GridLevelType
grid-view for level vectors
Definition: mg_solver.h:353
void lmgc(int lev, int cycleType)
compute correction on level and update defect
Definition: mg_solver_impl.hpp:2091
const vector_type * m_pSurfaceSol
Solution on surface grid.
Definition: mg_solver.h:321
virtual bool apply(vector_type &c, const vector_type &d)
Compute new correction c = B*d.
Definition: mg_solver_impl.hpp:176
void set_comm_comp_overlap(bool bOverlap)
sets if communication and computation should be overlaped
Definition: mg_solver.h:166
void copy_noghost_to_ghost(SmartPtr< GF > spVecTo, ConstSmartPtr< GF > spVecFrom, const std::vector< size_t > &vMapPatchToGlobal)
copies vector from smoothing patch using cached mapping
Definition: mg_solver_impl.hpp:1460
bool m_bCommCompOverlap
flag if overlapping communication and computation
Definition: mg_solver.h:362
TDomain domain_type
Domain.
Definition: mg_solver.h:87
bool m_bGatheredBaseUsed
flag if using parallel base solver
Definition: mg_solver.h:465
void set_emulate_full_refined_grid(bool bEmulate)
sets if copies should be used to emulate a full-refined grid
Definition: mg_solver.h:143
Allows to mark elements.
Definition: bool_marker.h:64
Definition: grid_function_util.h:1021
represents numerical solutions on a grid using an algebraic vector
Definition: grid_function.h:121
Definition: grid_level.h:42
ViewType
type of view
Definition: grid_level.h:48
@ SURFACE
Definition: grid_level.h:48
@ LEVEL
Definition: grid_level.h:48
Interface providing Jacobian and Defect of a discretization.
Definition: assemble_interface.h:110
describes a linear iterator
Definition: linear_iterator.h:81
describes a linear mapping X->Y
Definition: linear_operator.h:80
describes an inverse linear mapping X->Y
Definition: linear_operator_inverse.h:80
interface for transfer routines
Definition: transfer_interface.h:50
interface for transfer routines
Definition: transfer_interface.h:128
Records statistics on how individual parts of a multigrid method worked.
Definition: mg_stats.h:44
Stage
Defines at which stage data is recorded in a given multigrid cycle.
Definition: mg_stats.h:51
Wrapper for sequential matrices to handle them in parallel.
Definition: parallel_matrix.h:65
Class used to identify a state of adaption of a grid, approx-space, ...
Definition: revision_counter.h:56
Represents the surface view of a multi-grid hierarchy.
Definition: surface_view.h:61
#define UG_THROW(msg)
Definition: error.h:57
CPUAlgebra::vector_type vector_type
string TrimString(const string &str)
Definition: string_util.cpp:104
void SelectNonShadowsAdjacentToShadowsOnLevel(BoolMarker &sel, const SurfaceView &surfView, int level)
selects all non-shadows, that are adjacent to a shadow on a grid levels
Definition: mg_solver.cpp:42
Definition: mg_solver.h:418
SmartPtr< ITransferOperator< TDomain, TAlgebra > > Restriction
Definition: mg_solver.h:431
SmartPtr< GF > sc
vectors needed (sx = no-ghosts [for smoothing], t = for transfer)
Definition: mg_solver.h:434
SmartPtr< MatrixOperator< matrix_type, vector_type > > A
Level matrix operator.
Definition: mg_solver.h:420
std::vector< size_t > vSurfShadowing
list of corresponding surface index to shadowing indices
Definition: mg_solver.h:443
SmartPtr< ITransferOperator< TDomain, TAlgebra > > Projection
Projection operator.
Definition: mg_solver.h:427
int n_prolong_calls
Definition: mg_solver.h:455
matrix_type RimCpl_Coarse_Fine
missing coarse grid correction
Definition: mg_solver.h:452
int n_restr_calls
Definition: mg_solver.h:455
SmartPtr< ITransferOperator< TDomain, TAlgebra > > Prolongation
Transfer operator.
Definition: mg_solver.h:430
SmartPtr< ILinearIterator< vector_type > > PostSmoother
Definition: mg_solver.h:424
SmartPtr< ILinearIterator< vector_type > > PreSmoother
Smoother.
Definition: mg_solver.h:423
SmartPtr< GF > t
Definition: mg_solver.h:434
int n_post_calls
Definition: mg_solver.h:455
std::vector< size_t > vShadowing
list of shadowing indices
Definition: mg_solver.h:440
std::vector< SurfLevelMap > vSurfLevelMap
map surface to level
Definition: mg_solver.h:446
matrix_type RimCpl_Fine_Coarse
missing coarse grid correction
Definition: mg_solver.h:449
SmartPtr< GF > sd
Definition: mg_solver.h:434
int n_pre_calls
debugging output information (number of calls of the pre-, postsmoothers, base solver etc)
Definition: mg_solver.h:455
SmartPtr< GF > st
Definition: mg_solver.h:434
int n_base_calls
Definition: mg_solver.h:455
std::vector< size_t > vMapPatchToGlobal
maps global indices (including ghosts) to patch indices (no ghosts included).
Definition: mg_solver.h:437
Definition: mg_solver.h:395
int level
Definition: mg_solver.h:398
LevelIndex()
Definition: mg_solver.h:396
size_t indexLower
Definition: mg_solver.h:397
size_t index
Definition: mg_solver.h:397
int levelLower
Definition: mg_solver.h:398
Definition: mg_solver.h:409
size_t surfIndex
Definition: mg_solver.h:413
SurfLevelMap()
Definition: mg_solver.h:410
SurfLevelMap(size_t levIndex_, size_t surfIndex_)
Definition: mg_solver.h:411
size_t levIndex
Definition: mg_solver.h:413