This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Suggestions on implementing DO?

0 votes

I'm planning trying to replicate the numerical scheme described in this paper using fenics:
http://mseas.mit.edu/publications/PDF/ueckermann_etal_DO-numerics_JCP2013.pdf

I already have the IPC scheme working for flow over a circular cylinder (same geometry as those authors), but now I want to implement the stochastic part.

To do this I need to store multiple velocity and pressure fields, one for each mode, and one for the mean. I also have to store monte-carlo samples for each of the modes (but this can be done in a simple numpy array). At some point, I would like to do a matrix-vector product of the sample-covariance matrix and the velocity modes, and it is not apparent to me how to do that using fenics.

I was thinking of just storing the different velocity modes in a python list and iterating through, using loops (basically writing my own, inefficient matrix-vector products). But it would be nice (i.e. more efficient) to be able to do some matrix operations.

I'm still a fenics newb, and I'm working my way through the book, but it wasn't apparent to me if there would be a simple python-route to do this. Can anyone point me to useful documentation, or does anyone have any suggestions?

Thanks!

asked Apr 26, 2014 by ns-do FEniCS Novice (230 points)

You need to ask a focused question to maximum the likelihood of an answer, e.g., 'How do I do X in FEniCS?', where X is clear and precise.

1 Answer

+2 votes
 
Best answer

GenericMatrix inherits GenericLinearOperator::mult method which is efficiently implemented by linear algebra backend (default PETSc). For your field (Function DOLFIN object), say u, you can access these vectors using u.vector() and manipulate with it using the GenericVector infeterface. Matrices and vectors can be assembled by DOLFIN from bilinear and linear forms. Things which can't be done using DOLFIN can be often managed using petsc4py. You just access petsc4py objects using PETScMatrix.mat(), PETScVector.vec(),... PETScFoo.bar().

answered Apr 28, 2014 by Jan Blechta FEniCS Expert (51,420 points)
selected Apr 30, 2014 by ns-do

Excellent. Thanks you. I think this is what I was looking for.

...