Changeset 3869
- Timestamp:
- 05/20/10 16:22:15 (15 years ago)
- Location:
- issm/trunk/src/c
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/DataSet/DataSet.cpp
r3847 r3869 945 945 } 946 946 947 } 948 /*}}}*/ 949 /*FUNCTION DataSet::DepthAverageInputAtBase(int enum_type) {{{1*/ 950 void DataSet::DepthAverageInputAtBase(int enum_type){ 951 952 vector<Object*>::iterator object; 953 Element* element=NULL; 954 955 for ( object=objects.begin() ; object < objects.end(); object++ ){ 956 957 if(EnumIsElement((*object)->Enum())){ 958 959 element=(Element*)(*object); 960 element->DepthAverageInputAtBase(enum_type); 961 } 962 } 963 964 } 965 /*}}}*/ 966 /*FUNCTION DataSet::InputExtrude(int enum_type) {{{1*/ 967 void DataSet::InputExtrude(int enum_type){ 968 969 vector<Object*>::iterator object; 970 Penta* penta=NULL; 971 972 for ( object=objects.begin() ; object < objects.end(); object++ ){ 973 974 if((*object)->Enum()==PentaEnum){ 975 penta=(Penta*)(*object); 976 penta->InputExtrude(enum_type); 977 } 978 } 979 } 980 /*}}}*/ 981 /*FUNCTION DataSet::InputToResult{{{1*/ 982 void DataSet::InputToResult(Mat* psolution,int enum_type){ 983 984 /*Output*/ 985 Mat solution=NULL; 986 987 /*Intermediary*/ 988 int i; 989 vector<Object*>::iterator object; 990 extern int num_procs; 991 extern int my_rank; 992 Element* element=NULL; 993 int elemcols; 994 int cols=0,lines=0; 995 int local_cols=0; 996 int* all_cols=NULL; 997 int local_lines=0; 998 int* all_lines=NULL; 999 1000 ISSMERROR("not implemented yet"); 1001 /*First: Get number of columns to be allocated*/ 1002 for ( object=objects.begin() ; object < objects.end(); object++ ){ 1003 1004 if(EnumIsElement((*object)->Enum())){ 1005 1006 /*increase number of lines by 1*/ 1007 local_lines++; 1008 1009 /*Get number of columns required for this element*/ 1010 element=(Element*)(*object); 1011 //elemcols=element->InputToResultAllocation(enum_type); 1012 1013 /*Increase number of columns if higher than previous value*/ 1014 //if(elemcols>local_cols) local_cols=elemcols; 1015 } 1016 } 1017 1018 /*OK, sum contributions of all cpus*/ 1019 all_lines=(int*)xmalloc(num_procs*sizeof(int)); 1020 MPI_Gather(&local_lines,1,MPI_INT,all_lines,1,MPI_INT,0,MPI_COMM_WORLD); 1021 MPI_Bcast(all_lines,num_procs,MPI_INT,0,MPI_COMM_WORLD); 1022 all_cols=(int*)xmalloc(num_procs*sizeof(int)); 1023 MPI_Gather(&local_cols,1,MPI_INT,all_cols,1,MPI_INT,0,MPI_COMM_WORLD); 1024 MPI_Bcast(all_cols,num_procs,MPI_INT,0,MPI_COMM_WORLD); 1025 1026 for(i=0;i<num_procs;i++) if(all_cols[i]>cols) cols=all_cols[i]; 1027 for(i=0;i<num_procs;i++) lines+=all_lines[i]; 1028 1029 /*Second: Create Dense matrix that has the right size*/ 1030 MatCreateMPIDense(PETSC_COMM_WORLD, PETSC_DECIDE, PETSC_DECIDE,lines,cols,PETSC_NULL,&solution); 1031 1032 /*Finally, enter solution for every element*/ 1033 for ( object=objects.begin() ; object < objects.end(); object++ ){ 1034 1035 if(EnumIsElement((*object)->Enum())){ 1036 element=(Element*)(*object); 1037 //elemcols=element->InputToResult(&solution,enum_type); 1038 } 1039 } 1040 1041 /*Allocate output pointer*/ 1042 *psolution=solution; 1043 1044 /* Free ressources: */ 1045 xfree((void**)&all_cols); 1046 xfree((void**)&all_lines); 947 1047 } 948 1048 /*}}}*/ -
issm/trunk/src/c/DataSet/DataSet.h
r3855 r3869 93 93 void FieldAverageOntoVertices(Vec fieldsum,Vec connectivity,double* field); 94 94 void FieldDepthAverageAtBase(Vec field,double* field_serial,char* fieldname); 95 void DepthAverageInputAtBase(int enum_type); 96 void InputExtrude(int enum_type); 95 97 int DeleteObject(Object* object); 96 98 void ComputeBasalStress(Vec sigma_b,int analysis_type,int sub_analysis_type); … … 99 101 int FindResult(void* pvalue, char* name); 100 102 void FieldExtrude(Vec field,double* field_serial,char* field_name, int collapse); 103 void InputToResult(Mat* psolution,int enum_type); 101 104 void UpdateVertexPositions(double* thickness,double* bed); 102 105 void OutputRifts(Vec riftproperties); … … 128 131 /*numerics: {{{1*/ 129 132 int AddInput(Input* in_input); 133 Input* GetInput(int enum_name); 130 134 Inputs* SpawnTriaInputs(int* indices); 131 135 -
issm/trunk/src/c/DataSet/Inputs.cpp
r3861 r3869 529 529 } 530 530 /*}}}*/ 531 /*FUNCTION Inputs::GetInput{{{1*/ 532 Input* Inputs::GetInput(int enum_name){ 533 534 vector<Object*>::iterator object; 535 Input* input=NULL; 536 537 for ( object=objects.begin() ; object < objects.end(); object++ ){ 538 539 input=(Input*)(*object); 540 541 if (input->EnumType()==enum_name){ 542 return input; 543 } 544 } 545 ISSMERROR("input with enum %i (%s) not found",enum_name,EnumAsString(enum_name)); 546 } 547 /*}}}*/ 531 548 /*FUNCTION Inputs::ChangeEnum{{{1*/ 532 549 void Inputs::ChangeEnum(int oldenumtype,int newenumtype){ -
issm/trunk/src/c/DepthAverageInputx/DepthAverageInputx.cpp
r3823 r3869 11 11 12 12 void DepthAverageInputx( DataSet* elements,DataSet* nodes, DataSet* vertices, DataSet* loads, DataSet* materials, Parameters* parameters,int enum_type){ 13 14 /*First, get elements*/ 15 elements->Configure(elements,loads, nodes,vertices, materials,parameters); 13 16 14 15 /*First, get elements and loads configured: */ 16 elements->Configure(elements,loads, nodes,vertices, materials,parameters); 17 nodes->Configure(elements,loads, nodes,vertices, materials,parameters); 18 loads->Configure(elements, loads, nodes,vertices, materials,parameters); 19 parameters->Configure(elements,loads, nodes,vertices, materials,parameters); 17 /*First depth-average inputs at base of the glacier*/ 18 elements->DepthAverageInputAtBase(enum_type); 20 19 21 20 /*Then extrude vertically the new inputs*/ 21 elements->InputExtrude(enum_type); 22 22 23 23 } -
issm/trunk/src/c/ExtrudeInputx/ExtrudeInputx.cpp
r3791 r3869 12 12 void ExtrudeInputx( DataSet* elements,DataSet* nodes, DataSet* vertices, DataSet* loads, DataSet* materials, Parameters* parameters,int enum_type){ 13 13 14 ISSMERROR(" not supported yet!"); 14 /*First, get elements*/ 15 elements->Configure(elements,loads, nodes,vertices, materials,parameters); 16 17 /*Then extrude vertically the new inputs*/ 18 elements->InputExtrude(enum_type); 15 19 16 20 } -
issm/trunk/src/c/FieldAverageOntoVerticesx/FieldAverageOntoVerticesx.cpp
r3775 r3869 23 23 Vec field=NULL; 24 24 25 /*Initi oalize intermediary*/25 /*Initialize intermediary*/ 26 26 found=parameters->FindParam(&numberofvertices,NumberOfVerticesEnum); 27 27 connectivity=NewVec(numberofvertices); -
issm/trunk/src/c/InputToResultx/InputToResultx.cpp
r3807 r3869 13 13 void InputToResultx(Result** presult,DataSet* elements,DataSet* nodes, DataSet* vertices, DataSet* loads, DataSet* materials,Parameters* parameters,int enum_type,int id, double time, int step){ 14 14 15 ISSMERROR(" not supported yet!"); 15 /*Intermediary output vector*/ 16 Mat solution=NULL; 17 Result* result=NULL; 18 19 /*First, get elements*/ 20 elements->Configure(elements,loads, nodes,vertices, materials,parameters); 21 22 /*Then extrude vertically the new inputs*/ 23 elements->InputToResult(&solution,enum_type); 24 25 /*Create Result and clean up*/ 26 /*Mat support in result to be added!!!!!!*/ 27 //result=new Result(id,time,step,enum_type,solution); 28 MatFree(&solution); 29 30 /*Assign output pointer*/ 31 *presult=result; 16 32 17 33 } -
issm/trunk/src/c/objects/Elements/Beam.h
r3821 r3869 52 52 Object* copy(); 53 53 void SetClone(int* minranks); 54 void 55 void 56 void 57 void 58 void 59 void 54 void UpdateInputsFromVector(double* vector, int name, int type); 55 void UpdateInputsFromVector(int* vector, int name, int type); 56 void UpdateInputsFromVector(bool* vector, int name, int type); 57 void UpdateInputsFromConstant(double constant, int name){ISSMERROR("Not implemented yet!");} 58 void UpdateInputsFromConstant(int constant, int name){ISSMERROR("Not implemented yet!");} 59 void UpdateInputsFromConstant(bool constant, int name){ISSMERROR("Not implemented yet!");} 60 60 61 void 61 void UpdateInputsFromSolution(double* solution, int analysis_type, int sub_analysis_type); 62 62 63 63 void DepthAverageInputAtBase(int enum_type){ISSMERROR("not implemented yet");}; 64 64 /*}}}*/ 65 65 /*numerics: {{{1*/ -
issm/trunk/src/c/objects/Elements/Element.h
r3821 r3869 42 42 virtual double CostFunction(int analysis_type,int sub_analysis_type)=0; 43 43 virtual double SurfaceArea(int analysis_type,int sub_analysis_type)=0; 44 virtual void DepthAverageInputAtBase(int enum_type)=0; 44 45 virtual void ComputeBasalStress(Vec sigma_b,int analysis_type,int sub_analysis_type)=0; 45 46 virtual void ComputePressure(Vec p_g, int analysis_type,int sub_analysis_type)=0; -
issm/trunk/src/c/objects/Elements/Penta.cpp
r3864 r3869 337 337 } 338 338 else return false; 339 } 340 /*}}}*/ 341 /*FUNCTION Penta::IsOnSurface{{{1*/ 342 bool Penta::IsOnSurface(void){ 343 344 bool onsurface; 345 inputs->GetParameterValue(&onsurface,ElementOnSurfaceEnum); 346 return onsurface; 347 348 } 349 /*}}}*/ 350 /*FUNCTION Penta::GetUpperElement{{{1*/ 351 Penta* Penta::GetUpperElement(void){ 352 353 Penta* upper_penta=NULL; 354 upper_penta=(Penta*)neighbors[1]; //first one under, second one above 355 return upper_penta; 356 339 357 } 340 358 /*}}}*/ … … 2962 2980 2963 2981 } //if (extrude) 2982 } 2983 /*}}}*/ 2984 /*FUNCTION Penta::InputExtrude {{{1*/ 2985 void Penta::InputExtrude(int enum_type){ 2986 2987 bool onbed; 2988 bool onsurface; 2989 2990 Penta* penta=NULL; 2991 2992 /*recover parameters: */ 2993 inputs->GetParameterValue(&onbed,ElementOnBedEnum); 2994 inputs->GetParameterValue(&onsurface,ElementOnSurfaceEnum); 2995 2996 /*Are we on the base, not on the surface?:*/ 2997 if(onbed==1 & onsurface==0){ 2998 2999 /*this element is on the bed. We are going to, follow the upper element until we reach the surface. At each upper element, 3000 * we'll add the input of the lower element*/ 3001 3002 penta=this; 3003 3004 for(;;){ 3005 3006 /* get upper Penta*/ 3007 penta=penta->GetUpperElement(); 3008 3009 /*Add input of the basal element*/ 3010 penta->inputs->AddInput(this->inputs->GetInput(enum_type)); 3011 3012 /*Stop if we have reached the surface*/ 3013 if (penta->IsOnSurface()) break; 3014 3015 } 3016 } 3017 3018 return; 3019 } 3020 /*}}}*/ 3021 /*FUNCTION Penta::DepthAverageInputAtBase{{{1*/ 3022 void Penta::DepthAverageInputAtBase(int enum_type){ 3023 ISSMERROR("Not implemented yet (see Penta::InputExtrude and Node::FieldDepthAverageAtBase)"); 2964 3024 } 2965 3025 /*}}}*/ -
issm/trunk/src/c/objects/Elements/Penta.h
r3858 r3869 50 50 int Enum(); 51 51 int Id(); 52 bool IsInput(int name); 52 bool IsInput(int name); 53 bool IsOnSurface(void); 54 Penta* GetUpperElement(void); 53 55 void Marshall(char** pmarshalled_dataset); 54 56 int MarshallSize(); … … 98 100 void GetNodalFunctions(double* l1l6, double* gauss_coord); 99 101 void FieldExtrude(Vec field,double* field_serial,char* field_name, int iscollapsed); 102 void InputExtrude(int enum_type); 103 void DepthAverageInputAtBase(int enum_type); 100 104 void ComputeBasalStress(Vec sigma_b,int analysis_type,int sub_analysis_type); 101 105 void ComputePressure(Vec p_g,int analysis_type,int sub_analysis_type); -
issm/trunk/src/c/objects/Elements/Sing.h
r3821 r3869 61 61 void UpdateInputsFromSolution(double* solution, int analysis_type, int sub_analysis_type); 62 62 63 void DepthAverageInputAtBase(int enum_type){ISSMERROR("not implemented yet");}; 63 64 /*}}}*/ 64 65 /*numerics: {{{1*/ -
issm/trunk/src/c/objects/Elements/Tria.cpp
r3864 r3869 470 470 /*FUNCTION Tria::UpdateInputsFromSolutionPrognostic {{{1*/ 471 471 void Tria::UpdateInputsFromSolutionPrognostic(double* solution, int analysis_type, int sub_analysis_type){ 472 ISSMERROR(" not supported yet!"); 472 473 int i; 474 475 const int numvertices=3; 476 const int numdofpervertex=1; 477 const int numdof=numdofpervertex*numvertices; 478 479 int doflist[numdof]; 480 double values[numdof]; 481 double thickness[numvertices]; 482 483 int dummy; 484 485 /*Get dof list: */ 486 GetDofList(&doflist[0],&dummy); 487 488 /*Use the dof list to index into the solution vector: */ 489 for(i=0;i<numdof;i++){ 490 values[i]=solution[doflist[i]]; 491 } 492 493 /*Add thickness as inputs to the tria element: */ 494 this->inputs->AddInput(new TriaVertexInput(ThicknessEnum,values)); 473 495 } 474 496 /*}}}*/ … … 4663 4685 } 4664 4686 /*}}}*/ 4687 /*FUNCTION Tria::DepthAverageInputAtBase {{{1*/ 4688 void Tria::DepthAverageInputAtBase(int enum_type){ 4689 4690 /*New input*/ 4691 Input* oldinput=NULL; 4692 Input* newinput=NULL; 4693 4694 /*copy input of enum_type*/ 4695 oldinput=this->inputs->GetInput(enum_type); 4696 newinput=(Input*)oldinput->copy(); 4697 4698 /*Assign new name (average)*/ 4699 switch(enum_type){ 4700 4701 case VxEnum: 4702 newinput->ChangeEnum(VxAverageEnum); 4703 break; 4704 4705 case VyEnum: 4706 newinput->ChangeEnum(VyAverageEnum); 4707 break; 4708 4709 default: 4710 ISSMERROR("enum_type: %i (%s) not suppoerted yet",enum_type,EnumAsString(enum_type)); 4711 } 4712 4713 /*Add new input to current element*/ 4714 this->inputs->AddInput(newinput); 4715 4716 } 4717 /*}}}*/ -
issm/trunk/src/c/objects/Elements/Tria.h
r3834 r3869 52 52 int MyRank(); 53 53 void SetClone(int* minranks); 54 54 void DepthAverageInputAtBase(int enum_type); 55 55 /*}}}*/ 56 56 /*FUNCTION element numerical routines {{{1*/
Note:
See TracChangeset
for help on using the changeset viewer.