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

How to define custom-made FunctionSpace objects?

0 votes

I start with

nx = 5
ny = 5
mesh = UnitSquareMesh(nx, ny)
R = FunctionSpace(mesh, "R", 0)

Next: Given some $v \in \mathbb{R}^{10}$ and some $c \in \mathbb{R}^{11}$ (say as list's or as numpy.array's), I wish to define FunctionSpace objects corresponding to the following two vector spaces:

  • $V_1 := \mathbb{R}^{10}$
  • $V_2 :=$ the set of $x \in \mathbb{R}^{10}$ such that $\sum_{j=1}^{10} c_j x_j = c_{11}$

Regarding the construction of $V_1$, I suppose I could do something like:

V_1 = R * R * R * R * R * R * R * R * R * R

but I wonder if I could instead do:

V_1 = R
for i in range(1, 10):
    V_1 = V_1 * R

Regarding the construction of $V_2$, I don't know how to even start.

Any and all suggestions would be welcome.

asked Sep 10, 2015 by kdma-at-dtu FEniCS Novice (590 points)
edited Sep 17, 2015 by kdma-at-dtu

My Python is a bit rusty at the moment, but you could probably also do V1= MixedFunctionSpace([R]*10), May I ask what you intend to do and why you need a finite element package for this?

@Christian Waluga: Thanks for the comment.

To answer your question in a nutshell: The mathematical model I am considering is PDE-based, but a solution to such a model is a pair $(u, c)$ where $u$ is a finite-element function and $V_2$ is as defined in my initial post. Therefore, my trial space has to be a product space of the form some_finite_element_space_for_u * V_2.

I hope this sheds some light on my interest in this issue.

Also, I would like to ask a follow-up question: With regard to the implementation of V_2, the only idea I have been able to come up with is of indirect nature - namely, I could define $V_2 := \mathbb{R}^{10}$ (either via a for-loop, or by means of your suggestion) and replace each occurrence of $c_{11}$ in the definition of the variational problem with $- \left( \sum_{j=1}^{10} c_j \right)$.

However, the indirect nature of this idea is somewhat unsatisfactory, and I would like to know if there is a direct way to implement V_2 in a FEniCS program. I would appreciate any suggestions and pointers to start looking in the right direction.

...