Ejemplo n.º 1
0
def save_xdmfs(step, time):

    #define any NN interps we'll need
    ix1, weights1, d1 = nn_evaluation(swarm.particleCoordinates.data,
                                      mesh.data,
                                      n=5,
                                      weighted=True)

    #rebuild any mesh vars that are not self-updating
    viscosityField.data[:,
                        0] = np.average(viscosityMapFn.evaluate(swarm)[:,
                                                                       0][ix1],
                                        weights=weights1,
                                        axis=len((weights1.shape)) - 1)
    strainRateField.data[:] = strainRate_2ndInvariant.evaluate(mesh)

    fullpath = os.path.join(outputPath + "xdmf/")
    #if not os.path.exists(fullpath+"mesh.h5"):
    #    _mH = mesh.save(fullpath+"mesh.h5")

    try:
        _mH
    except:
        _mH = mesh.save(fullpath + "mesh.h5")

    #Part 1
    mh = _mH
    vH = velocityField.save(fullpath + "velocity_" + str(step) + ".h5")
    tH = temperatureField.save(fullpath + "temp_" + str(step) + ".h5")
    srH = strainRateField.save(fullpath + "strainrate_" + str(step) + ".h5")
    viscH = viscosityField.save(fullpath + "visc_" + str(step) + ".h5")

    #part2

    velocityField.xdmf(fullpath + "velocity_" + str(step),
                       vH,
                       'velocity',
                       mh,
                       'mesh',
                       modeltime=time)
    temperatureField.xdmf(fullpath + "temp_" + str(step),
                          tH,
                          'temperature',
                          mh,
                          'mesh',
                          modeltime=time)
    strainRateField.xdmf(fullpath + "strainrate_" + str(step),
                         srH,
                         'strainrate',
                         mh,
                         'mesh',
                         modeltime=time)
    viscosityField.xdmf(fullpath + "visc_" + str(step),
                        viscH,
                        'visc',
                        mh,
                        'mesh',
                        modeltime=time)
Ejemplo n.º 2
0
def save_files():

    #update info
    ix1, weights1, d1 = nn_evaluation(swarm.particleCoordinates.data,
                                      markerEvalFault.particleCoordinates.data,
                                      n=5,
                                      weighted=True)

    faultPoints = uw.swarm.SwarmVariable(markerEvalFault, 'double', 2)
    faultVisc = uw.swarm.SwarmVariable(markerEvalFault, 'double', 1)
    faultSr = uw.swarm.SwarmVariable(markerEvalFault, 'double', 1)
    faultVelMag = uw.swarm.SwarmVariable(markerEvalFault, 'double', 1)

    faultPoints.data[:] = markerEvalFault.particleCoordinates.data
    if len(weights1):
        faultVisc.data[:,
                       0] = np.average(viscosityMapFn.evaluate(swarm)[:,
                                                                      0][ix1],
                                       weights=weights1,
                                       axis=len((weights1.shape)) - 1)
    faultSr.data[:] = strainRate_2ndInvariant.evaluate(markerEvalFault)
    faultVelMag.data[:] = velMagFn.evaluate(markerEvalFault)

    #use a weighted interpolation

    ix2, weights2, d2 = nn_evaluation(
        swarm.particleCoordinates.data,
        markerEvalMantle.particleCoordinates.data,
        n=5,
        weighted=True)

    mantlePoints = uw.swarm.SwarmVariable(markerEvalMantle, 'double', 2)
    mantleVisc = uw.swarm.SwarmVariable(markerEvalMantle, 'double', 1)
    mantleSr = uw.swarm.SwarmVariable(markerEvalMantle, 'double', 1)
    mantleVelMag = uw.swarm.SwarmVariable(markerEvalMantle, 'double', 1)

    mantlePoints.data[:] = markerEvalMantle.particleCoordinates.data
    if len(weights2):
        mantleVisc.data[:,
                        0] = np.average(viscosityMapFn.evaluate(swarm)[:,
                                                                       0][ix2],
                                        weights=weights2,
                                        axis=len((weights2.shape)) - 1)
    mantleSr.data[:] = strainRate_2ndInvariant.evaluate(markerEvalMantle)
    mantleVelMag.data[:] = velMagFn.evaluate(markerEvalMantle)

    #Save the files:
    fullpath = os.path.join(outputPath + "files/")
    #fault
    step = 'xx'

    faultPoints.save(fullpath + "faultPoints" + str(step).zfill(2))
    faultVisc.save(fullpath + "faultVisc" + str(step).zfill(2))
    faultSr.save(fullpath + "faultSr" + str(step).zfill(2))
    faultVelMag.save(fullpath + "faultVelMag" + str(step).zfill(2))

    #fault
    mantlePoints.save(fullpath + "mantlePoints" + str(step).zfill(2))
    mantleVisc.save(fullpath + "mantleVisc" + str(step).zfill(2))
    mantleSr.save(fullpath + "mantleSr" + str(step).zfill(2))
    mantleVelMag.save(fullpath + "mantleVelMag" + str(step).zfill(2))
Ejemplo n.º 3
0
# In[23]:

proxyTempVariable = uw.swarm.SwarmVariable(swarm, 'double', 1)

conditions = [(upperLowerVar > 0,
               fn.math.erf((distFn) / (2. * np.sqrt(1. * ndp.opAge)))),
              (True, fn.math.erf((distFn) / (2. * np.sqrt(1. * ndp.slabAge))))]

tempFn = fn.branching.conditional(conditions)

proxyTempVariable.data[:] = tempFn.evaluate(swarm)

# In[24]:

ix0, weights0, d0 = nn_evaluation(swarm.particleCoordinates.data,
                                  mesh.data,
                                  n=200,
                                  weighted=False)

temperatureField.data[:, 0] = np.average(tempFn.evaluate(swarm)[:, 0][ix0],
                                         weights=weights0,
                                         axis=len((weights0.shape)) - 1)

initialtemperatureField.data[:, 0] = np.average(tempFn.evaluate(swarm)[:,
                                                                       0][ix0],
                                                weights=weights0,
                                                axis=len((weights0.shape)) - 1)

# ## Mesh deformation
#
# Here I use proximity to a marker line to define nodes to adjust. The nodes effectivey sit right on yhe marker line and become the nodes we impose velocity on.
#
Ejemplo n.º 4
0
# In[28]:

proxyTempVariable = uw.swarm.SwarmVariable(swarm, 'double', 1)

conditions = [(upperLowerVar > 0,
               fn.math.erf((distFn) / (2. * np.sqrt(1. * ndp.opAge)))),
              (True, fn.math.erf((distFn) / (2. * np.sqrt(1. * ndp.slabAge))))]

tempFn = fn.branching.conditional(conditions)

proxyTempVariable.data[:] = tempFn.evaluate(swarm)

# In[29]:

ix0, weights0, d0 = nn_evaluation(swarm.particleCoordinates.data,
                                  mesh.data,
                                  n=200,
                                  weighted=False)

temperatureField.data[:, 0] = np.average(tempFn.evaluate(swarm)[:, 0][ix0],
                                         weights=weights0,
                                         axis=len((weights0.shape)) - 1)

initialtemperatureField.data[:, 0] = np.average(tempFn.evaluate(swarm)[:,
                                                                       0][ix0],
                                                weights=weights0,
                                                axis=len((weights0.shape)) - 1)

# ## Mesh deformation
#
# Here I use proximity to a marker line to define nodes to adjust.
#