Changeset 25015
- Timestamp:
- 06/11/20 14:59:11 (5 years ago)
- Location:
- issm/trunk-jpl
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/m/classes/qmu.py
r25011 r25015 158 158 fv = fieldnames(self.variables) 159 159 for i in range(len(fv)): 160 getattr(self.variables, fv[i]).checkconsistency(md, solution, analyses) 160 variable = getattr(self.variables, fv[i]) 161 if hasattr(variable, 'checkconsistency'): 162 variable.checkconsistency(md, solution, analyses) 161 163 162 164 return md -
issm/trunk-jpl/src/m/partition/partitioner.py
r25014 r25015 16 16 List of options to partitioner: 17 17 18 package: 'chaco', 'metis' 19 npart: number of partitions .18 package: 'chaco', 'metis', or 'scotch' 19 npart: number of partitions 20 20 weighting: 'on' or 'off': default off 21 section: 1 by defaults(1 = bisection, 2 = quadrisection, 3 =octasection)22 recomputeadjacency: 21 section: 1 by defaults(1=bisection, 2=quadrisection, 3=octasection) 22 recomputeadjacency: 'on' by default (set to 'off' to compute existing one) 23 23 type: 'node' or 'element' partition vector (default to 'node') 24 24 Output: partitionvector: the partition vector … … 39 39 vectortype = options.getfieldvalue('type', 'node') #default to node 40 40 41 # Python only: short-circuit 41 42 if vectortype == 'element' and not package == 'linear': 42 raise RuntimeError('partitioner error message: package ' + str(package) + ' does not allow element partitions.')43 raise RuntimeError('partitioner error message: package %s does not allow element partitions.' % package) 43 44 44 45 if(md.mesh.dimension() == 3): … … 62 63 63 64 if package == 'chaco': 64 #raise RuntimeError('Chaco is not currently supported for this function')65 # default method (from chaco.m)66 method = np.array([1, 1, 0, 0, 1, 1, 50, 0, 0.001, 7654321])67 method[0] = 3 # global method (3 = inertial (geometric))68 method[2] = 0 # vertex weights (0 = off, 1 = on)69 #specify bisection70 method[5] = section # ndims (1 = bisection, 2 = quadrisection, 3 = octasection)65 if vectortype == 'element': 66 raise RuntimeError('partitioner error message: package %s does not allow element partitions.' % package) 67 else: 68 # default method (from chaco.m) 69 method = np.array([1, 1, 0, 0, 1, 1, 50, 0, 0.001, 7654321]) 70 method[0] = 3 # global method (3 = inertial (geometric)) 71 method[2] = 0 # vertex weights (0 = off, 1 = on) 71 72 72 #are we using weights? 73 if weighting == 'on': 74 weights = np.floor(md.qmu.vertex_weight / min(md.qmu.vertex_weight)) 75 method[2] = 1 76 else: 77 weights = [] 73 #specify bisection 74 method[5] = section # ndims (1 = bisection, 2 = quadrisection, 3 = octasection) 78 75 79 method = method.reshape(-1, 1) # transpose to 1x10 instead of 10 80 # partition into nparts 81 if isinstance(md.mesh, mesh2d): 82 part = np.array(Chaco(md.qmu.adjacency, weights, np.array([]), md.mesh.x, md.mesh.y, np.zeros((md.mesh.numberofvertices, )), method, npart, np.array([]))).T + 1 #index partitions from 1 up. like metis. 83 else: 84 part = np.array(Chaco(md.qmu.adjacency, weights, np.array([]), md.mesh.x, md.mesh.y, md.mesh.z, method, npart, np.array([]))).T + 1 #index partitions from 1 up. like metis. 76 #are we using weights? 77 if weighting == 'on': 78 weights = np.floor(md.qmu.vertex_weight / min(md.qmu.vertex_weight)) 79 method[2] = 1 80 else: 81 weights = [] 82 83 method = method.reshape(-1, 1) # transpose to 1x10 instead of 10 84 85 # partition into nparts 86 if isinstance(md.mesh, mesh2d): 87 part = np.array(Chaco(md.qmu.adjacency, weights, np.array([]), md.mesh.x, md.mesh.y, np.zeros((md.mesh.numberofvertices, )), method, npart, np.array([]))).T + 1 #index partitions from 1 up. like metis. 88 else: 89 part = np.array(Chaco(md.qmu.adjacency, weights, np.array([]), md.mesh.x, md.mesh.y, md.mesh.z, method, npart, np.array([]))).T + 1 #index partitions from 1 up. like metis. 85 90 86 91 elif package == 'scotch': 87 raise RuntimeError('Scotch is not currently supported for this function') 92 if vectortype == 'element': 93 raise RuntimeError('partitioner error message: package %s does not allow element partitions.' % package) 94 else: 95 #are we using weights? 96 if m.strcmpi(options.getfieldvalue('weighting'), 'on'): 97 weights = np.floor(md.qmu.vertex_weight / min(md.qmu.vertex_weight)) 98 else: 99 weights = [] 100 maptab = Scotch(md.qmu.adjacency, [], weights, [], 'cmplt', [npart]) 88 101 89 #are we using weights? 90 #if m.strcmpi(options.getfieldvalue('weighting'), 'on'): 91 #weights = np.floor(md.qmu.vertex_weight / min(md.qmu.vertex_weight)) 92 #else: 93 #weights = [] 94 #maptab = Scotch(md.qmu.adjacency, [], weights, [], 'cmplt', [npart]) 95 #part = maptab[:, 1] + 1 #index partitions from 1 up. like metis. 102 part = maptab[:, 1] + 1 #index partitions from 1 up. like metis. 96 103 97 104 elif package == 'linear': 98 99 if (npart == md.mesh.numberofelements) or (md.qmu.numberofpartitions == md.mesh.numberofelements): 105 if vectortype == 'element': 100 106 part = np.arange(1, 1 + md.mesh.numberofelements, 1) 101 107 print('Linear partitioner requesting partitions on elements') … … 104 110 105 111 elif package == 'metis': 106 raise RuntimeError('Metis/MeshPartition is not currently supported for this function') 107 #[element_partitioning, part] = MeshPartition(md, md.qmu.numberofpartitions) 112 if vectortype == 'element': 113 raise RuntimeError('partitioner error message: package %s does not allow element partitions.' % package) 114 else: 115 [element_partitioning, part] = MeshPartition(md, md.qmu.numberofpartitions) 108 116 109 117 else: 110 print(help) 111 raise RuntimeError('partitioner error message: could not find ' + str(package) + ' partitioner') 118 raise RuntimeError('partitioner error message: could not find %s partitioner' % package) 112 119 113 120 #extrude if we are in 3D: -
issm/trunk-jpl/src/m/qmu/importancefactors.py
r24873 r25015 1 1 import numpy as np 2 2 3 from MatlabFuncs import * 3 4 4 5 5 def importancefactors(md, variablename, responsename): 6 '''IMPORTANCEFACTORS - compute importance factors for a certain variable and response. 6 def importancefactors(md, variablename, responsename, partition): 7 ''' 8 IMPORTANCEFACTORS - compute importance factors for a certain variable and response. 7 9 8 Usage:9 factors = importancefactors(md, variablename, responsename)10 Usage: 11 factors = importancefactors(md, variablename, responsename) 10 12 11 13 Example: factors = importancefactors(md, 'drag', 'max_vel') 12 '''14 ''' 13 15 14 16 variablenamelength = len(variablename) … … 44 46 factors = importancefactors 45 47 return factors 46 elif count == np.max( md.qmu.epartition + 1):48 elif count == np.max(partition + 1): 47 49 #distribute importance factor 48 factors = importancefactors[( md.qmu.epartition.conj().T).flatten().astype(int)]50 factors = importancefactors[(partition.conj().T).flatten().astype(int)] 49 51 #md.qmu.partition was created to index "c" style 50 52 else: 51 53 #distribute importance factor 52 factors = importancefactors[( md.qmu.vpartition.conj().T).flatten().astype(int)]54 factors = importancefactors[(partition.conj().T).flatten().astype(int)] 53 55 #md.qmu.partition was created to index "c" style 54 56 -
issm/trunk-jpl/src/m/qmu/preqmu.m
r24998 r25015 88 88 89 89 %build a MatArray of variable partitions: 90 variable_fieldnames=fieldnames(md.qmu.variables(ivar));91 90 variablepartitions={}; 92 91 variablepartitions_npart=[]; 92 variable_fieldnames=fieldnames(md.qmu.variables(ivar)); 93 93 for i=1:length(variable_fieldnames), 94 94 field_name=variable_fieldnames{i}; … … 104 104 105 105 %build a MatArray of response partitions: 106 response_fieldnames=fieldnames(md.qmu.responses(ivar));107 106 responsepartitions={}; 108 107 responsepartitions_npart=[]; 108 response_fieldnames=fieldnames(md.qmu.responses(iresp)); 109 109 for i=1:length(response_fieldnames), 110 110 field_name=response_fieldnames{i}; 111 fieldresponse=md.qmu.responses(i var).(field_name);111 fieldresponse=md.qmu.responses(iresp).(field_name); 112 112 if fieldresponse.isscaled(); 113 113 responsepartitions{end+1}=fieldresponse.partition; -
issm/trunk-jpl/src/m/qmu/preqmu.py
r25013 r25015 7 7 from MatlabFuncs import * 8 8 from process_qmu_response_data import * 9 from qmupart2npart import *9 from qmupart2npart import qmupart2npart 10 10 11 11 12 12 def preqmu(md, options): 13 '''QMU - apply Quantification of Margins and Uncertainties techniques 13 ''' 14 QMU - apply Quantification of Margins and Uncertainties techniques 14 15 to a solution sequence (like stressbalance.py, progonstic.py, etc ...), 15 16 using the Dakota software from Sandia. 16 17 17 options come from the solve.py routine. They can include Dakota options:18 options come from the solve.py routine. They can include Dakota options: 18 19 19 20 qmufile: input file for Dakota … … 24 25 imethod: same thing for methods 25 26 iparams: same thing for params 26 '''27 ''' 27 28 28 29 print('preprocessing dakota inputs') … … 104 105 #fieldresponses = vars(md.qmu.responses[iresp])[field_name] 105 106 fieldresponses = vars(md.qmu.responses)[field_name] 106 for j in range(np.size(fieldresponses)): 107 responsedescriptors.append(fieldresponses[j].descriptor) 107 if type(fieldresponses) in [list, np.ndarray]: 108 for j in range(np.size(fieldresponses)): 109 responsedescriptors.append(fieldresponses[j].descriptor) 110 else: 111 responsedescriptors.append(fieldresponses.descriptor) 108 112 #}}} 109 113 … … 114 118 for i in range(len(variable_fieldnames)): 115 119 field_name = variable_fieldnames[i] 116 fieldvariable = getattr(md.qmu.variables, field_name) 117 if fieldvariable.isscaled(): 118 variablepartitions.append(fieldvariable.partition) 119 variablepartitions_npart.append(qmupart2npart(fieldvariable.partition)) 120 fieldvariable = vars(md.qmu.variables)[field_name] 121 if type(fieldvariable) in [list, np.ndarray]: 122 for j in range(np.size(fieldvariable)): 123 if fieldvariable[j].isscaled(): 124 variablepartitions.append(fieldvariable[j].partition) 125 variablepartitions_npart.append(qmupart2npart(fieldvariable[j].partition)) 126 else: 127 variablepartitions.append([]) 128 variablepartitions_npart.append(0) 120 129 else: 121 variablepartitions.append([]) 122 variablepartitions_npart.append(0) 130 if fieldvariable.isscaled(): 131 variablepartitions.append(fieldvariable.partition) 132 variablepartitions_npart.append(qmupart2npart(fieldvariable.partition)) 133 else: 134 variablepartitions.append([]) 135 variablepartitions_npart.append(0) 123 136 124 137 # Build a list of response partitions … … 128 141 for i in range(len(response_fieldnames)): 129 142 field_name = response_fieldnames[i] 130 fieldresponse = getattr(md.qmu.variables, field_name) 131 if fieldresponse.isscaled(): 132 responsepartitions.append(fieldresponse.partition) 133 responsepartitions_npart.append(qmupart2npart(fieldresponse.partition)) 143 fieldresponse = vars(md.qmu.responses)[field_name] 144 if type(fieldresponses) in [list, np.ndarray]: 145 for j in range(np.size(fieldresponses)): 146 if fieldresponse[j].isscaled(): 147 responsepartitions.append(fieldresponse[j].partition) 148 responsepartitions_npart.append(qmupart2npart(fieldresponse.partition)) 149 else: 150 responsepartitions.append([]) 151 responsepartitions_npart.append(0) 134 152 else: 135 responsepartitions.append([]) 136 responsepartitions_npart.append(0) 153 if fieldresponse.isscaled(): 154 responsepartitions.append(fieldresponse.partition) 155 responsepartitions_npart.append(qmupart2npart(fieldresponse.partition)) 156 else: 157 responsepartitions.append([]) 158 responsepartitions_npart.append(0) 137 159 138 160 # register the fields that will be needed by the Qmu model. -
issm/trunk-jpl/test/NightlyRun/test244.py
r24870 r25015 68 68 69 69 #partitioning 70 md.qmu.numberofpartitions = md.mesh.numberofelements 71 md = partitioner(md, 'package', 'linear', 'type', 'element') 72 md.qmu.epartition = (md.qmu.epartition - 1) 70 npart = md.mesh.numberofelements 71 partition = partitioner(md, 'package', 'linear', 'type', 'element', 'npart', npart) - 1 73 72 74 73 #variables 75 74 md.qmu.variables.surface_mass_balance = normal_uncertain.normal_uncertain( 76 75 'descriptor', 'scaled_SmbC', 77 'mean', np.ones(md. qmu.numberofpartitions),78 'stddev', .5 * np.ones(md. qmu.numberofpartitions),79 'partition', md.qmu.epartition76 'mean', np.ones(md.mesh.numberofelements), 77 'stddev', .5 * np.ones(md.mesh.numberofelements), 78 'partition', partition 80 79 ) 81 80 Tmin = 273. … … 83 82 mint_on_partition = telms.flatten() 84 83 for pa in range(np.size(mint_on_partition)): 85 vi = np.where( md.qmu.epartition == pa)84 vi = np.where(partition == pa) 86 85 mint = telms[0, vi] * 1.05 87 86 pos = np.where(mint < Tmin) … … 92 91 md.qmu.variables.surface_mass_balanceTa = uniform_uncertain.uniform_uncertain( 93 92 'descriptor', 'scaled_SmbTa', 94 'lower', .95 * np.ones(md. qmu.numberofpartitions),93 'lower', .95 * np.ones(md.mesh.numberofelements), 95 94 'upper', np.maximum(np.minimum(np.maximum(1.05, mint_on_partition), 0.9999), 0.0001), 96 'partition', md.qmu.epartition95 'partition', partition 97 96 ) 98 97
Note:
See TracChangeset
for help on using the changeset viewer.