Commit 520d5c64 authored by Pedro Flores's avatar Pedro Flores
Browse files

testando

parent 57f23b9d
......@@ -55,7 +55,7 @@ void gaussSeidel (Edo *edoeq, double *Y)
}
printf("iterações: %d\n", it);
}
/* u(i,j) são as variaveis do sistema linear não precisam ser instanciadas dentro do for*/
void gaussSeidelEDP (Edp *edpeq, double *Y)
{
int n = edpeq->n;
......@@ -67,12 +67,12 @@ void gaussSeidelEDP (Edp *edpeq, double *Y)
{
Y[k] = 0.0f;
}
for(int k = 0; k < MAXIT; k++) // 23 FLOP por iteração do método
for(int k = 0; k < MAXIT; k++)
{
int idx = 0;
for (int j=0; j < m; ++j) // Para cada equação do SL
for (int j=0; j < m; ++j)
{
yi = edpeq->c + (j+1)*hy; // valor xi da malha: 2 FLOP
yi = edpeq->c + (j+1)*hy;
for(int i = 0; i < n; i++)
{
xi = edpeq->a + (i+1)*hx;
......@@ -82,20 +82,38 @@ void gaussSeidelEDP (Edp *edpeq, double *Y)
d = -2 *(hx + hy);
ds = hy*hy;
sds = hx*hx;
// j: 0 -> m - 1 i: 0 -> n -1
// ya = 20 yb = 45; malha x
// yc = 45 yd = 100; malha y
// d: diag principal
// di: diag inf
// sdi : seg diag inf
// ds: diag sup
// sds: seg diag sup
// bi: termos indep
printf("[xi: %f] [yi: %f] [j: %d, i: %d]\n", xi, yi, j, i);
if (j == 0) bi -= ds*Y[idx+1] + sds*Y[idx+2] + sdi*Y[idx-2] + edpeq->yc *hy*hy;
//di e sdi
if(j == 0 && i == 0) bi -= ds*Y[idx+1] + sds*Y[idx+2] + edpeq->yc*hy*hy + edpeq->ya*hx*hx;
//di e sds
else if(j == 0 && i == n-1) bi -= ds*Y[idx+1] + sdi*Y[idx-2] + edpeq->yc*hy*hy + edpeq->yb*hx*hx;
//ds e sdi
else if(j == m-1 && i == 0) bi -= di*Y[idx-1] + sds*Y[idx+2] + edpeq->yd*hy*hy + edpeq->ya*hx*hx;
//ds e sds
else if(j == m-1 && i == n-1) bi -= di*Y[idx-1] + sdi*Y[idx-2] + edpeq->yd*hy*hy + edpeq->yb*hx*hx;
//di
else if (j == 0) bi -= ds*Y[idx+1] + sds*Y[idx+2] + sdi*Y[idx-2] + edpeq->yc*hy*hy;
//ds
else if (j == m-1) bi -= di*Y[idx-1] + sds*Y[idx+2] + sdi*Y[idx-2] + edpeq->yd*hy*hy;
//sdi
else if(i == 0) bi -= (ds*Y[idx+1] + di*Y[idx-1] + sds*Y[idx+2] + edpeq->ya*hx*hx);
//sds
else if(i == n-1) bi -= (ds*Y[idx+1] + di*Y[idx-1] + sdi*Y[idx-2] + edpeq->yb*hx*hx);
else bi -= ds*Y[idx+1] + di*Y[idx-1] + sds*Y[idx+2] + sdi*Y[idx-2];
//sem ponto de contorno
else bi -= ds*Y[idx+1] + di*Y[idx-1] + sds*Y[idx+2] + sdi*Y[idx-2];
Y[idx] = bi / d;
idx += 1;
}
}
printf("idx %d\n", idx);
}
}
......
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