def test_brickReadMesh(self):
   fname=os.path.join(FINLEY_TEST_MESH_PATH,'brick_4x4x4.fly')
   self.assertRaises(ValueError, ReadMesh, fname, diracPoints=[(0,0)])
   self.assertRaises(ValueError, ReadMesh, fname, diracPoints=[(0,0,0)])
   self.assertRaises(ValueError, ReadMesh, fname, diracPoints=[(0,0,0), (1,1,1)], diracTags=[40])
   self.assertRaises(ValueError, ReadMesh, fname, diracPoints=[(0,0,0), (1,1,1)], diracTags=["cows"])
   z=ReadMesh(fname, diracPoints=[(0,0,1), (0.25,0.25, 0.25)], diracTags=[40,51])
   z=ReadMesh(fname, diracPoints=[(0.125,0.625,0), (0.5,1,1), (0.75, 0.25,0), (0.89, 0.875, 0.5)], diracTags=["A", "B", "A", "C"])
   v=interpolate(z.getX(), DiracDeltaFunctions(z))
   if mpisize==1:
     self.assertEqual(v.toListOfTuples(),[(0.0, 0.5, 0.0), (0.5, 1.0, 1.0), (0.75, 0.25, 0.0), (1.0, 0.75, 0.5)])
     self.assertEqual(v.getNumberOfDataPoints(), 4)
     self.assertEqual(inf(v[0]), 0)
     self.assertEqual(inf(v[1]), 0.25)
     self.assertEqual(Lsup(v[0]), 1)
     self.assertEqual(Lsup(v[1]), 1)
   v.setTaggedValue("A",(-10,0.5,-0.5))
   if mpisize==1:
     self.assertEqual(inf(v[0]), -10)
     self.assertEqual(inf(v[1]), 0.5)
     self.assertEqual(inf(v[2]), -0.5)
   v.setTaggedValue(500,(-100,-100, -100))     # non-existant tag
   if mpisize==1:
     self.assertEqual(inf(v[0]), -10)
     self.assertEqual(inf(v[1]), 0.5)
     self.assertEqual(inf(v[2]), -0.5)
   self.assertEqual(z.showTagNames(), 'A, B, C, back, bottom, front, left, right, top')
   self.assertEqual(z.getTag("C"), 203)
Example #2
0
 def test_brickReadMesh(self):
   fname=os.path.join(FINLEY_TEST_MESH_PATH,'brick_4x4x4.fly')
   self.assertRaises(ValueError, ReadMesh, fname, diracPoints=[(0,0)])
   self.assertRaises(ValueError, ReadMesh, fname, diracPoints=[(0,0,0)])
   self.assertRaises(ValueError, ReadMesh, fname, diracPoints=[(0,0,0), (1,1,1)], diracTags=[40])
   self.assertRaises(ValueError, ReadMesh, fname, diracPoints=[(0,0,0), (1,1,1)], diracTags=["cows"])
   z=ReadMesh(fname, diracPoints=[(0,0,1), (0.25,0.25, 0.25)], diracTags=[40,51])
   z=ReadMesh(fname, diracPoints=[(0.125,0.625,0), (0.5,1,1), (0.75, 0.25,0), (0.89, 0.875, 0.5)], diracTags=["A", "B", "A", "C"])
   v=interpolate(z.getX(), DiracDeltaFunctions(z))
   if mpisize==1:
     self.assertEqual(v.toListOfTuples(),[(0.0, 0.5, 0.0), (0.5, 1.0, 1.0), (0.75, 0.25, 0.0), (1.0, 0.75, 0.5)])
     self.assertEqual(v.getNumberOfDataPoints(), 4)
     self.assertEqual(inf(v[0]), 0)
     self.assertEqual(inf(v[1]), 0.25)
     self.assertEqual(Lsup(v[0]), 1)
     self.assertEqual(Lsup(v[1]), 1)
   v.setTaggedValue("A",(-10,0.5,-0.5))
   if mpisize==1:
     self.assertEqual(inf(v[0]), -10)
     self.assertEqual(inf(v[1]), 0.5)
     self.assertEqual(inf(v[2]), -0.5)
   v.setTaggedValue(500,(-100,-100, -100))     # non-existant tag
   if mpisize==1:
     self.assertEqual(inf(v[0]), -10)
     self.assertEqual(inf(v[1]), 0.5)
     self.assertEqual(inf(v[2]), -0.5)
   self.assertEqual(z.showTagNames(), 'A, B, C, back, bottom, front, left, right, top')
   self.assertEqual(z.getTag("C"), 203)
Example #3
0
    for it in range(0, ls):
        t = it * h
        tt = t - t0
        dum1 = np.exp(-a * tt * tt)
        source[it] = -2. * a * tt * dum1
        if (abs(source[it]) > ampmax):
            ampmax = abs(source[it])
        time[it] = t * h

    # will introduce a spherical source at middle left of bottom face
    xc = [mx / 2, my / 2, 0]

    ####################################################DOMAIN CONSTRUCTION
    domain = ReadMesh(os.path.join(meshpath,
                                   'example09lc.fly'))  # create the domain
    x = domain.getX()  # get the locations of the nodes in the domain

    lam = Scalar(0, Function(domain))
    mu = Scalar(0, Function(domain))
    rho = Scalar(0, Function(domain))

    #Setting parameters for each layer in the model.
    for i in range(0, nlayers):
        rho.setTaggedValue("volume_%d" % i, rhoc + i * 100.)
        lamc = (vel + i * 100.)**2. * (rhoc + i * 100.) / 2.
        muc = (vel + i * 100.)**2. * (rhoc + i * 100.) / 4.
        lam.setTaggedValue("volume_%d" % i, lamc)
        mu.setTaggedValue("volume_%d" % i, muc)

    ##########################################################ESTABLISH PDE
    mypde = LinearPDE(domain)  # create pde
Example #4
0
         return  self.__pde_u.getSolution()

      def solve_g(self,u,tol=1.e-8):
         dp=Vector(0.,FunctionOnContactZero(self.domain))
         h=FunctionOnContactZero(self.domain).getSize()
         # print jump(u)-self.slip
         dp[0]=(self.slip[0]-jump(u[0]))*lam_mu/h
         dp[1]=(self.slip[1]-jump(u[1]))*lam_mu/h
         dp[2]=(self.slip[2]-jump(u[2]))*lam_mu/h
         return  dp


dom=ReadMesh("meshfault3D.fly",integrationOrder=-1)
prop=SlippingFault(dom)
d=dom.getDim()
x=dom.getX()[0]
# x=dom.getX()[d-1]
mask=whereZero(x-inf(x))*numpy.ones((d,))
x=FunctionOnContactZero(dom).getX()
s=numpy.array([-100000.,1.,1.])
for i in range(3):
     d=fend[i]-fstart[i]
     if d>0:
         q=(x[i]-fstart[i])/d
         s=q*(1-q)*4*s
     elif d<0:
         q=(x[i]-fend[i])/d
         s=q*(1-q)*4*s
u0=Vector(0.,Solution(dom))
p0=Vector(1.,FunctionOnContactZero(dom))
prop.initialize(fixed_u_mask=mask,slip=Data(s,FunctionOnContactZero(dom)), density=rho,lmbd=lam_lmbd, mu=lam_mu)
Example #5
0
DIP = 30 * U.DEG
N = 1  # boudary layer control

g = 9.81 * U.m / U.sec**2
#
#  derived values
#
dom = ReadMesh(MESHFILE)
DIM = dom.getDim()
bb = boundingBox(dom)
LX = bb[0][1] - bb[0][0]
if DIM == 3: LY = bb[1][1] - bb[1][0]
DEPTH = bb[DIM - 1][1] - bb[DIM - 1][0]

sc = StokesProblemCartesian(dom)
x = dom.getX()
#
v = Vector(0., Solution(dom))
mask = Vector(0., Solution(dom))
#
#  in subduction zone:
#

if DIM == 2:
    S = numpy.array([0., 0.])
    X0 = [bb[0][0], bb[1][1]]
    dd = [-cos(ALPHA), -sin(ALPHA)]
else:
    S = numpy.array([sin(STRIKE), cos(STRIKE), 0.])
    X0 = [bb[0][0], bb[1][0], bb[2][1]]
    dd = [-cos(ALPHA), 0., -sin(ALPHA)]
Example #6
0
N=1  # boudary layer control


g=9.81*U.m/U.sec**2
#
#  derived values
#
dom=ReadMesh(MESHFILE)
DIM=dom.getDim()
bb=boundingBox(dom)
LX=bb[0][1]-bb[0][0]
if DIM == 3: LY=bb[1][1]-bb[1][0]
DEPTH=bb[DIM-1][1]-bb[DIM-1][0]

sc=StokesProblemCartesian(dom)
x = dom.getX()
#
v=Vector(0.,Solution(dom))
mask=Vector(0.,Solution(dom))
#
#  in subduction zone:
#

