Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

elasticityRhs.C

Go to the documentation of this file.
00001 
00007 #include "petsc.h"
00008 #include "petscvec.h"
00009 #include "omg.h"
00010 #include "oda.h"
00011 #include "elasticityJac.h"
00012 #include "vecMass.h"
00013 
00014 PetscErrorCode ComputeElasticityRHS(ot::DAMG damg, Vec rhs) {
00015   PetscFunctionBegin;            
00016   ot::DA* da = damg->da;
00017   Vec tmp;
00018   VecDuplicate(rhs, &tmp);
00019   PetscScalar *inarray;
00020   VecZeroEntries(tmp);
00021   da->vecGetBuffer(tmp, inarray, false, false, false, 3);
00022 
00023   ElasticityData* data = (static_cast<ElasticityData*>(damg->user));
00024   unsigned char* bdyArr = data->bdyArr;
00025   unsigned int maxD;
00026   unsigned int balOctmaxD;
00027   if(da->iAmActive()) {
00028     maxD = da->getMaxDepth();
00029     balOctmaxD = maxD - 1;
00030     for(da->init<ot::DA_FLAGS::ALL>(); da->curr() < da->end<ot::DA_FLAGS::ALL>(); da->next<ot::DA_FLAGS::ALL>())  
00031     {
00032       Point pt;
00033       pt = da->getCurrentOffset();
00034       unsigned levelhere = da->getLevel(da->curr()) - 1;
00035       double hxOct = (double)((double)(1u << (balOctmaxD - levelhere))/(double)(1u << balOctmaxD));
00036       double x = (double)(pt.xint())/((double)(1u << (maxD-1)));
00037       double y = (double)(pt.yint())/((double)(1u << (maxD-1)));
00038       double z = (double)(pt.zint())/((double)(1u << (maxD-1)));
00039 
00040       unsigned int indices[8];
00041       da->getNodeIndices(indices); 
00042       double coord[8][3] = {
00043         {0.0,0.0,0.0},
00044         {1.0,0.0,0.0},
00045         {0.0,1.0,0.0},
00046         {1.0,1.0,0.0},
00047         {0.0,0.0,1.0},
00048         {1.0,0.0,1.0},
00049         {0.0,1.0,1.0},
00050         {1.0,1.0,1.0}
00051       };
00052       unsigned char hn = da->getHangingNodeIndex(da->curr());
00053 
00054       for(int i = 0; i < 8; i++)
00055       {
00056         if (!(hn & (1 << i))){
00057           //Dirichlet nodes will be set to 0
00058           if(!(bdyArr[indices[i]])) {
00059             //Some dummy loading with Fx = Fy = Fz at all pts.
00060             double xhere, yhere, zhere;
00061             xhere = x + coord[i][0]*hxOct ;
00062             yhere = y + coord[i][1]*hxOct;
00063             zhere = z + coord[i][2]*hxOct; 
00064             double rhsSum = 0.0;
00065             for(int freqCnt = 1; freqCnt < 10; freqCnt++) {
00066               double facsol = freqCnt;
00067               rhsSum  += (1.0 + 3*facsol*facsol*M_PI*M_PI)*cos(facsol*M_PI*xhere)*
00068                 cos(facsol*M_PI*yhere)*cos(facsol*M_PI*zhere);                                         
00069             }
00070             inarray[3*indices[i]] = rhsSum;
00071             inarray[(3*indices[i])+1] = rhsSum;
00072             inarray[(3*indices[i])+2] = rhsSum;
00073           }
00074         }
00075       }
00076     }
00077   }
00078 
00079   da->vecRestoreBuffer(tmp,inarray,false,false,false,3); 
00080 
00081   Mat vecMassMat;
00082   CreateConstVecMass(damg, &vecMassMat);
00083   ComputeConstVecMass(damg, vecMassMat, vecMassMat);
00084 
00085   MatMult(vecMassMat,tmp,rhs);
00086   MatDestroy(vecMassMat);
00087   VecDestroy(tmp);
00088 
00089   VecScale(rhs,-1.0);
00090 
00091   PetscFunctionReturn(0);
00092 }
00093 
00094 

Generated on Tue Mar 24 16:13:57 2009 for DENDRO by  doxygen 1.3.9.1