示例#1
0
文件: terms.py 项目: midhuniitm/sfepy
    def get_physical_qps(self):
        """
        Get physical quadrature points corresponding to the term region
        and integral.
        """
        from sfepy.discrete.common.mappings import get_physical_qps, PhysicalQPs

        if self.integration == "point":
            phys_qps = PhysicalQPs()

        elif self.integration == "plate":
            phys_qps = get_physical_qps(self.region, self.integral, map_kind="v")

        else:
            phys_qps = get_physical_qps(self.region, self.integral)

        return phys_qps
示例#2
0
文件: terms.py 项目: marcinch18/sfepy
    def get_physical_qps(self):
        """
        Get physical quadrature points corresponding to the term region
        and integral.
        """
        from sfepy.discrete.common.mappings import get_physical_qps, PhysicalQPs

        if self.integration == 'point':
            phys_qps = PhysicalQPs(self.region.igs)

        elif self.integration == 'plate':
            phys_qps = get_physical_qps(self.region,
                                        self.integral,
                                        map_kind='v')

        else:
            phys_qps = get_physical_qps(self.region, self.integral)

        return phys_qps
示例#3
0
    def test_invariance_qp(self):
        from sfepy import data_dir
        from sfepy.discrete import Integral
        from sfepy.terms import Term
        from sfepy.discrete.common.mappings import get_physical_qps

        ok = True
        for name in [
            "meshes/3d/block.mesh",
            "meshes/3d/cylinder.mesh",
            "meshes/2d/square_quad.mesh",
            "meshes/2d/square_unit_tri.mesh",
        ]:
            self.report(name)

            u = prepare_variable(op.join(data_dir, name), n_components=3)
            omega = u.field.region

            integral = Integral("i", order=3)
            qps = get_physical_qps(omega, integral)
            coors = qps.values

            term = Term.new("ev_volume_integrate(u)", integral, omega, u=u)
            term.setup()
            val1 = term.evaluate(mode="qp")
            val1 = val1.ravel()

            val2 = u.evaluate_at(coors).ravel()

            self.report("value: max. difference:", nm.abs(val1 - val2).max())
            ok1 = nm.allclose(val1, val2, rtol=0.0, atol=1e-12)
            self.report("->", ok1)

            term = Term.new("ev_grad(u)", integral, omega, u=u)
            term.setup()
            val1 = term.evaluate(mode="qp")
            val1 = val1.ravel()

            val2 = u.evaluate_at(coors, mode="grad").ravel()

            self.report("gradient: max. difference:", nm.abs(val1 - val2).max())
            ok2 = nm.allclose(val1, val2, rtol=0.0, atol=1e-10)
            self.report("->", ok2)

            ok = ok and ok1 and ok2

        return ok
示例#4
0
    def test_invariance_qp(self):
        from sfepy import data_dir
        from sfepy.discrete import Integral
        from sfepy.terms import Term
        from sfepy.discrete.common.mappings import get_physical_qps

        ok = True
        for name in [
                'meshes/3d/block.mesh', 'meshes/3d/cylinder.mesh',
                'meshes/2d/square_quad.mesh', 'meshes/2d/square_unit_tri.mesh'
        ]:
            self.report(name)

            u = prepare_variable(op.join(data_dir, name), n_components=3)
            omega = u.field.region

            integral = Integral('i', order=3)
            qps = get_physical_qps(omega, integral)
            coors = qps.values

            term = Term.new('ev_volume_integrate(u)', integral, omega, u=u)
            term.setup()
            val1 = term.evaluate(mode='qp')
            val1 = val1.ravel()

            val2 = u.evaluate_at(coors).ravel()

            self.report('value: max. difference:', nm.abs(val1 - val2).max())
            ok1 = nm.allclose(val1, val2, rtol=0.0, atol=1e-12)
            self.report('->', ok1)

            term = Term.new('ev_grad(u)', integral, omega, u=u)
            term.setup()
            val1 = term.evaluate(mode='qp')
            val1 = val1.ravel()

            val2 = u.evaluate_at(coors, mode='grad').ravel()

            self.report('gradient: max. difference:',
                        nm.abs(val1 - val2).max())
            ok2 = nm.allclose(val1, val2, rtol=0.0, atol=1e-10)
            self.report('->', ok2)

            ok = ok and ok1 and ok2

        return ok
示例#5
0
    def test_invariance_qp(self):
        from sfepy import data_dir
        from sfepy.discrete import Variables, Integral
        from sfepy.discrete.fem import Mesh, FEDomain, Field
        from sfepy.terms import Term
        from sfepy.discrete.common.mappings import get_physical_qps

        mesh = Mesh.from_file(data_dir + '/meshes/3d/block.mesh')

        bbox = mesh.get_bounding_box()
        dd = bbox[1,:] - bbox[0,:]
        data = nm.sin(4.0 * nm.pi * mesh.coors[:,0:1] / dd[0]) \
               * nm.cos(4.0 * nm.pi * mesh.coors[:,1:2] / dd[1])

        variables = {
            'u'       : ('unknown field', 'scalar_tp', 0),
            'v'       : ('test field',    'scalar_tp', 'u'),
        }

        domain = FEDomain('domain', mesh)
        omega = domain.create_region('Omega', 'all')
        field = Field.from_args('scalar_tp', nm.float64, 1, omega,
                                approx_order=1)
        ff = {field.name : field}

        vv = Variables.from_conf(transform_variables(variables), ff)
        u = vv['u']
        u.set_from_mesh_vertices(data)

        integral = Integral('i', order=2)
        term = Term.new('ev_volume_integrate(u)', integral, omega, u=u)
        term.setup()
        val1 = term.evaluate(mode='qp')
        val1 = val1.ravel()

        qps = get_physical_qps(omega, integral)
        coors = qps.values

        val2 = u.evaluate_at(coors).ravel()

        self.report('max. difference:', nm.abs(val1 - val2).max())
        ok = nm.allclose(val1, val2, rtol=0.0, atol=1e-12)
        self.report('invariance in qp: %s' % ok)

        return ok
示例#6
0
    def get_surface_basis(self, region):
        """
        Get basis for projections to region's facets.

        Notes
        -----
        Cannot be uses for all fields because IGA does not support surface
        mappings.
        """
        order = self.approx_order

        integral = Integral('i', order=2 * order)
        geo, mapping = self.get_mapping(region, integral, 'surface')
        pqps = get_physical_qps(region, integral)
        qps = pqps.values.reshape(pqps.shape)

        bfs = nm.broadcast_to(
            geo.bf[..., 0, :],
            (qps.shape[0], qps.shape[1], geo.bf.shape[3]),
        )

        return qps, bfs, geo.det[..., 0]