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_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)
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') sys.path.append(os.getcwd()) import context_module os.remove("context_module.py") Context.setFromModule(context_module) check_eq(Context.context)
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 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)
from proteus.default_n import * from proteus import ( Context, ) from proteus.mprans import SW2D from proteus.Gauges import PointGauges, LineGauges, LineIntegralGauges 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.33 #timeIntegration_sw2d = "SSP33" timeIntegration_sw2d = "FE" multilevelNonlinearSolver = Newton if (ct.LUMPED_MASS_MATRIX == 1): levelNonlinearSolver = ExplicitLumpedMassMatrixShallowWaterEquationsSolver else: levelNonlinearSolver = ExplicitConsistentMassMatrixShallowWaterEquationsSolver timeIntegration = ct.SW2DCV.RKEV stepController = Min_dt_controller if timeIntegration_sw2d == "SSP33": #mwf hack timeOrder = 3 nStagesTime = 3 else: timeOrder = 1 nStagesTime = 1
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 if not ct.useOnlyVF: pnList += [("ls_p", "ls_n"), ("redist_p", "redist_n"),
from __future__ import absolute_import from proteus.default_so import * from proteus import defaults defaults.reset_default_so() import proteus try: from . import step2d except: import 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_step2d" systemStepControllerType = proteus.SplitOperator.Sequential_tnList systemStepExact = True tnList = [0.0, 1.0]
""" The split operator module for air/water flow around a moving rigid cylinder """ from proteus.default_so import * from proteus import Context import floating_bar Context.setFromModule(floating_bar) ct = Context.get() if ct.useOnlyVF: pnList = [ ( "twp_navier_stokes_p", #0 "twp_navier_stokes_n"), ( "vof_p", #1 "vof_n") ] else: pnList = [ ( "twp_navier_stokes_p", #0 "twp_navier_stokes_n"), ( "vof_p", #1 "vof_n"), ( "ls_p", #2 "ls_n"), (
import os from proteus.default_so import * from proteus import Context from . import movemesh_monitor # 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(movemesh_monitor) ct = Context.get() # List of p/n files pnList = [] # moving mesh if ct.movingDomain: pnList += [("moveMesh_p", "moveMesh_n")] tnList = [0., ct.dt_init, ct.T] dt_system_fixed = 0.001 systemStepControllerType = Sequential_FixedStep needEBQ_GLOBAL = False needEBQ = False
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)
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.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 needEBQ = False tnList = [0.0, tank.dt_init ] + [i * tank.dt_fixed for i in range(1, tank.nDTout + 1)] archiveFlag = ArchiveFlags.EVERY_USER_STEP
from proteus import * from proteus.default_p import * from proteus import Domain import stokesDrivenCavity_2d from proteus import Context Context.setFromModule(stokesDrivenCavity_2d) ct = Context.get() """ Stokes Driven Cavity Flow - the file contains the physics corresponding to a Stokes Driven Cavity Flow. See notes for a detailed description. This model is being used to study the preformance of Schur complement preconditioners. """ ####################################################### # variables set from context name = ct.name numeric_scheme = ct.numeric_scheme useWeakBoundaryConditions = ct.useWeakBoundaryConditions ###################################################### # Mesh Options # space dimension nd = 2 # Mesh Properties # (bottom left part of mesh)
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]
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
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
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]
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
from proteus import * from proteus.default_p import * from proteus import Domain import nseDrivenCavity_2d from TwophaseNavierStokes_ST_LS_SO_VV import TwophaseNavierStokes_ST_LS_SO_VV from proteus import Context Context.setFromModule(nseDrivenCavity_2d) ct = Context.get() """ Stokes Driven Cavity Flow - the file contains the physics corresponding to a Stokes Driven Cavity Flow. See notes for a detailed description. This model is being used to study the preformance of Schur complement preconditioners. """ ####################################################### # variables set from context name = ct.name numeric_scheme = ct.numeric_scheme RE_through_bdy = ct.RE_through_bdy ###################################################### # space dimension nd = 2 # Mesh Creation x0 = [-1.0, -1.0] L = [2, 2]