Exemple #1
0
def test_get():
    from proteus import Context
    Context.set(ContextObject())
    ct = Context.get()
    check_eq(ct)
    try:
        ct.T=11.0
    except Exception as e:
        assert(type(e) is AttributeError)
def test_setFromModule():
    import os
    from proteus import Context
    with open("context_module.py","w") as f:
        f.write("nnx=11; T=10.0; g=9.8\n")
    import context_module
    os.remove("context_module.py")
    Context.setFromModule(context_module)
    check_eq(Context.context)
def test_Options():
    import os
    from proteus import Context
    Context.contextOptionsString="nnx=11"
    with open("context_module.py","w") as f:
        f.write('from proteus import Context; opts=Context.Options([("nnx",12,"number of nodes")]); nnx=opts.nnx; T=10.0; g=9.8\n')
    import context_module
    os.remove("context_module.py")
    Context.setFromModule(context_module)
    check_eq(Context.context)
Exemple #4
0
def test_setMutableFromModule():
    import os
    from proteus import Context
    with open("context_module.py","w") as f:
        f.write("nnx=11; T=10.0; g=9.8\n")
    sys.path.append(os.getcwd())
    import context_module
    os.remove("context_module.py")
    Context.setFromModule(context_module, mutable=True)
    check_eq(Context.context)
    ct = Context.get()
    ct.T=11.0
    eq(ct.T,11.0)
 def inlet_vof_dirichlet(x, t):
     from proteus import Context
     ct = Context.get()
     level = wave.mwl + wave.eta(x,t)
     mesh = ct.domain.MeshOptions
     he, ecH = ct.domain.MeshOptions.he, ct.epsFact_consrv_heaviside
     H = smoothedHeaviside(ecH*he,x[vert_axis]-level)
     return H
    def getContext(self, context=None):
        """
        Gets context from proteus.Context or

        Parameters
        ----------
        context: class, optional
             if set to None, the context will be created from proteus.Context
        """
        if context:
            from proteus import Context
            self.ct = Context.get()
        else:
            self.ct = context
 def twp_flowVelocity(x, t):
     from proteus import Context
     ct = Context.get()
     vert_axis = self.Shape.Domain.nd-1
     waveHeight = self.waves.mwl+self.waves.eta(x, t)
     wavePhi = x[vert_axis]-waveHeight
     if wavePhi <= 0:
         waterSpeed = self.waves.u(x, t)
     else:
         x_max = np.copy(x)
         x_max[vert_axis] = waveHeight
         waterSpeed = self.waves.u(x_max, t)
     he, ech = ct.domain.MeshOptions.he, ct.epsFact_consrv_heaviside
     H = smoothedHeaviside(0.5*ech*he, wavePhi-0.5*ech*he)
     return H*self.windSpeed[i] + (1-H)*waterSpeed[i]
 def ux_dirichlet(x, t):
     from proteus import Context
     ct = Context.get()
     waveHeight = wave.mwl+wave.eta(x, t)
     wavePhi = x[vert_axis]-waveHeight
     if wavePhi <= 0:
         waterSpeed = wave.u(x, t)
     else:
         x_max = list(x)
         x_max[vert_axis] = waveHeight
         waterSpeed = wave.u(x_max, t)
     he, ecH = ct.domain.MeshOptions.he, ct.epsFact_consrv_heaviside
     # smoothing only above wave, only on half the VOF smoothing length
     H = smoothedHeaviside(0.5*ecH*he, wavePhi-0.5*ecH*he)
     ux = H*windSpeed + (1-H)*waterSpeed
     return ux[i]
 def inlet_p_advective(x, t):
     from proteus import Context
     ct = Context.get()
     # This is the normal velocity, based on the outwards boundary
     # orientation b_or
     # needs to be equal to -ux_dirichlet
     b_or = self._b_or[self._b_i]
     nd = len(b_or)
     waterSpeed = np.array(wave.u(x, t))
     waveHeight = wave.mwl+wave.eta(x, t)
     wavePhi = x[vert_axis]-waveHeight
     he = ct.domain.MeshOptions.he
     if wavePhi <= 0:
         waterSpeed = wave.u(x, t)
     else:
         x_max = list(x)
         x_max[vert_axis] = waveHeight
         waterSpeed = wave.u(x_max, t)
     he, ecH = ct.domain.MeshOptions.he, ct.epsFact_consrv_heaviside
     # smoothing only above wave, only on half the VOF smoothing length
     H = smoothedHeaviside(0.5*ecH*he, wavePhi-0.5*ecH*he)
     U = H*windSpeed + (1-H)*waterSpeed
     u_p = np.sum(U[:nd]*b_or)
     return u_p
opts = Context.Options([
    # test options
    ("water_level", 1., "Height of free surface above bottom"),
    # tank
    ("tank_dim", (
        30.,
        1.5,
    ), "Dimensions of the tank"),
    ("generation", True, "Generate waves at the left boundary (True/False)"),
    ("absorption", True, "Absorb waves at the right boundary (True/False)"),
    ("tank_sponge", (5., 10.), "Length of generation/absorption zone"),
    ("free_slip", True, "Should tank walls have free slip conditions "
     "(otherwise, no slip conditions will be applied)."),
    #gravity
    ("g", [0, -9.81, 0], "Gravity vector"),
    # waves
    ("wave_period", 1.94, "Period of the waves"),
    ("wave_height", 0.025, "Height of the waves"),
    ("depth", 1., "Wave depth"),
    ("wave_dir", (1., 0., 0.), "Direction of the waves (from left boundary)"),
    ("wavelength", 5., "Wavelength"),
    # probe dx
    ("point_gauge_output", True, "Produce point gauge output"),
    ("column_gauge_output", True, "Produce column gauge output"),
    ("gauge_dx", 0.25, "Horizontal spacing of point gauges/column gauges"),
    # refinement
    ("refLevel", 100, "Refinement level (w/respect to wavelength)"),
    ("cfl", 0.33, "Target cfl"),
    # run time
    ("T", 10.0, "Simulation time"),
    ("dt_init", 0.001, "Initial time step"),
    # run details
    ("gen_mesh", True, "Generate new mesh"),
    ("useHex", False, "Use (hexahedral) structured mesh"),
    ("structured", False, "Use (triangular/tetrahedral) structured mesh"),
    ("nperiod", 10., "Number of time steps to save per period"),
])
Exemple #11
0
from proteus import *
from twp_navier_stokes_p import *
from tank import *
from proteus import Context
ctx = Context.get()

if timeDiscretization == 'vbdf':
    timeIntegration = VBDF
    timeOrder = 2
    stepController = Min_dt_cfl_controller
elif timeDiscretization == 'flcbdf':
    timeIntegration = FLCBDF
    #stepController = FLCBDF_controller_sys
    stepController = Min_dt_cfl_controller
    time_tol = 10.0 * ns_nl_atol_res
    atol_u = {1: time_tol, 2: time_tol, 3: time_tol}
    rtol_u = {1: time_tol, 2: time_tol, 3: time_tol}
else:
    timeIntegration = BackwardEuler_cfl
    stepController = Min_dt_cfl_controller

femSpaces = {0: basis, 1: basis, 2: basis, 3: basis}

massLumping = False
numericalFluxType = None
conservativeFlux = None

numericalFluxType = RANS2P.NumericalFlux
subgridError = RANS2P.SubgridError(coefficients,
                                   nd,
                                   lag=ns_lag_subgridError,
Exemple #12
0
from proteus.mprans import NCLS
from proteus import Norms
from proteus import Profiling 
import numpy as np
import math 

ct=Context.Options([
    # General parameters #
    ("problem",0,"0: 1D advection with PBCs. 1: 2D rotation of disk"),
    ("level_set_function",1,"0: distance function, 1: saturated distance function"),
    ("T",0.1,"Final time"),
    ("nDTout",1,"Number of time steps to archive"),
    ("refinement",3,"Level of refinement"),
    ("unstructured",False,"Use unstructured mesh. Set to false for periodic BCs"),
    # Choice of numerical method #
    ("STABILIZATION_TYPE",1,"0: SUPG, 1: EV, 2: smoothness based indicator"),
    ("SATURATED_LEVEL_SET",True,"Saturate the distance function or not?"),
    ("ENTROPY_TYPE",2,"1: parabolic, 2: logarithmic"),
    ("COUPEZ",True,"Flag to turn on/off the penalization term in Coupez approach"), 
    ("DO_REDISTANCING",True,"Solve Eikonal type equation after transport?"),    
    # Numerical parameters #
    ("pure_redistancing",False,"To test pure redistancing; i.e., no advection"),
    ("cE",1.0,"Entropy viscosity constant"),
    ("cfl",0.5,"Target cfl"),
    ("SSPOrder",2,"SSP method of order 1, 2 or 3")
],mutable=True)

assert ct.problem==0 or ct.problem==1, "Problem must be either 0 or 1"
assert ct.level_set_function== 0 or ct.level_set_function==1, "Leve set function must be set to 0 or 1"

# NUMERICAL PARAMETERS #
epsCoupez=3
Exemple #13
0
# *************************** #
# ***** GENERAL OPTIONS ***** #
# *************************** #

# Here we define Tstar which corresponds to experimental data time
# Tstar = {10,15,20,...,65} for the final time

T = 65.0
g = 9.81  # gravity
h0 = 1.0  # water depth
Tstar = T * np.sqrt(h0 / g)

opts = Context.Options([
    ('sw_model', 1, "sw_model = {0,1} for {SWEs,DSWEs}"),
    ("final_time", Tstar, "Final time for simulation"),
    ("dt_output", 0.1, "Time interval to output solution"),
    ("cfl", 0.2, "Desired CFL restriction"),
    ("refinement", 4, "Refinement level"),
    ("reflecting_BCs",False,"Use reflecting BCs")
])

###################
# DOMAIN AND MESH #
###################
L = (50.0, 1.0)
refinement = opts.refinement
domain = RectangularDomain(L=L, x=[-35.0, 0, 0])

# CREATE REFINEMENT #
nnx0 = 6
nnx = (nnx0 - 1) * (2**refinement) + 1
nny = old_div((nnx - 1), 10) + 1
Exemple #14
0
from proteus import Context

ct = Context.Options([(
    "test_case", 1,
    "1: 2D periodic vortex, 2: 2D solid rotation, 3: 3D solid rotation, 4: 3D LeVeque test"
)],
                     mutable=True)
from proteus.default_so import *
import proteus
import cavity2d
from proteus import Context
import os

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

pnList = [("twp_navier_stokes_cylinder_2d_p", "twp_navier_stokes_cylinder_2d_n")]

name = "twp_navier_stokes_cavity_2d"

systemStepControllerType = proteus.SplitOperator.Sequential_tnList
systemStepExact = True

tnList = [0.0,100000.0]
Exemple #16
0
import os
from proteus.default_so import *
from proteus import Context
from importlib import import_module
import addedmass3D

# Create context from main module
name_so = os.path.basename(__file__)
if '_so.py' in name_so[-6:]:
    name = name_so[:-6]
elif '_so.pyc' in name_so[-7:]:
    name = name_so[:-7]
else:
    raise NameError, 'Split operator module must end with "_so.py"'

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

# List of p/n files
pnList = []

# moving mesh
if ct.movingDomain:
    pnList += [("moveMesh_p", "moveMesh_n")]


# Navier-Stokes and VOF
pnList += [("twp_navier_stokes_p", "twp_navier_stokes_n"),
           ("vof_p", "vof_n")]

# Level set
Exemple #17
0
def test_set():
    from proteus import Context
    Context.set(ContextObject())
    check_eq(Context.context)
Exemple #18
0
from __future__ import division
from past.utils import old_div
from proteus import Domain
from proteus import Context
from proteus.mprans import NCLS
import numpy as np

ct=Context.Options([
    # General parameters #
    ("T",0.01,"Final time"),
    ("nDTout",1,"Number of time steps to archive"),
    ("refinement",1,"Level of refinement"),
    ("unstructured",False,"Use unstructured mesh. Set to false for periodic BCs"),
    # parameters for elliptic re-distancing    
    ("ELLIPTIC_REDISTANCING",0, "Type of elliptic re-distancing"),
],mutable=True)

# ELLIPTIC_REDISTANCING #
#0: no elliptic re-distancing
#1: nolinear via single or double potential, with(out) |grad(u)| reconstructed
#2: linear via C0 normal reconstruction
#3: nolninear via C0 normal reconstruction
runCFL=0.33

#number of space dimensions
nd=2

# General parameters 
parallel = True
linearSmoother = None
checkMass=False
Exemple #19
0
# The default options for the context are set below.
# nLevels - this must be an iteger value >=1
# name - this must be a string
# numeric_scheme: currently implemented -
#                 TH - Taylor Hood
#                 C0P1C0P1 - stabilized continous linears velocity and pressure
# parallel - this must be a boolean value

##########################################################

opts = Context.Options([
    ("nLevels", 1, "number of levels of uniform refinement"),
    ("name", "poiseuilleFlow", "output data file name"),
    ("numeric_scheme", "TH", "specify the numerical scheme being used"),
    ("useWeakBoundaryConditions", True,
     "Flag: False-Strong boundary conditions, True-Weak boundary conditions"),
    ("solveIteratively", True,
     "Flag: False-Direct Solver, True-Iterative Solver"),
    ("solveInParallel", False, "Flag: False-Serial Solve, True-Parallel Solve")
])

# TODO - add asserts

nLevels = opts.nLevels
name = opts.name
numeric_scheme = opts.numeric_scheme
useWeakBoundaryConditions = opts.useWeakBoundaryConditions
solveIteratively = opts.solveIteratively
solveInParallel = opts.solveInParallel
Exemple #20
0
from proteus.default_so import *
import proteus
import step2d
reload(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_cylinder_2d"

systemStepControllerType = proteus.SplitOperator.Sequential_tnList
systemStepExact = True

tnList = [0.0, 1000000000000000000.0] #, 5, 7, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 1000] #, 100]
#tnList = [0.0,cavity2d.dt_init]+[i*cavity2d.dt_fixed for i in range(1,cavity2d.nDTout+1)] 
Exemple #21
0
from proteus import Context

ct=Context.Options([
    ("test_case",1,"1: 2D falling bubble. 2: 3D falling bubble")
],mutable=True)
Exemple #22
0
import proteus.SWFlow.SWFlowProblem as SWFlowProblem
"""
This is the problem of monochromatic waves propagating
over an elliptic shoal. Details can be found in section 4.5 of
A discontinuous Galerkin method for a new class of Green Naghdi
equations on simplicial unstructured meshes by Duran and Marche.
We use proteus's wave tools feature for defining
the monochromatic waves at the inlet.
"""

# *************************** #
# ***** GENERAL OPTIONS ***** #
# *************************** #
opts = Context.Options([('sw_model', 0, "sw_model = {0,1} for {SWEs,DSWEs}"),
                        ("final_time", 10.0, "Final time for simulation"),
                        ("dt_output", 0.1, "Time interval to output solution"),
                        ("cfl", 0.33, "Desired CFL restriction"),
                        ("refinement", 5, "Refinement level")])

###################
# DOMAIN AND MESH #
###################
L = (15.0, 1.0)
domain = RectangularDomain(L=L, x=[0, 0, 0])
X_coords = (0.0, 15.0)  # this is domain in x direction, used in BCs

# CREATE REFINEMENT #
refinement = opts.refinement
nnx0 = 6
nnx = (nnx0 - 1) * (2**refinement) + 1
nny = old_div((nnx - 1), 10) + 1
Exemple #23
0
from proteus.default_n import *
from proteus import (StepControl, TimeIntegration, NonlinearSolvers,
                     LinearSolvers, LinearAlgebraTools, Context)
import ls_p as physics
from proteus.mprans import NCLS

ct = Context.get()
mesh = ct.domain.MeshOptions

runCFL = ct.runCFL
if ct.timeDiscretization == 'vbdf':
    timeIntegration = TimeIntegration.VBDF
    timeOrder = 2
    stepController = StepControl.Min_dt_cfl_controller
elif ct.timeDiscretization == 'flcbdf':
    timeIntegration = TimeIntegration.FLCBDF
    #stepController = FLCBDF_controller
    stepController = StepControl.Min_dt_cfl_controller
    time_tol = 10.0 * ct.ls_nl_atol_res
    atol_u = {0: time_tol}
    rtol_u = {0: time_tol}
else:
    timeIntegration = TimeIntegration.BackwardEuler_cfl
    stepController = StepControl.Min_dt_cfl_controller

# mesh options
nLevels = ct.nLevels
parallelPartitioningType = mesh.parallelPartitioningType
nLayersOfOverlapForParallel = mesh.nLayersOfOverlapForParallel
restrictFineSolutionToAllMeshes = mesh.restrictFineSolutionToAllMeshes
triangleOptions = mesh.triangleOptions
Exemple #24
0
import numpy as np
from proteus import (Domain, Context)
from proteus.Profiling import logEvent
from proteus.mprans.SpatialTools import Tank2D
from proteus.mprans import SpatialTools as st
import proteus.TwoPhaseFlow.TwoPhaseFlowProblem as TpFlow
from proteus.Gauges import PointGauges, LineIntegralGauges, LineGauges
import os

# *************************** #
# ***** GENERAL OPTIONS ***** #
# *************************** #
opts = Context.Options([("final_time", 3.0, "Final time for simulation"),
                        ("dt_output", 0.01,
                         "Time interval to output solution"),
                        ("cfl", 0.25, "Desired CFL restriction"),
                        ("he", 0.01, "he relative to Length of domain in x"),
                        ("refinement", 3, "level of refinement"),
                        ("adapt", 0, "will adapt?")])

# ****************** #
# ***** GAUGES ***** #
# ****************** #
height_gauges1 = LineGauges(
    gauges=(
        (
            ("phi", ),
            (
                ((2.724, 0.0, 0.0),
                 (2.724, 1.8, 0.0)),  # We consider this one in our paper
                ((2.228, 0.0, 0.0),
Exemple #25
0
from proteus import *
from proteus.default_p import *
from proteus import Domain
import stokes_2d
from proteus import Context
Context.setFromModule(stokes_2d)
ct=Context.get()
"""
Stokes Poiseuille Equation - this file contains the physics
corresponding to a Stokes' Poiseuille flow.

This model is used primarily as a test to confirm the
accuracy of various numerical schemes.
"""

#######################################################

# variables set from context
name = "poiseulleFlow"
numeric_scheme = "THQuads"
useWeakBoundaryConditions = False

######################################################

# space dimension
nd = 2

# Mesh Creation
# (bottom left corner of mesh)
x0 = [-1.0,-1.0]
# (mesh length in x and y direction)
Exemple #26
0

"""
This is a mach reflection test.
"""

# *************************** #
# ***** GENERAL OPTIONS ***** #
# *************************** #

opts = Context.Options([
    ('sw_model', 0, "sw_model = {0,1} for {SWEs, Disperisve SWEs}}"),
    ("final_time", 5.0, "Final time for simulation"),
    ("dt_output", 0.1, "Time interval to output solution"),
    ("cfl", 0.25, "Desired CFL restriction"),
    ("refinement", 4, "Refinement level"),
    ("reflecting_BCs", False, "Use reflecting BCs"),
    ("structured", False, "Structured or unstructured mesh"),
    ("he", 0.3, "Mesh size for unstructured mesh"),
    ("mannings", 0.0, "Mannings roughness coefficient")
])

###################
# DOMAIN AND MESH #
###################
domain = Domain.PlanarStraightLineGraphDomain()

my_vertices = [[0.0,0.0],[3.0,0.0],[10.0,3.2],[10.0,10.0],[0.0,10.0]]
my_segments = [[0,1],[1,2],[2,3],[3,4],[4,0]]

# boundary tags dictionary
Exemple #27
0
import numpy as np
from proteus import (Domain, Context, Gauges, MeshTools as mt)
from proteus.Gauges import PointGauges, LineIntegralGauges, LineGauges
from proteus.Profiling import logEvent
from subprocess import check_call
import proteus.TwoPhaseFlow.TwoPhaseFlowProblem as TpFlow
from proteus.TwoPhaseFlow.utils.Parameters import ParametersPhysical as PP
from proteus.ctransportCoefficients import smoothedHeaviside
import math

# *************************** #
# ***** GENERAL OPTIONS ***** #
# *************************** #
opts = Context.Options([("final_time", 7.5, "Final time for simulation"),
                        ("dt_output", 0.1, "Time interval to output solution"),
                        ("gauges", True, "Collect data for validation"),
                        ("cfl", 0.2, "Desired CFL restriction"),
                        ("he", 0.5, "Max mesh element diameter"),
                        ("use_gmsh", False, "Use gmsh to generate mesh")])

#assert opts.ns_model==1, "use ns_model=1 (rans3pf) for this"

# ****************** #
# ***** GAUGES ***** #
# ****************** #
if opts.gauges:
    pressure_gauges = PointGauges(
        gauges=(
            (
                ('p', ),
                (
                    (2.389, 0.526, 0.025),  #P1
Exemple #28
0
import numpy as np
from proteus import Domain, Context
from proteus.mprans import SpatialTools as st
import proteus.TwoPhaseFlow.TwoPhaseFlowProblem as TpFlow
from proteus import WaveTools as wt

# dependencies for FSI
from proteus.mbd import CouplingFSI as fsi
import pychrono

opts = Context.Options([
    ("final_time", 10.0, "Final time for simulation"),
    ("dt_output", 0.1, "Time interval to output solution"),
    ("cfl", 0.5, "Desired CFL restriction"),
    ("he", 0.05, "he relative to Length of domain in x"),
])

# general options
# sim time
T = opts.final_time
# initial step
dt_init = 0.001
# CFL value
cfl = 0.5
# mesh size
he = 0.05
# rate at which values are recorded
sampleRate = 0.05
# for ALE formulation
movingDomain = True
# for added mass stabilization
Exemple #29
0
from proteus.ctransportCoefficients import smoothedHeaviside
from proteus.ctransportCoefficients import smoothedHeaviside_integral
from proteus.Gauges import PointGauges, LineGauges, LineIntegralGauges
from proteus import Comm
from proteus import Context
from proteus.WaveTools import TimeSeries
from proteus.Domain import InterpolatedBathymetryDomain, PiecewiseLinearComplexDomain
from proteus.MeshTools import InterpolatedBathymetryMesh

comm = Comm.init()
opts = Context.Options([
    ("wave_type", 'single-peaked',
     "type of waves generated: 'linear', 'Nonlinear', 'single-peaked', 'double-peaked', 'time-series'"
     ), ("depth", 7.25, "water depth [m]"),
    ("wave_height", 4.0, "wave height [m]"),
    ("peak_period", 1.0 / 0.09, "Peak period [s]"),
    ("peak_period2", 6.0,
     "Second peak period (only used in double-peaked case)[s]"),
    ("peak_wavelength", 10.0, "Peak wavelength in [m]"),
    ("parallel", True, "Run in parallel"), ("gauges", False, "Enable gauges")
])

# Wave generator
windVelocity = [0., 0., 0.]
depth = 7.0
inflowVelocityMean = [0., 0., 0.]
period = opts.peak_period
omega = 2.0 * math.pi / period
waveheight = opts.wave_height
amplitude = waveheight / 2.0
wavelength = opts.peak_wavelength
Exemple #30
0
import proteus.MeshTools
from proteus import Domain
from proteus.Profiling import logEvent
from proteus.default_n import *
from proteus.ctransportCoefficients import smoothedHeaviside
from proteus.ctransportCoefficients import smoothedHeaviside_integral

from proteus import Context
opts=Context.Options([
    ("bar_dim", (0.33,0.33,0.2), "Dimensions of the bar"),
    ("tank_dim", (1.0,1.0,1.0), "Dimensions of the tank"),
    ("water_surface_height",0.5,"Height of free surface above bottom"),
    ("speed",0.0,"Speed of current if non-zero"),
    ("bar_height",0.4,"Initial height of bar center above bottom"),
    ("bar_rotation",(0,0,0),"Initial rotation about x,y,z axes"),
    ("refinement_level",0,"Set maximum element diameter to he/2**refinement_level"),
    ("gen_mesh",True,"Generate new mesh"),
    ("T",10.0,"Simulation time"),
    ("dt_init",0.001,"Initial time step"),
    ("cfl",0.33,"Target cfl"),
    ("nsave",100,"Number of time steps to  save"),
    ("parallel",True,"Run in parallel"),
    ("free_x",(0.0,0.0,1.0),"Free translations"),
    ("free_r",(1.0,1.0,0.0),"Free rotations")])

#----------------------------------------------------
# Physical properties
#----------------------------------------------------
rho_0=998.2
nu_0 =1.004e-6

rho_1=1.205
Exemple #31
0
    # mesh refinement
    ("he", 1., "Set characteristic element size"),
    # numerical options
    ("genMesh", True,
     "True: generate new mesh every time. False: do not generate mesh if file 	    exists"
     ),
    ("use_gmsh", False, "use_gmsh"),
    ("refinement", True, "ref"),
    ("refinement_freesurface", 0.05, "ref"),
    ("refinement_grading", 1.2, "ref"),
    ("movingDomain", False, "True/False")
]

# instantiate context options
opts = Context.Options(context_options)

#  ____                        _
# |  _ \  ___  _ __ ___   __ _(_)_ __
# | | | |/ _ \| '_ ` _ \ / _` | | '_ \
# | |_| | (_) | | | | | | (_| | | | | |
# |____/ \___/|_| |_| |_|\__,_|_|_| |_|
# Domain
# All geometrical options go here (but not mesh options)

domain = Domain.PiecewiseLinearComplexDomain()

SG = st.ShapeSTL(domain, 'Blocks.stl')
boundaryTags = SG.boundaryTags

current = wt.SteadyCurrent(U=opts.U,
"""
from __future__ import division
from past.utils import old_div
import numpy as np
from proteus import (Domain, Context, MeshTools as mt)
from proteus.Profiling import logEvent
import proteus.TwoPhaseFlow.TwoPhaseFlowProblem as TpFlow
import os

# *************************** #
# ***** GENERAL OPTIONS ***** #
# *************************** #
opts = Context.Options([('ns_model', 1, "ns_model = {rans2p,rans3p}"),
                        ("final_time", 3.0, "Final time for simulation"),
                        ("dt_output", 0.1, "Time interval to output solution"),
                        ("cfl", 0.2, "Desired CFL restriction"),
                        ("refinement", 16, "level of refinement"),
                        ("he", 1E-2, "he value"),
                        ("ARTIFICIAL_VISCOSITY", 3, "artificial viscosity")])

assert opts.ns_model == 1, "use ns_model=1 (rans3pf) for this"

# ****************** #
# ***** GAUGES ***** #
# ****************** #
# None

# *************************** #
# ***** DOMAIN AND MESH ***** #
# ****************** #******* #
useHex = False
Exemple #33
0
from __future__ import print_function
from __future__ import division
from builtins import range
from past.utils import old_div
from math import *
import proteus.MeshTools
from proteus import Domain
from proteus.default_n import *
from proteus.Profiling import logEvent

from proteus import Context

ct = Context.Options(
    [("T", 4.0, "Time interval [0, T]"), ("he", 0.12, "maximum size of edges"),
     ("onlySaveFinalSolution", False, "Only save the final solution"),
     ("vspaceOrder", 2, "FE space for velocity"),
     ("pspaceOrder", 1, "FE space for pressure"),
     ("use_sbm", True, "use sbm instead of imb"),
     ("use_regions", False, "use refinement regions")],
    mutable=True)

if ct.use_sbm:
    USE_SBM = 1
else:
    USE_SBM = 0

#  Discretization -- input options
sedimentDynamics = False
genMesh = False  #True
movingDomain = False
applyRedistancing = True
useOldPETSc = False
Exemple #34
0
from builtins import object
from proteus.default_p import *
from proteus import Context
from proteus.mprans import SW2D, SW2DCV
from proteus.Domain import RectangularDomain, PlanarStraightLineGraphDomain

import numpy as np
import math

opts = Context.Options([("T", 10.0, "Length of simulation in seconds"),
                        ("nDTout", 100, "number of time steps to archive"),
                        ("refinement", 3, "Level of refinement"),
                        ("structured", False, "Use structured mesh"),
                        ("reflecting_BCs", 1, "Use reflecting BCs")],
                       mutable=True)

AUTOMATED_TEST = True
if AUTOMATED_TEST:
    opts.T = 10
    opts.nDTout = 1
    opts.refinement = 2
#
refinement = opts.refinement
T = opts.T
nDTout = opts.nDTout
L = (75.0, 30.0)

######################
##### PARAMETERS #####
######################
# PHYSICAL PARAMETERS #
from __future__ import division
from builtins import range
from past.utils import old_div
from proteus.default_n import *
from proteus import (
    Context, )
from proteus.mprans import SW2D
import sw_hump_2d_p
Context.setFromModule(sw_hump_2d_p)
ct = Context.get()

reflecting_BCs = ct.opts.reflecting_BCs
refinement = ct.opts.refinement
runCFL = 0.5
sspOrder = 3

multilevelNonlinearSolver = Newton
if (ct.LUMPED_MASS_MATRIX == 1):
    levelNonlinearSolver = ExplicitLumpedMassMatrixShallowWaterEquationsSolver
else:
    levelNonlinearSolver = ExplicitConsistentMassMatrixShallowWaterEquationsSolver

timeIntegration = ct.SW2DCV.RKEV
stepController = Min_dt_controller
timeOrder = sspOrder
nStagesTime = sspOrder

rtol_u[0] = 1.0e-4
rtol_u[1] = 1.0e-4
rtol_u[2] = 1.0e-4
atol_u[0] = 1.0e-4
Exemple #36
0
from proteus import Context

#===============================================================================
# Context
#===============================================================================
ct = Context.Options(
    [
        ("T", 4.0, "Time interval [0, T]"),
        ("onlySaveFinalSolution", False, "Only save the final solution"),
        ("parallel", False, "Use parallel or not"),
        ("dt_fixed", 0.005, "fixed time step"),
        ##################################
        ("Refinement", 6, "refinement"),
        ("StrongDirichlet", True, "weak or strong"),
        ("use_sbm", 0, "use sbm instead of imb"),
        ("spaceOrder", 1, "FE space for velocity"),
        ("timeOrder", 2,
         "1=be or 2=vbdf"),  #both works, but 2 gives better cd-cl
        ("use_supg", 1, "Use supg or not"),
        ("nonconservative", 0, "0=conservative"),
        ("forceStrongDirichlet", False, "strong or weak"),
        ##################################
        ("use_ball_as_particle", 1, "1 or 0 == use ball or particle"),
        ("nDTout", 100, "output number"),
    ],
    mutable=True)

#===============================================================================
# supg
#===============================================================================
use_supg = ct.use_supg  ##########
Exemple #37
0
from proteus.Profiling import logEvent
from proteus.mprans.SpatialTools import Tank2D
from proteus.mprans.SpatialTools import Tank3D
from proteus.mprans import SpatialTools as st
from proteus.Profiling import logEvent
import proteus.TwoPhaseFlow.TwoPhaseFlowProblem as TpFlow
import math
import os

# *************************** #
# ***** GENERAL OPTIONS ***** #
# *************************** #
opts = Context.Options([('ns_model', 1, "ns_model={0,1} for {rans2p,rans3p}"),
                        ("final_time", 7.5, "Final time for simulation"),
                        ("dt_output", 0.1, "Time interval to output solution"),
                        ("gauges", True, "Collect data for validation"),
                        ("cfl", 0.2, "Desired CFL restriction"),
                        ("he", 0.5, "Max mesh element diameter"),
                        ("ARTIFICIAL_VISCOSITY", 3, "artificial viscosity")])

assert opts.ns_model == 1, "use ns_model=1 (rans3pf) for this"

# ****************** #
# ***** GAUGES ***** #
# ****************** #
if opts.gauges:
    pressure_gauges = Gauges.PointGauges(
        gauges=(
            (
                ('p', ),
                (
Exemple #38
0
opts = Context.Options([
    # predefined test cases
    ("water_level", 0.900, "Height of free surface above bottom"),
    # Geometry
    ("tank_dim", (
        1.,
        1.2,
    ), "Dimensions of the tank"),
    ("tank_sponge", (2., 2.),
     "Length of relaxation zones (front/back, left/right)"),
    ("tank_BC", 'FreeSlip', "tank boundary conditions: NoSlip or FreeSlip"),
    # waves
    ('wave', False, 'Enable  generation'),
    ('waveType', 'Fenton', 'Wavetype for regular waves, Linear or Fenton'),
    ("wave_period", 1.30, "Period of the waves"),
    ("wave_height", 0.167, "Height of the waves"),
    ('wavelength', 2.121, 'Wavelength only if Fenton is activated'),
    ('Ycoeff', [
        0.21107604, 0.07318902, 0.02782228, 0.01234846, 0.00618291, 0.00346483,
        0.00227917, 0.00194241
    ], 'Ycoeff only if Fenton is activated'),
    ('Bcoeff', [
        0.23112932, 0.03504843, 0.00431442, 0.00036993, 0.00004245, 0.00001877,
        0.00000776, 0.00000196
    ], 'Bcoeff only if Fenton is activated'),
    ('Nf', 8, 'Number of frequency components for fenton waves'),
    ('meanVelocity', [0., 0., 0.], 'Velocity used for currents'),
    ('phi0', 0.0, 'Initial phase for waves'),
    ('Uwind', [0.0, 0.0, 0.0], 'Set air velocity'),
    ('fast', True, 'Switches ON fast cosh approximation'),
    # caisson
    ("caisson2D", True, "Switch on/off caisson2D"),
    ("center", (0.5, 0.9), "Coord of the caisson center"),
    ('dimx', 0.3, 'X-dimension of the caisson2D'),
    ('dimy', 0.1, 'Y-dimension of the caisson2D'),
    ('width', 0.9, 'Z-dimension of the caisson2D'),
    ('mass', 125., 'Mass of the caisson2D [kg]'),
    ('caisson_BC', 'FreeSlip', 'caisson2D boundaries: NoSlip or FreeSlip'),
    ("free_x", (0., 0., 0.), "Translational DOFs"),
    ("free_r", (0., 0., 1.0), "Rotational DOFs"),
    ("caisson_inertia", 0.236, "Inertia of the caisson [kg m2]"),
    ("rotation_angle", 15., "Initial rotation angle (in degrees)"),
    ("Tn", 0.93, "Roll natural period"),
    ("overturning", True, "Switch on/off overturning module"),
    ('scheme', 'Forward_Euler',
     'Numerical scheme applied to solve motion calculation (Runge_Kutta or Forward_Euler)'
     ),
    # numerical options
    ("refinement_level", 0.0, "he=walength/refinement_level"),
    ("he", 0.04, "he=walength/refinement_level"),
    ("cfl", 0.4, "Target cfl"),
    ("duration", 10., "Durarion of the simulation"),
    ("freezeLevelSet", True, "No motion to the levelset"),
    ("useVF", 1.0, "For density and viscosity smoothing"),
    ('movingDomain', True, "Moving domain and mesh option"),
    ('conservativeFlux', True,
     'Fix post-processing velocity bug for porous interface'),
])
from proteus.Profiling import logEvent
from proteus.mprans.SpatialTools import Tank2D

# predefined options
opts = Context.Options([
    # water column
    ("water_level", 0.6, "Height of water column in m"),
    ("water_width", 1.2, "Width of  water column in m"),
    # tank
    ("tank_dim", (3.22, 1.8), "Dimensions of the tank  in m"),
    #gravity
    ("g", (0, -9.81, 0), "Gravity vector in m/s^2"),
    # gauges
    ("gauge_output", True, "Produce gauge data"),
    ("gauge_location_p", (3.22, 0.12, 0), "Pressure gauge location in m"),
    # mesh refinement and timestep
    ("refinement", 32,
     "Refinement level, he = L/(4*refinement - 1), where L is the horizontal dimension"
     ),
    ("cfl", 0.33, "Target cfl"),
    # run time options
    ("T", 0.09, "Simulation time in s"),
    ("dt_fixed", 0.01, "Fixed time step in s"),
    ("dt_init", 0.001, "Maximum initial time step in s"),
    ("useHex", False, "Use a hexahedral structured mesh"),
    ("structured", False, "Use a structured triangular mesh"),
    ("gen_mesh", True, "Generate new mesh"),
])

# ----- CONTEXT ------ #

# water
Exemple #40
0
from proteus import Context
from proteus import Comm
comm = Comm.get()
ctx = Context.get()


# simulation flags for error analysis
#
# simFlagsList is initialized in proteus.iproteus
#

simFlagsList[0]['errorQuantities']=['u']
simFlagsList[0]['errorTypes']= ['numericalSolution'] #compute error in soln and glob. mass bal
simFlagsList[0]['errorNorms']= ['L1','LI'] #compute L2 norm in space or H0 or ...
simFlagsList[0]['errorTimes']= ['Last'] #'All', 'Last'
simFlagsList[0]['echo']=True
simFlagsList[0]['echoRelativeErrors']=True
#
start
quit
Exemple #41
0
from proteus.default_so import *
import tank
from proteus import Context
Context.setFromModule(tank)
ctx = Context.get()

if tank.useOnlyVF:
    pnList = [("twp_navier_stokes_p", "twp_navier_stokes_n"),
              ("vof_p",               "vof_n")]
else:
    pnList = [("twp_navier_stokes_p", "twp_navier_stokes_n"),
              ("vof_p",               "vof_n"),
              ("ls_p",                "ls_n"),
              ("redist_p",            "redist_n"),
              ("ls_consrv_p",         "ls_consrv_n")]


if tank.useRANS > 0:
    pnList.append(("kappa_p",
                   "kappa_n"))
    pnList.append(("dissipation_p",
                   "dissipation_n"))
name = "tank_p"

if tank.timeDiscretization == 'flcbdf':
    systemStepControllerType = Sequential_MinFLCBDFModelStep
    systemStepControllerType = Sequential_MinAdaptiveModelStep
else:
    systemStepControllerType = Sequential_MinAdaptiveModelStep

needEBQ_GLOBAL = False
def test_get():
    from proteus import Context
    Context.set(ContextObject())
    ct = Context.get()
    check_eq(ct)
Exemple #43
0
from proteus.default_n import *
from proteus import (Context,)
from proteus.mprans import SW2D
import sw_hump_2d_p
Context.setFromModule(sw_hump_2d_p)
ct = Context.get()

reflecting_BCs=ct.opts.reflecting_BCs
refinement=ct.opts.refinement
runCFL=0.5
sspOrder = 3

multilevelNonlinearSolver  = Newton
if (ct.LUMPED_MASS_MATRIX==1):
    levelNonlinearSolver = ExplicitLumpedMassMatrixShallowWaterEquationsSolver
else:
    levelNonlinearSolver = ExplicitConsistentMassMatrixShallowWaterEquationsSolver


timeIntegration = ct.SW2DCV.RKEV 
stepController = Min_dt_controller
timeOrder = sspOrder
nStagesTime = sspOrder

rtol_u[0] = 1.0e-4
rtol_u[1] = 1.0e-4
rtol_u[2] = 1.0e-4
atol_u[0] = 1.0e-4
atol_u[1] = 1.0e-4
atol_u[2] = 1.0e-4
femSpaces = {0:C0_AffineLinearOnSimplexWithNodalBasis,
from proteus import (Domain, Context, MeshTools as mt)
from proteus.Profiling import logEvent
from proteus.Gauges import PointGauges
import proteus.SWFlow.SWFlowProblem as SWFlowProblem
"""
Well-balancing test with conical island bathymetry and H_0 = 1m.
"""

# *************************** #
# ***** GENERAL OPTIONS ***** #
# *************************** #
opts = Context.Options([('sw_model', 1, "sw_model = {0,1} for {SWEs,DSWEs}"),
                        ("final_time", 10.0, "Final time for simulation"),
                        ("dt_output", 0.1, "Time interval to output solution"),
                        ("cfl", 0.33, "Desired CFL restriction"),
                        ("refinement", 4, "Refinement level"),
                        ("reflecting_BCs", False, "Use reflecting BCs"),
                        ("structured", True,
                         "Structured or unstructured mesh"),
                        ("he", 0.1, "Mesh size for unstructured mesh")])

###################
# DOMAIN AND MESH #
###################
L = (30.0, 25.0)  # this is length in x direction and y direction
refinement = opts.refinement
rectangle = RectangularDomain(L=L)

# CREATE REFINEMENT #
nnx0 = 6
nnx = (nnx0 - 1) * (2**refinement) + 1
Exemple #45
0
from proteus import *
from proteus import iproteus as ip
from proteus.default_p import *
reload(default_p)
from proteus import Domain
import stokes_2d
from proteus import Context
Context.setFromModule(stokes_2d)
ct = Context.get()
"""
Stokes Poiseuille Equation - this file contains the physics
corresponding to a Stokes' Poiseuille flow.

This model is used primarily as a test to confirm the
accuracy of various numerical schemes.
"""

#######################################################

# variables set from context
name = "poiseulleFlow"
numeric_scheme = "THQuads"
useWeakBoundaryConditions = False

######################################################

# space dimension
nd = 2

# Mesh Creation
# (bottom left corner of mesh)
Exemple #46
0
from proteus.default_n import *
from proteus.Profiling import logEvent
from proteus.ctransportCoefficients import smoothedHeaviside
from proteus.ctransportCoefficients import smoothedHeaviside_integral
from proteus import Gauges
from proteus.Gauges import PointGauges,LineGauges,LineIntegralGauges
from proteus import WaveTools as WT
import vegZoneVelocityInterp as vegZoneInterp


from proteus import Context
opts=Context.Options([
    ("wave_type", 'linear', "type of waves generated: 'linear', 'Nonlinear', 'single-peaked', 'double-peaked'"),
    ("depth", 0.457, "water depth at leading edge of vegetation (not at wave generator)[m]"),
    ("wave_height", 0.192, "wave height at leading edget of vegetation [m]"),
    ("peak_period", 2.0, "Peak period [s]"),
    ("peak_period2", 1.5, "Second peak period (only used in double-peaked case)[s]"),
    ("peak_wavelength",3.91,"Peak wavelength in [m]"),
    ("parallel", False, "Run in parallel"),
    ("gauges", True, "Enable gauges"),
    ("tank_height", 1.0, "height of wave tank")])

#wave generator
windVelocity = (0.0,0.0, 0.0)
veg_platform_height = 17.2/44.0 + 6.1/20.0
depth = opts.depth #veg_platform_height + opts.depth
inflowHeightMean = depth
inflowVelocityMean = (0.0,0.0,0.0)
period = opts.peak_period
omega = 2.0*math.pi/period
waveheight = opts.wave_height
amplitude = waveheight/ 2.0
Exemple #47
0
from proteus.default_n import *
import ls_p as physics
from proteus import (StepControl,
                     TimeIntegration,
                     NonlinearSolvers,
                     LinearSolvers,
                     LinearAlgebraTools)
from proteus.mprans import NCLS
from proteus import Context

ct = Context.get()
domain = ct.domain
nd = ct.domain.nd
mesh = domain.MeshOptions

# time stepping
runCFL = ct.runCFL
if ct.timeIntegration == "VBDF":
    timeIntegration = TimeIntegration.VBDF
    timeOrder = 2
else:
    timeIntegration = TimeIntegration.BackwardEuler_cfl
stepController  = StepControl.Min_dt_controller

# mesh options
nLevels = ct.nLevels
parallelPartitioningType = mesh.parallelPartitioningType
nLayersOfOverlapForParallel = mesh.nLayersOfOverlapForParallel
restrictFineSolutionToAllMeshes = mesh.restrictFineSolutionToAllMeshes
triangleOptions = mesh.triangleOptions
Exemple #48
0
from builtins import range
from past.utils import old_div
from math import *
import proteus.MeshTools
from proteus import Domain
from proteus.default_n import *
from proteus.Profiling import logEvent

#  Discretization -- input options
from proteus import Context

ct = Context.Options([
    ("T", 0.2, "Time interval [0, T]"),
    ("vspaceOrder",1,"FE space for velocity"),
    ##used in -C
    ("isHotStart",False,"Use hotStart or not"),
    ("Refinement",1,"refinement"),
    ("dt_fixed",0.005,"the size of fixed time step"),
    ("onlySaveFinalSolution",False,"Only save the final solution")
], mutable=True)

#Refinement = 20#45min on a single core for spaceOrder=1, useHex=False
mu = 1.0 #Just to compute force terms for convergence test
manufactured_solution = 1 #1: u.n!=0, 2: u.n=0
KILL_PRESSURE_TERM = False
fixNullSpace_PresInc = True
INTEGRATE_BY_PARTS_DIV_U_PresInc = True
CORRECT_VELOCITY = True
ns_forceStrongDirichlet = True
STABILIZATION_TYPE = 1 #0: SUPG, 1: EV via weak residual, 2: EV via strong residual
cE = 0