Example #1
0
def proteus_runner(expr, problem_kws, numerics_kws, *args, **kws):
    opts, args = get_prog_opts(args, __doc__)
    log = kws.get('log', None)
    if log is None: log = Profiling.logEvent
    comm = init_mpi_petsc(opts, log)
    problem_list = [ProteusProblem(**problem_kws),]
    simulation_list = [default_s]
    numerics_list = [ProteusNumerics(**numerics_kws),]
    numerics_list[0].periodicDirichletConditions = problem_list[0].periodicDirichletConditions
    numerics_list[0].T = problem_list[0].T
    simulation_name = problem_list[0].name + "_" + numerics_list[0].__class__.__name__
    simulation_name_proc = simulation_name + "_" + repr(comm.rank())
    simFlagsList = [{ 'simulationName': simulation_name,
                      'simulationNameProc': simulation_name_proc,
                      'dataFile': simulation_name_proc + '.dat',
                      'components' : [ci for ci in range(problem_list[0].coefficients.nc)],
                      }]

    so = default_so
    so.name = problem_list[0].name
    so.pnList = problem_list
    so.sList = [default_s]
    try:
        so.systemStepControllerType = numerics_list[0].systemStepControllerType
    except AttributeError:
        pass
    try:
        so.tnList = numerics_list[0].tnList
        so.archiveFlag = numerics_list[0].archiveFlag
    except AttributeError:
        pass

    runNumber = 0
    runName = so.name + repr(runNumber)
    Profiling.procID=comm.rank()
    if simulation_list[0].logAllProcesses or opts.logAllProcesses:
        Profiling.logAllProcesses = True
    Profiling.flushBuffer=simulation_list[0].flushBuffer

    if opts.logLevel > 0:
        Profiling.openLog(runName+".log",opts.logLevel)


    ns = NumericalSolution.NS_base(default_so, problem_list, numerics_list, simulation_list,
                                   opts, simFlagsList)

    ns.calculateSolution(runName)
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
Example #3
0
            line = line[:line.index('#')]
        return line

    stripped_data = [strip_comments(line) for line in data]
    petsc_argv += '\n'.join(stripped_data).split()
    log("PETSc options from commandline")
    log(str(petsc_argv))

Comm.argv = petsc_argv
comm = Comm.init()
Profiling.procID=comm.rank()
if opts.logLevel > 0:
    #mwf looks like just gets .py.log if no sso file given
    #Profiling.openLog(args[0][-3:]+".log",opts.logLevel)
    if len(args) == 0:
        Profiling.openLog("proteus.log",opts.logLevel)
    elif len(args[0].split(' ')) == 1:
        Profiling.openLog(args[0].split('.')[0]+".log",opts.logLevel)
    else:
        Profiling.openLog(args[0][-3:]+".log",opts.logLevel)
if opts.logAllProcesses:
    Profiling.logAllProcesses = True

#blanket import statements can go below here now that petsc4py should be initialized
from proteus import *
try:
    from proteusGraphical import *
except:
    pass

log("Adding "+str(opts.probDir)+" to path for loading modules")
Example #4
0
            line = line[:line.index('#')]
        return line

    stripped_data = [strip_comments(line) for line in data]
    petsc_argv += '\n'.join(stripped_data).split()
    log("PETSc options from commandline")
    log(str(petsc_argv))

Comm.argv = petsc_argv
comm = Comm.init()
Profiling.procID = comm.rank()
if opts.logLevel > 0:
    #mwf looks like just gets .py.log if no sso file given
    #Profiling.openLog(args[0][-3:]+".log",opts.logLevel)
    if len(args) == 0:
        Profiling.openLog("proteus.log", opts.logLevel)
    elif len(args[0].split(' ')) == 1:
        Profiling.openLog(args[0].split('.')[0] + ".log", opts.logLevel)
    else:
        Profiling.openLog(args[0][-3:] + ".log", opts.logLevel)
if opts.logAllProcesses:
    Profiling.logAllProcesses = True

#blanket import statements can go below here now that petsc4py should be initialized
from proteus import *
try:
    from proteusGraphical import *
except:
    pass

log("Adding " + str(opts.probDir) + " to path for loading modules")
Example #5
0
from __future__ import print_function
#import sys
#from proteus import Comm
from future import standard_library
standard_library.install_aliases()
import os
import sys
import socket
import pickle
import numpy
import proteus
#remove blankent import statements until after Comm initialized for petsc4py
# from proteus import *
from proteus import Profiling, Comm
from warnings import *
import optparse
import sys
import pstats
import pdb
import petsc4py
Profiling.openLog("proteus.log", 7)
print(sys.argv[:1])
Comm.argv = sys.argv[:1]
comm = Comm.init()
comm = Comm.init()
#petsc4py.init(sys.argv[:1])
print(comm.rank(), comm.size())
print("Hello World from", comm.rank())
from proteus import *
Profiling.procID = comm.rank()
Example #6
0
def getpath():
    path = sys.path[0]+'/'
    return path

def remove_files(filenames):
    ''' delete files in filenames list '''
    for f in filenames:
        if os.path.exists(f):
            try:
                os.remove(f)
            except OSError as e:
                print ("Error: %s - %s" %(e.filename,e.strerror))
        else:
            pass

Profiling.logEvent("Testing Bodydynamics")

class TestAuxFunctions(unittest.TestCase):
    def testForwardEler(self):
        from proteus.mprans.BodyDynamics import forward_euler
        p0 = 5.0
        v0 = 2.0
        a  = 0.5
        dt = 0.01
        v = v0 + a*dt
        p = p0 + v*dt
        p1, v1 = forward_euler(p0, v0, a, dt)
        self.assertTrue(p==p1)
        self.assertTrue(v==v1)

    def testRungeKutta(self):
Example #7
0


from proteus import Comm, Profiling
import numpy as np
import numpy.testing as npt
import unittest
import pytest

comm = Comm.init()
Profiling.procID = comm.rank()

Profiling.logEvent("Testing SedClosure")
class GlobalVariables():
    def __init__(self):
        from proteus.mprans.SedClosure import HsuSedStress
        self.C4e = 1.
        self.C3e = 1.2
        self.eR = 0.8
        self.aDarcy = 1.
        self.bForch = 1.
        self.grain = 0.1
        self.packFraction = 0.2
        self.packMargin = 0.01
        self.sigmaC = 1.1
        self.maxFraction = 0.635
        self.frFraction = 0.57
        self.fContact = 0.02
        self.mContact = 2.
        self.nContact = 5.
        self.angFriction = np.pi/6.
Example #8
0
from proteus import Comm, Profiling
import numpy as np
import numpy.testing as npt
import unittest
import pytest

comm = Comm.init()
Profiling.procID = comm.rank()

Profiling.logEvent("Testing SedClosure")


class GlobalVariables():
    def __init__(self):
        from proteus.mprans.SedClosure import HsuSedStress
        self.C4e = 1.
        self.C3e = 1.2
        self.eR = 0.8
        self.aDarcy = 1.
        self.bForch = 1.
        self.grain = 0.1
        self.packFraction = 0.2
        self.packMargin = 0.01
        self.sigmaC = 1.1
        self.maxFraction = 0.635
        self.frFraction = 0.57
        self.fContact = 0.02
        self.mContact = 2.
        self.nContact = 5.
        self.angFriction = np.pi / 6.
        self.vos_limiter = 0.6
Example #9
0
#import sys
#from proteus import Comm
import os
import sys
import socket
import cPickle
import numpy
import proteus
#remove blankent import statements until after Comm initialized for petsc4py
# from proteus import *
from proteus import Profiling,Comm
from warnings import *
import optparse
import sys
import pstats
import pdb
import petsc4py
Profiling.openLog("proteus.log",7)
print sys.argv[:1]
comm = Comm.init(argv=sys.argv[:1])
comm = Comm.init(argv=sys.argv[:1])
#petsc4py.init(sys.argv[:1])
print comm.rank(),comm.size()
print "Hellow World from",comm.rank()
from proteus import *
Profiling.procID=comm.rank()
Example #10
0
def getpath():
    path = sys.path[0]+'/'
    return path

def remove_files(filenames):
    ''' delete files in filenames list '''
    for f in filenames:
        if os.path.exists(f):
            try:
                os.remove(f)
            except OSError, e:
                print ("Error: %s - %s" %(e.filename,e.strerror))
        else:
            pass

Profiling.logEvent("Testing Bodydynamics")

class TestAuxFunctions(unittest.TestCase):
    def testForwardEler(self):
        from proteus.mprans.BodyDynamics import forward_euler
        p0 = 5.0
        v0 = 2.0
        a  = 0.5
        dt = 0.01
        v = v0 + a*dt
        p = p0 + v*dt
        p1, v1 = forward_euler(p0, v0, a, dt)
        self.assertTrue(p==p1)
        self.assertTrue(v==v1)

    def testRungeKutta(self):
Example #11
0
import sys,os
import logging


comm = Comm.init()
Profiling.procID = comm.rank()
def getpath():
    path =str(os.getcwd())
    if "tests" in path[-6:]:
        path =""
    else:
        path = path+"/proteus/tests/"
    return path


Profiling.logEvent("Testing WaveTools")
class TestAuxFunctions(unittest.TestCase):
    def testVDir(self):
        from proteus.WaveTools import setVertDir
        self.assertTrue(np.array_equal(setVertDir(np.array([0,-9.81,0])), np.array([0,1,0])))
    def testDirVector(self):
        from proteus.WaveTools import setDirVector
        self.assertTrue(all(setDirVector(np.array([2.,2.,1.]))== np.array([2.,2.,1])/3.))
    def testDirCheck(self):
        from proteus.WaveTools import dirCheck
        dirCheck(np.array([1.,2.,3.]),np.array([7.,4.,-5.]) )# Just loading the function with two vertical vectors
        with self.assertRaises(SystemExit) as cm:
            dirCheck(np.array([9,9,9]),np.array([4,5,6]))
        self.assertEqual(cm.exception.code, 1)     
        
    def testReduceToIntervals(self):