def pde_work(self, **args): x = self.domain.getX() gammaD = whereZero(x[0]) + whereZero(x[1]) mypde = Poisson(domain=self.domain) mypde.setValue(f=1 + self.swid, q=gammaD) u = mypde.getSolution() return True
def task(self, **kwargs): v = kwargs['v'] dom = self.domain pde = Poisson(dom) x = dom.getX() gammaD = whereZero(x[0]) + whereZero(x[1]) pde.setValue(f=v, q=gammaD) soln = pde.getSolution() soln.dump('soln%d.ncdf' % v)
def task(self, **kwargs): v=kwargs['v'] dom=self.domain pde=Poisson(dom) x=dom.getX() gammaD=whereZero(x[0])+whereZero(x[1]) pde.setValue(f=v, q=gammaD) soln=pde.getSolution() soln.dump('soln%d.ncdf'%v)
def work(self): x = self.domain.getX() gammaD = whereZero(x[0]) + whereZero(x[1]) # define PDE and get its solution u mypde = Poisson(domain=self.domain) mypde.setValue(f=self.jobid, q=gammaD) u = Lsup(mypde.getSolution()) # we won't actually export the value to make self.exportValue("answer", self.jobid) # testing easier return True
def work(self): x = self.domain.getX() gammaD = whereZero(x[0]) + whereZero(x[1]) # define PDE and get its solution u mypde = Poisson(domain=self.domain) mypde.setValue(f=self.jobid, q=gammaD) u = Lsup(mypde.getSolution() ) # we won't actually export the value to make self.exportValue("answer", self.jobid) # testing easier return True
def Solve2(mydomain, height): print("Partially constraint solution") l = [1., 1., 1.] l[mydomain.getDim() - 1] = height print(l) cf = ContinuousFunction(mydomain) x = cf.getX() #construct exact solution: u_ex = Scalar(1., cf) for i in range(mydomain.getDim()): u_ex *= x[i] * (2 * l[i] - x[i]) #construct mask: msk = Scalar(0., cf) for i in range(mydomain.getDim()): msk += whereZero(x[i]) #construct right hand side f = Scalar(0, cf) for i in range(mydomain.getDim()): f_p = Scalar(1, cf) for j in range(mydomain.getDim()): if i == j: f_p *= 2. else: f_p *= x[j] * (2 * l[j] - x[j]) f += f_p mypde = Poisson(mydomain) mypde.setTolerance(1.e-10) mypde.setValue(f=f, q=msk) u = mypde.getSolution() error = Lsup(u - u_ex) / Lsup(u_ex) print("error = ", error) return error
def Solve2(mydomain,height): print("Partially constraint solution") l=[1.,1.,1.] l[mydomain.getDim()-1]=height print(l) cf=ContinuousFunction(mydomain) x=cf.getX() #construct exact solution: u_ex=Scalar(1.,cf) for i in range(mydomain.getDim()): u_ex*=x[i]*(2*l[i]-x[i]) #construct mask: msk=Scalar(0.,cf) for i in range(mydomain.getDim()): msk+=whereZero(x[i]) #construct right hand side f=Scalar(0,cf) for i in range(mydomain.getDim()): f_p=Scalar(1,cf) for j in range(mydomain.getDim()): if i==j: f_p*=2. else: f_p*=x[j]*(2*l[j]-x[j]) f+=f_p mypde=Poisson(mydomain) mypde.setTolerance(1.e-10) mypde.setValue(f=f,q=msk) u=mypde.getSolution() error=Lsup(u-u_ex)/Lsup(u_ex) print("error = ",error) return error
from esys.ripley import Brick HAVE_RIPLEY = True except ImportError: HAVE_RIPLEY = False print("Ripley module not available") if HAVE_RIPLEY: from esys.escript import * from esys.escript.linearPDEs import Poisson from esys.weipa import saveSilo, saveVoxet import tempfile dom = Brick(l0=1., l1=1., n0=9, n1=9, n2=9) x = dom.getX() gammaD = whereZero(x[0]) + whereZero(x[1]) pde = Poisson(dom) q = gammaD pde.setValue(f=1, q=q) u = pde.getSolution() u = interpolate(u + dom.getX()[2], ReducedFunction(dom)) print(u) handle, filename = tempfile.mkstemp(suffix='.vo', prefix='poisson') saveVoxet(filename, u=u) print("-------") dom = Brick(l0=1., l1=1., l2=4., n0=18, n1=18, n2=36) v = readVoxet(dom, filename, 'u', fillValue=0.5) print(v) os.remove(filename) #saveSilo('/tmp/poisson', v=v)
# Very basic sanity checks following a build # It is important that this script does not create any files unless # it is _certain_ they are removed when finished or failed. # We do not want the source directory polluted by actions here from esys.escript import * from esys.escript.linearPDEs import Poisson import esys.ripley as ripley import esys.finley as finley import esys.speckley as speckley from esys.weipa import saveVTK mydomain = finley.Rectangle(l0=1.,l1=1.,n0=40, n1=20) # define characteristic function of Gamma^D x = mydomain.getX() gammaD = whereZero(x[0])+whereZero(x[1]) # define PDE and get its solution u mypde = Poisson(domain=mydomain) mypde.setValue(f=1,q=gammaD) u = mypde.getSolution() # write u to an external file #saveVTK("u.vtu",sol=u)
# Very basic sanity checks following a build # It is important that this script does not create any files unless # it is _certain_ they are removed when finished or failed. # We do not want the source directory polluted by actions here from esys.escript import * from esys.escript.linearPDEs import Poisson import esys.ripley as ripley import esys.finley as finley import esys.speckley as speckley from esys.weipa import saveVTK mydomain = finley.Rectangle(l0=1., l1=1., n0=40, n1=20) # define characteristic function of Gamma^D x = mydomain.getX() gammaD = whereZero(x[0]) + whereZero(x[1]) # define PDE and get its solution u mypde = Poisson(domain=mydomain) mypde.setValue(f=1, q=gammaD) u = mypde.getSolution() # write u to an external file #saveVTK("u.vtu",sol=u)
if __name__ == "__main__": try: from esys.ripley import Brick HAVE_RIPLEY = True except ImportError: HAVE_RIPLEY = False print("Ripley module not available") if HAVE_RIPLEY: from esys.escript import * from esys.escript.linearPDEs import Poisson from esys.weipa import saveSilo, saveVoxet dom = Brick(l0=1.,l1=1.,n0=9, n1=9, n2=9) x = dom.getX() gammaD = whereZero(x[0])+whereZero(x[1]) pde = Poisson(dom) q = gammaD pde.setValue(f=1, q=q) u = pde.getSolution() u=interpolate(u+dom.getX()[2], ReducedFunction(dom)) print(u) saveVoxet('/tmp/poisson.vo', u=u) print("-------") dom = Brick(l0=1.,l1=1.,l2=4.,n0=18, n1=18, n2=36) v=readVoxet(dom, '/tmp/poisson.vo', 'u', fillValue=0.5) print(v) #saveSilo('/tmp/poisson', v=v)