Changeset 5518
- Timestamp:
- 08/23/10 14:27:43 (15 years ago)
- Location:
- issm/trunk/src/c
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/modules/AverageOntoPartitionx/AverageOntoPartitionx.cpp
r5478 r5518 19 19 20 20 21 void AverageOntoPartitionx(double** average, double* vertex_response, Vertices* vertices, Parameters* parameters,Vec node_partition){21 void AverageOntoPartitionx(double** paverage, Elements* elements, Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,double* vertex_response,Vec vertex_cluster_partition){ 22 22 23 23 int i,j,k; … … 25 25 26 26 int qmu_npart; 27 double *qmu_part_ serial= NULL;27 double *qmu_part_nocluster = NULL; 28 28 double *qmu_part = NULL; 29 double* partition=NULL; //serial version of node_partition29 double* partition=NULL; //serial version of vertex_cluster_partition 30 30 int numberofvertices; 31 31 32 /*First, recover qmu partition of vertices. Careful, do not confuse with node_partition, which is just used to distribute vertices 32 /*output: */ 33 Vec partition_contributions=NULL; 34 Vec partition_areas=NULL; 35 Vec vec_average=NULL; 36 double* average=NULL; 37 38 /*First, recover qmu partition of vertices. Careful, do not confuse with vertex_cluster_partition, which is just used to distribute vertices 33 39 * onto cpus in a cluter: */ 34 if(!parameters->FindParam(&qmu_part_ serial,&dummy,QmuPartEnum))ISSMERROR(" could not find qmu partition vector");40 if(!parameters->FindParam(&qmu_part_nocluster,&dummy,QmuPartEnum))ISSMERROR(" could not find qmu partition vector"); 35 41 36 42 /*Some parameters: */ … … 38 44 parameters->FindParam(&qmu_npart,QmuNPartEnum); 39 45 40 /*serialize nodal partition vector: */41 VecToMPISerial(&partition, node_partition);46 /*serialize vertex_cluster_partition: */ 47 VecToMPISerial(&partition,vertex_cluster_partition); 42 48 43 /*Use partition vector to repartition qmu_part_ serial, which is ordered in a serial way: */49 /*Use partition vector to repartition qmu_part_nocluster, which is ordered for use on a serial machine, not a cluster: */ 44 50 qmu_part=(double*)xmalloc(numberofvertices*sizeof(double)); 45 for(k=0;k<numberofvertices;k++) qmu_part[(int)(partition[k])]=qmu_part_ serial[k];51 for(k=0;k<numberofvertices;k++) qmu_part[(int)(partition[k])]=qmu_part_nocluster[k]; 46 52 47 53 /*Ok, now we have a qmu partition (into separate areas) that takes into account the parallelism of the cluster. … … 49 55 be a npart sized vector. */ 50 56 51 ISSMERROR(" not supported yet!"); 57 /*allocate: */ 58 partition_contributions=NewVec(qmu_npart); 59 partition_areas=NewVec(qmu_npart); 60 vec_average=NewVec(qmu_npart); 52 61 62 /*loop on each element, and add contribution of the element to the partition (surface weighted average): */ 63 for(i=0;i<elements->Size();i++){ 64 Element* element=(Element*)elements->GetObjectByOffset(i); 65 element->AverageOntoPartition(partition_contributions,partition_areas,vertex_response,qmu_part); 66 } 53 67 68 /*Assemble: */ 69 VecAssemblyBegin(partition_contributions); 70 VecAssemblyEnd(partition_contributions); 71 72 VecAssemblyBegin(partition_areas); 73 VecAssemblyEnd(partition_areas); 74 75 /*We have the partition_areas and the partition_contributions for each partition -> compute the surfae weighted average: */ 76 VecPointwiseDivide(vec_average,partition_contributions,partition_areas); 77 78 /*serialize:*/ 79 VecToMPISerial(&average,vec_average); 80 81 /*Free ressources:*/ 82 xfree((void**)&partition); 83 xfree((void**)&qmu_part_nocluster); 84 xfree((void**)&qmu_part); 85 VecFree(&partition_contributions); 86 VecFree(&partition_areas); 87 VecFree(&vec_average); 88 89 /*Assign output pointers:*/ 90 *paverage=average; 54 91 } -
issm/trunk/src/c/modules/AverageOntoPartitionx/AverageOntoPartitionx.h
r5478 r5518 9 9 #include "../../Container/Container.h" 10 10 11 void AverageOntoPartitionx(double** average, double* vertex_response, Vertices* vertices,Parameters* parameters,Vec node_partition);11 void AverageOntoPartitionx(double** average, Elements* elements, Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,double* vertex_response,Vec vertex_cluster_partition); 12 12 13 13 #endif /* _AVERAGEONTOPARTITIONXX_H */ -
issm/trunk/src/c/modules/DakotaResponsesx/DakotaResponsesx.cpp
r5480 r5518 18 18 19 19 20 void DakotaResponsesx(double* d_responses,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters,Vec node_partition,char** responses_descriptors,int numresponsedescriptors,int d_numresponses){20 void DakotaResponsesx(double* d_responses,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters,Vec vertex_cluster_partition,char** responses_descriptors,int numresponsedescriptors,int d_numresponses){ 21 21 22 22 int i,j,k; … … 31 31 int flag; 32 32 double* vertex_response=NULL; 33 double* partition_response=NULL;33 double* qmu_response=NULL; 34 34 35 35 double* responses_pointer=NULL; … … 54 54 55 55 /*Now, average it onto the partition grids: */ 56 AverageOntoPartitionx(& partition_response,vertex_response,vertices,parameters,node_partition);56 AverageOntoPartitionx(&qmu_response,elements,nodes,vertices,loads,materials,parameters,vertex_response,vertex_cluster_partition); 57 57 58 58 /*Copy onto our dakota responses: */ 59 for(i=0;i<npart;i++)responses_pointer[i]=partition_response[i]; 59 if(my_rank==0){ 60 /*plug response: */ 61 for(i=0;i<npart;i++)responses_pointer[i]=qmu_response[i]; 62 63 /*increment response_pointer :*/ 64 responses_pointer+=npart; 65 } 60 66 61 67 /*Free ressources:*/ 62 68 xfree((void**)&vertex_response); 63 xfree((void**)&partition_response); 64 65 /*increment response_pointer :*/ 66 responses_pointer+=npart; 69 xfree((void**)&qmu_response); 67 70 68 71 } -
issm/trunk/src/c/modules/DakotaResponsesx/DakotaResponsesx.h
r5480 r5518 9 9 #include "../../Container/Container.h" 10 10 11 void DakotaResponsesx(double* d_responses,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters,Vec node_partition,char** responses_descriptors,int numresponsedescriptors,int d_numresponses);11 void DakotaResponsesx(double* d_responses,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters,Vec vertex_cluster_partition,char** responses_descriptors,int numresponsedescriptors,int d_numresponses); 12 12 13 13 #endif /* _DAKOTARESPONSESXX_H */ -
issm/trunk/src/c/objects/Elements/Element.h
r5286 r5518 78 78 virtual void InputControlUpdate(double scalar,bool save_parameter)=0; 79 79 virtual bool InputConvergence(double* eps, int* enums,int num_enums,int* criterionenums,double* criterionvalues,int num_criterionenums)=0; 80 virtual void AverageOntoPartition(Vec partition_contributions,Vec partition_areas,double* vertex_response,double* qmu_part)=0; 80 81 81 82 /*Implementation: */ -
issm/trunk/src/c/objects/Elements/Penta.cpp
r5510 r5518 465 465 466 466 /*Element virtual functions definitions: */ 467 /*FUNCTION Penta::AverageOntoPartition {{{1*/ 468 void Penta::AverageOntoPartition(Vec partition_contributions,Vec partition_areas,double* vertex_response,double* qmu_part){ 469 ISSMERROR("Not supported yet!"); 470 } 471 /*}}}*/ 467 472 /*FUNCTION Penta::ComputeBasalStress {{{1*/ 468 473 void Penta::ComputeBasalStress(Vec sigma_b){ -
issm/trunk/src/c/objects/Elements/Penta.h
r5311 r5518 69 69 /*}}}*/ 70 70 /*Element virtual functions definitions: {{{1*/ 71 void AverageOntoPartition(Vec partition_contributions,Vec partition_areas,double* vertex_response,double* qmu_part); 71 72 void ComputeBasalStress(Vec sigma_b); 72 73 void ComputePressure(Vec p_g); -
issm/trunk/src/c/objects/Elements/Tria.cpp
r5414 r5518 529 529 530 530 /*Element virtual functions definitions: */ 531 /*FUNCTION Tria::AverageOntoPartition {{{1*/ 532 void Tria::AverageOntoPartition(Vec partition_contributions,Vec partition_areas,double* vertex_response,double* qmu_part){ 533 534 int i,j; 535 const int numvertices=3; 536 double area; 537 double mean; 538 int partition[numvertices]; 539 int offset[numvertices]; 540 double values[3]; 541 bool already=false; 542 543 /*First, get the area: */ 544 area=this->GetArea(); 545 546 /*Figure out the average for this element: */ 547 this->GetDofList1(&offset[0]); 548 mean=0; 549 for(i=0;i<numvertices;i++){ 550 partition[i]=(int)qmu_part[offset[i]]; 551 mean=mean+1.0/numvertices*vertex_response[offset[i]]; 552 } 553 554 /*Add contribution: */ 555 for(i=0;i<numvertices;i++){ 556 already=false; 557 for(j=0;j<i;j++){ 558 if (partition[i]==partition[j]){ 559 already=true; 560 break; 561 } 562 } 563 if(!already){ 564 VecSetValue(partition_contributions,partition[i],mean*area,ADD_VALUES); 565 VecSetValue(partition_areas,partition[i],area,ADD_VALUES); 566 }; 567 } 568 } 569 /*}}}*/ 531 570 /*FUNCTION Tria::ComputeBasalStress {{{1*/ 532 571 void Tria::ComputeBasalStress(Vec eps){ … … 6378 6417 x3=xyz_list[2][0]; y3=xyz_list[2][1]; 6379 6418 6380 return x2*y3 - y2*x3 + x1*y2 - y1*x2 + x3*y1 - y3*x1;6419 return (x2*y3 - y2*x3 + x1*y2 - y1*x2 + x3*y1 - y3*x1)/2; 6381 6420 } 6382 6421 /*}}}*/ -
issm/trunk/src/c/objects/Elements/Tria.h
r5387 r5518 66 66 /*}}}*/ 67 67 /*Element virtual functions definitions: {{{1*/ 68 void AverageOntoPartition(Vec partition_contributions,Vec partition_areas,double* vertex_response,double* qmu_part); 68 69 void ComputeBasalStress(Vec sigma_b); 69 70 void ComputePressure(Vec p_g);
Note:
See TracChangeset
for help on using the changeset viewer.