思考下人生
今天周一,想做的事太多,行动的太少,python3的学习还是进展的慢,英语的学习还是没啥进步
1 import pygimli as pg 2 3 4 ############################################################################### 5 # Every part of the c++ namespace :gimliapi:`GIMLI` is bound to python and can 6 # be used with the leading ``pg.`` 7 # 8 # For instance get the current version for :term:`GIMLi` with: 9 10 print(pg.__version__) 11 12 ############################################################################### 13 # This yields: 14 # 15 # Now we know the name space :gimliapi:`GIMLI` and can create a first mesh. 16 # A mesh is represented by a collection of nodes, cells and boundaries, 17 # i.e., geometrical entities. 18 # 19 # .. note:: 20 # 21 # A regularly spaced mesh consisting of rectangles or hexahedrons is 22 # usually called grid. However, a grid is just a special variant of a mesh 23 # so GIMLi treat it the same. The only difference is how they are created. 24 # 25 # GIMLi provides a collection of tools for mesh import, export and generation. 26 # A simple grid generation is built-in but we also provide wrappers for 27 # unstructured mesh generations, e.g., :term:`Triangle`, :term:`Tetgen` and 28 # :term:`Gmsh`. To create a 2d grid you need to give two arrays/lists for the 29 # sampling points in x and y direction, respectively, or just numbers. 30 31 grid = pg.createGrid(x=[-1.0, 0.0, 1.0, 4.0], y=(-1.0, 0.0, 1.0, 4.0)) 32 33 34 ############################################################################### 35 # The returned object ``grid`` is an instance of :gimliapi:`GIMLI::Mesh` and 36 # provides various methods for modification and io-operations. General 37 # informations can be simply printed. 38 # 39 print(grid) 40 41 ############################################################################### 42 # yields: 43 # 44 # Or you can access them manually: 45 # 46 print('Mesh: Nodes:', grid.nodeCount(), 47 'Cells:', grid.cellCount(), 48 'Boundaries:', grid.boundaryCount()) 49 50 ############################################################################### 51 # 52 # You can iterate through all cells of the general type :gimliapi:`GIMLI::Cell` 53 # that also provides a lot of methods. Here we list the number of nodes and the 54 # node ids per cell: 55 56 for cell in grid.cells(): 57 print("Cell", cell.id(), "has", cell.nodeCount(), 58 "nodes. Node IDs:", [n.id() for n in cell.nodes()]) 59 60 print(type(grid.cell(0))) 61 62 ############################################################################### 63 # To find the grid generation input arrays ``x`` and ``y``, you can use the 64 # build-in :gimliapi:`GIMLI::Vector` (pre-defined with value type double as 65 # ``pg.RVector``), standard python lists or :term:`numpy` arrays, 66 # which are widely compatible with :term:`GIMLi` vectors. 67 68 import numpy as np 69 70 grid = pg.createGrid(x=np.linspace(-1.0, 1.0, 10), 71 y=1.0 - np.logspace(np.log10(1.0), np.log10(2.0), 10)) 72 73 ############################################################################### 74 # 75 # We can find that this new ``grid`` contains 76 # 77 78 print(grid.cellCount()) 79 80 ############################################################################### 81 # rectangles of type :gimliapi:`GIMLI::Quadrangle` being derived from the 82 # base type :gimliapi:`GIMLI::Cell`, 83 # 84 85 print(grid.boundaryCount()) 86 87 ############################################################################### 88 # edges of type :gimliapi:`GIMLI::Edge`, which are boundaries of the general 89 # type :gimliapi:`GIMLI::Boundary`. 90 # 91 # The mesh can be saved and loaded in our binary mesh format ``.bms``. 92 # Or exported into ``.vtk`` format for 2D or 3D visualization using 93 # :term:`Paraview`. 94 # 95 # However, we recommend visualizing 2-dimensional content using python scripts 96 # that provides better exports to graphics files (e.g., png, pdf, svg). 97 # In :term:`pygimli` we provide some basic post-processing routines using 98 # the :term:`matplotlib` visualization framework. The main visualization call 99 # is :py:mod:`pygimli.viewer.show` which is sufficient for the most meshs, 100 # fields, models and streamline views. 101 102 pg.viewer.show(grid) 103 104 ############################################################################### 105 # For more control you can also use the appropriate draw methods 106 # :py:mod:`pygimli.mplviewer.drawMesh`. 107 108 pg.wait()
晚上的主要任务是学习写自己的博客,平时看的东西有点多,写的内容太少,容易眼高手低

 
                    
                
 
                
            
         浙公网安备 33010602011771号
浙公网安备 33010602011771号