Changeset 25836 for issm/trunk/src/m/partition/AreaAverageOntoPartition.py
- Timestamp:
- 12/08/20 08:45:53 (4 years ago)
- Location:
- issm/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk
- Property svn:mergeinfo changed
-
issm/trunk/src
- Property svn:mergeinfo changed
-
issm/trunk/src/m/partition/AreaAverageOntoPartition.py
r24313 r25836 1 import copy 2 1 3 import numpy as np 2 import copy 4 3 5 from adjacency import adjacency 4 6 from project2d import project2d 7 from qmupart2npart import qmupart2npart 5 8 6 9 7 def AreaAverageOntoPartition(md, vector, layer=None):8 ''' AREAAVERAGEONTOPARTITION9 compute partition values for a certain vector expressed on the vertices of the mesh.10 Use area weighted average.10 def AreaAverageOntoPartition(md, vector, partition, layer=None): 11 ''' 12 AREAAVERAGEONTOPARTITION - compute partition values for a certain vector expressed on the vertices of the mesh. 13 Use area weighted average. 11 14 12 Usage: 13 average = AreaAverageOntoPartition(md, vector) 14 average = AreaAverageOntoPartition(md, vector, layer) #if in 3D, chose which layer is partitioned 15 ''' 15 Usage: 16 average = AreaAverageOntoPartition(md, vector) 17 average = AreaAverageOntoPartition(md, vector, layer) # If in 3D, chose which layer is partitioned 18 ''' 19 16 20 #some checks 17 21 if(md.mesh.dimension() == 3): … … 19 23 raise RuntimeError('AreaAverageOntoPartition: layer should be provided onto which Area Averaging occurs') 20 24 21 #save 3D model25 #save 3D model 22 26 md3d = copy.deepcopy(md) 23 27 … … 30 34 md.mesh.vertexconnectivity = [] 31 35 32 #run connectivity routine36 #run connectivity routine 33 37 md = adjacency(md) 34 38 35 39 #finally, project vector: 36 40 vector = project2d(md3d, vector, layer) 37 md.qmu.vpartition = project2d(md3d, md3d.qmu.vpartition, layer)41 partition = project2d(md3d, partition, layer) 38 42 39 43 #ok, first check that part is Matlab indexed 40 part = (md.qmu.vpartition).copy()44 part = partition.copy() 41 45 part = part.flatten() + 1 42 46 43 47 #some check: 44 if md.qmu.numberofpartitions != max(part): 45 raise RuntimeError('AreaAverageOntoPartition error message: ''npart'' should be equal to max(md.qmu.vpartition)') 48 npart = qmupart2npart(partition) 49 if npart != max(part): 50 raise RuntimeError('AreaAverageOntoPartition error message: ''npart'' should be equal to max(partition)') 46 51 47 52 #initialize output
Note:
See TracChangeset
for help on using the changeset viewer.