GithubHelp home page GithubHelp logo

exodus.jl's Introduction

Build Status Aqua QA Coverage Dev

Exodus.jl

A julia interface for accessing the ExodusII data format for large scale finite element simulations. The C library is directly called through julia ccalls.

Installation

From the package manager simply type

add Exodus

Read Example

To read in an exodusII file (typically has a .e or .exo extension) simply do the following

exo = ExodusDatabase("/path-to-file/file.e", "r")

This returns an ExodusDatabase container which has a single field "exo" that is a file id for this now opened exodusII database in "r" i.e. read only format. The purpose of the container is to attached various types for multiple dispatch later on as the exodusII format can switch between data types for various fields such as element connectivity in Int32 or Int64 format or nodal variables in floats or doubles.

For more useful methods, one can fetch the blocks of elements as follows which contains connectivity information for different blocks of elements useful for grouping materials

blocks = read_sets(exo, Block)

For boundary conditions one can grab the nodes with the following commands

nsets = read_sets(exo, NodeSet)

Full code example:

using Exodus
exo = ExodusDatabase("../path-to-file/file.e", "r") # read only format
coords          = read_coordinates(exo) # matrix of n_nodes x n_dim
blocks          = read_sets(exo, Block) # contains connectivity information
nsets           = read_sets(exo, NodeSet) # contains nodes on boundaries
nodal_var_names = read_names(exo, NodalVariable)
elem_var_names  = read_names(exo, ElementVariable)
close(exo) # cleanup

Write Example where the mesh is first copied

using Exodus
copy_mesh("./mesh.g", "r")
exo = ExodusDatabase("./temp_element_variables.e", "rw")

write_time(exo, 1, 0.0)

write_names(exo, NodalVariable, ["displ_x", "displ_y"])
write_names(exo, ElementVariable, ["stress_xx", "stress_yy", "stress_xy"])

write_values(exo, NodalVariable, 1, 1, randn(...))
... # and so on.

close(exo)

Write example from scratch

using Exodus

# data to write
coords = [
  1.0 0.5 0.5 1.0 0.0 0.0 0.5 1.0 0.0
  1.0 1.0 0.5 0.5 1.0 0.5 0.0 0.0 0.0
]

conn = [
  1 2 4 3
  2 5 3 6
  3 6 7 9
  4 3 8 7
]

# make some hack variables to write
v_nodal_1 = rand(9)
v_nodal_2 = rand(9)

v_elem_1 = rand(4)
v_elem_2 = rand(4)

# set the types
maps_int_type = Int32
ids_int_type  = Int32
bulk_int_type = Int32
float_type    = Float64

# initialization parameters
num_dim, num_nodes = size(coords)
num_elems          = size(conn, 2)
num_elem_blks      = 1
num_side_sets      = 0
num_node_sets      = 0

# make init
init = Initialization{bulk_int_type}(
  num_dim, num_nodes, num_elems,
  num_elem_blks, num_side_sets, num_node_sets
)

# finally make empty exo database
exo = ExodusDatabase(
  "test_write.e", "w", init,
  maps_int_type, ids_int_type, bulk_int_type, float_type
)

# how to write coordinates
write_coordinates(exo, coords)
# how to write a block
write_block(exo, 1, "QUAD4", conn)
# need at least one timestep to output variables
write_time(exo, 1, 0.0)
# write number of variables and their names
write_names(exo, NodalVariable, ["v_nodal_1", "v_nodal_2"])
write_names(exo, ElementVariable, ["v_elem_1", "v_elem_2"])
# write variable values the 1 is for the time step
write_values(exo, NodalVariable, 1, "v_nodal_1", v_nodal_1)
write_values(exo, NodalVariable, 1, "v_nodal_2", v_nodal_2)
# the first 1 is for the time step 
# and the second 1 is for the block number
write_values(exo, ElementVariable, 1, 1, "v_elem_1", v_elem_1)
write_values(exo, ElementVariable, 1, 1, "v_elem_2", v_elem_2)
# don't forget to close the exodusdatabase, it can get corrupted otherwise if you're writing
close(exo)

exodus.jl's People

Contributors

cmhamel avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

exodus.jl's Issues

Exodiff errors

Make exodiff not error out when files are not the same. Actually handle stderr properly

TagBot trigger issue

This issue is used to trigger TagBot; feel free to unsubscribe.

If you haven't already, you should update your TagBot.yml to include issue comment triggers.
Please see this post on Discourse for instructions and more details.

If you'd like for me to do this for you, comment TagBot fix on this issue.
I'll open a PR within a few hours, please be patient!

Add windows CI back

just skip whatever tests don't work on Windows, we can use this as a way to see what works and what doesn't.

Undefined types in SideSets.jl

There are undefined variable types in SideSets.jl. They are here:

https://github.com/cmhamel/Exodus.jl/blob/master/src/SideSets.jl#L74
https://github.com/cmhamel/Exodus.jl/blob/master/src/SideSets.jl#L75
https://github.com/cmhamel/Exodus.jl/blob/master/src/SideSets.jl#L87
https://github.com/cmhamel/Exodus.jl/blob/master/src/SideSets.jl#L88

The type B which exist in the exo variable is readily available on the first two occurrences above, but not in the last two ones.

This type B and the type I also from exo are used for side sets but not for node sets. Maybe they could be removed?

read_coordinates(ExodusObject) fails

Hello!

I try to read a Exodus file with the Exodus.jl package! Installation was successful and easy, and most functions from the read me (i.e. read_block_ids, read_blocks, read_node_set_ids, read_node_sets, read_nodal_variable_names, read_element_variable_names) work well and without a problem!

However, when I try to read coordinates with read_coordinates, my terminal crashes and I am left with the following error in a VSCode pop-up:

The terminal process "C:\Users\Win10\AppData\Local\Programs\Julia-1.8.5\bin\julia.exe '-i', '--banner=no', '--project=c:\Users\Win10\Desktop\Arbeit\TU\work_env', 'c:\Users\Win10.vscode\extensions\julialang.language-julia-1.47.2\scripts\terminalserver\terminalserver.jl', '\.\pipe\vsc-jl-repl-e371abf6-13c9-4920-ac21-070935af1a66', '\.\pipe\vsc-jl-cr-d5d8da41-2d79-4dba-aa9f-98ddec369c24', 'USE_REVISE=true', 'USE_PLOTPANE=true', 'USE_PROGRESS=true', 'ENABLE_SHELL_INTEGRATION=true', 'DEBUG_MODE=false'" terminated with exit code: 3221226356.

Sometimes there used to be a different Messge within the Terminal, when it not crashed, however I fail to reproduce that now. But for the sake of additional information, it said something with ReadOnly.... Error. And it also said that I should report the bug here!

Here is the code that reproduces the Terminal termination for me everytime.

exo = ExodusDatabase("read_exodus\\test.e", "r")
coords          = read_coordinates(exo)

I understand that the test file might be corrupt, but it is still strange behaviour since the other functions work very well, and when I use the FiniteMesh.jl package, I can easily read the coordinates!

If it is beneficial for answering the question or resolving the issues, I can ask my supervisors if I can upload the test file!

Thank you very much, I will try to help find the bug but I am happy with any help!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.