You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
simulacion-permeabilidad/fftma_module/gen/lib_src/length.c

40 lines
791 B
C

#include <math.h>
/* compute the length for one dimension*/
int length(int N, int i, double *scf, double *ap, double D, int Nvari)
{
int maxfactor(int n);
double temp1, temp2;
int n, j, k, nmax;
int nlimit = 13;
if (N == 1) {
n = 1;
} else {
for (k = 0; k < Nvari; k++) {
temp1 = fabs(ap[9*k+i])*scf[3*k]*scf[3*k];
for (j = 1; j <3; j++) {
temp2 = fabs(ap[9*k+3*j+i])*scf[3*k+j]*scf[3*k+j];
if (temp2 > temp1)
temp1 = temp2;
}
}
temp1 = sqrt(temp1);
temp1 /= (double)D;
if ((double)N/temp1 < 2.) {
n = N+(int)(2*temp1);
} else {
n = N+(int)temp1;
}
if ((n % 2) != 0)
n = n+1;
nmax = maxfactor(n);
while (nmax > nlimit) {
n += 2;
nmax = maxfactor(n);
}
}
return (n);
}