Changeset 9621
- Timestamp:
- Feb 6, 2015, 9:49:16 AM (9 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/anuga/__init__.py
r9590 r9621 261 261 from anuga.parallel.parallel_operator_factory import Boyd_pipe_operator 262 262 from anuga.parallel.parallel_operator_factory import Weir_orifice_trapezoid_operator 263 from anuga.parallel.parallel_operator_factory import Internal_boundary_operator 263 264 else: 264 265 from anuga.structures.inlet_operator import Inlet_operator … … 266 267 from anuga.structures.boyd_pipe_operator import Boyd_pipe_operator 267 268 from anuga.structures.weir_orifice_trapezoid_operator import Weir_orifice_trapezoid_operator 269 from anuga.structures.internal_boundary_operator import Internal_boundary_operator 268 270 269 271 -
trunk/anuga_core/anuga/parallel/parallel_operator_factory.py
r9500 r9621 18 18 from parallel_boyd_pipe_operator import Parallel_Boyd_pipe_operator 19 19 from parallel_weir_orifice_trapezoid_operator import Parallel_Weir_orifice_trapezoid_operator#added by PM 22/10/2013 20 from parallel_internal_boundary_operator import Parallel_Internal_boundary_operator 20 21 21 22 from . import distribute, myid, numprocs, finalize … … 25 26 import anuga.structures.boyd_pipe_operator 26 27 import anuga.structures.inlet_operator 28 import anuga.structures.internal_boundary_operator 27 29 28 30 import anuga.structures.weir_orifice_trapezoid_operator #added by PM 22/10/2013 … … 603 605 604 606 607 """ 608 Factory method for Parallel Internal_boundary_operator. All parameters are the same 609 as normal Internal_boundary_operator. master_proc coordinates the allocation process, 610 procs contains the potential list of processors to allocate the inlet to. 611 612 Returns None for calling processors not associated with structure. Otherwise 613 return an instance of Parallel Internal_boundary_operator 614 """ 615 616 def Internal_boundary_operator(domain, 617 internal_boundary_function, 618 width=0., 619 height=0., 620 end_points=None, 621 exchange_lines=None, 622 enquiry_points=None, 623 invert_elevation=None, 624 apron=0.0, 625 enquiry_gap=0.0, 626 use_velocity_head=False, 627 zero_outflow_momentum=False, 628 smoothing_timescale=0.0, 629 description=None, 630 label=None, 631 structure_type='internal_boundary', 632 logging=False, 633 verbose=False, 634 master_proc = 0, 635 procs = None, 636 inlet_master_proc = [0,0], 637 inlet_procs = None, 638 enquiry_proc = [0,0]): 639 640 # If not parallel domain then allocate serial Internal boundary operator 641 if isinstance(domain, Parallel_domain) is False: 642 if verbose: print "Allocating non parallel internal_boundary operator ....." 643 return anuga.structures.internal_boundary_operator.Internal_boundary_operator(domain=domain, 644 internal_boundary_function=internal_boundary_function, 645 width=width, 646 height=height, 647 end_points=end_points, 648 exchange_lines=exchange_lines, 649 enquiry_points=enquiry_points, 650 invert_elevation=invert_elevation, 651 apron=apron, 652 enquiry_gap=enquiry_gap, 653 use_velocity_head=use_velocity_head, 654 zero_outflow_momentum=zero_outflow_momentum, 655 smoothing_timescale=smoothing_timescale, 656 description=description, 657 label=label, 658 structure_type=structure_type, 659 logging=logging, 660 verbose=verbose) 661 662 import pypar 663 if procs is None: 664 procs = range(0,pypar.size()) 665 666 myid = pypar.rank() 667 668 end_points = ensure_numeric(end_points) 669 exchange_lines = ensure_numeric(exchange_lines) 670 enquiry_points = ensure_numeric(enquiry_points) 671 672 if height is None: 673 height = width 674 675 diameter = None 676 677 if apron is None: 678 apron = width 679 680 681 # Calculate location of inlet enquiry points and exchange lines 682 if myid == master_proc: 683 if exchange_lines is not None: 684 exchange_lines_tmp = exchange_lines 685 enquiry_points_tmp = __process_skew_culvert(exchange_lines, end_points, enquiry_points, apron, enquiry_gap) 686 687 for i in procs: 688 if i == master_proc: continue 689 pypar.send(enquiry_points_tmp, i) 690 691 elif end_points is not None: 692 exchange_lines_tmp, enquiry_points_tmp = __process_non_skew_culvert(end_points, width, 693 enquiry_points, apron, enquiry_gap) 694 for i in procs: 695 if i == master_proc: continue 696 pypar.send(exchange_lines_tmp, i) 697 pypar.send(enquiry_points_tmp, i) 698 else: 699 raise Exception, 'Define either exchange_lines or end_points' 700 701 else: 702 if exchange_lines is not None: 703 exchange_lines_tmp = exchange_lines 704 enquiry_points_tmp = pypar.receive(master_proc) 705 elif end_points is not None: 706 exchange_lines_tmp = pypar.receive(master_proc) 707 enquiry_points_tmp = pypar.receive(master_proc) 708 709 # Determine processors associated with first inlet 710 line0 = exchange_lines_tmp[0] 711 enquiry_point0 = enquiry_points_tmp[0] 712 713 alloc0, inlet0_master_proc, inlet0_procs, enquiry0_proc = allocate_inlet_procs(domain, line0, enquiry_point = enquiry_point0, 714 master_proc = master_proc, 715 procs = procs, verbose=verbose) 716 717 # Determine processors associated with second inlet 718 line1 = exchange_lines_tmp[1] 719 enquiry_point1 = enquiry_points_tmp[1] 720 721 alloc1, inlet1_master_proc, inlet1_procs, enquiry1_proc = allocate_inlet_procs(domain, line1, enquiry_point = enquiry_point1, 722 master_proc = master_proc, 723 procs = procs, verbose=verbose) 724 725 structure_procs = list(set(inlet0_procs + inlet1_procs)) 726 inlet_master_proc = [inlet0_master_proc, inlet1_master_proc] 727 inlet_procs = [inlet0_procs, inlet1_procs] 728 enquiry_proc = [enquiry0_proc, enquiry1_proc] 729 730 if myid == master_proc and verbose: 731 print "Parallel Internal boundary Operator =============================" 732 print "Structure Master Proc is P" + str(inlet0_master_proc) 733 print "Structure Procs are P" + str(structure_procs) 734 print "Inlet Master Procs are P" + str(inlet_master_proc) 735 print "Inlet Procs are P" + str(inlet_procs[0]) + " and " + str(inlet_procs[1]) 736 print "Inlet Enquiry Procs are P" + str(enquiry_proc) 737 print "Enquiry Points are " + str(enquiry_point0) + " and " + str(enquiry_point1) 738 print "Inlet Exchange Lines are " + str(line0) + " and " + str(line1) 739 print "========================================================" 740 741 if alloc0 or alloc1: 742 return Parallel_Internal_boundary_operator(domain=domain, 743 internal_boundary_function=internal_boundary_function, 744 width=width, 745 height=height, 746 end_points=end_points, 747 exchange_lines=exchange_lines, 748 enquiry_points=enquiry_points, 749 invert_elevation=invert_elevation, 750 apron=apron, 751 enquiry_gap=enquiry_gap, 752 use_velocity_head=use_velocity_head, 753 zero_outflow_momentum=zero_outflow_momentum, 754 smoothing_timescale=smoothing_timescale, 755 description=description, 756 label=label, 757 structure_type=structure_type, 758 logging=logging, 759 verbose=verbose, 760 master_proc = inlet0_master_proc, 761 procs = structure_procs, 762 inlet_master_proc = inlet_master_proc, 763 inlet_procs = inlet_procs, 764 enquiry_proc = enquiry_proc) 765 else: 766 return None 767 605 768 606 769 -
trunk/anuga_work/development/gareth/tests/ras_bridge/channel_floodplain1.py
r9618 r9621 12 12 import numpy 13 13 #from anuga_parallel.parallel_operator_factory import Inlet_operator, Boyd_box_operator 14 from anuga.parallel.parallel_operator_factory import Inlet_operator, Boyd_box_operator 14 #from anuga.parallel.parallel_operator_factory import Inlet_operator, Boyd_box_operator, Internal_boundary_operator 15 from anuga.parallel.parallel_operator_factory import Inlet_operator, Boyd_box_operator, Internal_boundary_operator 15 16 from anuga.parallel import distribute, myid, numprocs, finalize, barrier 16 frominternal_boundary_operator import Internal_boundary_operator17 from internal_boundary_functions import hecras_internal_boundary_function17 #from anuga.structures.internal_boundary_operator import Internal_boundary_operator 18 from anuga.structures.internal_boundary_functions import hecras_internal_boundary_function 18 19 19 20 #------------------------------------------------------------------------------ … … 185 186 allow_sign_reversal=True) 186 187 187 bridge = Internal_boundary_operator(188 domain,189 hecras_discharge_function,190 width=chan_width,191 height=1.3,192 end_points=None,193 exchange_lines=[bridge_in, bridge_out],194 invert_elevation=-3.5,195 enquiry_gap=0.01,196 use_velocity_head=False,197 smoothing_timescale=30.0,198 logging=True)188 #bridge = Internal_boundary_operator( 189 # domain, 190 # hecras_discharge_function, 191 # width=chan_width, 192 # height=1.3, 193 # end_points=None, 194 # exchange_lines=[bridge_in, bridge_out], 195 # invert_elevation=-3.5, 196 # enquiry_gap=0.01, 197 # use_velocity_head=False, 198 # smoothing_timescale=30.0, 199 # logging=True) 199 200 200 201 #------------------------------------------------------------------------------
Note: See TracChangeset
for help on using the changeset viewer.