Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
643d86e
refactor: code for homogeneous discretization of the heat equation
francescamorciano Mar 8, 2026
f2fe5c6
refactor: created files for space and time adaptivity solver
francescamorciano Mar 8, 2026
76a7af7
fix: updated CmakeLists.txt and fixed some compilation errors
agent-png Mar 9, 2026
4ebffdb
test: homogeneous solver behaviour with some test parameters
agent-png Mar 10, 2026
26b26d4
fix: changed .gitignore to ignore build directory
agent-png Mar 11, 2026
ba3063b
feat: wrote an initial draft for the hpp file
agent-png Mar 12, 2026
2c27731
feat: sample of main with some parameters for simple tests
agent-png Mar 12, 2026
337718a
fix: Added AffineConstraints<double> constraints, changed mesh to par…
agent-png Mar 12, 2026
8670ba6
feat: implemented AdaptiveHeat::setup(), allows mesh refinement and i…
agent-png Mar 12, 2026
f855bee
feat: implemented AdaptiveHeat::assemble(), AdaptiveHeat::solve_time_…
francescamorciano Mar 13, 2026
5c45a60
fix: fixed some include errors
agent-png Mar 17, 2026
e004331
fix: mesh_serial initialization moved to correct position (there were…
agent-png Mar 17, 2026
43ceb62
feat: implemented AdaptiveHeat::run() and AdaptiveHeat::output() methods
Mar 18, 2026
2411aad
feat: mesh generator; fix: adapted and fixed code to use parallel::di…
francescamorciano Mar 27, 2026
69a1695
fix: check if time has reached the end (time == T) before applying re…
agent-png Apr 15, 2026
266741f
style: added some logs
agent-png Apr 15, 2026
f1ab598
fix: local solution reinitialized correctly, constraints applied afte…
agent-png Apr 15, 2026
6dd889e
fix: lines that got out of previous commit about refine_grid()
agent-png Apr 15, 2026
e3d67d5
fix: fixed refine_grid(), max and min grid level introduced to avoid …
agent-png Apr 15, 2026
b8e7def
fix: update ghost cells for Kelly Estimator and implemented diagnosti…
Apr 21, 2026
a9f774f
fix: implemented Time-Adaptivity controller with Rollback logic in Ad…
May 1, 2026
dc7ef30
fix: implemented Timestep Boundaries to enhance stability of the algo…
May 1, 2026
c176154
feat: grid refinement based on spatial error, made refinement fractio…
francescamorciano May 8, 2026
1756e84
fix: some code fixes and spatial tolerance adjustments
francescamorciano May 8, 2026
4c0c5ef
feat: some optimizations
francescamorciano Jun 23, 2026
7722c63
fix: fixed MPI support, deadlock in refinement
agent-png Jun 25, 2026
7b141c3
feat: added some, very primitive, code to check accuracy
agent-png Jun 26, 2026
e81c9c5
Extended baseline comparison, added timers
agent-png Jul 3, 2026
d78b76b
Added code for timing functions and assess scalability
agent-png Jul 4, 2026
17ea7ff
Small fix to timing class, plus comparison results as .txt
agent-png Jul 9, 2026
ea07c0d
repo cleaning and readme file
francescamorciano Jul 9, 2026
37be280
eliminated prints
francescamorciano Jul 12, 2026
47bfacc
report
francescamorciano Jul 13, 2026
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
73 changes: 37 additions & 36 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,36 +1,37 @@
## C++ #########################################################################

# Prerequisites
*.d

# Compiled Object files
*.slo
*.lo
*.o
*.obj

# Precompiled Headers
*.gch
*.pch

# Compiled Dynamic libraries
*.so
*.dylib
*.dll

# Fortran module files
*.mod
*.smod

# Compiled Static libraries
*.lai
*.la
*.a
*.lib

# Executables
*.exe
*.out
*.app

*/build/*
## C++ #########################################################################

# Prerequisites
*.d

# Compiled Object files
*.slo
*.lo
*.o
*.obj

# Precompiled Headers
*.gch
*.pch

# Compiled Dynamic libraries
*.so
*.dylib
*.dll

# Fortran module files
*.mod
*.smod

# Compiled Static libraries
*.lai
*.la
*.a
*.lib

# Executables
*.exe
*.out
*.app

build/
.vscode
17 changes: 10 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
cmake_minimum_required(VERSION 3.12.0)
project(project_title LANGUAGES CXX C)

include(../common/cmake-common.cmake)

add_executable(lab-01 src/lab-01.cpp src/Poisson1D.cpp)
deal_ii_setup_target(lab-01)
cmake_minimum_required(VERSION 3.12.0)
project(project_title LANGUAGES CXX C)

include(common/cmake-common.cmake)

add_executable(H_Heat src/homogeneous/main.cpp src/homogeneous/H_Heat.cpp src/timing/Timing.cpp)
deal_ii_setup_target(H_Heat)

add_executable(STA_Heat src/adaptive/main.cpp src/adaptive/STA_Heat.cpp src/homogeneous/H_Heat.cpp src/timing/Timing.cpp)
deal_ii_setup_target(STA_Heat)
101 changes: 78 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,78 @@
### Organizing the source code
Please place all your sources into the `src` folder.

Binary files must not be uploaded to the repository (including executables).

Mesh files should not be uploaded to the repository. If applicable, upload `gmsh` scripts with suitable instructions to generate the meshes (and ideally a Makefile that runs those instructions). If not applicable, consider uploading the meshes to a different file sharing service, and providing a download link as part of the building and running instructions.

### Compiling
To build the executable, make sure you have loaded the needed modules with
```bash
$ module load gcc-glibc dealii
```
Then run the following commands:
```bash
$ mkdir build
$ cd build
$ cmake ..
$ make
```
The executable will be created into `build`, and can be executed through
```bash
$ ./executable-name
```
# Space-Time Adaptivity

## Project Information

- **Course:** Numerical Methods for Partial Differential Equations
- **Authors:** Giacomo Maglio, Francesca Morciano, Giuseppe Hares
- **Advisor:** Alfio Maria Quarteroni
- **Co-Advisor:** Michele Bucelli
- **Academic year:** 2025/2026
- **Institution:** Politecnico di Milano

This project contains two deal.II-based solvers for the heat equation:

- `H_Heat`: homogeneous reference solver
- `STA_Heat`: adaptive space-time solver

The code is organized under `src/` and builds with CMake.

## Repository layout

- `src/homogeneous/`: reference solver implementation
- `src/adaptive/`: adaptive solver implementation
- `src/timing/`: profiling utilities

## Requirements

You need a working C++ toolchain and deal.II with MPI support.

Environment setup:

```bash
$ apptainer shell *.sif
$ source /u/sw/etc/bash.bashrc
$ module load gcc-glibc dealii
```

## Build

From the repository root:

```bash
$ mkdir build
$ cd build
$ cmake ..
$ make
```

This creates the executables inside `build/`.

## Run

Available executables:

- `build/H_Heat`
- `build/STA_Heat`

Run them from the build directory, for example:

```bash
$ cd build
$ mpirun -n <number of threads> ./H_Heat # to run the homogenous solver
$ mpirun -n <number of threads> ./STA_Heat # to run the adaptive solver
```

Both executables currently use hardcoded parameters in their respective `main.cpp` files.
To change time step, final time, or forcing term, edit:

- `src/homogeneous/main.cpp`
- `src/adaptive/main.cpp`

## Output

The solvers write output files in the build directory.

## Notes

- The adaptive executable contains an optional baseline-comparison path behind the `COMPARE_WITH_BASE` macro.
- If you want to compare adaptive and homogeneous results, enable that macro in `src/adaptive/main.cpp` and ensure the baseline mesh is available.
34 changes: 34 additions & 0 deletions common/cmake-common.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED "ON")
set(CMAKE_CXX_FLAGS "-O3 -march=native -ffast-math")

# Set default build type to Release.
if(NOT CMAKE_BUILD_TYPE OR "${CMAKE_BUILD_TYPE}" STREQUAL "")
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE)
endif()
message(STATUS)
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
message(STATUS)
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
add_definitions(-DBUILD_TYPE_DEBUG)
endif()

# Locate MPI compiler.
find_package(MPI REQUIRED)
set(CMAKE_CXX_COMPILER "${MPI_CXX_COMPILER}")

# Locate Boost.
find_package(Boost 1.72.0 REQUIRED
COMPONENTS filesystem iostreams serialization
HINTS ${BOOST_DIR} $ENV{BOOST_DIR} $ENV{mkBoostPrefix})
message(STATUS "Using the Boost-${Boost_VERSION} configuration found at ${Boost_DIR}")
message(STATUS)
include_directories(${Boost_INCLUDE_DIRS})

# Locate deal.II and initialize its variables.
find_package(deal.II 9.3.1 REQUIRED
HINTS ${DEAL_II_DIR} $ENV{DEAL_II_DIR} $ENV{mkDealiiPrefix})
deal_ii_initialize_cached_variables()

# Add useful compiler flags.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wfloat-conversion -Wmissing-braces -Wnon-virtual-dtor")
110 changes: 110 additions & 0 deletions experiments_results/baseline_comparison.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
=======================================================================
Space and Time Adaptivity
=======================================================================

Baseline Results
Number of steps: 40
Elapsed Time:
---------------------------------------------------------------
Timer Calls Min(s) Avg(s) Max(s) Total(s)
---------------------------------------------------------------
update-ghost 40 1.17e-04 1.92e-04 4.22e-04 7.69e-03
solve 40 6.74e-02 8.87e-02 1.37e-01 3.55e+00
output 40 7.12e-02 8.70e-02 1.39e-01 3.48e+00
assemble 40 1.82e-01 2.13e-01 2.61e-01 8.50e+00
setup 1 3.13e-01 3.13e-01 3.13e-01 3.13e-01
---------------------------------------------------------------
Number of DoFs: 35937

Adaptivity Results
Number of steps: 42
Elapsed Time:
---------------------------------------------------------------
Timer Calls Min(s) Avg(s) Max(s) Total(s)
---------------------------------------------------------------
refine 12 1.96e-01 3.56e-01 8.15e-01 4.28e+00
time-adap 28 1.06e-01 1.41e-01 2.12e-01 3.95e+00
solve 42 2.27e-01 3.12e-01 4.82e-01 1.31e+01
output 28 1.06e-01 1.40e-01 2.11e-01 3.93e+00
assemble 42 1.87e-01 3.26e-01 5.21e-01 1.37e+01
update-ghost 73 1.10e-05 3.20e-04 1.20e-03 2.34e-02
setup 1 1.79e-01 1.79e-01 1.79e-01 1.79e-01
---------------------------------------------------------------
Max number of DoFs: 82891

Computing L2 against baseline
L2_error = 1.33e-03

=======================================================================
Only Space Adaptivity
=======================================================================

Baseline Results
Number of steps: 40
Elapsed Time:
---------------------------------------------------------------
Timer Calls Min(s) Avg(s) Max(s) Total(s)
---------------------------------------------------------------
update-ghost 40 1.19e-04 1.92e-04 5.98e-04 7.67e-03
solve 40 7.31e-02 8.91e-02 1.33e-01 3.56e+00
output 40 7.35e-02 8.89e-02 1.15e-01 3.56e+00
assemble 40 1.84e-01 2.14e-01 2.98e-01 8.55e+00
setup 1 3.38e-01 3.38e-01 3.38e-01 3.38e-01
---------------------------------------------------------------
Number of DoFs: 35937

Adaptivity Results
Number of steps: 20
Elapsed Time:
---------------------------------------------------------------
Timer Calls Min(s) Avg(s) Max(s) Total(s)
---------------------------------------------------------------
refine 5 2.21e-01 5.87e-01 1.04e+00 2.93e+00
time-adap 20 8.22e-02 1.60e-01 2.64e-01 3.20e+00
solve 20 1.39e-01 3.44e-01 5.44e-01 6.89e+00
output 20 8.19e-02 1.59e-01 2.62e-01 3.17e+00
assemble 20 2.09e-01 3.70e-01 5.98e-01 7.40e+00
update-ghost 43 1.39e-05 3.86e-04 1.42e-03 1.66e-02
setup 1 2.55e-01 2.55e-01 2.55e-01 2.55e-01
---------------------------------------------------------------
Max number of DoFs: 99978

Computing L2 against baseline
L2_error = 6.56e-05


=======================================================================
Only Time Adaptivity
=======================================================================

Baseline Results
Number of steps: 40
Elapsed Time:
---------------------------------------------------------------
Timer Calls Min(s) Avg(s) Max(s) Total(s)
---------------------------------------------------------------
update-ghost 40 1.09e-04 2.17e-04 5.24e-04 8.66e-03
solve 40 6.77e-02 8.45e-02 1.17e-01 3.38e+00
output 40 6.84e-02 8.88e-02 1.41e-01 3.55e+00
assemble 40 1.83e-01 2.16e-01 2.72e-01 8.63e+00
setup 1 1.80e-01 1.80e-01 1.80e-01 1.80e-01
---------------------------------------------------------------
Number of DoFs: 35937

Adaptivity Results
Number of steps: 40
Elapsed Time:
---------------------------------------------------------------
Timer Calls Min(s) Avg(s) Max(s) Total(s)
---------------------------------------------------------------
time-adap 27 7.31e-02 8.56e-02 1.12e-01 2.31e+00
solve 40 1.28e-01 1.92e-01 2.57e-01 7.69e+00
output 27 7.27e-02 8.51e-02 1.12e-01 2.30e+00
assemble 40 1.72e-01 2.07e-01 2.49e-01 8.27e+00
update-ghost 67 5.00e-05 2.39e-04 6.81e-04 1.60e-02
setup 1 2.26e-01 2.26e-01 2.26e-01 2.26e-01
---------------------------------------------------------------
Max number of DoFs: 35937

Computing L2 against baseline
L2_error = 1.35e-03
Loading