Esempio n. 1
0
#-------------------------------------------------------------------------------
# Master import file to import the Spheral packages and a standard set of
# helper extensions, including the optional solid material and strength
# extensions.
#-------------------------------------------------------------------------------
from Spheral import *
from SpheralModules.Spheral.SolidMaterial import *
from SolidNodeLists import *
from GradyKippTensorDamage import *
from SolidSPHHydros import *
from SolidSPHHydrosRZ import *

from spheralDimensions import spheralDimensions
dims = spheralDimensions()

from spheralDimensions import spheralDimensions
if 2 in spheralDimensions():
    from SolidSPHHydrosRZ import *
    from SolidCRKSPHHydrosRZ import *

# ------------------------------------------------------------------------------
# Import the SolidMaterial python extensions.
# ------------------------------------------------------------------------------
from SolidMaterialUnits import *
from SolidMaterialEquationsOfState import *

# ------------------------------------------------------------------------------
# Import our shadow layers for augmenting C++ types.
# ------------------------------------------------------------------------------
for shadowedthing in ("TillotsonEquationOfState", "ConstantStrength"):
    for dim in dims:
Esempio n. 2
0
#------------------------------------------------------------------------------
# A simple class to control simulation runs for Spheral.
#------------------------------------------------------------------------------
import sys, os, gc, warnings, mpi

from SpheralCompiledPackages import *
from SpheralTimer import SpheralTimer
from SpheralConservation import SpheralConservation
from GzipFileIO import GzipFileIO
from SpheralTestUtilities import globalFrame
from NodeGeneratorBase import ConstantRho
from findLastRestart import findLastRestart

from spheralDimensions import spheralDimensions
dims = spheralDimensions()


class SpheralController:

    #--------------------------------------------------------------------------
    # Constuctor.
    #--------------------------------------------------------------------------
    def __init__(self,
                 integrator,
                 kernel,
                 statsStep=1,
                 printStep=1,
                 garbageCollectionStep=100,
                 redistributeStep=None,
                 restartStep=None,
                 restartBaseName="restart",
Esempio n. 3
0
def __JohnsonCookDamageFactory(nodeList, D1, D2, D3, D4, D5, epsilondot0,
                               Tcrit, sigmamax, efailmin, domainIndependent,
                               D1method, D2method):

    # What dimension are we?
    assert nodeList.__class__.__name__ in ("SolidNodeList1d",
                                           "SolidNodeList2d",
                                           "SolidNodeList3d")
    ndim = int(nodeList.__class__.__name__[-2:-1])
    assert ndim in spheralDimensions()

    # Import the approprite bits of Spheral.
    exec("""
from SpheralCompiledPackages import JohnsonCookDamage%(ndim)sd as JohnsonCookDamage
from SpheralCompiledPackages import ScalarField%(ndim)sd as ScalarField
from SpheralCompiledPackages import DataBase%(ndim)sd as DataBase
from SpheralCompiledPackages import nodeOrdering%(ndim)sd as nodeOrdering
from SpheralCompiledPackages import mortonOrderIndices%(ndim)sd as mortonOrderIndices
""" % {"ndim": ndim})

    # Prepare the fields for D1 and D2
    fD1 = ScalarField("D1", nodeList, D1)
    fD2 = ScalarField("D2", nodeList, D2)

    # Now fill in the D1 and D2 fields using "D1method" and "D2method" to generate the values.
    # Are we generating domain-independent?
    if domainIndependent:

        # Assign a unique ordering to the nodes so we can step through them
        # in a domain independent manner.
        db = DataBase()
        db.appendNodeList(nodeList)
        keyList = mortonOrderIndices(db)
        orderingList = nodeOrdering(keyList)
        assert orderingList.numFields == 1
        ordering = orderingList[0]
        nglobal = max(0, ordering.max() + 1)

        # Reverse lookup in the ordering.
        order2local = [ordering[i] for i in xrange(nodeList.numInternalNodes)]

        # Generate random numbers in batches.
        iglobal = 0
        nbatch = max(1, nglobal / mpi.procs)
        for iproc in xrange(mpi.procs):
            if iproc == mpi.procs - 1:
                nlocal = nglobal - iglobal
            else:
                nlocal = nbatch
            D1vals = D1method(nlocal)
            D2vals = D2method(nlocal)
            for i in xrange(nlocal):
                try:
                    j = order2local.index(iglobal + i)
                    fD1[j] = D1vals[i]
                    fD2[j] = D2vals[i]
                except ValueError:
                    pass
            iglobal += nlocal

    else:

        # In the non-domain independent case we can generate more quickly in parallel.
        D1vals = D1method(nodeList.numInternalNodes)
        D2vals = D2method(nodeList.numInternalNodes)
        for i in xrange(nodeList.numInternalNodes):
            fD1[i] = vals[i]
            fD2[i] = vals[i]

    # Now we build and and return the damage model.
    return JohnsonCookDamage(nodeList, fD1, fD2, D3, D4, D5, epsilondot0,
                             Tcrit, sigmamax, efailmin)