Re: [deal.II] Discrete Galekin with periodic boundary condition

2018-11-08 Thread Jaekwang Kim
Thanks for the reply! 
I will take a look

Jaekwang 

On Wednesday, November 7, 2018 at 10:05:10 PM UTC-6, Praveen C wrote:
>
> You have to do some extra work to use periodic bc with MeshWorker. I have 
> a Euler DG code here which can do that
>
> https://github.com/cpraveen/dflo/tree/master/src_mpi
>
> The periodic bc is setup in these files (not my code, authors are 
> mentioned in the files)
>
> DealiiExtensions.cc
> DealiiExtensions.h 
> 
>
> Then see how these functions are used in claw.cc
>
> This code is somewhat old now and I have not run it for quite some time. 
> So it may or may not compile/run with latest deal.II, you have to try it 
> out.
>
> I have a simpler DG code for linear advection without MeshWorker here
>
> https://bitbucket.org/cpraveen/deal_ii/src/master/dg/1d_scalar_legendre/
>
> Best
> praveen
>
> On 08-Nov-2018, at 8:31 AM, Jaekwang Kim > 
> wrote:
>
>
>
> I am trying to solve advection equation using DG method with Meshworker. 
>
> Yet, I have a problem in implementing periodic boundary condition. 
>
> For example, I consider a 1D advection equation with periodic boundary 
> condition
>
>
>
> with source term f=-sin(x), I assume that I should get cos(x) as a steady 
> state solution, and I have confirmed this set up for the toy problem using 
> Finite Difference.  
>
>
>
>
> I derived my weak form as follow...
>
> 
>
>
>
> I am assembling equation (11) every time step,
>
>
> Mass matrix for n+1 step solution 
>
>
>  local_matrix(i,j) += fe_v.shape_value(i,point) *
>
>   fe_v.shape_value(j,point) *
>
>   JxW[point];
>
>
>
>
>
> and right hand side is 
>
> (cell integration) 
>
> local_vector(i) += (fe_v.shape_value(i,point)
>
> *(sol_phi[point] + dt * source_values[point])
>
> +
>
> dt*(advection_values[point]
>
> *fe_v.shape_grad (i,point))
>
> *sol_phi[point]
>
> ) *JxW[point];
>
>
>
> (Face integration) 
>
>
>  for (unsigned int i=0; i
> {
>
> if(advection_dot_normal >0) //outflux
>
> {local_vector(i) -= dt * advection_dot_normal *
>
> 
> (fe_v.shape_value(i,point)-fe_v_neighbor.shape_value(i,point)) *
>
> my_sol_phi[point] *
>
> JxW[point];
>
> }
>
> else //influx
>
> {
>
> local_vector(i) -= dt * advection_dot_normal *
>
>
> (fe_v.shape_value(i,point)-fe_v_neighbor.shape_value(i,point)) *
>
>neighbor_sol_phi[point] *
>
>JxW[point];
>
> }
>
> }
>
>
> (Boundary Integration)  <-think this is may be the problem 
>
>
>
> for (unsigned int i=0; i
> {   //sign changed here
>
> if(advection_dot_normal >0) //outflux
>
> { local_vector(i)-= dt*advection_dot_normal *
>
> fe_v.shape_value(i,point) *
>
> sol_phi[point] *
>
> JxW[point];
>
> }
>
> else
>
> {
>
> //influx this is problematic...it should be 
> connected to last end cell (but..how?)
>
>   local_vector(i)-= dt*advection_dot_normal *
>
> fe_v.shape_value(i,point) *
>
> *sol_phi[point] * *it should be 
> connected to last end cell, but the boundary integrate function cannot 
> call information from reference cell...  (but..how?)
>
> JxW[point];
>
> }
>
> }
>
>
> As I am solving this x in [0,4pi] I should see two period of cosine wave 
> after enough time step, but it is not..
>
>
>
> 
>
>
> Is there anyone who have the idea to use Meshworker for 
>
>
> *1D advection equation with periodic boundary condition?*
>
>
>
> Thanks in advance 
>
>
> Jaekwang 
>
>
>
> -- 
> The deal.II project is located at http://www.dealii.org/
> For mailing list/forum options, see 
> https://groups.google.com/d/forum/dealii?hl=en
> --- 
> You received this message because you are subscribed to the Google Groups 
> "deal.II User Group" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to dealii+un...@googlegroups.com .
> For more options, visit https://groups.google.com/d/optout.
>  6.15.31 PM.png>
>
>
>

-- 
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see 

Re: [deal.II] Discrete Galekin with periodic boundary condition

2018-11-07 Thread Praveen C
You have to do some extra work to use periodic bc with MeshWorker. I have a 
Euler DG code here which can do that

https://github.com/cpraveen/dflo/tree/master/src_mpi 


The periodic bc is setup in these files (not my code, authors are mentioned in 
the files)

DealiiExtensions.cc 
DealiiExtensions.h 


Then see how these functions are used in claw.cc 

This code is somewhat old now and I have not run it for quite some time. So it 
may or may not compile/run with latest deal.II, you have to try it out.

I have a simpler DG code for linear advection without MeshWorker here

https://bitbucket.org/cpraveen/deal_ii/src/master/dg/1d_scalar_legendre/ 


Best
praveen

> On 08-Nov-2018, at 8:31 AM, Jaekwang Kim  wrote:
> 
> 
> 
> 
> 
> I am trying to solve advection equation using DG method with Meshworker. 
> 
> Yet, I have a problem in implementing periodic boundary condition. 
> 
> For example, I consider a 1D advection equation with periodic boundary 
> condition
> 
> 
> 
> 
> 
> with source term f=-sin(x), I assume that I should get cos(x) as a steady 
> state solution, and I have confirmed this set up for the toy problem using 
> Finite Difference.  
> 
> 
> 
> 
> 
> 
> 
> I derived my weak form as follow...
> 
> 
> 
> 
> 
> 
> 
> I am assembling equation (11) every time step,
> 
> 
> 
> Mass matrix for n+1 step solution 
> 
> 
> 
>  local_matrix(i,j) += fe_v.shape_value(i,point) *
> 
>   fe_v.shape_value(j,point) *
> 
> 
>   JxW[point];
> 
> 
> 
> 
> 
> 
> 
> 
> and right hand side is 
> 
> (cell integration) 
> 
> local_vector(i) += (fe_v.shape_value(i,point)
> 
> *(sol_phi[point] + dt * source_values[point])
> 
> +
> 
> dt*(advection_values[point]
> 
> *fe_v.shape_grad (i,point))
> 
> *sol_phi[point]
> 
> ) *JxW[point];
> 
> 
> 
> 
> 
> (Face integration) 
> 
> 
> 
>  for (unsigned int i=0; i 
> {
> 
> if(advection_dot_normal >0) //outflux
> 
> {local_vector(i) -= dt * advection_dot_normal *
> 
> 
> (fe_v.shape_value(i,point)-fe_v_neighbor.shape_value(i,point)) *
> 
> my_sol_phi[point] *
> 
> JxW[point];
> 
> }
> 
> else //influx
> 
> {
> 
> local_vector(i) -= dt * advection_dot_normal *
> 
>
> (fe_v.shape_value(i,point)-fe_v_neighbor.shape_value(i,point)) *
> 
>neighbor_sol_phi[point] *
> 
>JxW[point];
> 
> }
> 
> 
> }
> 
> 
> 
> (Boundary Integration)  <-think this is may be the problem 
> 
> 
> 
> 
> 
> for (unsigned int i=0; i 
> {   //sign changed here
> 
> if(advection_dot_normal >0) //outflux
> 
> { local_vector(i)-= dt*advection_dot_normal *
> 
> fe_v.shape_value(i,point) *
> 
> sol_phi[point] *
> 
> JxW[point];
> 
> }
> 
> else
> 
> {
> 
> //influx this is problematic...it should be connected 
> to last end cell (but..how?)
> 
>   local_vector(i)-= dt*advection_dot_normal *
> 
> fe_v.shape_value(i,point) *
> 
> sol_phi[point] * it should be 
> connected to last end cell, but the boundary integrate function cannot call 
> information from reference cell...  (but..how?)
> 
> JxW[point];
> 
> }
> 
> 
> }
> 
> 
> 
> As I am solving this x in [0,4pi] I should see two period of cosine wave 
> after enough time step, but it is not..
> 
> 
> 
> 
> 
> 
> 
> 
> 
> Is there anyone who have the idea to use Meshworker for 
> 
> 
> 
> 1D advection equation with periodic boundary condition?
> 
> 
> 
> 
> 
> Thanks in advance 
> 
> 
> 
> Jaekwang 
> 
> 
> 
> 
> -- 
> The deal.II project is located at http://www.dealii.org/ 
> 
> For mailing list/forum options, see 
> https://groups.google.com/d/forum/dealii?hl=en 
> 
> --- 
> You received this message because you are subscribed to the Google Groups 
> "deal.II User Group" group.
> To unsubscribe from this group and stop receiving emails