Memorandum of introduction of EXODUS, a data model of the finite element method (FEM)

Introduction

EXODUS is a data file for storing data for finite element analysis. It is a format that can be used both as an intermediate generation file when diverting the calculation result in other code and as a format for storing the calculation result.

Until now, the calculation results for my own FEM were output in vtk format, but EXODUS seems to be more reusable, so I am moving to this.

Introduction

Bring the code from the repository below. https://github.com/gsjaardema/seacas#exodus I think that there is basically no problem with the introduction if you follow this.

Here, it is assumed that you check out and build with ~ / local.

cd ~
mkdir local
cd local
git clone https://github.com/gsjaardema/seacas.git
cd seacas && export ACCESS=`pwd`

It is necessary to prepare NetCDF and HDF5 as Third-Party Library (TPL), so download them from the following respectively. https://www.unidata.ucar.edu/downloads/netcdf/ https://portal.hdfgroup.org/display/support/HDF5%201.12.0

cd TPL/hdf5
wget https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.12/hdf5-1.12.0/src/hdf5-1.12.0.tar.gz
tar -zxvf ./hdf5-1.12.0.tar.gz
cd hdf5-1.12.0
../runconfigure.sh
cd ../../netcdf
wget https://www.unidata.ucar.edu/downloads/netcdf/ftp/netcdf-c-4.7.4.tar.gz
tar -zxvf ./netcdf-c-4.7.4.tar.gz
cd netcdf-c-4.7.4/
mkdir build
cd build
sh ../../runcmake.sh
make && make install
cd ../../../../
mkdir build
../cmake-exodus
make && make install

How to use

Basically it is OK if you look at the following manual https://gsjaardema.github.io/seacas/exodusII-new.pdf

As a sample, the code for outputting a mesh of a cantilever with dimensions 1 x 1 x 10 divided by 10 8-node hexahedron elements in EXODUS format is shown below.

#include <exodusII.h>
#include <iostream>
#include <vector>

int main(){
  int N;
  N = 10; // the length of cantilever
  
  int CPU_word_size, IO_word_size, exoid;
  CPU_word_size = sizeof(double);
  IO_word_size = 8;

  exoid = ex_create("test.exo",                //file Name
		    EX_CLOBBER,                //create mode
		    &CPU_word_size,            //CPU float word size in bytes
		    &IO_word_size);            //I/O float word size in bytes

  
  int dim = 3;           // dimension
  int NoN = 4 + 4 * N;   // num of nodes
  int NoE = N;       // num of elements
  int NoEB = 1;          // num of element blocks
  int NoNS = 0;          // num of node sets
  int NoSS = 0;          // num of side sets
  
  ex_put_init(exoid, "Test", dim, NoN, NoE, NoEB, NoNS, NoSS);
  std::vector<double> x(NoN), y(NoN), z(NoN), i2nn(NoN);
  char* coord_names[3];
  coord_names[0] = "xcoor";
  coord_names[1] = "ycoor";
  coord_names[2] = "zcoor";
  
  for(int i=0;i<=N;i++){
    x[i*4] = 0;   y[i*4] = 0;   z[i*4]=i;   i2nn[i*4] = i*4 + 1;
    x[i*4+1] = 1; y[i*4+1] = 0; z[i*4+1]=i; i2nn[i*4+1] = i*4 + 2;
    x[i*4+2] = 1; y[i*4+2] = 1; z[i*4+2]=i; i2nn[i*4+2] = i*4 + 3;
    x[i*4+3] = 0; y[i*4+3] = 1; z[i*4+3]=i; i2nn[i*4+3] = i*4 + 4;
  }
  ex_put_coord(exoid, x.data(), y.data(), z.data());
  ex_put_coord_names(exoid, coord_names);
  ex_put_node_num_map(exoid, i2nn.data());
  
  
  //for(int i=0;i<NoE;i++)i2nn[i] = i+1;
  
  int NoN_for_EB = NoE; // number of nodes for element block
  int NoN_per_Elem = 8; // number of nodes of each element
  int ebid = 1;         // element block id
  ex_put_elem_block(exoid, ebid, "hex", NoN_for_EB, NoN_per_Elem, 0);
  
  std::vector<int> connectivity(NoE * NoN_per_Elem);
  std::vector<int> i2en(NoE); // index to element number
  
  for(int i=0; i<NoE; i++){
    for(int j=0;j<8;j++){
      connectivity[i*8 + j] = i*4 + j +1;
    }
    i2en[i] = i+1;
  }
  ex_put_elem_conn(exoid, ebid, connectivity.data());
  ex_put_elem_num_map(exoid, i2en.data());
  ex_close(exoid);
  
  return 0;
}

For example, you can compile as follows.

g++ main.cpp -I ~/local/seacas/include -L ~/local/seacas/lib -lexodus

If you look at the output test.exo with Paraview, it will be as follows. image.png

Since the node amount and element amount are not output this time, the contour is the element ID.

At the end

This time, we showed the introduction and operation check of the EXODUS format that can store the result of the finite element method. I would appreciate it if you could let me know if you have a better file type.

that's all.

Recommended Posts

Memorandum of introduction of EXODUS, a data model of the finite element method (FEM)
Creating the finite element method (FEM) with python ~ vba → python translation ~
Creating the finite element method (FEM) with python ~ damyarou's messing around ~
A memorandum of trouble when formatting data
A memorandum of method often used when analyzing data with pandas (for beginners)
[Introduction to Python] How to get the index of data with a for statement
A memorandum about the warning of the pylint output result
A simple Python implementation of the k-nearest neighbor method (k-NN)
A network diagram was created with the data of COVID-19.
Finite element method Beginning 2 (Preparation of one-dimensional overall stiffness matrix)
The story of a Django model field disappearing from a class
I made a function to check the model of DCGAN
[Introduction to AWS] A memorandum of building a web server on AWS
Analyze the topic model of becoming a novelist with GensimPy3
[Data science memorandum] Confirmation of the contents of DataFrame type [python]
A memorandum of kernel compilation
A small memorandum of openpyxl
A memorandum of using eigen3
A memorandum of understanding for the Python package management tool ez_setup
A method of converting the style of an image while preserving the color
[Introduction to StyleGAN] I played with "The Life of a Man" ♬
Embedding method DensMAP that reflects the density of distribution of high-dimensional data
A function that measures the processing time of a method in python
Evaluate the performance of a simple regression model using LeaveOneOut cross-validation
[Introduction to SIR model] Consider the fitting result of Diamond Princess ♬
A memorandum regarding the acquisition of the Python3 engineer certification basic exam