![]() ![]() gmsh is None : raise RuntimeError ( 'Gmsh is not configured, set the gmsh path.' ) cmd = + list ( args ) subprocess. config, 'w' )) def _call_gmsh ( self, * args ): if self. gmsh = gmsh data = dict ( path = gmsh ) json. gmsh = data def _set_gmsh ( self, gmsh ): self. remove ( tmp_vtk ) # Private Protocol # def _ask_user_for_gmsh ( self ): gmsh = input ( 'Please provide the path to gmsh executable: ' ) return gmsh def _read_config ( self ): if exists ( self. _call_gmsh ( '-3', geo_file_name, '-o', tmp_vtk ) return vtk_file_to_points ( tmp_vtk, vertices = vertices, cell_centers = cell_centers ) finally : os. cell_centers: bool If True, converts the cell centers to points. vertices: bool If True, it converts the vertices to points. Parameters - geo_file_name: str Filename of the. geo file, generate a mesh and get the points from the mesh. def get_points_from_geo ( self, geo_file_name, vertices = True, cell_centers = False ): """Given a. format ( idx = e_idx, start = data + p_idx, cen = data + p_idx, end = data + p_idx ) fp. _write_circle ( fp, data, idx, point_id_base ) idx += 1 ids = ', '. ![]() _write_line ( fp, data, idx, point_id_base ) elif kind = 'circle' : self. append ( str ( idx )) kind, data = elem, elem if kind = 'line' : self. elems idx = 0 loop = for i in range ( len ( elems )): elem = elems idx = elem_id_base + i + 1 loop. _write_point ( fp, points, idx ) elems = self. points for i in range ( len ( points )): idx = point_id_base + i + 1 self. def write ( self, fp, point_id_base = 0, elem_id_base = 0 ): """Write data to given file object `fp`. shape = len ( pts ) / 3, 3 x, y, z = pts. CellCenters ( input = dataset ) cell_centers. to_array ()) if cell_centers : cell_centers = tvtk. array (, dtype = float ) if vertices : pts = np. Parameters - dataset : tvtk.DataSet vertices: bool If True, it converts the vertices to points. output def _convert_to_points ( dataset, vertices = True, cell_centers = True ): """Given a VTK dataset, convert it to a set of points that can be used for simulation with SPH. DataSetReader ( file_name = tmpfname ) else : tmpfname = None r = tvtk. mktemp ( suffix = '.vtk' ) with open ( tmpfname, 'wb' ) as tmpf : data = gzip. endswith ( '.vtk.gz' ): tmpfname = tempfile. """ # Copyright (c) 2015 Prabhu Ramachandran import gzip import json import numpy as np import subprocess import tempfile from tvtk.api import tvtk import os from os.path import exists, expanduser, join import sys def _read_vtk_file ( fname ): """Given a. It only switches to meshio if the format is not natively supported by vtk (e.g. This is very useful as Gmsh can generate VTK datasets from its meshes and thus the meshes can be imported as point clouds that may be used in an SPH simulation. As far as I know, pyvista is still using VTK readers for every VTK files. There is also a function to read VTK dataset and produce points from them. This module also provides some simple classes that allow one to create extruded 3D surfaces by generating a gmsh file in Python. This is primarily for meshes generated using Gmsh. """Utility module to read input mesh files. ![]()
0 Comments
Leave a Reply. |