Changeset 5772
- Timestamp:
- 09/13/10 13:18:07 (15 years ago)
- Location:
- issm/trunk/src
- Files:
-
- 13 added
- 48 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/Container/Constraints.cpp
r5057 r5772 63 63 } 64 64 /*}}}*/ 65 /*FUNCTION Constraints::SetupSpcs{{{1*/66 void Constraints::SetupSpcs(Nodes* nodes,Vec yg,int analysis_type){67 68 int i;69 70 Node* node=NULL;71 int nodeid;72 int dof;73 double value;74 75 for(i=0;i<this->Size();i++){76 77 Object* object=(Object*)this->GetObjectByOffset(i);78 79 /*Check this is a single point constraint (spc): */80 if(object->Enum()==SpcEnum){81 82 Spc* spc=(Spc*)object;83 84 if(spc->InAnalysis(analysis_type)){85 86 /*Ok, this object is a constraint. Get the nodeid from the node it applies to: */87 nodeid=spc->GetNodeId();88 dof=spc->GetDof();89 value=spc->GetValue();90 91 /*Now, chase through nodes and find the corect node: */92 node=(Node*)nodes->GetObjectById(NULL,nodeid);93 94 /*Apply constraint: */95 if(node){ //in case the spc is dealing with a node on another cpu96 node->ApplyConstraint(yg,dof,value);97 }98 }99 100 }101 }102 103 /*Assemble yg: */104 VecAssemblyBegin(yg);105 VecAssemblyEnd(yg);106 }107 /*}}}*/ -
issm/trunk/src/c/Container/Constraints.h
r5057 r5772 28 28 /*numerics: {{{1*/ 29 29 int NumberOfConstraints(void); 30 void SetupSpcs(Nodes* nodes,Vec yg,int analysis_type);31 30 /*}}}*/ 32 31 -
issm/trunk/src/c/Container/Nodes.cpp
r5296 r5772 44 44 /*Numerics*/ 45 45 /*FUNCTION Nodes::DistributeDofs{{{1*/ 46 void Nodes::DistributeDofs(int analysis_type ){46 void Nodes::DistributeDofs(int analysis_type,int setenum){ 47 47 48 48 extern int num_procs; … … 58 58 int numnodes=0; 59 59 60 /*some check: */ 61 if ((setenum!=GsetEnum) && (setenum!=FsetEnum) && (setenum!=SsetEnum))ISSMERROR("%s%s%s"," dof distribution for set of enum type ",EnumToString(setenum)," not supported yet!"); 62 60 63 /*Go through objects, and distribute dofs locally, from 0 to numberofdofs: */ 61 64 for (i=0;i<this->Size();i++){ … … 64 67 /*Check that this node corresponds to our analysis currently being carried out: */ 65 68 if (node->InAnalysis(analysis_type)){ 66 node->DistributeDofs(&dofcount); 67 } 68 } 69 70 69 node->DistributeDofs(&dofcount,setenum); 70 } 71 } 71 72 72 73 /*Ok, now every object has distributed dofs, but locally, and with a dof count starting from … … 96 97 Node* node=(Node*)this->GetObjectByOffset(i); 97 98 if (node->InAnalysis(analysis_type)){ 98 node->OffsetDofs(dofcount );99 node->OffsetDofs(dofcount,setenum); 99 100 } 100 101 … … 104 105 * object that is not a clone, tell them to show their dofs, so that later on, they can get picked 105 106 * up by their clones: */ 106 maxdofspernode=this->MaxNumDofs(analysis_type );107 maxdofspernode=this->MaxNumDofs(analysis_type,setenum); 107 108 numnodes=this->NumberOfNodes(analysis_type); 108 109 … … 114 115 Node* node=(Node*)this->GetObjectByOffset(i); 115 116 if (node->InAnalysis(analysis_type)){ 116 node->ShowTrueDofs(truedofs,maxdofspernode );//give maxdofspernode, column size, so that nodes can index into truedofs117 node->ShowTrueDofs(truedofs,maxdofspernode,setenum);//give maxdofspernode, column size, so that nodes can index into truedofs 117 118 } 118 119 } … … 125 126 Node* node=(Node*)this->GetObjectByOffset(i); 126 127 if (node->InAnalysis(analysis_type)){ 127 node->UpdateCloneDofs(alltruedofs,maxdofspernode ); //give maxdofspernode, column size, so that nodes can index into alltruedofs128 node->UpdateCloneDofs(alltruedofs,maxdofspernode,setenum); //give maxdofspernode, column size, so that nodes can index into alltruedofs 128 129 } 129 130 } … … 215 216 /*}}}*/ 216 217 /*FUNCTION Nodes::NumberOfDofs{{{1*/ 217 int Nodes::NumberOfDofs(int analysis_type ){218 int Nodes::NumberOfDofs(int analysis_type,int setenum){ 218 219 219 220 int i; … … 233 234 if (!node->IsClone()){ 234 235 235 numdofs+=node->GetNumberOfDofs( );236 numdofs+=node->GetNumberOfDofs(NoneApproximationEnum,setenum); 236 237 237 238 } … … 241 242 /*Gather from all cpus: */ 242 243 MPI_Allreduce ( (void*)&numdofs,(void*)&allnumdofs,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD); 243 244 244 return allnumdofs; 245 245 } … … 335 335 /*}}}*/ 336 336 /*FUNCTION Nodes::MaxNumDofs{{{1*/ 337 int Nodes::MaxNumDofs(int analysis_type ){337 int Nodes::MaxNumDofs(int analysis_type,int setenum){ 338 338 339 339 int i; … … 350 350 if (node->InAnalysis(analysis_type)){ 351 351 352 numdofs=node->GetNumberOfDofs( );352 numdofs=node->GetNumberOfDofs(NoneApproximationEnum,setenum); 353 353 if (numdofs>max)max=numdofs; 354 354 } -
issm/trunk/src/c/Container/Nodes.h
r5114 r5772 19 19 /*}}}*/ 20 20 /*numerics: {{{1*/ 21 void DistributeDofs(int analysis_type );21 void DistributeDofs(int analysis_type,int SETENUM); 22 22 void FlagClones(int analysis_type); 23 23 void FlagNodeSets(Vec pv_g, Vec pv_f, Vec pv_s,int analysis_type); 24 int NumberOfDofs(int analysis_type );24 int NumberOfDofs(int analysis_type,int setenum); 25 25 int NumberOfNodes(int analysis_type); 26 26 int NumberOfNodes(void); 27 27 void Ranks(int* ranks,int analysis_type); 28 int MaxNumDofs(int analysis_type );28 int MaxNumDofs(int analysis_type,int setenum); 29 29 /*}}}*/ 30 30 -
issm/trunk/src/c/Makefile.am
r5740 r5772 172 172 ./objects/Loads/Numericalflux.cpp\ 173 173 ./objects/Loads/Numericalflux.h\ 174 ./objects/Numerics/ElementMatrix.h\ 175 ./objects/Numerics/ElementMatrix.cpp\ 176 ./objects/Numerics/ElementVector.h\ 177 ./objects/Numerics/ElementVector.cpp\ 174 178 ./objects/Params/Param.h\ 175 179 ./objects/Params/BoolParam.cpp\ … … 448 452 ./modules/CostFunctionx/CostFunctionx.h\ 449 453 ./modules/CostFunctionx/CostFunctionx.cpp\ 454 ./modules/CreateNodalConstraintsx/CreateNodalConstraintsx.h\ 455 ./modules/CreateNodalConstraintsx/CreateNodalConstraintsx.cpp\ 450 456 ./modules/Orthx/Orthx.h\ 451 457 ./modules/Orthx/Orthx.cpp\ … … 524 530 ./modules/Reduceloadfromgtofx/Reduceloadfromgtofx.h\ 525 531 ./modules/Reduceloadfromgtofx/Reduceloadfromgtofx.cpp\ 532 ./modules/Reduceloadx/Reduceloadx.h\ 533 ./modules/Reduceloadx/Reduceloadx.cpp\ 526 534 ./modules/NodeConnectivityx/NodeConnectivityx.cpp\ 527 535 ./modules/NodeConnectivityx/NodeConnectivityx.h\ … … 723 731 ./objects/Loads/Numericalflux.cpp\ 724 732 ./objects/Loads/Numericalflux.h\ 733 ./objects/Numerics/ElementMatrix.h\ 734 ./objects/Numerics/ElementMatrix.cpp\ 735 ./objects/Numerics/ElementVector.h\ 736 ./objects/Numerics/ElementVector.cpp\ 725 737 ./objects/Params/Param.h\ 726 738 ./objects/Params/BoolParam.cpp\ … … 996 1008 ./modules/CostFunctionx/CostFunctionx.h\ 997 1009 ./modules/CostFunctionx/CostFunctionx.cpp\ 1010 ./modules/CreateNodalConstraintsx/CreateNodalConstraintsx.h\ 1011 ./modules/CreateNodalConstraintsx/CreateNodalConstraintsx.cpp\ 998 1012 ./modules/Orthx/Orthx.h\ 999 1013 ./modules/Orthx/Orthx.cpp\ … … 1070 1084 ./modules/Reduceloadfromgtofx/Reduceloadfromgtofx.h\ 1071 1085 ./modules/Reduceloadfromgtofx/Reduceloadfromgtofx.cpp\ 1086 ./modules/Reduceloadx/Reduceloadx.h\ 1087 ./modules/Reduceloadx/Reduceloadx.cpp\ 1072 1088 ./modules/MassFluxx/MassFluxx.cpp\ 1073 1089 ./modules/MassFluxx/MassFluxx.h\ … … 1128 1144 ./solvers/solver_adjoint_linear.cpp\ 1129 1145 ./solvers/solver_diagnostic_nonlinear.cpp\ 1146 ./solvers/solver_diagnostic_nonlinear_kgg.cpp\ 1147 ./solvers/solver_diagnostic_nonlinear_kff.cpp\ 1130 1148 ./solvers/solver_thermal_nonlinear.cpp\ 1131 1149 ./modules/Bamgx/Bamgx.cpp\ -
issm/trunk/src/c/modules/BuildNodeSetsx/BuildNodeSetsx.cpp
r5057 r5772 29 29 30 30 /*Get gsize; */ 31 gsize=nodes->NumberOfDofs(analysis_type );31 gsize=nodes->NumberOfDofs(analysis_type,GsetEnum); 32 32 33 33 if(gsize){ -
issm/trunk/src/c/modules/GetSolutionFromInputsx/GetSolutionFromInputsx.cpp
r5103 r5772 25 25 26 26 /*Get size of vector: */ 27 gsize=nodes->NumberOfDofs(configuration_type );27 gsize=nodes->NumberOfDofs(configuration_type,GsetEnum); 28 28 if (gsize==0) ISSMERROR("Allocating a Vec of size 0 as gsize=0 for configuration: %s",EnumToString(configuration_type)); 29 29 -
issm/trunk/src/c/modules/ModelProcessorx/CreateParameters.cpp
r5578 r5772 66 66 parameters->AddObject(new StringParam(SolverStringEnum,iomodel->solverstring)); 67 67 parameters->AddObject(new IntParam(NumberOfElementsEnum,iomodel->numberofelements)); 68 parameters->AddObject(new BoolParam(KffEnum,iomodel->kff)); 68 69 69 70 /*Deal with more complex parameters*/ -
issm/trunk/src/c/modules/NodesDofx/NodesDofx.cpp
r5114 r5772 26 26 *a node has already been distributed dofs on one cpu, all other cpus with the same node cannot distribute it 27 27 *anymore. Use clone field to be sure of that: */ 28 nodes->DistributeDofs(analysis_type); 29 28 nodes->DistributeDofs(analysis_type,GsetEnum); 29 nodes->DistributeDofs(analysis_type,FsetEnum); 30 nodes->DistributeDofs(analysis_type,SsetEnum); 30 31 } 31 32 -
issm/trunk/src/c/modules/SpcNodesx/SpcNodesx.cpp
r4217 r5772 10 10 #include "../../EnumDefinitions/EnumDefinitions.h" 11 11 12 void SpcNodesx( Vec* pyg,Nodes* nodes,Constraints* constraints,int analysis_type){12 void SpcNodesx(Nodes* nodes,Constraints* constraints,int analysis_type){ 13 13 14 14 int i; 15 int numberofdofs; 16 int gsize; 15 Node* node=NULL; 16 int nodeid; 17 int dof; 18 double value; 17 19 18 /*output: */ 19 Vec yg=NULL; 20 for(i=0;i<constraints->Size();i++){ 20 21 21 /*First, recover number of dofs from nodes: */ 22 numberofdofs=nodes->NumberOfDofs(analysis_type); 22 Object* object=(Object*)constraints->GetObjectByOffset(i); 23 23 24 if(numberofdofs){ 25 26 /*Allocate yg: */ 27 yg=NewVec(numberofdofs); 24 /*Check constraints is a single point constraint (spc): */ 25 if(object->Enum()==SpcEnum){ 28 26 29 /*Now, go through constraints, and update the nodes and the constraint vector at the same time: */ 30 constraints->SetupSpcs(nodes,yg,analysis_type); 27 Spc* spc=(Spc*)object; 31 28 32 /*Specify numentries: */ 33 VecGetSize(yg,&gsize); 29 if(spc->InAnalysis(analysis_type)){ 30 31 /*Ok, constraints object is a constraint. Get the nodeid from the node it applies to: */ 32 nodeid=spc->GetNodeId(); 33 dof=spc->GetDof(); 34 value=spc->GetValue(); 35 36 /*Now, chase through nodes and find the corect node: */ 37 node=(Node*)nodes->GetObjectById(NULL,nodeid); 38 39 /*Apply constraint: */ 40 if(node){ //in case the spc is dealing with a node on another cpu 41 node->ApplyConstraint(dof,value); 42 } 43 } 44 45 } 34 46 } 35 47 36 /*Assign output pointers: */37 *pyg=yg;38 48 } -
issm/trunk/src/c/modules/SpcNodesx/SpcNodesx.h
r4236 r5772 11 11 12 12 /* local prototypes: */ 13 void SpcNodesx( Vec* pyg,Nodes* nodesin,Constraints* constraints,int analysis_type);13 void SpcNodesx(Nodes* nodesin,Constraints* constraints,int analysis_type); 14 14 15 15 #endif /* _SPCNODESX_H */ -
issm/trunk/src/c/modules/SystemMatricesx/SystemMatricesx.cpp
r5703 r5772 9 9 #include "../../EnumDefinitions/EnumDefinitions.h" 10 10 11 void SystemMatricesx(Mat* pKgg, Vec* ppg,double* pkmax,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters,bool kflag,bool pflag,bool penalty_kflag,bool penalty_pflag){11 void SystemMatricesx(Mat* pKgg, Mat* pKff, Mat* pKfs, Vec* ppg, Vec* ppf, double* pkmax,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters,bool kflag,bool pflag,bool penalty_kflag,bool penalty_pflag){ 12 12 13 13 /*intermediary: */ 14 int i,j,gsize; 14 int i,j; 15 int gsize,fsize,ssize; 15 16 int connectivity, numberofdofspernode; 16 17 int analysis_type, configuration_type; 17 18 Element *element = NULL; 18 19 Load *load = NULL; 20 bool buildkff=false; 19 21 20 22 /*output: */ 21 23 Mat Kgg = NULL; 24 Mat Kff = NULL; 25 Mat Kfs = NULL; 22 26 Vec pg = NULL; 27 Vec pf = NULL; 23 28 double kmax = 0; 24 29 … … 31 36 parameters->FindParam(&configuration_type,ConfigurationTypeEnum); 32 37 parameters->FindParam(&connectivity,ConnectivityEnum); 38 parameters->FindParam(&buildkff,KffEnum); 33 39 34 40 /*Get size of matrix: */ 35 gsize=nodes->NumberOfDofs(configuration_type); 36 numberofdofspernode=nodes->MaxNumDofs(configuration_type); 41 gsize=nodes->NumberOfDofs(configuration_type,GsetEnum); 42 fsize=nodes->NumberOfDofs(configuration_type,FsetEnum); 43 ssize=nodes->NumberOfDofs(configuration_type,SsetEnum); 44 numberofdofspernode=nodes->MaxNumDofs(configuration_type,GsetEnum); 37 45 38 46 /*Checks in debugging mode {{{1*/ … … 46 54 if(kflag){ 47 55 48 Kgg=NewMat(gsize,gsize,NULL,&connectivity,&numberofdofspernode); 56 if(!buildkff)Kgg=NewMat(gsize,gsize,NULL,&connectivity,&numberofdofspernode); 57 else{ 58 Kff=NewMat(fsize,fsize,NULL,&connectivity,&numberofdofspernode); 59 Kfs=NewMat(fsize,ssize,NULL,&connectivity,&numberofdofspernode); 60 } 49 61 50 62 /*Fill stiffness matrix from elements: */ 51 63 for (i=0;i<elements->Size();i++){ 52 64 element=(Element*)elements->GetObjectByOffset(i); 53 element->CreateKMatrix(Kgg );65 element->CreateKMatrix(Kgg,Kff,Kfs); 54 66 } 55 67 … … 57 69 for (i=0;i<loads->Size();i++){ 58 70 load=(Load*)loads->GetObjectByOffset(i); 59 if (load->InAnalysis(configuration_type)) load->CreateKMatrix(Kgg );71 if (load->InAnalysis(configuration_type)) load->CreateKMatrix(Kgg,Kff,Kfs); 60 72 } 61 73 62 74 /*Assemble matrix and compress matrix to save memory: */ 63 MatAssemblyBegin(Kgg,MAT_FINAL_ASSEMBLY); 64 MatAssemblyEnd(Kgg,MAT_FINAL_ASSEMBLY); 65 MatCompress(Kgg); 75 if(!buildkff){ 76 MatAssemblyBegin(Kgg,MAT_FINAL_ASSEMBLY); 77 MatAssemblyEnd(Kgg,MAT_FINAL_ASSEMBLY); 78 MatCompress(Kgg); 79 } 80 else{ 81 MatAssemblyBegin(Kff,MAT_FINAL_ASSEMBLY); 82 MatAssemblyEnd(Kff,MAT_FINAL_ASSEMBLY); 83 MatCompress(Kff); 84 85 MatAssemblyBegin(Kfs,MAT_FINAL_ASSEMBLY); 86 MatAssemblyEnd(Kfs,MAT_FINAL_ASSEMBLY); 87 MatCompress(Kfs); 88 } 66 89 } 67 90 if(pflag){ … … 72 95 for (i=0;i<elements->Size();i++){ 73 96 element=(Element*)elements->GetObjectByOffset(i); 74 element->CreatePVector(pg );97 element->CreatePVector(pg,pf); 75 98 } 76 99 … … 78 101 for (i=0;i<loads->Size();i++){ 79 102 load=(Load*)loads->GetObjectByOffset(i); 80 if (load->InAnalysis(configuration_type)) load->CreatePVector(pg );103 if (load->InAnalysis(configuration_type)) load->CreatePVector(pg,pf); 81 104 } 82 105 83 VecAssemblyBegin(pg); 84 VecAssemblyEnd(pg); 106 if(!buildkff){ 107 VecAssemblyBegin(pg); 108 VecAssemblyEnd(pg); 109 } 110 else{ 111 VecAssemblyBegin(pf); 112 VecAssemblyEnd(pf); 113 } 85 114 } 86 115 116 87 117 /*Now, deal with penalties*/ 88 118 if(penalty_kflag){ 89 119 90 120 /*Now, figure out maximum value of K_gg, so that we can penalize it correctly: */ 91 MatNorm(Kgg,NORM_INFINITY,&kmax); 121 if(!buildkff)MatNorm(Kgg,NORM_INFINITY,&kmax); 122 else MatNorm(Kff,NORM_INFINITY,&kmax); 92 123 93 124 /*Fill stiffness matrix from loads: */ 94 125 for (i=0;i<loads->Size();i++){ 95 126 load=(Load*)loads->GetObjectByOffset(i); 96 if (load->InAnalysis(configuration_type)) load->PenaltyCreateKMatrix(Kgg, kmax);127 if (load->InAnalysis(configuration_type)) load->PenaltyCreateKMatrix(Kgg,Kff,Kfs,kmax); 97 128 } 98 129 99 130 /*Assemble matrix and compress matrix to save memory: */ 100 MatAssemblyBegin(Kgg,MAT_FINAL_ASSEMBLY); 101 MatAssemblyEnd(Kgg,MAT_FINAL_ASSEMBLY); 102 MatCompress(Kgg); 131 if(!buildkff){ 132 MatAssemblyBegin(Kgg,MAT_FINAL_ASSEMBLY); 133 MatAssemblyEnd(Kgg,MAT_FINAL_ASSEMBLY); 134 MatCompress(Kgg); 135 } 136 else{ 137 MatAssemblyBegin(Kff,MAT_FINAL_ASSEMBLY); 138 MatAssemblyEnd(Kff,MAT_FINAL_ASSEMBLY); 139 MatCompress(Kff); 140 141 MatAssemblyBegin(Kfs,MAT_FINAL_ASSEMBLY); 142 MatAssemblyEnd(Kfs,MAT_FINAL_ASSEMBLY); 143 MatCompress(Kfs); 144 } 103 145 } 104 146 if(penalty_pflag){ … … 107 149 for (i=0;i<loads->Size();i++){ 108 150 load=(Load*)loads->GetObjectByOffset(i); 109 if (load->InAnalysis(configuration_type)) load->PenaltyCreatePVector(pg, kmax);151 if (load->InAnalysis(configuration_type)) load->PenaltyCreatePVector(pg,pf,kmax); 110 152 } 111 153 112 VecAssemblyBegin(pg); 113 VecAssemblyEnd(pg); 154 if(!buildkff){ 155 VecAssemblyBegin(pg); 156 VecAssemblyEnd(pg); 157 } 158 else{ 159 VecAssemblyBegin(pf); 160 VecAssemblyEnd(pf); 161 } 114 162 } 115 163 116 164 /*Assign output pointers: */ 117 *pKgg=Kgg; 118 *ppg=pg; 165 if(pKgg) *pKgg=Kgg; 166 if(pKff) *pKff=Kff; 167 if(pKfs) *pKfs=Kfs; 168 if(ppg) *ppg=pg; 169 if(ppf) *ppf=pf; 119 170 if(pkmax) *pkmax=kmax; 120 171 } -
issm/trunk/src/c/modules/SystemMatricesx/SystemMatricesx.h
r5693 r5772 10 10 11 11 /* local prototypes: */ 12 void SystemMatricesx(Mat* pKgg, Vec* ppg,double* pkmax,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters,12 void SystemMatricesx(Mat* pKgg, Mat* pKff, Mat* pKfs, Vec* ppg, Vec* ppf, double* pkmax,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters, 13 13 bool kflag=true,bool pflag=true,bool penalty_kflag=true,bool penalty_pflag=true); 14 14 -
issm/trunk/src/c/modules/modules.h
r5709 r5772 20 20 #include "./ContourToNodesx/ContourToNodesx.h" 21 21 #include "./CostFunctionx/CostFunctionx.h" 22 #include "./CreateNodalConstraintsx/CreateNodalConstraintsx.h" 22 23 #include "./DakotaResponsesx/DakotaResponsesx.h" 23 24 #include "./ElementConnectivityx/ElementConnectivityx.h" … … 72 73 #include "./Qmux/Qmux.h" 73 74 #include "./Reduceloadfromgtofx/Reduceloadfromgtofx.h" 75 #include "./Reduceloadx/Reduceloadx.h" 74 76 #include "./Reducematrixfromgtofx/Reducematrixfromgtofx.h" 75 77 #include "./Reducevectorgtosx/Reducevectorgtosx.h" -
issm/trunk/src/c/objects/DofIndexing.cpp
r5254 r5772 21 21 DofIndexing::DofIndexing(){ 22 22 23 int i; 24 this->numberofdofs=UNDEF; 23 this->gsize=UNDEF; 24 this->fsize=UNDEF; 25 this->ssize=UNDEF; 25 26 this->clone=0; 26 27 this->f_set=NULL; 27 28 this->s_set=NULL; 28 this-> doflist=NULL;29 this->svalues=NULL; 29 30 this->doftype=NULL; 30 } 31 /*}}}*/ 32 /*FUNCTION DofIndexing::DofIndexing(int numberofdofs){{{1*/ 33 DofIndexing::DofIndexing(int in_numberofdofs){ 34 this->Init(in_numberofdofs,NULL); 31 this->gdoflist=NULL; 32 this->fdoflist=NULL; 33 this->sdoflist=NULL; 34 35 } 36 /*}}}*/ 37 /*FUNCTION DofIndexing::DofIndexing(int gsize){{{1*/ 38 DofIndexing::DofIndexing(int in_gsize){ 39 this->Init(in_gsize,NULL); 35 40 } 36 41 /*}}}*/ … … 39 44 40 45 int i; 41 this->numberofdofs=in->numberofdofs; 46 this->gsize=in->gsize; 47 this->fsize=in->fsize; 48 this->ssize=in->ssize; 49 42 50 this->clone=in->clone; 43 51 44 this->f_set=(int*)xmalloc(this->numberofdofs*sizeof(int)); 45 this->s_set=(int*)xmalloc(this->numberofdofs*sizeof(int)); 46 this->doflist=(int*)xmalloc(this->numberofdofs*sizeof(int)); 47 if (in->doftype) this->doftype=(int*)xmalloc(this->numberofdofs*sizeof(int)); 48 else this->doftype=NULL; 49 50 for(i=0;i<this->numberofdofs;i++){ 51 this->f_set[i]=in->f_set[i]; 52 this->s_set[i]=in->s_set[i]; 53 this->doflist[i]=in->doflist[i]; 54 if (in->doftype) this->doftype[i]=in->doftype[i]; 55 } 52 if(this->gsize){ 53 this->f_set=(bool*)xmalloc(this->gsize*sizeof(bool)); 54 this->s_set=(bool*)xmalloc(this->gsize*sizeof(bool)); 55 this->svalues=(double*)xmalloc(this->gsize*sizeof(int)); 56 if(in->doftype)this->doftype=(int*)xmalloc(this->gsize*sizeof(int)); 57 this->gdoflist=(int*)xmalloc(this->gsize*sizeof(int)); 58 } 59 else{ 60 this->f_set=NULL; 61 this->s_set=NULL; 62 this->svalues=NULL; 63 this->doftype=NULL; 64 this->gdoflist=NULL; 65 } 66 if(this->fsize)this->fdoflist=(int*)xmalloc(this->fsize*sizeof(int)); else this->fdoflist=NULL; 67 if(this->ssize)this->sdoflist=(int*)xmalloc(this->ssize*sizeof(int)); else this->sdoflist=NULL; 68 69 if(this->gsize){ 70 memcpy(this->f_set,in->f_set,this->gsize*sizeof(bool)); 71 memcpy(this->s_set,in->s_set,this->gsize*sizeof(bool)); 72 memcpy(this->svalues,in->svalues,this->gsize*sizeof(double)); 73 if(this->doftype)memcpy(this->doftype,in->doftype,this->gsize*sizeof(int)); 74 memcpy(this->gdoflist,in->gdoflist,this->gsize*sizeof(int)); 75 } 76 if(this->fsize)memcpy(this->fdoflist,in->fdoflist,this->fsize*sizeof(int)); 77 if(this->ssize)memcpy(this->sdoflist,in->sdoflist,this->ssize*sizeof(int)); 78 56 79 } 57 80 /*}}}*/ … … 61 84 xfree((void**)&f_set); 62 85 xfree((void**)&s_set); 63 xfree((void**)& doflist);86 xfree((void**)&svalues); 64 87 xfree((void**)&doftype); 88 xfree((void**)&gdoflist); 89 xfree((void**)&fdoflist); 90 xfree((void**)&sdoflist); 65 91 66 92 } 67 93 /*}}}*/ 68 94 /*FUNCTION DofIndexing::Init{{{1*/ 69 void DofIndexing::Init(int in_numberofdofs,int* in_doftype){ 70 71 int i; 72 this->numberofdofs=in_numberofdofs; 95 void DofIndexing::Init(int in_gsize,int* in_doftype){ 96 97 int i; 98 this->gsize=in_gsize; 99 73 100 this->clone=0; 74 101 75 102 /*allocate: */ 76 this->f_set=(int*)xmalloc(this->numberofdofs*sizeof(int)); 77 this->s_set=(int*)xmalloc(this->numberofdofs*sizeof(int)); 78 this->doflist=(int*)xmalloc(this->numberofdofs*sizeof(int)); 79 if (in_doftype) this->doftype=(int*)xmalloc(this->numberofdofs*sizeof(int)); 80 81 for (i=0;i<this->numberofdofs;i++){ 103 if(this->gsize){ 104 this->f_set=(bool*)xmalloc(this->gsize*sizeof(bool)); 105 this->s_set=(bool*)xmalloc(this->gsize*sizeof(bool)); 106 this->svalues=(double*)xmalloc(this->gsize*sizeof(double)); 107 if(in_doftype)this->doftype=(int*)xmalloc(this->gsize*sizeof(int)); 108 this->gdoflist=(int*)xmalloc(this->gsize*sizeof(int)); 109 } 110 111 for (i=0;i<this->gsize;i++){ 82 112 /*assume dof is free, no constraints, no rigid body constraint: */ 83 this->f_set[i]=1; 84 this->s_set[i]=0; 85 this->doflist[i]=UNDEF; 86 if(in_doftype) this->doftype[i]=in_doftype[i]; 87 } 113 this->f_set[i]=true; 114 this->s_set[i]=false; 115 if(this->doftype)this->doftype[i]=in_doftype[i]; 116 this->svalues[i]=0; //0 constraint is the default value 117 } 118 } 119 /*}}}*/ 120 /*FUNCTION DofIndexing::InitSet{{{1*/ 121 void DofIndexing::InitSet(int setenum){ 122 123 int i; 124 int size=0; 125 126 /*go through sets, and figure out how many dofs belong to this set, except for g-set, 127 * which has already been initialized: */ 128 if(setenum==FsetEnum){ 129 size=0; 130 for(i=0;i<this->gsize;i++) if(f_set[i])size++; 131 this->fsize=size; 132 if(this->fsize)this->fdoflist=(int*)xmalloc(size*sizeof(int)); 133 else this->fdoflist=NULL; 134 } 135 else if(setenum==SsetEnum){ 136 size=0; 137 for(i=0;i<this->gsize;i++) if(s_set[i])size++; 138 this->ssize=size; 139 if(this->ssize)this->sdoflist=(int*)xmalloc(size*sizeof(int)); 140 else this->sdoflist=NULL; 141 } 142 else ISSMERROR("%s%s%s"," set of enum type ",EnumToString(setenum)," not supported yet!"); 143 144 88 145 } 89 146 /*}}}*/ … … 96 153 97 154 printf("DofIndexing:\n"); 98 printf(" numberofdofs: %i\n",numberofdofs);155 printf(" gsize: %i\n",gsize); 99 156 printf(" clone: %i\n",clone); 100 157 } … … 106 163 107 164 printf("DofIndexing:\n"); 108 printf(" numberofdofs: %i\n",numberofdofs); 165 printf(" gsize: %i\n",gsize); 166 printf(" fsize: %i\n",fsize); 167 printf(" ssize: %i\n",ssize); 109 168 printf(" clone: %i\n",clone); 110 169 111 170 printf(" set membership: f,s sets \n"); 112 for(i=0;i<numberofdofs;i++){ 113 printf(" dof %i: %i %i\n",i,f_set[i],s_set[i]); 114 } 115 printf("\n"); 116 117 printf(" doflist: |"); 118 for(i=0;i<numberofdofs;i++){ 119 printf(" %i |",doflist[i]); 171 for(i=0;i<gsize;i++){ 172 printf(" dof %i: %s %s\n",i,f_set[i]?"true":"false",s_set[i]?"true":"false"); 173 } 174 175 printf(" svalues (%i): |",this->ssize); 176 for(i=0;i<this->gsize;i++){ 177 if(this->s_set[i])printf(" %g |",svalues[i]); 120 178 } 121 179 printf("\n"); … … 123 181 if(doftype){ 124 182 printf(" doftype: |"); 125 for(i=0;i< numberofdofs;i++){183 for(i=0;i<gsize;i++){ 126 184 printf(" %i |",doftype[i]); 127 185 } 128 186 printf("\n"); 129 187 } 130 else printf(" NULL doftype"); 131 188 else printf(" doftype: NULL\n"); 189 190 printf(" g_doflist (%i): |",this->gsize); 191 for(i=0;i<this->gsize;i++){ 192 printf(" %i |",gdoflist[i]); 193 } 194 printf("\n"); 195 196 printf(" f_doflist (%i): |",this->fsize); 197 for(i=0;i<this->fsize;i++){ 198 printf(" %i |",fdoflist[i]); 199 } 200 printf("\n"); 201 202 printf(" s_doflist (%i): |",this->ssize); 203 for(i=0;i<this->ssize;i++){ 204 printf(" %i |",sdoflist[i]); 205 } 206 printf("\n"); 132 207 } 133 208 /*}}}*/ … … 145 220 memcpy(&enum_type,marshalled_dataset,sizeof(int)); marshalled_dataset+=sizeof(int); 146 221 147 memcpy(&numberofdofs,marshalled_dataset,sizeof(numberofdofs));marshalled_dataset+=sizeof(numberofdofs); 222 /*easy part: */ 223 memcpy(&gsize,marshalled_dataset,sizeof(gsize));marshalled_dataset+=sizeof(gsize); 224 memcpy(&fsize,marshalled_dataset,sizeof(fsize));marshalled_dataset+=sizeof(fsize); 225 memcpy(&ssize,marshalled_dataset,sizeof(ssize));marshalled_dataset+=sizeof(ssize); 226 memcpy(&flagdoftype,marshalled_dataset,sizeof(flagdoftype));marshalled_dataset+=sizeof(flagdoftype); 148 227 memcpy(&clone,marshalled_dataset,sizeof(clone));marshalled_dataset+=sizeof(clone); 149 228 150 229 /*Allocate: */ 151 this->f_set=(int*)xmalloc(this->numberofdofs*sizeof(int)); 152 this->s_set=(int*)xmalloc(this->numberofdofs*sizeof(int)); 153 this->doflist=(int*)xmalloc(this->numberofdofs*sizeof(int)); 154 155 memcpy(f_set,marshalled_dataset,numberofdofs*sizeof(int));marshalled_dataset+=numberofdofs*sizeof(int); 156 memcpy(s_set,marshalled_dataset,numberofdofs*sizeof(int));marshalled_dataset+=numberofdofs*sizeof(int); 157 memcpy(doflist,marshalled_dataset,numberofdofs*sizeof(int));marshalled_dataset+=numberofdofs*sizeof(int); 158 159 memcpy(&flagdoftype,marshalled_dataset,sizeof(flagdoftype));marshalled_dataset+=sizeof(flagdoftype); 160 if(flagdoftype){ // there is a hook so demarshall it 161 this->doftype=(int*)xmalloc(this->numberofdofs*sizeof(int)); 162 memcpy(doftype,marshalled_dataset,numberofdofs*sizeof(int));marshalled_dataset+=numberofdofs*sizeof(int); 163 } 164 else this->doftype=NULL; //There is no coupling, so doftype is NULL 230 if(this->gsize){ 231 this->f_set=(bool*)xmalloc(this->gsize*sizeof(bool)); 232 this->s_set=(bool*)xmalloc(this->gsize*sizeof(bool)); 233 this->svalues=(double*)xmalloc(this->ssize*sizeof(double)); 234 if(flagdoftype)this->doftype=(int*)xmalloc(this->gsize*sizeof(int)); 235 else this->doftype=NULL; 236 this->gdoflist=(int*)xmalloc(this->gsize*sizeof(int)); 237 } 238 else{ 239 this->f_set=NULL; 240 this->s_set=NULL; 241 this->svalues=NULL; 242 this->doftype=NULL; 243 this->gdoflist=NULL; 244 } 245 if(this->fsize)this->fdoflist=(int*)xmalloc(this->fsize*sizeof(int)); 246 else this->fdoflist=NULL; 247 if(this->ssize)this->sdoflist=(int*)xmalloc(this->ssize*sizeof(int)); 248 else this->sdoflist=NULL; 249 250 /*Copy arrays: */ 251 if(this->gsize){ 252 memcpy(f_set,marshalled_dataset,gsize*sizeof(bool));marshalled_dataset+=gsize*sizeof(bool); 253 memcpy(s_set,marshalled_dataset,gsize*sizeof(bool));marshalled_dataset+=gsize*sizeof(bool); 254 memcpy(this->svalues,marshalled_dataset,this->gsize*sizeof(double));marshalled_dataset+=this->gsize*sizeof(double); 255 if(flagdoftype){ memcpy(doftype,marshalled_dataset,gsize*sizeof(int));marshalled_dataset+=gsize*sizeof(int); } 256 memcpy(this->gdoflist,marshalled_dataset,this->gsize*sizeof(int));marshalled_dataset+=this->gsize*sizeof(int); 257 } 258 259 if(this->fsize){ memcpy(this->fdoflist,marshalled_dataset,this->fsize*sizeof(int));marshalled_dataset+=this->fsize*sizeof(int); } 260 if(this->ssize){ memcpy(this->sdoflist,marshalled_dataset,this->ssize*sizeof(int));marshalled_dataset+=this->ssize*sizeof(int); } 165 261 166 262 /*return: */ … … 174 270 char* marshalled_dataset=NULL; 175 271 int enum_type=0; 176 intflagdoftype; //to indicate if there are some doftype or if NULL272 bool flagdoftype; //to indicate if there are some doftype or if NULL 177 273 178 274 /*recover marshalled_dataset: */ 179 275 marshalled_dataset=*pmarshalled_dataset; 180 276 277 /*preliminary: */ 278 if(this->doftype)flagdoftype=true; 279 else flagdoftype=false; 280 181 281 /*get enum type of DofIndexing: */ 182 282 enum_type=DofIndexingEnum; … … 186 286 187 287 /*marshall DofIndexing data: */ 188 memcpy(marshalled_dataset,&numberofdofs,sizeof(numberofdofs));marshalled_dataset+=sizeof(numberofdofs); 288 memcpy(marshalled_dataset,&gsize,sizeof(gsize));marshalled_dataset+=sizeof(gsize); 289 memcpy(marshalled_dataset,&fsize,sizeof(fsize));marshalled_dataset+=sizeof(fsize); 290 memcpy(marshalled_dataset,&ssize,sizeof(ssize));marshalled_dataset+=sizeof(ssize); 291 memcpy(marshalled_dataset,&flagdoftype,sizeof(flagdoftype));marshalled_dataset+=sizeof(flagdoftype); 189 292 memcpy(marshalled_dataset,&clone,sizeof(clone));marshalled_dataset+=sizeof(clone); 190 memcpy(marshalled_dataset,f_set,numberofdofs*sizeof(int));marshalled_dataset+=numberofdofs*sizeof(int); 191 memcpy(marshalled_dataset,s_set,numberofdofs*sizeof(int));marshalled_dataset+=numberofdofs*sizeof(int); 192 memcpy(marshalled_dataset,doflist,numberofdofs*sizeof(int));marshalled_dataset+=numberofdofs*sizeof(int); 193 194 /*marshall doftype if there are some and add a flag*/ 195 if(this->doftype){ 196 flagdoftype=1; 197 memcpy(marshalled_dataset,&flagdoftype,sizeof(flagdoftype));marshalled_dataset+=sizeof(flagdoftype); 198 memcpy(marshalled_dataset,doftype,numberofdofs*sizeof(int));marshalled_dataset+=numberofdofs*sizeof(int); 199 } 200 else{ 201 flagdoftype=0; 202 memcpy(marshalled_dataset,&flagdoftype,sizeof(flagdoftype));marshalled_dataset+=sizeof(flagdoftype); 203 } 293 294 295 if(this->gsize){ 296 memcpy(marshalled_dataset,f_set,gsize*sizeof(bool));marshalled_dataset+=gsize*sizeof(bool); 297 memcpy(marshalled_dataset,s_set,gsize*sizeof(bool));marshalled_dataset+=gsize*sizeof(bool); 298 memcpy(marshalled_dataset,svalues,gsize*sizeof(double)); marshalled_dataset+=gsize*sizeof(double); 299 if(flagdoftype){ memcpy(marshalled_dataset,doftype,gsize*sizeof(int)); marshalled_dataset+=gsize*sizeof(int); } 300 memcpy(marshalled_dataset,gdoflist,gsize*sizeof(int)); marshalled_dataset+=gsize*sizeof(int); 301 } 302 if(this->fsize){ memcpy(marshalled_dataset,fdoflist,fsize*sizeof(int)); marshalled_dataset+=fsize*sizeof(int);} 303 if(this->ssize){ memcpy(marshalled_dataset,sdoflist,ssize*sizeof(int)); marshalled_dataset+=ssize*sizeof(int);} 204 304 205 305 *pmarshalled_dataset=marshalled_dataset; … … 210 310 int DofIndexing::MarshallSize(){ 211 311 212 int doftype_size=0;213 214 /*FInd size of doftype*/215 doftype_size+=sizeof(int); //Flag 0 or 1216 if (this->doftype){217 doftype_size+=numberofdofs*sizeof(int);218 }219 220 return sizeof(numberofdofs)+221 sizeof(clone)+222 numberofdofs*sizeof(int)+223 numberofdofs*sizeof(int)+ 224 numberofdofs*sizeof(int)+225 doftype_size+ 226 sizeof(int); //sizeof(int) for enum type227 } 228 /*}}}*/ 312 int size=0; 313 314 size+=4*sizeof(int)+sizeof(bool); 315 if(this->gsize){ 316 size+= 2*this->gsize*sizeof(bool)+ 317 this->gsize*sizeof(double)+ 318 this->gsize*sizeof(int); 319 if(this->doftype)size+=this->gsize*sizeof(int); 320 } 321 if(this->fsize)size+=this->fsize*sizeof(int); 322 if(this->ssize)size+=this->ssize*sizeof(int); 323 324 size+=sizeof(int); //sizeof(int) for enum type 325 326 return size; 327 } 328 /*}}}*/ -
issm/trunk/src/c/objects/DofIndexing.h
r5254 r5772 10 10 public: 11 11 12 int numberofdofs; //number of dofs for a node, variable 12 /*sizes: */ 13 int gsize; //number of dofs for a node 14 int fsize; //number of dofs solver for 15 int ssize; //number of constrained dofs 13 16 14 17 /*partitioning: */ … … 16 19 17 20 /*boundary conditions sets: */ 18 int* f_set; //set on which we solve 19 int* s_set; //set on which boundary conditions (dirichlet) are applied 21 bool* f_set; //is dof on f-set (on which we solve) 22 bool* s_set; //is dof on s-set (on which boundary conditions -dirichlet- are applied) 23 double* svalues; //list of constraint values. size g_size, for ease of use. 20 24 25 /*types of dofs: */ 26 int* doftype; //approximation type of the dofs (used only for coupling), size g_size 27 21 28 /*list of degrees of freedom: */ 22 int* doflist; //dof list on which we solve 23 int* doftype; //approximation type of the dofs (used only for coupling) 29 int* gdoflist; //dof list in g_set 30 int* fdoflist; //dof list in f_set 31 int* sdoflist; //dof list in s_set 32 24 33 25 34 /*DofIndexing constructors, destructors {{{1*/ 26 35 DofIndexing(); 27 DofIndexing(int numberofdofs); 28 void Init(int numberofdofs,int* doftype); 36 DofIndexing(int g_size); 37 void Init(int g_size,int* doftype); 38 void InitSet(int setenum); 29 39 DofIndexing(DofIndexing* properties); 30 40 ~DofIndexing(); -
issm/trunk/src/c/objects/Elements/Element.h
r5745 r5772 28 28 virtual void Configure(Elements* elements,Loads* loads,DataSet* nodes,Materials* materials,Parameters* parameters)=0; 29 29 virtual void SetCurrentConfiguration(Elements* elements,Loads* loads,DataSet* nodes,Materials* materials,Parameters* parameters)=0; 30 virtual void CreateKMatrix(Mat Kgg )=0;31 virtual void CreatePVector(Vec pg )=0;30 virtual void CreateKMatrix(Mat Kgg,Mat Kff, Mat Kfs)=0; 31 virtual void CreatePVector(Vec pg, Vec pf)=0; 32 32 virtual void GetSolutionFromInputs(Vec solution)=0; 33 33 virtual int GetNodeIndex(Node* node)=0; -
issm/trunk/src/c/objects/Elements/Penta.cpp
r5769 r5772 367 367 /*Just branch to the correct InputUpdateFromSolution generator, according to the type of analysis we are carrying out: */ 368 368 if (analysis_type==DiagnosticHorizAnalysisEnum){ 369 InputUpdateFromSolutionDiagnosticHoriz( solution); 369 int approximation; 370 inputs->GetParameterValue(&approximation,ApproximationEnum); 371 if(approximation==StokesApproximationEnum || approximation==NoneApproximationEnum){ 372 InputUpdateFromSolutionDiagnosticStokes( solution); 373 } 374 else{ 375 InputUpdateFromSolutionDiagnosticHoriz( solution); 376 } 370 377 } 371 378 else if (analysis_type==DiagnosticHutterAnalysisEnum){ … … 685 692 /*}}}*/ 686 693 /*FUNCTION Penta::CreateKMatrix {{{1*/ 687 void Penta::CreateKMatrix(Mat Kgg ){694 void Penta::CreateKMatrix(Mat Kgg, Mat Kff, Mat Kfs){ 688 695 689 696 int analysis_type; … … 773 780 /*}}}*/ 774 781 /*FUNCTION Penta::CreatePVector {{{1*/ 775 void Penta::CreatePVector(Vec pg ){782 void Penta::CreatePVector(Vec pg, Vec pf){ 776 783 777 784 int analysis_type; … … 894 901 GetSolutionFromInputsDiagnosticStokes(solution); 895 902 } 896 else if (approximation==MacAyealApproximationEnum || approximation==PattynApproximationEnum ||approximation==HutterApproximationEnum){903 else{ 897 904 GetSolutionFromInputsDiagnosticHoriz(solution); 898 905 } 899 else if(approximation==MacAyealPattynApproximationEnum || approximation==PattynStokesApproximationEnum){900 return; //do nothing the elements around with update the solution901 }902 else ISSMERROR("approximation type : %i (%s) not implemented yet",approximation,EnumToString(approximation));903 906 } 904 907 else if(analysis_type==DiagnosticHutterAnalysisEnum){ … … 1892 1895 this->inputs->AddInput(new IntInput(ApproximationEnum,StokesApproximationEnum)); 1893 1896 } 1894 else if (*(iomodel->elements_type+index)==PattynStokesApproximationEnum){1895 this->inputs->AddInput(new IntInput(ApproximationEnum,PattynStokesApproximationEnum));1896 }1897 1897 else if (*(iomodel->elements_type+index)==NoneApproximationEnum){ 1898 1898 this->inputs->AddInput(new IntInput(ApproximationEnum,NoneApproximationEnum)); … … 1988 1988 /*Spawn Tria element from the base of the Penta: */ 1989 1989 tria=(Tria*)SpawnTria(0,1,2); //grids 0, 1 and 2 make the new tria. 1990 tria->CreateKMatrix(Kgg );1990 tria->CreateKMatrix(Kgg,NULL,NULL); 1991 1991 delete tria->matice; delete tria; 1992 1992 … … 2018 2018 /*Spawn Tria element from the base of the Penta: */ 2019 2019 tria=(Tria*)SpawnTria(0,1,2); //grids 0, 1 and 2 make the new tria. 2020 tria->CreateKMatrix(Kgg );2020 tria->CreateKMatrix(Kgg,NULL,NULL); 2021 2021 delete tria->matice; delete tria; 2022 2022 … … 2096 2096 /* Get node coordinates and dof list: */ 2097 2097 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICESp); 2098 tria->GetDofList(&doflistm,MacAyealApproximationEnum ); //Pattyn dof list2099 GetDofList(&doflistp,PattynApproximationEnum ); //MacAyeal dof list2098 tria->GetDofList(&doflistm,MacAyealApproximationEnum,GsetEnum); //Pattyn dof list 2099 GetDofList(&doflistp,PattynApproximationEnum,GsetEnum); //MacAyeal dof list 2100 2100 2101 2101 /*Retrieve all inputs we will be needing: */ … … 2183 2183 if(IsOnWater())return; 2184 2184 2185 GetDofList(&doflist );2185 GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 2186 2186 2187 2187 /*Spawn 3 beam elements: */ … … 2321 2321 /*Call Tria function*/ 2322 2322 tria=(Tria*)SpawnTria(0,1,2); //grids 0, 1 and 2 make the new tria. 2323 tria->CreateKMatrix(Kgg );2323 tria->CreateKMatrix(Kgg,NULL,NULL); 2324 2324 delete tria->matice; delete tria; 2325 2325 … … 2343 2343 /* Get node coordinates and dof list: */ 2344 2344 GetVerticesCoordinates(&xyz_list[0][0], nodes,NUMVERTICES); 2345 tria->GetDofList(&doflist,MacAyealApproximationEnum ); //Pattyn dof list2345 tria->GetDofList(&doflist,MacAyealApproximationEnum,GsetEnum); //Pattyn dof list 2346 2346 2347 2347 /*Retrieve all inputs we will be needing: */ … … 2399 2399 * grids: */ 2400 2400 2401 tria->CreateKMatrixDiagnosticMacAyealFriction(Kgg );2401 tria->CreateKMatrixDiagnosticMacAyealFriction(Kgg,NULL,NULL); 2402 2402 } 2403 2403 … … 2476 2476 /* Get node coordinates and dof list: */ 2477 2477 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES); 2478 GetDofList(&doflist,PattynApproximationEnum );2478 GetDofList(&doflist,PattynApproximationEnum,GsetEnum); 2479 2479 2480 2480 /*Retrieve all inputs we will be needing: */ … … 2596 2596 /* Get node coordinates and dof list: */ 2597 2597 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES); 2598 GetDofList(&doflist,StokesApproximationEnum );2598 GetDofList(&doflist,StokesApproximationEnum,GsetEnum); 2599 2599 2600 2600 /*Retrieve all inputs we will be needing: */ … … 2756 2756 /* Get node coordinates and dof list: */ 2757 2757 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES); 2758 GetDofList(&doflist );2758 GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 2759 2759 2760 2760 /* Start looping on the number of gaussian points: */ … … 2827 2827 /*Spawn Tria element from the base of the Penta: */ 2828 2828 tria=(Tria*)SpawnTria(0,1,2); //grids 0, 1 and 2 make the new tria. 2829 tria->CreateKMatrix(Kgg );2829 tria->CreateKMatrix(Kgg,NULL,NULL); 2830 2830 delete tria->matice; delete tria; 2831 2831 … … 2852 2852 /*Spawn Tria element from the base of the Penta: */ 2853 2853 tria=(Tria*)SpawnTria(0,1,2); //grids 0, 1 and 2 make the new tria. 2854 tria->CreateKMatrix(Kgg );2854 tria->CreateKMatrix(Kgg,NULL,NULL); 2855 2855 delete tria->matice; delete tria; 2856 2856 return; … … 2920 2920 /* Get node coordinates and dof list: */ 2921 2921 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES); 2922 GetDofList(&doflist );2922 GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 2923 2923 2924 2924 // /*recovre material parameters: */ … … 3109 3109 /*Spawn Tria element from the base of the Penta: */ 3110 3110 tria=(Tria*)SpawnTria(0,1,2); //grids 0, 1 and 2 make the new tria. 3111 tria->CreatePVector(pg );3111 tria->CreatePVector(pg,NULL); 3112 3112 delete tria->matice; delete tria; 3113 3113 … … 3137 3137 /*Spawn Tria element from the base of the Penta: */ 3138 3138 tria=(Tria*)SpawnTria(0,1,2); //grids 0, 1 and 2 make the new tria. 3139 tria->CreatePVector(pg );3139 tria->CreatePVector(pg,NULL); 3140 3140 delete tria->matice; delete tria; 3141 3141 … … 3178 3178 3179 3179 /*recover doflist: */ 3180 GetDofList(&doflist );3180 GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 3181 3181 3182 3182 /*recover parameters: */ … … 3275 3275 *and use its CreatePVector functionality to return an elementary load vector: */ 3276 3276 tria=(Tria*)SpawnTria(0,1,2); //grids 0, 1 and 2 make the new tria. 3277 tria->CreatePVector(pg );3277 tria->CreatePVector(pg,NULL); 3278 3278 delete tria->matice; delete tria; 3279 3279 return; … … 3317 3317 /* Get node coordinates and dof list: */ 3318 3318 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES); 3319 GetDofList(&doflist,PattynApproximationEnum );3319 GetDofList(&doflist,PattynApproximationEnum,GsetEnum); 3320 3320 3321 3321 /*Retrieve all inputs we will be needing: */ … … 3429 3429 /* Get node coordinates and dof list: */ 3430 3430 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES); 3431 GetDofList(&doflist,StokesApproximationEnum );3431 GetDofList(&doflist,StokesApproximationEnum,GsetEnum); 3432 3432 3433 3433 /*Retrieve all inputs we will be needing: */ … … 3593 3593 /* Get node coordinates and dof list: */ 3594 3594 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES); 3595 GetDofList(&doflist );3595 GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 3596 3596 3597 3597 /*Retrieve all inputs we will be needing: */ … … 3656 3656 /*Spawn Tria element from the base of the Penta: */ 3657 3657 tria=(Tria*)SpawnTria(0,1,2); //grids 0, 1 and 2 make the new tria. 3658 tria->CreatePVector(pg );3658 tria->CreatePVector(pg,NULL); 3659 3659 delete tria->matice; delete tria; 3660 3660 … … 3680 3680 /*Spawn Tria element from the base of the Penta: */ 3681 3681 tria=(Tria*)SpawnTria(0,1,2); //grids 0, 1 and 2 make the new tria. 3682 tria->CreatePVector(pg );3682 tria->CreatePVector(pg,NULL); 3683 3683 delete tria->matice; delete tria; 3684 3684 return; … … 3744 3744 /* Get node coordinates and dof list: */ 3745 3745 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES); 3746 GetDofList(&doflist );3746 GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 3747 3747 3748 3748 /*recovre material parameters: */ … … 3821 3821 /*}}}*/ 3822 3822 /*FUNCTION Penta::GetDofList {{{1*/ 3823 void Penta::GetDofList(int** pdoflist,int approximation_enum ){3823 void Penta::GetDofList(int** pdoflist,int approximation_enum,int setenum){ 3824 3824 3825 3825 int i,j; … … 3832 3832 /*First, figure out size of doflist: */ 3833 3833 for(i=0;i<6;i++){ 3834 numberofdofs+=nodes[i]->GetNumberOfDofs(approximation_enum );3834 numberofdofs+=nodes[i]->GetNumberOfDofs(approximation_enum,setenum); 3835 3835 } 3836 3836 … … 3841 3841 count=0; 3842 3842 for(i=0;i<6;i++){ 3843 nodes[i]->GetDofList(doflist+count,approximation_enum );3844 count+=nodes[i]->GetNumberOfDofs(approximation_enum );3843 nodes[i]->GetDofList(doflist+count,approximation_enum,setenum); 3844 count+=nodes[i]->GetNumberOfDofs(approximation_enum,setenum); 3845 3845 } 3846 3846 … … 3995 3995 /*If the element is a coupling, do nothing: every grid is also on an other elements 3996 3996 * (as coupling is between MacAyeal and Pattyn) so the other element will take care of it*/ 3997 GetDofList(&doflist,approximation); 3997 if(approximation==MacAyealPattynApproximationEnum){ 3998 return; 3999 } 4000 else{ 4001 GetDofList(&doflist,approximation,GsetEnum); 4002 } 3998 4003 3999 4004 /*Ok, we have vx and vy in values, fill in vx and vy arrays: */ … … 4032 4037 4033 4038 /*Get dof list: */ 4034 GetDofList(&doflist );4039 GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 4035 4040 Input* vx_input=inputs->GetInput(VxEnum); ISSMASSERT(vx_input); 4036 4041 Input* vy_input=inputs->GetInput(VyEnum); ISSMASSERT(vy_input); … … 4070 4075 4071 4076 /*Get dof list: */ 4072 GetDofList(&doflist );4077 GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 4073 4078 Input* vz_input=inputs->GetInput(VzEnum); ISSMASSERT(vz_input); 4074 4079 … … 4106 4111 4107 4112 /*Get dof list: */ 4108 GetDofList(&doflist );4113 GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 4109 4114 Input* vx_input=inputs->GetInput(VxEnum); ISSMASSERT(vx_input); 4110 4115 Input* vy_input=inputs->GetInput(VyEnum); ISSMASSERT(vy_input); … … 4152 4157 4153 4158 /*Get dof list: */ 4154 GetDofList(&doflist );4159 GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 4155 4160 Input* t_input=inputs->GetInput(TemperatureEnum); ISSMASSERT(t_input); 4156 4161 … … 4442 4447 InputUpdateFromSolutionDiagnosticPattyn(solution); 4443 4448 } 4444 else if (approximation==StokesApproximationEnum || approximation==NoneApproximationEnum){4445 InputUpdateFromSolutionDiagnosticStokes(solution);4446 }4447 4449 else if (approximation==MacAyealPattynApproximationEnum){ 4448 4450 InputUpdateFromSolutionDiagnosticMacAyealPattyn(solution); 4449 }4450 else if (approximation==PattynStokesApproximationEnum){4451 InputUpdateFromSolutionDiagnosticPattynStokes(solution);4452 4451 } 4453 4452 } … … 4479 4478 4480 4479 /*Get dof list: */ 4481 GetDofList(&doflist,MacAyealApproximationEnum );4480 GetDofList(&doflist,MacAyealApproximationEnum,GsetEnum); 4482 4481 4483 4482 /*Use the dof list to index into the solution vector: */ … … 4572 4571 4573 4572 /*Get dof listof this element (pattyn dofs) and of the penta at base (macayeal dofs): */ 4574 GetDofList(&doflistp,PattynApproximationEnum );4575 penta->GetDofList(&doflistm,MacAyealApproximationEnum );4573 GetDofList(&doflistp,PattynApproximationEnum,GsetEnum); 4574 penta->GetDofList(&doflistm,MacAyealApproximationEnum,GsetEnum); 4576 4575 4577 4576 /*Get node data: */ … … 4657 4656 4658 4657 /*Get dof list: */ 4659 GetDofList(&doflist,PattynApproximationEnum );4658 GetDofList(&doflist,PattynApproximationEnum,GsetEnum); 4660 4659 4661 4660 /*Get node data: */ … … 4712 4711 } 4713 4712 4714 /*}}}*/4715 /*FUNCTION Penta::InputUpdateFromSolutionDiagnosticPattynStokes {{{1*/4716 void Penta::InputUpdateFromSolutionDiagnosticPattynStokes(double* solution){4717 4718 int i;4719 4720 const int numdofpervertexp=2;4721 const int numdofpervertexs=4;4722 const int numdofp=numdofpervertexp*NUMVERTICES;4723 const int numdofs=numdofpervertexs*NUMVERTICES;4724 int* doflistp=NULL;4725 int* doflists=NULL;4726 double pattyn_values[numdofp];4727 double stokes_values[numdofs];4728 double vx[NUMVERTICES];4729 double vy[NUMVERTICES];4730 double vz[NUMVERTICES];4731 double vel[NUMVERTICES];4732 int dummy;4733 double pressure[NUMVERTICES];4734 double xyz_list[NUMVERTICES][3];4735 4736 double *vz_ptr = NULL;4737 Penta *penta = NULL;4738 4739 /*OK, we have to add results of this element for pattyn4740 * and results from the penta at base for macayeal. Now recover results*/4741 4742 /*Get dof listof this element (pattyn dofs and stokes dofs): */4743 GetDofList(&doflistp,PattynApproximationEnum);4744 GetDofList(&doflists,StokesApproximationEnum);4745 4746 /*Get node data: */4747 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES);4748 4749 /*Use the dof list to index into the solution vector: */4750 for(i=0;i<numdofp;i++){4751 pattyn_values[i]=solution[doflistp[i]];4752 }4753 for(i=0;i<numdofs;i++){4754 stokes_values[i]=solution[doflists[i]];4755 }4756 4757 /*Ok, we have vx and vy in values, fill in vx and vy arrays: */4758 for(i=0;i<NUMVERTICES;i++){4759 vx[i]=stokes_values[i*numdofpervertexs+0]+pattyn_values[i*numdofpervertexp+0];4760 vy[i]=stokes_values[i*numdofpervertexs+1]+pattyn_values[i*numdofpervertexp+1];4761 vz[i]=stokes_values[i*numdofpervertexs+2];4762 pressure[i]=stokes_values[i*numdofpervertexs+3];4763 }4764 4765 /*Get Vz*/4766 Input* vz_input=inputs->GetInput(VzEnum);4767 if (vz_input){4768 if (vz_input->Enum()!=PentaVertexInputEnum){4769 ISSMERROR("Cannot compute Vel as Vz is of type %s",EnumToString(vz_input->Enum()));4770 }4771 vz_input->GetValuesPtr(&vz_ptr,&dummy);4772 for(i=0;i<NUMVERTICES;i++) vz[i]=vz[i]+vz_ptr[i];4773 }4774 else{4775 ISSMERROR("Cannot compute Vel there is no Vz input");4776 }4777 4778 /*Now Compute vel*/4779 for(i=0;i<NUMVERTICES;i++) {4780 vel[i]=pow( pow(vx[i],2.0) + pow(vy[i],2.0) + pow(vz[i],2.0) , 0.5);4781 }4782 4783 /*Now, we have to move the previous Vx and Vy inputs to old4784 * status, otherwise, we'll wipe them off: */4785 this->inputs->ChangeEnum(VxEnum,VxOldEnum);4786 this->inputs->ChangeEnum(VyEnum,VyOldEnum);4787 this->inputs->ChangeEnum(VzEnum,VzOldEnum);4788 this->inputs->ChangeEnum(PressureEnum,PressureOldEnum);4789 4790 /*Add vx and vy as inputs to the tria element: */4791 this->inputs->AddInput(new PentaVertexInput(VxEnum,vx));4792 this->inputs->AddInput(new PentaVertexInput(VyEnum,vy));4793 this->inputs->AddInput(new PentaVertexInput(VzEnum,vz));4794 this->inputs->AddInput(new PentaVertexInput(VelEnum,vel));4795 this->inputs->AddInput(new PentaVertexInput(PressureEnum,pressure));4796 4797 /*Free ressources:*/4798 xfree((void**)&doflistp);4799 xfree((void**)&doflists);4800 }4801 4713 /*}}}*/ 4802 4714 /*FUNCTION Penta::InputUpdateFromSolutionDiagnosticHutter {{{1*/ … … 4821 4733 4822 4734 /*Get dof list: */ 4823 GetDofList(&doflist );4735 GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 4824 4736 4825 4737 /*Get node data: */ … … 4900 4812 4901 4813 /*Get dof list: */ 4902 GetDofList(&doflist );4814 GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 4903 4815 4904 4816 /*Get node data: */ … … 4971 4883 4972 4884 /*Get dof list: */ 4973 GetDofList(&doflist );4885 GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 4974 4886 4975 4887 /*Use the dof list to index into the solution vector: */ … … 5029 4941 5030 4942 /*Get dof list: */ 5031 GetDofList(&doflist );4943 GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 5032 4944 5033 4945 /*Use the dof list to index into the solution vector: */ … … 5067 4979 5068 4980 /*Get dof list: */ 5069 GetDofList(&doflist );4981 GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 5070 4982 5071 4983 /*Use the dof list to index into the solution vector: */ … … 5102 5014 5103 5015 /*Get dof list: */ 5104 GetDofList(&doflist );5016 GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 5105 5017 5106 5018 /*Use the dof list to index into the solution vector: */ … … 5136 5048 5137 5049 /*Get dof list: */ 5138 GetDofList(&doflist );5050 GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 5139 5051 5140 5052 /*Use the dof list to index into the solution vector: */ … … 5164 5076 5165 5077 /*Get dof list: */ 5166 GetDofList(&doflist );5078 GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 5167 5079 5168 5080 /*Use the dof list to index into the solution vector and extrude it */ -
issm/trunk/src/c/objects/Elements/Penta.h
r5769 r5772 75 75 void SetCurrentConfiguration(Elements* elements,Loads* loads,DataSet* nodes,Materials* materials,Parameters* parameters); 76 76 double RegularizeInversion(void); 77 void CreateKMatrix(Mat Kgg );78 void CreatePVector(Vec pg );77 void CreateKMatrix(Mat Kgg, Mat Kff, Mat Kfs); 78 void CreatePVector(Vec pg, Vec pf); 79 79 void DeleteResults(void); 80 80 int GetNodeIndex(Node* node); … … 144 144 void CreatePVectorSlope( Vec pg); 145 145 void CreatePVectorThermal( Vec pg); 146 void GetDofList(int** pdoflist,int approximation_enum =0);146 void GetDofList(int** pdoflist,int approximation_enum,int setenum); 147 147 void GetDofList1(int* doflist); 148 int GetElementType(void);149 void GetParameterListOnVertices(double* pvalue,int enumtype);150 void GetParameterListOnVertices(double* pvalue,int enumtype,double defaultvalue);151 void GetParameterValue(double* pvalue,Node* node,int enumtype);148 int GetElementType(void); 149 void GetParameterListOnVertices(double* pvalue,int enumtype); 150 void GetParameterListOnVertices(double* pvalue,int enumtype,double defaultvalue); 151 void GetParameterValue(double* pvalue,Node* node,int enumtype); 152 152 void GetPhi(double* phi, double* epsilon, double viscosity); 153 153 void GetSolutionFromInputsDiagnosticHoriz(Vec solutiong); -
issm/trunk/src/c/objects/Elements/Tria.cpp
r5749 r5772 693 693 /*}}}*/ 694 694 /*FUNCTION Tria::CreateKMatrix {{{1*/ 695 void Tria::CreateKMatrix(Mat Kgg ){695 void Tria::CreateKMatrix(Mat Kgg, Mat Kff, Mat Kfs){ 696 696 697 697 /*retrive parameters: */ … … 705 705 /*Just branch to the correct element stiffness matrix generator, according to the type of analysis we are carrying out: */ 706 706 if (analysis_type==DiagnosticHorizAnalysisEnum || analysis_type==AdjointHorizAnalysisEnum){ 707 CreateKMatrixDiagnosticMacAyeal( Kgg );707 CreateKMatrixDiagnosticMacAyeal( Kgg,Kff,Kfs); 708 708 } 709 709 else if (analysis_type==DiagnosticHutterAnalysisEnum){ … … 739 739 /*}}}*/ 740 740 /*FUNCTION Tria::CreatePVector {{{1*/ 741 void Tria::CreatePVector(Vec pg ){741 void Tria::CreatePVector(Vec pg, Vec pf){ 742 742 743 743 int analysis_type; … … 2440 2440 /* Get node coordinates and dof list: */ 2441 2441 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES); 2442 GetDofList(&doflist );2442 GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 2443 2443 2444 2444 /*retrieve some parameters: */ … … 2578 2578 /* Get node coordinates and dof list: */ 2579 2579 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES); 2580 GetDofList(&doflist );2580 GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 2581 2581 this->parameters->FindParam(&dim,DimEnum); 2582 2582 … … 2680 2680 /* Get node coordinates and dof list: */ 2681 2681 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES); 2682 GetDofList(&doflist );2682 GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 2683 2683 2684 2684 /*Retrieve all inputs we will be needed*/ … … 2794 2794 /*}}}*/ 2795 2795 /*FUNCTION Tria::CreateKMatrixDiagnosticMacAyeal {{{1*/ 2796 void Tria::CreateKMatrixDiagnosticMacAyeal(Mat Kgg){ 2796 void Tria::CreateKMatrixDiagnosticMacAyeal(Mat Kgg,Mat Kff, Mat Kfs){ 2797 2798 const int numdof = 2 *NUMVERTICES; 2799 double *Ke_gg_viscous = NULL; 2800 double *Ke_gg_friction = NULL; 2801 ElementMatrix *Ke = NULL; 2802 2803 /*compute stiffness matrices on the g-set, at the element level: */ 2804 Ke_gg_viscous = CreateKMatrixDiagnosticMacAyealViscous(); 2805 Ke_gg_friction = CreateKMatrixDiagnosticMacAyealFriction(); 2806 2807 /*Initialize element matrix: */ 2808 Ke=this->NewElementMatrix(MacAyealApproximationEnum); 2809 2810 /*Add Ke_gg values to Ke element stifness matrix: */ 2811 if(Ke_gg_viscous) Ke->AddValues(Ke_gg_viscous); 2812 if(Ke_gg_friction)Ke->AddValues(Ke_gg_friction); 2813 2814 /*Add Ke element stiffness matrix to global stiffness matrix: */ 2815 Ke->AddToGlobal(Kgg,Kff,Kfs); 2816 2817 /*Free ressources:*/ 2818 delete Ke; 2819 xfree((void**)&Ke_gg_viscous); 2820 xfree((void**)&Ke_gg_friction); 2821 2822 } 2823 2824 /*}}}*/ 2825 /*FUNCTION Tria::CreateKMatrixDiagnosticMacAyealViscous{{{1*/ 2826 double* Tria::CreateKMatrixDiagnosticMacAyealViscous(void){ 2797 2827 2798 2828 /* local declarations */ 2799 2829 int i,j; 2830 2831 /*output: */ 2832 double* Ke_gg=NULL; 2800 2833 2801 2834 /* node data: */ 2802 2835 const int numdof=2*NUMVERTICES; 2803 2836 double xyz_list[NUMVERTICES][3]; 2804 int* doflist=NULL;2805 2837 2806 2838 /* gaussian points: */ … … 2827 2859 2828 2860 /* local element matrices: */ 2829 double Ke_gg[numdof][numdof]={0.0};2830 2861 double Ke_gg_gaussian[numdof][numdof]; //stiffness matrix evaluated at the gaussian point. 2831 2862 … … 2834 2865 /*input parameters for structural analysis (diagnostic): */ 2835 2866 double thickness; 2867 2836 2868 2837 2869 /*retrieve some parameters: */ … … 2839 2871 2840 2872 /*First, if we are on water, return empty matrix: */ 2841 if(IsOnWater()) return; 2873 if(IsOnWater()) return Ke_gg; 2874 2875 /*allocate output: */ 2876 Ke_gg=(double*)xcalloc(numdof*numdof,sizeof(double)); 2842 2877 2843 2878 /* Get node coordinates and dof list: */ 2844 2879 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES); 2845 GetDofList(&doflist,MacAyealApproximationEnum);2846 2880 2847 2881 /*Retrieve all inputs we will be needing: */ … … 2892 2926 2893 2927 /* Add the Ke_gg_gaussian, and optionally Ke_gg_drag_gaussian onto Ke_gg: */ 2894 for( i=0; i<numdof; i++) for(j=0;j<numdof;j++) Ke_gg[i][j]+=Ke_gg_gaussian[i][j]; 2895 2896 } 2897 2898 /*Add Ke_gg to global matrix Kgg: */ 2899 MatSetValues(Kgg,numdof,doflist,numdof,doflist,(const double*)Ke_gg,ADD_VALUES); 2900 2901 /*Do not forget to include friction: */ 2902 if(!IsOnShelf()){ 2903 CreateKMatrixDiagnosticMacAyealFriction(Kgg); 2904 } 2905 2928 for( i=0; i<numdof; i++) for(j=0;j<numdof;j++) *(Ke_gg+numdof*j+i)+=Ke_gg_gaussian[i][j]; 2929 2930 } 2906 2931 2907 2932 /*Clean up and return*/ 2908 2933 delete gauss; 2909 xfree((void**)&doflist); 2910 } 2911 /*}}}*/ 2912 /*FUNCTION Tria::CreateKMatrixCouplingMacAyealPattynFriction {{{1*/ 2913 void Tria::CreateKMatrixCouplingMacAyealPattynFriction(Mat Kgg){ 2934 return Ke_gg; 2935 } 2936 /*}}}*/ 2937 /*FUNCTION Tria::CreateKMatrixDiagnosticMacAyealFriction {{{1*/ 2938 void Tria::CreateKMatrixDiagnosticMacAyealFriction(Mat Kgg,Mat Kff, Mat Kfs){ 2939 2940 const int numdof = 2 *NUMVERTICES; 2941 double *Ke_gg_friction = NULL; 2942 ElementMatrix *Ke = NULL; 2943 2944 /*compute stiffness matrices on the g-set, at the element level: */ 2945 Ke_gg_friction = CreateKMatrixDiagnosticMacAyealFriction(); 2946 2947 if(Ke_gg_friction){ 2948 2949 /*Initialize element matrix: */ 2950 Ke=this->NewElementMatrix(MacAyealApproximationEnum); 2951 2952 /*Add Ke_gg values to Ke element stifness matrix: */ 2953 Ke->AddValues(Ke_gg_friction); 2954 2955 /*Add Ke element stiffness matrix to global stiffness matrix: */ 2956 Ke->AddToGlobal(Kgg,Kff,Kfs); 2957 2958 /*Free ressources:*/ 2959 delete Ke; 2960 } 2961 2962 /*Free ressources:*/ 2963 xfree((void**)&Ke_gg_friction); 2964 } 2965 2966 /*}}}*/ 2967 /*FUNCTION Tria::CreateKMatrixDiagnosticMacAyealFriction {{{1*/ 2968 double* Tria::CreateKMatrixDiagnosticMacAyealFriction(void){ 2914 2969 2915 2970 /* local declarations */ … … 2917 2972 int analysis_type; 2918 2973 2974 /*output: */ 2975 double* Ke_gg=NULL; 2976 2919 2977 /* node data: */ 2920 2978 const int numdof = 2 *NUMVERTICES; 2921 2979 double xyz_list[NUMVERTICES][3]; 2922 int* doflistm=NULL;2923 int* doflistp=NULL;2924 2980 int numberofdofspernode=2; 2925 2981 … … 2934 2990 2935 2991 /* local element matrices: */ 2936 double Ke_gg[numdof][numdof]={0.0};2937 2992 double Ke_gg_gaussian[numdof][numdof]; //stiffness matrix contribution from drag 2938 2993 … … 2952 3007 /*inputs: */ 2953 3008 int drag_type; 3009 2954 3010 2955 3011 /*retrive parameters: */ … … 2965 3021 /* Get node coordinates and dof list: */ 2966 3022 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES); 2967 GetDofList(&doflistm,MacAyealApproximationEnum);2968 GetDofList(&doflistp,PattynApproximationEnum);2969 3023 2970 3024 if (IsOnShelf()){ 2971 3025 /*no friction, do nothing*/ 2972 return; 2973 } 3026 return Ke_gg; 3027 } 3028 3029 /*allocte Ke_gg matrix: */ 3030 Ke_gg=(double*)xcalloc(numdof*numdof,sizeof(double)); 2974 3031 2975 3032 /*build friction object, used later on: */ … … 3013 3070 &Ke_gg_gaussian[0][0],0); 3014 3071 3015 for( i=0; i<numdof; i++) for(j=0;j<numdof;j++) Ke_gg[i][j]+=Ke_gg_gaussian[i][j]; 3016 3017 } 3018 3019 /*Add Ke_gg to global matrix Kgg: */ 3020 MatSetValues(Kgg,numdof,doflistm,numdof,doflistp,(const double*)Ke_gg,ADD_VALUES); 3021 MatSetValues(Kgg,numdof,doflistp,numdof,doflistm,(const double*)Ke_gg,ADD_VALUES); 3072 for( i=0; i<numdof; i++) for(j=0;j<numdof;j++) *(Ke_gg+numdof*i+j)+=Ke_gg_gaussian[i][j]; 3073 3074 } 3022 3075 3023 3076 /*Clean up and return*/ 3024 3077 delete gauss; 3025 3078 delete friction; 3026 xfree((void**)&doflistm); 3027 xfree((void**)&doflistp); 3028 } 3029 /*}}}*/ 3030 /*FUNCTION Tria::CreateKMatrixDiagnosticMacAyealFriction {{{1*/ 3031 void Tria::CreateKMatrixDiagnosticMacAyealFriction(Mat Kgg){ 3079 return Ke_gg; 3080 } 3081 /*}}}*/ 3082 /*FUNCTION Tria::CreateKMatrixCouplingMacAyealPattynFriction {{{1*/ 3083 void Tria::CreateKMatrixCouplingMacAyealPattynFriction(Mat Kgg){ 3032 3084 3033 3085 /* local declarations */ … … 3038 3090 const int numdof = 2 *NUMVERTICES; 3039 3091 double xyz_list[NUMVERTICES][3]; 3040 int* doflist=NULL; 3092 int* doflistm=NULL; 3093 int* doflistp=NULL; 3041 3094 int numberofdofspernode=2; 3042 3095 … … 3082 3135 /* Get node coordinates and dof list: */ 3083 3136 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES); 3084 GetDofList(&doflist,MacAyealApproximationEnum); 3137 GetDofList(&doflistm,MacAyealApproximationEnum,GsetEnum); 3138 GetDofList(&doflistp,PattynApproximationEnum,GsetEnum); 3085 3139 3086 3140 if (IsOnShelf()){ … … 3134 3188 3135 3189 /*Add Ke_gg to global matrix Kgg: */ 3136 MatSetValues(Kgg,numdof,doflist,numdof,doflist,(const double*)Ke_gg,ADD_VALUES); 3190 MatSetValues(Kgg,numdof,doflistm,numdof,doflistp,(const double*)Ke_gg,ADD_VALUES); 3191 MatSetValues(Kgg,numdof,doflistp,numdof,doflistm,(const double*)Ke_gg,ADD_VALUES); 3137 3192 3138 3193 /*Clean up and return*/ 3139 3194 delete gauss; 3140 3195 delete friction; 3141 xfree((void**)&doflist); 3196 xfree((void**)&doflistm); 3197 xfree((void**)&doflistp); 3142 3198 } 3143 3199 /*}}}*/ … … 3196 3252 /* Get node coordinates and dof list: */ 3197 3253 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES); 3198 GetDofList(&doflist,PattynApproximationEnum );3254 GetDofList(&doflist,PattynApproximationEnum,GsetEnum); 3199 3255 3200 3256 if (IsOnShelf()){ … … 3269 3325 if(IsOnWater())return; 3270 3326 3271 GetDofList(&doflist );3327 GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 3272 3328 3273 3329 /*Spawn 3 sing elements: */ … … 3319 3375 /* Get node coordinates and dof list: */ 3320 3376 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES); 3321 GetDofList(&doflist );3377 GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 3322 3378 3323 3379 /*Build normal vector to the surface:*/ … … 3418 3474 /* Get node coordinates and dof list: */ 3419 3475 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES); 3420 GetDofList(&doflist );3476 GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 3421 3477 3422 3478 … … 3507 3563 /* Get node coordinates and dof list: */ 3508 3564 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES); 3509 GetDofList(&doflist );3565 GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 3510 3566 3511 3567 /*Retrieve all inputs we will be needing: */ … … 3666 3722 /* Get node coordinates and dof list: */ 3667 3723 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES); 3668 GetDofList(&doflist );3724 GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 3669 3725 3670 3726 /*Retrieve all inputs we will be needed*/ … … 3750 3806 3751 3807 GetVerticesCoordinates(&xyz_list[0][0], nodes, numnodes); 3752 GetDofList(&doflist );3808 GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 3753 3809 3754 3810 /* Start looping on the number of gaussian points: */ … … 3814 3870 /* Get node coordinates and dof list: */ 3815 3871 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES); 3816 GetDofList(&doflist );3872 GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 3817 3873 3818 3874 //recover material parameters … … 3889 3945 /* Get node coordinates and dof list: */ 3890 3946 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES); 3891 GetDofList(&doflist );3947 GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 3892 3948 3893 3949 /*retrieve inputs :*/ … … 3954 4010 /* Get node coordinates and dof list: */ 3955 4011 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES); 3956 GetDofList(&doflist );4012 GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 3957 4013 3958 4014 /*Retrieve all inputs we will be needing: */ … … 4018 4074 /* Get node coordinates and dof list: */ 4019 4075 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES); 4020 GetDofList(&doflist );4076 GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 4021 4077 4022 4078 /*Retrieve all inputs we will be needing: */ … … 4088 4144 /* Get node coordinates and dof list: */ 4089 4145 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES); 4090 GetDofList(&doflist );4146 GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 4091 4147 4092 4148 /*Retrieve all inputs we will be needing: */ … … 4173 4229 /* Get node coordinates and dof list: */ 4174 4230 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES); 4175 GetDofList(&doflist,MacAyealApproximationEnum );4231 GetDofList(&doflist,MacAyealApproximationEnum,GsetEnum); 4176 4232 4177 4233 /* Start looping on the number of gaussian points: */ … … 4257 4313 /* Get node coordinates and dof list: */ 4258 4314 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES); 4259 GetDofList(&doflist );4315 GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 4260 4316 4261 4317 /*Retrieve all inputs we will be needing: */ … … 4350 4406 /* Get node coordinates and dof list: */ 4351 4407 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES); 4352 GetDofList(&doflist );4408 GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 4353 4409 4354 4410 /* Recover input data: */ … … 4571 4627 /* Get node coordinates and dof list: */ 4572 4628 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES); 4573 GetDofList(&doflist );4629 GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 4574 4630 4575 4631 /* Recover input data: */ … … 4755 4811 if(IsOnWater())return; 4756 4812 4757 GetDofList(&doflist );4813 GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 4758 4814 4759 4815 /* Get parameters */ … … 4832 4888 /* Get node coordinates and dof list: */ 4833 4889 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES); 4834 GetDofList(&doflist );4890 GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 4835 4891 4836 4892 /*Retrieve all inputs we will be needing: */ … … 4902 4958 /* Get node coordinates and dof list: */ 4903 4959 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES); 4904 GetDofList(&doflist );4960 GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 4905 4961 4906 4962 /*Retrieve all inputs we will be needing: */ … … 4973 5029 /* Get node coordinates and dof list: */ 4974 5030 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES); 4975 GetDofList(&doflist );5031 GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 4976 5032 4977 5033 /*Retrieve all inputs we will be needing: */ … … 5052 5108 /* Get node coordinates and dof list: */ 5053 5109 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES); 5054 GetDofList(&doflist );5110 GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 5055 5111 5056 5112 //recover material parameters … … 5145 5201 /* Get node coordinates and dof list: */ 5146 5202 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES); 5147 GetDofList(&doflist );5203 GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 5148 5204 5149 5205 //recover material parameters … … 5231 5287 /*}}}*/ 5232 5288 /*FUNCTION Tria::GetDofList {{{1*/ 5233 void Tria::GetDofList(int** pdoflist, int approximation_enum ){5289 void Tria::GetDofList(int** pdoflist, int approximation_enum,int setenum){ 5234 5290 5235 5291 int i,j; … … 5242 5298 /*First, figure out size of doflist: */ 5243 5299 for(i=0;i<3;i++){ 5244 numberofdofs+=nodes[i]->GetNumberOfDofs(approximation_enum );5300 numberofdofs+=nodes[i]->GetNumberOfDofs(approximation_enum,setenum); 5245 5301 } 5246 5302 … … 5251 5307 count=0; 5252 5308 for(i=0;i<3;i++){ 5253 nodes[i]->GetDofList(doflist+count,approximation_enum );5254 count+=nodes[i]->GetNumberOfDofs(approximation_enum );5309 nodes[i]->GetDofList(doflist+count,approximation_enum,setenum); 5310 count+=nodes[i]->GetNumberOfDofs(approximation_enum,setenum); 5255 5311 } 5256 5312 … … 5258 5314 *pdoflist=doflist; 5259 5315 5316 } 5317 /*}}}*/ 5318 /*FUNCTION Tria::GetInternalDofList {{{1*/ 5319 int* Tria::GetInternalDofList(int approximation_enum,int setenum){ 5320 5321 int i,j; 5322 int numberofdofs=0; 5323 int count=0; 5324 int count2=0; 5325 int ndof; 5326 int ngdof; 5327 5328 /*output: */ 5329 int* doflist=NULL; 5330 5331 /*First, figure out size of doflist: */ 5332 for(i=0;i<3;i++){ 5333 numberofdofs+=nodes[i]->GetNumberOfDofs(approximation_enum,setenum); 5334 } 5335 5336 if(numberofdofs){ 5337 /*Allocate: */ 5338 doflist=(int*)xmalloc(numberofdofs*sizeof(int)); 5339 5340 /*Populate: */ 5341 count=0; 5342 for(i=0;i<3;i++){ 5343 nodes[i]->GetInternalDofList(doflist+count,approximation_enum,setenum); 5344 count+=nodes[i]->GetNumberOfDofs(approximation_enum,setenum); 5345 } 5346 5347 /*We now have something like: [0 1 0 2 0 1]. Offset by gsize, to get something like: 5348 * [0 1 2 4 5 6]:*/ 5349 count=0; 5350 count2=0; 5351 for(i=0;i<3;i++){ 5352 ndof=nodes[i]->GetNumberOfDofs(approximation_enum,setenum); 5353 for(j=count;j<count+ndof;j++)doflist[j]+=count2; 5354 count+=ndof; 5355 count2+=nodes[i]->GetNumberOfDofs(approximation_enum,GsetEnum); 5356 } 5357 5358 } 5359 else doflist=NULL; 5360 5361 return doflist; 5362 5363 } 5364 /*}}}*/ 5365 /*FUNCTION Tria::GetExternalDofList {{{1*/ 5366 int* Tria::GetExternalDofList(int approximation_enum,int setenum){ 5367 5368 int i,j; 5369 int numberofdofs=0; 5370 int count=0; 5371 5372 /*output: */ 5373 int* doflist=NULL; 5374 5375 /*First, figure out size of doflist: */ 5376 for(i=0;i<3;i++){ 5377 numberofdofs+=nodes[i]->GetNumberOfDofs(approximation_enum,setenum); 5378 } 5379 5380 if(numberofdofs){ 5381 /*Allocate: */ 5382 doflist=(int*)xmalloc(numberofdofs*sizeof(int)); 5383 5384 /*Populate: */ 5385 count=0; 5386 for(i=0;i<3;i++){ 5387 nodes[i]->GetDofList(doflist+count,approximation_enum,setenum); 5388 count+=nodes[i]->GetNumberOfDofs(approximation_enum,setenum); 5389 } 5390 } 5391 else doflist=NULL; 5392 5393 return doflist; 5394 } 5395 /*}}}*/ 5396 /*FUNCTION Tria::GetNumberOfDofs {{{1*/ 5397 int Tria::GetNumberOfDofs(int approximation_enum,int setenum){ 5398 5399 int i; 5400 5401 /*output: */ 5402 int numberofdofs=0; 5403 5404 for(i=0;i<3;i++){ 5405 numberofdofs+=nodes[i]->GetNumberOfDofs(approximation_enum,setenum); 5406 } 5407 5408 return numberofdofs; 5260 5409 } 5261 5410 /*}}}*/ … … 5350 5499 5351 5500 /*Get dof list: */ 5352 GetDofList(&doflist );5501 GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 5353 5502 5354 5503 /*Get inputs*/ … … 5393 5542 5394 5543 /*Get dof list: */ 5395 GetDofList(&doflist );5544 GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 5396 5545 5397 5546 /*Get inputs*/ … … 5586 5735 5587 5736 /*Get dof list: */ 5588 GetDofList(&doflist );5737 GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 5589 5738 5590 5739 /*Use the dof list to index into the solution vector: */ … … 5619 5768 5620 5769 /*Get dof list: */ 5621 GetDofList(&doflist );5770 GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 5622 5771 5623 5772 /*Use the dof list to index into the solution vector: */ … … 5660 5809 5661 5810 /*Get dof list: */ 5662 GetDofList(&doflist );5811 GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 5663 5812 5664 5813 /*Use the dof list to index into the solution vector: */ … … 5724 5873 5725 5874 /*Get dof list: */ 5726 GetDofList(&doflist );5875 GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 5727 5876 5728 5877 /*Use the dof list to index into the solution vector: */ … … 5789 5938 5790 5939 /*Get dof list: */ 5791 GetDofList(&doflist );5940 GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 5792 5941 5793 5942 /*Use the dof list to index into the solution vector: */ … … 5830 5979 } 5831 5980 /*}}}*/ 5981 /*FUNCTION Tria::NewElementMatrix{{{1*/ 5982 ElementMatrix* Tria::NewElementMatrix(int approximation){ 5983 5984 /*parameters: */ 5985 bool kff=false; 5986 5987 /*output: */ 5988 ElementMatrix* Ke=NULL; 5989 int gsize; 5990 int fsize; 5991 int ssize; 5992 int* gexternaldoflist=NULL; 5993 int* finternaldoflist=NULL; 5994 int* fexternaldoflist=NULL; 5995 int* sinternaldoflist=NULL; 5996 int* sexternaldoflist=NULL; 5997 bool symmetric=true; 5998 5999 /*retrieve some parameters: */ 6000 this->parameters->FindParam(&kff,KffEnum); 6001 6002 /*get number of dofs in sets g,f and s: */ 6003 gsize=this->GetNumberOfDofs(approximation,GsetEnum); 6004 if(kff){ 6005 fsize=this->GetNumberOfDofs(approximation,FsetEnum); 6006 ssize=this->GetNumberOfDofs(approximation,SsetEnum); 6007 } 6008 6009 /*get dof lists for f and s set: */ 6010 if(!kff) gexternaldoflist=this->GetExternalDofList(approximation,GsetEnum); 6011 else{ 6012 finternaldoflist=this->GetInternalDofList(approximation,FsetEnum); 6013 fexternaldoflist=this->GetExternalDofList(approximation,FsetEnum); 6014 sinternaldoflist=this->GetInternalDofList(approximation,SsetEnum); 6015 sexternaldoflist=this->GetExternalDofList(approximation,SsetEnum); 6016 } 6017 6018 /*Use symmetric constructor for ElementMatrix: */ 6019 if(!kff) Ke=new ElementMatrix(gsize,symmetric,gexternaldoflist); 6020 else Ke=new ElementMatrix(gsize,symmetric,finternaldoflist,fexternaldoflist,fsize,sinternaldoflist,sexternaldoflist,ssize); 6021 6022 /*Free ressources and return:*/ 6023 xfree((void**)&gexternaldoflist); 6024 xfree((void**)&finternaldoflist); 6025 xfree((void**)&fexternaldoflist); 6026 xfree((void**)&sinternaldoflist); 6027 xfree((void**)&sexternaldoflist); 6028 6029 return Ke; 6030 } 6031 /*}}}*/ 6032 /*FUNCTION Tria::NewElementVector{{{1*/ 6033 ElementVector* Tria::NewElementVector(int approximation){ 6034 6035 /*parameters: */ 6036 bool kff=false; 6037 6038 /*output: */ 6039 ElementVector* pe=NULL; 6040 int gsize; 6041 int fsize; 6042 int* gexternaldoflist=NULL; 6043 int* finternaldoflist=NULL; 6044 int* fexternaldoflist=NULL; 6045 6046 /*retrieve some parameters: */ 6047 this->parameters->FindParam(&kff,KffEnum); 6048 6049 /*get number of dofs in sets g,f and s: */ 6050 gsize=this->GetNumberOfDofs(approximation,GsetEnum); 6051 if(kff)fsize=this->GetNumberOfDofs(approximation,FsetEnum); 6052 6053 /*get dof lists for f and s set: */ 6054 if(!kff){ 6055 gexternaldoflist=this->GetExternalDofList(approximation,GsetEnum); 6056 } 6057 else{ 6058 finternaldoflist=this->GetInternalDofList(approximation,FsetEnum); 6059 fexternaldoflist=this->GetExternalDofList(approximation,FsetEnum); 6060 } 6061 6062 /*Use symmetric constructor for ElementVector: */ 6063 if(!kff)pe=new ElementVector(gsize,gexternaldoflist); 6064 else pe=new ElementVector(gsize,finternaldoflist,fexternaldoflist,fsize); 6065 6066 /*Free ressources and return:*/ 6067 xfree((void**)&gexternaldoflist); 6068 xfree((void**)&finternaldoflist); 6069 xfree((void**)&fexternaldoflist); 6070 6071 return pe; 6072 } 6073 /*}}}*/ 5832 6074 /*FUNCTION Tria::SetClone {{{1*/ 5833 6075 void Tria::SetClone(int* minranks){ -
issm/trunk/src/c/objects/Elements/Tria.h
r5746 r5772 17 17 class Matice; 18 18 class Matpar; 19 class ElementMatrix; 20 class ElementVector; 19 21 20 22 #include "../../include/include.h" … … 72 74 void SetCurrentConfiguration(Elements* elements,Loads* loads,DataSet* nodes,Materials* materials,Parameters* parameters); 73 75 double RegularizeInversion(void); 74 void CreateKMatrix(Mat Kgg );75 void CreatePVector(Vec pg );76 void CreateKMatrix(Mat Kgg, Mat Kff, Mat Kfs); 77 void CreatePVector(Vec pg, Vec pf); 76 78 int GetNodeIndex(Node* node); 77 79 bool IsOnBed(); … … 122 124 void CreateKMatrixBalancedthickness_CG(Mat Kgg); 123 125 void CreateKMatrixBalancedvelocities(Mat Kgg); 124 void CreateKMatrixDiagnosticMacAyeal(Mat Kgg); 126 void CreateKMatrixDiagnosticMacAyeal(Mat Kgg,Mat Kff, Mat Kfs); 127 double* CreateKMatrixDiagnosticMacAyealViscous(void); 128 double* CreateKMatrixDiagnosticMacAyealFriction(void); 129 void CreateKMatrixDiagnosticMacAyealFriction(Mat Kgg,Mat Kff, Mat Kfs); 125 130 void CreateKMatrixCouplingMacAyealPattynFriction(Mat Kgg); 126 void CreateKMatrixDiagnosticMacAyealFriction(Mat Kgg);127 131 void CreateKMatrixDiagnosticPattynFriction(Mat Kgg); 128 132 void CreateKMatrixDiagnosticHutter(Mat Kgg); … … 147 151 void CreatePVectorThermalSheet( Vec pg); 148 152 void CreatePVectorThermalShelf( Vec pg); 149 double GetArea(void);150 int GetElementType(void);151 void GetDofList(int** pdoflist,int approximation_enum =0);153 double GetArea(void); 154 int GetElementType(void); 155 void GetDofList(int** pdoflist,int approximation_enum,int setenum); 152 156 void GetDofList1(int* doflist); 153 void GetParameterListOnVertices(double* pvalue,int enumtype); 154 void GetParameterListOnVertices(double* pvalue,int enumtype,double defaultvalue); 155 void GetParameterValue(double* pvalue,Node* node,int enumtype); 157 int* GetInternalDofList(int approximation_enum,int setenum); 158 int* GetExternalDofList(int approximation_enum,int setenum); 159 int GetNumberOfDofs(int approximation_enum,int setenum); 160 void GetParameterListOnVertices(double* pvalue,int enumtype); 161 void GetParameterListOnVertices(double* pvalue,int enumtype,double defaultvalue); 162 void GetParameterValue(double* pvalue,Node* node,int enumtype); 156 163 void GetSolutionFromInputsDiagnosticHoriz(Vec solution); 157 164 void GetSolutionFromInputsDiagnosticHutter(Vec solution); 158 void GetStrainRate2d(double* epsilon,double* xyz_list, GaussTria* gauss, Input* vx_input, Input* vy_input);165 void GetStrainRate2d(double* epsilon,double* xyz_list, GaussTria* gauss, Input* vx_input, Input* vy_input); 159 166 void GradjDragStokes(Vec gradient); 160 167 void InputUpdateFromSolutionAdjointBalancedthickness( double* solution); … … 164 171 void InputUpdateFromSolutionOneDof(double* solution,int enum_type); 165 172 bool IsInput(int name); 173 ElementMatrix* NewElementMatrix(int approximation); 174 ElementVector* NewElementVector(int approximation); 166 175 void SetClone(int* minranks); 167 176 void SurfaceNormal(double* surface_normal, double xyz_list[3][3]); -
issm/trunk/src/c/objects/FemModel.cpp
r5103 r5772 38 38 analysis_type_list=(int*)xmalloc(nummodels*sizeof(int)); 39 39 m_nodesets=(NodeSets**)xmalloc(nummodels*sizeof(NodeSets*)); 40 m_yg=(Vec*)xmalloc(nummodels*sizeof(Vec));41 40 m_ys=(Vec*)xmalloc(nummodels*sizeof(Vec)); 42 41 … … 44 43 for(i=0;i<nummodels;i++)analysis_type_list[i]=analyses[i]; 45 44 for(i=0;i<nummodels;i++)m_nodesets[i]=NULL; 46 for(i=0;i<nummodels;i++)m_yg[i]=NULL;47 45 for(i=0;i<nummodels;i++)m_ys[i]=NULL; 48 46 … … 57 55 this->SetCurrentConfiguration(analysis_type); 58 56 59 _printf_(" create degrees of freedom\n");57 _printf_(" create vertex degrees of freedom\n"); 60 58 VerticesDofx(&partition,&tpartition,vertices,parameters); 59 60 _printf_(" resolve node constraints\n"); 61 SpcNodesx(nodes,constraints,analysis_type); 62 63 _printf_(" create nodal degrees of freedom\n"); 61 64 NodesDofx(nodes,parameters,analysis_type); 62 63 _printf_(" create single point constraints\n");64 SpcNodesx( &m_yg[i], nodes,constraints,analysis_type);65 66 _printf_(" create nodal constraints vector\n"); 67 CreateNodalConstraintsx(&m_ys[i],nodes,analysis_type); 65 68 66 69 _printf_(" create node sets\n"); 67 70 BuildNodeSetsx(&m_nodesets[i], nodes,analysis_type); 68 69 _printf_(" reducing single point constraints vector\n");70 Reducevectorgtosx(&m_ys[i], m_yg[i],m_nodesets[i]);71 71 72 72 _printf_(" configuring element and loads\n"); … … 97 97 NodeSets* temp_nodesets=m_nodesets[i]; 98 98 delete temp_nodesets; 99 Vec temp_yg=m_yg[i];100 VecFree(&temp_yg);101 99 Vec temp_ys=m_ys[i]; 102 100 VecFree(&temp_ys); … … 105 103 /*Delete dynamically allocated arrays: */ 106 104 xfree((void**)&m_nodesets); 107 xfree((void**)&m_yg);108 105 xfree((void**)&m_ys); 109 106 … … 147 144 /*activate matrices/vectors: */ 148 145 nodesets=m_nodesets[analysis_counter]; 149 yg=m_yg[analysis_counter];150 146 ys=m_ys[analysis_counter]; 151 147 -
issm/trunk/src/c/objects/FemModel.h
r5057 r5772 41 41 //multiple sets of matrices/vectors for each analysis_type. m stands for multiple 42 42 NodeSets** m_nodesets; //boundary conditions dof sets 43 Vec* m_yg; //boundary conditions in global g-set44 43 Vec* m_ys; //boundary conditions, in reduced s-set 45 44 -
issm/trunk/src/c/objects/IoModel.cpp
r5631 r5772 188 188 IoModelFetchData(&this->stokesreconditioning,iomodel_handle,"stokesreconditioning"); 189 189 IoModelFetchData(&this->waitonlock,iomodel_handle,"waitonlock"); 190 IoModelFetchData(&this->kff,iomodel_handle,"kff"); 190 191 191 192 /*!Get thermal parameters: */ … … 324 325 this->connectivity=0; 325 326 this->lowmem=0; 327 this->kff=0; 326 328 this->optscal=NULL; 327 329 this->yts=0; -
issm/trunk/src/c/objects/IoModel.h
r5631 r5772 150 150 double yts; 151 151 double waitonlock; 152 int kff; 152 153 153 154 /*thermal parameters: */ -
issm/trunk/src/c/objects/Loads/Icefront.cpp
r5743 r5772 307 307 /*}}}*/ 308 308 /*FUNCTION Icefront::CreateKMatrix {{{1*/ 309 void Icefront::CreateKMatrix(Mat Kgg ){309 void Icefront::CreateKMatrix(Mat Kgg, Mat Kff, Mat Kfs){ 310 310 311 311 /*No stiffness loads applied, do nothing: */ … … 315 315 /*}}}*/ 316 316 /*FUNCTION Icefront::CreatePVector {{{1*/ 317 void Icefront::CreatePVector(Vec pg ){317 void Icefront::CreatePVector(Vec pg, Vec pf){ 318 318 319 319 /*Checks in debugging mode*/ … … 331 331 inputs->GetParameterValue(&type,TypeEnum); 332 332 if (type==MacAyeal2dIceFrontEnum){ 333 CreatePVectorDiagnosticMacAyeal2d( pg );333 CreatePVectorDiagnosticMacAyeal2d( pg,pf); 334 334 } 335 335 else if (type==MacAyeal3dIceFrontEnum){ … … 353 353 /*}}}*/ 354 354 /*FUNCTION Icefront::PenaltyCreateKMatrix {{{1*/ 355 void Icefront::PenaltyCreateKMatrix(Mat Kgg, double kmax){355 void Icefront::PenaltyCreateKMatrix(Mat Kgg,Mat Kff, Mat Kfs, double kmax){ 356 356 /*do nothing: */ 357 357 } 358 358 /*}}}*/ 359 359 /*FUNCTION Icefront::PenaltyCreatePVector{{{1*/ 360 void Icefront::PenaltyCreatePVector(Vec pg, double kmax){360 void Icefront::PenaltyCreatePVector(Vec pg,Vec pf,double kmax){ 361 361 /*do nothing: */ 362 362 } … … 423 423 /*Icefront numerics: */ 424 424 /*FUNCTION Icefront::CreatePVectorDiagnosticMacAyeal2d{{{1*/ 425 void Icefront::CreatePVectorDiagnosticMacAyeal2d( Vec pg ){425 void Icefront::CreatePVectorDiagnosticMacAyeal2d( Vec pg,Vec pf){ 426 426 427 427 /*Constants*/ 428 428 const int numnodes= NUMVERTICESSEG; 429 429 const int numdofs = numnodes *NDOF2; 430 431 /*output: */ 432 ElementVector* pe=NULL; 430 433 431 434 /*Intermediary*/ … … 434 437 double thickness,bed,pressure,ice_pressure,rho_water,rho_ice,gravity; 435 438 double water_pressure,air_pressure,surface_under_water,base_under_water; 436 int *doflist = NULL;437 439 double xyz_list[numnodes][3]; 438 440 double pe_g[numdofs] = {0.0}; … … 444 446 445 447 /* Get dof list and node coordinates: */ 446 GetDofList(&doflist,MacAyealApproximationEnum);447 448 GetVerticesCoordinates(&xyz_list[0][0],nodes,numnodes); 448 449 … … 493 494 } 494 495 } 495 496 VecSetValues(pg,numdofs,doflist,pe_g,ADD_VALUES); 496 497 /*Initialize element matrix: */ 498 pe=this->NewElementVector(MacAyealApproximationEnum); 499 500 /*Add pe_g values to pe element stifness load: */ 501 pe->AddValues(&pe_g[0]); 502 503 /*Add pe element load vector to global load vector: */ 504 pe->AddToGlobal(pg,pf); 505 506 /*Free ressources:*/ 507 delete pe; 497 508 498 509 /*Free ressources:*/ 499 510 delete gauss; 500 xfree((void**)&doflist);501 511 } 502 512 /*}}}*/ … … 521 531 icefront->element=tria; 522 532 icefront->inputs->AddInput(new IntInput(TypeEnum,MacAyeal2dIceFrontEnum)); 523 icefront->CreatePVectorDiagnosticMacAyeal2d(pg );533 icefront->CreatePVectorDiagnosticMacAyeal2d(pg,NULL); 524 534 525 535 /*clean-up*/ … … 574 584 575 585 /* Get dof list and node coordinates: */ 576 GetDofList(&doflist,PattynApproximationEnum );586 GetDofList(&doflist,PattynApproximationEnum,GsetEnum); 577 587 GetVerticesCoordinates(&xyz_list[0][0], nodes, numnodes); 578 588 … … 692 702 693 703 /* Get dof list and node coordinates: */ 694 GetDofList(&doflist,StokesApproximationEnum );704 GetDofList(&doflist,StokesApproximationEnum,GsetEnum); 695 705 GetVerticesCoordinates(&xyz_list[0][0], nodes, numnodes); 696 706 … … 766 776 /*}}}*/ 767 777 /*FUNCTION Icefront::GetDofList {{{1*/ 768 void Icefront::GetDofList(int** pdoflist,int approximation_enum ){778 void Icefront::GetDofList(int** pdoflist,int approximation_enum,int setenum){ 769 779 770 780 int i,j; … … 792 802 /*Figure out size of doflist: */ 793 803 for(i=0;i<numberofnodes;i++){ 794 numberofdofs+=nodes[i]->GetNumberOfDofs(approximation_enum );804 numberofdofs+=nodes[i]->GetNumberOfDofs(approximation_enum,setenum); 795 805 } 796 806 … … 801 811 count=0; 802 812 for(i=0;i<numberofnodes;i++){ 803 nodes[i]->GetDofList(doflist+count,approximation_enum );804 count+=nodes[i]->GetNumberOfDofs(approximation_enum );813 nodes[i]->GetDofList(doflist+count,approximation_enum,setenum); 814 count+=nodes[i]->GetNumberOfDofs(approximation_enum,setenum); 805 815 } 806 816 807 817 /*Assign output pointers:*/ 808 818 *pdoflist=doflist; 819 } 820 /*}}}*/ 821 /*FUNCTION Icefront::GetInternalDofList {{{1*/ 822 int* Icefront::GetInternalDofList(int approximation_enum,int setenum){ 823 824 int i,j; 825 int numberofdofs=0; 826 int count=0; 827 int count2=0; 828 int type; 829 int numberofnodes=2; 830 int ndof; 831 832 /*output: */ 833 int* doflist=NULL; 834 835 /*recover type: */ 836 inputs->GetParameterValue(&type,TypeEnum); 837 838 /*Some checks for debugging*/ 839 ISSMASSERT(nodes); 840 841 /*How many nodes? :*/ 842 if(type==MacAyeal2dIceFrontEnum || type==MacAyeal3dIceFrontEnum) 843 numberofnodes=2; 844 else 845 numberofnodes=4; 846 847 /*Figure out size of doflist: */ 848 for(i=0;i<numberofnodes;i++){ 849 numberofdofs+=nodes[i]->GetNumberOfDofs(approximation_enum,setenum); 850 } 851 852 if(numberofdofs){ 853 /*Allocate: */ 854 doflist=(int*)xmalloc(numberofdofs*sizeof(int)); 855 856 /*Populate: */ 857 count=0; 858 for(i=0;i<numberofnodes;i++){ 859 nodes[i]->GetDofList(doflist+count,approximation_enum,setenum); 860 count+=nodes[i]->GetNumberOfDofs(approximation_enum,setenum); 861 } 862 863 /*We now have something like: [0 1 0 1]. Offset by gsize, to get something like: 864 * [0 1 2 3]: */ 865 count=0; 866 count2=0; 867 for(i=0;i<numberofnodes;i++){ 868 ndof=nodes[i]->GetNumberOfDofs(approximation_enum,setenum); 869 for(j=count;j<count+ndof;j++)doflist[j]+=count2; 870 count+=ndof; 871 count2+=nodes[i]->GetNumberOfDofs(approximation_enum,GsetEnum); 872 } 873 } 874 875 return doflist; 876 } 877 /*}}}*/ 878 /*FUNCTION Icefront::GetExternalDofList{{{1*/ 879 int* Icefront::GetExternalDofList(int approximation_enum,int setenum){ 880 881 int i,j; 882 int numberofdofs=0; 883 int count=0; 884 int type; 885 int numberofnodes=2; 886 887 /*output: */ 888 int* doflist=NULL; 889 890 /*recover type: */ 891 inputs->GetParameterValue(&type,TypeEnum); 892 893 /*Some checks for debugging*/ 894 ISSMASSERT(nodes); 895 896 /*How many nodes? :*/ 897 if(type==MacAyeal2dIceFrontEnum || type==MacAyeal3dIceFrontEnum) 898 numberofnodes=2; 899 else 900 numberofnodes=4; 901 902 /*Figure out size of doflist: */ 903 for(i=0;i<numberofnodes;i++){ 904 numberofdofs+=nodes[i]->GetNumberOfDofs(approximation_enum,setenum); 905 } 906 907 if(numberofdofs){ 908 /*Allocate: */ 909 doflist=(int*)xmalloc(numberofdofs*sizeof(int)); 910 911 /*Populate: */ 912 count=0; 913 for(i=0;i<numberofnodes;i++){ 914 nodes[i]->GetDofList(doflist+count,approximation_enum,setenum); 915 count+=nodes[i]->GetNumberOfDofs(approximation_enum,setenum); 916 } 917 } 918 919 return doflist; 920 } 921 /*}}}*/ 922 /*FUNCTION Icefront::GetNumberOfDofs {{{1*/ 923 int Icefront::GetNumberOfDofs(int approximation_enum,int setenum){ 924 925 926 int i; 927 int numberofdofs=0; 928 int type; 929 int numberofnodes=2; 930 931 /*recover type: */ 932 inputs->GetParameterValue(&type,TypeEnum); 933 934 /*Some checks for debugging*/ 935 ISSMASSERT(nodes); 936 937 /*How many nodes? :*/ 938 if(type==MacAyeal2dIceFrontEnum || type==MacAyeal3dIceFrontEnum) 939 numberofnodes=2; 940 else 941 numberofnodes=4; 942 943 /*Figure out size of doflist: */ 944 for(i=0;i<numberofnodes;i++){ 945 numberofdofs+=nodes[i]->GetNumberOfDofs(approximation_enum,setenum); 946 } 947 948 return numberofdofs; 809 949 } 810 950 /*}}}*/ … … 1309 1449 } 1310 1450 /*}}}*/ 1451 /*FUNCTION Icefront::NewElementVector{{{1*/ 1452 ElementVector* Icefront::NewElementVector(int approximation){ 1453 1454 /*parameters: */ 1455 bool kff=false; 1456 1457 /*output: */ 1458 ElementVector* pe=NULL; 1459 int gsize; 1460 int fsize; 1461 int* gexternaldoflist=NULL; 1462 int* finternaldoflist=NULL; 1463 int* fexternaldoflist=NULL; 1464 1465 /*retrieve some parameters: */ 1466 this->parameters->FindParam(&kff,KffEnum); 1467 1468 /*get number of dofs in sets g and f: */ 1469 gsize=this->GetNumberOfDofs(approximation,GsetEnum); 1470 if(kff)fsize=this->GetNumberOfDofs(approximation,FsetEnum); 1471 1472 /*get dof lists for f and s set: */ 1473 if(!kff){ 1474 gexternaldoflist=this->GetExternalDofList(approximation,GsetEnum); 1475 } 1476 else{ 1477 finternaldoflist=this->GetInternalDofList(approximation,FsetEnum); 1478 fexternaldoflist=this->GetExternalDofList(approximation,FsetEnum); 1479 } 1480 1481 /*Use symmetric constructor for ElementVector: */ 1482 if(!kff)pe=new ElementVector(gsize,gexternaldoflist); 1483 else pe=new ElementVector(gsize,finternaldoflist,fexternaldoflist,fsize); 1484 1485 /*Free ressources and return:*/ 1486 xfree((void**)&gexternaldoflist); 1487 xfree((void**)&finternaldoflist); 1488 xfree((void**)&fexternaldoflist); 1489 1490 return pe; 1491 } 1492 /*}}}*/ -
issm/trunk/src/c/objects/Loads/Icefront.h
r5722 r5772 16 16 class Element; 17 17 class IoModel; 18 class ElementVector; 18 19 /*}}}*/ 19 20 … … 69 70 void Configure(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters); 70 71 void SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters); 71 void CreateKMatrix(Mat Kgg );72 void CreatePVector(Vec pg );73 void PenaltyCreateKMatrix(Mat Kgg, double kmax);74 void PenaltyCreatePVector(Vec pg, double kmax);72 void CreateKMatrix(Mat Kgg, Mat Kff, Mat Kfs); 73 void CreatePVector(Vec pg, Vec pf); 74 void PenaltyCreateKMatrix(Mat Kgg,Mat Kff, Mat kfs, double kmax); 75 void PenaltyCreatePVector(Vec pg,Vec pf, double kmax); 75 76 bool InAnalysis(int analysis_type); 76 77 /*}}}*/ 77 78 /*Load management: {{{1*/ 78 void CreatePVectorDiagnosticMacAyeal2d(Vec pg );79 void CreatePVectorDiagnosticMacAyeal2d(Vec pg,Vec pf); 79 80 void CreatePVectorDiagnosticMacAyeal3d(Vec pg); 80 81 void CreatePVectorDiagnosticPattyn(Vec pg); 81 82 void CreatePVectorDiagnosticStokes(Vec pg); 82 void GetDofList(int** pdoflist,int approximation_enum=0); 83 void GetDofList(int** pdoflist,int approximation_enum,int setenum); 84 int* GetInternalDofList(int approximation_enum,int setenum); 85 int* GetExternalDofList(int approximation_enum,int setenum); 86 int GetNumberOfDofs(int approximation_enum,int setenum); 83 87 void QuadPressureLoad(double* pe_g,double rho_water,double rho_ice,double gravity, double* thickness_list, double* bed_list, 84 88 double* normal1,double* normal2,double* normal3,double* normal4,double* xyz_list); … … 86 90 double* normal1,double* normal2,double* normal3,double* normal4,double* xyz_list); 87 91 void GetNormal(double* normal,double xyz_list[2][3]); 92 ElementVector* NewElementVector(int approximation); 88 93 /*}}}*/ 89 94 }; -
issm/trunk/src/c/objects/Loads/Load.h
r4575 r5772 26 26 virtual void Configure(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters)=0; 27 27 virtual void SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters)=0; 28 virtual void CreateKMatrix(Mat Kgg )=0;29 virtual void CreatePVector(Vec pg )=0;30 virtual void PenaltyCreateKMatrix(Mat Kgg, double kmax)=0;31 virtual void PenaltyCreatePVector(Vec pg, double kmax)=0;28 virtual void CreateKMatrix(Mat Kgg,Mat Kff, Mat Kfs)=0; 29 virtual void CreatePVector(Vec pg, Vec pf)=0; 30 virtual void PenaltyCreateKMatrix(Mat Kgg,Mat Kff, Mat Kfs, double kmax)=0; 31 virtual void PenaltyCreatePVector(Vec pg, Vec pf, double kmax)=0; 32 32 virtual bool InAnalysis(int analysis_type)=0; 33 33 /*}}}*/ -
issm/trunk/src/c/objects/Loads/Numericalflux.cpp
r5741 r5772 328 328 /*}}}*/ 329 329 /*FUNCTION Numericalflux::CreateKMatrix {{{1*/ 330 void Numericalflux::CreateKMatrix(Mat Kgg ){330 void Numericalflux::CreateKMatrix(Mat Kgg,Mat Kff, Mat Kfs){ 331 331 332 332 int type; … … 349 349 /*}}}*/ 350 350 /*FUNCTION Numericalflux::CreatePVector {{{1*/ 351 void Numericalflux::CreatePVector(Vec pg ){351 void Numericalflux::CreatePVector(Vec pg,Vec pf){ 352 352 353 353 int type; … … 374 374 /*}}}*/ 375 375 /*FUNCTION Numericalflux::PenaltyCreateKMatrix {{{1*/ 376 void Numericalflux::PenaltyCreateKMatrix(Mat Kgg, double kmax){376 void Numericalflux::PenaltyCreateKMatrix(Mat Kgg,Mat Kff, Mat Kfs,double kmax){ 377 377 378 378 /*No stiffness loads applied, do nothing: */ … … 382 382 /*}}}*/ 383 383 /*FUNCTION Numericalflux::PenaltyCreatePVector{{{1*/ 384 void Numericalflux::PenaltyCreatePVector(Vec pg, double kmax){384 void Numericalflux::PenaltyCreatePVector(Vec pg,Vec pf,double kmax){ 385 385 386 386 /*No penalty loads applied, do nothing: */ … … 417 417 418 418 GetVerticesCoordinates(&xyz_list[0][0], nodes,NUMVERTICES_INTERNAL); 419 GetDofList(&doflist );419 GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 420 420 421 421 /*Retrieve all inputs and parameters we will be needing: */ … … 523 523 } 524 524 525 GetDofList(&doflist );525 GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 526 526 527 527 /* Start looping on the number of gaussian points: */ … … 617 617 } 618 618 619 GetDofList(&doflist );619 GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 620 620 621 621 /* Start looping on the number of gaussian points: */ … … 646 646 /*}}}*/ 647 647 /*FUNCTION Numericalflux::GetDofList {{{1*/ 648 void Numericalflux::GetDofList(int** pdoflist ){648 void Numericalflux::GetDofList(int** pdoflist,int approximation,int setenum){ 649 649 650 650 int i,j; … … 671 671 /*Figure out size of doflist: */ 672 672 for(i=0;i<numberofnodes;i++){ 673 numberofdofs+=nodes[i]->GetNumberOfDofs( );673 numberofdofs+=nodes[i]->GetNumberOfDofs(approximation,setenum); 674 674 } 675 675 … … 680 680 count=0; 681 681 for(i=0;i<numberofnodes;i++){ 682 nodes[i]->GetDofList(doflist+count );683 count+=nodes[i]->GetNumberOfDofs( );682 nodes[i]->GetDofList(doflist+count,approximation,setenum); 683 count+=nodes[i]->GetNumberOfDofs(approximation,setenum); 684 684 } 685 685 -
issm/trunk/src/c/objects/Loads/Numericalflux.h
r5739 r5772 65 65 void Configure(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters); 66 66 void SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters); 67 void CreateKMatrix(Mat Kgg );68 void CreatePVector(Vec pg );69 void PenaltyCreateKMatrix(Mat Kgg, double kmax);70 void PenaltyCreatePVector(Vec pg, double kmax);67 void CreateKMatrix(Mat Kgg, Mat Kff, Mat Kfs); 68 void CreatePVector(Vec pg, Vec pf); 69 void PenaltyCreateKMatrix(Mat Kgg,Mat Kff, Mat kfs, double kmax); 70 void PenaltyCreatePVector(Vec pg,Vec pf, double kmax); 71 71 bool InAnalysis(int analysis_type); 72 72 /*}}}*/ 73 73 /*Numericalflux management:{{{1*/ 74 void GetDofList(int** pdoflist );74 void GetDofList(int** pdoflist,int approximation_enum,int setenum); 75 75 void GetNormal(double* normal,double xyz_list[4][3]); 76 76 void CreateKMatrixInternal(Mat Kgg); -
issm/trunk/src/c/objects/Loads/Pengrid.cpp
r5735 r5772 281 281 /*}}}1*/ 282 282 /*FUNCTION Pengrid::CreateKMatrix {{{1*/ 283 void Pengrid::CreateKMatrix(Mat Kgg ){283 void Pengrid::CreateKMatrix(Mat Kgg,Mat Kff, Mat Kfs){ 284 284 285 285 /*No loads applied, do nothing: */ … … 289 289 /*}}}1*/ 290 290 /*FUNCTION Pengrid::CreatePVector {{{1*/ 291 void Pengrid::CreatePVector(Vec pg ){291 void Pengrid::CreatePVector(Vec pg,Vec pf){ 292 292 293 293 /*No loads applied, do nothing: */ … … 297 297 /*}}}1*/ 298 298 /*FUNCTION Pengrid::PenaltyCreateMatrix {{{1*/ 299 void Pengrid::PenaltyCreateKMatrix(Mat Kgg, double kmax){299 void Pengrid::PenaltyCreateKMatrix(Mat Kgg,Mat Kff, Mat Kfs,double kmax){ 300 300 301 301 int analysis_type; … … 320 320 /*}}}1*/ 321 321 /*FUNCTION Pengrid::PenaltyCreatePVector {{{1*/ 322 void Pengrid::PenaltyCreatePVector(Vec pg, double kmax){322 void Pengrid::PenaltyCreatePVector(Vec pg,Vec pf,double kmax){ 323 323 324 324 int analysis_type; … … 419 419 /*Pengrid management:*/ 420 420 /*FUNCTION Pengrid::GetDofList {{{1*/ 421 void Pengrid::GetDofList(int** pdoflist ){421 void Pengrid::GetDofList(int** pdoflist,int approximation,int setenum){ 422 422 423 423 int i,j; … … 431 431 432 432 /*First, figure out size of doflist: */ 433 numberofdofs=node->GetNumberOfDofs( );433 numberofdofs=node->GetNumberOfDofs(approximation,setenum); 434 434 435 435 /*Allocate: */ … … 437 437 438 438 /*Populate: */ 439 node->GetDofList(doflist );439 node->GetDofList(doflist,approximation,setenum); 440 440 441 441 /*Assign output pointers:*/ … … 567 567 568 568 /*Get dof list: */ 569 GetDofList(&doflist );569 GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 570 570 571 571 //recover slope: */ … … 620 620 621 621 /*Get dof list: */ 622 GetDofList(&doflist );622 GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 623 623 624 624 //Compute pressure melting point … … 656 656 657 657 /*Get dof list: */ 658 GetDofList(&doflist );658 GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 659 659 660 660 Ke[0][0]=kmax*pow((double)10,penalty_offset); … … 693 693 694 694 /*Get dof list: */ 695 GetDofList(&doflist );695 GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 696 696 697 697 //First recover pressure and temperature values, using the element: */ … … 756 756 757 757 /*Get dof list: */ 758 GetDofList(&doflist );758 GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 759 759 760 760 //First recover pressure and penalty_offset -
issm/trunk/src/c/objects/Loads/Pengrid.h
r5730 r5772 71 71 void Configure(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters); 72 72 void SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters); 73 void CreateKMatrix(Mat Kgg );74 void CreatePVector(Vec pg );75 void PenaltyCreateKMatrix(Mat Kgg, double kmax);76 void PenaltyCreatePVector(Vec pg, double kmax);73 void CreateKMatrix(Mat Kgg, Mat Kff, Mat Kfs); 74 void CreatePVector(Vec pg, Vec pf); 75 void PenaltyCreateKMatrix(Mat Kgg,Mat Kff, Mat kfs, double kmax); 76 void PenaltyCreatePVector(Vec pg,Vec pf, double kmax); 77 77 bool InAnalysis(int analysis_type); 78 78 /*}}}*/ 79 79 /*Pengrid management {{{1*/ 80 80 void PenaltyCreateKMatrixDiagnosticStokes(Mat Kgg,double kmax); 81 void GetDofList(int** pdoflist );81 void GetDofList(int** pdoflist,int approximation_enum,int setenum); 82 82 void PenaltyCreateKMatrixThermal(Mat Kgg,double kmax); 83 83 void PenaltyCreateKMatrixMelting(Mat Kgg,double kmax); -
issm/trunk/src/c/objects/Loads/Penpair.cpp
r5596 r5772 184 184 /*}}}1*/ 185 185 /*FUNCTION Penpair::CreateKMatrix {{{1*/ 186 void Penpair::CreateKMatrix(Mat Kgg ){186 void Penpair::CreateKMatrix(Mat Kgg,Mat Kff, Mat Kfs){ 187 187 /*If you code this piece, don't forget that a penalty will be inactive if it is dealing with clone nodes*/ 188 188 /*No loads applied, do nothing: */ … … 192 192 /*}}}1*/ 193 193 /*FUNCTION Penpair::CreatePVector {{{1*/ 194 void Penpair::CreatePVector(Vec pg ){194 void Penpair::CreatePVector(Vec pg,Vec pf){ 195 195 196 196 /*No loads applied, do nothing: */ … … 200 200 /*}}}1*/ 201 201 /*FUNCTION Penpair::PenaltyCreateKMatrix {{{1*/ 202 void Penpair::PenaltyCreateKMatrix(Mat Kgg, double kmax){202 void Penpair::PenaltyCreateKMatrix(Mat Kgg,Mat Kff, Mat Kfs,double kmax){ 203 203 int analysis_type; 204 204 … … 251 251 /*}}}1*/ 252 252 /*FUNCTION Penpair::PenaltyCreatePVector {{{1*/ 253 void Penpair::PenaltyCreatePVector(Vec pg, double kmax){253 void Penpair::PenaltyCreatePVector(Vec pg,Vec pf,double kmax){ 254 254 /*No loads applied, do nothing: */ 255 255 return; … … 297 297 298 298 /*Get dof list: */ 299 GetDofList(&doflist );299 GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 300 300 301 301 /*recover pointers: */ … … 340 340 341 341 /*Get dof list: */ 342 GetDofList(&doflist );342 GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 343 343 344 344 /*recover pointers: */ … … 378 378 /*}}}1*/ 379 379 /*FUNCTION Penpair::GetDofList {{{1*/ 380 void Penpair::GetDofList(int** pdoflist ){380 void Penpair::GetDofList(int** pdoflist,int approximation,int setenum){ 381 381 382 382 int i,j; … … 398 398 /*First, figure out size of doflist: */ 399 399 for(i=0;i<2;i++){ 400 numberofdofs+=nodes[i]->GetNumberOfDofs( );400 numberofdofs+=nodes[i]->GetNumberOfDofs(approximation,setenum); 401 401 } 402 402 … … 407 407 count=0; 408 408 for(i=0;i<2;i++){ 409 nodes[i]->GetDofList(doflist+count );410 count+=nodes[i]->GetNumberOfDofs( );409 nodes[i]->GetDofList(doflist+count,approximation,setenum); 410 count+=nodes[i]->GetNumberOfDofs(approximation,setenum); 411 411 } 412 412 -
issm/trunk/src/c/objects/Loads/Penpair.h
r5510 r5772 57 57 void Configure(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters); 58 58 void SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters); 59 void CreateKMatrix(Mat Kgg );60 void CreatePVector(Vec pg );61 void PenaltyCreateKMatrix(Mat Kgg, double kmax);62 void PenaltyCreatePVector(Vec pg, double kmax);59 void CreateKMatrix(Mat Kgg, Mat Kff, Mat Kfs); 60 void CreatePVector(Vec pg, Vec pf); 61 void PenaltyCreateKMatrix(Mat Kgg,Mat Kff, Mat kfs, double kmax); 62 void PenaltyCreatePVector(Vec pg,Vec pf, double kmax); 63 63 bool InAnalysis(int analysis_type); 64 64 /*}}}*/ … … 66 66 void PenaltyCreateKMatrixDiagnosticHoriz(Mat Kgg,double kmax); 67 67 void PenaltyCreateKMatrixDiagnosticStokes(Mat Kgg,double kmax); 68 void GetDofList(int** pdoflist );68 void GetDofList(int** pdoflist,int approximation_enum,int setenum); 69 69 /*}}}*/ 70 70 }; -
issm/trunk/src/c/objects/Loads/Riftfront.cpp
r5655 r5772 376 376 /*}}}*/ 377 377 /*FUNCTION Riftfront::CreateKMatrix {{{1*/ 378 void Riftfront::CreateKMatrix(Mat Kgg ){378 void Riftfront::CreateKMatrix(Mat Kgg,Mat Kff, Mat Kfs){ 379 379 /*do nothing: */ 380 380 } 381 381 /*}}}1*/ 382 382 /*FUNCTION Riftfront::CreatePVector {{{1*/ 383 void Riftfront::CreatePVector(Vec pg ){383 void Riftfront::CreatePVector(Vec pg,Vec pf){ 384 384 /*do nothing: */ 385 385 } 386 386 /*}}}1*/ 387 387 /*FUNCTION Riftfront::PenaltyCreateKMatrix {{{1*/ 388 void Riftfront::PenaltyCreateKMatrix(Mat Kgg, double kmax){388 void Riftfront::PenaltyCreateKMatrix(Mat Kgg,Mat Kff, Mat Kfs,double kmax){ 389 389 390 390 int i; … … 419 419 420 420 /* Get node coordinates and dof list: */ 421 GetDofList(&doflist );421 GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 422 422 423 423 /* Set Ke_gg to 0: */ … … 499 499 /*}}}1*/ 500 500 /*FUNCTION Riftfront::PenaltyCreatePVector {{{1*/ 501 void Riftfront::PenaltyCreatePVector(Vec pg, double kmax){501 void Riftfront::PenaltyCreatePVector(Vec pg,Vec pf,double kmax){ 502 502 503 503 int i ,j; … … 544 544 545 545 /* Get node coordinates and dof list: */ 546 GetDofList(&doflist );546 GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 547 547 548 548 /*Get some inputs: */ … … 731 731 /*}}}1*/ 732 732 /*FUNCTION Riftfront::GetDofList {{{1*/ 733 void Riftfront::GetDofList(int** pdoflist ){733 void Riftfront::GetDofList(int** pdoflist,int approximation,int setenum){ 734 734 735 735 int i,j; … … 751 751 /*Figure out size of doflist: */ 752 752 for(i=0;i<MAX_RIFTFRONT_GRIDS;i++){ 753 numberofdofs+=nodes[i]->GetNumberOfDofs( );753 numberofdofs+=nodes[i]->GetNumberOfDofs(approximation,setenum); 754 754 } 755 755 … … 760 760 count=0; 761 761 for(i=0;i<MAX_RIFTFRONT_GRIDS;i++){ 762 nodes[i]->GetDofList(doflist+count );763 count+=nodes[i]->GetNumberOfDofs( );762 nodes[i]->GetDofList(doflist+count,approximation,setenum); 763 count+=nodes[i]->GetNumberOfDofs(approximation,setenum); 764 764 } 765 765 -
issm/trunk/src/c/objects/Loads/Riftfront.h
r5655 r5772 74 74 void Configure(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters); 75 75 void SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters); 76 void CreateKMatrix(Mat Kgg );77 void CreatePVector(Vec pg );78 void PenaltyCreateKMatrix(Mat Kgg, double kmax);79 void PenaltyCreatePVector(Vec pg, double kmax);76 void CreateKMatrix(Mat Kgg, Mat Kff, Mat Kfs); 77 void CreatePVector(Vec pg, Vec pf); 78 void PenaltyCreateKMatrix(Mat Kgg,Mat Kff, Mat kfs, double kmax); 79 void PenaltyCreatePVector(Vec pg,Vec pf, double kmax); 80 80 bool InAnalysis(int analysis_type); 81 81 /*}}}*/ 82 82 /*Riftfront specific routines: {{{1*/ 83 void GetDofList(int** pdoflist );83 void GetDofList(int** pdoflist,int approximation_enum,int setenum); 84 84 bool PreStable(); 85 85 void SetPreStable(); -
issm/trunk/src/c/objects/Node.cpp
r5578 r5772 63 63 /*Intermediary*/ 64 64 int k; 65 int numdofs;65 int gsize; 66 66 67 67 /*id: */ … … 72 72 /*indexing:*/ 73 73 DistributeNumDofs(&this->indexing,analysis_type,iomodel->vertices_type+io_index); //number of dofs per node 74 numdofs=this->indexing.numberofdofs;74 gsize=this->indexing.gsize; 75 75 76 76 /*Hooks*/ … … 95 95 if (!iomodel->vertices_type) ISSMERROR("iomodel->vertices_type is NULL"); 96 96 if (iomodel->vertices_type[io_index]==MacAyealApproximationEnum && !iomodel->gridonbed[io_index]){ 97 for(k=1;k<= numdofs;k++) this->FreezeDof(k);97 for(k=1;k<=gsize;k++) this->FreezeDof(k); 98 98 } 99 99 if (iomodel->vertices_type[io_index]==MacAyealPattynApproximationEnum && iomodel->gridonmacayeal[io_index]){ 100 100 if(!iomodel->gridonbed[io_index]){ 101 for(k=1;k<= numdofs;k++) this->FreezeDof(k);101 for(k=1;k<=gsize;k++) this->FreezeDof(k); 102 102 } 103 103 } … … 106 106 if (!iomodel->gridonhutter) ISSMERROR("iomodel->gridonhutter is NULL"); 107 107 if (iomodel->gridonhutter[io_index]){ 108 for(k=1;k<= numdofs;k++){108 for(k=1;k<=gsize;k++){ 109 109 this->FreezeDof(k); 110 110 } … … 117 117 if (!iomodel->gridonhutter) ISSMERROR("iomodel->gridonhutter is NULL"); 118 118 if (!iomodel->gridonhutter[io_index]){ 119 for(k=1;k<= numdofs;k++){119 for(k=1;k<=gsize;k++){ 120 120 this->FreezeDof(k); 121 121 } … … 136 136 if (!iomodel->gridonbed) ISSMERROR("iomodel->gridonbed is NULL"); 137 137 if (!iomodel->gridonbed[io_index]){ 138 for(k=1;k<= numdofs;k++){138 for(k=1;k<=gsize;k++){ 139 139 this->FreezeDof(k); 140 140 } … … 199 199 int enum_type=0; 200 200 char* marshalled_inputs=NULL; 201 int marshalled_inputs _size;201 int marshalled_inputssize; 202 202 203 203 /*recover marshalled_dataset: */ … … 220 220 221 221 /*Marshall inputs: */ 222 marshalled_inputs _size=inputs->MarshallSize();222 marshalled_inputssize=inputs->MarshallSize(); 223 223 marshalled_inputs=inputs->Marshall(); 224 memcpy(marshalled_dataset,marshalled_inputs,marshalled_inputs _size*sizeof(char));225 marshalled_dataset+=marshalled_inputs _size;224 memcpy(marshalled_dataset,marshalled_inputs,marshalled_inputssize*sizeof(char)); 225 marshalled_dataset+=marshalled_inputssize; 226 226 227 227 /*Free ressources:*/ … … 294 294 295 295 /*Take care of hooking up all objects for this element, ie links the objects in the hooks to their respective 296 * datasets, using internal ids and off sets hidden in hooks: */296 * datasets, using internal ids and off_sets hidden in hooks: */ 297 297 hvertex->configure(verticesin); 298 298 … … 303 303 } 304 304 /*FUNCTION Node::GetDof {{{1*/ 305 int Node::GetDof(int dofindex){ 306 307 return indexing.doflist[dofindex]; 305 int Node::GetDof(int dofindex,int setenum){ 306 307 if(setenum==GsetEnum){ 308 return indexing.gdoflist[dofindex]; 309 } 310 else if(setenum==FsetEnum){ 311 return indexing.fdoflist[dofindex]; 312 } 313 else if(setenum==SsetEnum){ 314 return indexing.sdoflist[dofindex]; 315 } 316 else ISSMERROR("%s%s%s"," set of enum type ",EnumToString(setenum)," not supported yet!"); 308 317 309 318 } … … 320 329 /*}}}*/ 321 330 /*FUNCTION Node::GetDofList{{{1*/ 322 void Node::GetDofList(int* outdoflist,int approximation_enum ){331 void Node::GetDofList(int* outdoflist,int approximation_enum,int setenum){ 323 332 int i; 324 333 int count=0; 325 326 if(approximation_enum && this->indexing.doftype){ //if an approximation is specified and this node has several approsimations 327 for(i=0;i<this->indexing.numberofdofs;i++){ 328 if(indexing.doftype[i]==approximation_enum){ 329 outdoflist[count]=indexing.doflist[i]; 330 count++; 331 } 332 } 333 ISSMASSERT(count); 334 335 if(approximation_enum==NoneApproximationEnum){ 336 if(setenum==GsetEnum)for(i=0;i<this->indexing.gsize;i++) outdoflist[i]=indexing.gdoflist[i]; 337 if(setenum==FsetEnum)for(i=0;i<this->indexing.fsize;i++) outdoflist[i]=indexing.fdoflist[i]; 338 if(setenum==SsetEnum)for(i=0;i<this->indexing.ssize;i++) outdoflist[i]=indexing.sdoflist[i]; 334 339 } 335 340 else{ 336 for(i=0;i<this->indexing.numberofdofs;i++){ 337 outdoflist[i]=indexing.doflist[i]; 338 } 341 342 if(setenum==GsetEnum){ 343 if(indexing.doftype){ 344 count=0; 345 for(i=0;i<this->indexing.gsize;i++){ 346 if(indexing.doftype[i]==approximation_enum){ 347 outdoflist[count]=indexing.gdoflist[i]; 348 count++; 349 } 350 } 351 ISSMASSERT(count); 352 } 353 else for(i=0;i<this->indexing.gsize;i++) outdoflist[i]=indexing.gdoflist[i]; 354 } 355 else if(setenum==FsetEnum){ 356 if(indexing.doftype){ 357 count=0; 358 for(i=0;i<this->indexing.gsize;i++){ 359 if((indexing.doftype[i]==approximation_enum) && (indexing.f_set[i])){ 360 outdoflist[count]=indexing.fdoflist[i]; 361 count++; 362 } 363 } 364 ISSMASSERT(count); 365 } 366 else for(i=0;i<this->indexing.fsize;i++) outdoflist[i]=indexing.fdoflist[i]; 367 } 368 else if(setenum==SsetEnum){ 369 if(indexing.doftype){ 370 count=0; 371 for(i=0;i<this->indexing.gsize;i++){ 372 if((indexing.doftype[i]==approximation_enum) && (indexing.s_set[i])){ 373 outdoflist[count]=indexing.sdoflist[i]; 374 count++; 375 } 376 } 377 ISSMASSERT(count); 378 } 379 else for(i=0;i<this->indexing.ssize;i++) outdoflist[i]=indexing.sdoflist[i]; 380 } 381 else ISSMERROR("%s%s%s"," set of enum type ",EnumToString(setenum)," not supported yet!"); 382 } 383 } 384 /*}}}*/ 385 /*FUNCTION Node::GetInternalDofList{{{1*/ 386 void Node::GetInternalDofList(int* outdoflist,int approximation_enum,int setenum){ 387 int i; 388 int count=0; 389 int count2=0; 390 391 if(approximation_enum==NoneApproximationEnum){ 392 if(setenum==GsetEnum)for(i=0;i<this->indexing.gsize;i++) outdoflist[i]=i; 393 else if(setenum==FsetEnum){ 394 count=0; 395 for(i=0;i<this->indexing.fsize;i++){ 396 if(indexing.f_set[i]){ 397 outdoflist[count]=i; 398 count++; 399 } 400 } 401 } 402 else if(setenum==SsetEnum){ 403 count=0; 404 for(i=0;i<this->indexing.ssize;i++){ 405 if(indexing.s_set[i]){ 406 outdoflist[count]=i; 407 count++; 408 } 409 } 410 } 411 else ISSMERROR("%s%s%s"," set of enum type ",EnumToString(setenum)," not supported yet!"); 412 } 413 else{ 414 415 if(setenum==GsetEnum){ 416 if(indexing.doftype){ 417 count=0; 418 for(i=0;i<this->indexing.gsize;i++){ 419 if(indexing.doftype[i]==approximation_enum){ 420 outdoflist[count]=count; 421 count++; 422 } 423 } 424 ISSMASSERT(count); 425 } 426 else for(i=0;i<this->indexing.gsize;i++) outdoflist[i]=i; 427 } 428 else if(setenum==FsetEnum){ 429 430 if(indexing.doftype){ 431 count=0; 432 count2=0; 433 for(i=0;i<this->indexing.gsize;i++){ 434 if((indexing.doftype[i]==approximation_enum) && (indexing.f_set[i])){ 435 outdoflist[count]=count2; 436 count++; 437 } 438 if(indexing.doftype[i]==approximation_enum)count2++; 439 } 440 ISSMASSERT(count); 441 } 442 else{ 443 444 count=0; 445 for(i=0;i<this->indexing.gsize;i++){ 446 if(indexing.f_set[i]){ 447 outdoflist[count]=i; 448 count++; 449 } 450 } 451 } 452 } 453 else if(setenum==SsetEnum){ 454 if(indexing.doftype){ 455 count=0; 456 count2=0; 457 for(i=0;i<this->indexing.gsize;i++){ 458 if((indexing.doftype[i]==approximation_enum) && (indexing.s_set[i])){ 459 outdoflist[count]=count2; 460 count++; 461 } 462 if(indexing.doftype[i]==approximation_enum)count2++; 463 } 464 ISSMASSERT(count); 465 } 466 else{ 467 count=0; 468 for(i=0;i<this->indexing.gsize;i++){ 469 if(indexing.s_set[i]){ 470 outdoflist[count]=i; 471 count++; 472 } 473 } 474 } 475 } 476 else ISSMERROR("%s%s%s"," set of enum type ",EnumToString(setenum)," not supported yet!"); 339 477 } 340 478 } … … 380 518 /*Node numerics:*/ 381 519 /*FUNCTION Node::ApplyConstraints{{{1*/ 382 void Node::ApplyConstraint( Vec yg,int dof,double value){520 void Node::ApplyConstraint(int dof,double value){ 383 521 384 522 int index; 385 523 386 /* First, dof should be added in the s set, describing which524 /*Dof should be added in the s set, describing which 387 525 * dofs are constrained to a certain value (dirichlet boundary condition*/ 388 389 526 DofInSSet(dof-1); 390 391 /*Second, we should add value into yg, at dof corresponding to doflist[dof], unless 392 * we are a clone!*/ 393 394 if(!indexing.clone){ 395 396 index=indexing.doflist[dof-1]; //matlab indexing 397 398 VecSetValues(yg,1,&index,&value,INSERT_VALUES); 399 400 } 401 527 this->indexing.svalues[dof-1]=value; 402 528 } 403 529 /*}}}*/ … … 410 536 int i; 411 537 412 for(i=0;i<this->indexing. numberofdofs;i++){538 for(i=0;i<this->indexing.gsize;i++){ 413 539 414 540 /*g set: */ 415 VecSetValues(pv_g,1,&indexing. doflist[i],&gvalue,INSERT_VALUES);541 VecSetValues(pv_g,1,&indexing.gdoflist[i],&gvalue,INSERT_VALUES); 416 542 417 543 /*f set: */ 418 544 value=(double)this->indexing.f_set[i]; 419 VecSetValues(pv_f,1,&indexing. doflist[i],&value,INSERT_VALUES);545 VecSetValues(pv_f,1,&indexing.gdoflist[i],&value,INSERT_VALUES); 420 546 421 547 /*s set: */ 422 548 value=(double)this->indexing.s_set[i]; 423 VecSetValues(pv_s,1,&indexing.doflist[i],&value,INSERT_VALUES); 424 425 } 549 VecSetValues(pv_s,1,&indexing.gdoflist[i],&value,INSERT_VALUES); 550 551 } 552 553 554 } 555 /*}}}*/ 556 /*FUNCTION Node::CreateNodalConstraints{{{1*/ 557 void Node::CreateNodalConstraints(Vec ys){ 558 559 int i; 560 double* values=NULL; 561 int count; 562 563 /*Recover values for s set and plug them in constraints vector: */ 564 if(this->indexing.ssize){ 565 values=(double*)xmalloc(this->indexing.ssize*sizeof(double)); 566 count=0; 567 for(i=0;i<this->indexing.gsize;i++){ 568 if(this->indexing.s_set[i])values[count]=this->indexing.svalues[i]; 569 count++; 570 } 571 572 /*Add values into constraint vector: */ 573 VecSetValues(ys,this->indexing.ssize,this->indexing.sdoflist,values,INSERT_VALUES); 574 } 575 576 /*Free ressources:*/ 577 xfree((void**)&values); 426 578 427 579 … … 467 619 /*}}}*/ 468 620 /*FUNCTION Node::GetNumberOfDofs{{{1*/ 469 int Node::GetNumberOfDofs(int approximation_enum){ 621 int Node::GetNumberOfDofs(int approximation_enum,int setenum){ 622 623 /*Get number of degrees of freedom in a node, for a certain set (g,f or s-set) 624 *and for a certain approximation type: */ 470 625 471 626 int i; 472 627 int numdofs=0; 473 628 474 /*Count the dofs if an approximation is specified and the node contains several dofs type*/ 475 if(approximation_enum && this->indexing.doftype){ 476 for(i=0;i<this->indexing.numberofdofs;i++){ 477 if(this->indexing.doftype[i]==approximation_enum) numdofs++; 478 } 479 } 480 else numdofs=this->indexing.numberofdofs; 481 482 ISSMASSERT(numdofs); 629 if(approximation_enum==NoneApproximationEnum){ 630 if (setenum==GsetEnum) numdofs=this->indexing.gsize; 631 else if (setenum==FsetEnum) numdofs=this->indexing.fsize; 632 else if (setenum==SsetEnum) numdofs=this->indexing.ssize; 633 else ISSMERROR("%s%s%s"," set of enum type ",EnumToString(setenum)," not supported yet!"); 634 } 635 else{ 636 if(setenum==GsetEnum){ 637 if(this->indexing.doftype){ 638 numdofs=0; 639 for(i=0;i<this->indexing.gsize;i++){ 640 if(this->indexing.doftype[i]==approximation_enum) numdofs++; 641 } 642 } 643 else numdofs=this->indexing.gsize; 644 } 645 else if (setenum==FsetEnum){ 646 if(this->indexing.doftype){ 647 numdofs=0; 648 for(i=0;i<this->indexing.gsize;i++){ 649 if((this->indexing.doftype[i]==approximation_enum) && (this->indexing.f_set[i])) numdofs++; 650 } 651 } 652 else numdofs=this->indexing.fsize; 653 } 654 else if (setenum==SsetEnum){ 655 if(this->indexing.doftype){ 656 numdofs=0; 657 for(i=0;i<this->indexing.gsize;i++){ 658 if((this->indexing.doftype[i]==approximation_enum) && (this->indexing.s_set[i])) numdofs++; 659 } 660 } 661 else numdofs=this->indexing.ssize; 662 } 663 else ISSMERROR("%s%s%s"," set of enum type ",EnumToString(setenum)," not supported yet!"); 664 } 483 665 return numdofs; 484 485 666 } 486 667 /*}}}*/ … … 625 806 /* DofObject routines:*/ 626 807 /*FUNCTION Node::DistributeDofs{{{1*/ 627 void Node::DistributeDofs(int* pdofcount ){808 void Node::DistributeDofs(int* pdofcount,int setenum){ 628 809 629 810 int i; … … 638 819 } 639 820 640 /*This node should distribute dofs, go ahead: */ 641 for(i=0;i<this->indexing.numberofdofs;i++){ 642 indexing.doflist[i]=dofcount+i; 643 } 644 dofcount+=this->indexing.numberofdofs; 821 /*This node should distribute dofs for setenum set (eg, f_set or s_set), go ahead: */ 822 823 if(setenum==GsetEnum){ 824 for(i=0;i<this->indexing.gsize;i++){ 825 indexing.gdoflist[i]=dofcount+i; 826 } 827 dofcount+=this->indexing.gsize; 828 } 829 else if(setenum==FsetEnum){ 830 this->indexing.InitSet(setenum); 831 for(i=0;i<this->indexing.fsize;i++){ 832 indexing.fdoflist[i]=dofcount+i; 833 } 834 dofcount+=this->indexing.fsize; 835 } 836 else if(setenum==SsetEnum){ 837 this->indexing.InitSet(setenum); 838 for(i=0;i<this->indexing.ssize;i++){ 839 indexing.sdoflist[i]=dofcount+i; 840 } 841 dofcount+=this->indexing.ssize; 842 } 843 else ISSMERROR("%s%s%s"," set of enum type ",EnumToString(setenum)," not supported yet!"); 844 645 845 646 846 /*Assign output pointers: */ … … 649 849 } 650 850 /*}}}*/ 651 /*FUNCTION Node::Off setDofs{{{1*/652 void Node::OffsetDofs(int dofcount ){851 /*FUNCTION Node::Off_setDofs{{{1*/ 852 void Node::OffsetDofs(int dofcount,int setenum){ 653 853 654 854 int i; … … 656 856 657 857 if(indexing.clone){ 658 /*This node is a clone, don't off set the dofs!: */858 /*This node is a clone, don't off_set the dofs!: */ 659 859 return; 660 860 } 661 861 662 /*This node should offset the dofs, go ahead: */ 663 for(i=0;i<this->indexing.numberofdofs;i++){ 664 indexing.doflist[i]+=dofcount; 665 } 862 /*This node should off_set the dofs, go ahead: */ 863 if(setenum==GsetEnum){ 864 for(i=0;i<this->indexing.gsize;i++) indexing.gdoflist[i]+=dofcount; 865 } 866 else if(setenum==FsetEnum){ 867 for(i=0;i<this->indexing.fsize;i++) indexing.fdoflist[i]+=dofcount; 868 } 869 else if(setenum==SsetEnum){ 870 for(i=0;i<this->indexing.ssize;i++) indexing.sdoflist[i]+=dofcount; 871 } 872 else ISSMERROR("%s%s%s"," set of enum type ",EnumToString(setenum)," not supported yet!"); 666 873 } 667 874 /*}}}*/ 668 875 /*FUNCTION Node::ShowTrueDofs{{{1*/ 669 void Node::ShowTrueDofs(int* truedofs, int ncols ){876 void Node::ShowTrueDofs(int* truedofs, int ncols,int setenum){ 670 877 671 878 int j; … … 676 883 677 884 /*Ok, we are not a clone, just plug our dofs into truedofs: */ 678 for(j=0;j<this->indexing.numberofdofs;j++){ 679 *(truedofs+ncols*sid+j)=indexing.doflist[j]; 680 } 885 if(setenum==GsetEnum)for(j=0;j<this->indexing.gsize;j++) *(truedofs+ncols*sid+j)=indexing.gdoflist[j]; 886 else if(setenum==FsetEnum)for(j=0;j<this->indexing.fsize;j++) *(truedofs+ncols*sid+j)=indexing.fdoflist[j]; 887 else if(setenum==SsetEnum)for(j=0;j<this->indexing.ssize;j++) *(truedofs+ncols*sid+j)=indexing.sdoflist[j]; 888 else ISSMERROR("%s%s%s"," set of enum type ",EnumToString(setenum)," not supported yet!"); 889 681 890 } 682 891 /*}}}*/ 683 892 /*FUNCTION Node::UpdateCloneDofs{{{1*/ 684 void Node::UpdateCloneDofs(int* alltruedofs,int ncols ){893 void Node::UpdateCloneDofs(int* alltruedofs,int ncols,int setenum){ 685 894 686 895 int j; … … 693 902 /*Ok, we are a clone node, but we did not create the dofs for this node. 694 903 * * Therefore, our doflist is garbage right now. Go pick it up in the alltruedofs: */ 695 for(j=0;j<this->indexing.numberofdofs;j++){ 696 indexing.doflist[j]=*(alltruedofs+ncols*sid+j); 697 } 904 if(setenum==GsetEnum)for(j=0;j<this->indexing.gsize;j++) indexing.gdoflist[j]=*(alltruedofs+ncols*sid+j); 905 else if(setenum==FsetEnum)for(j=0;j<this->indexing.fsize;j++) indexing.fdoflist[j]=*(alltruedofs+ncols*sid+j); 906 else if(setenum==SsetEnum)for(j=0;j<this->indexing.ssize;j++) indexing.sdoflist[j]=*(alltruedofs+ncols*sid+j); 907 else ISSMERROR("%s%s%s"," set of enum type ",EnumToString(setenum)," not supported yet!"); 698 908 699 909 } -
issm/trunk/src/c/objects/Node.h
r5557 r5772 65 65 /*Node numerical routines {{{1*/ 66 66 void Configure(DataSet* nodes,Vertices* vertices); 67 void CreateNodalConstraints(Vec ys); 67 68 void SetCurrentConfiguration(DataSet* nodes,Vertices* vertices); 68 69 int Sid(void); … … 72 73 bool InAnalysis(int analysis_type); 73 74 int GetApproximation(); 74 int GetNumberOfDofs(int approximation_enum =0);75 int GetNumberOfDofs(int approximation_enum,int setenum); 75 76 int IsClone(); 76 void ApplyConstraint( Vec yg,int dof,double value);77 void ApplyConstraint(int dof,double value); 77 78 void DofInSSet(int dof); 78 int GetDof(int dofindex );79 int GetDof(int dofindex,int setenum); 79 80 void CreateVecSets(Vec pv_g,Vec pv_f,Vec pv_s); 80 81 int GetConnectivity(); 81 void GetDofList(int* poutdoflist,int approximation_enum=0); 82 void GetDofList(int* poutdoflist,int approximation_enum,int setenum); 83 void GetInternalDofList(int* poutdoflist,int approximation_enum,int setenum); 82 84 int GetDofList1(void); 83 85 double GetX(); … … 92 94 /*}}}*/ 93 95 /*Dof Object routines {{{1*/ 94 void DistributeDofs(int* pdofcount );95 void OffsetDofs(int dofcount );96 void ShowTrueDofs(int* truerows,int ncols );97 void UpdateCloneDofs(int* alltruerows,int ncols );96 void DistributeDofs(int* pdofcount,int setenum); 97 void OffsetDofs(int dofcount,int setenum); 98 void ShowTrueDofs(int* truerows,int ncols,int setenum); 99 void UpdateCloneDofs(int* alltruerows,int ncols,int setenum); 98 100 void SetClone(int* minranks); 99 101 void CreatePartition(Vec partition); -
issm/trunk/src/c/objects/objects.h
r5740 r5772 73 73 #include "./Materials/Matpar.h" 74 74 75 /*Numerics:*/ 76 #include "./Numerics/ElementMatrix.h" 77 #include "./Numerics/ElementVector.h" 78 75 79 76 80 /*Params: */ -
issm/trunk/src/c/solutions/ResetBoundaryConditions.cpp
r4445 r5772 10 10 11 11 int verbose=0; 12 Vec ug=NULL; 12 Vec yg=NULL; 13 Vec ys=NULL; 13 14 int analysis_counter; 14 15 … … 19 20 femmodel->SetCurrentConfiguration(analysis_type); 20 21 21 GetSolutionFromInputsx( & ug, femmodel->elements,femmodel->nodes, femmodel->vertices,femmodel->loads, femmodel->materials, femmodel->parameters);22 GetSolutionFromInputsx( &yg, femmodel->elements,femmodel->nodes, femmodel->vertices,femmodel->loads, femmodel->materials, femmodel->parameters); 22 23 23 /*For this analysis_type, free existing boundary condition vector s: */24 /*For this analysis_type, free existing boundary condition vector: */ 24 25 analysis_counter=femmodel->analysis_counter; 25 26 //global dof set27 VecFree(&femmodel->m_yg[analysis_counter]);28 //in the s-set29 26 VecFree(&femmodel->m_ys[analysis_counter]); 30 27 31 //Now, duplicate ug (the solution vector) into the boundary conditions vector on the g-set32 VecDuplicatePatch(&femmodel->m_yg[analysis_counter],ug);33 34 28 //Reduce from g to s set 35 Reducevectorgtosx(&femmodel->m_ys[analysis_counter],femmodel->m_yg[analysis_counter],femmodel->m_nodesets[analysis_counter]); 29 Reducevectorgtosx(&ys,yg,femmodel->m_nodesets[analysis_counter]); 30 31 /*Plug into femmodel->m_ys: */ 32 femmodel->m_ys[analysis_counter]=ys; 36 33 37 34 /*Free ressources:*/ 38 VecFree(&ug); 39 35 VecFree(&yg); 40 36 } -
issm/trunk/src/c/solvers/solver_adjoint_linear.cpp
r5695 r5772 17 17 Vec pg = NULL, pf=NULL; 18 18 19 SystemMatricesx(&Kgg, &pg,NULL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters);19 SystemMatricesx(&Kgg, NULL, NULL, &pg,NULL, NULL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters); 20 20 21 21 Reducematrixfromgtofx(&Kff,&Kfs,Kgg,femmodel->nodesets,femmodel->parameters); MatFree(&Kgg); -
issm/trunk/src/c/solvers/solver_diagnostic_nonlinear.cpp
r5695 r5772 12 12 void solver_diagnostic_nonlinear(FemModel* femmodel,bool conserve_loads){ 13 13 14 /*intermediary: */15 Mat Kgg = NULL, Kff = NULL, Kfs = NULL;16 Vec ug = NULL, uf = NULL, old_ug= NULL, old_uf = NULL;17 Vec pg = NULL, pf = NULL;18 Loads* loads=NULL;19 int converged;20 int constraints_converged;21 int num_unstable_constraints;22 int count;23 int min_mechanical_constraints;24 int max_nonlinear_iterations;25 26 14 /*parameters:*/ 27 int verbose=0;15 bool kff=false; 28 16 29 17 /*Recover parameters: */ 30 femmodel->parameters->FindParam(&verbose,VerboseEnum); 31 femmodel->parameters->FindParam(&min_mechanical_constraints,MinMechanicalConstraintsEnum); 32 femmodel->parameters->FindParam(&max_nonlinear_iterations,MaxNonlinearIterationsEnum); 33 34 /*Were loads requested as output? : */ 35 if(conserve_loads){ 36 loads=(Loads*)femmodel->loads->Copy(); //protect loads from being modified by the solution 37 } 38 else{ 39 loads=(Loads*)femmodel->loads; //modify loads in this solution 40 } 18 femmodel->parameters->FindParam(&kff,KffEnum); 41 19 42 count=1;43 converged=0;20 if(!kff) solver_diagnostic_nonlinear_kgg(femmodel,conserve_loads); 21 else solver_diagnostic_nonlinear_kff(femmodel,conserve_loads); 44 22 45 /*Start non-linear iteration using input velocity: */46 GetSolutionFromInputsx(&ug, femmodel->elements, femmodel->nodes, femmodel->vertices, loads, femmodel->materials, femmodel->parameters);47 Reducevectorgtofx(&uf, ug, femmodel->nodesets);48 49 //Update once again the solution to make sure that vx and vxold are similar (for next step in transient or steadystate)50 InputUpdateFromSolutionx(femmodel->elements,femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,ug);51 52 for(;;){53 54 //save pointer to old velocity55 VecFree(&old_ug);old_ug=ug;56 VecFree(&old_uf);old_uf=uf;57 58 SystemMatricesx(&Kgg, &pg,NULL,femmodel->elements,femmodel->nodes,femmodel->vertices,loads,femmodel->materials,femmodel->parameters);59 60 Reducematrixfromgtofx(&Kff,&Kfs,Kgg,femmodel->nodesets,femmodel->parameters); MatFree(&Kgg);61 62 Reduceloadfromgtofx(&pf, pg, Kfs, femmodel->ys, femmodel->nodesets,femmodel->parameters); VecFree(&pg); MatFree(&Kfs);63 64 Solverx(&uf, Kff, pf, old_uf, femmodel->parameters);65 66 Mergesolutionfromftogx(&ug, uf,femmodel->ys,femmodel->nodesets,femmodel->parameters);67 68 InputUpdateFromSolutionx( femmodel->elements,femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,ug);69 70 PenaltyConstraintsx(&constraints_converged, &num_unstable_constraints, femmodel->elements,femmodel->nodes,femmodel->vertices,loads,femmodel->materials,femmodel->parameters);71 if(verbose)_printf_(" number of unstable constraints: %i\n",num_unstable_constraints);72 73 convergence(&converged,Kff,pf,uf,old_uf,femmodel->parameters); MatFree(&Kff);VecFree(&pf);74 75 InputUpdateFromConstantx( femmodel->elements,femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,converged,ConvergedEnum);76 77 //rift convergence78 if (!constraints_converged) {79 if (converged){80 if (num_unstable_constraints <= min_mechanical_constraints) converged=1;81 else converged=0;82 }83 }84 85 /*Increase count: */86 count++;87 if(converged==1)break;88 if(count>=max_nonlinear_iterations){89 _printf_(" maximum number of iterations (%i) exceeded\n",max_nonlinear_iterations);90 break;91 }92 }93 94 /*clean-up*/95 if(conserve_loads) delete loads;96 VecFree(&uf);97 VecFree(&ug);98 VecFree(&old_uf);99 VecFree(&old_ug);100 101 23 } -
issm/trunk/src/c/solvers/solver_linear.cpp
r5695 r5772 15 15 Vec pg = NULL, pf = NULL; 16 16 17 SystemMatricesx(&Kgg, &pg,NULL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters);17 SystemMatricesx(&Kgg,NULL, NULL, &pg,NULL, NULL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters); 18 18 19 19 Reducematrixfromgtofx(&Kff,&Kfs,Kgg,femmodel->nodesets,femmodel->parameters); MatFree(&Kgg); -
issm/trunk/src/c/solvers/solver_thermal_nonlinear.cpp
r5707 r5772 51 51 52 52 53 SystemMatricesx(&Kgg, &pg,&melting_offset,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters);53 SystemMatricesx(&Kgg,NULL, NULL, &pg,NULL, &melting_offset,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters); 54 54 55 55 Reducematrixfromgtofx(&Kff,&Kfs,Kgg,femmodel->nodesets,femmodel->parameters); MatFree(&Kgg); -
issm/trunk/src/c/solvers/solvers.h
r4839 r5772 14 14 void solver_thermal_nonlinear(FemModel* femmodel); 15 15 void solver_diagnostic_nonlinear(FemModel* femmodel,bool conserve_loads); 16 void solver_diagnostic_nonlinear_kgg(FemModel* femmodel,bool conserve_loads); 17 void solver_diagnostic_nonlinear_kff(FemModel* femmodel,bool conserve_loads); 16 18 void solver_linear(FemModel* femmodel); 17 19 void solver_adjoint_linear(FemModel* femmodel); -
issm/trunk/src/m/classes/@model/model.m
r5631 r5772 309 309 md.qmu_relax=0; 310 310 311 %solution parameters 312 md.kff=0; 313 311 314 %partitioner: 312 315 md.adjacency=[]; -
issm/trunk/src/m/classes/@model/setdefaultparameters.m
r5631 r5772 256 256 %Ice solver: 'general' for Matlab's default solver (or 'lu' or 'sholesky') 257 257 md.solver_type='general'; 258 259 %solution speed-up 260 md.kff=0; -
issm/trunk/src/m/classes/public/marshall.m
r5631 r5772 138 138 WriteData(fid,md.stokesreconditioning,'Scalar','stokesreconditioning'); 139 139 WriteData(fid,md.waitonlock,'Scalar','waitonlock'); 140 WriteData(fid,md.kff,'Integer','kff'); 140 141 141 142 %Thermal parameters
Note:
See TracChangeset
for help on using the changeset viewer.