Example #1
0
    def __init__(self,
                 C,
                 xmax=0.,
                 xmin=0.,
                 ymax=0.,
                 ymin=0.,
                 zmax=0.,
                 zmin=0.,
                 colormap=None,
                 side='right'):
        self._colormap = colormap
        self._C = C
        self._side = side
        print(("> create colorbar with ", len(C), " side ", side))

        if side == 'right':
            scale = [0.25, 2.]
            displ = [xmax + 2., 0.]
            n = [0, len(C) - 2]
        if side == 'left':
            scale = [0.25, 2.]
            displ = [xmin - 1., 0.]
            n = [0, len(C) - 2]
        if side == 'bottom':
            scale = [2., 0.25]
            displ = [0., ymin - 2.]
            n = [len(C) - 2, 0]
        if side == 'top':
            scale = [2., 0.25]
            displ = [0., ymax + 2.]
            n = [len(C) - 2, 0]

        from caid.cad_geometry import square
        geometry = square()
        values = square(n=n)

        for geo in [geometry, values]:
            for axis in range(0, 2):
                geo.scale(scale[axis], axis=axis)
            geo.translate(displ)

        patch_id = 0
        nrb = values[patch_id]
        P = zeros_like(nrb.points)
        if side == 'right':
            P[0, :, 0] = C
            P[1, :, 0] = C
        if side == 'left':
            P[0, :, 0] = C
            P[1, :, 0] = C
        if side == 'bottom':
            P[:, 0, 0] = C
            P[:, 1, 0] = C
        if side == 'top':
            P[:, 0, 0] = C
            P[:, 1, 0] = C
        nrb.set_points(P)
        field.__init__(self, geometry=geometry, values=values, type='scalar')
Example #2
0
    def __init__(self, C, xmax=0.0, xmin=0.0, ymax=0.0, ymin=0.0, zmax=0.0, zmin=0.0, colormap=None, side="right"):
        self._colormap = colormap
        self._C = C
        self._side = side
        print("> create colorbar with ", len(C), " side ", side)

        if side == "right":
            scale = [0.25, 2.0]
            displ = [xmax + 2.0, 0.0]
            n = [0, len(C) - 2]
        if side == "left":
            scale = [0.25, 2.0]
            displ = [xmin - 1.0, 0.0]
            n = [0, len(C) - 2]
        if side == "bottom":
            scale = [2.0, 0.25]
            displ = [0.0, ymin - 2.0]
            n = [len(C) - 2, 0]
        if side == "top":
            scale = [2.0, 0.25]
            displ = [0.0, ymax + 2.0]
            n = [len(C) - 2, 0]

        from caid.cad_geometry import square

        geometry = square()
        values = square(n=n)

        for geo in [geometry, values]:
            for axis in range(0, 2):
                geo.scale(scale[axis], axis=axis)
            geo.translate(displ)

        patch_id = 0
        nrb = values[patch_id]
        P = zeros_like(nrb.points)
        if side == "right":
            P[0, :, 0] = C
            P[1, :, 0] = C
        if side == "left":
            P[0, :, 0] = C
            P[1, :, 0] = C
        if side == "bottom":
            P[:, 0, 0] = C
            P[:, 1, 0] = C
        if side == "top":
            P[:, 0, 0] = C
            P[:, 1, 0] = C
        nrb.set_points(P)
        field.__init__(self, geometry=geometry, values=values, type="scalar")
Example #3
0
def test3():
    # ...
    geo2d = square(n=[3, 3], p=[2, 2])
    con2d = connectivity(geo2d)

    con2d.init_data_structure()
    con2d.printinfo()
Example #4
0
def test3():
    # ...
    geo2d = square(n=[3,3], p=[2,2])
    con2d = connectivity(geo2d)

    con2d.init_data_structure()
    con2d.printinfo()
