예제 #1
0
from itasca import p2pLinkClient
import numpy as np
from pyDemFoam import pyDemIcoFoam

solver = pyDemIcoFoam()

with p2pLinkClient() as pfc_link:
    pfc_link.connect("10.0.2.2")

    pfc_link.send_data(solver.nodes())
    pfc_link.send_data(solver.elements())
    pfc_link.send_data(solver.rho())
    pfc_link.send_data(solver.mu())

    while True:
        print "waiting for run time"
        deltat = pfc_link.read_data()
        if deltat == 0.0:
            print "solve finished"
            break
        print "got run time", deltat
        solver.n(pfc_link.read_data())
        solver.f(pfc_link.read_data())
        print "got runtime and data"

        solver.set_dt(deltat)
        solver.solve(deltat)

        print "sending data to pfc"
        pfc_link.send_data(solver.p()*solver.rho())
        pfc_link.send_data(solver.gradp()*solver.rho())
예제 #2
0
from itasca import p2pLinkClient
import numpy as np
from pyDemFoam import pyDemIcoFoam

solver = pyDemIcoFoam()

pfc_link = p2pLinkClient()
#pfc_link.connect("10.0.2.2") # for VirtualBox
pfc_link.connect("")  # for WSL

pfc_link.send_data(solver.nodes())
pfc_link.send_data(solver.elements())
pfc_link.send_data(solver.cell_centers())
pfc_link.send_data(solver.cell_volumes())
pfc_link.send_data(solver.rho())
pfc_link.send_data(solver.mu())

while True:
    deltat = pfc_link.read_data()
    if deltat == 0.0:
        print "solve finished"
        break
    solver.n(pfc_link.read_data())
    solver.f(pfc_link.read_data())

    solver.set_dt(deltat)
    solver.solve(deltat)

    pfc_link.send_data(solver.p() * solver.rho())
    pfc_link.send_data(solver.gradp() * solver.rho())
    pfc_link.send_data(solver.U())
예제 #3
0
from itasca import p2pLinkClient
import numpy as np

with p2pLinkClient() as s:

    s.connect("localhost")

    s.send_data("James")

    s.send_data(np.array([1,2,3]))

    adata = np.random.random((1000,1000))
    print(adata)
    s.send_data(adata)

    for i in range(10):
        print("sent", i)
        s.send_data(i)

    s.send_data(-1)