if DIM==2: 
    S=numpy.array([0.,0.])
    X0=[bb[0][0],bb[1][1]]
    dd=[-cos(ALPHA),-sin(ALPHA)]
else:
    S=numpy.array([sin(STRIKE),cos(STRIKE),0.])
    X0=[bb[0][0],bb[1][0],bb[2][1]]
    dd=[-cos(ALPHA),0.,-sin(ALPHA)]
Example #7
0
    ampmax=0
    for it in range(0,ls):
        t = it*h
        tt = t-t0
        dum1 = np.exp(-a * tt * tt)
        source[it] = -2. * a * tt * dum1
        if (abs(source[it]) > ampmax):
            ampmax = abs(source[it])
        time[it]=t*h

    # will introduce a spherical source at middle left of bottom face
    xc=[mx/2,my/2,0]

    ####################################################DOMAIN CONSTRUCTION
    domain=ReadMesh(os.path.join(meshpath,'example09lc.fly')) # create the domain
    x=domain.getX() # get the locations of the nodes in the domain

    lam=Scalar(0,Function(domain))
    mu=Scalar(0,Function(domain))
    rho=Scalar(0,Function(domain))

    #Setting parameters for each layer in the model.
    for i in range(0,nlayers):
        rho.setTaggedValue("volume_%d"%i,rhoc+i*100.)
        lamc=(vel+i*100.)**2.*(rhoc+i*100.)/2.
        muc=(vel+i*100.)**2.*(rhoc+i*100.)/4.
        lam.setTaggedValue("volume_%d"%i,lamc)
        mu.setTaggedValue("volume_%d"%i,muc)

    ##########################################################ESTABLISH PDE
    mypde=LinearPDE(domain) # create pde
Example #8
0
        return self.__pde_u.getSolution()

    def solve_g(self, u, tol=1.e-8):
        dp = Vector(0., FunctionOnContactZero(self.domain))
        h = FunctionOnContactZero(self.domain).getSize()
        # print jump(u)-self.slip
        dp[0] = (self.slip[0] - jump(u[0])) * lam_mu / h
        dp[1] = (self.slip[1] - jump(u[1])) * lam_mu / h
        dp[2] = (self.slip[2] - jump(u[2])) * lam_mu / h
        return dp


dom = ReadMesh("meshfault3D.fly", integrationOrder=-1)
prop = SlippingFault(dom)
d = dom.getDim()
x = dom.getX()[0]
# x=dom.getX()[d-1]
mask = whereZero(x - inf(x)) * numpy.ones((d, ))
x = FunctionOnContactZero(dom).getX()
s = numpy.array([-100000., 1., 1.])
for i in range(3):
    d = fend[i] - fstart[i]
    if d > 0:
        q = (x[i] - fstart[i]) / d
        s = q * (1 - q) * 4 * s
    elif d < 0:
        q = (x[i] - fend[i]) / d
        s = q * (1 - q) * 4 * s
u0 = Vector(0., Solution(dom))
p0 = Vector(1., FunctionOnContactZero(dom))
prop.initialize(fixed_u_mask=mask,
Example #9
0
elocations=readElectrodeLocations(config.stationfile, delimiter=config.stationdelimiter)
if getMPIRankWorld() == 0:
    print("%s electrode locations read from %s."%(len(elocations), config.stationfile))

survey=readSurveyData(config.datafile, stations=elocations, usesStationCoordinates=config.usesStationCoordinates, columns=config.datacolumns, 
                     dipoleInjections=config.dipoleInjections, dipoleMeasurements=False, delimiter=config.datadelimiter, commend='#', printInfo=args.debug)
assert survey.getNumObservations()>0, "no data found."

# define region with fixed conductivity:
if isinstance(config.region_fixed , list):
    fixedm=MaskFromTag(domain, *tuple(config.region_fixed))
    if len(config.region_fixed)> 0 and getMPIRankWorld() == 0: 
        print("Tags of regions with fixed property function : %s"%(config.region_fixed) )
else:
    x=domain.getX()
    fixedm=whereZero(x[2]-inf(x[2]))
    del x
    if getMPIRankWorld() == 0: 
        print("Properties are fixed at the bottom of the domain.")

# define true properties if available:
if not config.true_properties is None:
    sigma_true, gamma_true = config.true_properties(domain)
    txt1, txt2 = str(sigma_true).replace("\n", ";"), str(gamma_true).replace("\n", ";")
    if getMPIRankWorld() == 0:
        print("True properties set:\n\tsigma = %s\n\tgamma = %s"%(txt1, txt2))
else:
    assert args.truesigma, 'If true conductivity is used true_properties must be set.'