使用 FENICS 模拟 3D 活塞中的热扩散

计算科学 有限元 泊松 芬尼克斯 gmsh
2021-12-25 01:09:34

我正在尝试模拟 3D 活塞中的热扩散。我标记了 GMSH 的边界。

我在活塞的顶面上使用了 300 的 Dirichlet BC。但结果看起来异常。沿着顶面边缘的温度会发生变化,这不应该是这种情况。

这是代码片段

from __future__ import print_function
from fenics import *
import numpy as np


mesh = Mesh("piston-3d.xml");

V = FunctionSpace(mesh, 'P', 1)

subdomains = MeshFunction("size_t", mesh, "piston-3d_physical_region.xml")
boundaries = MeshFunction("size_t", mesh, "piston-3d_facet_region.xml")


#Define neumann bcs
g_1= Constant(300.0)
g_2 = Constant(100.0)
g_3 = Constant(30.0)
g_4 = Constant(0.0) // On the cross-sectional faces, Neumann
g_5 = Constant(0.0) // On the cross-sectional faces, Neumann


bc1 = DirichletBC(V, g_1, boundaries, 1) // Top face of piston
bc2 = DirichletBC(V, g_2, boundaries, 2) // Liner face of the piston
bc3 = DirichletBC(V, g_3, boundaries, 3) // Inner side of piston and bottom

bcs = [bc1, bc2, bc3]

#define measures
ds = Measure('ds', domain=mesh, subdomain_data=boundaries)
dx = Measure('dx', domain=mesh, subdomain_data=subdomains)


u_D = Constant(100.0)

# Define initial value
u_n = interpolate(u_D, V)


# Define variational problem
u = TrialFunction(V)
v = TestFunction(V)
f = 0.0

a = dot(grad(u), grad(v))*dx 

L = f*v*dx - (g_4*v*ds(4) + g_5*v*ds(5))

# Time-stepping
u = Function(V)

# Compute solution
solve(a == L, u, bcs)

vtkfile = File("solution_steady.pvd")   
vtkfile << u

结果看起来像这样

我的问题是为什么顶面的温度不保持恒定(300)?是因为边界共享吗?

0个回答
没有发现任何回复~