dynareadout

package module
v0.0.0-...-4f574c7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 28, 2023 License: Zlib Imports: 7 Imported by: 0

README

dynareadout

An Ansi C library for parsing binary output files of LS Dyna (d3plot, binout) with bindings for go.

Examples

Binout
package main

import (
	"fmt"
	dro "github.com/PucklaJ/dynareadout_go"
	"os"
)

func main() {
	// This library also supports opening multiple binout files at once by globing them
	binFile, err := dro.BinoutOpen("simulation/binout*")
	if err != nil {
		fmt.Fprintln(os.Stderr, "Failed to open binout:", err)
		return
	}
	defer binFile.Close()

	// Print the children of the binout
	children := binFile.GetChildren("/")
	for i, child := range children {
		fmt.Printf("Child %d: %s\n", i, child)
	}

	// Read some data. The library implements read functions for multiple types
	nodeIds, err := binFile.ReadInt32("/nodout/metadata/ids")
	if err != nil {
		fmt.Fprintln(os.Stderr, "Failed to read node ids:", err)
		return
	}

	for i, nid := range nodeIds {
		fmt.Printf("Node ID %d: %d\n", i, nid)
	}
}
D3plot
package main

import (
	"fmt"
	dro "github.com/PucklaJ/dynareadout_go"
	"os"
)

func main() {
	// Just give it the first d3plot file and it opens all of them
	plotFile, err := dro.D3plotOpen("simulation/d3plot")
	if err != nil {
		fmt.Fprintln(os.Stderr, "Failed to open d3plot:", err)
		return
	}

	// Read the title
	title, _ := plotFile.ReadTitle()
	fmt.Println("Title:", title)

	// Read node ids
	nodeIds, _ := plotFile.ReadNodeIDs()
	fmt.Println("Nodes:", len(nodeIds))
	for i, nid := range nodeIds {
		fmt.Printf("Node %d: %d\n", i, nid)
	}

	// Read node coordinates of time step 10
	nodeCoords, _ := plotFile.ReadNodeCoordinates(10)
	for i, c := range nodeCoords {
		fmt.Printf("Node Coords %d: (%.2f, %.2f, %.2f)\n", i, c[0], c[1], c[2])
	}
}

Other Languages

This library is also available for C, C++ and python.

Documentation

Index

Constants

View Source
const (
	BinoutTypeInt8    = 1
	BinoutTypeInt16   = 2
	BinoutTypeInt32   = 3
	BinoutTypeInt64   = 4
	BinoutTypeUint8   = 5
	BinoutTypeUint16  = 6
	BinoutTypeUint32  = 7
	BinoutTypeUint64  = 8
	BinoutTypeFloat32 = 9
	BinoutTypeFloat64 = 10
	BinoutTypeInvalid = math.MaxUint64
)
View Source
const (
	CardParseInt    = C.CARD_PARSE_INT
	CardParseFloat  = C.CARD_PARSE_FLOAT
	CardParseString = C.CARD_PARSE_STRING

	DefaultValueWidth = 10
)

Variables

This section is empty.

Functions

func D3plotIndexForID

func D3plotIndexForID(id uint64, IDs []uint64) uint64

func KeyFileParse

func KeyFileParse(fileName string, parseConfig KeyFileParseConfig) (Keywords, *KeyFileWarning, error)

Types

type Binout

type Binout struct {
	// contains filtered or unexported fields
}

func BinoutOpen

func BinoutOpen(fileName string) (bin_file Binout, err error)

func (Binout) Close

func (bin_file Binout) Close()

func (Binout) GetChildren

func (bin_file Binout) GetChildren(path string) []string

func (Binout) GetNumTimesteps

func (bin_file Binout) GetNumTimesteps(path string) (uint64, error)

func (Binout) GetTypeID

func (bin_file Binout) GetTypeID(path string) uint64

func (Binout) ReadFloat32

func (bin_file Binout) ReadFloat32(path string) ([]float32, error)

func (Binout) ReadFloat64

func (bin_file Binout) ReadFloat64(path string) ([]float64, error)

func (Binout) ReadInt16

func (bin_file Binout) ReadInt16(path string) ([]int16, error)

func (Binout) ReadInt32

func (bin_file Binout) ReadInt32(path string) ([]int32, error)

func (Binout) ReadInt64

func (bin_file Binout) ReadInt64(path string) ([]int64, error)

func (Binout) ReadInt8

func (bin_file Binout) ReadInt8(path string) ([]int8, error)

func (Binout) ReadString

func (bin_file Binout) ReadString(path string) (string, error)

func (Binout) ReadTimedFloat32

func (bin_file Binout) ReadTimedFloat32(path string) ([][]float32, error)

