コード例 #1
0
#!/usr/bin/env python3
# 
import sys

import numpy as np
from scipy.sparse.linalg import cg, LinearOperator
from scipy.sparse import coo_matrix, csr_matrix, csc_matrix, spdiags, bmat

from fealpy.pde.linear_elasticity_model import  PolyModel3d as PDE
from fealpy.functionspace import LagrangeFiniteElementSpace
from fealpy.boundarycondition import DirichletBC 
from fealpy.solver.LinearElasticityRLFEMFastSolver import LinearElasticityRLFEMFastSolver as FastSovler

n = int(sys.argv[1])

pde = PDE(lam=100.0, mu=1.0)
mu = pde.mu
lam = pde.lam
mesh = pde.init_mesh(n=n)

space = LagrangeFiniteElementSpace(mesh, p=1, q=1)
M, G = space.recovery_linear_elasticity_matrix(lam, mu, format=None)
F = space.source_vector(pde.source, dim=3)

uh = space.function(dim=3)    
isBdDof = space.set_dirichlet_bc(uh, pde.dirichlet)   

solver = FastSovler(lam, mu, M, G, isBdDof)

solver.solve(uh, F, tol=1e-12)
コード例 #2
0
from fealpy.pde.linear_elasticity_model import PolyModel3d, Model2d, HuangModel2d
from fealpy.mesh.simple_mesh_generator import rectangledomainmesh
from fealpy.fem.LinearElasticityFEMModel import LinearElasticityFEMModel 
from fealpy.tools.show import showmultirate

import numpy as np  
import matplotlib.pyplot as plt


m = int(sys.argv[1])
p = int(sys.argv[2])
n = int(sys.argv[3])

if m == 1:
    pde = PolyModel3d()
if m == 2:
    pde = Model2d()
if m == 3:
    pde = SimplifyModel2d()
if m == 4:
    pde = HuangModel2d()

#box = [0, 1, 0, 1]
#mesh = rectangledomainmesh(box, nx=n, ny=n)

mesh = pde.init_mesh(n)
integrator = mesh.integrator(7)

maxit = 3 
コード例 #3
0
#!/usr/bin/env python3
#
import sys

import numpy as np
from scipy.sparse.linalg import spsolve
from scipy.sparse import coo_matrix, csr_matrix, spdiags, bmat
from scipy.sparse.linalg import spsolve, cg, LinearOperator, spilu

from fealpy.pde.linear_elasticity_model import PolyModel3d
from fealpy.functionspace import LagrangeFiniteElementSpace
from fealpy.boundarycondition import DirichletBC

n = int(sys.argv[1])

pde = PolyModel3d(lam=10000, mu=1.0)
mesh = pde.init_mesh(n=n)

space = LagrangeFiniteElementSpace(mesh, p=1, q=3)
uh = space.function(dim=3)

A = space.linear_elasticity_matrix(pde.lam, pde.mu)
F = space.source_vector(pde.source, dim=3)

bc = DirichletBC(space, pde.dirichlet)
A, F = bc.apply(A, F, uh)

uh.T.flat[:], info = cg(A, F, tol=1e-10)

error = space.integralalg.L2_error(pde.displacement, uh)