nmmhuynh
(Monica)
March 17, 2021, 3:27pm
1
Hi everyone!
I am sequentially solving two PDEs, correlated by the diffusion term:
After solving the first PDE (thus getting u) with
solve firstpde (u, v) = int3d (Th) ( A * grad(u)’ * grad(v) ) + BCs ) ;
where Th is the triangulation of the mesh Vh, I tried to define the diffusion coefficient B as
macro grad(f) [dx(f), dy(f), dz(f) ]
func B = int3d (Th) ( A * grad( u ) ) )
but it gives me error on the definition of B.
Does anyone can help me?
Thank you!
Where is the depend in x in definition of B, it is in function u ?
nmmhuynh
(Monica)
March 18, 2021, 8:54am
3
oh I’m sorry, I wrote it wrong.
B is constant through the domain.
so no problem just do:
real Bx = int2d(Th)(Adx(u));
real By = int2d(Th)(A dy(u));
B is a vector because A is a scalar ,
so the third equation have no meaning
nmmhuynh
(Monica)
March 18, 2021, 10:11am
5
Ok, so B = [Bx, By], is that correct?
How can I then solve the third equation? I would be a simple laplace problem with constant coefficient B.
I tried to put Bx, By into a diagonal matrix
matrix B = [ [Bx, 0], [0, By] ];
and then solve the problem
macro grad(func) [dx(func), dy(func), dz(func) ] \
func rhs = 1;
solve secondPDE (w, v) = int2d(Th) ( B * grad(w)’ * grad(v) ) - int2d(Th) ( rhs * v ) + BCs
but it gives me error on the last line.
Is it related to the definition of the diffusion coefficient B as matrix? Should it be a constant?
Thank you very much for your help!
you have to write
with in 2d the grad definition is
macro grad(u) [dx(u),dy(u)]//
... int2d(Th) ( grad(w)’ *B* grad(v) ) ...
nmmhuynh
(Monica)
March 18, 2021, 10:50am
7
Sorry, I have mixed 3D and 2D.
However, it still doesn’t work.
macro grad(u) [dx(u), dy(u)] //
matrix B = [ [Bx, 0], [0, By] ];
func rhs = 1;
solve secondPDE (w, v) = int2d(Th) ( grad(w)’ * B * grad(v) ) …
It says
Error in (last) line, before token *
Compile error :
line number :176, *
the correct writing is in
monica.edp (310 Bytes)
nmmhuynh
(Monica)
March 18, 2021, 1:10pm
9
Thank you very very much for your help!