Basic queries from the fenics book, chapter 1, Set #1

  1. I guess this is more of a python question than FEniCS.

This looks fine to me. At least evaluating the function itself, pe se. Check the lines before and after.

That is as much as there is to Spyder. I haven’t used it in a very long time. The answers here are your best friend.

  1. If you want to interactively visualize the solution as opposed to using Paraview, I would suggest using vtkplotter (now vedo I believe). See here and a list of examples here. A minimal example would be
from vedo.dolfin import plot as vtplot # if you are using `from dolfin import *`
vtplot(u) # u is your `dolfin` Function
  1. For simple problems, when using vanilla solve interface would give you the solution, I believe you need not. For more complicated and niche problems, you may have to fine tune your solver.

  2. You can get the keys of parameters by simply doing:

print(parameters.keys()) #this gives you the keys
print(parameters["key"]) # "key" is in the list `parameters.keys()`
  1. See this It is pretty much how you would do it in matplotlib which is the backend for plot

  2. Could you explain by what do you mean they do not work?

  3. You are passing a dictionary to solver_parameters. If you assign it to a variable first and then pass that, you can see what you want

solverParams = {“linear_solver”: “cg”, “preconditioner”: “ilu”}
solve(a == L, u, bc, solver_parameters = solverParams)

  1. You are setting the verbosity of dolfin’s log and not printing anything. You need to print the log level
print(get_log_level())

to print the current log_level

  1. It should print all the global variable names. As I have not used dolfin with Spyder I do not completely know what variable names are you seeing in addition to what you globally declare in your code. If you paste a screenshot, that would perhaps help in deciphering the issue.
3 Likes