Commit 5fa79e41 authored by Pedro Flores's avatar Pedro Flores
Browse files

adequando a matriz do exemplo

parent 8c5c5b96
No preview for this file type
......@@ -55,7 +55,7 @@ int main()
double Y[a.n];
double Yedp[b.n*b.m];
gaussSeidelEDP (&b,Yedp, &tTotal, &slB);
prnVetor(Yedp, b.n*b.m);
// prnVetor(Yedp, b.n*b.m);
printf("norma L2: %f\n", normaL2Residuo(&slB, Yedp));
return 1;
}
\ No newline at end of file
No preview for this file type
......@@ -16,11 +16,11 @@ real_t normaL2Residuo(SL_Pentadiag *SL, real_t *y)
}
prnVetor(SL->B, 15);
prnVetor(y, 15);
prnVetor(SL->Sdi, 15);
prnVetor(SL->Di, 15);
prnVetor(SL->D, 15);
prnVetor(SL->Ds, 15);
prnVetor(SL->Sds, 15);
prnVetor(SL->Ds, 15);
prnVetor(SL->D, 15);
prnVetor(SL->Di, 15);
prnVetor(SL->Sdi, 15);
for(int i = 0; i < SL->n; i++)
{
A[i] += SL->D[i]*y[i] + SL->Di[i]*y[i] + SL->Ds[i]*y[i] + SL->Di[i]*y[i] + SL->Sdi[i]*y[i] + SL->Sds[i]*y[i];
......@@ -161,15 +161,21 @@ void gaussSeidelEDP (Edp *edpeq, double *Y, double *tTotal, SL_Pentadiag *SL)
}
//di e sds
else if(j == 0 && i == n-1){
di = 0;
sds = 0;
bi -= ds*Y[idx+n] + sdi*Y[idx-1] + edpeq->yc*hy*hy + edpeq->yb*hx*hx;
/* di = 0;
sds = 0; */
//bi -= ds*Y[idx+n] + sdi*Y[idx-1] + edpeq->yc*hy*hy + edpeq->yb*hx*hx;
bi -= di*Y[idx-n] + sds*Y[idx+1] + edpeq->yd*hy*hy + edpeq->ya*hx*hx;
ds = 0;
sdi = 0;
}
//ds e sdi
else if(j == m-1 && i == 0) {
ds = 0;
sdi = 0;
bi -= di*Y[idx-n] + sds*Y[idx+1] + edpeq->yd*hy*hy + edpeq->ya*hx*hx;
// ds = 0;
// sdi = 0;
//bi -= di*Y[idx-n] + sds*Y[idx+1] + edpeq->yd*hy*hy + edpeq->ya*hx*hx;
sds = 0;
di = 0;
bi -= ds*Y[idx+n] + sdi*Y[idx-1] + edpeq->yc*hy*hy + edpeq->yb*hx*hx;
}
//ds e sds
else if(j == m-1 && i == n-1) {
......@@ -181,29 +187,30 @@ void gaussSeidelEDP (Edp *edpeq, double *Y, double *tTotal, SL_Pentadiag *SL)
else if (j == 0) {
// di = 0;
// bi -= ds*Y[idx+n] + sds*Y[idx+1] + sdi*Y[idx-1] + edpeq->yc*hy*hy;
bi -= (ds*Y[idx+n] + di*Y[idx-n] + sds*Y[idx+1] + edpeq->ya*hx*hx);
sdi = 0;
bi -= (ds*Y[idx+n] + di*Y[idx-n] + sds*Y[idx+1] + edpeq->ya*hx*hx);
}
//ds
else if (j == m-1) {
bi -= (ds*Y[idx+n] + di*Y[idx-n] + sdi*Y[idx-1] + edpeq->yb*hx*hx);
sds = 0;
// bi -= di*Y[idx-n] + sds*Y[idx+1] + sdi*Y[idx-1] + edpeq->yd*hy*hy;
// ds = 0;
sds = 0;
bi -= (ds*Y[idx+n] + di*Y[idx-n] + sdi*Y[idx-1] + edpeq->yb*hx*hx);
}
//sdi
else if(i == 0) {
// bi -= (ds*Y[idx+n] + di*Y[idx-n] + sds*Y[idx+1] + edpeq->ya*hx*hx);
// sdi = 0;
di = 0;
bi -= ds*Y[idx+n] + sds*Y[idx+1] + sdi*Y[idx-1] + edpeq->yc*hy*hy;
// bi -= (ds*Y[idx+n] + di*Y[idx-n] + sds*Y[idx+1] + edpeq->ya*hx*hx);
// sdi = 0;
}
//sds
else if(i == n-1) {
// bi -= (ds*Y[idx+n] + di*Y[idx-n] + sdi*Y[idx-1] + edpeq->yb*hx*hx);
// sds = 0;
bi -= di*Y[idx-n] + sds*Y[idx+1] + sdi*Y[idx-1] + edpeq->yd*hy*hy;
ds = 0;
bi -= di*Y[idx-n] + sds*Y[idx+1] + sdi*Y[idx-1] + edpeq->yd*hy*hy;
}
//sem ponto de contorno
else bi -= ds*Y[idx+n] + di*Y[idx-n] + sds*Y[idx+1] + sdi*Y[idx-1];
......@@ -245,8 +252,11 @@ void gaussSeidelEDP (Edp *edpeq, double *Y, double *tTotal, SL_Pentadiag *SL)
void prnVetor (real_t *v, unsigned int n)
{
for(int i = 0; i < n; i++)
{
printf("%.9g ", v[i]);
{
if(v[i] < 0)
printf("%.9g ", v[i]);
else
printf(" %.9g ", v[i]);
}
printf("\n");
}
......
No preview for this file type
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment