-
-
Notifications
You must be signed in to change notification settings - Fork 178
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
Interpolation between different meshes #2245
Merged
jhale
merged 64 commits into
FEniCS:main
from
massimiliano-leoni:mleoni/mesh-interpolation
Oct 21, 2022
Merged
Changes from 20 commits
Commits
Show all changes
64 commits
Select commit
Hold shift + click to select a range
f186f3f
add neighbor version
IgorBaratta f784f33
minor fix
IgorBaratta 6e1f58b
small simplifications
IgorBaratta 9210c2b
fix type of points
IgorBaratta 79e673f
add timers
IgorBaratta 7415ab7
update demo
IgorBaratta a1afe9e
rewrite cell collision
IgorBaratta 8367668
some small updates
IgorBaratta 2710f2e
Merge branch 'main' into igor/mesh-interpolation
jorgensd 2dc8ce3
fix function call
IgorBaratta ff8fab7
fix tests
IgorBaratta b3aa45e
minor adjustments
IgorBaratta fddc7a8
Add test of 2D->3D and 3D->2D interpolation + one std::size_t compile…
jorgensd 30ea7ed
Merge branch 'main' of github.com:FEniCS/dolfinx into igor/mesh-inter…
IgorBaratta d603268
create function
IgorBaratta 3b81fce
fix request
IgorBaratta 5e170f8
fix funciton call
IgorBaratta e3207bd
remove unused variable
IgorBaratta aba9131
Merge branch 'main' into mleoni/mesh-interpolation
IgorBaratta f987381
Update cpp/dolfinx/fem/interpolate.h
massimiliano-leoni 224b359
Apply suggestions from code review
IgorBaratta a3294f1
Loop optimisation
f8320ea
Merge branch 'mleoni/mesh-interpolation' of github.com:massimiliano-l…
d117bba
minor tweaks in demo
IgorBaratta 9c8f93b
Merge branch 'main' into mleoni/mesh-interpolation
IgorBaratta 1e08a0c
Add new function that distributes points
jorgensd 8139090
Separate functions into sub-routines
jorgensd 461c384
std::size_t->std::int32_t
jorgensd e39c9ea
Remove extra input parameter
jorgensd 92841ed
Improve docs
jorgensd ed3c15c
Merge branch 'main' into mleoni/mesh-interpolation
b047f36
Merge pull request #1 from FEniCS/dokken/mesh-interpolation
massimiliano-leoni 3cc2c5e
Merge branch 'main' into mleoni/mesh-interpolation
massimiliano-leoni 9440f67
Merge branch 'main' into dokken/mi-mdspan
jorgensd a8865c9
Regenerate demos and various span fixes
jorgensd 33914d2
Remove comment
jorgensd 3a7c598
Remove const span reference and fix in,out
jorgensd e7ae908
Debug
jorgensd 6e04fef
Works in serial, crashes in parallel
jorgensd fdfe259
Refactoring code. Remove xtensor. Various documation fixes.
jorgensd 6c723a8
Doc update
jorgensd 51387c7
Merge branch 'main' into dokken/mi-mdspan
jorgensd 4083fa1
Merge pull request #2 from FEniCS/dokken/mi-mdspan
massimiliano-leoni 25acc95
Merge branch 'main' into mleoni/mesh-interpolation
jorgensd 5d15604
Merge branch 'main' into mleoni/mesh-interpolation
massimiliano-leoni f86e50d
Applying suggestions by Garth
massimiliano-leoni 3cb62b1
Merge branch 'main' into mleoni/mesh-interpolation
massimiliano-leoni e649d91
Merge branch 'main' into mleoni/mesh-interpolation
chrisrichardson daf2803
Merge branch 'main' into mleoni/mesh-interpolation
chrisrichardson a2c9796
Remove copy_N
chrisrichardson c124352
Merge branch 'main' into mleoni/mesh-interpolation
garth-wells ec4377d
Merge branch 'main' into mleoni/mesh-interpolation
massimiliano-leoni 41e3848
Tentatively updating python wrapper
massimiliano-leoni d712ec7
Merge branch 'main' into mleoni/mesh-interpolation
massimiliano-leoni 3fc5115
Merge branch 'main' into mleoni/mesh-interpolation
massimiliano-leoni ace1246
Merge branch 'main' into mleoni/mesh-interpolation
massimiliano-leoni b50b1e3
Merge branch 'main' into mleoni/mesh-interpolation
massimiliano-leoni e243755
Merge branch 'main' into mleoni/mesh-interpolation
massimiliano-leoni 809b353
Merge branch 'main' into mleoni/mesh-interpolation
massimiliano-leoni 257e9dd
Merge branch 'main' into mleoni/mesh-interpolation
massimiliano-leoni a234386
Merge branch 'main' into mleoni/mesh-interpolation
massimiliano-leoni 862767b
Merge branch 'main' into mleoni/mesh-interpolation
massimiliano-leoni 06d8e55
Merge branch 'FEniCS:main' into mleoni/mesh-interpolation
massimiliano-leoni 9de3459
Merge branch 'main' into mleoni/mesh-interpolation
mscroggs 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 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 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 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,35 @@ | ||
# This file was generated by running | ||
# | ||
# python cmake/scripts/generate-cmakefiles from dolfinx/cpp | ||
# | ||
cmake_minimum_required(VERSION 3.16) | ||
|
||
set(PROJECT_NAME demo_interpolation) | ||
project(${PROJECT_NAME} LANGUAGES C CXX) | ||
|
||
# Set C++17 standard | ||
set(CMAKE_CXX_STANDARD 17) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
set(CMAKE_CXX_EXTENSIONS OFF) | ||
|
||
if (NOT TARGET dolfinx) | ||
find_package(DOLFINX REQUIRED) | ||
endif() | ||
|
||
set(CMAKE_INCLUDE_CURRENT_DIR ON) | ||
|
||
add_executable(${PROJECT_NAME} main.cpp) | ||
target_link_libraries(${PROJECT_NAME} dolfinx) | ||
|
||
# Do not throw error for 'multi-line comments' (these are typical in | ||
# rst which includes LaTeX) | ||
include(CheckCXXCompilerFlag) | ||
CHECK_CXX_COMPILER_FLAG("-Wno-comment" HAVE_NO_MULTLINE) | ||
set_source_files_properties(main.cpp PROPERTIES COMPILE_FLAGS "$<$<BOOL:${HAVE_NO_MULTLINE}>:-Wno-comment -Wall -Wextra -pedantic -Werror>") | ||
|
||
# Test targets (used by DOLFINx testing system) | ||
set(TEST_PARAMETERS2 -np 2 ${MPIEXEC_PARAMS} "./${PROJECT_NAME}") | ||
set(TEST_PARAMETERS3 -np 3 ${MPIEXEC_PARAMS} "./${PROJECT_NAME}") | ||
add_test(NAME ${PROJECT_NAME}_mpi_2 COMMAND "mpirun" ${TEST_PARAMETERS2}) | ||
add_test(NAME ${PROJECT_NAME}_mpi_3 COMMAND "mpirun" ${TEST_PARAMETERS3}) | ||
add_test(NAME ${PROJECT_NAME}_serial COMMAND ${PROJECT_NAME}) |
This file contains 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,80 @@ | ||
#include <basix/e-lagrange.h> | ||
#include <cmath> | ||
#include <dolfinx/common/timing.h> | ||
#include <dolfinx/fem/utils.h> | ||
#include <dolfinx/io/ADIOS2Writers.h> | ||
#include <dolfinx/mesh/generation.h> | ||
#include <memory> | ||
|
||
using namespace dolfinx; | ||
|
||
using T = double; | ||
|
||
void interpolation_different_meshes() | ||
{ | ||
const std::array<std::size_t, 3> subdivisions = {50, 50, 50}; | ||
massimiliano-leoni marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
auto meshL = std::make_shared<mesh::Mesh>(mesh::create_box( | ||
massimiliano-leoni marked this conversation as resolved.
Show resolved
Hide resolved
|
||
MPI_COMM_WORLD, {{{0, 0, 0}, {1, 1, 1}}}, subdivisions, | ||
mesh::CellType::tetrahedron, mesh::GhostMode::shared_facet)); | ||
|
||
auto meshR = std::make_shared<mesh::Mesh>(mesh::create_box( | ||
MPI_COMM_WORLD, {{{0, 0, 0}, {1, 1, 1}}}, {47, 49, 33}, | ||
mesh::CellType::hexahedron, mesh::GhostMode::shared_facet)); | ||
|
||
basix::FiniteElement eL = basix::element::create_lagrange( | ||
mesh::cell_type_to_basix_type(meshL->topology().cell_type()), 1, | ||
basix::element::lagrange_variant::equispaced, false); | ||
auto VL = std::make_shared<fem::FunctionSpace>( | ||
fem::create_functionspace(meshL, eL, 3)); | ||
|
||
basix::FiniteElement eR = basix::element::create_lagrange( | ||
mesh::cell_type_to_basix_type(meshR->topology().cell_type()), 2, | ||
basix::element::lagrange_variant::equispaced, false); | ||
auto VR = std::make_shared<fem::FunctionSpace>( | ||
fem::create_functionspace(meshR, eR, 3)); | ||
|
||
auto uL = std::make_shared<fem::Function<T>>(VL); | ||
auto uR = std::make_shared<fem::Function<T>>(VR); | ||
|
||
auto fun = [](auto& x) | ||
{ | ||
auto r = xt::zeros_like(x); | ||
for (std::size_t i = 0; i < x.shape(1); ++i) | ||
{ | ||
r(0, i) = std::cos(10 * x(0, i)) * std::sin(10 * x(2, i)); | ||
r(1, i) = std::sin(10 * x(0, i)) * std::sin(10 * x(2, i)); | ||
r(2, i) = std::cos(10 * x(0, i)) * std::cos(10 * x(2, i)); | ||
} | ||
return r; | ||
}; | ||
|
||
uL->interpolate(fun); | ||
|
||
uR->interpolate(*uL); | ||
|
||
io::VTXWriter writeruL(meshL->comm(), "uL.bp", {uL}); | ||
writeruL.write(0.0); | ||
|
||
io::VTXWriter writeruR(meshR->comm(), "uR.bp", {uR}); | ||
writeruR.write(0.0); | ||
} | ||
|
||
int main(int argc, char* argv[]) | ||
{ | ||
dolfinx::init_logging(argc, argv); | ||
MPI_Init(&argc, &argv); | ||
|
||
int mpi_rank; | ||
MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); | ||
|
||
interpolation_different_meshes(); | ||
dolfinx::list_timings(MPI_COMM_WORLD, {dolfinx::TimingType::wall}, | ||
dolfinx::Table::Reduction::max); | ||
|
||
dolfinx::list_timings(MPI_COMM_WORLD, {dolfinx::TimingType::wall}, | ||
dolfinx::Table::Reduction::min); | ||
MPI_Finalize(); | ||
|
||
return 0; | ||
} |
This file contains 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why has this been added?
I don't see that the script that generates the CMake files has been updated.