func (Binout) ReadTimedFloat64

func (bin_file Binout) ReadTimedFloat64(path string) ([][]float64, error)

func (Binout) ReadUint16

func (bin_file Binout) ReadUint16(path string) ([]uint16, error)

func (Binout) ReadUint32

func (bin_file Binout) ReadUint32(path string) ([]uint32, error)

func (Binout) ReadUint64

func (bin_file Binout) ReadUint64(path string) ([]uint64, error)

func (Binout) ReadUint8

func (bin_file Binout) ReadUint8(path string) ([]uint8, error)

func (Binout) SimplePathToReal

func (bin_file Binout) SimplePathToReal(simple string) (string, int, bool, error)

func (Binout) VariableExists

func (bin_file Binout) VariableExists(path string) bool

type Card

type Card struct {
	// contains filtered or unexported fields
}

func (*Card) ParseBegin

func (c *Card) ParseBegin(valueWidth int)

func (Card) ParseDone

func (c Card) ParseDone() bool

func (Card) ParseFloat32

func (c Card) ParseFloat32() (float32, error)

func (Card) ParseFloat32Width

func (c Card) ParseFloat32Width(valueWidth int) (float32, error)

func (Card) ParseFloat64

func (c Card) ParseFloat64() (float64, error)

func (Card) ParseFloat64Width

func (c Card) ParseFloat64Width(valueWidth int) (float64, error)

func (Card) ParseGetType

func (c Card) ParseGetType() int

func (Card) ParseGetTypeWidth

func (c Card) ParseGetTypeWidth(valueWidth int) int

func (Card) ParseInt

func (c Card) ParseInt() (int, error)

func (Card) ParseIntWidth

func (c Card) ParseIntWidth(valueWidth int) (int, error)

func (*Card) ParseNext

func (c *Card) ParseNext()

func (*Card) ParseNextWidth

func (c *Card) ParseNextWidth(valueWidth int)

func (Card) ParseString

func (c Card) ParseString() string

func (Card) ParseStringNoTrim

func (c Card) ParseStringNoTrim() string

func (Card) ParseStringWidth

func (c Card) ParseStringWidth(valueWidth int) string

func (Card) ParseStringWidthNoTrim

func (c Card) ParseStringWidthNoTrim(valueWidth int) string

func (Card) ParseWhole

func (c Card) ParseWhole() string

func (Card) ParseWholeNoTrim

func (c Card) ParseWholeNoTrim() string

type D3plot

type D3plot struct {
	// contains filtered or unexported fields
}

func D3plotOpen

func D3plotOpen(fileName string) (plotFile D3plot, err error)

func (D3plot) Close

func (plotFile D3plot) Close()

func (D3plot) NumTimeSteps

func (plotFile D3plot) NumTimeSteps() uint64

func (D3plot) ReadAllElementIDs

func (plotFile D3plot) ReadAllElementIDs() ([]uint64, error)

func (D3plot) ReadAllNodeAcceleration

func (plotFile D3plot) ReadAllNodeAcceleration() ([][][3]float64, error)

func (D3plot) ReadAllNodeCoordinates

func (plotFile D3plot) ReadAllNodeCoordinates() ([][][3]float64, error)

func (D3plot) ReadAllNodeVelocity

func (plotFile D3plot) ReadAllNodeVelocity() ([][][3]float64, error)

func (D3plot) ReadAllTime

func (plotFile D3plot) ReadAllTime() ([]float64, error)

func (D3plot) ReadBeamElementIDs

func (plotFile D3plot) ReadBeamElementIDs() ([]uint64, error)

func (D3plot) ReadBeamElements

func (plotFile D3plot) ReadBeamElements() ([]C.d3plot_beam_con, error)

func (D3plot) ReadBeamsState

func (plotFile D3plot) ReadBeamsState(state uint64) ([]C.d3plot_beam, error)

func (D3plot) ReadNodeAcceleration

func (plotFile D3plot) ReadNodeAcceleration(state uint64) ([][3]float64, error)

func (D3plot) ReadNodeCoordinates

func (plotFile D3plot) ReadNodeCoordinates(state uint64) ([][3]float64, error)

TODO: Implement bindings for the 32-Bit variants

func (D3plot) ReadNodeIDs

func (plotFile D3plot) ReadNodeIDs() ([]uint64, error)

func (D3plot) ReadNodeVelocity

func (plotFile D3plot) ReadNodeVelocity(state uint64) ([][3]float64, error)

func (D3plot) ReadPart

func (plotFile D3plot) ReadPart(partIndex uint64) (D3plotPart, error)

func (D3plot) ReadPartByID

func (plotFile D3plot) ReadPartByID(partID uint64, partIDs []uint64) (D3plotPart, error)

