Merge lp:~fluidity-core/fluidity/fix-lagr-detectors into lp:fluidity

Proposed by Michael Lange
Status: Merged
Merged at revision: 4315
Proposed branch: lp:~fluidity-core/fluidity/fix-lagr-detectors
Merge into: lp:fluidity
Diff against target: 554 lines (+319/-59)
13 files modified
femtools/Detector_Parallel.F90 (+25/-13)
femtools/Diagnostic_variables.F90 (+2/-1)
tests/detectors_parallel_adaptivity/detectors_parallel_adaptivity.xml (+12/-2)
tests/detectors_parallel_adaptivity/readtool.py (+0/-21)
tests/lagrangian_detectors/lagrangian_detectors.xml (+28/-2)
tests/lagrangian_detectors/lagrangian_detectors_rk.flml (+15/-0)
tests/lagrangian_detectors/readtool.py (+0/-20)
tests/lagrangian_detectors_checkpoint/Makefile (+9/-0)
tests/lagrangian_detectors_checkpoint/Xvals.txt (+1/-0)
tests/lagrangian_detectors_checkpoint/Yvals.txt (+1/-0)
tests/lagrangian_detectors_checkpoint/lagrangian_detectors.flml (+178/-0)
tests/lagrangian_detectors_checkpoint/lagrangian_detectors_checkpoint.xml (+35/-0)
tests/lagrangian_detectors_checkpoint/square.geo (+13/-0)
To merge this branch: bzr merge lp:~fluidity-core/fluidity/fix-lagr-detectors
Reviewer Review Type Date Requested Status
Jon Hill Approve
Rhodri Davies Approve
Review via email: mp+202367@code.launchpad.net

Description of the change

Fixing several bugs in lagrangian detectors:

 * Bug #1262890: Single lagrangian detectors are initialised with wrong names, causing detector I/O to fail in parallel
 * Bug #1260019: Prevent buffer corruption in exchange_detectors through use of multiple send/receive buffers
 * Re-initialisation of detector names from checkpoint

To post a comment you must log in.
Revision history for this message
Michael Lange (michael-lange) wrote :

Buildbot queue is green.

Revision history for this message
Rhodri Davies (rhodri-davies) wrote :

Hi Michael,

The changes looks good to me, although it may be worth somebody that better understands how detectors are handled in parallel taking a look at the MPI changes before the merge is approved.

One issue: there don't seem to be any modifications to tests to verify that these errors will not crop up again in the future. Is there any way some of the lagrangian detector cases could be modified to test these things? I guess a test for the individual lagrangian detector I/O bug could easily be added to an existing test, but how about the other bug?

Rhod

Revision history for this message
Jon Hill (jon-hill) wrote :

Yep - these look good. We do need a short test, if possible to verify these changes do fix the bug (I'm positive they do!) and do make the detectors more robust in general. Otherwise, it's an approve from me.

4305. By Michael Lange

Adding a test for single lagrangian detectors.

4306. By Michael Lange

Adding a test for detector checkpointing based on the lagrangian_detectors test.

4307. By Michael Lange

Bugfix to allow detector output files to grow larger than 2.1GB. Thanks to Jean Mensa for reporting and providing the fix for this.

4308. By Michael Lange

Merge from trunk

Revision history for this message
Michael Lange (michael-lange) wrote :

I added tests for detector checkpointing and the single lagrangian detector fix. The buffer corruption issue, however, cannot reliably be triggered and requires a lot of detectors; so I think it is impractical to test for this in small/medium tests.

I have also added Jean Mensa's fix for large detector output files, but again this seems like a corner case that is very hard to catch in buildbot.

Revision history for this message
Jon Hill (jon-hill) wrote :

Fine - we can't add tests for 3Gb files on a buildbot, so approved.

review: Approve
Revision history for this message
Rhodri Davies (rhodri-davies) wrote :

Hi Michael/Jon,

Sorry - I emailed Michal this earlier rather than add it to the review... At present, there remains work to be done before the merge (email copied below)...

------------

Hi Michael,

Whilst looking over your most recent changes to the fix_lagr_detectors branch, I tried to run the lagrangian_detectors test case locally. I get the following error (with backtrace):

*** FLUIDITY ERROR ***
Source location: (Diagnostic_variables.F90, 2785)
Error message: Failed assertion ierror == MPI_SUCCESS
Backtrace will follow if it is available:
../../bin/fluidity(fprint_backtrace_+0x1f) [0x57be1f]
../../bin/fluidity(__fldebug_MOD_flabort_pinpoint+0x304) [0x5701c3]
../../bin/fluidity(__diagnostic_variables_MOD_write_mpi_out+0x7a0) [0x627c29]
../../bin/fluidity(__diagnostic_variables_MOD_write_detectors+0x1c7d) [0x62af98]
../../bin/fluidity(__diagnostic_variables_MOD_write_diagnostics+0x577d) [0x635d9e]
../../bin/fluidity(__fluids_module_MOD_fluids+0x72a5) [0x57b17c]
../../bin/fluidity(mainfl+0x11d) [0x56d889]
../../bin/fluidity(main+0x177) [0x5641ad]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xed) [0x7f785ded476d]
../../bin/fluidity() [0x563d51]
Use addr2line -e <binary> <address> to decipher.
Error is terminal.