Example #5
0
    def test2D3():
        spl = splineRefMat(DIM_2D, useDecouple=True)
        list_r1 = list(np.random.random(20))
        list_r2 = list(np.random.random(20))
    #    list_r1 = [0.1, 0.2]
    #    list_r2 = [0.9]

        nx = 20 ; ny = 31
        px = 3 ; py = 2
        geo = square(n=[nx, ny], p=[px, py])

        n = nx + px + 1 + len(list_r1)
        m = ny + py + 1 + len(list_r2)

        dim     = geo.dim
        nrb     = geo[0]

        u1,u2   = nrb.knots
        n1,n2   = nrb.shape
        p1,p2   = nrb.degree

        H1, H2 = spl.construct(list_r1, list_r2, p1, p2, n1, n2, u1, u2)

        assert(np.allclose(np.array(H1.shape), np.array((44,24))))
        assert(np.allclose(np.array(H2.shape), np.array((54,34))))

        print("test2D3: OK")
Example #6
0
    def test2D3():
        spl = splineRefMat(DIM_2D, useDecouple=True)
        list_r1 = list(np.random.random(20))
        list_r2 = list(np.random.random(20))
        #    list_r1 = [0.1, 0.2]
        #    list_r2 = [0.9]

        nx = 20
        ny = 31
        px = 3
        py = 2
        geo = square(n=[nx, ny], p=[px, py])

        n = nx + px + 1 + len(list_r1)
        m = ny + py + 1 + len(list_r2)

        dim = geo.dim
        nrb = geo[0]

        u1, u2 = nrb.knots
        n1, n2 = nrb.shape
        p1, p2 = nrb.degree

        H1, H2 = spl.construct(list_r1, list_r2, p1, p2, n1, n2, u1, u2)

        assert (np.allclose(np.array(H1.shape), np.array((44, 24))))
        assert (np.allclose(np.array(H2.shape), np.array((54, 34))))

        print("test2D3: OK")
Example #7
0
def test3():
    print("====== test 3 : bezier patchs  =====")
    geo = square(p=[px,py])
    u = np.linspace(0., 1.0, nx+2)[1:-1]
    v = np.linspace(0., 1.0, ny+2)[1:-1]
    tx = []
    for t in u:
        tx += [t]*px
    ty = []
    for t in u:
        ty += [t]*py

    geo.refine(list_t=[tx,ty])

    filename = "bezier"
    geo.to_bezier_patchs(filename)
Example #8
0
def test2():
    print("====== test 2 : splines patch =====")
    nx = 3 ; ny = 3
    px = 2 ; py = 2
    geo = square(n=[nx,ny], p=[px,py])
    geo.translate([3.,0.])
    #geo.plotMesh() ; plt.show()
    #geo.append(geo[0])
    #list_lmatrices = geo.bezier_extract()

    nrb = geo[0]
    print((">>> shape ", nrb.shape))
    print((">>> ux    ", nrb.knots[0]))
    print((">>> uy    ", nrb.knots[1]))
    filename = "bezier"
    geo.to_bezier_patchs(filename)
Example #9
0
    def test2D2():
        spl = splineRefMat(DIM_2D)
        list_r1 = list(np.random.random(20))
        list_r2 = list(np.random.random(20))
        #    list_r1 = [0.1, 0.2]
        #    list_r2 = [0.9]

        nx = 20
        ny = 31
        px = 3
        py = 2
        geo = square(n=[nx, ny], p=[px, py])

        n = nx + px + 1 + len(list_r1)
        m = ny + py + 1 + len(list_r2)

        dim = geo.dim
        nrb = geo[0]

        u1, u2 = nrb.knots
        n1, n2 = nrb.shape
        p1, p2 = nrb.degree

        H = spl.construct(list_r1, list_r2, p1, p2, n1, n2, u1, u2)

        Px = nrb.points[:, :, 0].copy()
        Py = nrb.points[:, :, 1].copy()

        geo.refine(id=0, list_t=[list_r1, list_r2])
        nrb = geo[0]
        Qx = np.asarray(nrb.points[:, :, 0])
        Qy = np.asarray(nrb.points[:, :, 1])

        list_P = [Px, Py]
        list_Q = [Qx, Qy]
        #    list_P = [Px]
        #    list_Q = [Qx]
        for (U, Q) in zip(list_P, list_Q):
            nU, mU = U.shape
            vecU = U.transpose().reshape(nU * mU)
            vecP = H.dot(vecU)
            P = vecP.reshape((m, n)).transpose()

            assert (np.allclose(P, Q))

        print("test2D2: OK")
