Esempio n. 1
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)
Esempio n. 2
0
from builtins import range
from builtins import object
from proteus import *
from proteus.default_p import *
from proteus import defaults
defaults.reset_default_p()
"""
Heterogeneous Poisson's equations for one component (uncoupled) in 2D
"""

##\page Tests Test Problems
# \ref poisson_het_2d_p.py "Heterogeneous Poisson's equation for 1 components"
#

##\ingroup test
#\file poisson_het_2d_p.py
#
#\brief Heterogensou Poisson's equations for one component (uncoupled) in 2D

nd = 2

test_problem_number = 5
assert test_problem_number in [2, 5]

initialConditions = None
sd = True
Ident = numpy.zeros((nd, nd), 'd')
Ident[0, 0] = 1.0
Ident[1, 1] = 1.0
domain = None
polyfile = None