Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if not so.useOneMesh:
so.useOneArchive=False
logEvent("Setting Archiver(s)")
if so.useOneArchive:
self.femSpaceWritten={}
tmp = Archiver.XdmfArchive(opts.dataDir,so.name,useTextArchive=opts.useTextArchive,
gatherAtClose=opts.gatherArchive,hotStart=opts.hotStart,
useGlobalXMF=(not opts.subdomainArchives),
global_sync=opts.global_sync)
self.ar = dict([(i,tmp) for i in range(len(self.pList))])
elif len(self.pList) == 1:
self.ar = {0:Archiver.XdmfArchive(opts.dataDir,so.name,useTextArchive=opts.useTextArchive,
gatherAtClose=opts.gatherArchive,hotStart=opts.hotStart)} #reuse so.name if possible
else:
self.ar = dict([(i,Archiver.XdmfArchive(opts.dataDir,p.name,useTextArchive=opts.useTextArchive,
gatherAtClose=opts.gatherArchive,hotStart=opts.hotStart)) for i,p in enumerate(self.pList)])
#by default do not save quadrature point info
self.archive_q = dict([(i,False) for i in range(len(self.pList))]);
self.archive_ebq_global = dict([(i,False) for i in range(len(self.pList))]);
self.archive_ebqe = dict([(i,False) for i in range(len(self.pList))]);
self.archive_pod_residuals = dict([(i,False) for i in range(len(self.pList))]);
if simFlagsList is not None:
assert len(simFlagsList) == len(self.pList), "len(simFlagsList) = %s should be %s " % (len(simFlagsList),len(self.pList))
for index in range(len(self.pList)):
if 'storeQuantities' in simFlagsList[index]:
for quant in [a for a in simFlagsList[index]['storeQuantities'] if a is not None]:
recType = quant.split(':')
if len(recType) > 1 and recType[0] == 'q':
self.archive_q[index] = True
elif len(recType) > 1 and recType[0] == 'ebq_global':
self.archive_ebq_global[index] = True
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
log(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)
log(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()
# TODO get rid of this
for ci, fbcObject in self.fluxBoundaryConditionsObjectsDict.iteritems():
self.ebqe[('advectiveFlux_bc_flag', ci)] = numpy.zeros(
self.ebqe[('advectiveFlux_bc', ci)].shape, 'i')
for t, g in fbcObject.advectiveFluxBoundaryConditionsDict.iteritems():
if self.coefficients.advection.has_key(ci):
self.ebqe[
('advectiveFlux_bc', ci)][
t[0], t[1]] = g(
self.ebqe[
('x')][
t[0], t[1]], self.timeIntegration.t)
self.ebqe[('advectiveFlux_bc_flag', ci)][t[0], t[1]] = 1
# reduced quad
#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
log(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)
log(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()
#TODO get rid of this
# for ci,fbcObject in self.fluxBoundaryConditionsObjectsDict.iteritems():
# self.ebqe[('advectiveFlux_bc_flag',ci)] = numpy.zeros(self.ebqe[('advectiveFlux_bc',ci)].shape,'i')
# for t,g in fbcObject.advectiveFluxBoundaryConditionsDict.iteritems():
# if self.coefficients.advection.has_key(ci):
# self.ebqe[('advectiveFlux_bc',ci)][t[0],t[1]] = g(self.ebqe[('x')][t[0],t[1]],self.timeIntegration.t)
# self.ebqe[('advectiveFlux_bc_flag',ci)][t[0],t[1]] = 1
if hasattr(self.numericalFlux,'setDirichletValues'):
self.numericalFlux.setDirichletValues(self.ebqe)
if not hasattr(self.numericalFlux,'isDOFBoundary'):
self.numericalFlux.isDOFBoundary = {0:numpy.zeros(self.ebqe[('u',0)].shape,'i')}
if not hasattr(self.numericalFlux,'ebqe'):
self.numericalFlux.ebqe = {('u',0):numpy.zeros(self.ebqe[('u',0)].shape,'d')}
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] = old_div(self.numericalFlux.penalty_constant, \
self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power)
log(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)
log(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
log("flux bc objects")
for ci, fbcObject in list(self.fluxBoundaryConditionsObjectsDict.items()):
self.ebqe[('advectiveFlux_bc_flag', ci)] = numpy.zeros(self.ebqe[('advectiveFlux_bc', ci)].shape, 'i')
for t, g in list(fbcObject.advectiveFluxBoundaryConditionsDict.items()):
if ci in self.coefficients.advection:
self.ebqe[('advectiveFlux_bc', ci)][t[0], t[1]] = g(self.ebqe[('x')][t[0], t[1]], self.timeIntegration.t)
self.ebqe[('advectiveFlux_bc_flag', ci)][t[0], t[1]] = 1
for ck, diffusiveFluxBoundaryConditionsDict in list(fbcObject.diffusiveFluxBoundaryConditionsDictDict.items()):
self.ebqe[('diffusiveFlux_bc_flag', ck, ci)] = numpy.zeros(self.ebqe[('diffusiveFlux_bc', ck, ci)].shape, 'i')
for t, g in list(diffusiveFluxBoundaryConditionsDict.items()):
self.ebqe[('diffusiveFlux_bc', ck, ci)][t[0], t[1]] = g(self.ebqe[('x')][t[0], t[1]], self.timeIntegration.t)
self.ebqe[('diffusiveFlux_bc_flag', ck, ci)][t[0], t[1]] = 1
self.numericalFlux.setDirichletValues(self.ebqe)
self.ebq[('v',0)] = self.tmpvt.ebq[('v',0)]
self.ebq[('w',0)] = self.tmpvt.ebq[('w',0)]
self.ebq['sqrt(det(g))'] = self.tmpvt.ebq['sqrt(det(g))']
self.ebq['n'] = self.tmpvt.ebq['n']
self.ebq[('dS_u',0)] = self.tmpvt.ebq[('dS_u',0)]
self.ebqe['dS'] = self.tmpvt.ebqe['dS']
self.ebqe['n'] = self.tmpvt.ebqe['n']
self.ebq_global['n'] = self.tmpvt.ebq_global['n']
self.ebq_global['x'] = self.tmpvt.ebq_global['x']
from proteus import PostProcessingTools
self.velocityPostProcessor = PostProcessingTools.VelocityPostProcessingChooser(self)
log(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()
for ci,fbcObject in self.fluxBoundaryConditionsObjectsDict.iteritems():
self.ebqe[('advectiveFlux_bc_flag',ci)] = numpy.zeros(self.ebqe[('advectiveFlux_bc',ci)].shape,'i')
for t,g in fbcObject.advectiveFluxBoundaryConditionsDict.iteritems():
if self.coefficients.advection.has_key(ci):
self.ebqe[('advectiveFlux_bc',ci)][t[0],t[1]] = g(self.ebqe[('x')][t[0],t[1]],self.timeIntegration.t)
self.ebqe[('advectiveFlux_bc_flag',ci)][t[0],t[1]] = 1
for ck,diffusiveFluxBoundaryConditionsDict in fbcObject.diffusiveFluxBoundaryConditionsDictDict.iteritems():
self.ebqe[('diffusiveFlux_bc_flag',ck,ci)] = numpy.zeros(self.ebqe[('diffusiveFlux_bc',ck,ci)].shape,'i')
for t,g in diffusiveFluxBoundaryConditionsDict.iteritems():
self.ebqe[('diffusiveFlux_bc',ck,ci)][t[0],t[1]] = g(self.ebqe[('x')][t[0],t[1]],self.timeIntegration.t)
self.ebqe[('diffusiveFlux_bc_flag',ck,ci)][t[0],t[1]] = 1
self.numericalFlux.setDirichletValues(self.ebqe)
if self.movingDomain:
self.MOVING_DOMAIN=1.0
else:
#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
if self.coefficients.useConstantH:
self.elementDiameter = self.mesh.elementDiametersArray.copy()
self.elementDiameter[:] = max(self.mesh.elementDiametersArray)
else:
self.elementDiameter = self.mesh.elementDiametersArray
self.mcorr = cMCorr_base(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)
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
log(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)
log(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()
#TODO get rid of this
# for ci,fbcObject in self.fluxBoundaryConditionsObjectsDict.iteritems():
# self.ebqe[('advectiveFlux_bc_flag',ci)] = numpy.zeros(self.ebqe[('advectiveFlux_bc',ci)].shape,'i')
# for t,g in fbcObject.advectiveFluxBoundaryConditionsDict.iteritems():
# if self.coefficients.advection.has_key(ci):
# self.ebqe[('advectiveFlux_bc',ci)][t[0],t[1]] = g(self.ebqe[('x')][t[0],t[1]],self.timeIntegration.t)
# self.ebqe[('advectiveFlux_bc_flag',ci)][t[0],t[1]] = 1
if hasattr(self.numericalFlux,'setDirichletValues'):
self.numericalFlux.setDirichletValues(self.ebqe)
if not hasattr(self.numericalFlux,'isDOFBoundary'):
self.numericalFlux.isDOFBoundary = {0:numpy.zeros(self.ebqe[('u',0)].shape,'i')}
if not hasattr(self.numericalFlux,'ebqe'):
self.numericalFlux.ebqe = {('u',0):numpy.zeros(self.ebqe[('u',0)].shape,'d')}
#TODO how to handle redistancing calls for calculateCoefficients,calculateElementResidual etc
self.globalResidualDummy = None
#penalty term
#cek move to Numerical flux initialization
if 'penalty' in self.ebqe:
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] = old_div(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()
#TODO get rid of this
for ci,fbcObject in list(self.fluxBoundaryConditionsObjectsDict.items()):
self.ebqe[('advectiveFlux_bc_flag',ci)] = numpy.zeros(self.ebqe[('advectiveFlux_bc',ci)].shape,'i')
for t,g in list(fbcObject.advectiveFluxBoundaryConditionsDict.items()):
if ci in self.coefficients.advection:
self.ebqe[('advectiveFlux_bc',ci)][t[0],t[1]] = g(self.ebqe[('x')][t[0],t[1]],self.timeIntegration.t)
self.ebqe[('advectiveFlux_bc_flag',ci)][t[0],t[1]] = 1
if hasattr(self.numericalFlux,'setDirichletValues'):
self.numericalFlux.setDirichletValues(self.ebqe)
if not hasattr(self.numericalFlux,'isDOFBoundary'):
self.numericalFlux.isDOFBoundary = {0:numpy.zeros(self.ebqe[('u',0)].shape,'i')}
if not hasattr(self.numericalFlux,'ebqe'):
self.numericalFlux.ebqe = {('u',0):numpy.zeros(self.ebqe[('u',0)].shape,'d')}
for ebN in range(self.mesh.nElementBoundaries_global):
for k in range(self.nElementBoundaryQuadraturePoints_elementBoundary):
self.ebq_global['penalty'][ebN,k] = old_div(self.numericalFlux.penalty_constant,(self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power))
#penalty term
#cek move to Numerical flux initialization
if 'penalty' in self.ebqe:
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] = old_div(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
#helper for writing out data storage
self.elementQuadratureDictionaryWriter = Archiver.XdmfWriter()
self.elementBoundaryQuadratureDictionaryWriter = Archiver.XdmfWriter()
self.exteriorElementBoundaryQuadratureDictionaryWriter = Archiver.XdmfWriter()
for ci,sbcObject in list(self.stressFluxBoundaryConditionsObjectsDict.items()):
self.ebqe[('stressFlux_bc_flag',ci)] = np.zeros(self.ebqe[('stressFlux_bc',ci)].shape,'i')
for t,g in list(sbcObject.stressFluxBoundaryConditionsDict.items()):
self.ebqe[('stressFlux_bc',ci)][t[0],t[1]] = g(self.ebqe[('x')][t[0],t[1]],self.timeIntegration.t)
self.ebqe[('stressFlux_bc_flag',ci)][t[0],t[1]] = 1
self.numericalFlux.setDirichletValues(self.ebqe)
self.forceStrongConditions=False
self.dirichletConditionsForceDOF = {}
if self.forceStrongConditions:
for cj in range(self.nc):
self.dirichletConditionsForceDOF[cj] = DOFBoundaryConditions(self.u[cj].femSpace,dofBoundaryConditionsSetterDict[cj],weakDirichletConditions=False)
compKernelFlag=0
self.elastoPlastic = cElastoPlastic_base(self.nSpace_global,
self.nQuadraturePoints_element,
self.u[0].femSpace.elementMaps.localFunctionSpace.dim,
self.ebq[('w', 0)] = self.tmpvt.ebq[('w', 0)]
self.ebq['sqrt(det(g))'] = self.tmpvt.ebq['sqrt(det(g))']
self.ebq['n'] = self.tmpvt.ebq['n']
self.ebq[('dS_u', 0)] = self.tmpvt.ebq[('dS_u', 0)]
self.ebqe['dS'] = self.tmpvt.ebqe['dS']
self.ebqe['n'] = self.tmpvt.ebqe['n']
self.ebq_global['n'] = self.tmpvt.ebq_global['n']
self.ebq_global['x'] = self.tmpvt.ebq_global['x']
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()
for ci, fbcObject in list(self.fluxBoundaryConditionsObjectsDict.items()):
self.ebqe[('advectiveFlux_bc_flag', ci)] = np.zeros(self.ebqe[('advectiveFlux_bc', ci)].shape, 'i')
for t, g in list(fbcObject.advectiveFluxBoundaryConditionsDict.items()):
if ci in self.coefficients.advection:
self.ebqe[('advectiveFlux_bc', ci)][t[0], t[1]] = g(self.ebqe[('x')][t[0], t[1]], self.timeIntegration.t)
self.ebqe[('advectiveFlux_bc_flag', ci)][t[0], t[1]] = 1
for ck, diffusiveFluxBoundaryConditionsDict in list(fbcObject.diffusiveFluxBoundaryConditionsDictDict.items()):
self.ebqe[('diffusiveFlux_bc_flag', ck, ci)] = np.zeros(self.ebqe[('diffusiveFlux_bc', ck, ci)].shape, 'i')
for t, g in list(diffusiveFluxBoundaryConditionsDict.items()):
self.ebqe[('diffusiveFlux_bc', ck, ci)][t[0], t[1]] = g(self.ebqe[('x')][t[0], t[1]], self.timeIntegration.t)
self.ebqe[('diffusiveFlux_bc_flag', ck, ci)][t[0], t[1]] = 1
# self.numericalFlux.setDirichletValues(self.ebqe)
if self.movingDomain:
self.MOVING_DOMAIN = 1.0
else:
self.MOVING_DOMAIN = 0.0