Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pucklaj/dynareadout_go
Go bindings to the dynareadout library
https://github.com/pucklaj/dynareadout_go
binout cae d3plot dyna golang ls-dyna
Last synced: about 1 month ago
JSON representation
Go bindings to the dynareadout library
- Host: GitHub
- URL: https://github.com/pucklaj/dynareadout_go
- Owner: PucklaJ
- License: zlib
- Created: 2022-12-04T23:15:53.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2023-11-30T12:35:36.000Z (about 1 year ago)
- Last Synced: 2024-06-20T12:29:03.750Z (6 months ago)
- Topics: binout, cae, d3plot, dyna, golang, ls-dyna
- Language: C
- Homepage:
- Size: 259 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# dynareadout
An Ansi C library for parsing binary output files of LS Dyna (d3plot, binout) with bindings for go.
## Examples
### Binout
```go
package mainimport (
"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
```go
package mainimport (
"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++](https://github.com/PucklaJ/dynareadout) and [python](https://github.com/PucklaJ/dynareadout_python).