Run linter
parent
96db89d10c
commit
6d62c0e798
@ -1,10 +1,74 @@
|
|||||||
from distutils.core import setup, Extension
|
from distutils.core import setup, Extension
|
||||||
|
|
||||||
|
|
||||||
module_FFTMA = Extension('FFTMA', include_dirs = ['./include'],sources=["moduleFFTMA.c","./lib_src/Py_getvalues.c","./lib_src/Py_kgeneration.c","./lib_src/genlib.c","./lib_src/random.c","./lib_src/simpio.c","./lib_src/strlib.c","./lib_src/symtab.c","./lib_src/scanadt.c","./lib_src/stack.c","./lib_src/gammf.c","./lib_src/fftma.c","./lib_src/addstat.c","./lib_src/axes.c","./lib_src/cgrid.c","./lib_src/covariance.c","./lib_src/fourt.c","./lib_src/length.c","./lib_src/maxfactor.c","./lib_src/test_fact.c","./lib_src/cov_value.c","./lib_src/generate.c","./lib_src/gasdev.c","./lib_src/ran2.c","./lib_src/stable.c","./lib_src/gaussian.c","./lib_src/power.c","./lib_src/cubic.c","./lib_src/spherical.c","./lib_src/nugget.c","./lib_src/exponential.c","./lib_src/cardsin.c","./lib_src/nor2log.c","./lib_src/kgeneration.c","./lib_src/kgeneration2.c","./lib_src/fftma2.c","./lib_src/prebuild_gwn.c","./lib_src/build_real.c","./lib_src/addstat2.c","./lib_src/clean_real.c","./lib_src/pgeneration.c","./lib_src/pgeneration2.c","./lib_src/FFTPressure.c","./lib_src/FFTtest.c","./lib_src/build_pressure.c","./lib_src/build_velocity.c","./lib_src/total_pressure.c","./lib_src/total_velocity.c","./lib_src/clean_real2.c","./lib_src/waveVectorCompute3D.c","./lib_src/mat_vec.c","./lib_src/derivReal.c","./lib_src/inputdata.c","./lib_src/inputfiledata.c","./lib_src/debuginput.c","./lib_src/readdata.c","./lib_src/readfile_bin.c","./lib_src/writefile.c","./lib_src/writefile_bin.c","./lib_src/testmemory.c","./lib_src/testopenfile.c","./lib_src/readdata3.c"])
|
module_FFTMA = Extension(
|
||||||
|
"FFTMA",
|
||||||
|
include_dirs=["./include"],
|
||||||
|
sources=[
|
||||||
|
"moduleFFTMA.c",
|
||||||
|
"./lib_src/Py_getvalues.c",
|
||||||
|
"./lib_src/Py_kgeneration.c",
|
||||||
|
"./lib_src/genlib.c",
|
||||||
|
"./lib_src/random.c",
|
||||||
|
"./lib_src/simpio.c",
|
||||||
|
"./lib_src/strlib.c",
|
||||||
|
"./lib_src/symtab.c",
|
||||||
|
"./lib_src/scanadt.c",
|
||||||
|
"./lib_src/stack.c",
|
||||||
|
"./lib_src/gammf.c",
|
||||||
|
"./lib_src/fftma.c",
|
||||||
|
"./lib_src/addstat.c",
|
||||||
|
"./lib_src/axes.c",
|
||||||
|
"./lib_src/cgrid.c",
|
||||||
|
"./lib_src/covariance.c",
|
||||||
|
"./lib_src/fourt.c",
|
||||||
|
"./lib_src/length.c",
|
||||||
|
"./lib_src/maxfactor.c",
|
||||||
|
"./lib_src/test_fact.c",
|
||||||
|
"./lib_src/cov_value.c",
|
||||||
|
"./lib_src/generate.c",
|
||||||
|
"./lib_src/gasdev.c",
|
||||||
|
"./lib_src/ran2.c",
|
||||||
|
"./lib_src/stable.c",
|
||||||
|
"./lib_src/gaussian.c",
|
||||||
|
"./lib_src/power.c",
|
||||||
|
"./lib_src/cubic.c",
|
||||||
|
"./lib_src/spherical.c",
|
||||||
|
"./lib_src/nugget.c",
|
||||||
|
"./lib_src/exponential.c",
|
||||||
|
"./lib_src/cardsin.c",
|
||||||
|
"./lib_src/nor2log.c",
|
||||||
|
"./lib_src/kgeneration.c",
|
||||||
|
"./lib_src/kgeneration2.c",
|
||||||
|
"./lib_src/fftma2.c",
|
||||||
|
"./lib_src/prebuild_gwn.c",
|
||||||
|
"./lib_src/build_real.c",
|
||||||
|
"./lib_src/addstat2.c",
|
||||||
|
"./lib_src/clean_real.c",
|
||||||
|
"./lib_src/pgeneration.c",
|
||||||
|
"./lib_src/pgeneration2.c",
|
||||||
|
"./lib_src/FFTPressure.c",
|
||||||
|
"./lib_src/FFTtest.c",
|
||||||
|
"./lib_src/build_pressure.c",
|
||||||
|
"./lib_src/build_velocity.c",
|
||||||
|
"./lib_src/total_pressure.c",
|
||||||
|
"./lib_src/total_velocity.c",
|
||||||
|
"./lib_src/clean_real2.c",
|
||||||
|
"./lib_src/waveVectorCompute3D.c",
|
||||||
|
"./lib_src/mat_vec.c",
|
||||||
|
"./lib_src/derivReal.c",
|
||||||
|
"./lib_src/inputdata.c",
|
||||||
|
"./lib_src/inputfiledata.c",
|
||||||
|
"./lib_src/debuginput.c",
|
||||||
|
"./lib_src/readdata.c",
|
||||||
|
"./lib_src/readfile_bin.c",
|
||||||
|
"./lib_src/writefile.c",
|
||||||
|
"./lib_src/writefile_bin.c",
|
||||||
|
"./lib_src/testmemory.c",
|
||||||
|
"./lib_src/testopenfile.c",
|
||||||
|
"./lib_src/readdata3.c",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
setup(ext_modules=[module_FFTMA])
|
setup(ext_modules=[module_FFTMA])
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
from distutils.core import setup, Extension
|
from distutils.core import setup, Extension
|
||||||
|
|
||||||
|
|
||||||
module = Extension('refine', sources=['FINALrefine.c'])
|
module = Extension("refine", sources=["FINALrefine.c"])
|
||||||
|
|
||||||
|
|
||||||
setup(ext_modules=[module])
|
setup(ext_modules=[module])
|
||||||
|
@ -1,136 +1,142 @@
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
def joinCmapX(cmap1,cmap2):
|
|
||||||
|
|
||||||
nclus1 = np.max(cmap1)
|
def joinCmapX(cmap1, cmap2):
|
||||||
cmap2=np.where(cmap2!=0,cmap2+nclus1,0)
|
|
||||||
|
|
||||||
old_nclus=0
|
|
||||||
new_nclus=1
|
|
||||||
|
|
||||||
while new_nclus!= old_nclus:
|
|
||||||
|
|
||||||
old_nclus=new_nclus
|
|
||||||
for i in range(cmap1.shape[1]):
|
|
||||||
for j in range(cmap1.shape[2]):
|
|
||||||
if cmap1[-1,i,j] != 0 and cmap2[0,i,j] !=0:
|
|
||||||
if cmap1[-1,i,j] != cmap2[0,i,j]:
|
|
||||||
cmap2=np.where(cmap2==cmap2[0,i,j],cmap1[-1,i,j],cmap2)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for i in range(cmap1.shape[1]):
|
|
||||||
for j in range(cmap1.shape[2]):
|
|
||||||
if cmap1[-1,i,j] != 0 and cmap2[0,i,j] !=0:
|
|
||||||
if cmap1[-1,i,j] != cmap2[0,i,j]:
|
|
||||||
cmap1=np.where(cmap1==cmap1[-1,i,j],cmap2[0,i,j],cmap1)
|
|
||||||
|
|
||||||
cmap=np.append(cmap1,cmap2,axis=0)
|
|
||||||
y = np.bincount(cmap.reshape(-1).astype(int))
|
|
||||||
ii = np.nonzero(y)[0]
|
|
||||||
cf=np.vstack((ii,y[ii])).T #numero de cluster, frecuencia
|
|
||||||
new_nclus=cf.shape[0] #cantidad de clusters
|
|
||||||
#print(new_nclus)
|
|
||||||
|
|
||||||
return cmap
|
|
||||||
|
|
||||||
|
|
||||||
def joinCmapY(cmap1,cmap2):
|
|
||||||
|
|
||||||
nclus1 = np.max(cmap1)
|
|
||||||
cmap2=np.where(cmap2!=0,cmap2+nclus1,0)
|
|
||||||
|
|
||||||
old_nclus=0
|
|
||||||
new_nclus=1
|
|
||||||
|
|
||||||
while new_nclus!= old_nclus:
|
|
||||||
|
|
||||||
old_nclus=new_nclus
|
|
||||||
for i in range(cmap1.shape[0]):
|
|
||||||
for j in range(cmap1.shape[2]):
|
|
||||||
if cmap1[i,-1,j] != 0 and cmap2[i,0,j] !=0:
|
|
||||||
if cmap1[i,-1,j] != cmap2[i,0,j]:
|
|
||||||
cmap2=np.where(cmap2==cmap2[i,0,j],cmap1[i,-1,j],cmap2)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for i in range(cmap1.shape[0]):
|
|
||||||
for j in range(cmap1.shape[2]):
|
|
||||||
if cmap1[i,-1,j] != 0 and cmap2[i,0,j] !=0:
|
|
||||||
if cmap1[i,-1,j] != cmap2[i,0,j]:
|
|
||||||
cmap1=np.where(cmap1==cmap1[i,-1,j],cmap2[i,0,j],cmap1)
|
|
||||||
|
|
||||||
cmap=np.append(cmap1,cmap2,axis=1)
|
|
||||||
y = np.bincount(cmap.reshape(-1).astype(int))
|
|
||||||
ii = np.nonzero(y)[0]
|
|
||||||
cf=np.vstack((ii,y[ii])).T #numero de cluster, frecuencia
|
|
||||||
new_nclus=cf.shape[0] #cantidad de clusters
|
|
||||||
#print(new_nclus)
|
|
||||||
|
|
||||||
return cmap
|
|
||||||
|
|
||||||
|
|
||||||
def joinCmapZ(cmap1,cmap2):
|
|
||||||
|
|
||||||
nclus1 = np.max(cmap1)
|
|
||||||
cmap2=np.where(cmap2!=0,cmap2+nclus1,0)
|
|
||||||
|
|
||||||
old_nclus=0
|
|
||||||
new_nclus=1
|
|
||||||
|
|
||||||
while new_nclus!= old_nclus:
|
|
||||||
|
|
||||||
old_nclus=new_nclus
|
|
||||||
for i in range(cmap1.shape[0]):
|
|
||||||
for j in range(cmap1.shape[1]):
|
|
||||||
if cmap1[i,j,-1] != 0 and cmap2[i,j,0] !=0:
|
|
||||||
if cmap1[i,j,-1] != cmap2[i,j,0]:
|
|
||||||
cmap2=np.where(cmap2==cmap2[i,j,0],cmap1[i,j,-1],cmap2)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for i in range(cmap1.shape[0]):
|
|
||||||
for j in range(cmap1.shape[1]):
|
|
||||||
if cmap1[i,j,-1] != 0 and cmap2[i,j,0] !=0:
|
|
||||||
if cmap1[i,j,-1] != cmap2[i,j,0]:
|
|
||||||
cmap1=np.where(cmap1==cmap1[i,j,-1],cmap2[i,j,0],cmap1)
|
|
||||||
|
|
||||||
cmap=np.append(cmap1,cmap2,axis=2)
|
|
||||||
y = np.bincount(cmap.reshape(-1).astype(int))
|
|
||||||
ii = np.nonzero(y)[0]
|
|
||||||
cf=np.vstack((ii,y[ii])).T #numero de cluster, frecuencia
|
|
||||||
new_nclus=cf.shape[0] #cantidad de clusters
|
|
||||||
#print(new_nclus)
|
|
||||||
|
|
||||||
return cmap
|
|
||||||
|
|
||||||
def joinBox(vec,join_y,join_z):
|
|
||||||
|
|
||||||
Nx, Ny,Nz=vec.shape[0],vec.shape[1],vec.shape[2]
|
|
||||||
nx = Nx//2
|
|
||||||
ny,nz=Ny, Nz
|
|
||||||
if join_y:
|
|
||||||
ny=Ny//2
|
|
||||||
if join_z:
|
|
||||||
nz=Nz//2
|
|
||||||
|
|
||||||
vec[:,:ny,:nz] = joinCmapX(vec[:nx,:ny,:nz],vec[nx:,:ny,:nz])
|
|
||||||
if not join_z and not join_y:
|
|
||||||
return vec
|
|
||||||
|
|
||||||
if join_y:
|
|
||||||
vec[:,ny:,:nz] = joinCmapX(vec[:nx,ny:,:nz],vec[nx:,ny:,:nz])
|
|
||||||
if join_z:
|
|
||||||
vec[:,:ny,nz:] = joinCmapX(vec[:nx,:ny,nz:],vec[nx:,:ny,nz:])
|
|
||||||
if join_z and join_y:
|
|
||||||
vec[:,ny:,nz:] = joinCmapX(vec[:nx,ny:,nz:],vec[nx:,ny:,nz:])
|
|
||||||
if join_y:
|
|
||||||
vec[:,:,:nz] = joinCmapY(vec[:,:ny,:nz],vec[:,ny:,:nz])
|
|
||||||
if join_z:
|
|
||||||
if join_y:
|
|
||||||
vec[:,:,nz:] = joinCmapY(vec[:,:ny,nz:],vec[:,ny:,nz:])
|
|
||||||
vec[:,:,:] = joinCmapZ(vec[:,:,:nz],vec[:,:,nz:])
|
|
||||||
|
|
||||||
return vec
|
|
||||||
|
|
||||||
|
nclus1 = np.max(cmap1)
|
||||||
|
cmap2 = np.where(cmap2 != 0, cmap2 + nclus1, 0)
|
||||||
|
|
||||||
|
old_nclus = 0
|
||||||
|
new_nclus = 1
|
||||||
|
|
||||||
|
while new_nclus != old_nclus:
|
||||||
|
|
||||||
|
old_nclus = new_nclus
|
||||||
|
for i in range(cmap1.shape[1]):
|
||||||
|
for j in range(cmap1.shape[2]):
|
||||||
|
if cmap1[-1, i, j] != 0 and cmap2[0, i, j] != 0:
|
||||||
|
if cmap1[-1, i, j] != cmap2[0, i, j]:
|
||||||
|
cmap2 = np.where(
|
||||||
|
cmap2 == cmap2[0, i, j], cmap1[-1, i, j], cmap2
|
||||||
|
)
|
||||||
|
|
||||||
|
for i in range(cmap1.shape[1]):
|
||||||
|
for j in range(cmap1.shape[2]):
|
||||||
|
if cmap1[-1, i, j] != 0 and cmap2[0, i, j] != 0:
|
||||||
|
if cmap1[-1, i, j] != cmap2[0, i, j]:
|
||||||
|
cmap1 = np.where(
|
||||||
|
cmap1 == cmap1[-1, i, j], cmap2[0, i, j], cmap1
|
||||||
|
)
|
||||||
|
|
||||||
|
cmap = np.append(cmap1, cmap2, axis=0)
|
||||||
|
y = np.bincount(cmap.reshape(-1).astype(int))
|
||||||
|
ii = np.nonzero(y)[0]
|
||||||
|
cf = np.vstack((ii, y[ii])).T # numero de cluster, frecuencia
|
||||||
|
new_nclus = cf.shape[0] # cantidad de clusters
|
||||||
|
# print(new_nclus)
|
||||||
|
|
||||||
|
return cmap
|
||||||
|
|
||||||
|
|
||||||
|
def joinCmapY(cmap1, cmap2):
|
||||||
|
|
||||||
|
nclus1 = np.max(cmap1)
|
||||||
|
cmap2 = np.where(cmap2 != 0, cmap2 + nclus1, 0)
|
||||||
|
|
||||||
|
old_nclus = 0
|
||||||
|
new_nclus = 1
|
||||||
|
|
||||||
|
while new_nclus != old_nclus:
|
||||||
|
|
||||||
|
old_nclus = new_nclus
|
||||||
|
for i in range(cmap1.shape[0]):
|
||||||
|
for j in range(cmap1.shape[2]):
|
||||||
|
if cmap1[i, -1, j] != 0 and cmap2[i, 0, j] != 0:
|
||||||
|
if cmap1[i, -1, j] != cmap2[i, 0, j]:
|
||||||
|
cmap2 = np.where(
|
||||||
|
cmap2 == cmap2[i, 0, j], cmap1[i, -1, j], cmap2
|
||||||
|
)
|
||||||
|
|
||||||
|
for i in range(cmap1.shape[0]):
|
||||||
|
for j in range(cmap1.shape[2]):
|
||||||
|
if cmap1[i, -1, j] != 0 and cmap2[i, 0, j] != 0:
|
||||||
|
if cmap1[i, -1, j] != cmap2[i, 0, j]:
|
||||||
|
cmap1 = np.where(
|
||||||
|
cmap1 == cmap1[i, -1, j], cmap2[i, 0, j], cmap1
|
||||||
|
)
|
||||||
|
|
||||||
|
cmap = np.append(cmap1, cmap2, axis=1)
|
||||||
|
y = np.bincount(cmap.reshape(-1).astype(int))
|
||||||
|
ii = np.nonzero(y)[0]
|
||||||
|
cf = np.vstack((ii, y[ii])).T # numero de cluster, frecuencia
|
||||||
|
new_nclus = cf.shape[0] # cantidad de clusters
|
||||||
|
# print(new_nclus)
|
||||||
|
|
||||||
|
return cmap
|
||||||
|
|
||||||
|
|
||||||
|
def joinCmapZ(cmap1, cmap2):
|
||||||
|
|
||||||
|
nclus1 = np.max(cmap1)
|
||||||
|
cmap2 = np.where(cmap2 != 0, cmap2 + nclus1, 0)
|
||||||
|
|
||||||
|
old_nclus = 0
|
||||||
|
new_nclus = 1
|
||||||
|
|
||||||
|
while new_nclus != old_nclus:
|
||||||
|
|
||||||
|
old_nclus = new_nclus
|
||||||
|
for i in range(cmap1.shape[0]):
|
||||||
|
for j in range(cmap1.shape[1]):
|
||||||
|
if cmap1[i, j, -1] != 0 and cmap2[i, j, 0] != 0:
|
||||||
|
if cmap1[i, j, -1] != cmap2[i, j, 0]:
|
||||||
|
cmap2 = np.where(
|
||||||
|
cmap2 == cmap2[i, j, 0], cmap1[i, j, -1], cmap2
|
||||||
|
)
|
||||||
|
|
||||||
|
for i in range(cmap1.shape[0]):
|
||||||
|
for j in range(cmap1.shape[1]):
|
||||||
|
if cmap1[i, j, -1] != 0 and cmap2[i, j, 0] != 0:
|
||||||
|
if cmap1[i, j, -1] != cmap2[i, j, 0]:
|
||||||
|
cmap1 = np.where(
|
||||||
|
cmap1 == cmap1[i, j, -1], cmap2[i, j, 0], cmap1
|
||||||
|
)
|
||||||
|
|
||||||
|
cmap = np.append(cmap1, cmap2, axis=2)
|
||||||
|
y = np.bincount(cmap.reshape(-1).astype(int))
|
||||||
|
ii = np.nonzero(y)[0]
|
||||||
|
cf = np.vstack((ii, y[ii])).T # numero de cluster, frecuencia
|
||||||
|
new_nclus = cf.shape[0] # cantidad de clusters
|
||||||
|
# print(new_nclus)
|
||||||
|
|
||||||
|
return cmap
|
||||||
|
|
||||||
|
|
||||||
|
def joinBox(vec, join_y, join_z):
|
||||||
|
|
||||||
|
Nx, Ny, Nz = vec.shape[0], vec.shape[1], vec.shape[2]
|
||||||
|
nx = Nx // 2
|
||||||
|
ny, nz = Ny, Nz
|
||||||
|
if join_y:
|
||||||
|
ny = Ny // 2
|
||||||
|
if join_z:
|
||||||
|
nz = Nz // 2
|
||||||
|
|
||||||
|
vec[:, :ny, :nz] = joinCmapX(vec[:nx, :ny, :nz], vec[nx:, :ny, :nz])
|
||||||
|
if not join_z and not join_y:
|
||||||
|
return vec
|
||||||
|
|
||||||
|
if join_y:
|
||||||
|
vec[:, ny:, :nz] = joinCmapX(vec[:nx, ny:, :nz], vec[nx:, ny:, :nz])
|
||||||
|
if join_z:
|
||||||
|
vec[:, :ny, nz:] = joinCmapX(vec[:nx, :ny, nz:], vec[nx:, :ny, nz:])
|
||||||
|
if join_z and join_y:
|
||||||
|
vec[:, ny:, nz:] = joinCmapX(vec[:nx, ny:, nz:], vec[nx:, ny:, nz:])
|
||||||
|
if join_y:
|
||||||
|
vec[:, :, :nz] = joinCmapY(vec[:, :ny, :nz], vec[:, ny:, :nz])
|
||||||
|
if join_z:
|
||||||
|
if join_y:
|
||||||
|
vec[:, :, nz:] = joinCmapY(vec[:, :ny, nz:], vec[:, ny:, nz:])
|
||||||
|
vec[:, :, :] = joinCmapZ(vec[:, :, :nz], vec[:, :, nz:])
|
||||||
|
|
||||||
|
return vec
|
||||||
|
@ -1,135 +1,123 @@
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
#import petsc4py
|
|
||||||
|
# import petsc4py
|
||||||
import math
|
import math
|
||||||
import time
|
import time
|
||||||
#from mpi4py import MPI
|
|
||||||
|
# from mpi4py import MPI
|
||||||
from tools.postprocessK.kperm.computeFlows import *
|
from tools.postprocessK.kperm.computeFlows import *
|
||||||
|
|
||||||
from petsc4py import PETSc
|
from petsc4py import PETSc
|
||||||
#petsc4py.init('-ksp_max_it 9999999999',comm=PETSc.COMM_SELF)
|
|
||||||
from tools.postprocessK.flow import getKeff
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def PetscP(datadir,ref,k,saveres):
|
|
||||||
|
|
||||||
#datadir='./data/'+str(job)+'/'
|
|
||||||
|
|
||||||
|
|
||||||
#comm=MPI.COMM_WORLD
|
|
||||||
#rank=comm.Get_rank()
|
|
||||||
'''
|
|
||||||
size=comm.Get_size()
|
|
||||||
print(rank,size)
|
|
||||||
pcomm = MPI.COMM_WORLD.Split(color=rank, key=rank)
|
|
||||||
#print(new_comm.Get_rank())
|
|
||||||
|
|
||||||
#pcomm=comm.Create(newgroup)
|
|
||||||
print('entro')
|
|
||||||
print pcomm.Get_rank()
|
|
||||||
|
|
||||||
print pcomm.Get_size()
|
|
||||||
pcomm=comm
|
|
||||||
|
|
||||||
|
|
||||||
rank=pcomm.rank
|
|
||||||
pn=pcomm.size
|
|
||||||
#PETSc.COMM_WORLD.PetscSubcommCreate(pcomm,PetscSubcomm *psubcomm)
|
|
||||||
print(rank,pn)
|
|
||||||
'''
|
|
||||||
#Optpetsc = PETSc.Options()
|
|
||||||
rank=0
|
|
||||||
pn=1
|
|
||||||
t0=time.time()
|
|
||||||
|
|
||||||
#comm=MPI.Comm.Create()
|
|
||||||
if k.shape[2]==1:
|
|
||||||
refz=1
|
|
||||||
else:
|
|
||||||
refz=ref
|
|
||||||
|
|
||||||
nz, ny, nx=k.shape[0]*ref,k.shape[1]*ref,k.shape[2]*refz
|
|
||||||
n=nx*ny*nz
|
|
||||||
|
|
||||||
print('algo')
|
|
||||||
|
|
||||||
K = PETSc.Mat().create(comm=PETSc.COMM_SELF)
|
|
||||||
print('algo2')
|
|
||||||
K.setType('seqaij')
|
|
||||||
print('algo3')
|
|
||||||
K.setSizes(((n,None),(n,None))) # Aca igual que lo que usas arriba
|
|
||||||
K.setPreallocationNNZ(nnz=(7,4)) # Idem anterior
|
|
||||||
|
|
||||||
|
|
||||||
#K = PETSc.Mat('seqaij', m=n,n=n,nz=7,comm=PETSc.COMM_WORLD)
|
|
||||||
#K = PETSc.Mat('aij', ((n,None),(n,None)), nnz=(7,4),comm=PETSc.COMM_WORLD)
|
|
||||||
#K = PETSc.Mat().createAIJ(((n,None),(n,None)), nnz=(7,4),comm=PETSc.COMM_WORLD)
|
|
||||||
#K = PETSc.Mat().createSeqAIJ(((n,None),(n,None)), nnz=(7,4),comm=PETSc.COMM_WORLD)
|
|
||||||
#K.setPreallocationNNZ(nnz=(7,4))
|
|
||||||
print('ksetup')
|
|
||||||
#K.MatCreateSeqAIJ()
|
|
||||||
#K=PETSc.Mat().MatCreate(PETSc.COMM_WORLD)
|
|
||||||
|
|
||||||
#K = PETSc.Mat().createAIJ(((n,None),(n,None)), nnz=(7,4),comm=pcomm)
|
|
||||||
|
|
||||||
K.setUp()
|
|
||||||
print('entro2')
|
|
||||||
R = PETSc.Vec().createSeq((n,None),comm=PETSc.COMM_SELF) #PETSc.COMM_WORLD
|
|
||||||
R.setUp()
|
|
||||||
print('entro2')
|
|
||||||
k2, Nz, nnz2=getKref(k,1,2,ref)
|
|
||||||
k, Nz, nnz=getKref(k,0,2,ref)
|
|
||||||
|
|
||||||
|
|
||||||
pbc=float(Nz)
|
|
||||||
#print('entro3')
|
|
||||||
|
|
||||||
K,R = firstL(K,R,k,pbc)
|
|
||||||
r=(k.shape[1]-2)*(k.shape[2]-2)*nnz2 #start row
|
|
||||||
K,R =lastL(K,R,k2,r)
|
|
||||||
|
|
||||||
k2=0
|
|
||||||
|
|
||||||
K.assemble()
|
|
||||||
R.assemble()
|
|
||||||
|
|
||||||
|
|
||||||
print('entro3')
|
|
||||||
ksp = PETSc.KSP()
|
|
||||||
ksp.create(comm=PETSc.COMM_SELF)
|
|
||||||
ksp.setFromOptions()
|
|
||||||
print('entro4')
|
|
||||||
P = R.copy()
|
|
||||||
ksp.setType(PETSc.KSP.Type.CG)
|
|
||||||
pc = PETSc.PC()
|
|
||||||
|
|
||||||
pc.create(comm=PETSc.COMM_SELF)
|
|
||||||
print('entro4')
|
|
||||||
pc.setType(PETSc.PC.Type.JACOBI)
|
|
||||||
ksp.setPC(pc)
|
|
||||||
ksp.setOperators(K)
|
|
||||||
ksp.setUp()
|
|
||||||
t1=time.time()
|
|
||||||
ksp.solve(R, P)
|
|
||||||
t2=time.time()
|
|
||||||
p=P.getArray().reshape(nz,ny,nx)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if rank==0:
|
|
||||||
keff,Q=getKeff(p,k[1:-1,1:-1,1:-1],pbc,Nz)
|
|
||||||
|
|
||||||
return keff
|
|
||||||
|
|
||||||
|
|
||||||
return
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#Ver: A posteriori error estimates and adaptive solvers for porous media flows (Martin Vohralik)
|
|
||||||
|
|
||||||
|
# petsc4py.init('-ksp_max_it 9999999999',comm=PETSc.COMM_SELF)
|
||||||
|
from tools.postprocessK.flow import getKeff
|
||||||
|
|
||||||
|
|
||||||
|
def PetscP(datadir, ref, k, saveres):
|
||||||
|
|
||||||
|
# datadir='./data/'+str(job)+'/'
|
||||||
|
|
||||||
|
# comm=MPI.COMM_WORLD
|
||||||
|
# rank=comm.Get_rank()
|
||||||
|
"""
|
||||||
|
size=comm.Get_size()
|
||||||
|
print(rank,size)
|
||||||
|
pcomm = MPI.COMM_WORLD.Split(color=rank, key=rank)
|
||||||
|
#print(new_comm.Get_rank())
|
||||||
|
|
||||||
|
#pcomm=comm.Create(newgroup)
|
||||||
|
print('entro')
|
||||||
|
print pcomm.Get_rank()
|
||||||
|
|
||||||
|
print pcomm.Get_size()
|
||||||
|
pcomm=comm
|
||||||
|
|
||||||
|
|
||||||
|
rank=pcomm.rank
|
||||||
|
pn=pcomm.size
|
||||||
|
#PETSc.COMM_WORLD.PetscSubcommCreate(pcomm,PetscSubcomm *psubcomm)
|
||||||
|
print(rank,pn)
|
||||||
|
"""
|
||||||
|
# Optpetsc = PETSc.Options()
|
||||||
|
rank = 0
|
||||||
|
pn = 1
|
||||||
|
t0 = time.time()
|
||||||
|
|
||||||
|
# comm=MPI.Comm.Create()
|
||||||
|
if k.shape[2] == 1:
|
||||||
|
refz = 1
|
||||||
|
else:
|
||||||
|
refz = ref
|
||||||
|
|
||||||
|
nz, ny, nx = k.shape[0] * ref, k.shape[1] * ref, k.shape[2] * refz
|
||||||
|
n = nx * ny * nz
|
||||||
|
|
||||||
|
print("algo")
|
||||||
|
|
||||||
|
K = PETSc.Mat().create(comm=PETSc.COMM_SELF)
|
||||||
|
print("algo2")
|
||||||
|
K.setType("seqaij")
|
||||||
|
print("algo3")
|
||||||
|
K.setSizes(((n, None), (n, None))) # Aca igual que lo que usas arriba
|
||||||
|
K.setPreallocationNNZ(nnz=(7, 4)) # Idem anterior
|
||||||
|
|
||||||
|
# K = PETSc.Mat('seqaij', m=n,n=n,nz=7,comm=PETSc.COMM_WORLD)
|
||||||
|
# K = PETSc.Mat('aij', ((n,None),(n,None)), nnz=(7,4),comm=PETSc.COMM_WORLD)
|
||||||
|
# K = PETSc.Mat().createAIJ(((n,None),(n,None)), nnz=(7,4),comm=PETSc.COMM_WORLD)
|
||||||
|
# K = PETSc.Mat().createSeqAIJ(((n,None),(n,None)), nnz=(7,4),comm=PETSc.COMM_WORLD)
|
||||||
|
# K.setPreallocationNNZ(nnz=(7,4))
|
||||||
|
print("ksetup")
|
||||||
|
# K.MatCreateSeqAIJ()
|
||||||
|
# K=PETSc.Mat().MatCreate(PETSc.COMM_WORLD)
|
||||||
|
|
||||||
|
# K = PETSc.Mat().createAIJ(((n,None),(n,None)), nnz=(7,4),comm=pcomm)
|
||||||
|
|
||||||
|
K.setUp()
|
||||||
|
print("entro2")
|
||||||
|
R = PETSc.Vec().createSeq((n, None), comm=PETSc.COMM_SELF) # PETSc.COMM_WORLD
|
||||||
|
R.setUp()
|
||||||
|
print("entro2")
|
||||||
|
k2, Nz, nnz2 = getKref(k, 1, 2, ref)
|
||||||
|
k, Nz, nnz = getKref(k, 0, 2, ref)
|
||||||
|
|
||||||
|
pbc = float(Nz)
|
||||||
|
# print('entro3')
|
||||||
|
|
||||||
|
K, R = firstL(K, R, k, pbc)
|
||||||
|
r = (k.shape[1] - 2) * (k.shape[2] - 2) * nnz2 # start row
|
||||||
|
K, R = lastL(K, R, k2, r)
|
||||||
|
|
||||||
|
k2 = 0
|
||||||
|
|
||||||
|
K.assemble()
|
||||||
|
R.assemble()
|
||||||
|
|
||||||
|
print("entro3")
|
||||||
|
ksp = PETSc.KSP()
|
||||||
|
ksp.create(comm=PETSc.COMM_SELF)
|
||||||
|
ksp.setFromOptions()
|
||||||
|
print("entro4")
|
||||||
|
P = R.copy()
|
||||||
|
ksp.setType(PETSc.KSP.Type.CG)
|
||||||
|
pc = PETSc.PC()
|
||||||
|
|
||||||
|
pc.create(comm=PETSc.COMM_SELF)
|
||||||
|
print("entro4")
|
||||||
|
pc.setType(PETSc.PC.Type.JACOBI)
|
||||||
|
ksp.setPC(pc)
|
||||||
|
ksp.setOperators(K)
|
||||||
|
ksp.setUp()
|
||||||
|
t1 = time.time()
|
||||||
|
ksp.solve(R, P)
|
||||||
|
t2 = time.time()
|
||||||
|
p = P.getArray().reshape(nz, ny, nx)
|
||||||
|
|
||||||
|
if rank == 0:
|
||||||
|
keff, Q = getKeff(p, k[1:-1, 1:-1, 1:-1], pbc, Nz)
|
||||||
|
|
||||||
|
return keff
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
# Ver: A posteriori error estimates and adaptive solvers for porous media flows (Martin Vohralik)
|
||||||
|
@ -1,17 +1,14 @@
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
|
|
||||||
|
def getKeff(pm, k, pbc, Nz):
|
||||||
|
|
||||||
|
nx = k.shape[2] # Pasar k sin bordes de k=0
|
||||||
|
ny = k.shape[1]
|
||||||
|
|
||||||
def getKeff(pm,k,pbc,Nz):
|
tz = 2 * k[1, :, :] * k[0, :, :] / (k[0, :, :] + k[1, :, :])
|
||||||
|
q = ((pm[0, :, :] - pm[1, :, :]) * tz).sum()
|
||||||
nx = k.shape[2] #Pasar k sin bordes de k=0
|
area = ny * nx
|
||||||
ny = k.shape[1]
|
l = Nz
|
||||||
|
keff = q * l / (pbc * area)
|
||||||
tz = 2*k[1,:,:]*k[0, :,:]/(k[0, :,:]+k[1,:,:])
|
return keff, q
|
||||||
q=((pm[0,:,:]-pm[1,:,:])*tz).sum()
|
|
||||||
area=ny*nx
|
|
||||||
l=Nz
|
|
||||||
keff=q*l/(pbc*area)
|
|
||||||
return keff,q
|
|
||||||
|
|
||||||
|
@ -1,179 +1,167 @@
|
|||||||
|
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import petsc4py
|
import petsc4py
|
||||||
import math
|
import math
|
||||||
import time
|
import time
|
||||||
#from mpi4py import MPI
|
|
||||||
|
# from mpi4py import MPI
|
||||||
from tools.postprocessK.kperm.computeFlows import *
|
from tools.postprocessK.kperm.computeFlows import *
|
||||||
from tools.postprocessK.flow import getKeff
|
from tools.postprocessK.flow import getKeff
|
||||||
from petsc4py import PETSc
|
from petsc4py import PETSc
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
def PetscP(datadir,ref,k,saveres,Rtol,comm):
|
def PetscP(datadir, ref, k, saveres, Rtol, comm):
|
||||||
|
|
||||||
|
if comm == 0:
|
||||||
|
pcomm = PETSc.COMM_SELF
|
||||||
if comm==0:
|
rank = 0
|
||||||
pcomm=PETSc.COMM_SELF
|
pn = 1
|
||||||
rank=0
|
|
||||||
pn=1
|
else:
|
||||||
|
pcomm = PETSc.COMM_WORLD
|
||||||
else:
|
rank = pcomm.rank
|
||||||
pcomm=PETSc.COMM_WORLD
|
pn = pcomm.size
|
||||||
rank=pcomm.rank
|
|
||||||
pn=pcomm.size
|
t0 = time.time()
|
||||||
|
|
||||||
|
if pn == 1:
|
||||||
t0=time.time()
|
if not isinstance(k, np.ndarray):
|
||||||
|
k = np.load(datadir + "k.npy")
|
||||||
|
if k.shape[2] == 1:
|
||||||
if pn==1:
|
refz = 1
|
||||||
if not isinstance(k,np.ndarray):
|
else:
|
||||||
k = np.load(datadir+'k.npy')
|
refz = ref
|
||||||
if k.shape[2]==1:
|
|
||||||
refz=1
|
nz, ny, nx = k.shape[0] * ref, k.shape[1] * ref, k.shape[2] * refz
|
||||||
else:
|
n = nx * ny * nz
|
||||||
refz=ref
|
|
||||||
|
K = PETSc.Mat().create(comm=pcomm)
|
||||||
nz, ny, nx=k.shape[0]*ref,k.shape[1]*ref,k.shape[2]*refz
|
K.setType("seqaij")
|
||||||
n=nx*ny*nz
|
K.setSizes(((n, None), (n, None))) # Aca igual que lo que usas arriba
|
||||||
|
K.setPreallocationNNZ(nnz=(7, 4)) # Idem anterior
|
||||||
|
K.setUp()
|
||||||
K = PETSc.Mat().create(comm=pcomm)
|
|
||||||
K.setType('seqaij')
|
R = PETSc.Vec().createSeq((n, None), comm=pcomm) # PETSc.COMM_WORLD
|
||||||
K.setSizes(((n,None),(n,None))) # Aca igual que lo que usas arriba
|
R.setUp()
|
||||||
K.setPreallocationNNZ(nnz=(7,4)) # Idem anterior
|
k2, Nz, nnz2 = getKref(k, 1, 2, ref)
|
||||||
K.setUp()
|
k, Nz, nnz = getKref(k, 0, 2, ref)
|
||||||
|
|
||||||
R = PETSc.Vec().createSeq((n,None),comm=pcomm) #PETSc.COMM_WORLD
|
pbc = float(Nz)
|
||||||
R.setUp()
|
|
||||||
k2, Nz, nnz2=getKref(k,1,2,ref)
|
K, R = firstL(K, R, k, pbc)
|
||||||
k, Nz, nnz=getKref(k,0,2,ref)
|
r = (k.shape[1] - 2) * (k.shape[2] - 2) * nnz2 # start row
|
||||||
|
K, R = lastL(K, R, k2, r)
|
||||||
|
|
||||||
pbc=float(Nz)
|
k2 = 0
|
||||||
|
else:
|
||||||
|
|
||||||
K,R = firstL(K,R,k,pbc)
|
if not isinstance(k, np.ndarray):
|
||||||
r=(k.shape[1]-2)*(k.shape[2]-2)*nnz2 #start row
|
k = np.load(datadir + "k.npy")
|
||||||
K,R =lastL(K,R,k2,r)
|
k, Nz, nnz = getKref(k, rank, pn, ref)
|
||||||
|
pbc = float(Nz)
|
||||||
k2=0
|
nz, ny, nx = (k.shape[0] - 2), (k.shape[1] - 2), (k.shape[2] - 2)
|
||||||
else:
|
n = nx * ny * nz
|
||||||
|
|
||||||
|
K = PETSc.Mat().createAIJ(((n, None), (n, None)), nnz=(7, 4), comm=pcomm)
|
||||||
|
K.setUp()
|
||||||
if not isinstance(k,np.ndarray):
|
R = PETSc.Vec().createMPI((n, None), comm=pcomm)
|
||||||
k = np.load(datadir+'k.npy')
|
R.setUp()
|
||||||
k, Nz, nnz=getKref(k,rank,pn,ref)
|
r = nx * ny * nnz * rank # start row
|
||||||
pbc=float(Nz)
|
|
||||||
nz, ny, nx=(k.shape[0]-2),(k.shape[1]-2),(k.shape[2]-2)
|
if rank == 0:
|
||||||
n=nx*ny*nz
|
K, R = firstL(K, R, k, pbc)
|
||||||
|
if (rank > 0) and (rank < pn - 1):
|
||||||
K = PETSc.Mat().createAIJ(((n,None),(n,None)), nnz=(7,4), comm=pcomm)
|
K, R = centL(K, R, k, r)
|
||||||
K.setUp()
|
k = 0
|
||||||
R = PETSc.Vec().createMPI((n,None),comm=pcomm)
|
if rank == (pn - 1):
|
||||||
R.setUp()
|
K, R = lastL(K, R, k, r)
|
||||||
r=nx*ny*nnz*rank #start row
|
k = 0
|
||||||
|
|
||||||
if rank==0:
|
K.assemble()
|
||||||
K,R = firstL(K,R,k,pbc)
|
R.assemble()
|
||||||
if (rank>0) and (rank<pn-1):
|
|
||||||
K,R=centL(K,R,k,r)
|
ksp = PETSc.KSP()
|
||||||
k=0
|
ksp.create(comm=pcomm)
|
||||||
if rank==(pn-1):
|
ksp.setTolerances(rtol=Rtol, atol=1.0e-100, max_it=999999999)
|
||||||
K,R =lastL(K,R,k,r)
|
ksp.setFromOptions()
|
||||||
k=0
|
P = R.copy()
|
||||||
|
ksp.setType(PETSc.KSP.Type.CG)
|
||||||
K.assemble()
|
pc = PETSc.PC()
|
||||||
R.assemble()
|
pc.create(comm=pcomm)
|
||||||
|
pc.setType(PETSc.PC.Type.JACOBI)
|
||||||
|
ksp.setPC(pc)
|
||||||
ksp = PETSc.KSP()
|
ksp.setOperators(K)
|
||||||
ksp.create(comm=pcomm)
|
ksp.setUp()
|
||||||
ksp.setTolerances(rtol=Rtol, atol=1.0e-100, max_it=999999999)
|
t1 = time.time()
|
||||||
ksp.setFromOptions()
|
ksp.solve(R, P)
|
||||||
P = R.copy()
|
t2 = time.time()
|
||||||
ksp.setType(PETSc.KSP.Type.CG)
|
p = P.getArray().reshape(nz, ny, nx)
|
||||||
pc = PETSc.PC()
|
|
||||||
pc.create(comm=pcomm)
|
if rank == 0:
|
||||||
pc.setType(PETSc.PC.Type.JACOBI)
|
keff, Q = getKeff(p, k[1:-1, 1:-1, 1:-1], pbc, Nz)
|
||||||
ksp.setPC(pc)
|
if saveres == True:
|
||||||
ksp.setOperators(K)
|
|
||||||
ksp.setUp()
|
for i in range(1, pn):
|
||||||
t1=time.time()
|
from mpi4py import MPI
|
||||||
ksp.solve(R, P)
|
|
||||||
t2=time.time()
|
comm = MPI.COMM_WORLD
|
||||||
p=P.getArray().reshape(nz,ny,nx)
|
pi = comm.recv(source=i)
|
||||||
|
p = np.append(p, pi, axis=0)
|
||||||
|
|
||||||
|
np.save(datadir + "P", p)
|
||||||
|
f = open(datadir + "RunTimes.out", "a")
|
||||||
if rank==0:
|
f.write("ref: " + str(ref) + "\n")
|
||||||
keff,Q=getKeff(p,k[1:-1,1:-1,1:-1],pbc,Nz)
|
f.write("Matrix creation: " + str(t1 - t0) + "\n")
|
||||||
if saveres==True:
|
f.write("Solver: " + str(t2 - t1) + "\n")
|
||||||
|
f.write("Keff: " + str(keff) + "\n")
|
||||||
for i in range(1,pn):
|
f.write("N_cores: " + str(pn) + "\n")
|
||||||
from mpi4py import MPI
|
f.close()
|
||||||
comm=MPI.COMM_WORLD
|
try:
|
||||||
pi=comm.recv(source=i)
|
res = np.loadtxt(datadir + "SolverRes.txt")
|
||||||
p=np.append(p,pi,axis=0)
|
res = np.append(res, np.array([keff, ref, t2 - t0, pn]))
|
||||||
|
except:
|
||||||
|
res = np.array([keff, ref, t2 - t0, pn])
|
||||||
np.save(datadir+'P',p)
|
np.savetxt(
|
||||||
f=open(datadir+"RunTimes.out","a")
|
datadir + "SolverRes.txt", res, header="Keff, ref, Runtime, N_cores"
|
||||||
f.write("ref: "+str(ref)+"\n")
|
)
|
||||||
f.write("Matrix creation: "+str(t1-t0)+"\n")
|
print(datadir[-3:], " keff= " + str(keff), " rtime= " + str(t2 - t0))
|
||||||
f.write("Solver: "+str(t2-t1)+"\n")
|
return keff
|
||||||
f.write("Keff: "+str(keff)+"\n")
|
|
||||||
f.write("N_cores: "+str(pn)+"\n")
|
else:
|
||||||
f.close()
|
if saveres == True:
|
||||||
try:
|
from mpi4py import MPI
|
||||||
res=np.loadtxt(datadir+'SolverRes.txt')
|
|
||||||
res=np.append(res,np.array([keff,ref,t2-t0,pn]))
|
comm = MPI.COMM_WORLD
|
||||||
except:
|
comm.send(p, dest=0)
|
||||||
res=np.array([keff,ref,t2-t0,pn])
|
|
||||||
np.savetxt(datadir+'SolverRes.txt',res,header='Keff, ref, Runtime, N_cores')
|
return
|
||||||
print(datadir[-3:],' keff= '+str(keff), ' rtime= '+str(t2-t0))
|
|
||||||
return keff
|
|
||||||
|
# Ver: A posteriori error estimates and adaptive solvers for porous media flows (Martin Vohralik)
|
||||||
else:
|
|
||||||
if saveres==True:
|
|
||||||
from mpi4py import MPI
|
|
||||||
comm=MPI.COMM_WORLD
|
|
||||||
comm.send(p, dest=0)
|
|
||||||
|
|
||||||
return
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#Ver: A posteriori error estimates and adaptive solvers for porous media flows (Martin Vohralik)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if sys.argv[5]=='1':
|
if sys.argv[5] == "1":
|
||||||
from mpi4py import MPI
|
from mpi4py import MPI
|
||||||
icomm = MPI.Comm.Get_parent()
|
|
||||||
PetscP(sys.argv[1],int(sys.argv[2]),'0',True,float(sys.argv[4]),1) #multip cores not Tupac
|
|
||||||
#icomm = MPI.Comm.Get_parent()
|
|
||||||
icomm.Disconnect()
|
|
||||||
else:
|
|
||||||
PetscP(sys.argv[1],int(sys.argv[2]),'0',True,float(sys.argv[4]),0) #1 core read k map
|
|
||||||
|
|
||||||
|
|
||||||
except IndexError:
|
|
||||||
try:
|
|
||||||
PetscP(sys.argv[1],int(sys.argv[2]),'0',True,1e-4,1) # multip core as executable
|
|
||||||
except IndexError:
|
|
||||||
nada=0
|
|
||||||
|
|
||||||
|
|
||||||
# PetscP(sys.argv[1],int(sys.argv[2]),sys.argv[3],False,1e-4,0) #1 core, k field as argument
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
icomm = MPI.Comm.Get_parent()
|
||||||
|
PetscP(
|
||||||
|
sys.argv[1], int(sys.argv[2]), "0", True, float(sys.argv[4]), 1
|
||||||
|
) # multip cores not Tupac
|
||||||
|
# icomm = MPI.Comm.Get_parent()
|
||||||
|
icomm.Disconnect()
|
||||||
|
else:
|
||||||
|
PetscP(
|
||||||
|
sys.argv[1], int(sys.argv[2]), "0", True, float(sys.argv[4]), 0
|
||||||
|
) # 1 core read k map
|
||||||
|
|
||||||
|
|
||||||
|
except IndexError:
|
||||||
|
try:
|
||||||
|
PetscP(
|
||||||
|
sys.argv[1], int(sys.argv[2]), "0", True, 1e-4, 1
|
||||||
|
) # multip core as executable
|
||||||
|
except IndexError:
|
||||||
|
nada = 0
|
||||||
|
|
||||||
|
|
||||||
|
# PetscP(sys.argv[1],int(sys.argv[2]),sys.argv[3],False,1e-4,0) #1 core, k field as argument
|
||||||
|
@ -1,17 +1,14 @@
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
|
|
||||||
|
def getKeff(pm, k, pbc, Nz):
|
||||||
|
|
||||||
|
nx = k.shape[2] # Pasar k sin bordes de k=0
|
||||||
|
ny = k.shape[1]
|
||||||
|
|
||||||
def getKeff(pm,k,pbc,Nz):
|
tz = 2 * k[1, :, :] * k[0, :, :] / (k[0, :, :] + k[1, :, :])
|
||||||
|
q = ((pm[0, :, :] - pm[1, :, :]) * tz).sum()
|
||||||
nx = k.shape[2] #Pasar k sin bordes de k=0
|
area = ny * nx
|
||||||
ny = k.shape[1]
|
l = Nz
|
||||||
|
keff = q * l / (pbc * area)
|
||||||
tz = 2*k[1,:,:]*k[0, :,:]/(k[0, :,:]+k[1,:,:])
|
return keff, q
|
||||||
q=((pm[0,:,:]-pm[1,:,:])*tz).sum()
|
|
||||||
area=ny*nx
|
|
||||||
l=Nz
|
|
||||||
keff=q*l/(pbc*area)
|
|
||||||
return keff,q
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue