Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Periodic background mesh #88

Open
zjwegert opened this issue Jun 7, 2024 · 4 comments
Open

Periodic background mesh #88

zjwegert opened this issue Jun 7, 2024 · 4 comments

Comments

@zjwegert
Copy link
Contributor

zjwegert commented Jun 7, 2024

Hi,
Is there support for periodic background meshes? The MWE below does not work.

using Gridap
using GridapEmbedded,GridapEmbedded.LevelSetCutters
import Gridap.Geometry: get_node_coordinates,collect1d

model = CartesianDiscreteModel((0,1,0,1),(100,100),isperiodic=(true,true));
V_φ = TestFESpace(model,ReferenceFE(lagrangian,Float64,1))

φh = interpolate(x->-cos(4π*x[1])*cos(4*pi*x[2])/4-0.2/4,V_φ)
point_to_coords = model.grid_topology.vertex_coordinates
geo = DiscreteGeometry(get_free_dof_values(φh),point_to_coords,name="")
cutgeo = cut(model,geo)

Ω = Triangulation(cutgeo,PHYSICAL)

writevtk(Ω,"discrete_geo_periodic",cellfields=["φh"=>φh])

Based on some testing I've conducted, it seems that analytic geometries do respect periodicity of the background mesh though.

@zjwegert
Copy link
Contributor Author

zjwegert commented Jun 8, 2024

Similar to #89, it looks like this just requires that the FEFunction is evaluated at all model node coordinates. E.g.,

using Gridap
using GridapEmbedded,GridapEmbedded.LevelSetCutters
import Gridap.Geometry: get_node_coordinates,collect1d

model = CartesianDiscreteModel((0,1,0,1),(100,100),isperiodic=(true,true));
V_φ = TestFESpace(model,ReferenceFE(lagrangian,Float64,1))

φh = interpolate(x->-cos(4π*(x[1]))*cos(4*pi*x[2])/4-0.2/4,V_φ)
point_to_coords = collect1d(get_node_coordinates(model))
geo = DiscreteGeometry(φh(point_to_coords),point_to_coords,name="")
cutgeo = cut(model,geo)

Ω = Triangulation(cutgeo,PHYSICAL)

writevtk(Ω,"discrete_geo_periodic",cellfields=["φh"=>φh])

It might be nice to create a version of the constructor for DiscreteGeometry that takes an FEFunction/CellField and is optimised to avoid searching in φh(point_to_coords)

@zjwegert
Copy link
Contributor Author

The changes in #89 allows for a periodic background mesh when generating a DiscreteGeometry. I have added a serial test of AgFEM with a periodic background mesh in #90. This works as expected.

I've also added a distributed test but this is currently disabled due to #87. I expect these will work once #87 has been fixed.

@ericneiva
Copy link
Member

Hi, @zjwegert, concerning #87, I have already implemented the fix in
b70a256. Whenever I find some time, I will PR this into to GE. Hope I can do it soon.

PS: I only see your comment now (sorry, I was on holidays).

@ericneiva
Copy link
Member

Hi, @zjwegert, FYI: #93

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

No branches or pull requests

2 participants