Different test- and trial spaces in FEniCS

Asked by Anders Pettersson

I wonder if it is not possible to solve PDE:s by Galerkin methods using different test and trial spaces? For example test functions as piecewise polynomials of degree q and trial functions of degree q-1, or vice verse depending on the problem?
Thanks!

Question information

Language:
English Edit question
Status:
Answered
For:
DOLFIN Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Anders Logg (logg) said :
#1

On Fri, Mar 09, 2012 at 03:06:22PM -0000, Anders Pettersson wrote:
> New question #190182 on DOLFIN:
> https://answers.launchpad.net/dolfin/+question/190182
>
> I wonder if it is not possible to solve PDE:s by Galerkin methods using different test and trial spaces? For example test functions as piecewise polynomials of degree q and trial functions of degree q-1, or vice verse depending on the problem?
> Thanks!

Yes, but you must make sure that you have the same number of trial and
test functions (you want to get a square non-singular system).

--
Anders

Revision history for this message
Anders Pettersson (fridasvelander) said :
#2

Ok, thank you!

Revision history for this message
Joachim Haga (jobh) said :
#3

>> I wonder if it is not possible to solve PDE:s by Galerkin methods using different test and trial spaces? For example test functions as piecewise polynomials of degree q and trial functions of degree q-1, or vice verse depending on the problem?
>
> Yes, but you must make sure that you have the same number of trial and
> test functions (you want to get a square non-singular system).

If the number of trial and test functions are not the same, it can be
solved (in the least-squares sense) f.x. with cbc.block. I don't know
if that's useful, but here's an example showing how:

from dolfin import *
from block import *
from block.iterative import ConjGrad
from block.algebraic.trilinos import ML

mesh = UnitSquare(16,16)

V = FunctionSpace(mesh, "CG", 1)
W = FunctionSpace(mesh, "CG", 2)

f = Expression("sin(3.14*x[0])")
u = TrialFunction(V)
v = TestFunction(V)
w = TestFunction(W)

# Form used for preconditing

am = u*v*dx + dot(grad(u), grad(v))*dx

# Forms for linear system, with different test/trial functions

a = u*w*dx + dot(grad(u), grad(w))*dx
L = f*w*dx

# Create linear system (matrices, transpose operator, RHS vector)

Am = assemble(am)
A = assemble(a)
AT = block_transpose(A)
b = assemble(L)

# Create inverse operator, preconditioned by ML

ATAinv = ConjGrad(AT*A, precond=ML(Am))

# Solve and plot

x = ATAinv*AT*b

plot(Function(V, x))
interactive()

Revision history for this message
Anders Pettersson (fridasvelander) said :
#4

Thanks for your help!

Revision history for this message
fanronghong (fanronghong) said :
#5

Now If I want to different boundary condition for trial and test function space, how should I do?

For example, trial function u = 1 on domain boundary, test function v = 2 on domain boundary and test function w = 3 on domain boundary.

Thanks in advance!!!

Can you help with this problem?

Provide an answer of your own, or ask Anders Pettersson for more information if necessary.

To post a message you must log in.