コード例 #1
0
    def check_c0q1(self,
                   test_hexMesh_3x3=False,
                   use_petsc=False,
                   name="_hexMesh_"):
        poisson_3d_p = load_physics('poisson_3d_p', modulepath)
        poisson_3d_c0q1_n = load_numerics('poisson_3d_c0q1_n', modulepath)
        poisson_3d_c0q1_n.hex = True
        if test_hexMesh_3x3 == True:
            poisson_3d_p.meshfile = 'hexMesh_3x3'
            poisson_3d_p.domain = Domain.MeshHexDomain(poisson_3d_p.meshfile)
            poisson_3d_p.x0 = (-3., -3., -3.)
            poisson_3d_p.L = (6., 6., 6.)
        pList = [poisson_3d_p]
        nList = [poisson_3d_c0q1_n]
        so = System_base()
        so.name = pList[0].name = "poisson_3d_c0q1" + name + "pe" + repr(
            comm.size())
        so.sList = [default_s]
        opts.logLevel = 7
        opts.verbose = True

        if use_petsc == True:
            nList[0].linearSolver = default_n.KSP_petsc4py
            nList[0].multilevelLinearSolver = default_n.KSP_petsc4py
        ns = NumericalSolution.NS_base(so, pList, nList, so.sList, opts)
        ns.calculateSolution('poisson_3d_c0q1')
        del ns
        assert (True)
コード例 #2
0
    def example_setting(self, pre_setting):
        Context.contextOptionsString = pre_setting

        my_so = defaults.load_system("cylinder_so", modulepath)

        opts.profile = False
        opts.gatherArchive = True

        pList = []
        nList = []
        sList = []
        for (pModule, nModule) in my_so.pnList:
            pList.append(defaults.load_physics(pModule, modulepath))
            nList.append(defaults.load_numerics(nModule, modulepath))
            if pList[-1].name == None:
                pList[-1].name = pModule

        if my_so.sList == []:
            for i in range(len(my_so.pnList)):
                s = default_s
                sList.append(s)
        else:
            sList = my_so.sList

        my_so.name += "_sbm_mesh3D_" + self.compare_name  #save data with different filename
        ns = proteus.NumericalSolution.NS_base(my_so, pList, nList, sList,
                                               opts)
        ns.calculateSolution(my_so.name)

        expected_path = 'comparison_files/' + self.compare_name + '.h5'
        with tables.open_file(os.path.join(self._scriptdir, expected_path)) as expected, \
                tables.open_file( my_so.name + '.h5') as actual:
            assert np.allclose(expected.root.u_t2,
                               actual.root.u_t2,
                               atol=1e-10)
コード例 #3
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
コード例 #4
0
ファイル: test_poisson.py プロジェクト: arnsong/proteus
    def check_c0q1(self,test_hexMesh_3x3=False,use_petsc=False,name="_hexMesh_"):
        poisson_3d_p = load_physics('poisson_3d_p',
                                    modulepath)
        poisson_3d_c0q1_n = load_numerics('poisson_3d_c0q1_n',
                                          modulepath)
        poisson_3d_c0q1_n.hex=True
        if test_hexMesh_3x3 == True:
            poisson_3d_p.meshfile='hexMesh_3x3'
            poisson_3d_p.domain = Domain.MeshHexDomain(poisson_3d_p.meshfile)
            poisson_3d_p.x0 = (-3.,-3.,-3.)
            poisson_3d_p.L  = ( 6., 6., 6.)
        pList = [poisson_3d_p]
        nList = [poisson_3d_c0q1_n]
        so = System_base()
        so.name = pList[0].name = "poisson_3d_c0q1"+name+"pe"+`comm.size()`
        so.sList=[default_s]
        opts.logLevel=7
        opts.verbose=True

        if use_petsc == True:
            nList[0].linearSolver=default_n.KSP_petsc4py
            nList[0].multilevelLinearSolver=default_n.KSP_petsc4py
        ns = NumericalSolution.NS_base(so,pList,nList,so.sList,opts)
        ns.calculateSolution('poisson_3d_c0q1')
        del ns
        assert(True)
コード例 #5
0
 def setup_method(self):
     nseDrivenCavity_2d_p = defaults.load_physics('nseDrivenCavity_2d_p',import_modules)
     nseDrivenCavity_2d_n = defaults.load_numerics('nseDrivenCavity_2d_n',import_modules)
     self.pList = [nseDrivenCavity_2d_p]
     self.nList = [nseDrivenCavity_2d_n]
     self.so = default_so
     self.so.name = self.pList[0].name
     self.so.sList = self.pList[0].name
     self.so.sList = [default_s]
     self._scriptdir = os.path.dirname(__file__)
     Profiling.openLog("proteus.log",10)
     Profiling.logAllProcesses = True
