Changeset 4855
- Timestamp:
- 07/28/10 19:02:43 (15 years ago)
- Location:
- issm/trunk/src/c
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/Container/Parameters.cpp
r4059 r4855 229 229 } 230 230 /*}}}*/ 231 /*FUNCTION Parameters::FindParam(double*** parray,int* pM,int** pmdims_array,int** pndims_array,int enum_type){{{1*/ 232 int Parameters::FindParam(double*** parray,int* pM,int** pmdims_array,int** pndims_array,int enum_type){ 233 234 /*Go through a dataset, and find a Param* object 235 *which parameter name is "name" : */ 236 237 vector<Object*>::iterator object; 238 Param* param=NULL; 239 240 int found=0; 241 242 for ( object=objects.begin() ; object < objects.end(); object++ ){ 243 244 /*Ok, this object is a parameter, recover it and ask which name it has: */ 245 param=(Param*)(*object); 246 247 if(param->EnumType()==enum_type){ 248 /*Ok, this is the one! Recover the value of this parameter: */ 249 param->GetParameterValue(parray,pM,pmdims_array,pndims_array); 250 found=1; 251 break; 252 } 253 } 254 return found; 255 } 256 /*}}}*/ 231 257 /*FUNCTION Parameters::FindParam(Vec* pvec,int enum_type){{{1*/ 232 258 int Parameters::FindParam(Vec* pvec,int enum_type){ -
issm/trunk/src/c/Container/Parameters.h
r4236 r4855 33 33 int FindParam(double** pdoublearray,int* pM,int enum_type); 34 34 int FindParam(double** pdoublearray,int* pM,int* pN,int enum_type); 35 int FindParam(double*** parray,int* pM, int** pmdims_array,int** pndims_array,int enum_type); 35 36 int FindParam(Vec* pvec,int enum_type); 36 37 int FindParam(Mat* pmat,int enum_type); -
issm/trunk/src/c/EnumDefinitions/EnumDefinitions.h
r4852 r4855 334 334 QmuErrNameEnum, 335 335 QmuInNameEnum, 336 QmuMassFluxNumSegmentsEnum,337 336 QmuMassFluxSegmentsEnum, 338 337 QmuNPartEnum, -
issm/trunk/src/c/modules/DakotaResponsesx/DakotaResponsesx.cpp
r4773 r4855 20 20 void DakotaResponsesx(double* responses,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters,char** responses_descriptors,int numresponses){ 21 21 22 int i ;22 int i,j; 23 23 int dummy; 24 int counter; 24 25 extern int my_rank; 25 26 … … 71 72 } 72 73 else if(strlen(response_descriptor)>=8){ 73 74 74 if(strncmp(response_descriptor,"MassFlux",8)==0){ 75 75 76 double* segments=NULL; 77 int num_segments; 76 /*Deal with several mass flux computations: {{{1*/ 77 double** array=NULL; 78 int M; 79 int* mdims_array=NULL; 80 int* ndims_array=NULL; 81 82 double* segments=NULL; 83 int num_segments; 78 84 79 85 /*retrieve qmu_mass_flux_segments: */ 80 parameters->FindParam(&segments,&num_segments,&dummy,QmuMassFluxSegmentsEnum); 86 parameters->FindParam(&array,&M,&mdims_array,&ndims_array,QmuMassFluxSegmentsEnum); 87 88 /*figure out counter after MassFlux: */ 89 sscanf(response_descriptor,"MassFlux%i",&counter); 90 91 /*retrieve segments from array: */ 92 segments=array[counter-1]; //matlab to "C" indexing 93 num_segments=mdims_array[counter-1]; 81 94 82 95 /*call mass flux module: */ … … 84 97 85 98 /*Free ressources:*/ 86 xfree((void**)&segments); 99 for(j=0;j<M;j++){ 100 double* matrix=array[i]; 101 xfree((void**)&matrix); 102 } 103 xfree((void**)&mdims_array); 104 xfree((void**)&ndims_array); 105 xfree((void**)&array); 106 /*}}}*/ 87 107 } 88 89 108 } 90 109 else{ -
issm/trunk/src/c/modules/ModelProcessorx/Qmu/CreateParametersQmu.cpp
r4854 r4855 44 44 double** array=NULL; 45 45 double* matrix=NULL; 46 double* temp_matrix=NULL; 46 47 int* mdims_array=NULL; 47 48 int* ndims_array=NULL; 48 49 int M; 50 int temp_m,temp_n; 49 51 50 52 #ifdef _SERIAL_ … … 190 192 #ifdef _SERIAL_ 191 193 pfield=mxGetField(iomodel_handle,0,"qmu_mass_flux_segments"); 192 for(i=0;i< iomodel->qmu_mass_flux_num_profiles;i++){194 for(i=0;i<M;i++){ 193 195 pfield2=mxGetCell(pfield,i); 194 196 FetchData(&matrix,mdims_array+i,ndims_array+i,pfield2); … … 196 198 } 197 199 #else 198 for(i=0;i<iomodel->qmu_mass_flux_num_profiles;i++){ 199 sprintf(massflux_tag,"%s%i","qmu_mass_flux_segmentsi",i); 200 IoModelFetchData(&tot_matrix,tot_mdims_array+i,NULL,iomodel_handle,"qmu_mass_flux_segments"); 201 variabledescriptors[i]=descriptor; 202 } 203 #endif 204 205 #ifdef _PARALLEL_ 206 IoModelFetchData(&qmu_mass_flux_segments,&tot_qmu_mass_flux_segments,NULL,iomodel_handle,"qmu_mass_flux_segments"); 207 IoModelFetchData(&qmu_mass_flux_num_segments,&tot_qmu_mass_flux_num_segments,NULL,iomodel_handle,"qmu_mass_flux_num_segments"); 208 209 210 /*Only if partitioning exist do we care about the segments: */ 211 if(iomodel->my_elements){ 212 213 /*Use the element partitioning vector from the iomodel to down select qmu_mass_flux_segments to only segments that are relevant 214 * to this cpu: */ 215 my_tot_qmu_mass_flux_segments=0; 216 for(j=0;j<tot_qmu_mass_flux_segments;j++){ 217 if ( iomodel->my_elements[(int)(*(qmu_mass_flux_segments+5*j+4))-1])my_tot_qmu_mass_flux_segments++; 200 for(i=0;i<M;i++){ 201 sprintf(massflux_tag,"%s%i","qmu_mass_flux_segments",i); 202 IoModelFetchData(&temp_matrix,&temp_m,&temp_n,iomodel_handle,massflux_tag); 203 204 /*This temp_matrix represents all the segments, for all elements. On this cpu, we only have a subset of these 205 * elements. Extract matrix, out of temp_matrix, corresponding to only our elements: */ 206 m=0; 207 for(j=0;j<temp_m;j++){ 208 if ( iomodel->my_elements[(int)(*(temp_matrix+5*j+4))-1])m++; 218 209 } 219 220 221 if(my_tot_qmu_mass_flux_segments){ 222 my_qmu_mass_flux_segments=(double*)xcalloc(5*my_tot_qmu_mass_flux_segments,sizeof(double)); 223 second_count=0; 224 for(j=0;j<tot_qmu_mass_flux_segments;j++){ 225 if (iomodel->my_elements[(int)*(qmu_mass_flux_segments+5*j+4)-1]){ 226 for(k=0;k<5;k++)*(my_qmu_mass_flux_segments+5*second_count+k)=*(qmu_mass_flux_segments+5*j+k); 227 second_count++; 210 if(m){ 211 matrix=(double*)xcalloc(5*m,sizeof(double)); 212 count=0; 213 for(j=0;j<temp_m;j++){ 214 if (iomodel->my_elements[(int)*(temp_matrix+5*j+4)-1]){ 215 for(k=0;k<5;k++)*(matrix+5*count+k)=*(temp_matrix+5*j+k); 216 count++; 228 217 } 229 218 } 230 219 } 231 220 232 parameters->AddObject(new DoubleMatParam(QmuMassFluxSegmentsEnum,my_qmu_mass_flux_segments,my_tot_qmu_mass_flux_segments,5)); 233 234 } 235 236 #else 237 IoModelFetchData(&qmu_mass_flux_segments,&tot_qmu_mass_flux_segments,NULL,iomodel_handle,"qmu_mass_flux_segments"); 238 IoModelFetchData(&qmu_mass_flux_num_segments,&tot_qmu_mass_flux_num_segments,NULL,iomodel_handle,"qmu_mass_flux_num_segments"); 239 240 parameters->AddObject(new DoubleMatParam(QmuMassFluxSegmentsEnum,qmu_mass_flux_segments,tot_qmu_mass_flux_segments,5)); 241 parameters->AddObject(new DoubleVecParam(QmuMassFluxNumSegmentsEnum,qmu_mass_flux_num_segments,tot_qmu_mass_flux_num_segments)); 242 221 /*Assign: */ 222 array[i]=matrix; 223 mdims_array[i]=m; 224 ndims_array[i]=5; 225 226 /*Free data: */ 227 xfree((void**)&temp_matrix); 228 } 243 229 #endif 244 230 245 xfree((void**)&qmu_mass_flux_segments); 246 xfree((void**)&my_qmu_mass_flux_segments); 247 xfree((void**)&qmu_mass_flux_num_segments); 248 xfree((void**)&my_qmu_mass_flux_num_segments); 231 /*Ok, we have an array of segments, different on every cpu. Create a DoubleMatArrayParam object with it: */ 232 parameters->AddObject(new DoubleMatArrayParam(QmuMassFluxSegmentsEnum,array,M,mdims_array,ndims_array)); 233 234 /*Free data: */ 235 for(i=0;i<M;i++){ 236 double* matrix=array[i]; 237 xfree((void**)&matrix); 238 } 239 xfree((void**)&mdims_array); 240 xfree((void**)&ndims_array); 241 xfree((void**)&array); 249 242 } 250 243 /*}}}*/
Note:
See TracChangeset
for help on using the changeset viewer.