I configured as follows:

./configure --enable-debugging --enable-2d-adaptivity ; make clean ; make -j ; make -j fltools

Do you get this error locally?

Buildbot on your branch is also red right now (but apparently not for this test, which confuses me slightly!)... Any ideas?

Rhod

Revision history for this message
Jon Hill (jon-hill) wrote :

then we will fix the approve :)

review: Needs Fixing
4309. By Michael Lange

Reverting the previous bugfix for large detector output files, since it causes buildbot failures. We'll have to re-visit this problem in a separate merge.

Revision history for this message
Michael Lange (michael-lange) wrote :

Hi Rhodri,

All tests pass locally for me, so the buildbot error is indeed confusing. Your local error though should to be due to the filesize bugfix I just reverted. Can you please confirm that this works now?

Thanks
Michael

Revision history for this message
Rhodri Davies (rhodri-davies) wrote :

Hi Michael,

I can confirm that the error is fixed on my local system, whilst detectors_parallel_adaptivity also passes locally. Sadly the buildbot branch is still red for the detectors_parallel_adaptivity case, however, which I think is a tolerance issue. Are you happy to reduce the final_location_error tolerance slightly (if this is indeed the issue on buildbot of course)? Once this test passes on buildbot I think this merge is good to go.

Rhod

Revision history for this message
Xiaohu Guo (xiaohu-guo) wrote :

Hi Michael,
   Just a thought.

   in femtools/Detector_Parallel.F90:35

   should MPI_ISEND also covered by "if (ndet_to_send>0)", otherwise you would have zero messages ?

Cheers
Xiaohu

4310. By Michael Lange

Avoid errors due to Python import caching in all lagrangian detector tests.

When runnning all test in one Python instance, like buildbot does, Python
would load the wrong readtool.py due to import caching. This can be avoided
by moving the test code into the xml.

Revision history for this message
Michael Lange (michael-lange) wrote :

Buildbot is green now.

Revision history for this message
Rhodri Davies (rhodri-davies) wrote :

In that case - I think it's good to go. Nice work.

