Skip to content
This repository has been archived by the owner on Jul 19, 2023. It is now read-only.

Incorrect boundary padded vector with composed PeriodicBC on 2d data #514

Open
vigeesh opened this issue Feb 22, 2022 · 6 comments
Open

Comments

@vigeesh
Copy link

vigeesh commented Feb 22, 2022

I'm trying to pad my vector u using the boundary condition operator Q.
It works fine for 1d data, but gives me incorrect padded vector for 2d data when I use PeriodicBC.

Code for reproduction

1-D

#left-plot
plot(data1d)
#right-plot
Q1 = Dirichlet0BC(Float64)
plot(Q1*data1d,label="Q1*u (Dirichlet)")
Q2 = PeriodicBC(Float64)
plot!(Q2*data1d,label="Q2*u (Periodic)")

out

2-D

#left-plot
heatmap(data2d)
#right-plot
Q3 = compose(Dirichlet0BC(Float64, (6,6))...)
heatmap(Q3*data2d)

2d_dir

But, when I use PeriodicBC,

#left-plot
Q4 = compose(PeriodicBC(Float64, (6,6))...)
heatmap(Q4*data2d)
#right-plot
heatmap(periodic_expected)

I get a padded data as shown in the left plot below, but I expect to get the one shown in the right,
2d_per

Am I doing something wrong in composing the BC's in 2-D?

@xtalax
Copy link
Member

xtalax commented Feb 22, 2022

I will take a look at this

@xtalax
Copy link
Member

xtalax commented Feb 23, 2022

In the meantime, you should be aware that MethodOfLines.jl now has support for periodic BCs. If this doesn't help you solve your problem we'd love to know why.

@xtalax
Copy link
Member

xtalax commented Feb 23, 2022

There's something strange going on, here the first testset passes, wheras the second testset displays the issue you described though both contain periodic BCs

@vigeesh
Copy link
Author

vigeesh commented Feb 24, 2022

Thanks @xtalax , I'll have a look at MethodOfLines.jl

here the first testset passes,

But it looks like it's not returning a correctly padded data.

I'm not sure if I understand this line:

BCx = vcat(fill(q1, div(m,2)), fill(q2, m-div(m,2)))  #The size of BCx has to be all size components *except* for x
BCy = vcat(fill(q2, div(n,2)), fill(q1, n-div(n,2)))

Why is it not,

BCx = fill(q1,m)
BCy = fill(q2,n)

But, even in the latter case, it gives me wrong results when I use PeriodicBC in both dims, but strangely gives me correct padding when I use a combination of PeriodicBC (along one dim) and Dirichlet/Neumann/RobinBC (for the other dim).

@xtalax
Copy link
Member

xtalax commented Feb 24, 2022

This was to test the constructor which supports different bcs along a boundary to facilitate space dependant robin.

But, even in the latter case, it gives me wrong results when I use PeriodicBC in both dims, but strangely gives me correct padding when I use a combination of PeriodicBC (along one dim) and Dirichlet/Neumann/RobinBC (for the other dim).

How are you applying the BCs, with compose? I wonder if its due to some compiler strangeness simplifying the filled periodic as a single object.

@vigeesh
Copy link
Author

vigeesh commented Feb 24, 2022

How are you applying the BCs, with compose?

yes, like in the test

BCx = fill(q1,m)
BCy = fill(q2,n)
Qx = MultiDimBC{1}(BCx)
Qy = MultiDimBC{2}(BCy)
Q = compose(BCx,BCy)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants