Skip to content

Commit

Permalink
Merge pull request #81 from gridap/affine-maps
Browse files Browse the repository at this point in the history
Support for Affine maps
  • Loading branch information
JordiManyer authored Sep 24, 2024
2 parents 70bb909 + 4cf67de commit f221e3b
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 9 deletions.
31 changes: 31 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,76 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.7.2] - 2024-09-24

### Added

- Added `has_affine_maps` kwarg.

## [0.7.1] - 2024-04-12

### Added

- Extension to 1D meshes in 2D space.
- Support for Gridap v0.18

## [0.7.0] - 2023-08-16

### Added

- High order meshes
- Support for PartitionedArrays v0.3

## [0.6.1] - 2022-07-29

### Fixed

- Handling of periodic boundaries, when two periodic boundaries intersect in a common vertex or edge.

## [0.6.0] - 2022-02-11

### Changed

- Substantial change in the dependencies to allow parallel computations.

### Added

- Support for parallel computations via `GridapDistributed`.

## [0.5.0] - 2021-11-24

### Changed

- Restrict to Gridap 0.17 as required for surface meshes.

## [0.4.5] - 2021-11-24

### Fixed

- Some tests failing for Gridap 0.16.

## [0.4.4] - 2021-11-22

### Added

- Support for surfaces meshes.

## [0.4.3] - 2021-10-28

### Added

- Support for Gridap v0.17.

## [0.4.2] - 2021-06-08

### Added

- Support for Gridap v0.16.

## [0.4.1] - 2021-01-22

### Added

- Support for periodic boundary conditions.
- Automatic installation via `BinaryBuilder.jl`.

Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "GridapGmsh"
uuid = "3025c34a-b394-11e9-2a55-3fee550c04c8"
authors = ["Francesc Verdugo <[email protected]>"]
version = "0.7.1"
version = "0.7.2"

[deps]
Gridap = "56d4f2e9-7ea1-5844-9cf6-b9c51ca7ce8e"
Expand Down
22 changes: 14 additions & 8 deletions src/GmshDiscreteModels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ const D3=3
const POINT=15
const UNSET = 0

function GmshDiscreteModel(mshfile; renumber=true)
# Note on has_affine_map:
# By default, the cell maps are only affine if the grid is simplicial. However,
# some cartesian-like grids can also have affine maps. You can force the creation of
# affine maps by setting has_affine_map=true.

function GmshDiscreteModel(mshfile; renumber=true, has_affine_map=nothing)
@check_if_loaded
if !isfile(mshfile)
error("Msh file not found: $mshfile")
Expand All @@ -17,18 +22,18 @@ function GmshDiscreteModel(mshfile; renumber=true)
gmsh.open(mshfile)
renumber && gmsh.model.mesh.renumberNodes()
renumber && gmsh.model.mesh.renumberElements()
model = GmshDiscreteModel(gmsh)
model = GmshDiscreteModel(gmsh;has_affine_map)
gmsh.finalize()
model
end

function GmshDiscreteModel(gmsh::Module)
function GmshDiscreteModel(gmsh::Module; has_affine_map=nothing)
Dc = _setup_cell_dim(gmsh)
Dp = _setup_point_dim(gmsh,Dc)
node_to_coords = _setup_node_coords(gmsh,Dp)
nnodes = length(node_to_coords)
vertex_to_node, node_to_vertex = _setup_nodes_and_vertices(gmsh,node_to_coords)
grid, cell_to_entity = _setup_grid(gmsh,Dc,Dp,node_to_coords,node_to_vertex)
grid, cell_to_entity = _setup_grid(gmsh,Dc,Dp,node_to_coords,node_to_vertex;has_affine_map)
cell_to_vertices, vertex_to_node, node_to_vertex = _setup_cell_to_vertices(grid,vertex_to_node,node_to_vertex)
grid_topology = UnstructuredGridTopology(grid,cell_to_vertices,vertex_to_node)
labeling = _setup_labeling(gmsh,grid,grid_topology,cell_to_entity,vertex_to_node,node_to_vertex)
Expand Down Expand Up @@ -73,7 +78,7 @@ function _setup_nodes_and_vertices_periodic(gmsh,dimTags,nnodes)
vertex_to_node, node_to_vertex
end

function _setup_grid(gmsh,Dc,Dp,node_to_coords,node_to_vertex)
function _setup_grid(gmsh,Dc,Dp,node_to_coords,node_to_vertex;has_affine_map=nothing)

if ( Dp == 3 && Dc == 2 ) || ( Dp == 2 && Dc == 1 )
orient_if_simplex = false
Expand Down Expand Up @@ -107,10 +112,11 @@ function _setup_grid(gmsh,Dc,Dp,node_to_coords,node_to_vertex)
reffes,
cell_to_type,
orientation,
facet_normal)

(grid, cell_to_entity)
facet_normal;
has_affine_map
)

grid, cell_to_entity
end

function _unit_outward_normal(v::MultiValue{Tuple{1,2}})
Expand Down
10 changes: 10 additions & 0 deletions test/GmshDiscreteModelsTests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,14 @@ test_discrete_model(model)
model2 = Gridap.DiscreteModelFromFile(mshfile)
test_discrete_model(model2)

mshfile = joinpath(@__DIR__,"square.msh")
model = GmshDiscreteModel(mshfile;has_affine_map=true)
test_discrete_model(model)
check_interpolation(model)

mshfile = joinpath(@__DIR__,"cube.msh")
model = GmshDiscreteModel(mshfile;has_affine_map=true)
test_discrete_model(model)
check_interpolation(model)

end # module

2 comments on commit f221e3b

@JordiManyer
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/115802

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.7.2 -m "<description of version>" f221e3b0637f132736baf43da99e9e21170e3c37
git push origin v0.7.2

Please sign in to comment.