35 #include "ModeLaplace2DQ2.h"
36 #include "Teuchos_Assert.hpp"
39 const int ModeLaplace2DQ2::dofEle = 9;
40 const int ModeLaplace2DQ2::maxConnect = 25;
42 const double ModeLaplace2DQ2::M_PI = 3.14159265358979323846;
46 ModeLaplace2DQ2::ModeLaplace2DQ2(
const Epetra_Comm &_Comm,
double _Lx,
int _nX,
67 ModeLaplace2DQ2::~ModeLaplace2DQ2() {
92 void ModeLaplace2DQ2::preProcess() {
98 bool *isTouched =
new bool[nX*nY];
100 for (j = 0; j < nY; ++j)
102 isTouched[i + j*nX] =
false;
104 int numEle = countElements(isTouched);
107 int *elemTopo =
new int[dofEle*numEle];
108 makeMyElementsTopology(elemTopo, isTouched);
113 int localSize = Map->NumMyElements();
114 int *numNz =
new int[localSize];
115 int *connectivity =
new int[localSize*maxConnect];
116 makeMyConnectivity(elemTopo, numEle, connectivity, numNz);
119 makeStiffness(elemTopo, numEle, connectivity, numNz);
122 makeMass(elemTopo, numEle, connectivity, numNz);
127 delete[] connectivity;
133 x =
new double[localSize];
134 y =
new double[localSize];
136 for (j=0; j<2*nY-1; ++j) {
137 for (i=0; i<2*nX-1; ++i) {
138 int node = i + j*(2*nX-1);
139 if (Map->LID(node) > -1) {
140 x[Map->LID(node)] = (i+1)*hx*0.5;
141 y[Map->LID(node)] = (j+1)*hy*0.5;
149 void ModeLaplace2DQ2::makeMap() {
151 int numProc = MyComm.NumProc();
152 int globalSize = (2*nX - 1)*(2*nY - 1);
153 assert(globalSize > numProc);
157 int *start =
new int[globalSize+1];
158 memset(start, 0, (globalSize+1)*
sizeof(
int));
161 for (j=0; j<2*nY-1; ++j) {
162 for (i=0; i<2*nX-1; ++i) {
163 int node = i + j*(2*nX-1);
166 connect *= ((i == 1) || (i == 2*nX-3)) ? 4 : 5;
169 connect *= ((i == 0) || (i == 2*nX-2)) ? 2 : 3;
172 connect *= ((j == 1) || (j == 2*nY-3)) ? 4 : 5;
175 connect *= ((j == 0) || (j == 2*nY-2)) ? 2 : 3;
178 start[node+1] = connect - 1;
182 for (i = 0; i < globalSize; ++i)
183 start[i+1] += start[i];
185 int *adjacency =
new int[start[globalSize]];
186 memset(adjacency, 0, start[globalSize]*
sizeof(
int));
188 int *elemTopo =
new int[dofEle];
189 for (j=0; j<nY; ++j) {
190 for (i=0; i<nX; ++i) {
191 int middleMiddle = 2*i + 2*j*(2*nX - 1);
192 elemTopo[0] = ((i==0) || (j==0)) ? -1 : middleMiddle - 2*nX;
193 elemTopo[1] = ((i==nX-1) || (j==0)) ? -1 : middleMiddle - 2*nX + 2;
194 elemTopo[2] = ((i==nX-1) || (j==nY-1)) ? -1 : middleMiddle + 2*nX;
195 elemTopo[3] = ((i==0) || (j==nY-1)) ? -1 : middleMiddle + 2*nX - 2;
196 elemTopo[4] = (j==0) ? -1 : middleMiddle - 2*nX + 1;
197 elemTopo[5] = (i==nX-1) ? -1 : middleMiddle + 1;
198 elemTopo[6] = (j==nY-1) ? -1 : middleMiddle + 2*nX - 1;
199 elemTopo[7] = (i==0) ? -1 : middleMiddle - 1;
200 elemTopo[8] = middleMiddle;
201 for (
int iD = 0; iD < dofEle; ++iD) {
202 if (elemTopo[iD] == -1)
204 for (
int jD = 0; jD < dofEle; ++jD) {
205 int neighbor = elemTopo[jD];
207 if ((neighbor == -1) || (iD == jD))
210 for (
int l = start[elemTopo[iD]]; l < start[elemTopo[iD]+1]; ++l) {
212 if (adjacency[l] == neighbor + 1)
214 if (adjacency[l] == 0) {
217 adjacency[l] = elemTopo[jD] + 1;
231 short int *partition =
new short int[globalSize];
233 interface(globalSize, start, adjacency, 0, 0, 0, 0, 0, 0, 0,
234 partition, 1, 1, nDir, 0, 1, 1, 1, 250, 1, 0.001, 7654321L);
237 int myPid = MyComm.MyPID();
238 for (i = 0; i < globalSize; ++i) {
239 if (partition[i] == myPid)
242 int *myRows =
new int[localSize];
244 for (i = 0; i < globalSize; ++i) {
245 if (partition[i] == myPid) {
246 myRows[localSize] = i;
253 Map =
new Epetra_Map(globalSize, localSize, myRows, 0, MyComm);
263 int ModeLaplace2DQ2::countElements(
bool *isTouched) {
271 for (j=0; j<nY; ++j) {
272 for (i=0; i<nX; ++i) {
273 isTouched[i + j*nX] =
false;
274 int middleMiddle = 2*i + 2*j*(2*nX - 1);
276 node = ((i==0) || (j==0)) ? -1 : middleMiddle - 2*nX;
277 if ((node > -1) && (Map->LID(node) > -1)) {
278 isTouched[i+j*nX] =
true;
282 node = ((i==nX-1) || (j==0)) ? -1 : middleMiddle - 2*nX + 2;
283 if ((node > -1) && (Map->LID(node) > -1)) {
284 isTouched[i+j*nX] =
true;
288 node = ((i==nX-1) || (j==nY-1)) ? -1 : middleMiddle + 2*nX;
289 if ((node > -1) && (Map->LID(node) > -1)) {
290 isTouched[i+j*nX] =
true;
294 node = ((i==0) || (j==nY-1)) ? -1 : middleMiddle + 2*nX - 2;
295 if ((node > -1) && (Map->LID(node) > -1)) {
296 isTouched[i+j*nX] =
true;
300 node = (j==0) ? -1 : middleMiddle - 2*nX + 1;
301 if ((node > -1) && (Map->LID(node) > -1)) {
302 isTouched[i+j*nX] =
true;
306 node = (i==nX-1) ? -1 : middleMiddle + 1;
307 if ((node > -1) && (Map->LID(node) > -1)) {
308 isTouched[i+j*nX] =
true;
312 node = (j==nY-1) ? -1 : middleMiddle + 2*nX - 1;
313 if ((node > -1) && (Map->LID(node) > -1)) {
314 isTouched[i+j*nX] =
true;
318 node = (i==0) ? -1 : middleMiddle - 1;
319 if ((node > -1) && (Map->LID(node) > -1)) {
320 isTouched[i+j*nX] =
true;
325 if ((node > -1) && (Map->LID(node) > -1)) {
326 isTouched[i+j*nX] =
true;
338 void ModeLaplace2DQ2::makeMyElementsTopology(
int *elemTopo,
bool *isTouched) {
346 for (j=0; j<nY; ++j) {
347 for (i=0; i<nX; ++i) {
348 if (isTouched[i + j*nX] ==
false)
350 int middleMiddle = 2*i + 2*j*(2*nX - 1);
351 elemTopo[dofEle*numEle] = ((i==0) || (j==0)) ? -1 : middleMiddle - 2*nX;
352 elemTopo[dofEle*numEle+1] = ((i==nX-1) || (j==0)) ? -1 : middleMiddle - 2*nX + 2;
353 elemTopo[dofEle*numEle+2] = ((i==nX-1) || (j==nY-1)) ? -1 : middleMiddle + 2*nX;
354 elemTopo[dofEle*numEle+3] = ((i==0) || (j==nY-1)) ? -1 : middleMiddle + 2*nX - 2;
355 elemTopo[dofEle*numEle+4] = (j==0) ? -1 : middleMiddle - 2*nX + 1;
356 elemTopo[dofEle*numEle+5] = (i==nX-1) ? -1 : middleMiddle + 1;
357 elemTopo[dofEle*numEle+6] = (j==nY-1) ? -1 : middleMiddle + 2*nX - 1;
358 elemTopo[dofEle*numEle+7] = (i==0) ? -1 : middleMiddle - 1;
359 elemTopo[dofEle*numEle+8] = middleMiddle;
367 void ModeLaplace2DQ2::makeMyConnectivity(
int *elemTopo,
int numEle,
int *connectivity,
374 int localSize = Map->NumMyElements();
376 for (i=0; i<localSize; ++i) {
378 for (j=0; j<maxConnect; ++j) {
379 connectivity[i*maxConnect + j] = -1;
383 for (i=0; i<numEle; ++i) {
384 for (j=0; j<dofEle; ++j) {
385 if (elemTopo[dofEle*i+j] == -1)
387 int node = Map->LID(elemTopo[dofEle*i+j]);
390 for (k=0; k<dofEle; ++k) {
391 int neighbor = elemTopo[dofEle*i+k];
396 for (l=0; l<maxConnect; ++l) {
397 if (neighbor == connectivity[node*maxConnect + l])
399 if (connectivity[node*maxConnect + l] == -1) {
400 connectivity[node*maxConnect + l] = neighbor;
413 void ModeLaplace2DQ2::makeStiffness(
int *elemTopo,
int numEle,
int *connectivity,
420 int localSize = Map->NumMyElements();
422 double *values =
new double[maxConnect];
423 for (i=0; i<maxConnect; ++i)
426 for (i=0; i<localSize; ++i) {
427 int info = K->InsertGlobalValues(Map->GID(i), numNz[i], values, connectivity+maxConnect*i);
429 "ModeLaplace2DQ2::makeStiffness(): InsertGlobalValues() returned error code " << info);
433 double *kel =
new double[dofEle*dofEle];
434 makeElementaryStiffness(kel);
437 int *indices =
new int[dofEle];
440 for (i=0; i<numEle; ++i) {
441 for (j=0; j<dofEle; ++j) {
442 if (elemTopo[dofEle*i + j] == -1)
444 if (Map->LID(elemTopo[dofEle*i+j]) == -1)
448 for (k=0; k<dofEle; ++k) {
449 if (elemTopo[dofEle*i+k] == -1)
451 indices[numEntries] = elemTopo[dofEle*i+k];
452 values[numEntries] = kel[dofEle*j + k];
455 int info = K->SumIntoGlobalValues(elemTopo[dofEle*i+j], numEntries, values, indices);
457 "ModeLaplace2DQ2::makeStiffness(): SumIntoGlobalValues() returned error code " << info);
465 int info = K->FillComplete();
467 "ModeLaplace2DQ2::makeStiffness(): FillComplete() returned error code " << info);
468 info = K->OptimizeStorage();
470 "ModeLaplace2DQ2::makeStiffness(): OptimizeStorage() returned error code " << info);
475 void ModeLaplace2DQ2::makeElementaryStiffness(
double *kel)
const {
482 for (i=0; i<dofEle; ++i) {
483 for (j=0; j<dofEle; ++j) {
484 kel[j + dofEle*i] = 0.0;
488 double gaussP[3], gaussW[3];
489 gaussP[0] = - sqrt(3.0/5.0); gaussP[1] = 0.0; gaussP[2] = - gaussP[0];
490 gaussW[0] = 5.0/9.0; gaussW[1] = 8.0/9.0; gaussW[2] = 5.0/9.0;
491 double jac = hx*hy/4.0;
492 double *qx =
new double[dofEle];
493 double *qy =
new double[dofEle];
494 for (i=0; i<3; ++i) {
495 double xi = gaussP[i];
496 double wi = gaussW[i];
497 for (j=0; j<3; ++j) {
498 double eta = gaussP[j];
499 double wj = gaussW[j];
501 qx[0] = 2.0/hx*(xi-0.5)*0.5*eta*(eta-1.0);
502 qx[1] = 2.0/hx*(xi+0.5)*0.5*eta*(eta-1.0);
503 qx[2] = 2.0/hx*(xi+0.5)*0.5*eta*(eta+1.0);
504 qx[3] = 2.0/hx*(xi-0.5)*0.5*eta*(eta+1.0);
505 qx[4] = 2.0/hx*(-2.0*xi)*0.5*eta*(eta-1.0);
506 qx[5] = 2.0/hx*(xi+0.5)*(eta+1.0)*(1.0-eta);
507 qx[6] = 2.0/hx*(-2.0*xi)*0.5*eta*(eta+1.0);
508 qx[7] = 2.0/hx*(xi-0.5)*(eta+1.0)*(1.0-eta);
509 qx[8] = 2.0/hx*(-2.0*xi)*(eta+1.0)*(1.0-eta);
510 qy[0] = 2.0/hy*0.5*xi*(xi-1.0)*(eta-0.5);
511 qy[1] = 2.0/hy*0.5*xi*(xi+1.0)*(eta-0.5);
512 qy[2] = 2.0/hy*0.5*xi*(xi+1.0)*(eta+0.5);
513 qy[3] = 2.0/hy*0.5*xi*(xi-1.0)*(eta+0.5);
514 qy[4] = 2.0/hy*(xi+1.0)*(1.0-xi)*(eta-0.5);
515 qy[5] = 2.0/hy*0.5*xi*(xi+1.0)*(-2.0*eta);
516 qy[6] = 2.0/hy*(xi+1.0)*(1.0-xi)*(eta+0.5);
517 qy[7] = 2.0/hy*0.5*xi*(xi-1.0)*(-2.0*eta);
518 qy[8] = 2.0/hy*(xi+1.0)*(1.0-xi)*(-2.0*eta);
521 for (ii=0; ii<dofEle; ++ii) {
522 for (jj=ii; jj<dofEle; ++jj) {
523 kel[dofEle*ii + jj] += wi*wj*jac*(qx[ii]*qx[jj] + qy[ii]*qy[jj]);
524 kel[dofEle*jj + ii] = kel[dofEle*ii + jj];
535 void ModeLaplace2DQ2::makeMass(
int *elemTopo,
int numEle,
int *connectivity,
542 int localSize = Map->NumMyElements();
544 double *values =
new double[maxConnect];
545 for (i=0; i<maxConnect; ++i)
547 for (i=0; i<localSize; ++i) {
548 int info = M->InsertGlobalValues(Map->GID(i), numNz[i], values, connectivity + maxConnect*i);
550 "ModeLaplace2DQ2::makeMass(): InsertGlobalValues() returned error code " << info);
554 double *mel =
new double[dofEle*dofEle];
555 makeElementaryMass(mel);
558 int *indices =
new int[dofEle];
561 for (i=0; i<numEle; ++i) {
562 for (j=0; j<dofEle; ++j) {
563 if (elemTopo[dofEle*i + j] == -1)
565 if (Map->LID(elemTopo[dofEle*i+j]) == -1)
569 for (k=0; k<dofEle; ++k) {
570 if (elemTopo[dofEle*i+k] == -1)
572 indices[numEntries] = elemTopo[dofEle*i+k];
573 values[numEntries] = mel[dofEle*j + k];
576 int info = M->SumIntoGlobalValues(elemTopo[dofEle*i+j], numEntries, values, indices);
578 "ModeLaplace2DQ2::makeMass(): SumIntoGlobalValues() returned error code " << info);
586 int info = M->FillComplete();
588 "ModeLaplace2DQ2::makeMass(): FillComplete() returned error code " << info);
589 info = M->OptimizeStorage();
591 "ModeLaplace2DQ2::makeMass(): OptimizeStorage() returned error code " << info);
596 void ModeLaplace2DQ2::makeElementaryMass(
double *mel)
const {
603 for (i=0; i<dofEle; ++i) {
604 for (j=0; j<dofEle; ++j) {
605 mel[j + dofEle*i] = 0.0;
609 double gaussP[3], gaussW[3];
610 gaussP[0] = - sqrt(3.0/5.0); gaussP[1] = 0.0; gaussP[2] = - gaussP[0];
611 gaussW[0] = 5.0/9.0; gaussW[1] = 8.0/9.0; gaussW[2] = 5.0/9.0;
612 double jac = hx*hy/4.0;
613 double *q =
new double[dofEle];
614 for (i=0; i<3; ++i) {
615 double xi = gaussP[i];
616 double wi = gaussW[i];
617 for (j=0; j<3; ++j) {
618 double eta = gaussP[j];
619 double wj = gaussW[j];
621 q[0] = 0.5*xi*(xi-1.0)*0.5*eta*(eta-1.0);
622 q[1] = 0.5*xi*(xi+1.0)*0.5*eta*(eta-1.0);
623 q[2] = 0.5*xi*(xi+1.0)*0.5*eta*(eta+1.0);
624 q[3] = 0.5*xi*(xi-1.0)*0.5*eta*(eta+1.0);
625 q[4] = (xi+1.0)*(1.0-xi)*0.5*eta*(eta-1.0);
626 q[5] = 0.5*xi*(xi+1.0)*(eta+1.0)*(1.0-eta);
627 q[6] = (xi+1.0)*(1.0-xi)*0.5*eta*(eta+1.0);
628 q[7] = 0.5*xi*(xi-1.0)*(eta+1.0)*(1.0-eta);
629 q[8] = (xi+1.0)*(1.0-xi)*(eta+1.0)*(1.0-eta);
632 for (ii=0; ii<dofEle; ++ii) {
633 for (jj=ii; jj<dofEle; ++jj) {
634 mel[dofEle*ii + jj] += wi*wj*jac*q[ii]*q[jj];
635 mel[dofEle*jj + ii] = mel[dofEle*ii + jj];
645 double ModeLaplace2DQ2::getFirstMassEigenValue()
const {
651 double cosj = cos(M_PI*hy/2/Ly);
653 double b = 4.0 + cos(M_PI*hy/Ly);
654 double c = -2.0*cosj;
655 double delta = sqrt(b*b - 4*a*c);
656 double alphay = (-b - delta)*0.5/a;
659 double cosi = cos(M_PI*hx/2/Lx);
661 b = 4.0 + cos(M_PI*hx/Lx);
663 delta = sqrt(b*b - 4*a*c);
664 double alphax = (-b - delta)*0.5/a;
666 double discrete = hx/15.0*(8.0+2*alphax*cosi);
667 discrete *= hy/15.0*(8.0+2*alphay*cosj);
675 double *normWeight)
const {
678 int qc = Q.NumVectors();
679 int myPid = MyComm.MyPID();
682 cout.setf(ios::scientific, ios::floatfield);
685 double tmp = myVerify.errorOrthonormality(&Q, M);
687 cout <<
" Maximum coefficient in matrix Q^T M Q - I = " << tmp << endl;
690 myVerify.errorEigenResiduals(Q, lambda, K, M, normWeight);
693 int numX = (int) ceil(sqrt(Lx*Lx*lambda[qc-1]/M_PI/M_PI));
694 numX = (numX > 2*nX) ? 2*nX : numX;
695 int numY = (int) ceil(sqrt(Ly*Ly*lambda[qc-1]/M_PI/M_PI));
696 numY = (numY > 2*nY) ? 2*nY : numY;
697 int newSize = (numX-1)*(numY-1);
698 double *discrete =
new (nothrow)
double[2*newSize];
702 double *continuous = discrete + newSize;
708 for (j = 1; j< numY; ++j) {
710 double cosj = cos(j*M_PI*hy/2/Ly);
711 double a = cosj*(92.0 - 12.0*cos(j*M_PI*hy/Ly));
712 double b = 48.0 + 32.0*cos(j*M_PI*hy/Ly);
713 double c = -160.0*cosj;
714 double delta = sqrt(b*b - 4*a*c);
715 double alphay = ((-b - delta)*0.5/a < 0.0) ? (-b + delta)*0.5/a : (-b - delta)*0.5/a;
716 for (i = 1; i < numX; ++i) {
717 int pos = i-1 + (j-1)*(numX-1);
718 continuous[pos] = M_PI*M_PI*(i*i/(Lx*Lx) + j*j/(Ly*Ly));
720 double cosi = cos(i*M_PI*hx/2/Lx);
721 a = cosi*(92.0 - 12.0*cos(i*M_PI*hx/Lx));
722 b = 48.0 + 32.0*cos(i*M_PI*hx/Lx);
724 delta = sqrt(b*b - 4*a*c);
725 double alphax = ((-b - delta)*0.5/a < 0.0) ? (-b + delta)*0.5/a : (-b - delta)*0.5/a;
727 discrete[pos] = 240.0*(1.0-alphax*cosi)/((8.0+2*alphax*cosi)*(3.0*hx*hx));
728 discrete[pos] += 240.0*(1.0-alphay*cosj)/((8.0+2*alphay*cosj)*(3.0*hy*hy));
733 mySort.sortScalars(newSize, continuous);
735 int *used =
new (nothrow)
int[newSize];
741 mySort.sortScalars(newSize, discrete, used);
743 int *index =
new (nothrow)
int[newSize];
750 for (i=0; i<newSize; ++i) {
755 int nMax = myVerify.errorLambda(continuous, discrete, newSize, lambda, qc);
758 int localSize = Map->NumMyElements();
759 double *vQ =
new (nothrow)
double[(nMax+1)*localSize + nMax];
767 double *normL2 = vQ + (nMax+1)*localSize;
770 if ((myPid == 0) && (nMax > 0)) {
772 cout <<
" --- Relative discretization errors for exact eigenvectors ---" << endl;
774 cout <<
" Cont. Values Disc. Values Error H^1 norm L^2 norm\n";
777 for (j=1; j < numY; ++j) {
778 for (i=1; i < numX; ++i) {
779 if (index[i-1 + (j-1)*(numX-1)] < nMax) {
781 double cosj = cos(j*M_PI*hy/2/Ly);
782 double a = cosj*(92.0 - 12.0*cos(j*M_PI*hy/Ly));
783 double b = 48.0 + 32.0*cos(j*M_PI*hy/Ly);
784 double c = -160.0*cosj;
785 double delta = sqrt(b*b - 4*a*c);
786 double alphay = ((-b - delta)*0.5/a < 0.0) ? (-b + delta)*0.5/a : (-b - delta)*0.5/a;
787 double cosi = cos(i*M_PI*hx/2/Lx);
788 a = cosi*(92.0 - 12.0*cos(i*M_PI*hx/Lx));
789 b = 48.0 + 32.0*cos(i*M_PI*hx/Lx);
791 delta = sqrt(b*b - 4*a*c);
792 double alphax = ((-b - delta)*0.5/a < 0.0) ? (-b + delta)*0.5/a : (-b - delta)*0.5/a;
794 for (ii=0; ii<localSize; ++ii) {
795 double coeff = sin(i*(M_PI/Lx)*x[ii])*sin(j*(M_PI/Ly)*y[ii]);
796 if (fabs(x[ii] - floor(x[ii]/hx+0.5)*hx) < 0.25*hx)
798 if (fabs(y[ii] - floor(y[ii]/hy+0.5)*hy) < 0.25*hy)
800 Qex.ReplaceMyValue(ii, index[i-1+(j-1)*(numX-1)], coeff);
807 Qi.Dot(MQex, &mnorm);
808 Qi.Scale(1.0/sqrt(mnorm));
811 for (ii=0; ii<localSize; ++ii) {
813 if (fabs(x[ii] - floor(x[ii]/hx+0.5)*hx) < 0.25*hx)
814 iX = 2.0*sin(i*(M_PI/Lx)*x[ii])/(hx*hx*i*(M_PI/Lx)*i*(M_PI/Lx)*i*(M_PI/Lx))*
815 sqrt(2.0/Lx)*( 3*hx*i*(M_PI/Lx) - 4*sin(i*(M_PI/Lx)*hx) +
816 cos(i*(M_PI/Lx)*hx)*hx*i*(M_PI/Lx) );
818 iX = 8.0*sin(i*(M_PI/Lx)*x[ii])/(hx*hx*i*(M_PI/Lx)*i*(M_PI/Lx)*i*(M_PI/Lx))*
819 sqrt(2.0/Lx)*( 2*sin(i*(M_PI/Lx)*0.5*hx) -
820 cos(i*(M_PI/Lx)*0.5*hx)*hx*i*(M_PI/Lx));
821 if (fabs(y[ii] - floor(y[ii]/hy+0.5)*hy) < 0.25*hy)
822 iY = 2.0*sin(j*(M_PI/Ly)*y[ii])/(hy*hy*j*(M_PI/Ly)*j*(M_PI/Ly)*j*(M_PI/Ly))*
823 sqrt(2.0/Ly)*( 3*hy*j*(M_PI/Ly) - 4*sin(j*(M_PI/Ly)*hy) +
824 cos(j*(M_PI/Ly)*hy)*hy*j*(M_PI/Ly) );
826 iY = 8.0*sin(j*(M_PI/Ly)*y[ii])/(hy*hy*j*(M_PI/Ly)*j*(M_PI/Ly)*j*(M_PI/Ly))*
827 sqrt(2.0/Ly)*( 2*sin(j*(M_PI/Ly)*0.5*hy) -
828 cos(j*(M_PI/Ly)*0.5*hy)*hy*j*(M_PI/Ly));
829 shapeInt.ReplaceMyValue(ii, 0, iX*iY);
831 Qi.Dot(shapeInt, normL2 + index[i-1+(j-1)*(numX-1)]);
837 for (i = 0; i < nMax; ++i) {
838 double normH1 = continuous[i]*(1.0 - 2.0*normL2[i]) + discrete[i];
839 normL2[i] = 2.0 - 2.0*normL2[i];
846 cout.setf(ios::scientific, ios::floatfield);
848 cout << continuous[i] <<
" " << discrete[i] <<
" ";
850 cout << fabs(discrete[i] - continuous[i])/continuous[i] <<
" ";
851 cout << sqrt(fabs(normH1)/(continuous[i]+1.0)) <<
" ";
852 cout << sqrt(fabs(normL2[i])) << endl;
862 myVerify.errorSubspaces(Q, Qex, M);
871 void ModeLaplace2DQ2::memoryInfo()
const {
873 int myPid = MyComm.MyPID();
876 if ((myPid == 0) && (Mat)) {
877 cout <<
" Total number of nonzero entries in mass matrix = ";
882 cout <<
" Memory requested for mass matrix per processor = (EST) ";
885 cout.setf(ios::fixed, ios::floatfield);
886 cout << memSize/1024.0/1024.0/MyComm.NumProc() <<
" MB " << endl;
891 if ((myPid == 0) && (Mat)) {
892 cout <<
" Total number of nonzero entries in stiffness matrix = ";
897 cout <<
" Memory requested for stiffness matrix per processor = (EST) ";
900 cout.setf(ios::fixed, ios::floatfield);
901 cout << memSize/1024.0/1024.0/MyComm.NumProc() <<
" MB " << endl;
908 void ModeLaplace2DQ2::problemInfo()
const {
910 int myPid = MyComm.MyPID();
914 cout.setf(ios::fixed, ios::floatfield);
915 cout <<
" --- Problem definition ---\n\n";
916 cout <<
" >> Laplace equation in 2D with homogeneous Dirichlet condition\n";
917 cout <<
" >> Domain = [0, " << Lx <<
"] x [0, " << Ly <<
"]\n";
918 cout <<
" >> Orthogonal mesh uniform per direction with Q2 elements (9 nodes)\n";
920 cout <<
" Global size = " << Map->NumGlobalElements() << endl;
922 cout <<
" Number of elements in [0, " << Lx <<
"] (X-direction): " << nX << endl;
923 cout <<
" Number of elements in [0, " << Ly <<
"] (Y-direction): " << nY << endl;
925 cout <<
" Number of interior nodes in the X-direction: " << 2*nX-1 << endl;
926 cout <<
" Number of interior nodes in the Y-direction: " << 2*nY-1 << endl;
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
virtual int NumGlobalNonzeros() const =0
virtual int NumGlobalRows() const =0