Beispiel #1
0
    def __init__(self, doflocs, t, **kwargs):

        warnings.warn("MeshTri2 is an experimental feature and "
                      "not governed by the semantic versioning. "
                      "Several features of MeshTri are still "
                      "missing.")

        if t.shape[0] == 6:
            dofs, ix = np.unique(t[:3], return_inverse=True)
            super(MeshTri2, self).__init__(
                doflocs[:, dofs],
                np.arange(len(dofs), dtype=np.int)[ix].reshape(t[:3].shape),
                sort_t=False,
                **kwargs)
        else:
            # fallback for refinterp
            super(MeshTri2, self).__init__(doflocs, t, **kwargs)
        from skfem.element import ElementTriP2
        from skfem.assembly import InteriorBasis
        from skfem.mapping import MappingAffine
        self._elem = ElementTriP2()
        self._basis = InteriorBasis(self, self._elem, MappingAffine(self))
        self._mesh = MeshTri.from_basis(self._basis)
        if t.shape[0] == 6:
            self._mesh.p = doflocs
            self._mesh.t = t
Beispiel #2
0
 def _mapping(self):
     """Return a default reference mapping for the mesh."""
     from skfem.mapping import MappingAffine, MappingIsoparametric
     if not hasattr(self, '_cached_mapping'):
         if self.affine:
             self._cached_mapping = MappingAffine(self)
         else:
             self._cached_mapping = MappingIsoparametric(
                 self,
                 self.elem(),
                 self.bndelem,
             )
     return self._cached_mapping
Beispiel #3
0
    def check_equivalence(self, ec, ev):
        X = np.array([[0.125, 0.1111], [0.0555, 0.6]])
        m = MeshTri.init_refdom()
        mapping = MappingAffine(m)

        for k in range(6):
            for i in [0, 1]:
                # accessing i'th component looks slightly different
                assert_array_equal(
                    ev.gbasis(mapping, X, k)[0].f[i],
                    ec.gbasis(mapping, X, k)[i].f)
                for j in [0, 1]:
                    assert_array_equal(
                        ev.gbasis(mapping, X, k)[0].df[i][j],
                        ec.gbasis(mapping, X, k)[i].df[j])
Beispiel #4
0
 def mapping(self):
     return MappingAffine(self)
Beispiel #5
0
 def mapping(self):
     from skfem.mapping import MappingAffine
     return MappingAffine(self)