### Defining a source term equals to: CST1 on part of the domain and to CST2 elsewhere

196
views
0
5 months ago by
Dear Fenics community,

I am considering a 3D vector field u that is defined in the cylindrical geometry:
domain = Cylinder(Point(cylinder_length, 0, 0), Point(0, 0, 0), W, W, 64)
mesh = generate_mesh(domain, 64)​

I would like to define the linear form $L\left(v\right)=\int_{\Omega}f\cdot v\mathrm{dx}$L(v)=Ωƒ ·vdx where   $f=\left(f_1,f_2,f_3\right)$ƒ =(ƒ 1,ƒ 2,ƒ 3) is a 3D vector field (like the 3D test vector function  $v$v ). The space is three dimensional  $x=\left(x_0,x_1,x_2\right)$x=(x0,x1,x2).
I would like to define  $f$ƒ such that:
1. $f\left(x_0,x_1,x_2\right)=\left(a_0,a_1,a_2\right)$ƒ (x0,x1,x2)=(a0,a1,a2) if   $L_1$L1$x_0$x0$L_2$L2
2. $f\left(x_0,x_1,x_2\right)=\left(b_0,b_1,b_2\right)$ƒ (x0,x1,x2)=(b0,b1,b2) otherwise
Note that  $\left(a_0,a_1,a_2\right)$(a0,a1,a2) and  $\left(b_0,b_1,b_2\right)$(b0,b1,b2) are constants.
My question is how do I define such function ? Should I:

1. Define f directly through an expression (maybe with some if statement : if {x0>L_1 and x_0<L2} then f=(a0,a1,a2) else f=(b0,b1,b2))
2. Cut the space into different subspaces and define f as being constant on each of these subspaces
3. Another method...
As I am rather new to fenics so I would appreciate if you could also provide the piece of code to achieve that.

Thank you very much in advance for your help !!!

PS: Last time Hernan was very helpful for a similar question ;-)

Community: FEniCS Project
I think this question is pretty similar, just that instead of a scalar quantity you have a vector:
https://www.allanswered.com/post/eqvbw/how-to-implement-a-piece-wise-constant-curl-curlelectromagnetic-maxwell-equations/

If your domains are fixed, try to include them already in the mesh generation process. This way, your subdomain boundaries would consist of element boundaries and the definition is followed better. (Cf. https://www.allanswered.com/post/nqzba/defending-sub-domains/)
written 5 months ago by klunkean
Please login to add an answer/comment or follow this question.

Similar posts:
Search »