Changeset 13925
- Timestamp:
- 11/09/12 15:25:17 (12 years ago)
- Location:
- issm/trunk-jpl/src/c
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/Container/Loads.cpp
r13916 r13925 51 51 } 52 52 53 } 54 /*}}}*/ 55 /*FUNCTION Loads::IsPenalty{{{*/ 56 bool Loads::IsPenalty(int analysis_type){ 57 58 int ispenalty=0; 59 int allispenalty=0; 60 61 /*Now go through all loads, and get how many nodes they own, unless they are clone nodes: */ 62 for(int i=0;i<this->Size();i++){ 63 64 Load* load=dynamic_cast<Load*>(this->GetObjectByOffset(i)); 65 if (load->InAnalysis(analysis_type)){ 66 if(load->IsPenalty()) ispenalty++; 67 } 68 } 69 70 /*Grab sum of all cpus: */ 71 #ifdef _HAVE_MPI_ 72 MPI_Allreduce((void*)&ispenalty,(void*)&allispenalty,1,MPI_INT,MPI_SUM,IssmComm::GetComm()); 73 ispenalty=allispenalty; 74 #endif 75 76 if(ispenalty) 77 return true; 78 else 79 return false; 53 80 } 54 81 /*}}}*/ -
issm/trunk-jpl/src/c/Container/Loads.h
r13916 r13925 26 26 /*numerics*/ 27 27 void Configure(Elements* elements,Loads* loads, Nodes* nodes, Vertices* vertices, Materials* materials,Parameters* parameters); 28 bool IsPenalty(int analysis); 28 29 int MaxNumNodes(int analysis); 29 30 int NumberOfLoads(void); -
issm/trunk-jpl/src/c/classes/FemModel.cpp
r13918 r13925 353 353 Vector<IssmDouble> *df = NULL; 354 354 355 //bool oldalloc=false;356 355 bool oldalloc=true; 357 356 … … 369 368 370 369 if(oldalloc){ 371 Kff=new Matrix<IssmDouble>(fsize,fsize,connectivity,numberofdofspernode);372 Kfs=new Matrix<IssmDouble>(fsize,ssize,connectivity,numberofdofspernode);373 df =new Vector<IssmDouble>(fsize);374 pf =new Vector<IssmDouble>(fsize);370 if(pKff) Kff=new Matrix<IssmDouble>(fsize,fsize,connectivity,numberofdofspernode); 371 if(pKfs) Kfs=new Matrix<IssmDouble>(fsize,ssize,connectivity,numberofdofspernode); 372 if(pdf) df =new Vector<IssmDouble>(fsize); 373 if(ppf) pf =new Vector<IssmDouble>(fsize); 375 374 } 376 375 else{ 377 /*Kff*/ 378 m=flocalsize; n=flocalsize; /*local sizes*/ 379 M=fsize; N=fsize; /*global sizes*/ 380 this->MatrixNonzeros(&d_nnz,&o_nnz,FsetEnum,FsetEnum); 381 Kff=new Matrix<IssmDouble>(m,n,M,N,d_nnz,o_nnz); 382 xDelete<int>(d_nnz); 383 xDelete<int>(o_nnz); 384 385 /*Kfs*/ 386 m=flocalsize; n=slocalsize; /*local sizes*/ 387 M=fsize; N=ssize; /*global sizes*/ 388 this->MatrixNonzeros(&d_nnz,&o_nnz,FsetEnum,SsetEnum); 389 Kfs=new Matrix<IssmDouble>(m,n,M,N,d_nnz,o_nnz); 390 xDelete<int>(d_nnz); 391 xDelete<int>(o_nnz); 392 393 /*Vectors*/ 394 df =new Vector<IssmDouble>(flocalsize,fsize); 395 pf =new Vector<IssmDouble>(flocalsize,fsize); 376 if(pKff){ 377 m=flocalsize; n=flocalsize; /*local sizes*/ 378 M=fsize; N=fsize; /*global sizes*/ 379 this->MatrixNonzeros(&d_nnz,&o_nnz,FsetEnum,FsetEnum); 380 Kff=new Matrix<IssmDouble>(m,n,M,N,d_nnz,o_nnz); 381 xDelete<int>(d_nnz); 382 xDelete<int>(o_nnz); 383 } 384 if(pKfs){ 385 m=flocalsize; n=slocalsize; /*local sizes*/ 386 M=fsize; N=ssize; /*global sizes*/ 387 this->MatrixNonzeros(&d_nnz,&o_nnz,FsetEnum,SsetEnum); 388 Kfs=new Matrix<IssmDouble>(m,n,M,N,d_nnz,o_nnz); 389 xDelete<int>(d_nnz); 390 xDelete<int>(o_nnz); 391 } 392 if(pdf) df =new Vector<IssmDouble>(flocalsize,fsize); 393 if(ppf) pf =new Vector<IssmDouble>(flocalsize,fsize); 396 394 } 397 395 398 396 /*Allocate output pointers*/ 399 *pKff = Kff;400 *pKfs = Kfs;401 *pdf = df;402 *ppf = pf;397 if(pKff) *pKff = Kff; 398 if(pKfs) *pKfs = Kfs; 399 if(pdf) *pdf = df; 400 if(ppf) *ppf = pf; 403 401 } 404 402 /*}}}*/ … … 770 768 Vector<IssmDouble> *pf = NULL; 771 769 Vector<IssmDouble> *df = NULL; 772 IssmDouble kmax ;770 IssmDouble kmax = 0; 773 771 774 772 /*Display message*/ … … 778 776 this->parameters->FindParam(&configuration_type,ConfigurationTypeEnum); 779 777 780 /*Compute penalty free mstiffness matrix and load vector*/ 778 /*First, we might need to do a dry run to get kmax if penalties are employed*/ 779 if(loads->IsPenalty(configuration_type)){ 780 781 /*Allocate Kff_temp*/ 782 Matrix<IssmDouble> *Kff_temp = NULL; 783 this->AllocateSystemMatrices(&Kff_temp,NULL,NULL,NULL); 784 785 /*Get complete stiffness matrix without penalties*/ 786 for (i=0;i<this->elements->Size();i++){ 787 element=dynamic_cast<Element*>(this->elements->GetObjectByOffset(i)); 788 element->CreateKMatrix(Kff_temp,NULL,NULL); 789 } 790 for (i=0;i<this->loads->Size();i++){ 791 load=dynamic_cast<Load*>(this->loads->GetObjectByOffset(i)); 792 if(load->InAnalysis(configuration_type)) load->CreateKMatrix(Kff_temp,NULL); 793 } 794 Kff_temp->Assemble(); 795 796 /*Now, figure out maximum value of stiffness matrix, so that we can penalize it correctly: */ 797 kmax=Kff_temp->Norm(NORM_INF); 798 delete Kff_temp; 799 } 800 801 /*Allocate stiffness matrices and load vector*/ 781 802 this->AllocateSystemMatrices(&Kff,&Kfs,&df,&pf); 782 803 … … 788 809 for (i=0;i<this->loads->Size();i++){ 789 810 load=dynamic_cast<Load*>(this->loads->GetObjectByOffset(i)); 790 if 811 if(load->InAnalysis(configuration_type)) load->CreateKMatrix(Kff,Kfs); 791 812 } 792 813 … … 798 819 for (i=0;i<this->loads->Size();i++){ 799 820 load=dynamic_cast<Load*>(this->loads->GetObjectByOffset(i)); 800 if (load->InAnalysis(configuration_type)) load->CreatePVector(pf); 801 } 802 803 /*Assemble matrices (required to get kmax)*/ 804 Kff->Assemble(); 805 Kfs->Assemble(); 806 df->Assemble(); 807 808 /*Now, figure out maximum value of stiffness matrix, so that we can penalize it correctly: */ 809 kmax=Kff->Norm(NORM_INF); 810 811 /*Now that we have kmax, deal with penalties (only in loads)*/ 812 for (i=0;i<this->loads->Size();i++){ 813 load=dynamic_cast<Load*>(this->loads->GetObjectByOffset(i)); 814 if (load->InAnalysis(configuration_type)) load->PenaltyCreateKMatrix(Kff,Kfs,kmax); 815 } 816 for (i=0;i<this->loads->Size();i++){ 817 load=dynamic_cast<Load*>(this->loads->GetObjectByOffset(i)); 818 if (load->InAnalysis(configuration_type)) load->PenaltyCreatePVector(pf,kmax); 821 if(load->InAnalysis(configuration_type)) load->CreatePVector(pf); 822 } 823 824 /*Now deal with penalties (only in loads)*/ 825 if(loads->IsPenalty(configuration_type)){ 826 for (i=0;i<this->loads->Size();i++){ 827 load=dynamic_cast<Load*>(this->loads->GetObjectByOffset(i)); 828 if(load->InAnalysis(configuration_type)) load->PenaltyCreateKMatrix(Kff,Kfs,kmax); 829 } 830 for (i=0;i<this->loads->Size();i++){ 831 load=dynamic_cast<Load*>(this->loads->GetObjectByOffset(i)); 832 if(load->InAnalysis(configuration_type)) load->PenaltyCreatePVector(pf,kmax); 833 } 819 834 } 820 835 … … 823 838 Kfs->Assemble(); 824 839 pf->Assemble(); 840 df->Assemble(); 825 841 //Kff->AllocationInfo(); 826 842 //Kfs->AllocationInfo(); -
issm/trunk-jpl/src/c/classes/objects/Loads/Icefront.cpp
r13915 r13925 316 316 } 317 317 318 } 319 /*}}}*/ 320 /*FUNCTION Icefront::IsPenalty{{{*/ 321 bool Icefront::IsPenalty(void){ 322 return false; 318 323 } 319 324 /*}}}*/ -
issm/trunk-jpl/src/c/classes/objects/Loads/Icefront.h
r13915 r13925 73 73 int GetNumberOfNodes(void); 74 74 void GetNodesSidList(int* sidlist); 75 bool IsPenalty(void); 75 76 void PenaltyCreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* kfs, IssmDouble kmax); 76 77 void PenaltyCreatePVector(Vector<IssmDouble>* pf, IssmDouble kmax); -
issm/trunk-jpl/src/c/classes/objects/Loads/Load.h
r13915 r13925 25 25 virtual ~Load(){}; 26 26 virtual void Configure(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters)=0; 27 virtual bool IsPenalty(void)=0; 27 28 virtual int GetNumberOfNodes(void)=0; 28 29 virtual void GetNodesSidList(int* sidlist)=0; -
issm/trunk-jpl/src/c/classes/objects/Loads/Numericalflux.cpp
r13915 r13925 340 340 } 341 341 342 } 343 /*}}}*/ 344 /*FUNCTION Numericalflux::IsPenalty{{{*/ 345 bool Numericalflux::IsPenalty(void){ 346 return false; 342 347 } 343 348 /*}}}*/ -
issm/trunk-jpl/src/c/classes/objects/Loads/Numericalflux.h
r13915 r13925 67 67 int GetNumberOfNodes(void); 68 68 void CreateJacobianMatrix(Matrix<IssmDouble>* Jff){_error_("Not implemented yet");}; 69 bool IsPenalty(void); 69 70 void PenaltyCreateJacobianMatrix(Matrix<IssmDouble>* Jff,IssmDouble kmax){_error_("Not implemented yet");}; 70 71 void PenaltyCreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* kfs, IssmDouble kmax); -
issm/trunk-jpl/src/c/classes/objects/Loads/Pengrid.cpp
r13915 r13925 293 293 if (in_analysis_type==this->analysis_type)return true; 294 294 else return false; 295 } 296 /*}}}*/ 297 /*FUNCTION Pengrid::IsPenalty{{{*/ 298 bool Pengrid::IsPenalty(void){ 299 return true; 295 300 } 296 301 /*}}}*/ -
issm/trunk-jpl/src/c/classes/objects/Loads/Pengrid.h
r13915 r13925 74 74 void GetNodesSidList(int* sidlist); 75 75 int GetNumberOfNodes(void); 76 bool IsPenalty(void); 76 77 void PenaltyCreateJacobianMatrix(Matrix<IssmDouble>* Jff,IssmDouble kmax){_error_("Not implemented yet");}; 77 78 void PenaltyCreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* kfs, IssmDouble kmax); -
issm/trunk-jpl/src/c/classes/objects/Loads/Penpair.cpp
r13915 r13925 161 161 162 162 return NUMVERTICES; 163 } 164 /*}}}*/ 165 /*FUNCTION Penpair::IsPenalty{{{*/ 166 bool Penpair::IsPenalty(void){ 167 return true; 163 168 } 164 169 /*}}}*/ -
issm/trunk-jpl/src/c/classes/objects/Loads/Penpair.h
r13915 r13925 59 59 void GetNodesSidList(int* sidlist); 60 60 int GetNumberOfNodes(void); 61 bool IsPenalty(void); 61 62 void PenaltyCreateKMatrix(Matrix<IssmDouble>* Kff,Matrix<IssmDouble>* Kfs,IssmDouble kmax); 62 63 void PenaltyCreatePVector(Vector<IssmDouble>* pf, IssmDouble kmax); -
issm/trunk-jpl/src/c/classes/objects/Loads/Riftfront.cpp
r13915 r13925 293 293 this->parameters=parametersin; 294 294 295 } 296 /*}}}*/ 297 /*FUNCTION Riftfront::IsPenalty{{{*/ 298 bool Riftfront::IsPenalty(void){ 299 return true; 295 300 } 296 301 /*}}}*/ -
issm/trunk-jpl/src/c/classes/objects/Loads/Riftfront.h
r13915 r13925 80 80 void GetNodesSidList(int* sidlist); 81 81 int GetNumberOfNodes(void); 82 bool IsPenalty(void); 82 83 void PenaltyCreateJacobianMatrix(Matrix<IssmDouble>* Jff,IssmDouble kmax){_error_("Not implemented yet");}; 83 84 void PenaltyCreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* kfs, IssmDouble kmax); -
issm/trunk-jpl/src/c/modules/Reducevectorgtofx/Reducevectorgtofx.cpp
r13622 r13925 12 12 13 13 /*variables: */ 14 int i;15 int configuration_type;16 int fsize;17 IssmDouble* ug_serial=NULL;14 int configuration_type; 15 int fsize; 16 IssmDouble *ug_serial = NULL; 17 bool oldalloc = true; 18 18 19 19 /*first figure out fsize: */ 20 20 parameters->FindParam(&configuration_type,ConfigurationTypeEnum); 21 21 fsize=nodes->NumberOfDofs(configuration_type,FsetEnum); 22 23 int analysis_type; 24 parameters->FindParam(&analysis_type,AnalysisTypeEnum); 25 int flocalsize = nodes->NumberOfDofsLocal(analysis_type,FsetEnum); 22 26 23 27 if(fsize==0){ … … 26 30 else{ 27 31 /*allocate: */ 28 uf=new Vector<IssmDouble>(fsize); 32 if(oldalloc) 33 uf=new Vector<IssmDouble>(fsize); 34 else 35 uf=new Vector<IssmDouble>(flocalsize,fsize); 29 36 30 37 if(nodes->NumberOfNodes(configuration_type)){ … … 34 41 35 42 /*Go through all nodes, and ask them to retrieve values from ug, and plug them into uf: */ 36 for(i =0;i<nodes->Size();i++){43 for(int i=0;i<nodes->Size();i++){ 37 44 38 45 Node* node=(Node*)nodes->GetObjectByOffset(i); -
issm/trunk-jpl/src/c/toolkits/petsc/objects/PetscMat.cpp
r13893 r13925 40 40 } 41 41 /*}}}*/ 42 /*FUNCTION PetscMat::PetscMat(int M,int N, IssmDouble sparsity){{{*/42 /*FUNCTION PetscMat::PetscMat(int m,int n,int M,int N,int* d_nnz,int* o_nnz){{{*/ 43 43 PetscMat::PetscMat(int m,int n,int M,int N,int* d_nnz,int* o_nnz){ 44 44
Note:
See TracChangeset
for help on using the changeset viewer.