Debian Codegraph @

packages/rol/example/PDE-OPT/topo-opt/elasticity/process3D.sh

raw
1 #!/bin/bash
2
3 # Grab number of nodes
4 NN=$(cat nodes.txt | wc -l)
5 NN0=$((NN * 3 + 2))
6
7 # Replace double space with single space in nodes
8 cat nodes.txt | tr -s '[:space:]' > nodes-mod.txt
9
10 # Extract nodal state data
11 sed -n "3~3p;$NN0 q" state.txt > state-dispx.txt
12 sed -n "4~3p;$NN0 q" state.txt > state-dispy.txt
13 sed -n "5~3p;$NN0 q" state.txt > state-dispz.txt
14
15 # Add nodal state data to nodes
16 paste -d'\0 ' nodes-mod.txt state-dispx.txt state-dispy.txt state-dispz.txt > results-state-0.txt
17
18 # Extract nodal control data
19 sed -n "3~3p;$NN0 q" density.txt > density-0.txt
20
21 # Add nodal state data to nodes
22 paste -d'\0 ' nodes-mod.txt density-0.txt > results-density-0.txt
23
24 # Add header to state and control results files
25 echo 'X Y Z DX DY DZ' > header-state.txt
26 cat header-state.txt results-state-0.txt > results-state.txt
27 echo 'X Y Z D' > header-density.txt
28 cat header-density.txt results-density-0.txt > results-density.txt
29
30 # Remove temporary files
31 rm state-dispx.txt state-dispy.txt state-dispz.txt density-0.txt
32 rm results-state-0.txt results-density-0.txt nodes-mod.txt
33 rm header-state.txt header-density.txt