diff --git a/fealpy/fem/LinearElasticityOperatorIntegrator.py b/fealpy/fem/LinearElasticityOperatorIntegrator.py index 316931d85..4bd1c1902 100644 --- a/fealpy/fem/LinearElasticityOperatorIntegrator.py +++ b/fealpy/fem/LinearElasticityOperatorIntegrator.py @@ -1,23 +1,24 @@ import numpy as np class LinearElasticityOperatorIntegrator: - def __init__(self, lam, mu, q=3): + def __init__(self, lam, mu, q=None): self.lam = lam self.mu = mu - self.q = q + self.q = q def assembly_cell_matrix(self, space, index=np.s_[:], cellmeasure=None, out=None): """ construct the linear elasticity fem matrix """ - q = self.q lam = self.lam mu = self.mu - - GD = len(space) mesh = space[0].mesh ldof = space[0].number_of_local_dofs() + p = space[0].p + GD = mesh.geo_dimension() + q = self.q if self.q is not None else p+1 + if cellmeasure is None: cellmeasure = mesh.entity_measure('cell', index=index) diff --git a/test/fem/test_linear_elasticity.py b/test/fem/test_linear_elasticity.py new file mode 100644 index 000000000..11a39f220 --- /dev/null +++ b/test/fem/test_linear_elasticity.py @@ -0,0 +1,26 @@ +import numpy as np + +import pytest + +def test_linear_elasticity_lfem(p, n): + """ + @brief Lagrange 元求解线弹性问题 + """ + from fealpy.pde.linear_elasticity_model import BoxDomainData2d + from fealpy.mesh import TriangleMesh + from fealpy.functionspace import LagrangeFESpace as Space + from fealpy.functionspace import LagrangeFiniteElementSpace as OldSpace + from fealpy.fem import LinearElasticityOperatorIntegrator + from fealpy.fem import BilinearForm + from fealpy.fem import LinearForm + + pde = BoxDomainData2d() + domain = pde.domain() + mesh = TriangleMesh.from_box(box=domain, nx=n, ny=n) + space = Space(mesh, p=p) + + bform = BilinearForm(space) + bform.add_domain_integrator(LinearElasticityOperatorIntegrator(pde.lam) + bform.assembly() + +