Esempio n. 1
0
from readOF import convertOFMeshToImage,convertOFMeshToImage_StructuredMesh
from sklearn.metrics import mean_squared_error as calMSE
import Ofpp
h=0.01
OFBCCoord=Ofpp.parse_boundary_field('TemplateCase/30/C')
OFLOWC=OFBCCoord[b'low'][b'value']
OFUPC=OFBCCoord[b'up'][b'value']
OFLEFTC=OFBCCoord[b'left'][b'value']
OFRIGHTC=OFBCCoord[b'right'][b'value']
leftX=OFLEFTC[:,0];leftY=OFLEFTC[:,1]
lowX=OFLOWC[:,0];lowY=OFLOWC[:,1]
rightX=OFRIGHTC[:,0];rightY=OFRIGHTC[:,1]
upX=OFUPC[:,0];upY=OFUPC[:,1]
ny=len(leftX);nx=len(lowX)
myMesh=hcubeMesh(leftX,leftY,rightX,rightY,
	             lowX,lowY,upX,upY,h,True,True,
	             tolMesh=1e-10,tolJoint=1)
batchSize=1
NvarInput=2
NvarOutput=1
nEpochs=1500
lr=0.001
Ns=1
nu=0.01
model=USCNN(h,nx,ny,NvarInput,NvarOutput).to('cuda')
criterion = nn.MSELoss()
optimizer = optim.Adam(model.parameters(),lr=lr)
padSingleSide=1
udfpad=nn.ConstantPad2d([padSingleSide,padSingleSide,padSingleSide,padSingleSide],0)
MeshList=[]
MeshList.append(myMesh)
Esempio n. 2
0
 leftX = []
 rightX = []
 for i in leftY:
     if i > -l / 2 and i < l / 2:
         leftX.append(+np.cos(2 * np.pi * i) * scalar - R)
         rightX.append(-np.cos(2 * np.pi * i) * scalar + R)
     else:
         leftX.append(-R)
         rightX.append(R)
 leftX = np.asarray(leftX)
 rightX = np.asarray(rightX)
 lowX = np.linspace(-R, R, nx)
 lowY = lowX * 0 - l / 2 - L / 2
 upX = lowX
 upY = lowY + l + L
 myMesh = hcubeMesh(leftX, leftY, rightX, rightY, lowX, lowY, upX, upY, h,
                    False, True, './Mesh' + str(scalar) + '.pdf')
 MeshList.append(myMesh)
 OFLF = np.zeros([nyOF, 3])
 OFLB = np.zeros([nyOF, 3])
 OFRF = np.zeros([nyOF, 3])
 OFRB = np.zeros([nyOF, 3])
 OFLF[:, 2] = OFRF[:, 2] = 0
 OFLB[:, 2] = OFRB[:, 2] = 0.01
 OFLF[:, 0] = leftX[idy]
 OFLF[:, 1] = leftY[idy]
 OFLB[:, 0] = leftX[idy]
 OFLB[:, 1] = leftY[idy]
 OFRF[:, 0] = rightX[idy]
 OFRF[:, 1] = rightY[idy]
 OFRB[:, 0] = rightX[idy]
 OFRB[:, 1] = rightY[idy]