コード例 #6
0
 def test_c0q2(self):
     pList = [load_physics('poisson_3d_p', modulepath)]
     nList = [load_numerics('poisson_3d_c0q2_n', modulepath)]
     so = System_base()
     so.name = pList[0].name = "poisson_3d_c0q2" + "pe" + repr(comm.size())
     so.sList = [default_s]
     opts.logLevel = 7
     opts.verbose = True
     nList[0].linearSolver = default_n.KSP_petsc4py
     nList[0].multilevelLinearSolver = default_n.KSP_petsc4py
     ns = NumericalSolution.NS_base(so, pList, nList, so.sList, opts)
     ns.calculateSolution('poisson_3d_c0q2')
     del ns
     assert (True)
コード例 #7
0
ファイル: test_poisson.py プロジェクト: arnsong/proteus
 def test_c0q2(self):
     pList = [load_physics('poisson_3d_p',
                           modulepath)]
     nList = [load_numerics('poisson_3d_c0q2_n',
                            modulepath)]
     so = System_base()
     so.name = pList[0].name = "poisson_3d_c0q2"+"pe"+`comm.size()`
     so.sList=[default_s]
     opts.logLevel=7
     opts.verbose=True
     nList[0].linearSolver=default_n.KSP_petsc4py
     nList[0].multilevelLinearSolver=default_n.KSP_petsc4py
     ns = NumericalSolution.NS_base(so,pList,nList,so.sList,opts)
     ns.calculateSolution('poisson_3d_c0q2')
     del ns
     assert(True)
コード例 #8
0
    def example_setting(self, pre_setting):
        Context.contextOptionsString = pre_setting

        my_so = defaults.load_system("cylinder_so", modulepath)

        opts.profile = False
        opts.gatherArchive = True

        pList = []
        nList = []
        sList = []
        for (pModule, nModule) in my_so.pnList:
            pList.append(defaults.load_physics(pModule, modulepath))
            nList.append(defaults.load_numerics(nModule, modulepath))
            if pList[-1].name == None:
                pList[-1].name = pModule

        if my_so.sList == []:
            for i in range(len(my_so.pnList)):
                s = default_s
                sList.append(s)
        else:
            sList = my_so.sList

        my_so.name += "_sbm_mesh3D_" + self.compare_name  #save data with different filename
        try:
            ns = proteus.NumericalSolution.NS_base(my_so, pList, nList, sList,
                                                   opts)
        except:
            assert 0, "NS setup failed"
        try:
            ns.calculateSolution(my_so.name)
        except:
            assert 0, "NS calculation failed"

        actual = tables.open_file(
            'cylinder_sbm_mesh3D_T001_P1_sbm_3Dmesh' + '.h5', 'r')
        expected_path = 'comparison_files/' + 'comparison_u_t2.csv'
        #write comparison file
        #np.array(actual.root.u_t2).tofile(os.path.join(self._scriptdir, expected_path),sep=",")
        np.testing.assert_almost_equal(np.fromfile(os.path.join(
            self._scriptdir, expected_path),
                                                   sep=","),
                                       np.array(actual.root.u_t2),
                                       decimal=10)

        actual.close()
コード例 #9
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()
コード例 #10
0
 def test_c0p2(genMesh=True):
     pList = [defaults.load_physics('poisson_3d_tetgen_p',
                                    modulepath)]
     nList = [defaults.load_numerics('poisson_3d_tetgen_c0p2_n',
                                     modulepath)]
     so = defaults.System_base()
     so.name = pList[0].name = "poisson_3d_tetgen_c0p2"+"pe"+`comm.size()`
     so.sList=[default_s]
     Profiling.logLevel=7
     Profiling.verbose=False
     opts.generatePartitionedMeshFromFiles = True
     opts.gatherArchive=True
     pList[0].genMesh=genMesh
     nList[0].linearSolver=default_n.KSP_petsc4py
     nList[0].multilevelLinearSolver=default_n.KSP_petsc4py
     ns = NumericalSolution.NS_base(so,pList,nList,so.sList,opts)
     ns.calculateSolution('poisson_3d_c0p2')
     assert(True)
コード例 #11
0
 def test_c0p2(genMesh=True):
     pList = [defaults.load_physics('poisson_3d_tetgen_p',
                                    modulepath)]
     nList = [defaults.load_numerics('poisson_3d_tetgen_c0p2_n',
                                     modulepath)]
     so = defaults.System_base()
     so.name = pList[0].name = "poisson_3d_tetgen_c0p2"+"pe"+repr(comm.size())
     so.sList=[default_s]
     Profiling.logLevel=7
     Profiling.verbose=False
     opts.generatePartitionedMeshFromFiles = True
     opts.gatherArchive=True
     pList[0].genMesh=genMesh
     nList[0].linearSolver=default_n.KSP_petsc4py
     nList[0].multilevelLinearSolver=default_n.KSP_petsc4py
     ns = NumericalSolution.NS_base(so,pList,nList,so.sList,opts)
     ns.calculateSolution('poisson_3d_c0p2')
     assert(True)
コード例 #12
0
ファイル: test_poisson.py プロジェクト: hbcbh1999/proteus
 def test_c0p1(self):
     pList = [load_physics('poisson_3d_p', modulepath)]
     nList = [load_numerics('poisson_3d_c0p1_n', modulepath)]
     so = System_base()
     so.name = pList[0].name = "poisson_3d_c0p1" + "pe" + ` comm.size() `
     so.sList = [default_s]
     opts.logLevel = 7
     opts.verbose = True
     opts.profile = True
     opts.gatherArchive = True
     nList[0].linearSolver = default_n.KSP_petsc4py
     nList[0].multilevelLinearSolver = default_n.KSP_petsc4py
     #nList[0].linearSolver=default_n.LU
     #nList[0].multilevelLinearSolver=default_n.LU
     ns = NumericalSolution.NS_base(so, pList, nList, so.sList, opts)
     ns.calculateSolution('poisson_3d_c0p1')
     del ns
     assert (True)
コード例 #13
0
def load_simulation(context_options_str=None):
    """
    Loads a two-phase step problem with settings

    Parameters
    ----------
    settings:

    Returns:
    --------

    """
    from proteus import Context
    from proteus import default_s
    reload(PETSc)
    reload(iproteus)
    reload(default_p)
    reload(default_n)
    reload(default_s)
    Profiling.openLog("proteus.log",11)
    Profiling.verbose=True
    Context.contextOptionsString=context_options_str

    step2d_so = defaults.load_system('step2d_so',import_modules)
    twp_navier_stokes_step2d_p = defaults.load_physics('twp_navier_stokes_step2d_p',import_modules)
    twp_navier_stokes_step2d_n = defaults.load_numerics('twp_navier_stokes_step2d_n',import_modules)
    
    pList = [twp_navier_stokes_step2d_p]
    nList = [twp_navier_stokes_step2d_n]
    pList[0].name = 'step2d'        
    so = step2d_so
    so.name = pList[0].name
    so.sList = pList[0].name
    so.sList = [default_s]
    _scriptdir = os.path.dirname(__file__)
    Profiling.logAllProcesses = False
    ns = NumericalSolution.NS_base(so,
                                   pList,
                                   nList,
                                   so.sList,
                                   opts)
    return ns
コード例 #14
0
    def example_setting(self, pre_setting):
        Context.contextOptionsString = pre_setting

        my_so = defaults.load_system("cylinder_so",modulepath)

        opts.profile = False
        opts.gatherArchive = True
        
        pList=[]
        nList=[]
        sList=[]
        for (pModule,nModule) in my_so.pnList:
            pList.append(defaults.load_physics(pModule,modulepath))
            nList.append(defaults.load_numerics(nModule,modulepath))
            if pList[-1].name == None:
                pList[-1].name = pModule

        if my_so.sList == []:
            for i in range(len(my_so.pnList)):
                s = default_s
                sList.append(s)
        else:
            sList = my_so.sList

        my_so.name += "_sbm_mesh3D_"+self.compare_name #save data with different filename
        ns = proteus.NumericalSolution.NS_base(my_so,
                                               pList,
                                               nList,
                                               sList,
                                               opts)
        ns.calculateSolution(my_so.name)

        expected_path = 'comparison_files/' + self.compare_name + '.h5'
        with tables.open_file(os.path.join(self._scriptdir, expected_path)) as expected, \
                tables.open_file( my_so.name + '.h5') as actual:
            assert np.allclose(expected.root.u_t2,
                               actual.root.u_t2,
                               atol=1e-10)
コード例 #15
0
 def setup_method(self):
     stokesDrivenCavity_2d_p = defaults.load_physics(
         'stokesDrivenCavity_2d_p', import_modules)
     stokesDrivenCavity_2d_n = defaults.load_numerics(
         'stokesDrivenCavity_2d_n', import_modules)
コード例 #16
0
import sys
import inspect
import numpy as np
import tables
import pickle
import pytest

from petsc4py import PETSc

TestTools.addSubFolders(inspect.currentframe())
from proteus import defaults
import_modules = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                              'import_modules')
twp_navier_stokes_cavity_2d_so = defaults.load_system(
    'twp_navier_stokes_cavity_2d_so', import_modules)
twp_navier_stokes_cavity_2d_p = defaults.load_physics(
    'twp_navier_stokes_cavity_2d_p', import_modules)
twp_navier_stokes_cavity_2d_n = defaults.load_numerics(
    'twp_navier_stokes_cavity_2d_n', import_modules)


def clean_up_directory():
    FileList = [
        'forceHistory_p',
        'forceHistory_v',
        #'cavity2D',
        #'mesh',
        'momentHistory',
        'proteus',
        'wettedAreaHistory',
        'twp_navier_stokes_cavity_2d'
    ]