From 15e975307676179d70044ec04881df7c7ea9fdef Mon Sep 17 00:00:00 2001
From: podlesny <podlesny@zedat.fu-berlin.de>
Date: Tue, 16 Jun 2020 11:19:57 +0200
Subject: [PATCH] multiplicative working

---
 .../levelpatchpreconditioner.hh               | 35 ++-----------------
 src/cantorfaultnetworks/cantorfaultnetwork.cc | 14 ++++----
 .../cantorfaultnetwork.parset                 |  8 ++---
 .../sparsecantorfaultnetwork.parset           |  4 +--
 4 files changed, 16 insertions(+), 45 deletions(-)

diff --git a/dune/faultnetworks/preconditioners/levelpatchpreconditioner.hh b/dune/faultnetworks/preconditioners/levelpatchpreconditioner.hh
index c9fb33f..1b672a5 100644
--- a/dune/faultnetworks/preconditioners/levelpatchpreconditioner.hh
+++ b/dune/faultnetworks/preconditioners/levelpatchpreconditioner.hh
@@ -98,6 +98,8 @@ public:
     }
 
     virtual void iterate() {
+        *(this->x_) = 0;
+
         if (mode_ == ADDITIVE)
             iterateAdd();
         else
@@ -151,8 +153,6 @@ private:
     }
 
     void iterateAdd() {
-        //*(this->x_) = 0;
-
         VectorType it, x;
         for (size_t i=0; i<localProblems_.size(); i++) {
             localProblems_[i]->solve(it);
@@ -182,44 +182,15 @@ private:
 
         auto& localProblem = *localProblems_[i];
 
-        VectorType v, v1, v2, v3;
-        localProblem.restrict(*(this->x_), v);
-
-        v1.resize(localProblem.getLocalMat().N());
-        localProblem.getLocalMat().mv(v, v1);
-        v3.resize(matrix_.N());
-        matrix_.mv(*(this->x_), v3);
-        localProblem.restrict(v3, v2);
-
-        //print(v1, "v1");
-        //print(v2, "v2");
-
-        VectorType r1;
-        localProblem.restrict(*(this->rhs_), r1);
-        Dune::MatrixVector::subtractProduct(r1, localProblem.getLocalMat(), v);
-
-        /*localProblem.updateLocalRhs(r);
-
-        VectorType x;
-        localProblem.solve(x);
-        v += x;
-
-        localProblem.updateVector(v, *(this->x_));*/
-
         VectorType localR;
         VectorType r = *(this->rhs_);
         Dune::MatrixVector::subtractProduct(r, matrix_, *(this->x_));
         localProblem.restrict(r, localR);
 
-       // print(r1, "r1");
-       // print(localR, "localR");
-
         localProblem.updateLocalRhs(localR);
 
-        VectorType x;
+        VectorType x, v;
         localProblem.solve(x);
-
-        //VectorType v;
         localProblem.prolong(x, v);
         *(this->x_) += v;
     }
diff --git a/src/cantorfaultnetworks/cantorfaultnetwork.cc b/src/cantorfaultnetworks/cantorfaultnetwork.cc
index e2ed377..b97a447 100644
--- a/src/cantorfaultnetworks/cantorfaultnetwork.cc
+++ b/src/cantorfaultnetworks/cantorfaultnetwork.cc
@@ -141,7 +141,7 @@ int main(int argc, char** argv) { try
     matrixReader.read(matrix);
 
     const int oscGridN = matrix.N();
-    const int oscGridLevelIdx = std::round(std::log2(oscGridN)) - coarseResolution;
+    const int oscGridLevelIdx = std::max(std::round(std::log2(oscGridN)) - coarseResolution, 0.0);
 
     if (oscGridN>fineGridN)
         DUNE_THROW(Dune::Exception, "Provided oscData too large!");
@@ -161,7 +161,7 @@ int main(int argc, char** argv) { try
     CantorFaultFactory<GridType> faultFactory(levelToCantorLevel, coarseResolution, exactLevelIdx, maxCantorLevel);
     const InterfaceNetwork<GridType>& interfaceNetwork = faultFactory.interfaceNetwork();
 
-    if (problemCount==0) {
+    /*if (problemCount==0) {
         std::vector<int> writeLevels {1, 2, 8};
         for (size_t i=0; i<writeLevels.size(); i++) {
             int writeLevel = writeLevels[i];
@@ -170,7 +170,7 @@ int main(int argc, char** argv) { try
             LevelInterfaceNetworkWriter networkWriter(resultPath + "levelinterfacenetwork_" + std::to_string(writeLevel) + ".tikz");
             networkWriter.write(interfaceNetwork.levelInterfaceNetwork(writeLevel), writeGrid);
         }
-    }
+    }*/
 
     const GridType& grid = faultFactory.grid();
 
@@ -332,23 +332,23 @@ int main(int argc, char** argv) { try
     DGMGTransfer<DGBasis> discMGTransfer(*fineBasis, *exactBasis);
 
     // solve
-    /*OscCGSolver<MatrixType, VectorType, DGBasis>
+    OscCGSolver<MatrixType, VectorType, DGBasis>
     solver(*fineBasis, &fineGlobalAssembler.matrix(), &initialX, &rhs, &preconditioner,
                     maxIterations, solverTolerance, &exactEnergyNorm,
-                    Solver::FULL, &exactSol, &fineSol, discMGTransfer, 1.0, true); //((oscGridN+0.0)/fineGridN) */
+                    Solver::FULL, &exactSol, &fineSol, discMGTransfer, 1.0, true); //((oscGridN+0.0)/fineGridN)
 
 
     //solver.historyBuffer_ = resultPath + "solutions/level_" + std::to_string(fineResolution) + ".vec";
 
 
-    VectorType x = initialX;
+    /*VectorType x = initialX;
     preconditioner.setProblem(fineGlobalAssembler.matrix(), x, rhs);
 
     Dune::Solvers::LoopSolver<VectorType>
     solver (preconditioner, maxIterations, solverTolerance,
                    fineEnergyNorm,
                    Solver::FULL,
-                   true, &fineSol);
+                   true, &fineSol);*/
 
     solver.check();
     solver.preprocess();
diff --git a/src/cantorfaultnetworks/cantorfaultnetwork.parset b/src/cantorfaultnetworks/cantorfaultnetwork.parset
index fe8182c..6e07b72 100644
--- a/src/cantorfaultnetworks/cantorfaultnetwork.parset
+++ b/src/cantorfaultnetworks/cantorfaultnetwork.parset
@@ -2,7 +2,7 @@ path        = ../data/
 resultPath  = ../cantorfaultnetworks/results/
 
 [preconditioner]
-patch = SUPPORT            # CELL , SUPPORT
+patch = CELL            # CELL , SUPPORT
 mode = MULTIPLICATIVE         # ADDITIVE , MULTIPLICATIVE
 multDirection = SYMMETRIC    # SYMMETRIC , FORWARD , BACKWARD
 patchDepth = 1
@@ -10,12 +10,12 @@ patchDepth = 1
 ###########################################
 
 [problem0]
-oscDataFile         = oscDataLaplace32.mat
+oscDataFile         = oscDataLaplace4.mat
 
 # level resolution in 2^(-...)
 coarseResolution = 0
-fineResolution = 5
-exactResolution = 8
+fineResolution = 3
+exactResolution = 4
 minCantorResolution = 0
 
 penaltyFactor = 1
diff --git a/src/cantorfaultnetworks/sparsecantorfaultnetwork.parset b/src/cantorfaultnetworks/sparsecantorfaultnetwork.parset
index 456c5bf..31cd4c7 100644
--- a/src/cantorfaultnetworks/sparsecantorfaultnetwork.parset
+++ b/src/cantorfaultnetworks/sparsecantorfaultnetwork.parset
@@ -14,8 +14,8 @@ oscDataFile         = oscDataLaplace4.mat
 
 # level resolution in 2^(-...)
 coarseCantorLevel = 1
-fineCantorLevel = 2
-maxCantorLevel = 3
+fineCantorLevel = 4
+maxCantorLevel = 5
 
 penaltyFactor = 1
 
-- 
GitLab