Changeset 24988
- Timestamp:
- 06/08/20 22:58:53 (5 years ago)
- Location:
- issm/trunk-jpl/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/modules/InputUpdateFromDakotax/InputUpdateFromDakotax.cpp
r24172 r24988 13 13 14 14 int i,j,k,l; 15 int dummy;16 15 17 16 int numberofvertices; … … 19 18 int nrows; 20 19 int ncols; 21 int npart; 22 double *qmu_vpart = NULL; 23 double *qmu_epart = NULL; 20 IssmDouble **variable_partitions = NULL; 21 IssmDouble * variable_partition = NULL; 22 int variable_partitions_num; 23 int *partitions_m = NULL; 24 int *partitions_n = NULL; 25 int npart; 26 int dummy; //should match numvariables 24 27 25 28 double *distributed_values = NULL; … … 29 32 30 33 /*retrieve parameters: */ 31 femmodel->parameters->FindParam(&npart,QmuNumberofpartitionsEnum); 32 femmodel->parameters->FindParam(&qmu_vpart,NULL,QmuVpartitionEnum); 33 femmodel->parameters->FindParam(&qmu_epart,NULL,QmuEpartitionEnum); 34 femmodel->parameters->FindParam(&variable_partitions,&variable_partitions_num,&partitions_m,&partitions_n,QmuVariablePartitionsEnum); 35 34 36 numberofvertices=femmodel->vertices->NumberOfVertices(); 35 37 numberofelements=femmodel->elements->NumberOfElements(); … … 44 46 /*From descriptor, figure out if the variable is scaled, indexed, nodal, or just a simple variable: */ 45 47 if (strncmp(descriptor,"scaled_",7)==0){ 48 49 /*recover partition vector: */ 50 variable_partition=variable_partitions[i]; 51 //_printf_("variable_partition_M: " << variable_partition_M << " variable_partition_N " << variable_partition_N << "\n"); 52 npart=partitions_m[i]; 46 53 47 54 /*Variable is scaled. Determine root name of variable (ex: scaled_DragCoefficient_1 -> DragCoefficient). Allocate distributed_values and fill the … … 57 64 } 58 65 66 59 67 /*Now, pick up the parameter corresponding to root: */ 60 68 femmodel->parameters->FindParamInDataset(¶meter,&nrows,&ncols,QmuVariableDescriptorsEnum,StringToEnumx(root)); 61 69 62 63 /*We've got the parameter, we need to update it using qmu_vpart or qmu_epart (depending on whether 64 * it is element or vertex distributed), and the distributed_values. 65 In addition, the parameter can be either a static or transient (nrows+1) vector. */ 70 /*We've got the parameter, we need to update it using the partition vector, and the distributed_values. 71 In addition, the parameter can be either a static or transient (nrows+1) vector. Finally, the partition vectors can include 72 -1 (meaning, don't update). */ 66 73 67 74 //_printf_("nrows: " << nrows << " numberofvertices: " << numberofvertices << " numberofelements: " << numberofelements << "\n"); … … 69 76 if (nrows==numberofvertices || nrows==(numberofvertices+1)){ 70 77 for(k=0;k<numberofvertices;k++){ 71 for(l=0;l<ncols;l++){ 72 *(parameter+ncols*k+l)=*(parameter+ncols*k+l)*distributed_values[(int)qmu_vpart[k]]; 78 if (variable_partition[k]==-1)continue; 79 else{ 80 for(l=0;l<ncols;l++){ 81 *(parameter+ncols*k+l)=*(parameter+ncols*k+l)*distributed_values[(int)variable_partition[k]]; 82 } 73 83 } 74 84 } … … 76 86 else if (nrows==numberofelements || nrows==(numberofelements+1)){ 77 87 for(k=0;k<numberofelements;k++){ 78 for(l=0;l<ncols;l++){ 79 *(parameter+ncols*k+l)=*(parameter+ncols*k+l)*distributed_values[(int)qmu_epart[k]]; 88 if (variable_partition[k]==-1)continue; 89 else{ 90 for(l=0;l<ncols;l++){ 91 *(parameter+ncols*k+l)=*(parameter+ncols*k+l)*distributed_values[(int)variable_partition[k]]; 92 } 80 93 } 81 94 } … … 108 121 /*increment i to skip the distributed values just collected: */ 109 122 i+=npart-1; //careful, the for loop will add 1. 110 123 111 124 /*Free allocations: */ 112 125 xDelete<double>(parameter); … … 126 139 127 140 /*Free ressources:*/ 128 xDelete<double>(qmu_vpart); 129 xDelete<double>(qmu_epart); 141 for(i=0;i<variable_partitions_num;i++){ 142 IssmDouble* matrix=variable_partitions[i]; 143 xDelete<IssmDouble>(matrix); 144 } 145 xDelete<int>(partitions_m); 146 xDelete<int>(partitions_n); 147 xDelete<IssmDouble*>(variable_partitions); 148 130 149 } -
issm/trunk-jpl/src/c/modules/ModelProcessorx/Dakota/CreateParametersDakota.cpp
r24450 r24988 13 13 /*variable declarations*/ 14 14 int i; 15 double *vpart = NULL;16 double *epart = NULL;17 int npart;18 15 char **responsedescriptors = NULL; 19 16 int numresponsedescriptors; … … 35 32 int numberofresponses; 36 33 int nrows,ncols; 34 35 //variable partitions: 36 IssmDouble **array = NULL; 37 int *mdims_array = NULL; 38 int *ndims_array = NULL; 39 int num_partitions; 37 40 38 41 /*recover parameters: */ … … 70 73 /*Load partitioning vectors (both vertex and element based: */ 71 74 parameters->AddObject(iomodel->CopyConstantObject("md.qmu.numberofpartitions",QmuNumberofpartitionsEnum)); 72 iomodel->FetchData(&vpart,&npart,NULL,"md.qmu.vpartition"); if(!vpart) _error_("md.qmu.vpartition is empty");73 parameters->AddObject(new DoubleVecParam(QmuVpartitionEnum,vpart,npart));74 75 75 iomodel->FetchData(&epart,&npart,NULL,"md.qmu.epartition"); if(!epart) _error_("md.qmu.epartition is empty"); 76 parameters->AddObject(new DoubleVecParam(QmuEpartitionEnum,epart,npart)); 76 /*Load partitioning vectors specific to variables:*/ 77 iomodel->FetchData(&array,&mdims_array,&ndims_array,&num_partitions,"md.qmu.variablepartitions"); 78 parameters->AddObject(new DoubleMatArrayParam(QmuVariablePartitionsEnum,array,num_partitions,mdims_array,ndims_array)); 79 77 80 78 81 /*Deal with data needed because of qmu variables*/ … … 114 117 } 115 118 xDelete<char*>(variabledescriptors); 116 xDelete<double>(vpart);117 xDelete<double>(epart);118 119 xDelete<char>(qmuinname); 119 120 xDelete<char>(qmuerrname); 120 121 xDelete<char>(qmuoutname); 122 123 for(i=0;i<num_partitions;i++){ 124 IssmDouble* matrix=array[i]; 125 xDelete<IssmDouble>(matrix); 126 } 127 xDelete<int>(mdims_array); 128 xDelete<int>(ndims_array); 129 xDelete<IssmDouble*>(array); 130 121 131 } 122 132 -
issm/trunk-jpl/src/m/classes/qmu.m
r24820 r24988 18 18 numberofresponses = 0; 19 19 variabledescriptors = {}; 20 variablepartitions = {}; 20 21 responsedescriptors = {}; 21 22 mass_flux_profile_directory = NaN; … … 57 58 methods 58 59 function self = extrude(self,md) % {{{ 59 self.vpartition=project3d(md,'vector',self.vpartition','type','node');60 self.epartition=project3d(md,'vector',self.epartition','type','element');61 60 end % }}} 62 61 function self = qmu(varargin) % {{{ … … 97 96 end 98 97 end 99 if ~isempty(md.qmu.vpartition) & ~any(isnan(md.qmu.vpartition)),100 if size(md.qmu.vpartition,1)~=md.mesh.numberofvertices101 md = checkmessage(md,['user supplied vertex partition for qmu analysis should have size md.mesh.numberofvertices x 1']);102 end103 if min(md.qmu.vpartition)~=0,104 md = checkmessage(md,['vertex partition vector not indexed from 0 on']);105 end106 if max(md.qmu.vpartition)>=md.qmu.numberofpartitions,107 md = checkmessage(md,['for qmu analysis, vertex partitioning vector cannot go over npart, number of partition areas']);108 end109 end110 if ~isempty(md.qmu.epartition) & ~any(isnan(md.qmu.epartition)),111 if size(md.qmu.epartition,1)~=md.mesh.numberofelements,112 md = checkmessage(md,['user supplied element partition for qmu analysis should have size md.mesh.numberofelements x 1']);113 end114 if min(md.qmu.epartition)~=0,115 md = checkmessage(md,['element partition vector not indexed from 0 on']);116 end117 if max(md.qmu.epartition)>=md.qmu.numberofpartitions,118 md = checkmessage(md,['for qmu analysis, element partitioning vector cannot go over npart, number of partition areas']);119 end120 end121 if isempty(md.qmu.vpartition) | any(isnan(md.qmu.vpartition)) | isempty(md.qmu.epartition) | any(isnan(md.qmu.epartition)),122 md = checkmessage(md,['for qmu analysis, both an element and partitioning vectors need to be supplied with no nan values! One can be defaulted to all zeros.']);123 end124 98 125 99 %go through variables and check for consistency: … … 198 172 end 199 173 end 200 fielddisplay(self,'vpartition','user provided mesh partitioning (vertex based)'); 201 fielddisplay(self,'epartition','user provided mesh partitioning (element based)'); 202 fielddisplay(self,'numberofpartitions','number of partitions for semi-discrete qmu') 174 fielddisplay(self,'variablepartitions',''); 203 175 fielddisplay(self,'variabledescriptors',''); 204 176 fielddisplay(self,'responsedescriptors',''); … … 223 195 WriteData(fid,prefix,'object',self,'fieldname','numberofresponses','format','Integer'); 224 196 WriteData(fid,prefix,'object',self,'fieldname','variabledescriptors','format','StringArray'); 197 WriteData(fid,prefix,'object',self,'fieldname','variablepartitions','format','MatArray'); 225 198 WriteData(fid,prefix,'object',self,'fieldname','responsedescriptors','format','StringArray'); 226 199 if ~isempty(self.mass_flux_segments), -
issm/trunk-jpl/src/m/qmu/preqmu.m
r24839 r24988 87 87 end 88 88 89 %build a MatArray of variable partitions: 90 variable_fieldnames=fieldnames(md.qmu.variables(ivar)); 91 variablepartitions={}; 92 for i=1:length(variable_fieldnames), 93 field_name=variable_fieldnames{i}; 94 fieldvariable=md.qmu.variables(ivar).(field_name); 95 if fieldvariable.isscaled(); 96 variablepartitions{end+1}=fieldvariable.partition; 97 else 98 variablepartitions{end+1}=[]; 99 end 100 end 101 102 89 103 %register the fields that will be needed by the Qmu model. 90 104 md.qmu.numberofresponses=numresponses; 91 105 md.qmu.variabledescriptors=variabledescriptors; 106 md.qmu.variablepartitions=variablepartitions; 92 107 md.qmu.responsedescriptors=responsedescriptors; 93 108 -
issm/trunk-jpl/src/m/qmu/setupdesign/QmuSetupVariables.m
r24870 r24988 9 9 %ok, key off according to type of descriptor: 10 10 if strncmp(descriptor,'scaled_',7), 11 %we have a scaled variable, expand it over the partition. 11 %we have a scaled variable, expand it over the partition. First recover the partition: 12 partition=variables.partition; 13 %figure out number of partitions: 14 npart=qmupart2npart(partition) 12 15 13 16 if isa(variables,'uniform_uncertain'), 14 if (length(variables.lower)>md.qmu.numberofpartitions || length(variables.upper)>md.qmu.numberofpartitions) 15 error('QmuSetupDesign error message: stddev should be either a scalar or a ''npart'' length vector'); 17 nlower=length(variables.lower); nupper=length(variables.upper); 18 if (nlower ~= npart || nupper ~=npart), 19 error('QmuSetupVariables error message: upper and lower fields should be same size as the number of partitions'); 16 20 end 17 21 elseif isa(variables,'normal_uncertain'), 18 if length(variables.stddev)>md.qmu.numberofpartitions, 19 error('QmuSetupDesign error message: stddev should be either a scalar or a ''npart'' length vector'); 22 nstddev=length(variables.stddev); 23 nmean=length(variables.mean); 24 if (nstddev ~= npart || nmean ~=npart), 25 error('QmuSetupVariables error message: stddev and mean fields should be same size as the number of partitions'); 20 26 end 21 27 end … … 23 29 %ok, dealing with semi-discrete distributed variable. Distribute according to how many 24 30 %partitions we want 25 for j=1: md.qmu.numberofpartitions31 for j=1:npart, 26 32 dvar(end+1) =variables; 27 33 dvar(end ).descriptor=sprintf('%s_%d',variables.descriptor,j); 28 34 if isa(variables,'uniform_uncertain'), 29 if length(variables.lower)>1, 30 dvar(end ).lower=variables.lower(j); 31 end 32 if length(variables.upper)>1, 33 dvar(end ).upper=variables.upper(j); 34 end 35 dvar(end ).lower=variables.lower(j); 36 dvar(end ).upper=variables.upper(j); 35 37 elseif isa(variables,'normal_uncertain'), 36 if length(variables.stddev)>1, 37 dvar(end ).stddev=variables.stddev(j); 38 end 39 if length(variables.mean)>1, 40 dvar(end ).mean=variables.mean(j); 41 end 42 38 dvar(end ).stddev=variables.stddev(j); 39 dvar(end ).mean=variables.mean(j); 43 40 end 44 41 end
Note:
See TracChangeset
for help on using the changeset viewer.