How to use the proteus.TransportCoefficients.TC_base function in proteus

To help you get started, we’ve selected a few proteus examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github erdc / proteus / proteus / mprans / AddedMass.py View on Github external
def initialize(self):
        assert(self.nd in [2, 3])
        if self.nd == 2:
            sdInfo = {(0, 0): (np.array([0, 1, 2], dtype='i'),
                               np.array([0, 1], dtype='i'))}
        else:
            sdInfo = {(0, 0): (np.array([0, 1, 2, 3], dtype='i'),
                               np.array([0, 1, 2], dtype='i'))}
        TC_base.__init__(self,
                         nc=1,
                         variableNames=['am'],
                         diffusion={0: {0: {0: 'constant'}}},
                         potential={0: {0: 'u'}},
                         sparseDiffusionTensors=sdInfo,
                         useSparseDiffusion=True)
        if self.flags_rigidbody is None:
            Profiling.logEvent("Warning: flags_rigidbody was not set for"+
                               "AddedMass model, using a zero array of length"+
                               "1000, this sets all boundaries as fixed walls"+
                               "for the added mass model and might cause"+
                               " issues if the domain contains more flags")
            self.flags_rigidbody = np.zeros(1000, dtype='int32')
github erdc / proteus / proteus / mprans / RANS3PF.py View on Github external
for ci in range(0, 3):
                self.numDiff_last[ci][:] = self.numDiff[ci]
        if self.lag == False and self.nStepsToDelay is not None and self.nSteps > self.nStepsToDelay:
            log("RANS3PF.ShockCapturing: switched to lagged shock capturing")
            self.lag = True
            for ci in range(0, 3):
                self.numDiff_last[ci] = self.numDiff[ci].copy()
        log(
            "RANS3PF: max numDiff_1 %e numDiff_2 %e numDiff_3 %e" %
            (globalMax(
                self.numDiff_last[0].max()), globalMax(
                self.numDiff_last[1].max()), globalMax(
                self.numDiff_last[2].max())))


class Coefficients(proteus.TransportCoefficients.TC_base):
    """
    The coefficients for two incompresslble fluids governed by the Navier-Stokes equations and separated by a sharp interface represented by a level set function
    """
    from proteus.ctransportCoefficients import TwophaseNavierStokes_ST_LS_SO_2D_Evaluate
    from proteus.ctransportCoefficients import TwophaseNavierStokes_ST_LS_SO_3D_Evaluate
    from proteus.ctransportCoefficients import TwophaseNavierStokes_ST_LS_SO_2D_Evaluate_sd
    from proteus.ctransportCoefficients import TwophaseNavierStokes_ST_LS_SO_3D_Evaluate_sd
    from proteus.ctransportCoefficients import calculateWaveFunction3d_ref

    def __init__(self,
                 epsFact=1.5,
                 sigma=72.8,
                 rho_0=998.2, nu_0=1.004e-6,
                 rho_1=1.205, nu_1=1.500e-5,
                 g=[0.0, 0.0, -9.8],
                 nd=3,
github erdc / proteus / proteus / mprans / MoveMesh.py View on Github external
from __future__ import division
from builtins import str
from builtins import range
from past.utils import old_div
import proteus
from proteus.mprans.cMoveMesh2D import cMoveMesh2D_base
from proteus.mprans.cMoveMesh import cMoveMesh_base
import numpy as np
from math import sqrt
from proteus.Transport import OneLevelTransport, TC_base, NonlinearEquation
from proteus import Quadrature, FemTools, Comm, Archiver, cfemIntegrals
from proteus.Profiling import logEvent, memory
from proteus import cmeshTools
from . import cArgumentsDict

class Coefficients(proteus.TransportCoefficients.TC_base):
    def __init__(self,
                 modelType_block,
                 modelParams_block,
                 g=[0.0, 0.0, -9.8],  # gravitational acceleration
                 rhow=998.2,  # kg/m^3 water density (used if pore pressures specified)
                 nd=3,
                 meIndex=0,
                 V_model=0,
                 nullSpace='NoNullSpace',
                 initialize=True):
        self.flowModelIndex = V_model
        self.modelType_block = modelType_block
        self.modelParams_block = modelParams_block
        self.g = np.array(g)
        self.gmag = sqrt(sum([gi**2 for gi in g]))
        self.rhow = rhow
github erdc / proteus / proteus / mprans / RDLS.py View on Github external
# don't modify dt_model
        self.solverFailures = 0
        self.errorFailures = 0
        self.saveSolution()
        # pseudo time step
        for m in self.model.levelModelList:
            m.timeIntegration.choose_dt()
        self.dt_model = self.start_ratio * m.timeIntegration.dt
        self.set_dt_allLevels()
        # physical time step
        self.t_model = self.substeps[0]
        self.setSubsteps([self.substeps[0]])
        logEvent("Osher-PsiTC choosing dt = %12.5e " % (self.dt_model,))


class Coefficients(proteus.TransportCoefficients.TC_base):
    from proteus.ctransportCoefficients import redistanceLevelSetCoefficientsEvaluate

    def __init__(self,
                 applyRedistancing=True,
                 epsFact=2.0,
                 nModelId=None,
                 u0=None,
                 rdModelId=0,
                 penaltyParameter=0.0,
                 useMetrics=0.0,
                 useConstantH=False,
                 weakDirichletFactor=10.0,
                 backgroundDiffusionFactor=0.01,
                 # Parameters for elliptic re-distancing
                 computeMetrics = False,
                 ELLIPTIC_REDISTANCING=0, #Linear elliptic re-distancing by default
github erdc / proteus / proteus / mprans / NCLS.py View on Github external
def setFromOptions(self, nOptions):
        """
        allow classes to set various numerical parameters
        """
        if 'runCFL' in dir(nOptions):
            self.runCFL = nOptions.runCFL
        flags = ['timeOrder']
        for flag in flags:
            if flag in dir(nOptions):
                val = getattr(nOptions, flag)
                setattr(self, flag, val)
                if flag == 'timeOrder':
                    self.resetOrder(self.timeOrder)


class Coefficients(proteus.TransportCoefficients.TC_base):
    from proteus.ctransportCoefficients import ncLevelSetCoefficientsEvaluate
    def __init__(self,
                 V_model=0,
                 RD_model=None,
                 ME_model=1,
                 checkMass=True,
                 epsFact=1.5,
                 useMetrics=0.0,
                 sc_uref=1.0,
                 sc_beta=1.0,
                 waterline_interval=-1,
                 movingDomain=False,
                 PURE_BDF=False,
                 # PARAMETERS FOR EV
                 STABILIZATION_TYPE=0,
                 LUMPED_MASS_MATRIX=False,
github erdc / proteus / proteus / mprans / MCorr3P.py View on Github external
from proteus.NonlinearSolvers import NonlinearEquation
from proteus.FemTools import (DOFBoundaryConditions,
                              FluxBoundaryConditions,
                              C0_AffineLinearOnSimplexWithNodalBasis)
from proteus.Comm import (globalMax,
                          globalSum)
from proteus.Profiling import memory
from proteus.Profiling import logEvent as log
from proteus.Transport import OneLevelTransport
from proteus.TransportCoefficients import TC_base
from proteus.SubgridError import SGE_base
from proteus.ShockCapturing import ShockCapturing_base
from . import cMCorr3P


class Coefficients(proteus.TransportCoefficients.TC_base):
    from proteus.ctransportCoefficients import levelSetConservationCoefficientsEvaluate
    from proteus.ctransportCoefficients import levelSetConservationCoefficientsEvaluate_sd

    def __init__(
            self,
            applyCorrection=True,
            epsFactHeaviside=0.0,
            epsFactDirac=1.0,
            epsFactDiffusion=2.0,
            LS_model=None,
            V_model=None,
            ME_model=None,
            VOS_model=None,
            VOF_model=None,
            checkMass=True,
            sd=True,
github erdc / proteus / proteus / mprans / Pres.py View on Github external
from . import cPres


class NumericalFlux(proteus.NumericalFlux.ConstantAdvection_exterior):
    def __init__(self,
                 vt,
                 getPointwiseBoundaryConditions,
                 getAdvectiveFluxBoundaryConditions,
                 getDiffusiveFluxBoundaryConditions):
        proteus.NumericalFlux.ConstantAdvection_exterior.__init__(self,
                                                                  vt, getPointwiseBoundaryConditions,
                                                                  getAdvectiveFluxBoundaryConditions,
                                                                  getDiffusiveFluxBoundaryConditions)


class Coefficients(TC_base):
    """
    The coefficients for pressure solution

    Update is given by

    .. math::

       p^{k+1} - p^{k} - phi^{k+1} + \nabla\cdot(\mu \mathbf{u}^{k+1}) = 0
    """

    def __init__(self,
                 modelIndex=None,
                 fluidModelIndex=None,
                 pressureIncrementModelIndex=None,
                 useRotationalForm=False,
                 initialize=True):
github erdc / proteus / proteus / mprans / SW2D.py View on Github external
def updateShockCapturingHistory(self):
        self.nSteps += 1
        if self.lag:
            for ci in range(3):
                self.numDiff_last[ci][:] = self.numDiff[ci]
        if self.lag == False and self.nStepsToDelay is not None and self.nSteps > self.nStepsToDelay:
            logEvent("SW2D.ShockCapturing: switched to lagged shock capturing")
            self.lag = True
            for ci in range(3):
                self.numDiff_last[ci] = self.numDiff[ci].copy()
        logEvent("SW2D: max numDiff_0 %e numDiff_1 %e numDiff_2 %e" % (globalMax(self.numDiff_last[0].max()),
                                                                       globalMax(self.numDiff_last[1].max()),
                                                                       globalMax(self.numDiff_last[2].max())))


class Coefficients(proteus.TransportCoefficients.TC_base):
    """
    The coefficients for the shallow water equations
    """

    def __init__(self,
                 nu=1.004e-6,
                 g=9.8,
                 nd=2,
                 sd=True,
                 movingDomain=False,
                 useRBLES=0.0,
                 useMetrics=0.0):
        self.useRBLES = useRBLES
        self.useMetrics = useMetrics
        self.sd = sd
        self.nu = nu