Skip to content

Commit

Permalink
Merge branch 'main' into refinement_partitioner
Browse files Browse the repository at this point in the history
  • Loading branch information
garth-wells authored Sep 26, 2024
2 parents 7b68d2d + 38b58bf commit 03970a3
Show file tree
Hide file tree
Showing 17 changed files with 324 additions and 255 deletions.
3 changes: 2 additions & 1 deletion cpp/demo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ macro(add_demo_subdirectory subdir)
endmacro(add_demo_subdirectory)

# Add demos
add_demo_subdirectory(biharmonic)
add_demo_subdirectory(codim_0_assembly)
add_demo_subdirectory(custom_kernel)
add_demo_subdirectory(poisson)
add_demo_subdirectory(poisson_matrix_free)
add_demo_subdirectory(hyperelasticity)
add_demo_subdirectory(interpolation-io)
add_demo_subdirectory(interpolation_different_meshes)
add_demo_subdirectory(biharmonic)
67 changes: 67 additions & 0 deletions cpp/demo/codim_0_assembly/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# This file was generated by running
#
# python cmake/scripts/generate-cmakefiles from dolfinx/cpp
#
cmake_minimum_required(VERSION 3.19)

set(PROJECT_NAME demo_codim_0_assembly)
project(${PROJECT_NAME} LANGUAGES C CXX)

# Set C++20 standard
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

if(NOT TARGET dolfinx)
find_package(DOLFINX REQUIRED)
endif()

include(CheckSymbolExists)
set(CMAKE_REQUIRED_INCLUDES ${PETSC_INCLUDE_DIRS})
check_symbol_exists(PETSC_USE_COMPLEX petscsystypes.h PETSC_SCALAR_COMPLEX)
check_symbol_exists(PETSC_USE_REAL_DOUBLE petscsystypes.h PETSC_REAL_DOUBLE)

# Add target to compile UFL files
if(PETSC_SCALAR_COMPLEX EQUAL 1)
if(PETSC_REAL_DOUBLE EQUAL 1)
set(SCALAR_TYPE "--scalar_type=complex128")
else()
set(SCALAR_TYPE "--scalar_type=complex64")
endif()
else()
if(PETSC_REAL_DOUBLE EQUAL 1)
set(SCALAR_TYPE "--scalar_type=float64")
else()
set(SCALAR_TYPE "--scalar_type=float32")
endif()
endif()
add_custom_command(
OUTPUT mixed_codim0.c
COMMAND ffcx ${CMAKE_CURRENT_SOURCE_DIR}/mixed_codim0.py ${SCALAR_TYPE}
VERBATIM
DEPENDS mixed_codim0.py
COMMENT "Compile mixed_codim0.py using FFCx"
)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

add_executable(${PROJECT_NAME} main.cpp ${CMAKE_CURRENT_BINARY_DIR}/mixed_codim0.c)
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})
6 changes: 3 additions & 3 deletions cpp/demo/codim_0_assembly/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ int main(int argc, char* argv[])
+ mesh->topology()->index_map(tdim)->num_ghosts();
std::vector<std::int32_t> cells(num_cells_local);
std::iota(cells.begin(), cells.end(), 0);
std::vector<std::int32_t> values(cell_map->size_local(), 1);
std::vector<std::int32_t> values(num_cells_local, 1);
std::for_each(marked_cells.begin(), marked_cells.end(),
[&values](auto& c) { values[c] = 2; });
dolfinx::mesh::MeshTags<std::int32_t> cell_marker(mesh->topology(), tdim,
Expand Down Expand Up @@ -123,7 +123,7 @@ int main(int argc, char* argv[])

la::SparsityPattern sp_mixed = fem::create_sparsity_pattern(*a_mixed);
sp_mixed.finalize();
la::MatrixCSR<double> A_mixed(sp_mixed);
la::MatrixCSR<PetscScalar> A_mixed(sp_mixed);
fem::assemble_matrix(A_mixed.mat_add_values(), *a_mixed, {});
A_mixed.scatter_rev();

Expand All @@ -132,7 +132,7 @@ int main(int argc, char* argv[])
la::SparsityPattern sp = fem::create_sparsity_pattern(*a);
sp.finalize();

la::MatrixCSR<double> A(sp);
la::MatrixCSR<PetscScalar> A(sp);
fem::assemble_matrix(A.mat_add_values(), *a, {});
A.scatter_rev();

Expand Down
5 changes: 3 additions & 2 deletions cpp/demo/codim_0_assembly/mixed_codim0.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
TestFunction,
TrialFunction,
dx,
inner,
)

cell = "quadrilateral"
Expand All @@ -27,9 +28,9 @@
# of the parent mesh. The integration domain is the parent mesh, but we restrict integration
# to all cells marked with subdomain_id=3, which will indicate what cells of our mesh is part
# of the submesh
a_mixed = p * v * dx(domain=mesh, subdomain_id=3)
a_mixed = inner(p, v) * dx(domain=mesh, subdomain_id=3)

q = TestFunction(W)
a = p * q * dx(domain=submesh)
a = inner(p, q) * dx(domain=submesh)

forms = [a_mixed, a]
151 changes: 0 additions & 151 deletions cpp/demo/mixed_topology/main.cpp

This file was deleted.

Loading

0 comments on commit 03970a3

Please sign in to comment.