SOLFEC_EXPORT command

In analogy to Solfec’s XDMF_EXPORT command, a new SOLFEC_EXPORT command has been added. This allows to save a subset of results into a separate directory and view them using Solfec’s viewer. Within Solfec sources example inp/devel/solfec-export.py depicts an application of this idea. (…)

Assuming we are inside of Solfec source directory, this example can be executed as follows:

./solfec inp/devel/solfec-export.py --geom0

to first demonstrate the export of initial geometry in ‘WRITE’ mode, followed by

./solfec -v out/sxptest0/

to view the initial state using Solfec’s viewer. To test the results export in the ‘READ’ mode run twice:

./solfec inp/devel/solfec-export.py

and then view any of the output files:

./solfec -v out/sxptest1
./solfec -v out/sxptest2
./solfec -v out/sxptest3
./solfec -v out/sxptest4
./solfec -v out/sxptest5

Listing of the input file, below, may help to associate those directories with a particular kind of exported subset.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# Set up domino toppling example
solfec = SOLFEC ('DYNAMIC', 1E-3, 'out/domino')
GRAVITY (solfec, (0, 0, -9.81))
mat = BULK_MATERIAL (solfec, model = 'KIRCHHOFF',
    young = 15E9, poisson = 0.3, density = 1.8E3)
SURFACE_MATERIAL (solfec, model = 'SIGNORINI_COULOMB',
                   friction = 0.5, restitution = 0.25)
cube = HEX ([0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1,
            1, 0, 1, 1, 1, 1, 0, 1, 1], 2, 2, 2, 1, [1]*6)
BODY (solfec, 'OBSTACLE', SCALE(COPY(cube), (1, 1, 0.1)), mat)
for i in range (0, 4):
  piece = SCALE (COPY(cube), (0.2, 0.05, 0.4))
  TRANSLATE (piece, (0.4, i*0.2, 0.1))
  BODY (solfec, 'RIGID', piece, mat, label = 'Domino' + str(i+1))
ball = BODY (solfec, 'RIGID', SPHERE ((0.5, -0.5, 0.4), 0.1, 3, 3), mat)
INITIAL_VELOCITY (ball, (0, 3, 0), (0, 0, 0))

# Export initial state or run simulation
argv = NON_SOLFEC_ARGV()
if argv != None and '--geom0' in argv:
  SOLFEC_EXPORT (solfec, 0.0, 'out/sxptest0')
  solfec.cleanup = 'ON'
else: RUN (solfec, NEWTON_SOLVER(), 1.0)

# Export results
if solfec.mode == 'READ' and not VIEWER():
  # export simulation state at t = 0.5
  SOLFEC_EXPORT (solfec, 0.5, 'out/sxptest1')
  # export entire simulation:
  SOLFEC_EXPORT (solfec, (0.0, 1.0), 'out/sxptest2')
  # 101 time instants:
  times = [0.01*i for i in range(0, 101)]
  # export all bodies at 101 times:
  SOLFEC_EXPORT (solfec, times, 'out/sxptest3')
  # export a subset of bodies at 101 times:
  SOLFEC_EXPORT (solfec, times, 'out/sxptest4',
    subset = [(0.4, 0, 0, 0.6, 0.05, 0.2), 'Domino2', ball])
  # export Domino2 and Domino3 at 101 times:
  SOLFEC_EXPORT (solfec, times, 'out/sxptest5', subset = 'Domino[2,3]')

Comments

comments powered by Disqus