func (D3plot) ReadPartIDs

func (plotFile D3plot) ReadPartIDs() ([]uint64, error)

func (D3plot) ReadPartTitles

func (plotFile D3plot) ReadPartTitles() ([]string, error)

func (D3plot) ReadRunTime

func (plotFile D3plot) ReadRunTime() (time.Time, error)

func (D3plot) ReadShellElementIDs

func (plotFile D3plot) ReadShellElementIDs() ([]uint64, error)

func (D3plot) ReadShellElements

func (plotFile D3plot) ReadShellElements() ([]C.d3plot_shell_con, error)

func (D3plot) ReadShellsState

func (plotFile D3plot) ReadShellsState(state uint64) ([]C.d3plot_shell, error)

TODO: Make separate struct to wrap around c type so that history variables can be read

func (D3plot) ReadSolidElementIDs

func (plotFile D3plot) ReadSolidElementIDs() ([]uint64, error)

func (D3plot) ReadSolidElements

func (plotFile D3plot) ReadSolidElements() ([]C.d3plot_solid_con, error)

func (D3plot) ReadSolidsState

func (plotFile D3plot) ReadSolidsState(state uint64) ([]C.d3plot_solid, error)

func (D3plot) ReadThickShellElementIDs

func (plotFile D3plot) ReadThickShellElementIDs() ([]uint64, error)

func (D3plot) ReadThickShellElements

func (plotFile D3plot) ReadThickShellElements() ([]C.d3plot_thick_shell_con, error)

func (D3plot) ReadThickShellsState

func (plotFile D3plot) ReadThickShellsState(state uint64) ([]C.d3plot_thick_shell, error)

TODO: Make separate struct to wrap around c type so that history variables can be read

func (D3plot) ReadTime

func (plotFile D3plot) ReadTime(state uint64) (float64, error)

func (D3plot) ReadTitle

func (plotFile D3plot) ReadTitle() (string, error)

type D3plotPart

type D3plotPart struct {
	// contains filtered or unexported fields
}

func (D3plotPart) BeamID

func (part D3plotPart) BeamID(index int) uint64

func (D3plotPart) Free

func (part D3plotPart) Free()

func (D3plotPart) GetNodeIDs

func (part D3plotPart) GetNodeIDs(plotFile D3plot) ([]uint64, error)

func (D3plotPart) GetNodeIndices

func (part D3plotPart) GetNodeIndices(plotFile D3plot) ([]uint64, error)

func (D3plotPart) GetNumNodes

func (part D3plotPart) GetNumNodes(plotFile D3plot) (int, error)

func (D3plotPart) LenBeamIDs

func (part D3plotPart) LenBeamIDs() int

func (D3plotPart) LenShellIDs

func (part D3plotPart) LenShellIDs() int

func (D3plotPart) LenSolidIDs

func (part D3plotPart) LenSolidIDs() int

func (D3plotPart) LenThickShellIDs

func (part D3plotPart) LenThickShellIDs() int

func (D3plotPart) ShellID

func (part D3plotPart) ShellID(index int) uint64

func (D3plotPart) SolidID

func (part D3plotPart) SolidID(index int) uint64

func (D3plotPart) ThickShellID

func (part D3plotPart) ThickShellID(index int) uint64

type KeyFileParseCallback

type KeyFileParseCallback func(string, int, string, *Card, int)

type KeyFileParseConfig

type KeyFileParseConfig struct {
	ParseIncludes          bool
	IgnoreNotFoundIncludes bool
}

func DefaultKeyFileParseConfig

func DefaultKeyFileParseConfig() KeyFileParseConfig

type KeyFileWarning

type KeyFileWarning struct {
	// contains filtered or unexported fields
}

func KeyFileParseWithCallback

func KeyFileParseWithCallback(fileName string, callback KeyFileParseCallback, parseConfig KeyFileParseConfig) (*KeyFileWarning, error)

func (*KeyFileWarning) Error

func (w *KeyFileWarning) Error() string

type Keyword

type Keyword struct {
	// contains filtered or unexported fields
}

func (*Keyword) Get

func (k *Keyword) Get(index int) Card

func (*Keyword) GetSlice

func (k *Keyword) GetSlice() []Card

func (Keyword) Len

func (k Keyword) Len() int

type Keywords

type Keywords struct {
	// contains filtered or unexported fields
}

func (*Keywords) Free

func (k *Keywords) Free()

func (*Keywords) Get

func (k *Keywords) Get(name string, index int) (Keyword, error)

func (*Keywords) GetSlice

func (k *Keywords) GetSlice(name string) ([]Keyword, error)

func (Keywords) Len

func (k Keywords) Len() int

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL