Example #1
0
 static public ISolverSmootherTemplate InitMultigridChain(MultigridOperator MgOp,
                                                          Func <int, ISolverSmootherTemplate> PreSmootherFactory,
                                                          Func <int, ISolverSmootherTemplate> PostSmootherFactory,
                                                          Action <int, ClassicMultigrid> ParamsSeter,
                                                          Func <ISolverSmootherTemplate> CoarsestSolverFactory) //
 {
     if (MgOp.CoarserLevel == null)
     {
         return(CoarsestSolverFactory());
     }
     else
     {
         var MgTop = new ClassicMultigrid();
         ParamsSeter(MgOp.LevelIndex, MgTop);
         MgTop.PreSmoother        = PreSmootherFactory(MgOp.LevelIndex);
         MgTop.PostSmoother       = PostSmootherFactory(MgOp.LevelIndex);
         MgTop.CoarserLevelSolver = InitMultigridChain(MgOp.CoarserLevel, PreSmootherFactory, PostSmootherFactory, ParamsSeter, CoarsestSolverFactory);
         return(MgTop);
     }
 }
Example #2
0
 static public ISolverSmootherTemplate InitMultigridChain(IEnumerable <AggregationGridData> MultigridSequence,
                                                          Func <int, ISolverSmootherTemplate> PreSmootherFactory,
                                                          Func <int, ISolverSmootherTemplate> PostSmootherFactory,
                                                          Action <int, ClassicMultigrid> ParamsSeter,
                                                          Func <ISolverSmootherTemplate> CoarsestSolverFactory,
                                                          int iLevel = 0) //
 {
     if (iLevel == MultigridSequence.Count() - 1)
     {
         return(CoarsestSolverFactory());
     }
     else
     {
         var MgTop = new ClassicMultigrid();
         ParamsSeter(iLevel, MgTop);
         MgTop.PreSmoother        = PreSmootherFactory(iLevel);
         MgTop.PostSmoother       = PostSmootherFactory(iLevel);
         MgTop.CoarserLevelSolver = InitMultigridChain(MultigridSequence, PreSmootherFactory, PostSmootherFactory, ParamsSeter, CoarsestSolverFactory, iLevel + 1);
         return(MgTop);
     }
 }