Example #10
0
    def test2D2():
        spl = splineRefMat(DIM_2D)
        list_r1 = list(np.random.random(20))
        list_r2 = list(np.random.random(20))
    #    list_r1 = [0.1, 0.2]
    #    list_r2 = [0.9]

        nx = 20 ; ny = 31
        px = 3 ; py = 2
        geo = square(n=[nx, ny], p=[px, py])

        n = nx + px + 1 + len(list_r1)
        m = ny + py + 1 + len(list_r2)

        dim     = geo.dim
        nrb     = geo[0]

        u1,u2   = nrb.knots
        n1,n2   = nrb.shape
        p1,p2   = nrb.degree

        H = spl.construct(list_r1, list_r2, p1, p2, n1, n2, u1, u2)

        Px      = nrb.points[:,:,0].copy()
        Py      = nrb.points[:,:,1].copy()

        geo.refine(id=0, list_t=[list_r1, list_r2])
        nrb     = geo[0]
        Qx      = np.asarray(nrb.points[:,:,0])
        Qy      = np.asarray(nrb.points[:,:,1])

        list_P = [Px, Py]
        list_Q = [Qx, Qy]
    #    list_P = [Px]
    #    list_Q = [Qx]
        for (U,Q) in zip(list_P, list_Q):
            nU,mU = U.shape
            vecU    = U.transpose().reshape(nU*mU)
            vecP    = H.dot(vecU)
            P       = vecP.reshape((m,n)).transpose()

            assert(np.allclose(P, Q))

        print("test2D2: OK")
Example #11
0
    def test2D1():
        spl = splineRefMat(DIM_1D)
        list_r1 = list(np.random.random(20))
        list_r2 = list(np.random.random(20))

        nx = 10
        ny = 15
        px = 3
        py = 2
        geo = square(n=[nx, ny], p=[px, py])

        dim = geo.dim
        nrb = geo[0]

        u1, u2 = nrb.knots
        n1, n2 = nrb.shape
        p1, p2 = nrb.degree

        M1 = spl.construct(list_r1, p1, n1, u1)
        M2 = spl.construct(list_r2, p2, n2, u2)
        tM2 = M2.transpose().tocsr()

        Px = nrb.points[:, :, 0].copy()
        Py = nrb.points[:, :, 1].copy()

        geo.refine(id=0, list_t=[list_r1, list_r2])
        nrb = geo[0]
        Qx = np.asarray(nrb.points[:, :, 0])
        Qy = np.asarray(nrb.points[:, :, 1])

        from scipy.sparse import csr_matrix

        list_P = [Px, Py]
        list_Q = [Qx, Qy]
        #    list_P = [Px]
        #    list_Q = [Qx]
        for (U, Q) in zip(list_P, list_Q):
            Us = csr_matrix(U).dot(tM2)
            tV = M1.dot(Us).todense()

            assert (np.allclose(tV, Q))

        print("test2D1: OK")
Example #12
0
    def test2D1():
        spl = splineRefMat(DIM_1D)
        list_r1 = list(np.random.random(20))
        list_r2 = list(np.random.random(20))

        nx = 10 ; ny = 15
        px = 3 ; py = 2
        geo = square(n=[nx, ny], p=[px, py])

        dim     = geo.dim
        nrb     = geo[0]

        u1,u2   = nrb.knots
        n1,n2   = nrb.shape
        p1,p2   = nrb.degree

        M1      = spl.construct(list_r1, p1, n1, u1)
        M2      = spl.construct(list_r2, p2, n2, u2)
        tM2     = M2.transpose().tocsr()

        Px      = nrb.points[:,:,0].copy()
        Py      = nrb.points[:,:,1].copy()

        geo.refine(id=0, list_t=[list_r1, list_r2])
        nrb     = geo[0]
        Qx      = np.asarray(nrb.points[:,:,0])
        Qy      = np.asarray(nrb.points[:,:,1])

        from scipy.sparse import csr_matrix

        list_P = [Px, Py]
        list_Q = [Qx, Qy]
    #    list_P = [Px]
    #    list_Q = [Qx]
        for (U,Q) in zip(list_P, list_Q):
            Us  = csr_matrix(U).dot(tM2)
            tV  = M1.dot(Us).todense()

            assert(np.allclose(tV, Q))

        print("test2D1: OK")
Example #13
0
def test2():
    geo = square()

    geo_r = refine(geo, n=[2,2], p=[2,2])
Example #14
0
#        list_faces  = [0, 1, 2, 3]
#        list_colors = ['k']*4
##        list_colors = ['r', 'g', 'b', 'k']
#        for (face, color) in zip(list_faces, list_colors):
#            nrb_bnd = nrb.extract_face(face)
#            plot_crv(nrb_bnd, t1, t2, tangent=False, normal=False, color=color,
#                     label='Face '+str(face))
# ...

nx = 3
ny = 3
px = 2
py = 2

# ... Import the square domain
geo_1 = square(n=[nx, ny], p=[px, py])

# ... Import the square domain
geo_2 = square(n=[nx, ny], p=[px, py])
geo_2[0].translate(1.0, axis=0)

# ... Import the square domain
geo_3 = square(n=[nx, ny], p=[px, py])
geo_3[0].translate(1.0, axis=1)

# ... Import the square domain
geo_4 = square(n=[nx, ny], p=[px, py])
geo_4[0].translate(1.0, axis=0)
geo_4[0].translate(1.0, axis=1)

geo_12 = geo_1.merge(geo_2)
Example #15
0
                    if nrbInfo.NurbsColor is not None:
                        _NurbsColor = asarray(nrbInfo.NurbsColor).copy()
                    NurbsSteps = nrbInfo.steps
                    evaluator = self.GetEvaluator(nrb \
                                                  , MeshColor=MeshColor \
                                                  , NurbsColor=_NurbsColor \
                                                  , alpha=alpha\
                                                  , steps=NurbsSteps)
                    showMesh = self.showMesh or nrbInfo.showMesh
                    evaluator.draw(mesh=showMesh, nurbs=True, blend=blend)
                if self.showPoints or nrbInfo.showPoints:
                    # Draw control points
                    self.DrawControlPoints(nrb \
                                           , PointsColor=PointsColor \
                                           ,alpha=alpha, blend=blend)


#######################################################################
if __name__ == '__main__':
    from caid.cad_geometry import square
    import matplotlib.pyplot as plt
    s1 = square(n=[3, 3])
    geo1 = geometry()
    for nrb in s1:
        geo1.append(nrb)
    geo1.plotMesh()
    plt.show()
    geo2 = geometry(s1)
    geo2.plotMesh()
    plt.show()
except:
    py = 3
#-----------------------------------

#-----------------------------------
# ...
# exact solution
# ...
u_exact = lambda x, y: [exp(0.5 * (x**2 + y**2))]
u0 = lambda x, y: 0.5 * (x**2 + y**2)
f0 = lambda x, y: (1. + x**2 + y**2) * exp(x**2 + y**2)
# ...
#-----------------------------------

#-----------------------------------
geo = square(n=[nx, ny], p=[px, py])
#-----------------------------------

#-----------------------------------
# ...
# values of u at the boundary
# ...
bc_dirichlet = {}
for data in geo.external_faces:
    patch_id = int(data[0])
    face_id = int(data[1])
    bc_dirichlet[patch_id, face_id] = u_exact
# ...
#-----------------------------------

with context():
Example #17
0
import numpy as np
from caid.cad_geometry import square
from caid.io import NML

geo = square(n=[31, 31], p=[1, 1])
nml_io = NML()
nml_io.write('domain_selalib.nml', geo)
Example #18
0
    #    print bez.degree
    #
    #    print (">>>>>>>>>>>>> square")
    #    bezier = square(p=[4,4])[0]
    #    bez = Bezier(control=bezier.points)
    ##    print bez.knots
    #    print bez.shape
    #    print bez.degree
    #
    #    print (">>>>>>>>>>>>> trilinear")
    #    bezier = trilinear(p=[3,3,3])[0]
    #    bez = Bezier(control=bezier.points)
    ##    print bez.knots
    #    print bez.shape
    #    print bez.degree

    print(">>>>>>>>>>>>> square extraction")
    geo = square(n=[3, 3], p=[2, 2])
    nrb = geo[0]
    #    geo_ref, list_lmatrices = geo.bezier_extract()
    #    print len(list_lmatrices)
    #    print geo_ref[0].shape
    #
    #    geo_f = geo.toBezier(0)
    #    print len(geo_f)

    #    bb = Bezier_Patchs(geometry=geo)
    bb = Beziers(nrb)

    print("done")
Example #19
0
import numpy as np
from caid.cad_geometry import square
from caid.io import NML

geo = square(n=[31,31],p=[1,1])
nml_io = NML()
nml_io.write('domain_selalib.nml',geo)


Example #20
0
def test2():
    geo = square()

    geo_r = refine(geo, n=[2, 2], p=[2, 2])
Example #21
0
#
#        list_faces  = [0, 1, 2, 3]
#        list_colors = ['k']*4
##        list_colors = ['r', 'g', 'b', 'k']
#        for (face, color) in zip(list_faces, list_colors):
#            nrb_bnd = nrb.extract_face(face)
#            plot_crv(nrb_bnd, t1, t2, tangent=False, normal=False, color=color,
#                     label='Face '+str(face))
# ...


nx = 3 ; ny = 3
px = 2 ; py = 2

# ... Import the square domain
geo_1 = square(n=[nx,ny],p=[px,py])

# ... Import the square domain
geo_2 = square(n=[nx,ny],p=[px,py])
geo_2[0].translate(1.0, axis=0)

# ... Import the square domain
geo_3 = square(n=[nx,ny],p=[px,py])
geo_3[0].translate(1.0, axis=1)

# ... Import the square domain
geo_4 = square(n=[nx,ny],p=[px,py])
geo_4[0].translate(1.0, axis=0)
geo_4[0].translate(1.0, axis=1)

geo_12 = geo_1.merge(geo_2)
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))
    weights[1, 0] = s
    weights[0, 1] = s
    weights[2, 1] = s
    weights[1, 2] = s

    srf = cad_nurbs([U, V], C, weights=weights)
    geo = cad_geometry()
    geo.append(srf)
Example #23
0
        wk = self.WorkGroup
        keycode = event.GetKeyCode()
        if keycode == wx.WXK_DELETE:
            wk.directAct.removeObject()

class MyApp(wx.App):
    '''Our application class
    '''
    def OnInit(self):
        '''Initialize by creating the split window with the tree
        '''
        frame = Inspector(None, -1, 'Inspector')
        frame.Show(True)
        self.SetTopWindow(frame)
        self.frame = frame

        return True

if __name__ == '__main__':
    app = MyApp(0)
    frame = app.frame
    tree = frame.tree
    from caid.cad_geometry import circle_5mp, square
    s1 = circle_5mp()
    s2 = square()
    geo1 = geometry(s1)
    geo2 = geometry(s2)
    tree.add_geometry(geo1)
    tree.add_geometry(geo2)
    app.MainLoop()
Example #24
0
def run(filename):
    # ...
    from caid.cad_geometry import square
    geometry = square()
    mapping = Mapping(geometry=geometry)
    # ...

    # ...
    import os

    cmd = "mkdir -p output"
    os.system(cmd)
    # ...

    # ... creates discretization parameters
    from clapp.disco.parameters.bspline import BSpline

    bspline_params = BSpline([8,8], [2,2], \
                             bc_min=[0,0], \
                             bc_max=[0,0])
    # ...

    # ... create a context from discretization
    context = Context(dirname="input", \
                      discretization_params=bspline_params)
    # ...

    # ...
    vale = Vale(filename=filename)
    pde = vale.parse(context, mapping)
    # ...

    # ... accessing the pde declarations
    V = pde["V"]
    u = pde["u"]
    form_a = pde["a"]
    form_b = pde["b"]

    assembler_a = form_a.assembler
    matrix = form_a.matrix
    assembler_b = form_b.assembler
    rhs = form_b.vector

    assembler_a.assemble()
    assembler_b.assemble()
    # ...

    # ...
    from clapp.plaf.parameters.linear_solver import LAPACK_LU
    from clapp.plaf.parameters.linear_solver import DRIVER

    params = DRIVER(solver=LAPACK_LU())
    linsol = Linear_solver(matrix=matrix, dirname="input", parameters=params)
    # ...

    # ...
    y = linsol.solve(rhs)
    # ...

    # ... exports the field
    u.set(y)
    # ...

    # ... plot field using matplotlib
    filename_out = "uh_2d_" + filename.split('/')[-1].split('.')[0] + ".png"

    u.plot(n_pts=100)
    plt.savefig(filename_out)
    # ...

    # ... compute L2 error
    x = u.compute_l2_error(mapping=mapping, \
                           function_name="u_analytic")
    print(">> norms : ", x)
    # ...

    # ...
    cmd = "rm -rf input"
    os.system(cmd)
    # ...

    # ...
    plt.clf()
    # ...

    print("> run using ", filename, " passed.")
Example #25
0

class MyApp(wx.App):
    """Our application class
    """

    def OnInit(self):
        """Initialize by creating the split window with the tree
        """
        frame = Inspector(None, -1, "Inspector")
        frame.Show(True)
        self.SetTopWindow(frame)
        self.frame = frame

        return True


if __name__ == "__main__":
    app = MyApp(0)
    frame = app.frame
    tree = frame.tree
    from caid.cad_geometry import circle_5mp, square

    s1 = circle_5mp()
    s2 = square()
    geo1 = geometry(s1)
    geo2 = geometry(s2)
    tree.add_geometry(geo1)
    tree.add_geometry(geo2)
    app.MainLoop()
from caid.numbering.connectivity import connectivity
from caid.utils.quadratures import *

############################################################
if __name__=="__main__":
    from caid.cad_geometry import square, circle, circle_5mp

#    px = 1; py = 1
#    px = 2; py = 2
    px = 3; py = 3
#    px = 4; py = 4
#    px = 5; py = 5

#    geo = square(n=[1,1], p=[px,py])
#    geo = square(n=[3,3], p=[px,py])
#    geo = square(n=[7,7], p=[px,py])
#    geo = square(n=[15,15], p=[px,py])
    geo = square(n=[31,31], p=[px,py])
#    geo = square(n=[63,63], p=[px,py])




#    geo = circle_5mp(n=[3,3], p=[3,3])

    basename = "splines"
    from caid.io import BZR
    rw = BZR()
    rw.write(basename, geo, fmt="txt")

try:
    ny = int(sys.argv[2])
except:
    ny = 15

try:
    px = int(sys.argv[3])
except:
    px = 2

try:
    py = int(sys.argv[4])
except:
    py = 2

geo = square(n=[nx, ny], p=[px, py])
#geo   = circle(radius=1.,n=[nx,ny], p=[px,py])
#geo   = quart_circle(n=[nx,ny], p=[px,py])
#geo   = annulus(n=[nx,ny], p=[px,py])

#from caid.cad_geometry import cad_geometry as domain
#geo = domain("input/iter_inner.xml")
#-----------------------------------

#-----------------------------------
tc = testcase(1)
rho0 = tc.rho0
rho1 = tc.rho1

verbose = 1
Example #28
0
import numpy as np
from caid.cad_geometry import square, cad_nurbs, cad_geometry
#from igakit.nurbs import NURBS

sqr = square(n=[0, 0], p=[2, 2])[0]
U, V = sqr.knots
C = sqr.points

s = 1. / np.sqrt(2)
weights = np.ones((3, 3))
weights[1, 0] = s
weights[0, 1] = s
weights[2, 1] = s
weights[1, 2] = s
srf = cad_nurbs([U, V], C, weights=weights)
geo = cad_geometry()
geo.append(srf)

try:
    nx, ny
except:
    nx = 3
    ny = 5

tx = np.linspace(0., 1., nx + 2)[1:-1]
ty = np.linspace(0., 1., ny + 2)[1:-1]
geo.refine(0, list_t=[tx, ty])
geo._internal_faces = []
geo._external_faces = [[0, 0], [0, 1], [0, 2], [0, 3]]
geo._connectivity = []
Example #29
0
    blue.append(1)
    blue.append(11)
    blue.append(111)
    print("blue.n = ", blue.n)
    for obj in blue:
        print(obj)
    # --------------------------------------

    # --------------------------------------
    # operator class test
    # --------------------------------------
    print(">>> operator class test")
    from pigasus.gallery.poisson import poisson
    from pigasus.gallery.bilaplacian import bilaplacian
    from caid.cad_geometry import square
    geo = square(n=[3, 3], p=[2, 2])
    PDE_1 = bilaplacian(geometry=geo)
    PDE_2 = poisson(geometry=geo, V=PDE_1.V)
    PDE_3 = poisson(geometry=geo, V=PDE_1.V)
    PDE_4 = poisson(geometry=geo)

    #    print id(PDE_1.V), PDE_1.V.id
    #    print id(PDE_2.V), PDE_2.V.id
    #    print "---"
    #    print PDE_1.operators
    #    print PDE_2.operators

    S_1 = PDE_1.D2
    S_2 = PDE_2.stiffness
    S_3 = PDE_3.stiffness
    S_4 = PDE_4.stiffness
Example #30
0
                nrbInfo = self.list_patchInfo[i]
                if nrbInfo.show:
                    _NurbsColor = asarray(NurbsColor).copy()
                    if nrbInfo.NurbsColor is not None:
                        _NurbsColor = asarray(nrbInfo.NurbsColor).copy()
                    NurbsSteps = nrbInfo.steps
                    evaluator = self.GetEvaluator(
                        nrb, MeshColor=MeshColor, NurbsColor=_NurbsColor, alpha=alpha, steps=NurbsSteps
                    )
                    showMesh = self.showMesh or nrbInfo.showMesh
                    evaluator.draw(mesh=showMesh, nurbs=True, blend=blend)
                if self.showPoints or nrbInfo.showPoints:
                    # Draw control points
                    self.DrawControlPoints(nrb, PointsColor=PointsColor, alpha=alpha, blend=blend)


#######################################################################
if __name__ == "__main__":
    from caid.cad_geometry import square
    import matplotlib.pyplot as plt

    s1 = square(n=[3, 3])
    geo1 = geometry()
    for nrb in s1:
        geo1.append(nrb)
    geo1.plotMesh()
    plt.show()
    geo2 = geometry(s1)
    geo2.plotMesh()
    plt.show()
Example #31
0
# coding: utf-8
import numpy as np
from caid.numbering.connectivity import connectivity
from caid.utils.quadratures import *

############################################################
if __name__ == "__main__":
    from caid.cad_geometry import square, circle, circle_5mp

    #    px = 1; py = 1
    #    px = 2; py = 2
    px = 3
    py = 3
    #    px = 4; py = 4
    #    px = 5; py = 5

    #    geo = square(n=[1,1], p=[px,py])
    #    geo = square(n=[3,3], p=[px,py])
    #    geo = square(n=[7,7], p=[px,py])
    #    geo = square(n=[15,15], p=[px,py])
    geo = square(n=[31, 31], p=[px, py])
    #    geo = square(n=[63,63], p=[px,py])

    #    geo = circle_5mp(n=[3,3], p=[3,3])

    basename = "splines"
    from caid.io import BZR
    rw = BZR()
    rw.write(basename, geo, fmt="txt")