コード例 #1
0
ファイル: gmsh_primitives.py プロジェクト: VBaratham/nEuronMI
    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
ファイル: neuronexusprobe.py プロジェクト: VBaratham/nEuronMI
    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
ファイル: test_probes.py プロジェクト: VBaratham/nEuronMI
    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
ファイル: baseneuron.py プロジェクト: VBaratham/nEuronMI
 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)