def test2D_EM(): print("Test 2D-EM:") # PRINT = True PRINT = False from caid.cad_geometry import square as domain n = [50, 50] p = [3, 3] geo = domain(n=n, p=p) nrb = geo[0] # creation of a multi-patch domaine with 4 patchs npatchs = 4 for i in range(1, npatchs): geo.append(nrb) # with the following boundary Conditions DirFaces = [[1, 2], [2, 3], [0, 3], [0, 1]] DuplicatedFaces = [[0, 3], [1, 0], [2, 1], [0, 0]] DuplicataFaces = [[1, 1], [2, 2], [3, 3], [3, 2]] list_n = [nrb.shape for nrb in geo] from .idutils import computeLocalID, computeGlobalID, print_id list_id = computeLocalID(list_n, DirFaces, DuplicatedFaces, DuplicataFaces) ID = computeGlobalID(list_id) from time import time t_start = time() EM = ElementsManager(geo) list_supports = EM.supports EM.InitializeIDsupports(list_id, ID) t_end = time() print("Elapsed time : ", t_end - t_start) t_start = time() nodelist = list(range(0, (n[0] + 2 * p[0] + 1) / 2)) EM.setNodeList(nodelist) list_patchs = EM.GetLocalPatchs() # print "listpatchs = ", list_patchs for ipatch in list_patchs: list_elts = EM.GetLocalElements(ipatch) # print "patch ", i, " elements ", list_elts t_end = time() print("Elapsed time : ", t_end - t_start) if PRINT: print("-------------- FINAL ------------------") for i, id in enumerate(list_id): print("...... patch id : ", i, " ......") print_id(id) print("...... supports ................") print(list_supports[i]) print("-------------- ID ------------------") print(ID) print("-------------- I DATA --------------") for I, data in enumerate(EM.IDsupports): # print "I ", I, " data ", data print("<<< I ", I + 1, " >>>") for [ipatch, elts] in data: print("patch ", ipatch, " elements ", elts)
def test2D_EM(): print("Test 2D-EM:") # PRINT = True PRINT = False from caid.cad_geometry import square as domain n = [50,50] p = [3,3] geo = domain(n=n,p=p) nrb = geo[0] # creation of a multi-patch domaine with 4 patchs npatchs = 4 for i in range(1,npatchs): geo.append(nrb) # with the following boundary Conditions DirFaces = [[1,2],[2,3],[0,3],[0,1]] DuplicatedFaces = [[0,3],[1,0],[2,1],[0,0]] DuplicataFaces = [[1,1],[2,2],[3,3],[3,2]] list_n = [nrb.shape for nrb in geo] from .idutils import computeLocalID, computeGlobalID, print_id list_id = computeLocalID(list_n, DirFaces, DuplicatedFaces, DuplicataFaces) ID = computeGlobalID(list_id) from time import time t_start = time() EM = ElementsManager(geo) list_supports = EM.supports EM.InitializeIDsupports(list_id, ID) t_end = time() print("Elapsed time : ", t_end - t_start) t_start = time() nodelist = list(range(0, (n[0]+2*p[0]+1)/2)) EM.setNodeList(nodelist) list_patchs = EM.GetLocalPatchs() # print "listpatchs = ", list_patchs for ipatch in list_patchs: list_elts = EM.GetLocalElements(ipatch) # print "patch ", i, " elements ", list_elts t_end = time() print("Elapsed time : ", t_end - t_start) if PRINT : print("-------------- FINAL ------------------") for i,id in enumerate(list_id): print("...... patch id : ", i, " ......") print_id(id) print("...... supports ................") print(list_supports[i]) print("-------------- ID ------------------") print(ID) print("-------------- I DATA --------------") for I,data in enumerate(EM.IDsupports): # print "I ", I, " data ", data print("<<< I ", I+1, " >>>") for [ipatch, elts] in data: print("patch ", ipatch, " elements ", elts)
def test3D(): print("Test 3D:") from caid.cad_geometry import trilinear as domain n = [10,10,10] p = [2,2,2] geo = domain(n=n,p=p) from time import time t_start = time() list_supports = get_elements(geo) t_end = time() print("Elapsed time : ", t_end - t_start)
def test3D(): print("Test 3D:") from caid.cad_geometry import trilinear as domain n = [10, 10, 10] p = [2, 2, 2] geo = domain(n=n, p=p) from time import time t_start = time() list_supports = get_elements(geo) t_end = time() print("Elapsed time : ", t_end - t_start)
# number of levels of the output surface nstagex = int(sys.argv[5]) nstagey = int(sys.argv[6]) # degrees of the output surface px = int(sys.argv[7]) py = int(sys.argv[8]) nx = nx_in ny = ny_in for i in range(0, nstagex): nx = 2 * nx + 1 for i in range(0, nstagey): ny = 2 * ny + 1 geo = domain(n=[nx_in, ny_in], p=[px_in, py_in]) nrb = geo[0] C = np.zeros_like(nrb.points) # import the solution _C = np.genfromtxt("u.txt") shape = list(nrb.shape) C = np.zeros(shape + [3]) C[..., 0] = _C srf = cad_nurbs(nrb.knots, C, weights=nrb.weights) geo_f = cad_geometry() geo_f.append(srf) geo_tmp = domain(n=[nx, ny], p=[px, py]) tx = [t for t in geo_tmp[0].knots[0] if t not in geo[0].knots[0]]
px = 2 py = 2 #----------------------------------- #----------------------------------- # ... from caid.cad_geometry import line geo1 = line(n=[nx], p=[px]) f1, u1 = testcase_line() PDE1 = poisson(geometry=geo1) # ... # ... from caid.cad_geometry import square as domain geo2 = domain(n=[nx, ny], p=[px, py]) f2, u2 = testcase_square_Dirichlet() PDE2 = poisson(geometry=geo2) # ... # ... PDE1.assembly(f=f1, u=u1) PDE2.assembly(f=f2, u=u2) # ... # ... PDE1.solve() PDE2.solve() # ...
PLOT=False # ... import numpy as np import sys import inspect filename = inspect.getfile(inspect.currentframe()) # script filename (usually with path) sys.stdout = open(filename.split('.py')[0]+'.txt', 'w') from pigasus.fem.block_basicPDE import * from caid.cad_geometry import square as domain from numpy import pi, sin with context(): nx = 15 ; ny = 15 px = 2 ; py = 2 geo = domain(n=[nx,ny],p=[px,px]) #----------------------------------- def testcase(): # implicit part tc = {} kx = 2. * pi ky = 2. * pi # ... exact solution u = lambda x,y : [sin ( kx * x ) * sin ( ky * y )] # ... rhs f = lambda x,y : [( kx**2 + ky**2 ) * sin ( kx * x ) * sin ( ky * y )] A = lambda x,y : [ 1., 0. \
if 3 in self.faces: li_i = li_nex - 1 for li_j in range(0, li_ney): li_index = li_j * li_nex + li_i list_real_elts.append(li_index + 1) return np.array(list_real_elts) def get_real_elts_3D(self): # default print("boundary_grid : get_real_elts_3D : not done yet") def get_real_elts(self): if self.dim == 1: return self.get_real_elts_1D() if self.dim == 2: return self.get_real_elts_2D() if self.dim == 3: return self.get_real_elts_3D() if self.dim not in [1, 2, 3]: print("boundary_grid : get_real_elts : dimension not done yet") if __name__ == '__main__': from caid.cad_geometry import square as domain geo = domain(n=[3, 2], p=[1, 1]) k = [2, 2] nrb = geo[0] grids_id = 0 id = 0 grid = boundary_grid(grids_id, id, nrb, k, faces=[0, 1])
# coding: utf-8 import numpy as np from caid.cad_geometry import square as domain from pigasus.gallery.poisson import * sin = np.sin ; pi = np.pi # ... # ... kx = 2. * pi ky = 2. * pi # ... exact solution u = lambda x,y : [sin ( kx * x ) * sin ( ky * y )] # ... rhs f = lambda x,y : [( kx**2 + ky**2 ) * sin ( kx * x ) * sin ( ky * y )] AllDirichlet = True nx=15; ny = 15; px = 2; py = 2 geo = domain(n=[nx,ny],p=[px,py]) PDE = poisson(geometry=geo, AllDirichlet=AllDirichlet) PDE.assembly(f=f) PDE.solve() # ... # ... normU = PDE.norm(exact=u) print(("norm U = ", normU)) U = PDE.unknown u = U.tomatrix(0) from caid.cad_geometry import cad_nurbs nrb = geo[0] C = np.zeros_like(nrb.points) C[...,0]=u nrb_f = cad_nurbs(nrb.knots, C, weights=nrb.weights) from caid.cad_geometry import cad_geometry
def OnClick(self, event): # inspector = self.parent wk = self.parent.WorkGroup ID = event.GetId() if ID == self.BCK_ID: self.parent.ShowAction(self.parent.geometryActions) if ID == self.EMP_ID: geo = cad_geometry() wk.add_geometry(geometry(geo)) if wk.macroRecording: macro_script = wk.macro_script macro_script.new_line() macro_script.append("# ... create object") macro_script.append("_geo = cad_geometry()") macro_script.append("wk.add_geometry(geometry(_geo))") macro_script.append("# ...") if ID == self.LIN_ID: from caid.cad_geometry import line as domain geo = domain() wk.add_geometry(geometry(geo)) if wk.macroRecording: macro_script = wk.macro_script macro_script.new_line() macro_script.append("# ... create object") macro_script.append("_geo = line()") macro_script.append("wk.add_geometry(geometry(_geo))") macro_script.append("# ...") if ID == self.LNR_ID: self.parent.objectActionsCreateLinear.asGeometry() self.parent.ShowAction(self.parent.objectActionsCreateLinear) if ID == self.ARC_ID: self.parent.objectActionsCreateArc.asGeometry() self.parent.ShowAction(self.parent.objectActionsCreateArc) if ID == self.CRV_ID: self.parent.objectActionsCurve.asGeometry() self.parent.ShowAction(self.parent.objectActionsCurve) if ID == self.SQR_ID: from caid.cad_geometry import square as domain geo = domain() wk.add_geometry(geometry(geo)) # macro recording if wk.macroRecording: macro_script = wk.macro_script macro_script.new_line() macro_script.append("# ... create object") macro_script.append("_geo = square()") macro_script.append("wk.add_geometry(geometry(_geo))") macro_script.append("# ...") if ID == self.BIL_ID: self.parent.objectActionsCreateBilinear.asGeometry() self.parent.ShowAction(self.parent.objectActionsCreateBilinear) if ID == self.CRC_ID: self.parent.objectActionsCreateCircle.asGeometry() self.parent.ShowAction(self.parent.objectActionsCreateCircle) if ID == self.QCR_ID: self.parent.objectActionsCreateQuartCircle.asGeometry() self.parent.ShowAction(self.parent.objectActionsCreateQuartCircle) if ID == self.ANL_ID: self.parent.objectActionsCreateAnnulus.asGeometry() self.parent.ShowAction(self.parent.objectActionsCreateAnnulus) if ID == self.CR5_ID: self.parent.objectActionsCreateCircle_5mp.asGeometry() self.parent.ShowAction(self.parent.objectActionsCreateCircle_5mp) if ID == self.TRL_ID: self.parent.objectActionsCreateTriangle.asGeometry() self.parent.ShowAction(self.parent.objectActionsCreateTriangle)
#----------------------------------- try: nx = int(sys.argv[1]) except: nx = 5 try: px = int(sys.argv[2]) except: px = 3 #----------------------------------- # ... from caid.cad_geometry import line as domain geo = domain(n=[nx],p=[px], periodic=True) # ... with context(): # ... PDE = basicPDE(geometry=geo, testcase=tc) # ... # ... PDE.assembly() M = PDE.system M.save("M.mtx") PDE.solve() # ... normU = PDE.norm(exact=u)
from caid.cad_geometry import square as domain from caid.cad_geometry import cad_nurbs import matplotlib.pyplot as plt import numpy as np pi = np.pi ; cos = np.cos ; sin = np.sin n = 15 p = 2 geo = domain(n=[n,n], p=[p,p]) nrb = geo[0] eps = 0.5 * (nrb.knots[0][p+1] - nrb.knots[0][0]) kx = 4 * pi ky = 8 * pi # --------------------------------------------------- def genNewMesh(nrb): P = nrb.points x = P[:,:,0] y = P[:,:,1] shp = P.shape nx = shp[0] ; ny = shp[1] tx = np.linspace(0.,1.,nx) ty = np.linspace(0.,1.,ny) Tx,Ty = np.meshgrid(tx,ty) Tx = Tx.transpose() Ty = Ty.transpose()
except: ny = 1 try: px = int(sys.argv[3]) except: px = 2 try: py = int(sys.argv[4]) except: py = 2 from caid.cad_geometry import circle as domain radius = 0.5 geo = domain(radius=radius, n=[nx, ny], p=[px, px]) #----------------------------------- # ... # exact solution # ... meanU = 0.60125862034 u = lambda x, y: [sin(1.0 - x**2 - y**2) - meanU / (pi * radius**2)] # ... # ... # rhs # ... f = lambda x, y: [ 4.0 * (x**2 + y**2) * sin(1.0 - x**2 - y**2) + 4.0 * cos(1.0 - x**2 - y**2) ]
def OnClick(self, event): # inspector = self.parent wk = self.parent.WorkGroup ID = event.GetId() if ID == self.BCK_ID: self.parent.ShowAction(self.parent.geometryActions) if ID == self.EMP_ID: geo = cad_geometry() wk.add_geometry(geometry(geo)) if wk.macroRecording: macro_script = wk.macro_script macro_script.new_line() macro_script.append("# ... create object") macro_script.append("_geo = cad_geometry()") macro_script.append("wk.add_geometry(geometry(_geo))") macro_script.append("# ...") if ID == self.LIN_ID: from caid.cad_geometry import line as domain geo = domain() wk.add_geometry(geometry(geo)) if wk.macroRecording: macro_script = wk.macro_script macro_script.new_line() macro_script.append("# ... create object") macro_script.append("_geo = line()") macro_script.append("wk.add_geometry(geometry(_geo))") macro_script.append("# ...") if ID == self.LNR_ID: self.parent.objectActionsCreateLinear.asGeometry() self.parent.ShowAction(self.parent.objectActionsCreateLinear) if ID == self.ARC_ID: self.parent.objectActionsCreateArc.asGeometry() self.parent.ShowAction(self.parent.objectActionsCreateArc) if ID == self.CRV_ID: self.parent.objectActionsCurve.asGeometry() self.parent.ShowAction(self.parent.objectActionsCurve) if ID == self.SQR_ID: from caid.cad_geometry import square as domain geo = domain() wk.add_geometry(geometry(geo)) # macro recording if wk.macroRecording: macro_script = wk.macro_script macro_script.new_line() macro_script.append("# ... create object") macro_script.append("_geo = square()") macro_script.append("wk.add_geometry(geometry(_geo))") macro_script.append("# ...") if ID == self.BIL_ID: self.parent.objectActionsCreateBilinear.asGeometry() self.parent.ShowAction(self.parent.objectActionsCreateBilinear) if ID == self.CRC_ID: self.parent.objectActionsCreateCircle.asGeometry() self.parent.ShowAction(self.parent.objectActionsCreateCircle) if ID == self.QCR_ID: self.parent.objectActionsCreateQuartCircle.asGeometry() self.parent.ShowAction(self.parent.objectActionsCreateQuartCircle) if ID == self.ANL_ID: self.parent.objectActionsCreateAnnulus.asGeometry() self.parent.ShowAction(self.parent.objectActionsCreateAnnulus) if ID == self.CR5_ID: self.parent.objectActionsCreateCircle_5mp.asGeometry() self.parent.ShowAction(self.parent.objectActionsCreateCircle_5mp) if ID == self.PC5_ID: self.parent.objectActionsCreatePinched_Circle_5mp.asGeometry() self.parent.ShowAction( self.parent.objectActionsCreatePinched_Circle_5mp) if ID == self.TRL_ID: self.parent.objectActionsCreateTriangle.asGeometry() self.parent.ShowAction(self.parent.objectActionsCreateTriangle) if ID == self.CUB_ID: # from caid.cad_geometry import cube as domain from caid.cad_geometry import trilinear as domain geo = domain() wk.add_geometry(geometry(geo))
def OnClick(self, event): ID = event.GetId() if ID == self.BCK_ID: self.parent.ShowAction(self.parent.geometryActions) if ID == self.LNR_ID: self.parent.objectActionsCreateLinear.asPatch() self.parent.ShowAction(self.parent.objectActionsCreateLinear) if ID == self.ARC_ID: self.parent.objectActionsCreateArc.asPatch() self.parent.ShowAction(self.parent.objectActionsCreateArc) if ID == self.CRV_ID: self.parent.objectActionsCurve.asPatch() self.parent.ShowAction(self.parent.objectActionsCurve) if ID == self.BIL_ID: self.parent.objectActionsCreateBilinear.asPatch() self.parent.ShowAction(self.parent.objectActionsCreateBilinear) if ID == self.CRC_ID: self.parent.objectActionsCreateCircle.asPatch() self.parent.ShowAction(self.parent.objectActionsCreateCircle) if ID == self.QCR_ID: self.parent.objectActionsCreateQuartCircle.asPatch() self.parent.ShowAction(self.parent.objectActionsCreateQuartCircle) if ID == self.ANL_ID: self.parent.objectActionsCreateAnnulus.asPatch() self.parent.ShowAction(self.parent.objectActionsCreateAnnulus) if ID == self.CR5_ID: self.parent.objectActionsCreateCircle_5mp.asPatch() self.parent.ShowAction(self.parent.objectActionsCreateCircle_5mp) if ID == self.TRL_ID: self.parent.objectActionsCreateTriangle.asGeometry() self.parent.ShowAction(self.parent.objectActionsCreateTriangle) if ID == self.LIN_ID: from caid.cad_geometry import line as domain nrb = domain()[0] # inspector = self.parent wk = self.parent.WorkGroup geo = wk.inspector.currentGeometry geoItem = wk.inspector.currentGeometryItem wk.add_patch(geoItem, geo, nrb) # macro recording if wk.macroRecording: macro_script = wk.macro_script macro_script.new_line() macro_script.append("# ... add line patch") patch = wk.inspector.currentObject patchItem = wk.inspector.currentPatchItem geoItem = wk.inspector.tree.GetItemParent(patchItem) geo = wk.inspector.tree.GetPyData(geoItem) geo_id = wk.list_geo.index(geo) patch_id = geo.index(patch) macro_script.append("geo_id = "+str(geo_id)) macro_script.append("patch_id = "+str(patch_id)) macro_script.append("geo = geometries[geo_id]") macro_script.append("patch = geo[patch_id]") macro_script.append("cad_nrb = line()[0]") macro_script.append("geoItem = geo.treeItem") macro_script.append("wk.add_patch(geoItem, geo, cad_nrb)") macro_script.append("wk.Refresh(inspector=True)") macro_script.append("# ...") wk.Refresh(inspector=True) if ID == self.SQR_ID: from caid.cad_geometry import square as domain nrb = domain()[0] # inspector = self.parent wk = self.parent.WorkGroup geo = wk.inspector.currentGeometry geoItem = wk.inspector.currentGeometryItem wk.add_patch(geoItem, geo, nrb) # macro recording if wk.macroRecording: macro_script = wk.macro_script macro_script.new_line() macro_script.append("# ... add line patch") patch = wk.inspector.currentObject patchItem = wk.inspector.currentPatchItem geoItem = wk.inspector.tree.GetItemParent(patchItem) geo = wk.inspector.tree.GetPyData(geoItem) geo_id = wk.list_geo.index(geo) patch_id = geo.index(patch) macro_script.append("geo_id = "+str(geo_id)) macro_script.append("patch_id = "+str(patch_id)) macro_script.append("geo = geometries[geo_id]") macro_script.append("patch = geo[patch_id]") macro_script.append("cad_nrb = square()[0]") macro_script.append("geoItem = geo.treeItem") macro_script.append("wk.add_patch(geoItem, geo, cad_nrb)") macro_script.append("wk.Refresh(inspector=True)") macro_script.append("# ...") wk.Refresh(inspector=True)
def OnClick(self, event): ID = event.GetId() if ID == self.BCK_ID: self.parent.ShowAction(self.parent.geometryActions) if ID == self.LNR_ID: self.parent.objectActionsCreateLinear.asPatch() self.parent.ShowAction(self.parent.objectActionsCreateLinear) if ID == self.ARC_ID: self.parent.objectActionsCreateArc.asPatch() self.parent.ShowAction(self.parent.objectActionsCreateArc) if ID == self.CRV_ID: self.parent.objectActionsCurve.asPatch() self.parent.ShowAction(self.parent.objectActionsCurve) if ID == self.BIL_ID: self.parent.objectActionsCreateBilinear.asPatch() self.parent.ShowAction(self.parent.objectActionsCreateBilinear) if ID == self.CRC_ID: self.parent.objectActionsCreateCircle.asPatch() self.parent.ShowAction(self.parent.objectActionsCreateCircle) if ID == self.QCR_ID: self.parent.objectActionsCreateQuartCircle.asPatch() self.parent.ShowAction(self.parent.objectActionsCreateQuartCircle) if ID == self.ANL_ID: self.parent.objectActionsCreateAnnulus.asPatch() self.parent.ShowAction(self.parent.objectActionsCreateAnnulus) if ID == self.CR5_ID: self.parent.objectActionsCreateCircle_5mp.asPatch() self.parent.ShowAction(self.parent.objectActionsCreateCircle_5mp) if ID == self.PC5_ID: self.parent.objectActionsCreatePinched_Circle_5mp.asPatch() self.parent.ShowAction( self.parent.objectActionsCreatePinched_Circle_5mp) if ID == self.TRL_ID: self.parent.objectActionsCreateTriangle.asGeometry() self.parent.ShowAction(self.parent.objectActionsCreateTriangle) if ID == self.LIN_ID: from caid.cad_geometry import line as domain nrb = domain()[0] # inspector = self.parent wk = self.parent.WorkGroup geo = wk.inspector.currentGeometry geoItem = wk.inspector.currentGeometryItem wk.add_patch(geoItem, geo, nrb) # macro recording if wk.macroRecording: macro_script = wk.macro_script macro_script.new_line() macro_script.append("# ... add line patch") patch = wk.inspector.currentObject patchItem = wk.inspector.currentPatchItem geoItem = wk.inspector.tree.GetItemParent(patchItem) geo = wk.inspector.tree.GetItemData(geoItem) geo_id = wk.list_geo.index(geo) patch_id = geo.index(patch) macro_script.append("geo_id = " + str(geo_id)) macro_script.append("patch_id = " + str(patch_id)) macro_script.append("geo = geometries[geo_id]") macro_script.append("patch = geo[patch_id]") macro_script.append("cad_nrb = line()[0]") macro_script.append("geoItem = geo.treeItem") macro_script.append("wk.add_patch(geoItem, geo, cad_nrb)") macro_script.append("wk.Refresh(inspector=True)") macro_script.append("# ...") wk.Refresh(inspector=True) if ID == self.SQR_ID: from caid.cad_geometry import square as domain nrb = domain()[0] # inspector = self.parent wk = self.parent.WorkGroup geo = wk.inspector.currentGeometry geoItem = wk.inspector.currentGeometryItem wk.add_patch(geoItem, geo, nrb) # macro recording if wk.macroRecording: macro_script = wk.macro_script macro_script.new_line() macro_script.append("# ... add line patch") patch = wk.inspector.currentObject patchItem = wk.inspector.currentPatchItem geoItem = wk.inspector.tree.GetItemParent(patchItem) geo = wk.inspector.tree.GetItemData(geoItem) geo_id = wk.list_geo.index(geo) patch_id = geo.index(patch) macro_script.append("geo_id = " + str(geo_id)) macro_script.append("patch_id = " + str(patch_id)) macro_script.append("geo = geometries[geo_id]") macro_script.append("patch = geo[patch_id]") macro_script.append("cad_nrb = square()[0]") macro_script.append("geoItem = geo.treeItem") macro_script.append("wk.add_patch(geoItem, geo, cad_nrb)") macro_script.append("wk.Refresh(inspector=True)") macro_script.append("# ...") if ID == self.CUB_ID: # from caid.cad_geometry import cube as domain from caid.cad_geometry import trilinear as domain nrb = domain()[0] # inspector = self.parent wk = self.parent.WorkGroup geo = wk.inspector.currentGeometry geoItem = wk.inspector.currentGeometryItem wk.add_patch(geoItem, geo, nrb) wk.Refresh(inspector=True)
except: py = 2 from caid.cad_geometry import circle as domain from caid.cad_geometry import cad_geometry, cad_nurbs from pigasus.fem.metric import metric from caid.cad_geometry import square as patch from caid.cad_geometry import square TYPE = None #TYPE = "mapping" #TYPE = "points" #TYPE = "analytic" if TYPE is None: geo = domain(n=[nx, ny], p=[px, py]) # ----------------- if TYPE is not None: # geo = cad_geometry("domain.xml") # geo = patch(n=[nx,ny],p=[px,py]) geo_s = square(p=[2, 2]) nrb = geo_s[0] U, V = nrb.knots #C = nrb.points C = np.zeros_like(nrb.points) s = 1. / np.sqrt(2) weights = np.ones((3, 3))
#----------------------------------- try: nx = int(sys.argv[1]) except: nx = 31 try: px = int(sys.argv[2]) except: px = 2 #----------------------------------- # ... from caid.cad_geometry import line as domain geo = domain(n=[nx], p=[px]) # ... with context(): # ... PDE = basicPDE(geometry=geo, testcase=tc) # ... # ... PDE.assembly() PDE.solve() # ... normU = PDE.norm(exact=u) print("norm U = ", normU) # ...
#r = lambda s,t : sqrt( (s-xc)**2 + (t-yc)**2 ) #theta = lambda s,t : atan(t-yc,s-xc) #def rho1(s,t): # r_ = r(s,t) ; t_ = theta(s,t) # val = C1 * (1. + 9./(1. + (10*r_*cos(t_-20*r_**2))**2) ) # return val # ... c_rho = C0 / C1 # ... #----------------------------------- #----------------------------------- # ... from caid.cad_geometry import square as domain geo = domain(n=n, p=p) gamma = 11. eps = 1. dt = 1. rtol = 1.e-3 maxiter = 10 verbose = True # ... # values of gradu.n at the boundary # ... def func_g(x, y): return [x, y]