How to use the proteus.Comm.globalSum 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 / RANS2P_IB.py View on Github external
self.coefficients.vel_avg,
            self.coefficients.netBeamDrag)
        for i in range(self.coefficients.nBeams):
            for j in range(self.coefficients.nBeamElements):
                for k in range(self.coefficients.beam_quadOrder):
                    # globalSum(self.q1[i*(self.coefficients.nBeamElements*self.coefficients.beam_quadOrder)+j*self.coefficients.beam_quadOrder+k])
                    self.coefficients.q1[i, j, k] = globalSum(self.q1[i, j, k])
                    # globalSum(self.q2[i*(self.coefficients.nBeamElements*self.coefficients.beam_quadOrder)+j*self.coefficients.beam_quadOrder+k])
                    self.coefficients.q2[i, j, k] = globalSum(self.q2[i, j, k])
                    # globalSum(self.q3[i*(self.coefficients.nBeamElements*self.coefficients.beam_quadOrder)+j*self.coefficients.beam_quadOrder+k])
                    self.coefficients.q3[i, j, k] = globalSum(self.q3[i, j, k])
        for i in range(3):
            self.coefficients.vel_avg[i] = globalSum(self.coefficients.vel_avg[i])

        self.coefficients.vel_avg = old_div(self.coefficients.vel_avg, 0.1472)
        self.coefficients.netBeamDrag[0] = globalSum(self.coefficients.netBeamDrag[0])
github erdc / proteus / proteus / mprans / MCorr.py View on Github external
argsDict["ebqe_n"] = self.ebqe[('grad(u)', 0)]
        argsDict["q_r"] = self.q[('r', 0)]
        argsDict["q_porosity"] = self.offset[0]
        argsDict["offset_u"] = self.stride[0]
        argsDict["stride_u"] = r
        argsDict["globalResidual"] = self.coefficients.q_porosity
        argsDict["nExteriorElementBoundaries_global"] = self.mesh.nExteriorElementBoundaries_global
        argsDict["exteriorElementBoundariesArray"] = self.mesh.exteriorElementBoundariesArray
        argsDict["elementBoundaryElementsArray"] = self.mesh.elementBoundaryElementsArray
        argsDict["elementBoundaryLocalElementBoundariesArray"] = self.mesh.elementBoundaryLocalElementBoundariesArray
        argsDict["maxIts"] = self.maxIts
        argsDict["atol"] = self.atol
        argsDict["constant_u"] = U
        (R, J) = self.mcorr.globalConstantRJ(argsDict)
        R = globalSum(R)
        J = globalSum(J)
        self.coefficients.massConservationError = fabs(R)
        return (R, J)
github erdc / proteus / proteus / mprans / MCorr3P.py View on Github external
self.q[('grad(u)', 0)],
            self.ebqe[('u', 0)],
            self.ebqe[('grad(u)', 0)],
            self.q[('r', 0)],
            self.coefficients.q_vos,
            self.offset[0], self.stride[0],
            r,
            self.mesh.nExteriorElementBoundaries_global,
            self.mesh.exteriorElementBoundariesArray,
            self.mesh.elementBoundaryElementsArray,
            self.mesh.elementBoundaryLocalElementBoundariesArray,
            # FOR FAST ASSEMBLY of Jacobian matrix
            self.interface_lumpedMassMatrix)

        log("Global residual", level=9, data=r)
        self.coefficients.massConservationError = fabs(globalSum(r[:self.mesh.nNodes_owned].sum()))
        log("   Mass Conservation Error", level=3,
            data=self.coefficients.massConservationError)
        self.nonlinear_function_evaluations += 1
        if self.globalResidualDummy is None:
            self.globalResidualDummy = numpy.zeros(r.shape, 'd')
github erdc / proteus / proteus / mprans / CLSVOF.py View on Github external
self.coefficients.alpha/self.mesh.elementDiametersArray.min())

        # RELATED TO EIKONAL EQUATION #
        if self.preRedistancingStage == 1:
            # FREEZE INTERFACE #
            if (self.coefficients.freeze_interface_during_preRedistancing==True):
                for gi in range(len(self.u[0].dof)):
                    if self.interface_locator[gi] == 1.0:
                        r[gi] = 0
        # END OF FREEZING INTERFACE #
        else: # RELATED CLSVOF MODEL #
            # Quantities to compute normalization factor
            from proteus.Comm import globalSum, globalMax
            self.min_distance = -globalMax(-min_distance[0])
            self.max_distance = globalMax(max_distance[0])
            self.mean_distance = globalSum(mean_distance[0])
            self.volume_domain = globalSum(volume_domain[0])
            self.mean_distance /= self.volume_domain

            if self.forceStrongConditions:#
                for dofN,g in self.dirichletConditionsForceDOF.DOFBoundaryConditionsDict.iteritems():
                    r[dofN] = 0

            if self.displayCFL:
                cell_based_cflMax=globalMax(self.q[('cfl',0)].max())*self.timeIntegration.dt
                logEvent("...   Maximum Cell Based CFL = " + str(cell_based_cflMax),level=2)

            if self.stabilization:
                self.stabilization.accumulateSubgridMassHistory(self.q)
            logEvent("Global residual",level=9,data=r)

            self.nonlinear_function_evaluations += 1