review: Approve
Revision history for this message
Jon Hill (jon-hill) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'femtools/Detector_Parallel.F90'
--- femtools/Detector_Parallel.F90 2011-10-14 07:58:31 +0000
+++ femtools/Detector_Parallel.F90 2014-01-29 10:13:58 +0000
@@ -50,6 +50,11 @@
50 type(detector_list_ptr), dimension(:), allocatable, target, save :: detector_list_array50 type(detector_list_ptr), dimension(:), allocatable, target, save :: detector_list_array
51 integer :: num_detector_lists = 051 integer :: num_detector_lists = 0
5252
53 type detector_buffer
54 !!< Container type for MPI data buffers
55 real, dimension(:,:), pointer :: ptr
56 end type detector_buffer
57
53contains58contains
5459
55 subroutine register_detector_list(detector_list)60 subroutine register_detector_list(detector_list)
@@ -301,7 +306,7 @@
301 type(detector_linked_list), intent(inout) :: detector_list306 type(detector_linked_list), intent(inout) :: detector_list
302 type(detector_linked_list), dimension(:), intent(inout) :: send_list_array307 type(detector_linked_list), dimension(:), intent(inout) :: send_list_array
303308
304 real, dimension(:,:), allocatable :: detector_buffer309 type(detector_buffer), dimension(:), allocatable :: send_buffer, recv_buffer
305 type(detector_type), pointer :: detector, detector_received310 type(detector_type), pointer :: detector, detector_received
306 type(vector_field), pointer :: xfield311 type(vector_field), pointer :: xfield
307 type(halo_type), pointer :: ele_halo312 type(halo_type), pointer :: ele_halo
@@ -342,9 +347,10 @@
342 end if347 end if
343 348
344 ! Send to all procs349 ! Send to all procs
350 allocate(send_buffer(nprocs))
345 do target_proc=1, nprocs351 do target_proc=1, nprocs
346 ndet_to_send=send_list_array(target_proc)%length352 ndet_to_send=send_list_array(target_proc)%length
347 allocate(detector_buffer(ndet_to_send,det_size))353 allocate(send_buffer(target_proc)%ptr(ndet_to_send,det_size))
348354
349 if (ndet_to_send>0) then355 if (ndet_to_send>0) then
350 ewrite(2,*) " Sending", ndet_to_send, "detectors to process", target_proc356 ewrite(2,*) " Sending", ndet_to_send, "detectors to process", target_proc
@@ -360,9 +366,9 @@
360 detector%element = halo_universal_number(ele_halo, detector%element)366 detector%element = halo_universal_number(ele_halo, detector%element)
361367
362 if (have_update_vector) then368 if (have_update_vector) then
363 call pack_detector(detector, detector_buffer(j,1:det_size), dim, nstages=n_stages)369 call pack_detector(detector, send_buffer(target_proc)%ptr(j,1:det_size), dim, nstages=n_stages)
364 else370 else
365 call pack_detector(detector, detector_buffer(j,1:det_size), dim)371 call pack_detector(detector, send_buffer(target_proc)%ptr(j,1:det_size), dim)
366 end if372 end if
367373
368 ! delete also advances detector374 ! delete also advances detector
@@ -372,18 +378,17 @@
372 end if378 end if
373379
374 ! getprocno() returns the rank of the processor + 1, hence target_proc-1380 ! getprocno() returns the rank of the processor + 1, hence target_proc-1
375 call MPI_ISEND(detector_buffer,size(detector_buffer), &381 call MPI_ISEND(send_buffer(target_proc)%ptr,size(send_buffer(target_proc)%ptr(:,:)), &
376 & getpreal(), target_proc-1, TAG, MPI_COMM_FEMTOOLS, sendRequest(target_proc), IERROR)382 & getpreal(), target_proc-1, TAG, MPI_COMM_FEMTOOLS, sendRequest(target_proc), IERROR)
377 assert(ierror == MPI_SUCCESS)383 assert(ierror == MPI_SUCCESS)
378384
379 ! deallocate buffer after sending
380 deallocate(detector_buffer)
381 end do385 end do
382386
383 allocate( status(MPI_STATUS_SIZE) )387 allocate( status(MPI_STATUS_SIZE) )
384 call get_universal_numbering_inverse(ele_halo, ele_numbering_inverse)388 call get_universal_numbering_inverse(ele_halo, ele_numbering_inverse)
385389
386 ! Receive from all procs390 ! Receive from all procs
391 allocate(recv_buffer(nprocs))
387 do receive_proc=1, nprocs392 do receive_proc=1, nprocs
388 call MPI_PROBE(receive_proc-1, TAG, MPI_COMM_FEMTOOLS, status(:), IERROR) 393 call MPI_PROBE(receive_proc-1, TAG, MPI_COMM_FEMTOOLS, status(:), IERROR)
389 assert(ierror == MPI_SUCCESS)394 assert(ierror == MPI_SUCCESS)
@@ -392,13 +397,13 @@
392 assert(ierror == MPI_SUCCESS)397 assert(ierror == MPI_SUCCESS)
393398
394 ndet_received=count/det_size399 ndet_received=count/det_size
395 allocate(detector_buffer(ndet_received,det_size))400 allocate(recv_buffer(receive_proc)%ptr(ndet_received,det_size))
396401
397 if (ndet_received>0) then402 if (ndet_received>0) then
398 ewrite(2,*) " Receiving", ndet_received, "detectors from process", receive_proc403 ewrite(2,*) " Receiving", ndet_received, "detectors from process", receive_proc
399 end if404 end if
400405
401 call MPI_Recv(detector_buffer,count, getpreal(), status(MPI_SOURCE), TAG, MPI_COMM_FEMTOOLS, MPI_STATUS_IGNORE, IERROR)406 call MPI_Recv(recv_buffer(receive_proc)%ptr,count, getpreal(), status(MPI_SOURCE), TAG, MPI_COMM_FEMTOOLS, MPI_STATUS_IGNORE, IERROR)
402 assert(ierror == MPI_SUCCESS)407 assert(ierror == MPI_SUCCESS)
403408
404 do j=1, ndet_received409 do j=1, ndet_received
@@ -407,10 +412,10 @@
407 ! Unpack routine uses ele_numbering_inverse to translate universal element 412 ! Unpack routine uses ele_numbering_inverse to translate universal element
408 ! back to local detector element413 ! back to local detector element
409 if (have_update_vector) then414 if (have_update_vector) then
410 call unpack_detector(detector_received,detector_buffer(j,1:det_size),dim,&415 call unpack_detector(detector_received,recv_buffer(receive_proc)%ptr(j,1:det_size),dim,&
411 global_to_local=ele_numbering_inverse,coordinates=xfield,nstages=n_stages)416 global_to_local=ele_numbering_inverse,coordinates=xfield,nstages=n_stages)
412 else417 else
413 call unpack_detector(detector_received,detector_buffer(j,1:det_size),dim,&418 call unpack_detector(detector_received,recv_buffer(receive_proc)%ptr(j,1:det_size),dim,&
414 global_to_local=ele_numbering_inverse,coordinates=xfield)419 global_to_local=ele_numbering_inverse,coordinates=xfield)
415 end if420 end if
416421
@@ -423,8 +428,15 @@
423428
424 call insert(detector_received, detector_list) 429 call insert(detector_received, detector_list)
425 end do430 end do
426 deallocate(detector_buffer)431 end do
427 end do 432
433 ! Deallocate buffers after exchange
434 do target_proc=1, nprocs
435 deallocate(send_buffer(target_proc)%ptr)
436 deallocate(recv_buffer(target_proc)%ptr)
437 end do
438 deallocate(send_buffer)
439 deallocate(recv_buffer)
428440
429 call MPI_WAITALL(nprocs, sendRequest, MPI_STATUSES_IGNORE, IERROR)441 call MPI_WAITALL(nprocs, sendRequest, MPI_STATUSES_IGNORE, IERROR)
430 assert(ierror == MPI_SUCCESS)442 assert(ierror == MPI_SUCCESS)
431443
=== modified file 'femtools/Diagnostic_variables.F90'
--- femtools/Diagnostic_variables.F90 2013-10-10 07:35:33 +0000
+++ femtools/Diagnostic_variables.F90 2014-01-29 10:13:58 +0000
@@ -1533,7 +1533,7 @@
1533 default_stat%detector_list%detector_names(static_dete+i)=detector_name1533 default_stat%detector_list%detector_names(static_dete+i)=detector_name
15341534
1535 call create_single_detector(default_stat%detector_list, xfield, &1535 call create_single_detector(default_stat%detector_list, xfield, &
1536 detector_location, static_dete+1, LAGRANGIAN_DETECTOR, trim(detector_name))1536 detector_location, static_dete+i, LAGRANGIAN_DETECTOR, trim(detector_name))
1537 end do1537 end do
15381538
1539 k=static_dete+lagrangian_dete+11539 k=static_dete+lagrangian_dete+1
@@ -1682,6 +1682,7 @@
1682 read(default_stat%detector_checkpoint_unit) detector_location1682 read(default_stat%detector_checkpoint_unit) detector_location
1683 call create_single_detector(default_stat%detector_list, xfield, &1683 call create_single_detector(default_stat%detector_list, xfield, &
1684 detector_location, k, type_det, trim(detector_name)) 1684 detector_location, k, type_det, trim(detector_name))
1685 default_stat%detector_list%detector_names(k)=trim(detector_name)
1685 k=k+1 1686 k=k+1
1686 end do1687 end do
1687 else 1688 else
16881689
=== modified file 'tests/detectors_parallel_adaptivity/detectors_parallel_adaptivity.xml'
--- tests/detectors_parallel_adaptivity/detectors_parallel_adaptivity.xml 2013-08-21 19:58:53 +0000
+++ tests/detectors_parallel_adaptivity/detectors_parallel_adaptivity.xml 2014-01-29 10:13:58 +0000
@@ -18,8 +18,18 @@
18ElapsedTime=s["ElapsedTime"]["value"]18ElapsedTime=s["ElapsedTime"]["value"]
19 </variable>19 </variable>
20 <variable name="last_locations_error" language="python">20 <variable name="last_locations_error" language="python">
21from readtool import readstat21from fluidity_tools import stat_parser
22last_locations_error = readstat("detectors.detectors")22from numpy import zeros,fromfile
23
24s = stat_parser('detectors.detectors')
25last_locations_error = zeros((2,100))
26X = fromfile('Xvals.txt',sep=' ')
27Y = fromfile('Yvals.txt',sep=' ')
28for i in range(100):
29 name = 'Steve_' + str(i+1).zfill(3)
30 # +0.5 due to domain change from the lagrangian_detectors setup
31 last_locations_error[0,i] = s[name]['position'][0][-1] - X[i] + 0.5
32 last_locations_error[1,i] = s[name]['position'][1][-1] - Y[i] + 0.5
23 </variable>33 </variable>
24 </variables>34 </variables>
25 <pass_tests>35 <pass_tests>
2636
=== removed file 'tests/detectors_parallel_adaptivity/readtool.py'
--- tests/detectors_parallel_adaptivity/readtool.py 2011-06-08 19:33:56 +0000
+++ tests/detectors_parallel_adaptivity/readtool.py 1970-01-01 00:00:00 +0000
@@ -1,21 +0,0 @@
1from fluidity_tools import stat_parser
2from numpy import zeros,fromfile
3def readstat(file_name):
4 s = stat_parser(file_name)
5
6 last_locations_error = zeros((2,100))
7 for i in range(100):
8 n = i + 1
9 padding = ''
10 if(n<100):
11 padding = '0'
12 if(n<10):
13 padding ='00'
14 # +0.5 due to domain change from the lagrangian_detectors setup
15 last_locations_error[0,i] = s['Steve_'+padding+str(n)]['position'][0][-1]+0.5
16 last_locations_error[1,i] = s['Steve_'+padding+str(n)]['position'][1][-1]+0.5
17 X = fromfile('Xvals.txt',sep=' ')
18 Y = fromfile('Yvals.txt',sep=' ')
19 last_locations_error[0,:] = last_locations_error[0,:] - X
20 last_locations_error[1,:] = last_locations_error[1,:] - Y
21 return last_locations_error
220
=== modified file 'tests/lagrangian_detectors/lagrangian_detectors.xml'
--- tests/lagrangian_detectors/lagrangian_detectors.xml 2013-08-21 19:58:53 +0000
+++ tests/lagrangian_detectors/lagrangian_detectors.xml 2014-01-29 10:13:58 +0000
@@ -11,12 +11,38 @@
11 </command_line>11 </command_line>
12 </problem_definition>12 </problem_definition>
13 <variables>13 <variables>
14 <variable name="last_single_locations_error" language="python">
15import numpy as np
16from fluidity_tools import stat_parser
17s = stat_parser("lagrangian_detectors.detectors")
18last_single_locations_error = np.zeros((2,3))
19X = np.fromfile('Xvals.txt',sep=' ')
20Y = np.fromfile('Yvals.txt',sep=' ')
21last_single_locations_error[0,0] = s['Single_Lagr_1']['position'][0][-1] - X[0]
22last_single_locations_error[1,0] = s['Single_Lagr_1']['position'][1][-1] - Y[0]
23last_single_locations_error[0,1] = s['Single_Lagr_2']['position'][0][-1] - X[50]
24last_single_locations_error[1,1] = s['Single_Lagr_2']['position'][1][-1] - Y[50]
25last_single_locations_error[0,2] = s['Single_Lagr_3']['position'][0][-1] - X[99]
26last_single_locations_error[1,2] = s['Single_Lagr_3']['position'][1][-1] - Y[99]
27 </variable>
14 <variable name="last_locations_error" language="python">28 <variable name="last_locations_error" language="python">
15from readtool import readstat29from fluidity_tools import stat_parser
16last_locations_error = readstat()30from numpy import zeros,fromfile
31
32s = stat_parser('lagrangian_detectors.detectors')
33last_locations_error = zeros((2,100))
34X = fromfile('Xvals.txt',sep=' ')
35Y = fromfile('Yvals.txt',sep=' ')
36for i in range(100):
37 name = 'Steve_' + str(i+1).zfill(3)
38 last_locations_error[0,i] = s[name]['position'][0][-1] - X[i]
39 last_locations_error[1,i] = s[name]['position'][1][-1] - Y[i]
17 </variable>40 </variable>
18 </variables>41 </variables>
19 <pass_tests>42 <pass_tests>
43 <test name="CorrectSingleLagrangianDetectors" language="python">
44assert abs(last_single_locations_error).max() &lt; 1.0e-6
45 </test>
20 <test name="CorrectLagrangianTrajectory" language="python">46 <test name="CorrectLagrangianTrajectory" language="python">
21assert abs(last_locations_error).max() &lt; 1.0e-647assert abs(last_locations_error).max() &lt; 1.0e-6
22 </test>48 </test>
2349
=== modified file 'tests/lagrangian_detectors/lagrangian_detectors_rk.flml'
--- tests/lagrangian_detectors/lagrangian_detectors_rk.flml 2012-03-11 02:25:56 +0000
+++ tests/lagrangian_detectors/lagrangian_detectors_rk.flml 2014-01-29 10:13:58 +0000
@@ -52,6 +52,21 @@
52 <output_mesh name="VelocityMesh"/>52 <output_mesh name="VelocityMesh"/>
53 <stat/>53 <stat/>
54 <detectors>54 <detectors>
55 <lagrangian_detector name="Single_Lagr_1">
56 <location>
57 <real_value shape="2" dim1="dim" rank="1">0.5 0.5</real_value>
58 </location>
59 </lagrangian_detector>
60 <lagrangian_detector name="Single_Lagr_2">
61 <location>
62 <real_value shape="2" dim1="dim" rank="1">0.625 0.5</real_value>
63 </location>
64 </lagrangian_detector>
65 <lagrangian_detector name="Single_Lagr_3">
66 <location>
67 <real_value shape="2" dim1="dim" rank="1">0.7475 0.5</real_value>
68 </location>
69 </lagrangian_detector>
55 <detector_array name="Steve">70 <detector_array name="Steve">
56 <number_of_detectors>71 <number_of_detectors>
57 <integer_value rank="0">100</integer_value>72 <integer_value rank="0">100</integer_value>
5873
=== removed file 'tests/lagrangian_detectors/readtool.py'
--- tests/lagrangian_detectors/readtool.py 2011-02-16 16:29:58 +0000
+++ tests/lagrangian_detectors/readtool.py 1970-01-01 00:00:00 +0000
@@ -1,20 +0,0 @@
1from fluidity_tools import stat_parser
2from numpy import zeros,fromfile
3def readstat():
4 s = stat_parser("lagrangian_detectors.detectors")
5
6 last_locations_error = zeros((2,100))
7 for i in range(100):
8 n = i + 1
9 padding = ''
10 if(n<100):
11 padding = '0'
12 if(n<10):
13 padding ='00'
14 last_locations_error[0,i] = s['Steve_'+padding+str(n)]['position'][0][-1]
15 last_locations_error[1,i] = s['Steve_'+padding+str(n)]['position'][1][-1]
16 X = fromfile('Xvals.txt',sep=' ')
17 Y = fromfile('Yvals.txt',sep=' ')
18 last_locations_error[0,:] = last_locations_error[0,:] - X
19 last_locations_error[1,:] = last_locations_error[1,:] - Y
20 return last_locations_error
210
=== added directory 'tests/lagrangian_detectors_checkpoint'
=== added file 'tests/lagrangian_detectors_checkpoint/Makefile'
--- tests/lagrangian_detectors_checkpoint/Makefile 1970-01-01 00:00:00 +0000
+++ tests/lagrangian_detectors_checkpoint/Makefile 2014-01-29 10:13:58 +0000
@@ -0,0 +1,9 @@
1input: default
2default: clean
3 gmsh -2 -bin square.geo -o square.msh
4
5clean:
6 rm -rf *.msh *.halo *.vtu *.pvtu *.log* *.err* *.stat blob_[012] *.detectors *.dat *.groups *flredecomp* *checkpoint.flml
7
8logs:
9 ../../bin/fluidity -v3 -l lagrangian_detectors_rk.flml
010
=== added file 'tests/lagrangian_detectors_checkpoint/Xvals.txt'
--- tests/lagrangian_detectors_checkpoint/Xvals.txt 1970-01-01 00:00:00 +0000
+++ tests/lagrangian_detectors_checkpoint/Xvals.txt 2014-01-29 10:13:58 +0000
@@ -0,0 +1,1 @@
10.5 0.499391156266 0.498782312532 0.498173468799 0.497564625065 0.496955781331 0.496346937597 0.495738093863 0.49512925013 0.494520406396 0.493911562662 0.493302718928 0.492693875194 0.492085031461 0.491476187727 0.490867343993 0.490258500259 0.489649656525 0.489040812792 0.488431969058 0.487823125324 0.48721428159 0.486605437856 0.485996594123 0.485387750389 0.484778906655 0.484170062921 0.483561219187 0.482952375453 0.48234353172 0.481734687986 0.481125844252 0.480517000518 0.479908156784 0.479299313051 0.478690469317 0.478081625583 0.477472781849 0.476863938115 0.476255094382 0.475646250648 0.475037406914 0.47442856318 0.473819719446 0.473210875713 0.472602031979 0.471993188245 0.471384344511 0.470775500777 0.470166657044 0.46955781331 0.468948969576 0.468340125842 0.467731282108 0.467122438375 0.466513594641 0.465904750907 0.465295907173 0.464687063439 0.464078219706 0.463469375972 0.462860532238 0.462251688504 0.46164284477 0.461034001037 0.460425157303 0.459816313569 0.459207469835 0.458598626101 0.457989782368 0.457380938634 0.4567720949 0.456163251166 0.455554407432 0.454945563699 0.454336719965 0.453727876231 0.453119032497 0.452510188763 0.45190134503 0.451292501296 0.450683657562 0.450074813828 0.449465970094 0.44885712636 0.448248282627 0.447639438893 0.447030595159 0.446421751425 0.445812907691 0.445204063958 0.444595220224 0.44398637649 0.443377532756 0.442768689022 0.442159845289 0.441551001555 0.440942157821 0.440333314087 0.439724470353
0\ No newline at end of file2\ No newline at end of file
13
=== added file 'tests/lagrangian_detectors_checkpoint/Yvals.txt'
--- tests/lagrangian_detectors_checkpoint/Yvals.txt 1970-01-01 00:00:00 +0000
+++ tests/lagrangian_detectors_checkpoint/Yvals.txt 2014-01-29 10:13:58 +0000
@@ -0,0 +1,1 @@
10.5 0.50242472726 0.50484945452 0.50727418178 0.50969890904 0.5121236363 0.51454836356 0.51697309082 0.51939781808 0.52182254534 0.5242472726 0.52667199986 0.52909672712 0.53152145438 0.53394618164 0.5363709089 0.53879563616 0.54122036342 0.54364509068 0.54606981794 0.5484945452 0.55091927246 0.55334399972 0.55576872698 0.55819345424 0.5606181815 0.56304290876 0.56546763602 0.56789236328 0.57031709054 0.5727418178 0.57516654506 0.57759127232 0.58001599958 0.58244072684 0.5848654541 0.58729018136 0.58971490862 0.59213963588 0.59456436314 0.5969890904 0.59941381766 0.60183854492 0.60426327218 0.60668799944 0.6091127267 0.61153745396 0.61396218122 0.61638690848 0.61881163574 0.621236363 0.62366109026 0.62608581752 0.62851054478 0.63093527204 0.6333599993 0.63578472656 0.63820945382 0.64063418108 0.64305890834 0.6454836356 0.64790836286 0.65033309012 0.65275781738 0.65518254464 0.6576072719 0.66003199916 0.662456726419 0.664881453679 0.667306180939 0.669730908199 0.672155635459 0.674580362719 0.677005089979 0.679429817239 0.681854544499 0.684279271759 0.686703999019 0.689128726279 0.691553453539 0.693978180799 0.696402908059 0.698827635319 0.701252362579 0.703677089839 0.706101817099 0.708526544359 0.710951271619 0.713375998879 0.715800726139 0.718225453399 0.720650180659 0.723074907919 0.725499635179 0.727924362439 0.730349089699 0.732773816959 0.735198544219 0.737623271479 0.740047998739
0\ No newline at end of file2\ No newline at end of file
13
=== added file 'tests/lagrangian_detectors_checkpoint/lagrangian_detectors.flml'
--- tests/lagrangian_detectors_checkpoint/lagrangian_detectors.flml 1970-01-01 00:00:00 +0000
+++ tests/lagrangian_detectors_checkpoint/lagrangian_detectors.flml 2014-01-29 10:13:58 +0000
@@ -0,0 +1,178 @@
1<?xml version='1.0' encoding='utf-8'?>
2<fluidity_options>
3 <simulation_name>
4 <string_value lines="1">lagrangian_detectors</string_value>
5 </simulation_name>
6 <problem_type>
7 <string_value lines="1">fluids</string_value>
8 </problem_type>
9 <geometry>
10 <dimension>
11 <integer_value rank="0">2</integer_value>
12 </dimension>
13 <mesh name="CoordinateMesh">
14 <from_file file_name="square">
15 <format name="gmsh"/>
16 <stat>
17 <include_in_stat/>
18 </stat>
19 </from_file>
20 </mesh>
21 <mesh name="VelocityMesh">
22 <from_mesh>
23 <mesh name="CoordinateMesh"/>
24 <mesh_shape>
25 <polynomial_degree>
26 <integer_value rank="0">1</integer_value>
27 </polynomial_degree>
28 </mesh_shape>
29 <mesh_continuity>
30 <string_value>discontinuous</string_value>
31 </mesh_continuity>
32 <stat>
33 <exclude_from_stat/>
34 </stat>
35 </from_mesh>
36 </mesh>
37 <quadrature>
38 <degree>
39 <integer_value rank="0">3</integer_value>
40 </degree>
41 </quadrature>
42 </geometry>
43 <io>
44 <dump_format>
45 <string_value>vtk</string_value>
46 </dump_format>
47 <dump_period>
48 <constant>
49 <real_value rank="0">4.0</real_value>
50 </constant>
51 </dump_period>
52 <output_mesh name="VelocityMesh"/>
53 <checkpointing>
54 <checkpoint_period_in_dumps>
55 <integer_value rank="0">1</integer_value>
56 </checkpoint_period_in_dumps>
57 </checkpointing>
58 <stat/>
59 <detectors>
60 <detector_array name="Steve">
61 <number_of_detectors>
62 <integer_value rank="0">100</integer_value>
63 </number_of_detectors>
64 <lagrangian/>
65 <python>
66 <string_value lines="20" type="code" language="python">def val(t):
67 from numpy import arange,zeros,reshape,concatenate
68 x = 0.5+0.25*arange(0,100.)/100.
69 y = zeros(100) + 0.5
70 return reshape(concatenate((x,y)),(2,100)).T</string_value>
71 </python>
72 </detector_array>
73 <fail_outside_domain/>
74 <lagrangian_timestepping>
75 <subcycles>
76 <integer_value rank="0">1</integer_value>
77 </subcycles>
78 <search_tolerance>
79 <real_value rank="0">1.0e-10</real_value>
80 </search_tolerance>
81 <explicit_runge_kutta_guided_search>
82 <n_stages>
83 <integer_value rank="0">4</integer_value>
84 </n_stages>
85 <stage_weights>
86 <real_value shape="6" rank="1">0.5 0. 0.5 0. 0. 1</real_value>
87 </stage_weights>
88 <timestep_weights>
89 <real_value shape="4" rank="1">0.16666666666666666 0.3333333333333333
90 0.3333333333333333 0.16666666666666666</real_value>
91 </timestep_weights>
92 </explicit_runge_kutta_guided_search>
93 </lagrangian_timestepping>
94 </detectors>
95 </io>
96 <timestepping>
97 <current_time>
98 <real_value rank="0">0.0</real_value>
99 </current_time>
100 <timestep>
101 <real_value rank="0">0.1</real_value>
102 </timestep>
103 <finish_time>
104 <real_value rank="0">8</real_value>
105 </finish_time>
106 </timestepping>
107 <physical_parameters>
108 <gravity>
109 <magnitude>
110 <real_value rank="0">1</real_value>
111 </magnitude>
112 <vector_field name="GravityDirection" rank="1">
113 <prescribed>
114 <mesh name="CoordinateMesh"/>
115 <value name="WholeMesh">
116 <constant>
117 <real_value shape="2" dim1="dim" rank="1">0.0 -1.0</real_value>
118 </constant>
119 </value>
120 <output/>
121 <stat>
122 <include_in_stat/>
123 </stat>
124 <detectors>
125 <exclude_from_detectors/>
126 </detectors>
127 </prescribed>
128 </vector_field>
129 </gravity>
130 </physical_parameters>
131 <material_phase name="BoussinesqFluid">
132 <vector_field name="Velocity" rank="1">
133 <prescribed>
134 <mesh name="VelocityMesh"/>
135 <value name="WholeMesh">
136 <python>
137 <string_value lines="20" type="code" language="python">def val(X,t):
138 x = X[0]
139 y = X[1]
140 return [-(y-0.5),x-0.5]</string_value>
141 </python>
142 </value>
143 <output/>
144 <stat>
145 <include_in_stat/>
146 </stat>
147 <detectors>
148 <exclude_from_detectors/>
149 </detectors>
150 </prescribed>
151 </vector_field>
152 </material_phase>
153 <mesh_adaptivity>
154 <hr_adaptivity>
155 <period>
156 <real_value rank="0">4.</real_value>
157 </period>
158 <maximum_number_of_nodes>
159 <integer_value rank="0">200</integer_value>
160 </maximum_number_of_nodes>
161 <enable_gradation/>
162 <tensor_field name="MinimumEdgeLengths">
163 <anisotropic_symmetric>
164 <constant>
165 <real_value symmetric="true" dim2="dim" shape="2 2" dim1="dim" rank="2">0.05 0.0 0.0 0.05</real_value>
166 </constant>
167 </anisotropic_symmetric>
168 </tensor_field>
169 <tensor_field name="MaximumEdgeLengths">
170 <anisotropic_symmetric>
171 <constant>
172 <real_value symmetric="true" dim2="dim" shape="2 2" dim1="dim" rank="2">0.06 0.0 0.0 0.06</real_value>
173 </constant>
174 </anisotropic_symmetric>
175 </tensor_field>
176 </hr_adaptivity>
177 </mesh_adaptivity>
178</fluidity_options>
0179
=== added file 'tests/lagrangian_detectors_checkpoint/lagrangian_detectors_checkpoint.xml'
--- tests/lagrangian_detectors_checkpoint/lagrangian_detectors_checkpoint.xml 1970-01-01 00:00:00 +0000
+++ tests/lagrangian_detectors_checkpoint/lagrangian_detectors_checkpoint.xml 2014-01-29 10:13:58 +0000
@@ -0,0 +1,35 @@
1<?xml version="1.0" encoding="UTF-8" ?>
2
3<testproblem>
4 <name>lagrangian_detectors_checkpoint</name>
5 <owner userid="mlange"/>
6 <tags>flml detectors checkpoint</tags>
7 <problem_definition length="short" nprocs="4">
8 <command_line>
9../../bin/fluidity -v2 -l lagrangian_detectors.flml;
10../../bin/fluidity -v2 -l lagrangian_detectors_1_checkpoint.flml
11 </command_line>
12 </problem_definition>
13 <variables>
14 <variable name="last_locations_error" language="python">
15from fluidity_tools import stat_parser
16from numpy import zeros,fromfile
17
18s = stat_parser('lagrangian_detectors_checkpoint.detectors')
19last_locations_error = zeros((2,100))
20X = fromfile('Xvals.txt',sep=' ')
21Y = fromfile('Yvals.txt',sep=' ')
22for i in range(100):
23 name = 'Steve_' + str(i+1).zfill(3)
24 last_locations_error[0,i] = s[name]['position'][0][-1] - X[i]
25 last_locations_error[1,i] = s[name]['position'][1][-1] - Y[i]
26 </variable>
27 </variables>
28 <pass_tests>
29 <test name="CorrectLagrangianTrajectory" language="python">
30assert abs(last_locations_error).max() &lt; 1.0e-6
31 </test>
32 </pass_tests>
33 <warn_tests>
34 </warn_tests>
35</testproblem>
036
=== added file 'tests/lagrangian_detectors_checkpoint/square.geo'
--- tests/lagrangian_detectors_checkpoint/square.geo 1970-01-01 00:00:00 +0000
+++ tests/lagrangian_detectors_checkpoint/square.geo 2014-01-29 10:13:58 +0000
@@ -0,0 +1,13 @@
1Point(1) = {0,0,0,0.03};
2Extrude {1,0,0} {
3 Point{1};
4}
5Extrude {0,1,0} {
6 Line{1};
7}
8Physical Line(8) = {2};
9Physical Line(9) = {4};
10Physical Line(10) = {3};
11Physical Line(11) = {1};
12Physical Surface(7) = {5};
13