示例#1
0
 def test_01_FullRun(self):
     stokesDrivenCavity_2d_p = defaults.load_physics(
         'stokesDrivenCavity_2d_p', import_modules)
     stokesDrivenCavity_2d_n = defaults.load_numerics(
         'stokesDrivenCavity_2d_n', import_modules)
     self.pList = [stokesDrivenCavity_2d_p]
     self.nList = [stokesDrivenCavity_2d_n]
     self.nList[0].linearSmoother = proteus.LinearSolvers.Schur_Qp
     self.pList = [stokesDrivenCavity_2d_p]
     self.nList = [stokesDrivenCavity_2d_n]
     defaults.reset_default_so()
     self.so = default_so
     self.so.tnList = [0., 1.]
     self.so.name = self.pList[0].name
     self.so.sList = self.pList[0].name
     self.so.sList = [default_s]
     self._setPETSc()
     self._runTest()
     relpath = 'comparison_files/Qp_expected.log'
     actual_log = TestTools.NumericResults.build_from_proteus_log(
         'proteus.log')
     expected_log = TestTools.NumericResults.build_from_proteus_log(
         os.path.join(self._scriptdir, relpath))
     plot_lst = [(1.0, 0, 0), (1.0, 1, 0), (1.0, 2, 0)]
     L1 = expected_log.get_ksp_resid_it_info(plot_lst)
     L2 = actual_log.get_ksp_resid_it_info(plot_lst)
     assert L1 == L2
示例#2
0
    def test_AddedMass_2D(self):
        from proteus import defaults
        defaults.reset_default_p()
        defaults.reset_default_n()
        defaults.reset_default_so()
        from . import addedmass2D as am2D
        am2D.myTpFlowProblem.initializeAll()
        so = am2D.myTpFlowProblem.so
        so.name = 'addedMass2D'
        pList = []
        nList = []
        for (pModule, nModule) in so.pnList:
            pList.append(pModule)
            nList.append(nModule)
        if so.sList == []:
            for i in range(len(so.pnList)):
                s = default_s
                so.sList.append(s)
        Profiling.logLevel = 7
        Profiling.verbose = True
        # PETSc solver configuration
        OptDB = PETSc.Options()
        OptDB.clear()
        dirloc = os.path.dirname(os.path.realpath(__file__))
        with open(os.path.join(dirloc, "petsc.options.superlu_dist")) as f:
            all = f.read().split()
            i = 0
            while i < len(all):
                if i < len(all) - 1:
                    if all[i + 1][0] != '-':
                        print("setting ", all[i].strip(), all[i + 1])
                        OptDB.setValue(all[i].strip('-'), all[i + 1])
                        i = i + 2
                    else:
                        print("setting ", all[i].strip(), "True")
                        OptDB.setValue(all[i].strip('-'), True)
                        i = i + 1
                else:
                    print("setting ", all[i].strip(), "True")
                    OptDB.setValue(all[i].strip('-'), True)
                    i = i + 1
        ns = NumericalSolution.NS_base(so, pList, nList, so.sList, opts)
        ns.calculateSolution('addedmass2D')
        Aij = am2D.body.Aij

        #np.savetxt('Aij_sol2D.csv', Aij, delimiter=',')
        Aij_sol = np.genfromtxt(os.path.join(modulepath, 'Aij_sol2D.csv'),
                                delimiter=',')
        npt.assert_almost_equal(Aij, Aij_sol, decimal=5)
        self.teardown_method(self)
示例#3
0
 def test_02_FullRun(self):
     stokesDrivenCavity_2d_p = defaults.load_physics(
         'stokesDrivenCavity_2d_p', import_modules)
     stokesDrivenCavity_2d_n = defaults.load_numerics(
         'stokesDrivenCavity_2d_n', import_modules)
     self.pList = [stokesDrivenCavity_2d_p]
     self.nList = [stokesDrivenCavity_2d_n]
     self.pList = [stokesDrivenCavity_2d_p]
     self.nList = [stokesDrivenCavity_2d_n]
     defaults.reset_default_so()
     self.so = default_so
     self.so.tnList = [0., 1.]
     self.so.name = self.pList[0].name
     self.so.sList = self.pList[0].name
     self.so.sList = [default_s]
     self._setPETSc_LU()
     self._runTest()
示例#4
0
from __future__ import absolute_import
from proteus.default_so import *
from proteus import defaults
defaults.reset_default_so()
import proteus
try:
    from . import step2d
except:
    import step2d

from proteus import Context
import os

Context.setFromModule(step2d)
ct = Context.get()

pnList = [("twp_navier_stokes_step2d_p", "twp_navier_stokes_step2d_n")]

name = "twp_navier_stokes_step2d"

systemStepControllerType = proteus.SplitOperator.Sequential_tnList
systemStepExact = True

tnList = [0.0, 1.0]