Changeset 23431
- Timestamp:
- 10/17/18 03:28:24 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified issm/trunk-jpl/src/m/classes/model.py ¶
r23095 r23431 16 16 from basalforcings import basalforcings 17 17 from matice import matice 18 from levelset import levelset 18 from levelset import levelset 19 19 from calving import calving 20 20 from fourierlove import fourierlove … … 75 75 76 76 # classtype=model.properties 77 77 78 78 # for classe in dict.keys(classtype): 79 79 # print classe … … 225 225 This routine extracts a submodel from a bigger model with respect to a given contour 226 226 md must be followed by the corresponding exp file or flags list 227 It can either be a domain file (argus type, .exp extension), or an array of element flags. 228 If user wants every element outside the domain to be 227 It can either be a domain file (argus type, .exp extension), or an array of element flags. 228 If user wants every element outside the domain to be 229 229 extract2d, add '~' to the name of the domain file (ex: '~HO.exp') 230 230 an empty string '' will be considered as an empty domain … … 349 349 md2.mesh.lowerelements[pos]=Pelem[md2.mesh.lowerelements[pos].astype(int)-1] 350 350 351 #Initial 2d mesh 351 #Initial 2d mesh 352 352 if md1.mesh.__class__.__name__=='mesh3dprisms': 353 353 flag_elem_2d=flag_elem[np.arange(0,md1.mesh.numberofelements2d)] … … 431 431 if np.size(md1.stressbalance.spcvx)>1 and np.size(md1.stressbalance.spcvy)>2 and np.size(md1.stressbalance.spcvz)>2: 432 432 if np.size(md1.inversion.vx_obs)>1 and np.size(md1.inversion.vy_obs)>1: 433 md2.stressbalance.spcvx[nodestoflag2]=md2.inversion.vx_obs[nodestoflag2] 433 md2.stressbalance.spcvx[nodestoflag2]=md2.inversion.vx_obs[nodestoflag2] 434 434 md2.stressbalance.spcvy[nodestoflag2]=md2.inversion.vy_obs[nodestoflag2] 435 435 else: … … 508 508 - follow two polynomial laws, one for the lower part and one for the upper part of the mesh 509 509 - be discribed by a list of coefficients (between 0 and 1) 510 510 511 511 512 512 Usage: … … 596 596 number_nodes3d=np.size(x3d) #number of 3d nodes for the non extruded part of the mesh 597 597 598 #Extrude elements 598 #Extrude elements 599 599 elements3d=np.empty((0,6),int) 600 600 for i in xrange(numlayers-1): … … 618 618 md.mesh.upperelements=upperelements 619 619 620 #Save old mesh 620 #Save old mesh 621 621 md.mesh.x2d=md.mesh.x 622 622 md.mesh.y2d=md.mesh.y … … 625 625 md.mesh.numberofvertices2d=md.mesh.numberofvertices 626 626 627 #Build global 3d mesh 627 #Build global 3d mesh 628 628 md.mesh.elements=elements3d 629 629 md.mesh.x=x3d … … 672 672 673 673 md.materials.extrude(md) 674 md.damage.extrude(md) 674 if md.damage.isdamage==1: 675 md.damage.extrude(md) 675 676 md.gia.extrude(md) 676 677 md.mask.extrude(md) … … 688 689 ''' 689 690 collapses a 3d mesh into a 2d mesh 690 691 691 692 This routine collapses a 3d model into a 2d model and collapses all 692 693 the fileds of the 3d model by taking their depth-averaged values 693 694 694 695 Usage: 695 696 md=collapse(md) 696 ''' 697 ''' 697 698 698 699 #Check that the model is really a 3d model 699 700 if md.mesh.domaintype().lower() != '3d': 700 701 raise StandardError("only a 3D model can be collapsed") 701 702 702 703 #dealing with the friction law 703 704 #drag is limited to nodes that are on the bedrock. 704 if hasattr(md.friction,'coefficient'): 705 if hasattr(md.friction,'coefficient'): 705 706 md.friction.coefficient=project2d(md,md.friction.coefficient,1) 706 707 707 708 #p and q (same deal, except for element that are on the bedrock: ) 708 if hasattr(md.friction,'p'): 709 if hasattr(md.friction,'p'): 709 710 md.friction.p=project2d(md,md.friction.p,1) 710 if hasattr(md.friction,'q'): 711 if hasattr(md.friction,'q'): 711 712 md.friction.q=project2d(md,md.friction.q,1) 712 713 if hasattr(md.friction,'coefficientcoulomb'): 713 714 if hasattr(md.friction,'coefficientcoulomb'): 714 715 md.friction.coefficientcoulomb=project2d(md,md.friction.coefficientcoulomb,1) 715 if hasattr(md.friction,'C'): 716 if hasattr(md.friction,'C'): 716 717 md.friction.C=project2d(md,md.friction.C,1) 717 if hasattr(md.friction,'As'): 718 if hasattr(md.friction,'As'): 718 719 md.friction.As=project2d(md,md.friction.As,1) 719 720 if hasattr(md.friction,'effective_pressure') and not np.isnan(md.friction.effective_pressure).all(): 720 721 md.friction.effective_pressure=project2d(md,md.friction.effective_pressure,1) 721 if hasattr(md.friction,'water_layer'): 722 if hasattr(md.friction,'water_layer'): 722 723 md.friction.water_layer=project2d(md,md.friction.water_layer,1) 723 if hasattr(md.friction,'m'): 724 if hasattr(md.friction,'m'): 724 725 md.friction.m=project2d(md,md.friction.m,1) 725 726 726 727 #observations 727 if not np.isnan(md.inversion.vx_obs).all(): 728 md.inversion.vx_obs=project2d(md,md.inversion.vx_obs,md.mesh.numberoflayers) 729 if not np.isnan(md.inversion.vy_obs).all(): 730 md.inversion.vy_obs=project2d(md,md.inversion.vy_obs,md.mesh.numberoflayers) 731 if not np.isnan(md.inversion.vel_obs).all(): 732 md.inversion.vel_obs=project2d(md,md.inversion.vel_obs,md.mesh.numberoflayers) 733 if not np.isnan(md.inversion.cost_functions_coefficients).all(): 734 md.inversion.cost_functions_coefficients=project2d(md,md.inversion.cost_functions_coefficients,md.mesh.numberoflayers) 728 if not np.isnan(md.inversion.vx_obs).all(): 729 md.inversion.vx_obs=project2d(md,md.inversion.vx_obs,md.mesh.numberoflayers) 730 if not np.isnan(md.inversion.vy_obs).all(): 731 md.inversion.vy_obs=project2d(md,md.inversion.vy_obs,md.mesh.numberoflayers) 732 if not np.isnan(md.inversion.vel_obs).all(): 733 md.inversion.vel_obs=project2d(md,md.inversion.vel_obs,md.mesh.numberoflayers) 734 if not np.isnan(md.inversion.cost_functions_coefficients).all(): 735 md.inversion.cost_functions_coefficients=project2d(md,md.inversion.cost_functions_coefficients,md.mesh.numberoflayers) 735 736 if isinstance(md.inversion.min_parameters,np.ndarray): 736 if md.inversion.min_parameters.size>1: 737 md.inversion.min_parameters=project2d(md,md.inversion.min_parameters,md.mesh.numberoflayers) 737 if md.inversion.min_parameters.size>1: 738 md.inversion.min_parameters=project2d(md,md.inversion.min_parameters,md.mesh.numberoflayers) 738 739 if isinstance(md.inversion.max_parameters,np.ndarray): 739 if md.inversion.max_parameters.size>1: 740 md.inversion.max_parameters=project2d(md,md.inversion.max_parameters,md.mesh.numberoflayers) 740 if md.inversion.max_parameters.size>1: 741 md.inversion.max_parameters=project2d(md,md.inversion.max_parameters,md.mesh.numberoflayers) 741 742 if not np.isnan(md.smb.mass_balance).all(): 742 md.smb.mass_balance=project2d(md,md.smb.mass_balance,md.mesh.numberoflayers) 743 743 md.smb.mass_balance=project2d(md,md.smb.mass_balance,md.mesh.numberoflayers) 744 744 745 #results 745 if not np.isnan(md.initialization.vx).all(): 746 if not np.isnan(md.initialization.vx).all(): 746 747 md.initialization.vx=DepthAverage(md,md.initialization.vx) 747 if not np.isnan(md.initialization.vy).all(): 748 if not np.isnan(md.initialization.vy).all(): 748 749 md.initialization.vy=DepthAverage(md,md.initialization.vy) 749 if not np.isnan(md.initialization.vz).all(): 750 if not np.isnan(md.initialization.vz).all(): 750 751 md.initialization.vz=DepthAverage(md,md.initialization.vz) 751 if not np.isnan(md.initialization.vel).all(): 752 if not np.isnan(md.initialization.vel).all(): 752 753 md.initialization.vel=DepthAverage(md,md.initialization.vel) 753 if not np.isnan(md.initialization.temperature).all(): 754 if not np.isnan(md.initialization.temperature).all(): 754 755 md.initialization.temperature=DepthAverage(md,md.initialization.temperature) 755 if not np.isnan(md.initialization.pressure).all(): 756 if not np.isnan(md.initialization.pressure).all(): 756 757 md.initialization.pressure=project2d(md,md.initialization.pressure,1) 757 if not np.isnan(md.initialization.sediment_head).all(): 758 if not np.isnan(md.initialization.sediment_head).all(): 758 759 md.initialization.sediment_head=project2d(md,md.initialization.sediment_head,1) 759 if not np.isnan(md.initialization.epl_head).all(): 760 if not np.isnan(md.initialization.epl_head).all(): 760 761 md.initialization.epl_head=project2d(md,md.initialization.epl_head,1) 761 if not np.isnan(md.initialization.epl_thickness).all(): 762 if not np.isnan(md.initialization.epl_thickness).all(): 762 763 md.initialization.epl_thickness=project2d(md,md.initialization.epl_thickness,1) 763 764 764 765 #giaivins 765 if not np.isnan(md.gia.mantle_viscosity).all(): 766 md.gia.mantle_viscosity=project2d(md,md.gia.mantle_viscosity,1) 767 if not np.isnan(md.gia.lithosphere_thickness).all(): 768 md.gia.lithosphere_thickness=project2d(md,md.gia.lithosphere_thickness,1) 766 if not np.isnan(md.gia.mantle_viscosity).all(): 767 md.gia.mantle_viscosity=project2d(md,md.gia.mantle_viscosity,1) 768 if not np.isnan(md.gia.lithosphere_thickness).all(): 769 md.gia.lithosphere_thickness=project2d(md,md.gia.lithosphere_thickness,1) 769 770 770 771 #elementstype … … 777 778 778 779 # Hydrologydc variables 779 if hasattr(md.hydrology,'hydrologydc'):780 if type(md.hydrology is 'hydrologydc'): 780 781 md.hydrology.spcsediment_head=project2d(md,md.hydrology.spcsediment_head,1) 781 md.hydrology.mask_eplactive_node=project2d(md,md.hydrology.mask_eplactive_node,1)782 782 md.hydrology.sediment_transmitivity=project2d(md,md.hydrology.sediment_transmitivity,1) 783 783 md.hydrology.basal_moulin_input=project2d(md,md.hydrology.basal_moulin_input,1) 784 md.hydrology.mask_thawed_node=project2d(md,md.hydrology.mask_thawed_node,1) 784 785 if md.hydrology.isefficientlayer == 1: 786 md.hydrology.mask_eplactive_node=project2d(md,md.hydrology.mask_eplactive_node,1) 785 787 md.hydrology.spcepl_head=project2d(md,md.hydrology.spcepl_head,1) 786 788 … … 793 795 md.masstransport.spcthickness=project2d(md,md.masstransport.spcthickness,md.mesh.numberoflayers) 794 796 md.thermal.spctemperature=project2d(md,md.thermal.spctemperature,md.mesh.numberoflayers-1) 795 if not np.isnan(md.damage.spcdamage).all(): 797 if not np.isnan(md.damage.spcdamage).all(): 796 798 md.damage.spcdamage=project2d(md,md.damage.spcdamage,md.mesh.numberoflayers-1) 797 799 … … 799 801 md.materials.rheology_B=DepthAverage(md,md.materials.rheology_B) 800 802 md.materials.rheology_n=project2d(md,md.materials.rheology_n,1) 801 802 #damage: 803 804 #damage: 803 805 if md.damage.isdamage: 804 806 md.damage.D=DepthAverage(md,md.damage.D) 805 807 806 808 #special for thermal modeling: 807 md.basalforcings.groundedice_melting_rate=project2d(md,md.basalforcings.groundedice_melting_rate,1) 808 md.basalforcings.floatingice_melting_rate=project2d(md,md.basalforcings.floatingice_melting_rate,1) 809 md.basalforcings.groundedice_melting_rate=project2d(md,md.basalforcings.groundedice_melting_rate,1) 810 md.basalforcings.floatingice_melting_rate=project2d(md,md.basalforcings.floatingice_melting_rate,1) 809 811 md.basalforcings.geothermalflux=project2d(md,md.basalforcings.geothermalflux,1) #bedrock only gets geothermal flux 810 812 … … 848 850 mesh.numberofelements=md.mesh.numberofelements2d 849 851 mesh.elements=md.mesh.elements2d 850 if not np.isnan(md.mesh.vertexonboundary).all(): 852 if not np.isnan(md.mesh.vertexonboundary).all(): 851 853 mesh.vertexonboundary=project2d(md,md.mesh.vertexonboundary,1) 852 if not np.isnan(md.mesh.elementconnectivity).all(): 854 if not np.isnan(md.mesh.elementconnectivity).all(): 853 855 mesh.elementconnectivity=project2d(md,md.mesh.elementconnectivity,1) 854 856 if isinstance(md.mesh.lat,np.ndarray): 855 if md.mesh.lat.size==md.mesh.numberofvertices: 856 mesh.lat=project2d(md,md.mesh.lat,1) 857 if md.mesh.lat.size==md.mesh.numberofvertices: 858 mesh.lat=project2d(md,md.mesh.lat,1) 857 859 if isinstance(md.mesh.long,np.ndarray): 858 if md.mesh.long.size==md.mesh.numberofvertices: 859 md.mesh.long=project2d(md,md.mesh.long,1) 860 if md.mesh.long.size==md.mesh.numberofvertices: 861 md.mesh.long=project2d(md,md.mesh.long,1) 860 862 mesh.epsg=md.mesh.epsg 861 863 if isinstance(md.mesh.scale_factor,np.ndarray): 862 if md.mesh.scale_factor.size==md.mesh.numberofvertices: 863 md.mesh.scale_factor=project2d(md,md.mesh.scale_factor,1) 864 if md.mesh.scale_factor.size==md.mesh.numberofvertices: 865 md.mesh.scale_factor=project2d(md,md.mesh.scale_factor,1) 864 866 md.mesh=mesh 865 867 md.mesh.vertexconnectivity=NodeConnectivity(md.mesh.elements,md.mesh.numberofvertices)[0]
Note:
See TracChangeset
for help on using the changeset viewer.