我在Windows子系统的Linux上安装了fenics来做作业。我正在尝试测试fenics。所以我在本教程上使用ft01_possion.py。
*(text+3)
它没有显示数字。 我得到的错误是:
from fenics import *
# Create mesh and define function space
mesh = UnitSquareMesh(8, 8)
V = FunctionSpace(mesh, 'P', 1)
# Define boundary conditions
u_D = Expression('1 + x[0]*x[0] + 2*x[1]*x[1]', degree = 2)
def boundary(x, on_boundary):
return on_boundary
bc = DirichletBC(V, u_D, boundary)
# Define variational problem
u = TrialFunction(V)
v = TestFunction(V)
f = Constant(-6.0)
a = dot(grad(u), grad(v))*dx
L = f*v*dx
# Compute solution
u = Function(V)
solve(a == L, u, bc)
# Plot solution and mesh
plot(u)
plot(mesh)
interactive()
我曾尝试重新安装fenics。但这是最新的。
答案 0 :(得分:1)
不幸的是,有些Fenics示例已经过时了。请参阅以下GitHub post。
将'interactive()'更改为
static async Task Main(string[]args)
{
// Those two tasks need to run at the same time
Task.Run(() =>
{
// Need to be awaited
var writer = WritingDatabase();
}
Task.Run(() =>
{
// Need to be awaited as well
var reader = ReadingDatabase();
}
}
public async Task<List<Code>> ReadingDatabase()
{
List<Code> listCode = new List<Code>();
// Some code
listCode.Add(await database.ReceiveMessageAsync());
return listCode;
}
这将显示您的结果。
答案 1 :(得分:0)
错误显示如下: error_L2 = 0.008235098073354827 error_max = 1.3322676295501878e-15 但是有:NameError:未定义名称'interactive',可能这个错误不会影响结果