-
-
Notifications
You must be signed in to change notification settings - Fork 215
Mixed topology #2597
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
Merged
Merged
Mixed topology #2597
Changes from all commits
Commits
Show all changes
93 commits
Select commit
Hold shift + click to select a range
389b2f5
compile
chrisrichardson efc5613
Merge branch 'main' into chris/mixed-geom
chrisrichardson c84d253
Catch a few cases
chrisrichardson ffb6f03
Fix typo
chrisrichardson 28ce267
Change create_topology input [skip ci]
chrisrichardson 7bac6a4
update create topology
IgorBaratta 51349bc
add some checks
IgorBaratta 3157382
afix documentation
IgorBaratta 5dd1b1e
remove checl
IgorBaratta 2fb15c4
fix type conversion
IgorBaratta ddb7e51
fix "const"
IgorBaratta 3c7fb71
Store multiple cell types
chrisrichardson 7aa8061
Merge branch 'mixed-topology-hackathon-23' of ssh://github.com/fenics…
chrisrichardson 2ce930b
Start demo
jpdean 50240e8
Merge branch 'mixed-topology-hackathon-23' of github.com:FEniCS/dolfi…
jpdean e0c4d71
remove petsc from demo
IgorBaratta d5235ee
fix test
IgorBaratta 7b237c2
Fix test
chrisrichardson f3581e9
fix
chrisrichardson 6f88835
Fix demo
chrisrichardson dc673db
Sort and unique boundary vertices
chrisrichardson 86f58ef
Print out something
chrisrichardson e197dd6
Generalise test
jpdean 38add11
throw an error if multiple cell types are used where. ...
IgorBaratta ed5c949
Merge branch 'mixed-topology-hackathon-23' of github.com:FEniCS/dolfi…
IgorBaratta df024a7
Merge branch 'mixed-topology-hackathon-23' of github.com:FEniCS/dolfi…
jpdean 46bcf23
Print
jpdean 6bc54ef
Merge branch 'mixed-topology-hackathon-23' of github.com:FEniCS/dolfi…
jpdean 5e6633a
Fix offsets
jpdean f652eef
Fix python layer
chrisrichardson ab50554
Fix in python wrapper
chrisrichardson 3cd927e
fix cpp build
IgorBaratta d9be3dd
Merge branch 'chris/mixed-geom' of github.com:FEniCS/dolfinx into chr…
IgorBaratta 8946e62
Python layer
chrisrichardson 5c176f6
Add method to set entity group offsets
jpdean dbf4f41
Fix test
chrisrichardson 9468be1
Fix docs
chrisrichardson 771adb0
Add method to get entity group offsets
jpdean b8c1ef2
Set offsets
jpdean 1b46cca
Fix some tests
chrisrichardson 81614c9
Add docs
jpdean faa63ed
Merge branch 'mixed-topology-hackathon-23' of github.com:FEniCS/dolfi…
jpdean ef274f9
merge
chrisrichardson 34b278d
Fixups
chrisrichardson 1e2bb3a
Fix test
chrisrichardson 0ef8d30
Pass list of ElementDofLayouts to build_basic_dofmap
chrisrichardson 0564c17
Add some mixed topology checks and limitations
chrisrichardson 8ad0232
Add more multiple ElementDofLayouts for building dofmap
chrisrichardson e8f90da
Int type
chrisrichardson bbe7c10
Create dof array with mixture of elements
chrisrichardson 18e78d8
Rename cell_type as cell_types
chrisrichardson e6429d7
resize array
chrisrichardson 052caa2
int type
chrisrichardson 75d5f1c
typo fix
chrisrichardson 80261bd
More adjustments for multiple ElementDofLayouts
chrisrichardson 97019d6
Minor fix
chrisrichardson 24ecffa
Fix size_t again
chrisrichardson 078f2fa
Fixes for ADIOS2
chrisrichardson 192c771
Wrapper fixes
chrisrichardson 3af10ee
Fix allocation
chrisrichardson 74a76bb
Fix demos
chrisrichardson 7dd91f8
Another place for cell_types()
chrisrichardson 00413ba
Fix for submesh
chrisrichardson c6ae0ca
More renaming type->types
chrisrichardson 5091dc7
Fix for zero size mesh
chrisrichardson 0a77472
Merge branch 'main' into mixed-topology-hackathon-23
chrisrichardson 98b4f31
Create CoordinateElements
chrisrichardson 262e8f8
merge fix
chrisrichardson 48519d3
typo
chrisrichardson 99aa197
merge
chrisrichardson f75e025
Fixes for submesh
chrisrichardson 1a56366
Set groups for submesh
chrisrichardson 32b6fc6
Fix AdjacencyList creation after reordering geometry nodes
chrisrichardson d3e1e9c
Put in an actual Mesh
chrisrichardson 5317b5a
Update basix interface to create_element
chrisrichardson 05867f6
typo
chrisrichardson a684a1b
fix up for demo
chrisrichardson 90cd1aa
ordering
chrisrichardson 6539efd
merge
chrisrichardson 2552910
Fix cmap->cmaps
chrisrichardson 92d241f
cmaps
chrisrichardson 94e7da4
Merge branch 'chris/basix-interface-change' into mixed-topology-hacka…
chrisrichardson fb09ef0
More fixes
chrisrichardson 86ecac0
Merge branch 'main' into mixed-topology-hackathon-23
chrisrichardson b970947
Add a little more documentation
chrisrichardson 687fb8b
merge
chrisrichardson 02cbe61
fixes
chrisrichardson 3b88b41
Suggested changes
chrisrichardson e7c916e
Difficult merge
chrisrichardson 60c3b7b
Fixes
chrisrichardson 255518a
Fix for functionspace
chrisrichardson 18a91e4
another
chrisrichardson d926874
Undo unintended changes to demo
chrisrichardson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
cmake_minimum_required(VERSION 3.16) | ||
project(mixed_topology_testing) | ||
|
||
# Find DOLFINx config file | ||
find_package(DOLFINX REQUIRED) | ||
|
||
# Set C++20 standard | ||
set(CMAKE_CXX_STANDARD 20) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
set(CMAKE_CXX_EXTENSIONS OFF) | ||
|
||
include(CheckSymbolExists) | ||
set(CMAKE_REQUIRED_INCLUDES ${PETSC_INCLUDE_DIRS}) | ||
check_symbol_exists(PETSC_USE_COMPLEX petscsystypes.h PETSC_SCALAR_COMPLEX) | ||
|
||
# Add target to compile UFL files | ||
if(PETSC_SCALAR_COMPLEX EQUAL 1) | ||
set(SCALAR_TYPE "--scalar_type=double _Complex") | ||
endif() | ||
|
||
set(CMAKE_INCLUDE_CURRENT_DIR ON) | ||
|
||
add_executable(${PROJECT_NAME} main.cpp) | ||
target_link_libraries(${PROJECT_NAME} dolfinx) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
#include <dolfinx/common/IndexMap.h> | ||
#include <dolfinx/common/MPI.h> | ||
#include <dolfinx/graph/AdjacencyList.h> | ||
#include <dolfinx/mesh/Geometry.h> | ||
#include <dolfinx/mesh/Mesh.h> | ||
#include <dolfinx/mesh/Topology.h> | ||
#include <dolfinx/mesh/cell_types.h> | ||
#include <iostream> | ||
#include <vector> | ||
|
||
// Note: this demo is not currently intended to provide a fully functional | ||
// example of using a mixed-topology mesh, but shows only the | ||
// basic constrution. Experimental. | ||
|
||
int main(int argc, char* argv[]) | ||
{ | ||
dolfinx::init_logging(argc, argv); | ||
MPI_Init(&argc, &argv); | ||
|
||
const int nx_s = 2; | ||
chrisrichardson marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const int nx_t = 2; | ||
const int ny = 4; | ||
|
||
const int num_s = nx_s * ny; | ||
const int num_t = 2 * nx_t * ny; | ||
|
||
std::vector<double> x; | ||
for (int i = 0; i < nx_s + nx_t + 1; ++i) | ||
{ | ||
for (int j = 0; j < ny + 1; ++j) | ||
chrisrichardson marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
x.push_back(i); | ||
x.push_back(j); | ||
x.push_back(0); | ||
} | ||
} | ||
|
||
std::vector<std::int64_t> cells; | ||
std::vector<std::int32_t> offsets{0}; | ||
for (int i = 0; i < nx_s + nx_t; ++i) | ||
{ | ||
for (int j = 0; j < ny; ++j) | ||
{ | ||
const int v_0 = j + i * (ny + 1); | ||
const int v_1 = v_0 + 1; | ||
const int v_2 = v_0 + ny + 1; | ||
const int v_3 = v_0 + ny + 2; | ||
|
||
if (i < nx_s) | ||
{ | ||
cells.push_back(v_0); | ||
cells.push_back(v_1); | ||
cells.push_back(v_3); | ||
cells.push_back(v_2); | ||
|
||
offsets.push_back(cells.size()); | ||
} | ||
else | ||
{ | ||
cells.push_back(v_0); | ||
cells.push_back(v_1); | ||
cells.push_back(v_2); | ||
|
||
offsets.push_back(cells.size()); | ||
|
||
cells.push_back(v_1); | ||
cells.push_back(v_2); | ||
cells.push_back(v_3); | ||
|
||
offsets.push_back(cells.size()); | ||
} | ||
} | ||
} | ||
|
||
dolfinx::graph::AdjacencyList<std::int64_t> cells_list(cells, offsets); | ||
|
||
std::vector<std::int64_t> original_global_index(num_s + num_t); | ||
std::iota(original_global_index.begin(), original_global_index.end(), 0); | ||
|
||
std::vector<int> ghost_owners; | ||
|
||
std::vector<std::int32_t> cell_group_offsets{0, num_s, num_s + num_t, | ||
num_s + num_t, num_s + num_t}; | ||
|
||
std::vector<std::int64_t> boundary_vertices; | ||
for (int j = 0; j < ny + 1; ++j) | ||
{ | ||
boundary_vertices.push_back(j); | ||
boundary_vertices.push_back(j + (nx_s + nx_t + 1) * ny); | ||
} | ||
for (int i = 0; i < nx_s + nx_t + 1; ++i) | ||
{ | ||
boundary_vertices.push_back((ny + 1) * i); | ||
boundary_vertices.push_back(ny + (ny + 1) * i); | ||
} | ||
|
||
std::sort(boundary_vertices.begin(), boundary_vertices.end()); | ||
boundary_vertices.erase( | ||
std::unique(boundary_vertices.begin(), boundary_vertices.end()), | ||
boundary_vertices.end()); | ||
|
||
std::vector<dolfinx::mesh::CellType> cell_types{ | ||
dolfinx::mesh::CellType::quadrilateral, | ||
dolfinx::mesh::CellType::triangle}; | ||
std::vector<dolfinx::fem::CoordinateElement> elements; | ||
for (auto ct : cell_types) | ||
elements.push_back(dolfinx::fem::CoordinateElement(ct, 1)); | ||
|
||
{ | ||
auto topo = dolfinx::mesh::create_topology( | ||
MPI_COMM_WORLD, cells_list, original_global_index, ghost_owners, | ||
cell_types, cell_group_offsets, boundary_vertices); | ||
|
||
auto topo_cells = topo.connectivity(2, 0); | ||
|
||
for (int i = 0; i < topo_cells->num_nodes(); ++i) | ||
{ | ||
std::cout << i << " ["; | ||
for (auto q : topo_cells->links(i)) | ||
std::cout << q << " "; | ||
std::cout << "]\n"; | ||
} | ||
|
||
topo.create_connectivity(1, 0); | ||
|
||
auto topo_facets = topo.connectivity(1, 0); | ||
for (int i = 0; i < topo_facets->num_nodes(); ++i) | ||
{ | ||
std::cout << i << " ["; | ||
for (auto q : topo_facets->links(i)) | ||
std::cout << q << " "; | ||
std::cout << "]\n"; | ||
} | ||
|
||
auto geom = dolfinx::mesh::create_geometry(MPI_COMM_WORLD, topo, elements, | ||
cells_list, x, 2); | ||
|
||
dolfinx::mesh::Mesh mesh(MPI_COMM_WORLD, topo, geom); | ||
std::cout << "num cells = " << mesh.topology().index_map(2)->size_local() | ||
<< "\n"; | ||
for (auto q : mesh.topology().entity_group_offsets(2)) | ||
std::cout << q << " "; | ||
std::cout << "\n"; | ||
} | ||
|
||
MPI_Finalize(); | ||
|
||
return 0; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.