示例#1
0
	def genMesh(self,fnOut=None,debug=False):
		
		"""Main mesh generation function.
		
		.. note:: If ``fnOut=None``, will use ``geometry.fnGeo``.
		
		.. note:: If ``fromFile=True``, will generate from .geo file running
		   gmsh directly on the file. If not, will try to run hard coded FiPy
		   version for mesh generation via :py:func:`runFiPyMeshGenerator` .
		
		Keyword Args:
			fnOut (str): Output filepath for meshfile.
			debug (bool): Print debugging messages.
			dim (int): Dimension of mesh.
			
		Returns:
			fipy.GmshImporter3D: Gmsh mesh object.
		
		"""
		
		if fnOut==None:
			fnOut=self.simulation.embryo.geometry.fnGeo.replace(".geo",".msh")
		
		dim=self.simulation.embryo.geometry.getDim()
		
		if self.fromFile:
			self.fnMesh=pyfrp_misc_module.fixPath(fnOut)
		
			pyfrp_gmsh_module.runGmsh(self.simulation.embryo.geometry.fnGeo,fnOut=fnOut,debug=debug,volSizeMax=self.volSizePx,dim=dim)
			
			self.importMeshFromFile(self.fnMesh)
		else:
			self.runFiPyMeshGenerator(self.simulation.embryo.geometry.typ)

		return self.mesh
示例#2
0
	def __init__(self,embryo,typ,fnGeo,center,dim=3):
		
		self.typ=typ
		self.embryo=embryo
		self.fnGeo=pyfrp_misc_module.fixPath(fnGeo)
		self.center=center
		self.dim=dim
		
		self.geoFileParameters={}
示例#3
0
    def setFnMesh(self, fn):
        """Sets the filepath of meshfile.
		
		Imports the new mesh right away using :py:func:`importMeshFromFile`.
		
		"""

        self.fnMesh = pyfrp_misc_module.fixPath(fn)
        self.importMeshFromFile(self.fnMesh)
        return self.fnMesh
示例#4
0
def test_readStlFile():

	"""Test function for readStlFile. 

	Reads in .stl and checks if there are enough
	vertices read in."""

	d=pyfrp_gmsh_IO_module.readStlFile(pyfrp_misc_module.fixPath(pyfrp_misc_module.getMeshfilesDir()+"tests/readStlFile.stl"))
	
	assert len(d.vertices) == 5
	
	
示例#5
0
	def setFnGeo(self,fn):
		
		"""Sets path to .geo file.
		
		Args:
			fn (str): Path to file.
		
		Returns:
			str: Path to file.
		"""
		
		self.fnGeo=pyfrp_misc_module.fixPath(fn)
		return self.fnGeo
示例#6
0
	def setFnMesh(self,fn):
		
		
		"""Sets the filepath of meshfile.
		
		Imports the new mesh right away using :py:func:`importMeshFromFile`.
		
		"""
		
		
		self.fnMesh=pyfrp_misc_module.fixPath(fn)
		self.importMeshFromFile(self.fnMesh)
		return self.fnMesh
示例#7
0
def test_domainSimplifySurfaces():

	"""Test domain's simplify surfaces method. 

	Reads in .stl, tries to the geometry and checks if 
	it has been simplified properly."""
	
	d=pyfrp_gmsh_IO_module.readStlFile(pyfrp_misc_module.fixPath(pyfrp_misc_module.getMeshfilesDir()+"tests/surfaceFuse.stl"))
	
	d.simplifySurfaces(triangIterations=0,addPoints=False,fixSurfaces=False,debug=False,iterations=3)
	sameNormal=d.getAllObjectsWithProp("ruledSurfaces","normal",np.array([0,-1.,0]))
	
	assert len(sameNormal) == 1
示例#8
0
	def setICimgByFn(self,fn):
		
		"""Sets image for initial condition interpolation given a filepath.
		
		Args:
			fn (str): Path to file.
			
		Returns:
			numpy.ndarray: New ICimg.
		
		"""
		
		img=pyfrp_img_module.loadImg(pyfrp_misc_module.fixPath(fn),self.embryo.dataEnc)
		
		return self.setICimg(img)
示例#9
0
    def setICimgByFn(self, fn):
        """Sets image for initial condition interpolation given a filepath.
		
		Args:
			fn (str): Path to file.
			
		Returns:
			numpy.ndarray: New ICimg.
		
		"""

        img = pyfrp_img_module.loadImg(pyfrp_misc_module.fixPath(fn),
                                       self.embryo.dataEnc)

        return self.setICimg(img)
示例#10
0
def test_domainSimplifySurfaces():
    """Test domain's simplify surfaces method. 

	Reads in .stl, tries to the geometry and checks if 
	it has been simplified properly."""

    d = pyfrp_gmsh_IO_module.readStlFile(
        pyfrp_misc_module.fixPath(pyfrp_misc_module.getMeshfilesDir() +
                                  "tests/surfaceFuse.stl"))

    d.simplifySurfaces(triangIterations=0,
                       addPoints=False,
                       fixSurfaces=False,
                       debug=False,
                       iterations=3)
    sameNormal = d.getAllObjectsWithProp("ruledSurfaces", "normal",
                                         np.array([0, -1., 0]))

    assert len(sameNormal) == 1
示例#11
0
def test_surfaceFuse():

	"""Test surface fuse function. 

	Reads in .stl, tries to fuse a few surfaces and checks if new surface 
	lineLoop has proper number of vertices."""

	d=pyfrp_gmsh_IO_module.readStlFile(pyfrp_misc_module.fixPath(pyfrp_misc_module.getMeshfilesDir()+"tests/surfaceFuse.stl"))
	
	sfID=1
	toFuseIDs=[2,3,4,5,6,7]
	
	# Grab first surface
	sf1=d.getRuledSurfaceById(sfID)[0]

	# Try to successively fuse
	for ID in toFuseIDs:
		sf1.fuse(d.getRuledSurfaceById(ID)[0],debug=True)
		
	assert pyfrp_misc_module.objAttrToList(sf1.lineLoop.getVertices(),'Id') == [1, 2, 4, 5, 6, 7, 8, 9, 3]
示例#12
0
def test_surfaceFuse():
    """Test surface fuse function. 

	Reads in .stl, tries to fuse a few surfaces and checks if new surface 
	lineLoop has proper number of vertices."""

    d = pyfrp_gmsh_IO_module.readStlFile(
        pyfrp_misc_module.fixPath(pyfrp_misc_module.getMeshfilesDir() +
                                  "tests/surfaceFuse.stl"))

    sfID = 1
    toFuseIDs = [2, 3, 4, 5, 6, 7]

    # Grab first surface
    sf1 = d.getRuledSurfaceById(sfID)[0]

    # Try to successively fuse
    for ID in toFuseIDs:
        sf1.fuse(d.getRuledSurfaceById(ID)[0], debug=True)

    assert pyfrp_misc_module.objAttrToList(
        sf1.lineLoop.getVertices(), 'Id') == [1, 2, 4, 5, 6, 7, 8, 9, 3]
示例#13
0
    def genMesh(self, fnOut=None, debug=False):
        """Main mesh generation function.
		
		.. note:: If ``fnOut=None``, will use ``geometry.fnGeo``.
		
		.. note:: If ``fromFile=True``, will generate from .geo file running
		   gmsh directly on the file. If not, will try to run hard coded FiPy
		   version for mesh generation via :py:func:`runFiPyMeshGenerator` .
		
		Keyword Args:
			fnOut (str): Output filepath for meshfile.
			debug (bool): Print debugging messages.
			dim (int): Dimension of mesh.
			
		Returns:
			fipy.GmshImporter3D: Gmsh mesh object.
		
		"""

        if fnOut == None:
            fnOut = self.simulation.embryo.geometry.fnGeo.replace(
                ".geo", ".msh")

        dim = self.simulation.embryo.geometry.getDim()

        if self.fromFile:
            self.fnMesh = pyfrp_misc_module.fixPath(fnOut)

            pyfrp_gmsh_module.runGmsh(self.simulation.embryo.geometry.fnGeo,
                                      fnOut=fnOut,
                                      debug=debug,
                                      volSizeMax=self.volSizePx,
                                      dim=dim)

            self.importMeshFromFile(self.fnMesh)
        else:
            self.runFiPyMeshGenerator(self.simulation.embryo.geometry.typ)

        return self.mesh