예제 #1
0
    def link_surfaces(self, model, tags, links, box=None, tol=1E-10):
        '''Account for possible cut and shift of center of mass of face'''
        # This pass is blind
        links = link_surfaces(model, tags, self, links, tol=tol)
        # NOTE: everything is assumed to be z aligned. We might have
        # a cut z plane
        metric = lambda x, y: np.abs((y - x)[:, 2])  # But z coord should match

        return link_surfaces(model,
                             tags,
                             self,
                             tol=tol,
                             links=links,
                             metric=metric)
예제 #2
0
 def link_surfaces(self, model, tags, links, box, tol=1E-10):
     '''Account for possible cut and shift of center of mass of face'''
     # Should be fine for tip
     links = link_surfaces(model, tags, self, links=links, tol=tol)
     # NOTE: as we chop the by box, the wall won't be found with the
     # above metric; But we should match x, y and z should account for chop
     Z0 = 0.5 * (box.max_[2] + self.params['tip_z'])
     metric = lambda x, y: np.sqrt(
         np.abs((y - x)[:, 0])**2 + np.abs((y - x)[:, 1])**2 + np.abs(
             (x[:, 2] - Z0)**2))
     return link_surfaces(model,
                          tags,
                          self,
                          links=links,
                          metric=metric,
                          tol=tol)
예제 #3
0
    def link_surfaces(self, model, tags, links, box, tol=1E-10):
        '''Account for possible cut and shift of center of mass of face'''
        # Account for probe rotation in tagging
        for surf, point in self._surfaces.items():
            self._surfaces[surf] = self.rotate(point)

        links = link_surfaces(model, tags, self, links=links, tol=tol)
        # NOTE: as we chop the by box, the wall won't be found with the above metric
        # So we don't match on Z
        metric = lambda x, y: np.sqrt(((y - x)[:, 0])**2 + ((y - x)[:, 1])**2)
        links = link_surfaces(model,
                              tags,
                              self,
                              links=links,
                              metric=metric,
                              tol=tol)

        return links
예제 #4
0
    def test_contact_find(self):
        # The idea here is that we should always be able to find the
        # contact surfaces of the standalone probe

        for Probe in probe_list.values():
            gmsh.initialize()

            probe = Probe()
            model = gmsh.model
            factory = model.occ
            # Probe can have more volumes
            volumes = probe.as_gmsh(model)
            volumes = list(zip(repeat(3), volumes))
            factory.synchronize()
            # Their bounding surface
            volumes_surfs = [model.getBoundary([vp]) for vp in volumes]
            # A boundary can also contain curves - we ignore those; only keep 2d
            volumes_surfs = sum(
                ([s[1] for s in ss if s[0] == 2] for ss in volumes_surfs), [])
            volumes_surfs = list(set(volumes_surfs))

            self.assertTrue(volumes_surfs)

            # At the moment its surfaces are all surfaces
            probe_surfaces = {}
            # We found all
            probe_surfaces = link_surfaces(model,
                                           volumes_surfs,
                                           probe,
                                           probe_surfaces,
                                           claim_last=False)

            # Find these
            is_contact = lambda s: 'contact_' in s
            want = set(filter(is_contact, probe._surfaces))
            have = set(filter(is_contact, probe_surfaces))

            # And we can make the mesh
            # model.mesh.generate(3)
            # vtx_order, vtices, _ = model.mesh.getNodes()
            gmsh.finalize()

            self.assertTrue(want == have)
예제 #5
0
 def link_surfaces(self, model, tags, links, box=None, tol=1E-10):
     '''Rely on correspondence of center of mass'''
     return link_surfaces(model, tags, self, links, tol=tol)