Browse Source

Added tests

Snow 8 years ago
parent
commit
1de92ae534
3 changed files with 7 additions and 8 deletions
  1. 4 6
      hdpg1d/adaptation.py
  2. 1 0
      hdpg1d/coefficients.py
  3. 2 2
      hdpg1d/postprocess.py

+ 4 - 6
hdpg1d/adaptation.py

@@ -69,7 +69,7 @@ class hdpg1d(object):
                           self.mesh[index[i] - 1]) / 2
         self.mesh = np.sort(np.insert(self.mesh, 0, inValue))
 
-    def solveLocal(self):
+    def solvePrimal(self):
         """Solve the primal problem"""
         if 'matLocal' in locals():
             # if matLocal exists,
@@ -155,7 +155,7 @@ class hdpg1d(object):
         maxCount = 30
         while estError > TOL and nodeCount < maxCount:
             # solve
-            self.solveLocal()
+            self.solvePrimal()
             self.solveAdjoint()
             # plot the solution at certain counter
             if nodeCount in [0, 4, 9, 19, maxCount]:
@@ -173,12 +173,10 @@ class hdpg1d(object):
             self.meshAdapt(index)
             self.numEle = self.numEle + len(index)
             nodeCount += 1
-            print("Iteration {}. Target function error {:.3e}.".format(
-                nodeCount, estError))
+            print("Iteration {}. Estimated target function error {:.3e}."
+                  .format(nodeCount, estError))
             if nodeCount == maxCount:
                 print("Max iteration number is reached "
                       "while the convergence criterion is not satisfied.\n"
                       "Check the problem statement or "
                       "raise the max iteration number, then try again.\n")
-                from .solve import runInteractive
-                runInteractive()

+ 1 - 0
hdpg1d/coefficients.py

@@ -29,5 +29,6 @@ class coefficients:
                 print("Sorry, wrong data type.")
                 continue
             else:
+                print("Something is wrong. Exit.")
                 break
         return cls(diff, conv, reaction, pOrder, numEle, tauPlus, tauMinus)

+ 2 - 2
hdpg1d/postprocess.py

@@ -19,7 +19,7 @@ class utils(object):
         self.solution.coeff.pOrder = self.exactBasisFuncs - 1
         self.solution.mesh = np.linspace(0, 1, self.exactNumEle + 1)
         # approximate the exact solution for general problems
-        self.solution.solveLocal()
+        self.solution.solvePrimal()
         exactSoln = self.solution.separateSoln(self.solution.primalSoln)[0][
             self.exactNumEle * self.exactBasisFuncs - 1]
         # for the reaction diffusion test problem, we know the exact solution
@@ -33,7 +33,7 @@ class utils(object):
         numBasisFuncs = self.solution.coeff.pOrder + 1
         # solve on the uniform mesh
         self.solution.mesh = np.linspace(0, 1, numEle + 1)
-        self.solution.solveLocal()
+        self.solution.solvePrimal()
         gradState, _ = self.solution.separateSoln(self.solution.primalSoln)
         errorL2 = np.abs(
             gradState[numBasisFuncs * numEle - 1] - self.exactSoln)