VAR* laplac(VAR* A){ VAR* temp; VAR* ret_var; temp = grad(A); ret_var = diverg(temp); return ret_var; }
//---------------bakterijų koncentracijos apskaičiavimas sekančiam laiko momentui double* bact(int size_x, int size_y, int size_z, double* u, double* v, float dt, float delta, double (*A)(double, double), double (*B)(double, double, double), double* (*C)(double*, double), double (*D)(double, double, double), double (*f)(double, double), double d, double lambda, double k) { int x; int y; int z; int pos; int dz; dz = size_x * size_y; char state_x; char state_y; char state_z; double tmp_scal; double* tmp_vect_1; double* tmp_vect_2; int dim; dim = 1; if (size_y != 1) { dim++; } if (size_z != 1) { dim++; } double* res = (double*)malloc(sizeof(double)*size_x*size_y*size_z); double* buf = (double*)malloc(sizeof(double)*dim*size_x*size_y*size_z); int i; #pragma omp parallel for private(x, y, z, state_x, state_y, state_z, pos, tmp_scal, tmp_vect_1, tmp_vect_2) shared(size_x, size_y, size_z, dz, res) for (z=0; z<size_z; z++) { state_z = check(z, size_z); for (y=0; y<size_y; y++) { state_y = check(y, size_y); for (x=0; x<size_x; x++) { state_x = check(x, size_x); pos = x + y*size_x + z*dz; tmp_vect_1 = grad(&u[pos], dim, size_x, dz, delta, state_x, state_y, state_z); tmp_scal = D(u[pos], d, k); for (i=0; i<dim; i++) { tmp_vect_1[i] = tmp_scal * tmp_vect_1[i]; } tmp_vect_2 = C(grad(&v[pos], dim, size_x, dz, delta, state_x, state_y, state_z), k); tmp_scal = A(u[pos], k) * B(u[pos], lambda, k); for (i=0; i<dim; i++) { buf[dim*pos+i] = tmp_vect_1[i] - tmp_scal*tmp_vect_2[i]; } } } } #pragma omp parallel for private(x, y, z, state_x, state_y, state_z, pos, tmp_scal) shared(size_x, size_y, size_z, dz, res) for (z=0; z<size_z; z++) { state_z = check(z, size_z); for (y=0; y<size_y; y++) { state_y = check(y, size_y); for (x=0; x<size_x; x++) { state_x = check(x, size_x); pos = x + y*size_x + z*dz; tmp_scal = diverg(&buf[dim*pos], dim, size_x, dz, delta, state_x, state_y, state_z) + f(u[pos], k); res[pos] = u[pos] + dt*tmp_scal; } } } free(buf); return res; }