How to use the proteus.Transport.OneLevelTransport 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 / ADR.py View on Github external
c[('r',ci)].flat[i] = -self.fOfX[ci](c['x'].flat[3*i:3*(i+1)])
                        c[('a',ci,ci)].flat[nd*nd*i:nd*nd*(i+1)] = self.aOfX[ci](c['x'].flat[3*i:3*(i+1)]).flat

    def evaluate(self,t,c):
        if self.timeVaryingCoefficients:
            nd = self.nd
            for ci in range(self.nc):
                if self.velocity is not None:
                    c[('df',ci,ci)][...,:] = self.velocity
                else:
                    c[('df',ci,ci)].flat[:] = 0.0
                for i in range(len(c[('r',ci)].flat)):
                    c[('r',ci)].flat[i] = -self.fOfX[ci](c['x'].flat[3*i:3*(i+1)])
                    c[('a',ci,ci)].flat[nd*nd*i:nd*nd*(i+1)] = self.aOfX[ci](c['x'].flat[3*i:3*(i+1)]).flat

class LevelModel(proteus.Transport.OneLevelTransport):
    """
    Optimized LevelModel for ADR equations

    .. inheritance-diagram:: LevelModel
       :parts: 2
    """
    nCalls=0
    def __init__(self,
                 uDict,
                 phiDict,
                 testSpaceDict,
                 matType,
                 dofBoundaryConditionsDict,
                 dofBoundaryConditionsSetterDict,
                 coefficients,
                 elementQuadrature,
github erdc / proteus / proteus / mprans / RDLS.py View on Github external
vt.dirichletNodeSetList[0] = []
            vt.dirichletGlobalNodeSet[0] = set()
            vt.dirichletValues[0] = {}
            for eN in range(vt.mesh.nElements_global):
                vt.dirichletNodeSetList[0].append(set())

    # def
    setZeroLSweakDirichletBCs = staticmethod(setZeroLSweakDirichletBCs)
    setZeroLSweakDirichletBCs2 = staticmethod(setZeroLSweakDirichletBCs2)
    setZeroLSweakDirichletBCs3 = staticmethod(setZeroLSweakDirichletBCs3)


debugRDLS = False  # True


class LevelModel(proteus.Transport.OneLevelTransport):
    nCalls = 0

    def __init__(self,
                 uDict,
                 phiDict,
                 testSpaceDict,
                 matType,
                 dofBoundaryConditionsDict,
                 dofBoundaryConditionsSetterDict,
                 coefficients,
                 elementQuadrature,
                 elementBoundaryQuadrature,
                 fluxBoundaryConditionsDict=None,
                 advectiveFluxBoundaryConditionsSetterDict=None,
                 diffusiveFluxBoundaryConditionsSetterDictDict=None,
                 stressTraceBoundaryConditionsSetterDict=None,
github erdc / proteus / proteus / mprans / VOF3P.py View on Github external
self.VolumeAveragedVOFCoefficientsEvaluate(self.eps,
                                                       v,
                                                       phi,
                                                       porosity,
                                                       c[('u', 0)],
                                                       c[('m', 0)],
                                                       c[('dm', 0, 0)],
                                                       c[('f', 0)],
                                                       c[('df', 0, 0)])
        # if self.checkMass:
        #     logEvent("Phase  0 mass in eavl = %12.5e" % (Norms.scalarDomainIntegral(self.model.q['dV'],
        #                                                                        self.model.q[('m',0)],
        #                                                                        self.model.mesh.nElements_owned),),level=2)


class LevelModel(proteus.Transport.OneLevelTransport):
    nCalls = 0

    def __init__(self,
                 uDict,
                 phiDict,
                 testSpaceDict,
                 matType,
                 dofBoundaryConditionsDict,
                 dofBoundaryConditionsSetterDict,
                 coefficients,
                 elementQuadrature,
                 elementBoundaryQuadrature,
                 fluxBoundaryConditionsDict=None,
                 advectiveFluxBoundaryConditionsSetterDict=None,
                 diffusiveFluxBoundaryConditionsSetterDictDict=None,
                 stressTraceBoundaryConditionsSetterDict=None,
github erdc / proteus / proteus / mprans / MCorr.py View on Github external
c[('u', 0)],
                                                                  c[('r', 0)],
                                                                  c[('dr', 0, 0)],
                                                                  c[('a', 0, 0)])
        if (self.checkMass and c[('u', 0)].shape == self.q_u_ls.shape):
            self.m_tmp[:] = H_vof
            self.m_tmp += self.massCorrModel.q[('r', 0)]
            logEvent("mass correction during Newton %12.5e" % (Norms.scalarDomainIntegral(self.vofModel.q['dV'],
                                                                                          self.massCorrModel.q[('r', 0)],
                                                                                          self.massCorrModel.mesh.nElements_owned),), level=2)
            logEvent("Phase 0 mass during Newton %12.5e" % (Norms.scalarDomainIntegral(self.vofModel.q['dV'],
                                                                                       self.m_tmp,
                                                                                       self.massCorrModel.mesh.nElements_owned),), level=2)


class LevelModel(proteus.Transport.OneLevelTransport):
    nCalls = 0

    def __init__(self,
                 uDict,
                 phiDict,
                 testSpaceDict,
                 matType,
                 dofBoundaryConditionsDict,
                 dofBoundaryConditionsSetterDict,
                 coefficients,
                 elementQuadrature,
                 elementBoundaryQuadrature,
                 fluxBoundaryConditionsDict=None,
                 advectiveFluxBoundaryConditionsSetterDict=None,
                 diffusiveFluxBoundaryConditionsSetterDictDict=None,
                 stressTraceBoundaryConditionsSetterDict=None,
github erdc / proteus / proteus / mprans / RANS3PF.py View on Github external
if self.model.comm.isMaster():
            self.wettedAreaHistory.write("%21.16e\n" % (self.wettedAreas[-1],))
            self.forceHistory_p.write("%21.16e %21.16e %21.16e\n" %tuple(self.netForces_p[-1,:]))
            self.forceHistory_p.flush()
            self.forceHistory_v.write("%21.16e %21.16e %21.16e\n" %tuple(self.netForces_v[-1,:]))
            self.forceHistory_v.flush()
            self.momentHistory.write("%21.15e %21.16e %21.16e\n" % tuple(self.netMoments[-1,:]))
            self.momentHistory.flush()
            if self.nParticles:
                self.particle_forceHistory.write("%21.16e %21.16e %21.16e\n" %tuple(self.particle_netForces[0,:]))
                self.particle_forceHistory.flush()
                self.particle_momentHistory.write("%21.15e %21.16e %21.16e\n" % tuple(self.particle_netMoments[0,:]))
                self.particle_momentHistory.flush()

class LevelModel(proteus.Transport.OneLevelTransport):
    nCalls = 0

    def __init__(self,
                 uDict,
                 phiDict,
                 testSpaceDict,
                 matType,
                 dofBoundaryConditionsDict,
                 dofBoundaryConditionsSetterDict,
                 coefficients,
                 elementQuadrature,
                 elementBoundaryQuadrature,
                 fluxBoundaryConditionsDict=None,
                 advectiveFluxBoundaryConditionsSetterDict=None,
                 diffusiveFluxBoundaryConditionsSetterDictDict=None,
                 stressTraceBoundaryConditionsSetterDictDict=None,
github erdc / proteus / proteus / mprans / GN_SW2DCV.py View on Github external
def calculateAuxiliaryQuantitiesAfterStep(self):
        self.h_dof_sge[:] = self.u[0].dof
        self.hu_dof_sge[:] = self.u[1].dof
        self.hv_dof_sge[:] = self.u[2].dof
        self.heta_dof_sge[:] = self.u[3].dof
        self.hw_dof_sge[:] = self.u[4].dof
        OneLevelTransport.calculateAuxiliaryQuantitiesAfterStep(self)
github erdc / proteus / proteus / mprans / AddedMass.py View on Github external
return copyInstructions

    def postStep(self, t, firstStep=False):
        """
        Update the fluid velocities
        """
        copyInstructions = {}
        return copyInstructions

    def evaluate(self, t, c):
        if c[('u',0)].shape == self.q_rho.shape:
            c[('a', 0, 0)][..., 0] = old_div(1.0,self.q_rho)
            for i in range(1, c[('a', 0, 0)].shape[-1]):
                c[('a', 0, 0)][..., i] = c[('a', 0, 0)][..., 0]

class LevelModel(proteus.Transport.OneLevelTransport):
    nCalls = 0

    def __init__(self,
                 uDict,
                 phiDict,
                 testSpaceDict,
                 matType,
                 dofBoundaryConditionsDict,
                 dofBoundaryConditionsSetterDict,
                 coefficients,
                 elementQuadrature,
                 elementBoundaryQuadrature,
                 fluxBoundaryConditionsDict=None,
                 advectiveFluxBoundaryConditionsSetterDict=None,
                 diffusiveFluxBoundaryConditionsSetterDictDict=None,
                 stressTraceBoundaryConditionsSetterDict=None,
github erdc / proteus / proteus / mprans / MCorr.py View on Github external
H_vof,
                                                                  c[('u',0)],
                                                                  c[('r',0)],
                                                                  c[('dr',0,0)],
                                                                  c[('a',0,0)])
        if (self.checkMass and c[('u',0)].shape == self.q_u_ls.shape):
            self.m_tmp[:] = H_vof
            self.m_tmp += self.massCorrModel.q[('r',0)]
            logEvent("mass correction during Newton %12.5e" % (Norms.scalarDomainIntegral(self.vofModel.q['dV'],
                                                                                     self.massCorrModel.q[('r',0)],
                                                                                     self.massCorrModel.mesh.nElements_owned),),level=2)
            logEvent("Phase 0 mass during Newton %12.5e" % (Norms.scalarDomainIntegral(self.vofModel.q['dV'],
                                                                                 self.m_tmp,
                                                                                  self.massCorrModel.mesh.nElements_owned),),level=2)

class LevelModel(proteus.Transport.OneLevelTransport):
    nCalls=0
    def __init__(self,
                 uDict,
                 phiDict,
                 testSpaceDict,
                 matType,
                 dofBoundaryConditionsDict,
                 dofBoundaryConditionsSetterDict,
                 coefficients,
                 elementQuadrature,
                 elementBoundaryQuadrature,
                 fluxBoundaryConditionsDict=None,
                 advectiveFluxBoundaryConditionsSetterDict=None,
                 diffusiveFluxBoundaryConditionsSetterDictDict=None,
                 stressTraceBoundaryConditionsSetterDict=None,
                 stabilization=None,
github IgnitionProject / ignition / ignition / utils / proteus / defaults.py View on Github external
coefficients = None
    dirichletConditions = {}
    periodicDirichletConditions = None
    fluxBoundaryConditions = {} # Dictionary of flux boundary condition flags for each component 
                                # ('outflow','noflow','setflow','mixedflow')
    advectiveFluxBoundaryConditions =  {} # Dictionary of advective flux boundary conditions setter functions
    diffusiveFluxBoundaryConditions = {} # Dictionary of diffusive flux boundary conditions setter functions
    stressFluxBoundaryConditions = {} # Dictionary of stress tensor flux boundary conditions setter functions
    initialConditions = None #Dictionary of initial condition function objects
    weakDirichletConditions = None # Dictionary of weak Dirichlet constraint setters
    bcsTimeDependent = True # Allow optimizations if boundary conditions are not time dependent
    dummyInitialConditions = False #mwf temporary hack for RD level sets
    finalizeStep = lambda c: None
    T=1.0 # End of time interval
    sd = True # Use sparse representation of diffusion tensors
    LevelModelType = proteus.Transport.OneLevelTransport


class ProteusNumerics(ProteusBase):
    """The default values for numerics modules
    """
    stepController = proteus.StepControl.FixedStep # The step controller class derived from :class:`proteus.StepControl.SC_base`
    timeIntegration = proteus.TimeIntegration.NoIntegration # The time integration class derived from :class:`proteus.TimeIntegraction.TI_base
    timeIntegrator  = proteus.TimeIntegration.ForwardIntegrator # Deprecated, the time integrator class
    runCFL = 0.9 # The maximum CFL for the time step
    nStagesTime = 1 # The number of stages for the time discretization
    timeOrder= 1 # The order of the time discretization
    DT = 1.0 # The time step
    nDTout = 1 # The number of output time steps
    rtol_u = {0:1.0e-4} # A dictionary of relative time integration tolerances for the components
    atol_u = {0:1.0e-4} # A dictionary of absolute time integration tolerances for the components
    nltol_u = 0.33 # The nonlinear tolerance factor for the component error
github erdc / proteus / proteus / mprans / VOF.py View on Github external
self.VolumeAveragedVOFCoefficientsEvaluate(self.eps,
                                                       v,
                                                       phi,
                                                       porosity,
                                                       c[('u', 0)],
                                                       c[('m', 0)],
                                                       c[('dm', 0, 0)],
                                                       c[('f', 0)],
                                                       c[('df', 0, 0)])
        # if self.checkMass:
        #     logEvent("Phase  0 mass in eavl = %12.5e" % (Norms.scalarDomainIntegral(self.model.q['dV'],
        #                                                                        self.model.q[('m',0)],
        #                                                                        self.model.mesh.nElements_owned),),level=2)


class LevelModel(proteus.Transport.OneLevelTransport):
    nCalls = 0

    def __init__(self,
                 uDict,
                 phiDict,
                 testSpaceDict,
                 matType,
                 dofBoundaryConditionsDict,
                 dofBoundaryConditionsSetterDict,
                 coefficients,
                 elementQuadrature,
                 elementBoundaryQuadrature,
                 fluxBoundaryConditionsDict=None,
                 advectiveFluxBoundaryConditionsSetterDict=None,
                 diffusiveFluxBoundaryConditionsSetterDictDict=None,
                 stressTraceBoundaryConditionsSetterDict=None,