[23186] | 1 | Index: ../trunk-jpl/src/c/analyses/StressbalanceAnalysis.h
|
---|
| 2 | ===================================================================
|
---|
| 3 | --- ../trunk-jpl/src/c/analyses/StressbalanceAnalysis.h (revision 23161)
|
---|
| 4 | +++ ../trunk-jpl/src/c/analyses/StressbalanceAnalysis.h (revision 23162)
|
---|
| 5 | @@ -73,6 +73,7 @@
|
---|
| 6 | ElementMatrix* CreateKMatrixFSViscous(Element* element);
|
---|
| 7 | ElementMatrix* CreateKMatrixFSViscousLA(Element* element);
|
---|
| 8 | ElementMatrix* CreateKMatrixFSViscousXTH(Element* element);
|
---|
| 9 | + ElementMatrix* CreatePressureMassMatrix(Element* element);
|
---|
| 10 | ElementVector* CreatePVectorFS(Element* element);
|
---|
| 11 | ElementVector* CreatePVectorFSFriction(Element* element);
|
---|
| 12 | ElementVector* CreatePVectorFSFront(Element* element);
|
---|
| 13 | Index: ../trunk-jpl/src/c/analyses/StressbalanceAnalysis.cpp
|
---|
| 14 | ===================================================================
|
---|
| 15 | --- ../trunk-jpl/src/c/analyses/StressbalanceAnalysis.cpp (revision 23161)
|
---|
| 16 | +++ ../trunk-jpl/src/c/analyses/StressbalanceAnalysis.cpp (revision 23162)
|
---|
| 17 | @@ -3242,6 +3242,56 @@
|
---|
| 18 | xDelete<int>(cs_list);
|
---|
| 19 | return Ke;
|
---|
| 20 | }/*}}}*/
|
---|
| 21 | +ElementMatrix* StressbalanceAnalysis::CreatePressureMassMatrix(Element* element){/*{{{*/
|
---|
| 22 | +
|
---|
| 23 | + /*Intermediaries*/
|
---|
| 24 | + int i,dim;
|
---|
| 25 | + IssmDouble FSreconditioning,Jdet;
|
---|
| 26 | + IssmDouble *xyz_list = NULL;
|
---|
| 27 | +
|
---|
| 28 | + /*Get problem dimension*/
|
---|
| 29 | + element->FindParam(&dim,DomainDimensionEnum);
|
---|
| 30 | +
|
---|
| 31 | + /*Fetch number of nodes and dof for this finite element*/
|
---|
| 32 | + int vnumnodes = element->NumberofNodesVelocity();
|
---|
| 33 | + int pnumnodes = element->NumberofNodesPressure();
|
---|
| 34 | + int numdof = vnumnodes*dim + pnumnodes;
|
---|
| 35 | +
|
---|
| 36 | + /*Initialize Element matrix and vectors*/
|
---|
| 37 | + ElementMatrix* Ke = element->NewElementMatrix(FSvelocityEnum);
|
---|
| 38 | + IssmDouble* pbasis = xNew<IssmDouble>(pnumnodes);
|
---|
| 39 | +
|
---|
| 40 | + /*Retrieve all inputs and parameters*/
|
---|
| 41 | + element->GetVerticesCoordinates(&xyz_list);
|
---|
| 42 | + //element->FindParam(&FSreconditioning,StressbalanceFSreconditioningEnum);
|
---|
| 43 | +
|
---|
| 44 | + /* Start looping on the number of gaussian points: */
|
---|
| 45 | + Gauss* gauss = element->NewGauss(5);
|
---|
| 46 | + for(int ig=gauss->begin();ig<gauss->end();ig++){
|
---|
| 47 | + gauss->GaussPoint(ig);
|
---|
| 48 | +
|
---|
| 49 | + element->JacobianDeterminant(&Jdet,xyz_list,gauss);
|
---|
| 50 | + element->NodalFunctionsPressure(pbasis,gauss);
|
---|
| 51 | +
|
---|
| 52 | + if(dim==3){
|
---|
| 53 | + /*Pressure mass matrix*/
|
---|
| 54 | + for(int k=0;k<pnumnodes;k++){
|
---|
| 55 | + for(int j=0;j<pnumnodes;j++){
|
---|
| 56 | + Ke->values[(3*vnumnodes+k)*numdof+3*vnumnodes+j] += gauss->weight*Jdet*(pbasis[j]*pbasis[k]);
|
---|
| 57 | + }
|
---|
| 58 | + }
|
---|
| 59 | + }
|
---|
| 60 | + else{
|
---|
| 61 | + _error_("STOP");
|
---|
| 62 | + }
|
---|
| 63 | + }
|
---|
| 64 | +
|
---|
| 65 | + /*Clean up and return*/
|
---|
| 66 | + delete gauss;
|
---|
| 67 | + xDelete<IssmDouble>(xyz_list);
|
---|
| 68 | + xDelete<IssmDouble>(pbasis);
|
---|
| 69 | + return Ke;
|
---|
| 70 | +}/*}}}*/
|
---|
| 71 | ElementMatrix* StressbalanceAnalysis::CreateKMatrixFSViscousLA(Element* element){/*{{{*/
|
---|
| 72 |
|
---|
| 73 | /*Intermediaries*/
|
---|
| 74 | Index: ../trunk-jpl/src/c/solutionsequences/solutionsequence_schurcg.cpp
|
---|
| 75 | ===================================================================
|
---|
| 76 | --- ../trunk-jpl/src/c/solutionsequences/solutionsequence_schurcg.cpp (revision 23161)
|
---|
| 77 | +++ ../trunk-jpl/src/c/solutionsequences/solutionsequence_schurcg.cpp (revision 23162)
|
---|
| 78 | @@ -10,7 +10,7 @@
|
---|
| 79 | #include "../analyses/analyses.h"
|
---|
| 80 |
|
---|
| 81 | #ifdef _HAVE_PETSC_
|
---|
| 82 | -void SchurCGSolver(Vector<IssmDouble>** puf,Mat Kff, Vec pf, Vec uf0,Vec df,Parameters* parameters){/*{{{*/
|
---|
| 83 | +void SchurCGSolver(Vector<IssmDouble>** puf,Mat Kff,Mat Mff,Vec pf, Vec uf0,Vec df,Parameters* parameters){/*{{{*/
|
---|
| 84 |
|
---|
| 85 | /*Initialize output*/
|
---|
| 86 | Vec uf = NULL;
|
---|
| 87 | @@ -34,6 +34,7 @@
|
---|
| 88 | Vector<IssmDouble>* pf0 = NULL;
|
---|
| 89 | Vector<IssmDouble>* df = NULL;
|
---|
| 90 | Vector<IssmDouble>* ys = NULL;
|
---|
| 91 | + Matrix<IssmDouble>* Mff = NULL;
|
---|
| 92 |
|
---|
| 93 | /*parameters:*/
|
---|
| 94 | int max_nonlinear_iterations;
|
---|
| 95 | @@ -71,17 +72,32 @@
|
---|
| 96 | CreateNodalConstraintsx(&ys,femmodel->nodes,configuration_type);
|
---|
| 97 | Reduceloadx(pf, Kfs, ys); delete Kfs;
|
---|
| 98 |
|
---|
| 99 | + /*Create mass matrix*/
|
---|
| 100 | + int fsize; Kff->GetSize(&fsize,&fsize);
|
---|
| 101 | + Mff=new Matrix<IssmDouble>(fsize,fsize,100,4);
|
---|
| 102 | + StressbalanceAnalysis* analysis = new StressbalanceAnalysis();
|
---|
| 103 | + /*Get complete stiffness matrix without penalties*/
|
---|
| 104 | + for(int i=0;i<femmodel->elements->Size();i++){
|
---|
| 105 | + Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i));
|
---|
| 106 | + ElementMatrix* Me = analysis->CreatePressureMassMatrix(element);
|
---|
| 107 | + if(Me) Me->AddToGlobal(Mff,NULL);
|
---|
| 108 | + delete Me;
|
---|
| 109 | + }
|
---|
| 110 | + Mff->Assemble();
|
---|
| 111 | + delete analysis;
|
---|
| 112 | +
|
---|
| 113 | /*Solve*/
|
---|
| 114 | femmodel->profiler->Start(SOLVER);
|
---|
| 115 | _assert_(Kff->type==PetscMatType);
|
---|
| 116 | SchurCGSolver(&uf,
|
---|
| 117 | Kff->pmatrix->matrix,
|
---|
| 118 | + Mff->pmatrix->matrix,
|
---|
| 119 | pf->pvector->vector,
|
---|
| 120 | old_uf->pvector->vector,
|
---|
| 121 | df->pvector->vector,
|
---|
| 122 | femmodel->parameters);
|
---|
| 123 | femmodel->profiler->Stop(SOLVER);
|
---|
| 124 | - delete pf0;
|
---|
| 125 | + delete pf0; delete Mff;
|
---|
| 126 |
|
---|
| 127 | /*Merge solution from f set to g set*/
|
---|
| 128 | Mergesolutionfromftogx(&ug, uf,ys,femmodel->nodes,femmodel->parameters);delete ys;
|
---|