github erdc / proteus / proteus / mprans / CLSVOF.py View on Github external
u_exact,
             self.offset[0],self.stride[0])

        from proteus.Comm import globalSum
        # Interface metrics
        self.global_I_err = globalSum(global_I_err)
        self.global_sI_err = globalSum(global_sI_err)
        # conservation metrics
        self.global_V = globalSum(global_V)
        self.global_V0 = globalSum(global_V0)
        self.global_sV = globalSum(global_sV)
        self.global_sV0 = globalSum(global_sV0)
        self.global_V_err = old_div(np.abs(self.global_V-self.global_V0),self.global_V0)
        self.global_sV_err = old_div(np.abs(self.global_sV-self.global_sV0),self.global_sV0)
        # distance property metric
        self.global_D_err = globalSum(global_D_err)
        # L2 error on level set
        self.global_L2_err = globalSum(global_L2_err)
        self.global_L2Banded_err = old_div(globalSum(global_L2Banded_err),globalSum(global_area_band))
        self.global_sH_L2_err = globalSum(global_sH_L2_err)
github erdc / proteus / proteus / mprans / MCorr3P.py View on Github external
def calculateMass(self, q_phi):
        return globalSum(self.mcorr3p.calculateMass(  # element
            self.u[0].femSpace.elementMaps.psi,
            self.u[0].femSpace.elementMaps.grad_psi,
            self.mesh.nodeArray,
            self.mesh.elementNodesArray,
            self.elementQuadratureWeights[('u', 0)],
            self.u[0].femSpace.psi,
            self.u[0].femSpace.grad_psi,
            self.u[0].femSpace.psi,
            self.u[0].femSpace.grad_psi,
            # element boundary
            self.u[0].femSpace.elementMaps.psi_trace,
            self.u[0].femSpace.elementMaps.grad_psi_trace,
            self.elementBoundaryQuadratureWeights[('u', 0)],
            self.u[0].femSpace.psi_trace,
            self.u[0].femSpace.grad_psi_trace,
            self.u[0].femSpace.psi_trace,
github erdc / proteus / proteus / mprans / CLSVOF.py View on Github external
self.mesh.elementDiametersArray,
             self.mesh.nodeDiametersArray,
             self.degree_polynomial,
             self.coefficients.epsFactHeaviside,
             self.u[0].dof, # This is u_lstage due to update stages in RKEV
             self.u0_dof,
             u_exact,
             self.offset[0],self.stride[0])

        from proteus.Comm import globalSum
        # Interface metrics
        self.global_I_err = globalSum(global_I_err)
        self.global_sI_err = globalSum(global_sI_err)
        # conservation metrics
        self.global_V = globalSum(global_V)
        self.global_V0 = globalSum(global_V0)
        self.global_sV = globalSum(global_sV)
        self.global_sV0 = globalSum(global_sV0)
        self.global_V_err = old_div(np.abs(self.global_V-self.global_V0),self.global_V0)
        self.global_sV_err = old_div(np.abs(self.global_sV-self.global_sV0),self.global_sV0)
        # distance property metric
        self.global_D_err = globalSum(global_D_err)
        # L2 error on level set
        self.global_L2_err = globalSum(global_L2_err)
        self.global_L2Banded_err = old_div(globalSum(global_L2Banded_err),globalSum(global_area_band))
        self.global_sH_L2_err = globalSum(global_sH_L2_err)
github erdc / proteus / proteus / mprans / CLSVOF.py View on Github external
# RELATED TO EIKONAL EQUATION #
        if self.preRedistancingStage == 1:
            # FREEZE INTERFACE #
            if (self.coefficients.freeze_interface_during_preRedistancing==True):
                for gi in range(len(self.u[0].dof)):
                    if self.interface_locator[gi] == 1.0:
                        r[gi] = 0
        # END OF FREEZING INTERFACE #
        else: # RELATED CLSVOF MODEL #
            # Quantities to compute normalization factor
            from proteus.Comm import globalSum, globalMax
            self.min_distance = -globalMax(-min_distance[0])
            self.max_distance = globalMax(max_distance[0])
            self.mean_distance = globalSum(mean_distance[0])
            self.volume_domain = globalSum(volume_domain[0])
            self.mean_distance /= self.volume_domain

            if self.forceStrongConditions:#
                for dofN,g in self.dirichletConditionsForceDOF.DOFBoundaryConditionsDict.iteritems():
                    r[dofN] = 0

            if self.displayCFL:
                cell_based_cflMax=globalMax(self.q[('cfl',0)].max())*self.timeIntegration.dt
                logEvent("...   Maximum Cell Based CFL = " + str(cell_based_cflMax),level=2)

            if self.stabilization:
                self.stabilization.accumulateSubgridMassHistory(self.q)
            logEvent("Global residual",level=9,data=r)

            self.nonlinear_function_evaluations += 1
            if self.globalResidualDummy is None: