Exemple #1
0
def viz(fields = [],
        filename = "RubberBalls-3d"):
    dumpPhysicsState(integrator,
                     filename,
                     visitDir,
                     fields = fields,
                     )
def viz(fields=[], filename="ExpandingTube-3d"):
    tdamage = nodesSteel.damage()
    etdamage = nodesSteel.effectiveDamage()
    tstrain = damageModel.strain()
    etstrain = damageModel.effectiveStrain()
    sdamage = ScalarField("damage magnitude", nodesSteel)
    mindamage = ScalarField("damage magnitude min", nodesSteel)
    maxdamage = ScalarField("damage magnitude max", nodesSteel)
    esdamage = ScalarField("effective damage magnitude", nodesSteel)
    minedamage = ScalarField("effective damage magnitude min", nodesSteel)
    maxedamage = ScalarField("effective damage magnitude max", nodesSteel)
    sstrain = ScalarField("strain average", nodesSteel)
    esstrain = ScalarField("effective strain average", nodesSteel)
    for i in xrange(nodesSteel.numInternalNodes):
        sdamage[i] = tdamage[i].Trace()
        esdamage[i] = etdamage[i].Trace()
        ev = tdamage[i].eigenValues()
        eev = etdamage[i].eigenValues()
        maxdamage[i] = ev.maxElement()
        mindamage[i] = ev.minElement()
        maxedamage[i] = eev.maxElement()
        minedamage[i] = eev.minElement()
        sstrain[i] = tstrain[i].Trace() / 3.0
        esstrain[i] = etstrain[i].Trace() / 3.0
    dumpPhysicsState(
        integrator,
        filename,
        visitDir,
        fields=[
            damageModel.sumActivationEnergiesPerNode(),
            damageModel.numFlawsPerNode(), sdamage, mindamage, maxdamage,
            esdamage, minedamage, maxedamage, sstrain, esstrain
        ] + [x.nodeFlags for x in (VISARa, VISARb, VISARc)] + fields,
    )
Exemple #3
0
def viz(nodes, nodesDamaged, damageModel):
    if isinstance(damageModel, TensorDamageModel3d):
        tdamage = damageModel.damage()
        tstrain = damageModel.strain()
        sdamage = ScalarField3d("damage magnitude", nodes)
        sdamagemin = ScalarField3d("damage magnitude min", nodes)
        sdamagemax = ScalarField3d("damage magnitude max", nodes)
        sstrain = ScalarField3d("strain average", nodes)
        sstrainmin = ScalarField3d("strain min", nodes)
        sstrainmax = ScalarField3d("strain max", nodes)
        for i in xrange(nodes.numInternalNodes):
            sdamage[i] = tdamage[i].Trace()
            sdamagemin[i] = tdamage[i].eigenValues().minElement()
            sdamagemax[i] = tdamage[i].eigenValues().maxElement()
            sstrain[i] = tstrain[i].Trace() / 2.0
            sstrainmin[i] = tstrain[i].eigenValues().minElement()
            sstrainmax[i] = tstrain[i].eigenValues().maxElement()
        dumpPhysicsState(
            integrator,
            "TensileDisk-3d-visit",
            visitDir,
            fields=[
                damageModel.sumActivationEnergiesPerNode(),
                damageModel.numFlawsPerNode(),
                sdamage,
                sdamagemin,
                sdamagemax,
                sstrain,
                sstrainmin,
                sstrainmax,
                #ufragIndex
            ])

    else:
        raise "We need to add support for your damage model to the viz() function."
def viz(fields = [],
        filename = "ExpandingTube-rz"):
    damage = damageModel.damage()
    dtrace = ScalarField3d("damage magnitude", nodesSteel)
    dmin = ScalarField3d("damage min", nodesSteel)
    dmax = ScalarField3d("damage max", nodesSteel)
    strain = damageModel.strain()
    svol = ScalarField3d("strain vol", nodesSteel)
    smin = ScalarField3d("strain min", nodesSteel)
    smax = ScalarField3d("strain max", nodesSteel)
    for i in xrange(nodesSteel.numInternalNodes):
        dtrace[i] = damage[i].Trace()
        dev = damage[i].eigenValues()
        dmin[i] = dev.minElement()
        dmax[i] = dev.maxElement()
        svol[i] = strain[i].Trace()
        sev = strain[i].eigenValues()
        smin[i] = sev.minElement()
        smax[i] = sev.maxElement()
    dumpPhysicsState(integrator,
                     filename,
                     visitDir,
                     fields = [damageModel.sumActivationEnergiesPerNode(),
                               damageModel.numFlawsPerNode(),
                               VISARa.nodeFlags,
                               VISARb.nodeFlags,
                               VISARc.nodeFlags,
                               dtrace,
                               dmin,
                               dmax,
                               svol,
                               smin,
                               smax] + fields,
                     )
Exemple #5
0
def viz(nodes, nodesDamaged, damageModel):
    if isinstance(damageModel, TensorDamageModel2d):
        tdamage = nodes.damage()
        tstrain = damageModel.effectiveStrain()
        vr = ScalarField2d("radial velocity", nodes)
        sdamage = ScalarField2d("damage magnitude", nodes)
        sdamagemin = ScalarField2d("damage magnitude min", nodes)
        sdamagemax = ScalarField2d("damage magnitude max", nodes)
        sstrain = ScalarField2d("strain average", nodes)
        sstrainmin = ScalarField2d("strain min", nodes)
        sstrainmax = ScalarField2d("strain max", nodes)
        for i in xrange(nodes.numInternalNodes):
            runit = nodes.positions()[i].unitVector()
            vr[i] = nodes.velocity()[i].dot(runit)
            sdamage[i] = tdamage[i].Trace()
            sdamagemin[i] = tdamage[i].eigenValues().minElement()
            sdamagemax[i] = tdamage[i].eigenValues().maxElement()
            sstrain[i] = tstrain[i].Trace() / 2.0
            sstrainmin[i] = tstrain[i].eigenValues().minElement()
            sstrainmax[i] = tstrain[i].eigenValues().maxElement()
        dumpPhysicsState(
            integrator,
            "TensileDisk-2d-visit",
            visitDir,
            fields=[
                vr,
                damageModel.sumActivationEnergiesPerNode(),
                damageModel.numFlawsPerNode(),
                sdamage,
                sdamagemin,
                sdamagemax,
                sstrain,
                sstrainmin,
                sstrainmax,
                #ufragIndex
            ])

    else:
        raise "We need to add support for your damage model to the viz() function."
Exemple #6
0
restartBaseName = '%s/%s' % (restartDir, simName)
control = SpheralController(integrator,
                            WT,
                            statsStep=statsStep,
                            initializeMassDensity=True,
                            restartBaseName=restartBaseName)
output("control")
#print 'max |div B| (0):', maxDivB0

# Restore if desired.
if restoreCycle is not None:
    if restoreCycle == -1:
        restoreCycle = findLastRestart(simName)
    control.loadRestartFile(restoreCycle)
else:
    dumpPhysicsState(integrator, simName, visitDir, dumpDerivatives=True)

output("integrator.dtGrowth")
# If we're using a projection scheme to clean div B, advance one step and
# read off our diagnostics.
if mhd.divBCleaner == MHD.BDivergenceCleanerType.GreensFnProjCleaner or \
   mhd.divBCleaner == MHD.BDivergenceCleanerType.BiotSavartProjCleaner:
    control.advance(control.time() + 1e-10, 1)
    maxDivB1 = max(mhd.maxDivB(), abs(mhd.minDivB()))

# Otherwise, go get 'em!
else:
    while control.time() < goalTime:
        dt = goalTime / 10
        control.advance(min(goalTime, control.time() + dt), maxSteps)
        control.dropRestartFile()
#-------------------------------------------------------------------------------
if restoreCycle is not None:
    control.loadRestartFile(restoreCycle)
else:
    control.smoothState(smoothIters)

    # Viz the initial conditions.
    vx = ScalarField2d("x velocity", nodes)
    vy = ScalarField2d("y velocity", nodes)
    for i in xrange(nodes.numInternalNodes):
        vx[i] = nodes.velocity()[i].x
        vy[i] = nodes.velocity()[i].y
    dumpPhysicsState(integrator,
                     "TensileRod-2d-visit",
                     "dumps-specifiedFlaws-2d",
                     fields = [vx, vy,
                               damageModel.sumActivationEnergiesPerNode(),
                               damageModel.numFlawsPerNode()]
                     )

#-------------------------------------------------------------------------------
# Advance to the end time.
#-------------------------------------------------------------------------------
while control.time() < goalTime:
    nextGoalTime = min(control.time() + dtSample, goalTime)
    control.advance(nextGoalTime, maxSteps)
    control.dropRestartFile()

    # Viz the current state.
    vx = ScalarField2d("x velocity", nodes)
    vy = ScalarField2d("y velocity", nodes)
Exemple #8
0
output("integrator.dtMax")
output("integrator.dtGrowth")

#-------------------------------------------------------------------------------
# Build the controller.
#-------------------------------------------------------------------------------
control = SpheralController(integrator,
                            WT,
                            statsStep=statsStep,
                            initializeMassDensity=True)
integrator.setCurrentTime(t1)
output("control")

# Initial dump.
dumpPhysicsState(integrator,
                 "Zeldovich-pancake-SPH-%ix%ix%i-visit" % (nx, ny, nz),
                 visitDir)

#-------------------------------------------------------------------------------
# Advance.
#-------------------------------------------------------------------------------
#nextGoalTime = min(control.time() + dtSample, goalTime)
print 'Running from t = %g to %g' % (t1, t2)
control.advance(t2, 1000)
dumpPhysicsState(integrator,
                 "Zeldovich-pancake-SPH-%ix%ix%i-visit" % (nx, ny, nz),
                 visitDir)
D = gravity.matrix()
psi = gravity.potential()[0]
acc = nodes.DvelocityDt()
Exemple #9
0
#-------------------------------------------------------------------------------
control = SpheralController(integrator,
                            WT,
                            statsStep=statsStep,
                            restartStep=restartStep,
                            restartBaseName=restartBaseName)
output("control")

# Smooth the initial conditions.
if restoreCycle is not None:
    control.loadRestartFile(restoreCycle)
else:
    control.iterateIdealH()
    control.smoothState(smoothIters)
    control.dropRestartFile()
    dumpPhysicsState(integrator, "icf-2d", visitDir)

#-------------------------------------------------------------------------------
# Advance to the end time.
#-------------------------------------------------------------------------------
hstats(nodeSet)
while control.time() < goalTime:
    nextGoalTime = min(control.time() + dtSample, goalTime)
    control.advance(nextGoalTime, maxSteps)
    control.dropRestartFile()
    dumpPhysicsState(integrator, "icf-2d", visitDir)

#-------------------------------------------------------------------------------
# Plot the results.
#-------------------------------------------------------------------------------
if graphics:
Exemple #10
0
output("integrator.dtMax")
output("integrator.dtGrowth")

#-------------------------------------------------------------------------------
# Build the controller.
#-------------------------------------------------------------------------------
control = SpheralController(integrator, WT,
                            statsStep = statsStep,
                            initializeMassDensity = True)
integrator.setCurrentTime(t1)
integrator.setVerbose(1)
plotter = Plotter(gravity, nodes)
if plotEvery is not None:
   control.appendPeriodicWork(plotter, plotEvery)
output("control")

# Initial dump.
if os.path.exists(visitDir):
   import shutil
   shutil.rmtree(visitDir)
dumpPhysicsState(integrator, dumpName, visitDir)

#-------------------------------------------------------------------------------
# Advance.
#-------------------------------------------------------------------------------
print 'Running from t = %g to %g'%(t1, t2)
control.advance(t2, maxSteps)
dumpPhysicsState(integrator, dumpName, visitDir)
psi = gravity.potential()[0]
acc = nodes.DvelocityDt()