Ejemplo n.º 1
0
def test_minModelStep_stepExactTrue():
    pList = [load_p('ladr_2d_p', modulepath)]
    nList = [load_n('ladr_2d_n', modulepath)]
    so = So()
    so.name = pList[0].name = "ladr"
    so.tnList = nList[0].tnList
    so.systemStepControllerType = SplitOperator.Sequential_MinModelStep
    so.systemStepExact = True
    so.sList = [default_s]
    opts.logLevel = 7
    opts.verbose = True
    opts.profile = True
    opts.gatherArchive = True
    nList[0].runCFL = 0.33
    nList[0].linearSolver = default_n.LU
    nList[0].multilevelLinearSolver = default_n.LU
    ns = NumericalSolution.NS_base(so, pList, nList, so.sList, opts)
    ns.calculateSolution('ladr_minModelStep_stepExactTrue')
    assert ns.tCount + 1 == len(
        so.tnList), "wrong number of archvie steps " + repr(ns.tCount)
    assert ns.modelList[0].solver.solverList[
        0].solveCalls == 40, "wrong number of steps " + repr(
            ns.modelList[0].solver.solverList[0].solveCalls)
    archiveTimes = []
    for t in ns.ar[0].treeGlobal.iter('Time'):
        archiveTimes.append(t.attrib['Value'])
    archiveTimesCorrect = so.tnList
    npt.assert_almost_equal(np.array(archiveTimes, 'd'),
                            np.array(archiveTimesCorrect, 'd'))
    del ns
Ejemplo n.º 2
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)
Ejemplo n.º 3
0
def test_minModelStep_stepExactFalse():
    pList = [load_p('ladr_2d_p', modulepath)]
    nList = [load_n('ladr_2d_n', modulepath)]
    so = So()
    so.name = pList[0].name = "ladr"
    so.tnList = nList[0].tnList
    so.systemStepControllerType = SplitOperator.Sequential_MinModelStep
    so.systemStepExact = False
    so.sList = [default_s]
    opts.logLevel = 7
    opts.verbose = True
    opts.profile = True
    opts.gatherArchive = True
    nList[0].runCFL = 0.33
    nList[0].linearSolver = default_n.LU
    nList[0].multilevelLinearSolver = default_n.LU
    ns = NumericalSolution.NS_base(so, pList, nList, so.sList, opts)
    ns.calculateSolution('ladr_minModelStep_stepExactFalse')
    assert ns.tCount + 1 == len(
        so.tnList), "wrong number of archvie steps " + repr(ns.tCount)
    assert ns.modelList[0].solver.solverList[
        0].solveCalls == 34, "wrong number of steps " + repr(
            ns.modelList[0].solver.solverList[0].solveCalls)
    archiveTimes = []
    for t in ns.ar[0].treeGlobal.iter('Time'):
        archiveTimes.append(t.attrib['Value'])
    archiveTimesCorrect = [
        '0.0', '0.029516097303', '0.0516531702802', '0.0811692675832',
        '0.10330634056', '0.125443413538', '0.154959510841', '0.177096583818',
        '0.206612681121', '0.228749754098', '0.250886827075'
    ]
    npt.assert_almost_equal(np.array(archiveTimes, 'd'),
                            np.array(archiveTimesCorrect, 'd'))
    del ns
Ejemplo n.º 4
0
def test_minModelStep_stepExactFalse():
    pList = [load_p('ladr_2d_p', modulepath)]
    nList = [load_n('ladr_2d_n', modulepath)]
    so = So()
    so.name = pList[0].name = "ladr"
    so.tnList = nList[0].tnList
    so.systemStepControllerType = SplitOperator.Sequential_MinModelStep
    so.systemStepExact=False
    so.sList=[default_s]
    opts.logLevel=7
    opts.verbose=True
    opts.profile=True
    opts.gatherArchive=True
    nList[0].runCFL=0.33
    nList[0].linearSolver=default_n.LU
    nList[0].multilevelLinearSolver=default_n.LU
    ns = NumericalSolution.NS_base(so,pList,nList,so.sList,opts)
    ns.calculateSolution('ladr_minModelStep_stepExactFalse')
    assert ns.tCount + 1 == len(so.tnList), "wrong number of archvie steps " +`ns.tCount`
    assert ns.modelList[0].solver.solverList[0].solveCalls == 34, "wrong number of steps "+`ns.modelList[0].solver.solverList[0].solveCalls`
    archiveTimes=[]
    for t in ns.ar[0].treeGlobal.iter('Time'):
        archiveTimes.append(t.attrib['Value'])
    archiveTimesCorrect = ['0.0', '0.029516097303', '0.0516531702802', '0.0811692675832', '0.10330634056', '0.125443413538', '0.154959510841', '0.177096583818', '0.206612681121', '0.228749754098', '0.250886827075']
    npt.assert_almost_equal(np.array(archiveTimes,'d'), np.array(archiveTimesCorrect,'d'))
    del ns
Ejemplo n.º 5
0
def test_minModelStep_stepExactTrue():
    pList = [load_p('ladr_2d_p', modulepath)]
    nList = [load_n('ladr_2d_n', modulepath)]
    so = So()
    so.name = pList[0].name = "ladr"
    so.tnList = nList[0].tnList
    so.systemStepControllerType = SplitOperator.Sequential_MinModelStep
    so.systemStepExact=True
    so.sList=[default_s]
    opts.logLevel=7
    opts.verbose=True
    opts.profile=True
    opts.gatherArchive=True
    nList[0].runCFL=0.33
    nList[0].linearSolver=default_n.LU
    nList[0].multilevelLinearSolver=default_n.LU
    ns = NumericalSolution.NS_base(so,pList,nList,so.sList,opts)
    ns.calculateSolution('ladr_minModelStep_stepExactTrue')
    assert ns.tCount + 1 == len(so.tnList), "wrong number of archvie steps "+`ns.tCount`
    assert ns.modelList[0].solver.solverList[0].solveCalls == 40, "wrong number of steps "+`ns.modelList[0].solver.solverList[0].solveCalls`
    archiveTimes=[]
    for t in ns.ar[0].treeGlobal.iter('Time'):
        archiveTimes.append(t.attrib['Value'])
    archiveTimesCorrect = so.tnList
    npt.assert_almost_equal(np.array(archiveTimes,'d'), np.array(archiveTimesCorrect,'d'))
    del ns
Ejemplo n.º 6
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"+`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)
Ejemplo n.º 7
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)
Ejemplo n.º 8
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"+`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)
Ejemplo n.º 9
0
 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)
Ejemplo n.º 10
0
    def __init__(
        self,
        # DOMAIN AND MESH #
        domain=None,
        mesh=None,
        # INITIAL CONDITIONS #
        initialConditions=None,
        # BOUNDARY CONDITIONS #
        boundaryConditions=None,
    ):

        self.domain = domain
        self.mesh = mesh

        # ***** CREATE SYSTEM PHYSICS OBJECT ***** #
        self.SystemPhysics = SystemPhysics(ProblemInstance=self)
        self.SystemPhysics.initialConditions = initialConditions
        self.SystemPhysics.boundaryConditions = boundaryConditions

        #Model tracking objects
        self.SystemPhysics._modelIdxDict = {}
        self.SystemPhysics.modelDict = collections.OrderedDict()

        # ***** CREATE SYSTEM NUMERICS OBJECT ***** #
        self.SystemNumerics = SystemNumerics(ProblemInstance=self)

        # ***** CREATE MODEL PARAMETERS OBJECT ***** #
        self.Parameters = Parameters.ParametersHolder(ProblemInstance=self)

        # ***** CREATE FINITE ELEMENT SPACES ***** #
        self.FESpace = FESpace(ProblemInstance=self)

        # ***** CREATING OUTPUT MANAGEMENT OBJECTS ***** #
        self.so = System_base()
        self.outputStepping = OutputStepping()

        self._freeze()
