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

symmetric_assemble in dolfin 1.2.0

+2 votes

What is the dolfin 1.2.0 way of doing a symmetric_assemble like

A, An = symmetric_assemble(a, bc)

# assemble b
b = assemble(L)
bc.apply(b)
b = b - An*b

I'm doing a time integration where only L changes in time. I asked a similar question with regard to the dev version of dolfin (https://answers.launchpad.net/dolfin/+question/226971). However opposed to dolfin dev, dolfin 1.2.0 does not support the following syntax

A, b = assemble_system(a, L, bcs)
assembler = SystemAssembler(a, L, bcs)

# assemble b
assembler.assemble(b)

since the constructor of SystemAssembler does not support any arguments and its assemble method apparently always assembles both the linear and bilinear form.

How do I implement the assembly of the linear form belonging to a symmetric problem in dolfin 1.2.0?

Thanks a lot! Claas

asked Jun 11, 2013 by claasabert FEniCS Novice (180 points)
retagged Jun 12, 2013 by chris_richardson

You need to provide details on what doesn't work. We can do much with 'However it seems like the following does not work with dolfin 1.2.0'.

Thanks for the quick reply and sorry for the vague formulation. The SystemAssembler constructor of dolfin 1.2.0 as opposed to dolfin dev does apparently not support any parameters. Its assemble method always assembles both the biliniear form and the linear form as far as I understand.
I'd like to assemble the bilinear form once in a symmetric fashion and then assemble the linear form for every timestep (like symmetric_assemble in pre 1.2.0 versions of dolfin).

The functionality of reassembling only parts of matrix/vector depending on boundary conditions and caching the rest provided by SymmetricAssembler was definitely removed by Garth during assembler cleanup. I'm not sure why.

So dolfin 1.2.0 is the only version, where this can't be done? Is there any workaround you could imagine? In my case, the assembly of the matrix is pretty expensive. Also I have to stick to the 1.2.0 version of dolfin.

The code:

assembler = SystemAssembler(a, L, bcs)
assembler.assemble(b)

is definitely supported in the development version and is also covered by unit tests.

I thought it was in 1.2, but I don't have 1.2 installed to test. Anyway, some bugs were recently fixed for the above usage case, so I'd recommend using the development version. If you don't want to use git, you can get a snapshot at https://bitbucket.org/fenics-project/dolfin/get/master.tar.gz.


@classabert: You may eventually cherry-pick some old or new features to 1.2.0 and compile.

@Garth: Yes, you're right, my mistake.

Thank you very much Jan and Garth! I will try to switch my code to the dev version of dolfin. The above code for the symmetric assembly works fine. However my main problem when switching to the dev version is, that the mesh domains are no longer stored as MeshFunctions. I will create a new ticket for this.

Problem with new MeshDomains was succesfully solved by Garth. For example:

mesh_domains = mesh.domains()
facet_domains = MeshFunction('size_t', mesh, 1, mesh_domains)

That was quick. Works like a charm. You just saved my day. Thank you so much!

@Garth, could you post this code as answer so that topic can be closed?

1 Answer

+3 votes
 
Best answer

The code:

assembler = SystemAssembler(a, L, bcs)
assembler.assemble(b)

is definitely supported in the development version and is also covered by unit tests.

However, it is not supported in version 1.2. Some bugs were recently fixed for the above usage case, so I'd recommend using the newest development version. If you don't want to use git, you can get a snapshot at https://bitbucket.org/fenics-project/dolfin/get/master.tar.gz.

SystemAssembler is not fully optimised for the assembly of the RHS alone, but it will be soon and it will not affect the user interface.

answered Jun 11, 2013 by Garth N. Wells FEniCS Expert (35,930 points)
edited Jun 11, 2013 by Jan Blechta

This code is not definitely supported in 1.2. Answer edited appropriately.

...