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

Interpolation between different meshes #2245

Merged
merged 64 commits into from
Oct 21, 2022
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
f186f3f
add neighbor version
IgorBaratta Apr 8, 2022
f784f33
minor fix
IgorBaratta Apr 8, 2022
6e1f58b
small simplifications
IgorBaratta Apr 9, 2022
9210c2b
fix type of points
IgorBaratta Apr 9, 2022
79e673f
add timers
IgorBaratta Apr 11, 2022
7415ab7
update demo
IgorBaratta Apr 12, 2022
a1afe9e
rewrite cell collision
IgorBaratta Apr 12, 2022
8367668
some small updates
IgorBaratta Apr 12, 2022
2710f2e
Merge branch 'main' into igor/mesh-interpolation
jorgensd Jun 9, 2022
2dc8ce3
fix function call
IgorBaratta Jun 9, 2022
ff8fab7
fix tests
IgorBaratta Jun 9, 2022
b3aa45e
minor adjustments
IgorBaratta Jun 9, 2022
fddc7a8
Add test of 2D->3D and 3D->2D interpolation + one std::size_t compile…
jorgensd Jun 10, 2022
30ea7ed
Merge branch 'main' of github.com:FEniCS/dolfinx into igor/mesh-inter…
IgorBaratta Jun 13, 2022
d603268
create function
IgorBaratta Jun 13, 2022
3b81fce
fix request
IgorBaratta Jun 13, 2022
5e170f8
fix funciton call
IgorBaratta Jun 13, 2022
e3207bd
remove unused variable
IgorBaratta Jun 13, 2022
aba9131
Merge branch 'main' into mleoni/mesh-interpolation
IgorBaratta Jun 16, 2022
f987381
Update cpp/dolfinx/fem/interpolate.h
massimiliano-leoni Jun 16, 2022
224b359
Apply suggestions from code review
IgorBaratta Jun 16, 2022
a3294f1
Loop optimisation
Jun 16, 2022
f8320ea
Merge branch 'mleoni/mesh-interpolation' of github.com:massimiliano-l…
Jun 16, 2022
d117bba
minor tweaks in demo
IgorBaratta Jun 17, 2022
9c8f93b
Merge branch 'main' into mleoni/mesh-interpolation
IgorBaratta Jun 24, 2022
1e08a0c
Add new function that distributes points
jorgensd Jun 27, 2022
8139090
Separate functions into sub-routines
jorgensd Jun 27, 2022
461c384
std::size_t->std::int32_t
jorgensd Jun 27, 2022
e39c9ea
Remove extra input parameter
jorgensd Jun 28, 2022
92841ed
Improve docs
jorgensd Jun 28, 2022
ed3c15c
Merge branch 'main' into mleoni/mesh-interpolation
Jul 1, 2022
b047f36
Merge pull request #1 from FEniCS/dokken/mesh-interpolation
massimiliano-leoni Jul 13, 2022
3cc2c5e
Merge branch 'main' into mleoni/mesh-interpolation
massimiliano-leoni Jul 14, 2022
9440f67
Merge branch 'main' into dokken/mi-mdspan
jorgensd Jul 22, 2022
a8865c9
Regenerate demos and various span fixes
jorgensd Jul 22, 2022
33914d2
Remove comment
jorgensd Jul 22, 2022
3a7c598
Remove const span reference and fix in,out
jorgensd Jul 22, 2022
e7ae908
Debug
jorgensd Jul 23, 2022
6e04fef
Works in serial, crashes in parallel
jorgensd Jul 23, 2022
fdfe259
Refactoring code. Remove xtensor. Various documation fixes.
jorgensd Jul 24, 2022
6c723a8
Doc update
jorgensd Jul 24, 2022
51387c7
Merge branch 'main' into dokken/mi-mdspan
jorgensd Jul 24, 2022
4083fa1
Merge pull request #2 from FEniCS/dokken/mi-mdspan
massimiliano-leoni Jul 26, 2022
25acc95
Merge branch 'main' into mleoni/mesh-interpolation
jorgensd Jul 26, 2022
5d15604
Merge branch 'main' into mleoni/mesh-interpolation
massimiliano-leoni Aug 1, 2022
f86e50d
Applying suggestions by Garth
massimiliano-leoni Aug 5, 2022
3cb62b1
Merge branch 'main' into mleoni/mesh-interpolation
massimiliano-leoni Aug 22, 2022
e649d91
Merge branch 'main' into mleoni/mesh-interpolation
chrisrichardson Sep 6, 2022
daf2803
Merge branch 'main' into mleoni/mesh-interpolation
chrisrichardson Sep 8, 2022
a2c9796
Remove copy_N
chrisrichardson Sep 8, 2022
c124352
Merge branch 'main' into mleoni/mesh-interpolation
garth-wells Sep 9, 2022
ec4377d
Merge branch 'main' into mleoni/mesh-interpolation
massimiliano-leoni Sep 12, 2022
41e3848
Tentatively updating python wrapper
massimiliano-leoni Sep 12, 2022
d712ec7
Merge branch 'main' into mleoni/mesh-interpolation
massimiliano-leoni Sep 14, 2022
3fc5115
Merge branch 'main' into mleoni/mesh-interpolation
massimiliano-leoni Sep 19, 2022
ace1246
Merge branch 'main' into mleoni/mesh-interpolation
massimiliano-leoni Sep 29, 2022
b50b1e3
Merge branch 'main' into mleoni/mesh-interpolation
massimiliano-leoni Oct 8, 2022
e243755
Merge branch 'main' into mleoni/mesh-interpolation
massimiliano-leoni Oct 11, 2022
809b353
Merge branch 'main' into mleoni/mesh-interpolation
massimiliano-leoni Oct 11, 2022
257e9dd
Merge branch 'main' into mleoni/mesh-interpolation
massimiliano-leoni Oct 11, 2022
a234386
Merge branch 'main' into mleoni/mesh-interpolation
massimiliano-leoni Oct 11, 2022
862767b
Merge branch 'main' into mleoni/mesh-interpolation
massimiliano-leoni Oct 17, 2022
06d8e55
Merge branch 'FEniCS:main' into mleoni/mesh-interpolation
massimiliano-leoni Oct 18, 2022
9de3459
Merge branch 'main' into mleoni/mesh-interpolation
mscroggs Oct 19, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cpp/demo/hyperelasticity/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ else()
VERBATIM DEPENDS hyperelasticity.py COMMENT "Compile hyperelasticity.py using FFCx")

set(CMAKE_INCLUDE_CURRENT_DIR ON)

add_executable(${PROJECT_NAME} main.cpp ${CMAKE_CURRENT_BINARY_DIR}/hyperelasticity.c)
target_link_libraries(${PROJECT_NAME} dolfinx)

Expand Down
2 changes: 2 additions & 0 deletions cpp/demo/interpolation-io/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ if (NOT TARGET dolfinx)
find_package(DOLFINX REQUIRED)
endif()

set(CMAKE_INCLUDE_CURRENT_DIR ON)
Copy link
Member

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.


add_executable(${PROJECT_NAME} main.cpp)
target_link_libraries(${PROJECT_NAME} dolfinx)

Expand Down
35 changes: 35 additions & 0 deletions cpp/demo/interpolation/CMakeLists.txt
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})
80 changes: 80 additions & 0 deletions cpp/demo/interpolation/main.cpp
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;
}
2 changes: 2 additions & 0 deletions cpp/demo/poisson_matrix_free/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ add_custom_command(
COMMAND ffcx ${CMAKE_CURRENT_SOURCE_DIR}/poisson.py ${SCALAR_TYPE}
VERBATIM DEPENDS poisson.py COMMENT "Compile poisson.py using FFCx")

set(CMAKE_INCLUDE_CURRENT_DIR ON)

add_executable(${PROJECT_NAME} main.cpp ${CMAKE_CURRENT_BINARY_DIR}/poisson.c)
target_link_libraries(${PROJECT_NAME} dolfinx)

Expand Down
Loading