本文整理汇总了Python中proteus.Comm.get方法的典型用法代码示例。如果您正苦于以下问题:Python Comm.get方法的具体用法?Python Comm.get怎么用?Python Comm.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类proteus.Comm
的用法示例。
在下文中一共展示了Comm.get方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_line_gauge_output
# 需要导入模块: from proteus import Comm [as 别名]
# 或者: from proteus.Comm import get [as 别名]
def test_line_gauge_output():
filename = 'test_line_output.csv'
silent_rm(filename)
lines = (((0, 0, 0), (1, 1, 1)),)
fields = ('u0', )
l = LineGauges(gauges=((fields, lines),),
fileName=filename)
time_list=[0.0, 1.0, 2.0]
# good hard-code for up to 1,024 processes or so, but slow (about 8 seconds on single process).
run_gauge(l, time_list, total_nodes=2048)
correct_gauge_names = ['u0 [ 0 0 0]', 'u0 [ 0.076923 0.076923 0.076923]',
'u0 [ 0.15385 0.15385 0.15385]', 'u0 [ 0.23077 0.23077 0.23077]',
'u0 [ 0.30769 0.30769 0.30769]', 'u0 [ 0.38462 0.38462 0.38462]',
'u0 [ 0.46154 0.46154 0.46154]', 'u0 [ 0.53846 0.53846 0.53846]',
'u0 [ 0.61538 0.61538 0.61538]', 'u0 [ 0.69231 0.69231 0.69231]',
'u0 [ 0.76923 0.76923 0.76923]', 'u0 [ 0.84615 0.84615 0.84615]',
'u0 [ 0.92308 0.92308 0.92308]', 'u0 [ 1 1 1]']
correct_data = np.asarray([[0., 0., 8.53846154, 17.07692308, 25.61538462,
34.15384615, 42.69230769, 51.23076923, 59.76923077, 68.30769231,
76.84615385, 85.38461538, 93.92307692, 102.46153846, 111.],
[1., 0., 17.07692308, 34.15384615, 51.23076923,
68.30769231, 85.38461538, 102.46153846, 119.53846154, 136.61538462,
153.69230769, 170.76923077, 187.84615385, 204.92307692, 222.],
[2., 0., 25.61538462, 51.23076923, 76.84615385,
102.46153846, 128.07692308, 153.69230769, 179.30769231, 204.92307692,
230.53846154, 256.15384615, 281.76923077, 307.38461538, 333.]])
# synchronize processes before attempting to read file
Comm.get().barrier()
gauge_names, data = parse_gauge_output(filename)
eq_(correct_gauge_names, gauge_names)
npt.assert_allclose(correct_data, data)
delete_file(filename)
示例2: test_2D_line_integral_gauge_output
# 需要导入模块: from proteus import Comm [as 别名]
# 或者: from proteus.Comm import get [as 别名]
def test_2D_line_integral_gauge_output():
filename = 'test_2D_line_integral_gauge_output.csv'
silent_rm(filename)
lines = (((0, 0, 0), (1, 1, 0)),
((0, 0, 0), (1, 0, 0)),
((0, 0, 0), (0, 1, 0)),
((0, 0.5, 0), (1, 0.5, 0)),
((0, 1, 0), (1, 1, 0)),
((0.5, 0, 0), (0.5, 1, 0)))
fields = ('u0', )
l = LineIntegralGauges(gauges=((fields, lines),),
fileName=filename)
time_list=[0.0, 1.0, 2.0, 2.5]
run_gauge(l, time_list)
correct_gauge_names = ['u0 [ 0 0 0] - [ 1 1 0]',
'u0 [ 0 0 0] - [ 1 0 0]',
'u0 [ 0 0 0] - [ 0 1 0]',
'u0 [ 0 0.5 0] - [ 1 0.5 0]',
'u0 [ 0 1 0] - [ 1 1 0]',
'u0 [ 0.5 0 0] - [ 0.5 1 0]']
correct_data = np.asarray([[0., 7.77817459, 0.5, 5., 5.5, 10.5, 5.5],
[1., 15.55634919, 1., 10., 11., 21., 11.],
[2., 23.33452378, 1.5, 15., 16.5, 31.5, 16.5],
[2.5, 27.22361108, 1.75, 17.5, 19.25, 36.75, 19.25]])
# synchronize processes before attempting to read file
Comm.get().barrier()
gauge_names, data = parse_gauge_output(filename)
eq_(correct_gauge_names, gauge_names)
npt.assert_allclose(correct_data, data)
delete_file(filename)
示例3: gauge_setup
# 需要导入模块: from proteus import Comm [as 别名]
# 或者: from proteus.Comm import get [as 别名]
def gauge_setup(nd, total_nodes=None):
comm = Comm.get()
#Simplified Physics
p.name="test_gauges"
p.nd = nd
class LinearSolution:
def uOfXT(self,x,t):
return (x[0]+10*x[1]+100*x[2])*(t+1.0)
p.initialConditions = {0:LinearSolution()}
p.dirichletConditions = {0: lambda x,flag: None}
p.domain = Domain.RectangularDomain(name="test_gauges_domain")
p.coefficients = TransportCoefficients.PoissonEquationCoefficients(aOfX = [lambda x: np.eye(p.nd, p.nd)],
fOfX = [lambda x: 0], nc=1, nd=p.nd)
#Simplified and Incomplete Numerics
n.femSpaces = {0:FemTools.C0_AffineLinearOnSimplexWithNodalBasis}
n.elementQuadrature = Quadrature.SimplexGaussQuadrature(p.nd,3)
n.elementBoundaryQuadrature = Quadrature.SimplexGaussQuadrature(p.nd-1,3)
n.numericalFluxType = NumericalFlux.NoFlux
n.cfluxtag = None
n.conservativeFlux = None
if total_nodes is None:
total_nodes = 2*comm.size()
if p.nd == 1:
mlMesh = build1DMesh(p, total_nodes+1)
elif p.nd == 2:
nnx = nny = int(ceil(sqrt(total_nodes)))+1
mlMesh = build2DMesh(p, nnx, nny)
elif p.nd == 3:
nnx = nny = nnz = int(ceil(pow(total_nodes, 1.0/3.0)))+1
mlMesh = build3DMesh(p, nnx, nny, nnz)
model = Transport.MultilevelTransport(p, n, mlMesh)
return model, p.initialConditions
示例4: problems
# 需要导入模块: from proteus import Comm [as 别名]
# 或者: from proteus.Comm import get [as 别名]
#!/usr/bin/env python
"""
Test module for linear boundary value problems (serial)
This module solves equations of the form
.. math::
\nabla \cdot \left( a(x) \nabla u \right) = f(x)
"""
from proteus.iproteus import *
from proteus import Comm
comm = Comm.get()
Profiling.logLevel=7
Profiling.verbose=True
import numpy.testing as npt
from nose.tools import ok_ as ok
from nose.tools import eq_ as eq
def test_c0p1():
import poisson_het_2d_p
import poisson_het_2d_c0pk_n
pList = [poisson_het_2d_p]
nList = [poisson_het_2d_c0pk_n]
so = default_so
so.name = pList[0].name = "poisson_2d_c0p1"+"pe"+`comm.size()`
so.sList=[default_s]
opts.logLevel=7
opts.verbose=True
opts.profile=True
示例5: __init__
# 需要导入模块: from proteus import Comm [as 别名]
# 或者: from proteus.Comm import get [as 别名]
#.........这里部分代码省略.........
for ebNE in range(self.mesh.nExteriorElementBoundaries_global):
ebN = self.mesh.exteriorElementBoundariesArray[ebNE]
eN_global = self.mesh.elementBoundaryElementsArray[ebN, 0]
ebN_element = self.mesh.elementBoundaryLocalElementBoundariesArray[
ebN, 0]
for i in range(self.mesh.nNodes_element):
if i != ebN_element:
I = self.mesh.elementNodesArray[eN_global, i]
self.internalNodes -= set([I])
self.nNodes_internal = len(self.internalNodes)
self.internalNodesArray = numpy.zeros((self.nNodes_internal,), 'i')
for nI, n in enumerate(self.internalNodes):
self.internalNodesArray[nI] = n
#
del self.internalNodes
self.internalNodes = None
logEvent("Updating local to global mappings", 2)
self.updateLocal2Global()
logEvent("Building time integration object", 2)
logEvent(memory("inflowBC, internalNodes,updateLocal2Global",
"OneLevelTransport"), level=4)
# mwf for interpolating subgrid error for gradients etc
if self.stabilization and self.stabilization.usesGradientStabilization:
self.timeIntegration = TimeIntegrationClass(
self, integrateInterpolationPoints=True)
else:
self.timeIntegration = TimeIntegrationClass(self)
if options is not None:
self.timeIntegration.setFromOptions(options)
logEvent(memory("TimeIntegration", "OneLevelTransport"), level=4)
logEvent("Calculating numerical quadrature formulas", 2)
self.calculateQuadrature()
self.setupFieldStrides()
comm = Comm.get()
self.comm = comm
if comm.size() > 1:
assert numericalFluxType is not None and numericalFluxType.useWeakDirichletConditions, "You must use a numerical flux to apply weak boundary conditions for parallel runs"
logEvent(memory("stride+offset", "OneLevelTransport"), level=4)
if numericalFluxType is not None:
if options is None or options.periodicDirichletConditions is None:
self.numericalFlux = numericalFluxType(
self,
dofBoundaryConditionsSetterDict,
advectiveFluxBoundaryConditionsSetterDict,
diffusiveFluxBoundaryConditionsSetterDictDict)
else:
self.numericalFlux = numericalFluxType(
self,
dofBoundaryConditionsSetterDict,
advectiveFluxBoundaryConditionsSetterDict,
diffusiveFluxBoundaryConditionsSetterDictDict,
options.periodicDirichletConditions)
else:
self.numericalFlux = None
# strong Dirichlet
self.dirichletConditionsForceDOF = {0: DOFBoundaryConditions(self.u[cj].femSpace, dofBoundaryConditionsSetterDict[cj], weakDirichletConditions=False)}
# set penalty terms
# cek todo move into numerical flux initialization
if self.ebq_global.has_key('penalty'):
for ebN in range(self.mesh.nElementBoundaries_global):
for k in range(
self.nElementBoundaryQuadraturePoints_elementBoundary):
self.ebq_global['penalty'][ebN, k] = self.numericalFlux.penalty_constant / (
self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power)
# penalty term
# cek move to Numerical flux initialization
if self.ebqe.has_key('penalty'):
for ebNE in range(self.mesh.nExteriorElementBoundaries_global):
ebN = self.mesh.exteriorElementBoundariesArray[ebNE]
for k in range(
self.nElementBoundaryQuadraturePoints_elementBoundary):
self.ebqe['penalty'][ebNE, k] = self.numericalFlux.penalty_constant / \
self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power
logEvent(memory("numericalFlux", "OneLevelTransport"), level=4)
self.elementEffectiveDiametersArray = self.mesh.elementInnerDiametersArray
# use post processing tools to get conservative fluxes, None by default
from proteus import PostProcessingTools
self.velocityPostProcessor = PostProcessingTools.VelocityPostProcessingChooser(
self)
logEvent(memory("velocity postprocessor", "OneLevelTransport"), level=4)
# helper for writing out data storage
from proteus import Archiver
self.elementQuadratureDictionaryWriter = Archiver.XdmfWriter()
self.elementBoundaryQuadratureDictionaryWriter = Archiver.XdmfWriter()
self.exteriorElementBoundaryQuadratureDictionaryWriter = Archiver.XdmfWriter()
self.globalResidualDummy = None
compKernelFlag = 0
self.addedMass = cAddedMass.AddedMass(
self.nSpace_global,
self.nQuadraturePoints_element,
self.u[0].femSpace.elementMaps.localFunctionSpace.dim,
self .u[0].femSpace.referenceFiniteElement.localFunctionSpace.dim,
self.testSpace[0].referenceFiniteElement.localFunctionSpace.dim,
self.nElementBoundaryQuadraturePoints_elementBoundary,
compKernelFlag)
self.barycenters = self.coefficients.barycenters
self.flags_rigidbody = self.coefficients.flags_rigidbody
示例6: setup_profiling
# 需要导入模块: from proteus import Comm [as 别名]
# 或者: from proteus.Comm import get [as 别名]
def setup_profiling():
comm = Comm.get()
Profiling.procID = comm.rank()
Profiling.logLevel = 10
Profiling.logFile = sys.stdout
Profiling.logAllProcesses = True