Ejemplo n.º 1
0
def run():
    print("Running group...")
    g = VtkGroup(FILE_PATH)
    g.addFile(filepath="sim0000.vtu", sim_time=0.0)
    g.addFile(filepath="sim0001.vtu", sim_time=1.0)
    g.addFile(filepath="sim0002.vtu", sim_time=2.0)
    g.addFile(filepath="sim0003.vtu", sim_time=3.0)
    g.save()
Ejemplo n.º 2
0
def _write_vtu_series(grid, coordinates, connectivity, data, filename_base, last_step, is_cell_data):
    steps = last_step + 1 if last_step is not None else len(data)
    fn_tpl = "{}_{:08d}"

    npoints = len(coordinates[0])
    ncells = len(connectivity)

    ref = grid.reference_element
    if ref is ref is referenceelements.triangle:
        points_per_cell = 3
        vtk_el_type = VtkTriangle.tid
    elif ref is referenceelements.square:
        points_per_cell = 4
        vtk_el_type = VtkQuad.tid
    else:
        raise NotImplementedError("vtk output only available for grids with triangle or rectangle reference elments")

    connectivity = connectivity.reshape(-1)
    cell_types = np.empty(ncells, dtype='uint8')
    cell_types[:] = vtk_el_type
    offsets = np.arange(start=points_per_cell, stop=ncells*points_per_cell+1, step=points_per_cell, dtype='int32')

    group = VtkGroup(filename_base)
    for i in range(steps):
        fn = fn_tpl.format(filename_base, i)
        vtk_data = data[i, :]
        w = VtkFile(fn, VtkUnstructuredGrid)
        w.openGrid()
        w.openPiece(ncells=ncells, npoints=npoints)

        w.openElement("Points")
        w.addData("Coordinates", coordinates)
        w.closeElement("Points")
        w.openElement("Cells")
        w.addData("connectivity", connectivity)
        w.addData("offsets", offsets)
        w.addData("types", cell_types)
        w.closeElement("Cells")
        if is_cell_data:
            _addDataToFile(w, cellData={"Data": vtk_data}, pointData=None)
        else:
            _addDataToFile(w, cellData=None, pointData={"Data": vtk_data})

        w.closePiece()
        w.closeGrid()
        w.appendData(coordinates)
        w.appendData(connectivity).appendData(offsets).appendData(cell_types)
        if is_cell_data:
            _appendDataToFile(w, cellData={"Data": vtk_data}, pointData=None)
        else:
            _appendDataToFile(w, cellData=None, pointData={"Data": vtk_data})

        w.save()
        group.addFile(filepath=fn, sim_time=i)
    group.save()
Ejemplo n.º 3
0
def _write_vtu_series(grid, coordinates, connectivity, data, filename_base, last_step, is_cell_data):
    steps = last_step + 1 if last_step is not None else len(data)
    fn_tpl = "{}_{:08d}"

    npoints = len(coordinates[0])
    ncells = len(connectivity)

    ref = grid.reference_element
    if ref is ref is referenceelements.triangle:
        points_per_cell = 3
        vtk_el_type = VtkTriangle.tid
    elif ref is referenceelements.square:
        points_per_cell = 4
        vtk_el_type = VtkQuad.tid
    else:
        raise NotImplementedError("vtk output only available for grids with triangle or rectangle reference elments")

    connectivity = connectivity.reshape(-1)
    cell_types = np.empty(ncells, dtype='uint8')
    cell_types[:] = vtk_el_type
    offsets = np.arange(start=points_per_cell, stop=ncells*points_per_cell+1, step=points_per_cell, dtype='int32')

    group = VtkGroup(filename_base)
    for i in range(steps):
        fn = fn_tpl.format(filename_base, i)
        vtk_data = data[i, :]
        w = VtkFile(fn, VtkUnstructuredGrid)
        w.openGrid()
        w.openPiece(ncells=ncells, npoints=npoints)

        w.openElement("Points")
        w.addData("Coordinates", coordinates)
        w.closeElement("Points")
        w.openElement("Cells")
        w.addData("connectivity", connectivity)
        w.addData("offsets", offsets)
        w.addData("types", cell_types)
        w.closeElement("Cells")
        if is_cell_data:
            _addDataToFile(w, cellData={"Data": vtk_data}, pointData=None)
        else:
            _addDataToFile(w, cellData=None, pointData={"Data": vtk_data})

        w.closePiece()
        w.closeGrid()
        w.appendData(coordinates)
        w.appendData(connectivity).appendData(offsets).appendData(cell_types)
        if is_cell_data:
            _appendDataToFile(w, cellData={"Data": vtk_data}, pointData=None)
        else:
            _appendDataToFile(w, cellData=None, pointData={"Data": vtk_data})

        w.save()
        group.addFile(filepath=fn + '.vtu', sim_time=i)
    group.save()
Ejemplo n.º 4
0
        # and contact area
        # w.openData("Cell")
        # w.addData("area", area)
        # w.closeData("Cell")

        # and heat flux
        # w.openData("Cell")
        # w.addData("heatflux", heatflux)
        # w.closeData("Cell")

        # Wrap up
        w.closePiece()
        w.closeGrid()

        # Append binary data
        w.appendData( (x,y,z) )
        w.appendData(connections).appendData(offset).appendData(celltype)
        w.appendData(forceClean).appendData(connectionLengthClean)
        w.save()

    # Add this file to the group of all timesteps
    groupfile.addFile(filepath = os.path.relpath(vtufile,inputdir), sim_time = timestep)

    fileindex += 1
    timestep = forcedata.next()

# end of main loop - close group file
groupfile.save()

Ejemplo n.º 5
0
# *                                                                                 *
# *  2. Redistributions in binary form must reproduce the above copyright notice,   *
# *  this list of conditions and the following disclaimer in the documentation      *
# *  and/or other materials provided with the distribution.                         *
# *                                                                                 *
# * THIS SOFTWARE IS PROVIDED BY PAULO A. HERRERA ``AS IS'' AND ANY EXPRESS OR      *
# * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF    *
# * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO      *
# * EVENT SHALL <COPYRIGHT HOLDER> OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,        *
# * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,  *
# * BUT NOT LIMITED TO, PROCUREMEN OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,    *
# * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY           *
# * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING  *
# * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS              *
# * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.                    *
# ************************************************************************

# **************************************************************
# * Example of how to create a VTK group to visualize time     *
# * dependent data.                                            *
# **************************************************************

from evtk.vtk import VtkGroup

g = VtkGroup("./group")
g.addFile(filepath="sim0000.vtu", sim_time=0.0)
g.addFile(filepath="sim0001.vtu", sim_time=1.0)
g.addFile(filepath="sim0002.vtu", sim_time=2.0)
g.addFile(filepath="sim0003.vtu", sim_time=3.0)
g.save()
Ejemplo n.º 6
0
        # and contact area
        # w.openData("Cell")
        # w.addData("area", area)
        # w.closeData("Cell")

        # and heat flux
        # w.openData("Cell")
        # w.addData("heatflux", heatflux)
        # w.closeData("Cell")

        # Wrap up
        w.closePiece()
        w.closeGrid()

        # Append binary data
        w.appendData((x, y, z))
        w.appendData(connections).appendData(offset).appendData(celltype)
        w.appendData(forceClean).appendData(connectionLengthClean)
        w.save()

    # Add this file to the group of all timesteps
    groupfile.addFile(filepath=os.path.relpath(vtufile, inputdir),
                      sim_time=timestep)

    fileindex += 1
    timestep = forcedata.next()

# end of main loop - close group file
groupfile.save()