.. _fgrid-chapter: fgrid: FEHM grid manipulation ============================= This module contains classes and methods for the manipulation of FEHM grid files. Typically, usage will be limited to reading and writing of grid files, and the use of the spatial and connectivity information provided. PyFEHM can parse unstructured or structured grids in FEHM format. PyFEHM can construct orthogonal grids of arbitrary complexity using the :class:`~.fgrid.fmake` class or by calling :meth:`.fgrid.make`. For the purposes of this manual, the variable ``geo`` will be assumed to refer to a previously defined instance of the :class:`~.fgrid` class. Nodes ----- The smallest quantum of the finite element grid. Node objects and associated connectivity information are automatically created when a grid file is parsed (:meth:`.fgrid.read`). In FEHM, a node is associated with a position in space and a control volume - the region of space uniquely associated with the node. It is connected to other nodes, forming elements and the finite element grid. When a grid is loaded and associated with an FEHM input file, material properties and zone information are mapped back onto the nodes. For example, if the **ROCK** macro has been assigned in an input file, then density information for a given node is accessed through its density attribute, :attr:`.fnode.density`. .. autoclass:: fgrid.fnode Geometry attributes ^^^^^^^^^^^^^^^^^^^ .. autoattribute:: fgrid.fnode.index .. autoattribute:: fgrid.fnode.position .. autoattribute:: fgrid.fnode.vol .. autoattribute:: fgrid.fnode.connected_nodes .. autoattribute:: fgrid.fnode.connections .. autoattribute:: fgrid.fnode.elements Material property attributes ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. autoattribute:: fgrid.fnode.permeability .. autoattribute:: fgrid.fnode.conductivity .. autoattribute:: fgrid.fnode.density .. autoattribute:: fgrid.fnode.specific_heat .. autoattribute:: fgrid.fnode.porosity .. autoattribute:: fgrid.fnode.youngs_modulus .. autoattribute:: fgrid.fnode.poissons_ratio .. autoattribute:: fgrid.fnode.thermal_expansion .. autoattribute:: fgrid.fnode.pressure_coupling .. autoattribute:: fgrid.fnode.rlpmodel .. autoattribute:: fgrid.fnode.permmodel .. autoattribute:: fgrid.fnode.pormodel .. autoattribute:: fgrid.fnode.condmodel State attributes ^^^^^^^^^^^^^^^^ .. autoattribute:: fgrid.fnode.Pi .. autoattribute:: fgrid.fnode.Ti .. autoattribute:: fgrid.fnode.Si .. autoattribute:: fgrid.fnode.S_co2gi .. autoattribute:: fgrid.fnode.S_co2li .. autoattribute:: fgrid.fnode.co2aqi .. autoattribute:: fgrid.fnode.strsi .. autoattribute:: fgrid.fnode.dispi .. autoattribute:: fgrid.fnode.P .. autoattribute:: fgrid.fnode.T .. autoattribute:: fgrid.fnode.S .. autoattribute:: fgrid.fnode.S_co2g .. autoattribute:: fgrid.fnode.S_co2l .. autoattribute:: fgrid.fnode.co2aq .. autoattribute:: fgrid.fnode.strs .. autoattribute:: fgrid.fnode.disp Other attributes ^^^^^^^^^^^^^^^^ .. autoattribute:: fgrid.fnode.zone .. autoattribute:: fgrid.fnode.zonelist .. autoattribute:: fgrid.fnode.generator Methods ^^^^^^^ .. autoattribute:: fgrid.fnode.what Connections ----------- .. autoclass:: fgrid.fconn Attributes ^^^^^^^^^^ .. autoattribute:: fgrid.fconn.nodes .. autoattribute:: fgrid.fconn.distance Elements -------- .. autoclass:: fgrid.felem Attributes ^^^^^^^^^^ .. autoattribute:: fgrid.felem.index .. autoattribute:: fgrid.felem.nodes .. autoattribute:: fgrid.felem.centre Methods ^^^^^^^ .. autoattribute:: fgrid.felem.what Grids ----- The :class:`.fgrid` object contains all information about the finite element grid. The grid object corresponds to an FEHM grid file and comprises an assembly of :class:`.fnode`, :class:`.fconn` and :class:`.felem` objects. This assembly is constructed by reading an existing FEHM grid files (:meth:`.fgrid.read`) or by creating an empty :class:`.fgrid` object and creating a new mesh using the :meth:`.fgrid.make` command. Read and write support for FEHM stor files is supported. .. autoclass:: fgrid.fgrid Attributes: object lists ^^^^^^^^^^^^^^^^^^^^^^^^^ .. autoattribute:: fgrid.fgrid.node .. autoattribute:: fgrid.fgrid.nodelist .. autoattribute:: fgrid.fgrid.conn .. autoattribute:: fgrid.fgrid.connlist .. autoattribute:: fgrid.fgrid.elem .. autoattribute:: fgrid.fgrid.elemlist Attributes: grid properties ^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. autoattribute:: fgrid.fgrid.xmin .. autoattribute:: fgrid.fgrid.xmax .. autoattribute:: fgrid.fgrid.ymin .. autoattribute:: fgrid.fgrid.ymax .. autoattribute:: fgrid.fgrid.zmin .. autoattribute:: fgrid.fgrid.zmax .. autoattribute:: fgrid.fgrid.dimensions .. autoattribute:: fgrid.fgrid.number_nodes .. autoattribute:: fgrid.fgrid.number_elems Methods ^^^^^^^ .. automethod:: fgrid.fgrid.read .. automethod:: fgrid.fgrid.write .. automethod:: fgrid.fgrid.node_nearest_point .. automethod:: fgrid.fgrid.plot .. automethod:: fgrid.fgrid.make .. automethod:: fgrid.fgrid.lagrit_stor .. automethod:: fgrid.fgrid.volumes .. automethod:: fgrid.fgrid.remove_zeros .. autoattribute:: fgrid.fgrid.what Examples ^^^^^^^^ 1. Create an :class:`.fgrid` object and read an existing FEHM grid file. ``geo=``\ :class:`.fgrid`\ ``()`` ``geo.``:meth:`read <.fgrid.read>`\ ``('c:\\path\\to\\old_GRID.inp')`` or ``geo=``\ :class:`.fgrid`\ ``('c:\\path\\to\\old_GRID.inp')`` 2. Plot a view of the grid looking down the x-axis, with gridlines coloured blue. ``geo.``:meth:`plot <.fgrid.plot>`\ ``('FEHMgrid1.png',color='r',angle='x')`` 3. Plot a view of the grid looking along the axis x=y=z, gridlines coloured red, with a cutaway beginning at the centre. ``geo.``:meth:`plot <.fgrid.plot>`\ ``('FEHMgrid2.png',color='b',angle=[45,45],cutaway='middle')`` .. figure:: FEHMgrid2.png :scale: 50 % Image produced by example 3. 4. Make changes to an :class:`.fgrid` object and write out the changes to a new FEHM grid file. ``for nd in geo.``\ :attr:`~.fgrid.nodelist`\ ``: nd.``\ :attr:`~.fnode.position`\ ``[2]+=1000.`` ``geo.``\ :meth:`write <.fgrid.write>`\ ``('new_GRID.inp')`` 5. Find the node nearest a given location in space. ``nd=geo.``\ :meth:`node_nearest_point <.fgrid.node_nearest_point>`\ ``([225,1600,-356])`` 6. Create a new grid using the :meth:`.fgrid.make` command. ``geo.``\ :meth:`make <.fgrid.make>`\ ``('mygrid.inp', x=[0,1,2,3], y=[-10,-20,-30], z=[0.1,0.3,0.8])`` 7. For an existing grid, use :meth:`~.fgrid.lagrit_stor` method to instruct LaGriT to create a stor file. ``geo.``\ :meth:`lagrit_stor <.fgrid.lagrit_stor>`\ ``(overwrite=True, stor='stor\\geo.stor', exe='c:\\bin\\lagrit.exe')``