Ejemplo n.º 11
0
    def __init__(
            self,
            ns_model=0,  #0: rans2p, 1: rans3p
            ls_model=1,  #0: vof+ncls+rdls+mcorr, 1: clsvof
            nd=2,
            # TIME STEPPING #
            cfl=0.33,
            outputStepping=None,
            # DOMAIN AND MESH #
            structured=False,
            he=None,
            nnx=None,
            nny=None,
            nnz=None,
            domain=None,
            triangleFlag=1,
            # INITIAL CONDITIONS #
            initialConditions=None,
            # BOUNDARY CONDITIONS #
            boundaryConditions=None,
            # AUXILIARY VARIABLES #
            auxVariables=None,
            # OTHERS #
            useSuperlu=False,
            fastArchive=False):
        # ***** SET OF ASSERTS ***** #
        if ns_model is not None:
            assert ns_model in [
                0, 1
            ], "ns_model={0,1} for rans2p or rans3p respectively"
        if ls_model is not None:
            assert ls_model in [
                0, 1
            ], "ls_model={0,1} for vof+ncls+rdls+mcorr or clsvof respectively"
        assert nd in [2, 3], "nd={2,3}"
        assert cfl <= 1, "Choose cfl <= 1"
        assert isinstance(
            outputStepping,
            OutputStepping), "Provide an object from the OutputStepping class"
        assert type(
            he) == float, "Provide (float) he (characteristic mesh size)"
        assert domain is not None, "Provide a domain"
        if structured:
            assert type(nnx) == int and type(
                nny) == int, "Provide (int) nnx and nny"
            if nd == 3:
                assert type(nnz) == int, "Provide (int) nnz"
        else:
            assert domain.MeshOptions.triangleOptions != 'q30DenA', "Set domain.MeshOptions.triangleOptions"
        assert triangleFlag in [0, 1, 2], "triangleFlag must be 1, 2 or 3"
        if initialConditions is not None:
            assert type(initialConditions
                        ) == dict, "Provide dict of initial conditions"
            # assertion now done in TwoPhaseFlow_so.py
        if boundaryConditions is not None:
            assert type(boundaryConditions
                        ) == dict, "Provide dict of boundary conditions"

        # ***** SAVE PARAMETERS ***** #
        self.domain = domain
        self.Parameters = Parameters.ParametersHolder(ProblemInstance=self)
        self.ns_model = ns_model
        self.ls_model = ls_model
        self.nd = nd
        self.cfl = cfl
        self.outputStepping = outputStepping
        self.outputStepping.setOutputStepping()
        self.so = System_base()
        self.Parameters.mesh.he = he
        self.Parameters.mesh.nnx = nnx
        self.Parameters.mesh.nny = nny
        self.Parameters.mesh.nnz = nnz
        self.Parameters.mesh.triangleFlag = triangleFlag
        self.Parameters.mesh.setTriangleOptions()
        self.initialConditions = initialConditions
        self.boundaryConditions = boundaryConditions
        self.useSuperlu = useSuperlu
        self.movingDomain = False
        self.archiveAllSteps = False
        # to use proteus.mprans.BoundaryConditions
        # but only if SpatialTools was used to make the domain
        self.useBoundaryConditionsModule = True

        # ***** CREATE FINITE ELEMENT SPACES ***** #
        self.FESpace = FESpace(self.ns_model, self.nd)
        self.FESpace.setFESpace()

        # ***** DEFINE PHYSICAL AND NUMERICAL PARAMETERS ***** #
        self.physical_parameters = default_physical_parameters
        self.rans2p_parameters = default_rans2p_parameters
        self.rans3p_parameters = default_rans3p_parameters
        self.clsvof_parameters = default_clsvof_parameters

        # set indice of models if ns_model and ls_model is set
        ind = 0
        if self.ls_model == 0:
            if self.ns_model == 0:
                self.Parameters.Models.rans2p.index = ind
                ind += 1
            else:
                self.Parameters.Models.rans3p.index = ind
                ind += 1
                self.Parameters.Models.pressureIncrement.index = ind
                ind += 1
                self.Parameters.Models.pressure.index = ind
                ind += 1
                self.Parameters.Models.pressureInitial.index = ind
                ind += 1
            self.Parameters.Models.vof.index = ind
            ind += 1
            self.Parameters.Models.ncls.index = ind
            ind += 1
            self.Parameters.Models.rdls.index = ind
            ind += 1
            self.Parameters.Models.mcorr.index = ind
            ind += 1
        elif self.ls_model == 1:
            if self.ns_model == 0:
                self.Parameters.Models.rans2p.index = ind
                ind += 1
                self.Parameters.Models.clsvof.index = ind
                ind += 1
            else:
                self.Parameters.Models.clsvof.index = ind
                ind += 1
                self.Parameters.Models.rans3p.index = ind
                ind += 1
                self.Parameters.Models.pressureIncrement.index = ind
                ind += 1
                self.Parameters.Models.pressure.index = ind
                ind += 1
                self.Parameters.Models.pressureInitial.index = ind
                ind += 1
        # ***** DEFINE OTHER GENERAL NEEDED STUFF ***** #
        self.general = default_general
        self.fastArchive = fastArchive