Google Colab中保存的文件在哪里?

时间:2019-11-20 14:10:53

标签: python google-colaboratory vtk pde fenics

我正在尝试访问一个VTK文件,其中保存了热方程的解,但是我不知道它在Colab中的保存位置。

int* a = malloc(sizeof(int));
*a = 4;
// ...
free(a);

我已经尝试过了

from fenics import *
import time
T = 2.0            # final time
num_steps = 50     # number of time steps
dt = T / num_steps # time step size
# Create mesh and define function space
nx = ny = 30
mesh = RectangleMesh(Point(-2, -2), Point(2, 2), nx, ny)
V = FunctionSpace(mesh, 'P', 1)
# Define boundary condition
def boundary(x, on_boundary):
    return on_boundary
bc = DirichletBC(V, Constant(0), boundary)
# Define initial value
u_0 = Expression('exp(-a*pow(x[0], 2) - a*pow(x[1], 2))',
                 degree=2, a=5)
u_n = interpolate(u_0, V)
# Define variational problem
u = TrialFunction(V)
v = TestFunction(V)
f = Constant(0)
F = u*v*dx + dt*dot(grad(u), grad(v))*dx - (u_n + dt*f)*v*dx
a, L = lhs(F), rhs(F)
# Create VTK file for saving solution
vtkfile = File('heat_gaussian/solution.pvd')
# Time-stepping
u = Function(V)
t=0
for n in range(num_steps):
    # Update current time
    t += dt
    # Compute solution
    solve(a == L, u, bc)
    # Save to file and plot solution
    vtkfile << (u, t)
    plot(u)
    # Update previous solution
    u_n.assign(u)
# Hold plot
#interactive()

from google.colab import files
plt.savefig("vtkfile")
files.download("vtkfile")

但是仍然出现错误。在笔记本中创建的文件存储在哪里?

3 个答案:

答案 0 :(得分:1)

如果您安装了GDrive,则文件应存储在名为 Colab Notebooks

的文件夹中

您还可以使用以下命令之一检查当前文件夹。

%cd

!pwd 

答案 1 :(得分:1)

补充@jules-cui 的回答,在 Colab 界面的左侧你会看到几个图标。 单击文件夹图标,这会打开运行时中的所有文件。您可以点击任何文件右侧的扩展菜单,然后点击下载。

答案 2 :(得分:0)

在colab界面的左侧,有一个“文件”选项卡。您可以在其中找到保存的所有文件。