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# Set up domino toppling example
 2solfec = SOLFEC ('DYNAMIC', 1E-3, 'out/domino')
 3GRAVITY (solfec, (0, 0, -9.81))
 4mat = BULK_MATERIAL (solfec, model = 'KIRCHHOFF',
 5    young = 15E9, poisson = 0.3, density = 1.8E3)
 6SURFACE_MATERIAL (solfec, model = 'SIGNORINI_COULOMB',
 7                   friction = 0.5, restitution = 0.25)
 8cube = HEX ([0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1,
 9            1, 0, 1, 1, 1, 1, 0, 1, 1], 2, 2, 2, 1, [1]*6)
10BODY (solfec, 'OBSTACLE', SCALE(COPY(cube), (1, 1, 0.1)), mat)
11for i in range (0, 4):
12  piece = SCALE (COPY(cube), (0.2, 0.05, 0.4))
13  TRANSLATE (piece, (0.4, i*0.2, 0.1))
14  BODY (solfec, 'RIGID', piece, mat, label = 'Domino' + str(i+1))
15ball = BODY (solfec, 'RIGID', SPHERE ((0.5, -0.5, 0.4), 0.1, 3, 3), mat)
16INITIAL_VELOCITY (ball, (0, 3, 0), (0, 0, 0))
17
18# Export initial state or run simulation
19argv = NON_SOLFEC_ARGV()
20if argv != None and '--geom0' in argv:
21  SOLFEC_EXPORT (solfec, 0.0, 'out/sxptest0')
22  solfec.cleanup = 'ON'
23else: RUN (solfec, NEWTON_SOLVER(), 1.0)
24
25# Export results
26if solfec.mode == 'READ' and not VIEWER():
27  # export simulation state at t = 0.5
28  SOLFEC_EXPORT (solfec, 0.5, 'out/sxptest1')
29  # export entire simulation:
30  SOLFEC_EXPORT (solfec, (0.0, 1.0), 'out/sxptest2')
31  # 101 time instants:
32  times = [0.01*i for i in range(0, 101)]
33  # export all bodies at 101 times:
34  SOLFEC_EXPORT (solfec, times, 'out/sxptest3')
35  # export a subset of bodies at 101 times:
36  SOLFEC_EXPORT (solfec, times, 'out/sxptest4',
37    subset = [(0.4, 0, 0, 0.6, 0.05, 0.2), 'Domino2', ball])
38  # export Domino2 and Domino3 at 101 times:
39  SOLFEC_EXPORT (solfec, times, 'out/sxptest5', subset = 'Domino[2,3]')

Comments

comments powered by Disqus