Ejemplo n.º 1
0
 def setUp(self):
     super().setUp()
     self.seq = nutils.transformseq.DerivedTransforms(
         nutils.transformseq.PlainTransforms([(x1, s0), (x1, s1)],
                                             fromdims=1),
         References.uniform(line, 2), 'child_transforms', 1)
     self.check = (x1, s0, c0), (x1, s0, c1), (x1, s1, c0), (x1, s1, c1)
     self.checkmissing = (l1, s0), (x1, s0), (x1, s1), (r1, s0)
     self.checkrefs = References.uniform(line, 4)
     self.checkfromdims = 1
Ejemplo n.º 2
0
 def setUp(self):
     super().setUp()
     self.seq = nutils.transformseq.EmptyTransforms(fromdims=1)
     self.check = ()
     self.checkmissing = (l1, s0), (x1, s4), (r1, s0)
     self.checkrefs = References.empty(1)
     self.checkfromdims = 1
Ejemplo n.º 3
0
 def setUp(self):
     super().setUp()
     self.seq = nutils.transformseq.StructuredTransforms(
         x1, [nutils.transformseq.BndAxis(3, 3, 0, True)], 0)
     self.check = (x1, s2, e0),
     self.checkmissing = (x1, s0, e0), (x1, s3, e1), (x1, s4, e0)
     self.checkrefs = References.uniform(point, 1)
     self.checkfromdims = 0
Ejemplo n.º 4
0
 def setUp(self):
     super().setUp()
     self.seq = nutils.transformseq.StructuredTransforms(
         x1, [nutils.transformseq.DimAxis(0, 4, False)], 0)
     self.check = (x1, s0), (x1, s1), (x1, s2), (x1, s3)
     self.checkmissing = (l1, s0), (x1, s4), (r1, s0), (x1, c1)
     self.checkrefs = References.uniform(line, 4)
     self.checkfromdims = 1
Ejemplo n.º 5
0
 def test_DerivedTransforms_ndims_mismatch(self):
     transforms = nutils.transformseq.PlainTransforms([(x1, s0), (x1, s1)],
                                                      1)
     references = References.uniform(square, 2)
     with self.assertRaisesRegex(
             ValueError,
             '`parent` and `parent_references` have different dimensions'):
         nutils.transformseq.DerivedTransforms(transforms, references,
                                               'child_transforms', 1)
Ejemplo n.º 6
0
 def setUp(self):
     super().setUp()
     self.seq = nutils.transformseq.PlainTransforms([(x1, s0), (x1, s1),
                                                     (x1, s2), (x1, s3)],
                                                    fromdims=1)
     self.check = (x1, s0), (x1, s1), (x1, s2), (x1, s3)
     self.checkmissing = (l1, s0), (x1, s4), (r1, s0)
     self.checkrefs = References.uniform(line, 4)
     self.checkfromdims = 1
Ejemplo n.º 7
0
 def test_boundary_gradient(self):
   ref = _refined_refs[self.etype]
   trans = (transform.Identifier(ref.ndims, 'root'),)
   domain = topology.ConnectedTopology(References.uniform(ref, 1), transformseq.PlainTransforms([trans], ref.ndims), transformseq.PlainTransforms([trans], ref.ndims), ((-1,)*ref.nedges,)).refine(self.ref0)
   geom = function.rootcoords(ref.ndims)
   basis = domain.basis('std', degree=1)
   u = domain.projection(geom.sum(), onto=basis, geometry=geom, degree=2)
   bpoints = domain.refine(self.ref1).boundary.refine(self.ref2).sample('uniform', 1)
   g = bpoints.eval(u.grad(geom))
   numpy.testing.assert_allclose(g, 1)
Ejemplo n.º 8
0
 def test_DerivedTransforms_length_mismatch(self):
     transforms = nutils.transformseq.PlainTransforms([(x1, s0), (x1, s1)],
                                                      1)
     references = References.uniform(line, 3)
     with self.assertRaisesRegex(
             ValueError,
             '`parent` and `parent_references` should have the same length'
     ):
         nutils.transformseq.DerivedTransforms(transforms, references,
                                               'child_transforms', 1)
Ejemplo n.º 9
0
 def setUp(self):
     super().setUp()
     self.seq = nutils.transformseq.ReorderedTransforms(
         nutils.transformseq.PlainTransforms([(x2, s00), (x2, s01),
                                              (x2, s10), (x2, s11)],
                                             fromdims=2), [0, 2, 3, 1])
     self.check = (x2, s00), (x2, s10), (x2, s11), (x2, s01)
     self.checkmissing = (l2, s00), (x2, s02), (x2, s12), (r2, s00)
     self.checkrefs = References.uniform(square, 4)
     self.checkfromdims = 2
Ejemplo n.º 10
0
 def setUp(self):
     super().setUp()
     self.seq = nutils.transformseq.PlainTransforms([(x2, s00), (x2, s01),
                                                     (x2, s10), (x2, s11)],
                                                    fromdims=2)
     self.check = (x2, s00), (x2, s01), (x2, s10), (x2, s11)
     self.checkmissing = (l2, s00), (x2, s02), (x2, s12), (r2, s00)
     self.checkrefs = References.from_iter(
         (square, square, triangle, triangle), 2)
     self.checkfromdims = 2
Ejemplo n.º 11
0
 def setUp(self):
     super().setUp()
     self.seq = nutils.transformseq.StructuredTransforms(
         x2, [
             nutils.transformseq.DimAxis(0, 2, False),
             nutils.transformseq.DimAxis(2, 4, False)
         ], 0)
     self.check = (x2, s02), (x2, s03), (x2, s12), (x2, s13)
     self.checkmissing = (x2, s00), (x2, s01), (x2, s10), (x2, s11)
     self.checkrefs = References.uniform(square, 4)
     self.checkfromdims = 2
Ejemplo n.º 12
0
 def setUp(self):
     super().setUp()
     self.seq = nutils.transformseq.StructuredTransforms(
         x1, [nutils.transformseq.PIntAxis(0, 4, 0, False)], 0)
     self.check = (x1, s1, e1), (x1, s2, e1), (x1, s3, e1), (x1, s0, e1)
     self.checkmissing = (x1, s0, e0), (x1, s1, e0), (x1, s2,
                                                      e0), (x1, s3,
                                                            e0), (x1, s4,
                                                                  e0)
     self.checkrefs = References.uniform(point, 3)
     self.checkfromdims = 0
Ejemplo n.º 13
0
 def setUp(self):
     super().setUp()
     self.seq = nutils.transformseq.IdentifierTransforms(ndims=2,
                                                         name='foo',
                                                         length=4)
     self.check = [(nutils.transform.Identifier(2, ('foo', i)), )
                   for i in range(4)]
     self.checkmissing = (nutils.transform.Identifier(
         1, ('foo', 0)), ), (nutils.transform.Identifier(
             2, ('foo', -1)), ), (nutils.transform.Identifier(
                 2, ('foo', 4)), ), (nutils.transform.Identifier(
                     2, ('bar', 0)), )
     self.checkrefs = References.uniform(triangle, 4)
     self.checkfromdims = 2
Ejemplo n.º 14
0
    self.assertEqual(len(refined), len(checktransforms))
    self.assertEqual(set(refined.transforms), set(checktransforms))
    for ref, trans in zip(refined.references, refined.transforms):
      self.assertEqual(ref, checkreferences[checktransforms.index(trans)])

  def test_refine_iter(self):
    level_iter = iter(self.topo.refine_iter)
    check = self.topo
    for i in range(4):
      level = next(level_iter)
      self.assertEqual(level, check)
      check = check.refined

common(
  'Topology',
  topo=topology.Topology(References.uniform(element.PointReference(), 1), transformseq.PlainTransforms([(transform.Identifier(0, 'test'),)], 0), transformseq.PlainTransforms([(transform.Identifier(0, 'test'),)], 0)),
  hasboundary=False)
common(
  'StructuredTopology:2D',
  topo=mesh.rectilinear([2,2])[0])
common(
  'UnionTopology',
  topo=topology.UnionTopology([mesh.rectilinear([8])[0][l:r] for l, r in [[0,2],[4,6]]]),
  hasboundary=False,
  hasbasis=False)
common(
  'DisjointUnionTopology',
  topo=topology.DisjointUnionTopology([mesh.rectilinear([8])[0][l:r] for l, r in [[0,2],[4,6]]]),
  hasboundary=False,
  hasbasis=False)
Ejemplo n.º 15
0
        for ref, trans in zip(refined.references, refined.transforms):
            self.assertEqual(ref,
                             checkreferences[checktransforms.index(trans)])

    def test_refine_iter(self):
        level_iter = iter(self.topo.refine_iter)
        check = self.topo
        for i in range(4):
            level = next(level_iter)
            self.assertEqual(level, check)
            check = check.refined


common('Topology',
       topo=topology.Topology(
           References.uniform(element.PointReference(), 1),
           transformseq.PlainTransforms([(transform.Identifier(0, 'test'), )],
                                        0),
           transformseq.PlainTransforms([(transform.Identifier(0, 'test'), )],
                                        0)),
       hasboundary=False)
common('StructuredTopology:2D', topo=mesh.rectilinear([2, 2])[0])
common('UnionTopology',
       topo=topology.UnionTopology(
           [mesh.rectilinear([8])[0][l:r] for l, r in [[0, 2], [4, 6]]]),
       hasboundary=False,
       hasbasis=False)
common('DisjointUnionTopology',
       topo=topology.DisjointUnionTopology(
           [mesh.rectilinear([8])[0][l:r] for l, r in [[0, 2], [4, 6]]]),
       hasboundary=False,
Ejemplo n.º 16
0
 def setUp(self):
   self.seq = nutils.transformseq.StructuredTransforms(x2, [nutils.transformseq.DimAxis(0,2,False),nutils.transformseq.DimAxis(2,4,False)], 1)
   self.check = (x2,s01,c00),(x2,s01,c01),(x2,s01,c10),(x2,s01,c11)
   self.checkmissing = (x2,s00,c00),
   self.checkrefs = References.uniform(square, 4)
   self.checkfromdims = 2