Пример #1
0
fly.write("Tags\n")
fly.close()
mph.close()
print("escript file %s generated." % (args.fly))

if args.points:
    nodes = diracpoints['nodes']
    tags = diracpoints['tags']

    f = open(args.points, 'w')
    for k in range(len(tags)):
        idx = nodes[k][0]
        x = nodesX[idx, :]
        if sdim == 2:
            f.write("%d %g %g %g\n" % (tags[k], x[0], x[1], 0.))
        else:
            f.write("%d %g %g %g\n" % (tags[k], x[0], x[1], x[2]))

    f.close()
    print("source points have been written to " + args.points)

if args.silofile is not None:
    mesh = ReadMesh(args.fly)
    saveSilo(args.silofile, tags=makeTagField(ReducedFunction(mesh)))
    print(args.silofile + ".silo with tags has been generated.")

if args.points:
    print(
        "***WARNING: in COMSOL tags/ids for geometrical node IDs for sources are shown with an offset by 1 to the qIDs in the file. "
    )
Пример #2
0
    f.close()
    print(n, " measurement written to file " + config.datafile)

if args.silofile is not None:
    sigma_true.expand()
    gamma_true.expand()
    if args.plotA is not None:
        A = int(args.plotA)
    else:
        A = t[0]
    if args.plotB is not None:
        B = int(args.plotB)
    else:
        B = t[1]
    Es = secondary_field_field[A] - secondary_field_field[B]
    Es_hat = (secondary_field_field_hat[A] -
              secondary_field_field_hat[B]) / (1 - ETA0)
    E = primary_field_field[A] - primary_field_field[B] + Es
    gamma = inner(Es_hat, E) / inner(E, E)

    saveSilo(args.silofile,
             tag=makeTagField(ReducedFunction(domain)),
             sigma_true=sigma_true,
             gamma_true=gamma_true,
             gamma=gamma,
             Es=Es,
             Es_hat=Es_hat,
             E=E)
    print(args.silofile +
          ".silo with tags has been generated for injection [%d, %d]" % (A, B))
Пример #3
0


if args.query:
    sigma, potentials, dV=costf.getArguments(m)
    if getMPIRankWorld() == 0: 
        f=open(args.query,'w')
        for t in survey.tokenIterator(): # t=(A,B,M,N) (or so)
            f.write("%s, %e, %e\n"%(str(t)[1:-1], survey.getResistenceData(t), dV[t]))
        f.close()
        print("Data query/result file %s written."%args.query)
else:
    sigma=costf.getSigma(m)

if args.vtk:
    saveVTK(config.outfile, sigma=sigma, tag=makeTagField(Function(domain)))
    if getMPIRankWorld() == 0: 
        print("result written to %s.vtu"%config.outfile)
else:
    saveSilo(config.outfile, sigma=sigma, tag=makeTagField(Function(domain)))
    if getMPIRankWorld() == 0: 
            print("result written to %s.silo"%config.outfile)

if args.xyz:
    sigmas=interpolate(sigma, ReducedFunction(domain))
    X=sigmas.getFunctionSpace().getX()
    if isinstance(config.core, list):
        m=insertTaggedValues(Scalar(0., sigmas.getFunctionSpace()), **{ t: 1 for t in config.core })
        saveDataCSV(config.outfile+".csv", d0=X[0], d1=X[1], d2=X[2], sigma =sigmas, mask=m)
        if getMPIRankWorld() == 0: 
            print("result written to %s.csv. Core region is %s."%(config.outfile, config.core))
Пример #4
0
import argparse
from fingal import makeTagField

parser = argparse.ArgumentParser(
    description='creates a silo/vtk file from fly.')
parser.add_argument(dest='meshfile',
                    metavar='meshfile',
                    type=str,
                    help='fly file')
parser.add_argument('--silo',
                    '-s',
                    dest='silo',
                    metavar='SILO',
                    help="silo file to write.")
parser.add_argument('--vtk',
                    '-v',
                    dest='vtk',
                    metavar='SILO',
                    help="vtk file to write.")
args = parser.parse_args()

domain = ReadMesh(args.meshfile)
print("mesh read from " + args.meshfile)

if args.silo is not None:
    saveSilo(args.silo, tag=makeTagField(ReducedFunction(domain)))
    print(args.silo + ".silo with tags has been generate")
if args.vtk is not None:
    saveSilo(args.vtk, tag=makeTagField(ReducedFunction(domain)))
    print(args.vtk + ".vtk with tags has been generated.")
Пример #5
0
        print("\ttotal domain  = %s"%R2)
        print("\tlog, total domain = %s"%R2log)

        if config.core:
            mask=insertTaggedValues(Scalar(0., gammai.getFunctionSpace()), **{ t: 1 for t in config.core })
            R2=getR2(gamma_true, gammai, chi=mask)
            R2log=getR2(log(gamma_true), log(gammai), chi=mask)
            if getMPIRankWorld() == 0: 
                print("\tcore = %s"%R2)
                print("\tlog, core = %s"%R2log)
                
                

# assemblage of output: 
sigma.expand()
outargs={ "tag" : makeTagField(Function(domain)), "sigma":sigma } 

if not config.true_properties is None:
    outargs['sigma_error']=sigma/sigma_true
    sigma_true.expand()
    outargs['sigma_true']=sigma_true        

if not args.sigmaonly:
    outargs['gamma']=gamma
    if not config.true_properties is None:
        outargs['gamma_error']=gamma/gamma_true
        gamma_true.expand()
        outargs['gamma_true']=gamma_true
        
if args.vtk:
    saveVTK(config.outfile, **outargs)