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

Add fastscapelib (C++) integration #6204

Draft
wants to merge 46 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 43 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
e7dc2d1
Add fastscapelib xtensor xtl to contrib and Cmakelist
Minerallo Jul 8, 2023
8c016e7
add interface fastcapecc.cc .h and prm in cookbook
Minerallo Jul 14, 2023
abbfe0f
replaced hard variables back
Minerallo Jul 14, 2023
2308b65
add test case fastscape_eroding_box_cc.prm
Minerallo Jul 14, 2023
857afab
add test repository and output_screen
Minerallo Jul 14, 2023
9fc768f
correction of V in m/s
Minerallo Jul 20, 2023
7c7f828
add mpi communication
Minerallo Jul 21, 2023
2c649a9
add trimesh and spherical geometry
Minerallo Apr 7, 2024
d00dacd
reactivate box geometry
Minerallo Apr 8, 2024
4e38e3a
rebased ASPECT and remove std::cout messages
Minerallo Oct 18, 2024
8ef7c21
update fastscapelib
Minerallo Oct 18, 2024
3d4090a
update with Healpix
Minerallo Oct 18, 2024
fc6a048
add healpix_cxx library
Minerallo Oct 24, 2024
365d90e
Healpix library with box coupling
Minerallo Oct 24, 2024
81fc75b
error correction and grid_box = std::make_unique to figure out
Minerallo Oct 25, 2024
fb4d0b6
add modules cmake healpix brew
Minerallo Oct 25, 2024
ec934d1
add assert if box of shell
Minerallo Oct 25, 2024
1ca89d0
setting index nsides
Minerallo Oct 25, 2024
07bda86
array size
Minerallo Oct 25, 2024
ec5081d
no mst sink
MFraters Oct 25, 2024
5147666
timestep to test
Minerallo Oct 25, 2024
7ade8d8
If you read this please send help
MFraters Oct 25, 2024
5f9a868
add mpirun path and addtional modelule to load
Minerallo Oct 28, 2024
c72b29f
use radial velocity
Minerallo Oct 28, 2024
557029e
add fastscapelib cmake config
benbovy Jan 15, 2025
6c881cc
Add initial fastscape dealii adapter.
MFraters Jan 16, 2025
7340ada
add fastscapelib cmake config
benbovy Jan 15, 2025
e4b0575
indent
MFraters Jan 16, 2025
4bb6352
Merge branch 'coupling_fs_adapter' into add-fastscapelib-cpp-integration
benbovy Jan 16, 2025
614fdef
remove fastscapelib, xtensor and healpix sources
benbovy Jan 16, 2025
51e843a
cmake: remove fastscapelib xtensor included from contrib
benbovy Jan 16, 2025
07f9016
cmake: remove healpix support
benbovy Jan 16, 2025
bad804e
cleanup and fixes (fastscapelib stable version)
benbovy Jan 16, 2025
c637ad3
clean-up (remove healpix)
benbovy Jan 16, 2025
a9f6876
add back fastscape (fortran) python VTK script
benbovy Jan 16, 2025
0449818
tried ito interpolate to higher resolution
Minerallo Jan 16, 2025
e66ef84
Merge remote-tracking branch 'Minerallo/coupling_fs_updated15jan' int…
benbovy Jan 16, 2025
5d4fb60
indent + some cleanup
benbovy Jan 16, 2025
78479d8
temp link error dirty fix
benbovy Jan 16, 2025
74b8d08
add temporary instructions to install fastsacpelib
benbovy Jan 17, 2025
4cde3e6
nit
benbovy Jan 17, 2025
ed95139
make fastscapelib grid adapater more agnostic
benbovy Jan 22, 2025
0601980
clean-up
benbovy Jan 22, 2025
9745776
refactor init surface mesh
benbovy Jan 23, 2025
b172233
remove GeometryType
benbovy Jan 23, 2025
a484377
C++14 support
benbovy Jan 23, 2025
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
33 changes: 33 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,29 @@ if(ASPECT_WITH_FASTSCAPE)
endif()


# Fastscapelib (C++)
set(ASPECT_WITH_FASTSCAPELIB OFF CACHE BOOL "Whether the user wants to compile ASPECT with the landscape evolution C++ code Fastscape(lib), or not.")
message(STATUS "Using ASPECT_WITH_FASTSCAPELIB = '${ASPECT_WITH_FASTSCAPE}'")
if(ASPECT_WITH_FASTSCAPELIB)
find_package(fastscapelib CONFIG)
if(${fastscapelib_FOUND})
set(FS_WITH_HEALPIX OFF CACHE BOOL "Turn off Fastscapelib support of Healpix grid" FORCE)
message(STATUS "Using ASPECT_WITH_FASTSCAPELIB = '${ASPECT_WITH_FASTSCAPELIB}'")
message(STATUS " fastscapelib_INCLUDE_DIR: ${fastscapelib_INCLUDE_DIRS}")
message(STATUS " fastscapelib_VERSION: ${fastscapelib_VERSION}")
# fastscapelib dependencies
find_package(xtensor REQUIRED)
message(STATUS " xtensor_INCLUDE_DIR: ${xtensor_INCLUDE_DIRS}")
message(STATUS " xtensor_VERSION: ${xtensor_VERSION}")
else()
message(STATUS "Fastscapelib not found. Disabling ASPECT_WITH_FASTSCAPELIB. You can specify a hint to your installation directory with fastscapelib_DIR.")
set(ASPECT_WITH_FASTSCAPELIB OFF CACHE BOOL "" FORCE)
endif()
else()
message(STATUS "Using ASPECT_WITH_FASTSCAPELIB = 'OFF'")
endif()


# NetCDF (c including parallel)
set(ASPECT_WITH_NETCDF ON CACHE BOOL "Check if the user wants to compile ASPECT with the NetCDF libraries.")

Expand Down Expand Up @@ -358,6 +381,7 @@ if(ASPECT_WITH_WORLD_BUILDER)
endif()
message(STATUS "")

#include "datatypes.h"

#
# Other stuff about external tools and how we interact with the system:
Expand Down Expand Up @@ -882,6 +906,15 @@ if (FASTSCAPE)
endforeach()
endif()

# Fastscapelib
if (${fastscapelib_FOUND})
message(STATUS "Linking ASPECT against Fastscapelib (header-only)")
foreach(_T ${TARGET_EXECUTABLES})
target_include_directories(${_T} PRIVATE ${fastscapelib_INCLUDE_DIRS})
target_include_directories(${_T} PRIVATE ${xtensor_INCLUDE_DIRS})
endforeach()
endif()

# NetCDF
if(${NETCDF_FOUND})
message(STATUS "Linking ASPECT against NetCDF")
Expand Down
117 changes: 117 additions & 0 deletions WITH_FASTSCAPELIB.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# Using Aspect with Fastscapelib (C++)

## Install Fastscapelib using conda

You can use conda to install fastscapelib and all of its dependencies (we assume
that you are familiar with managing conda environments):

```
conda install fastscapelib -c conda-forge
```

## Install Fastscapelib from source

You can follow the steps below to install Fastscapelib and its dependencies from
source.

### Set the installation prefix path for Fastscapelib and its dependencies

Choose a common location where you want to download the source files of
Fastscapelib and its dependencies:

```
$ export FS_SOURCE_PATH=/path/to/fastscapelib/source
```

Choose a common location where you want to install Fastscapelib and its
dependencies:

```
export CMAKE_INSTALL_PREFIX=/path/to/fastscapelib/install/dir
```

### Install xtl and xtensor

Download the `xtl` git repository and checkout the last stable version:

```
$ cd $FS_SOURCE_PATH
$ git clone https://github.com/xtensor-stack/xtl
$ cd xtl
$ git checkout 0.7.7
```

Build and install `xtl`:

```
$ cmake -S. -Bbuild
$ cmake --install build
```

Download the `xtensor` git repository and checkout the last stable version:

```
$ cd $FS_SOURCE_PATH
$ git clone https://github.com/xtensor-stack/xtensor
$ cd xtensor
$ git checkout 0.25.0
```

Build and install `xtensor`:

```
$ cmake -S. -Bbuild
$ cmake --install build
```

### Install Fastscapelib

Download the `fastscapelib` git repository and checkout the last stable version:

```
$ cd $FS_SOURCE_PATH
$ git clone https://github.com/fastscape-lem/fastscapelib
$ cd fastscapelib
$ git checkout v0.2.2
```

IMPORTANT: edit the `cmake/fastscapelibConfig.cmake` file with the editor of
your choice and add the following line just below `@PACKAGE_INIT@` (this will be
required every time you checkout another version or branch and re-install
Fastscapelib, but this won't be required for Fastscapelib version >0.2.2):

```
include(CMakeFindDependencyMacro)
```

Build and install `fastscapelib`:

```
$ cmake -S. -Bbuild
$ cmake --install build
```

## Compile Aspect with Fastscapelib enabled

If you have installed Fastscapelib using conda, don't forget to activate the
environment where you have installed Fastscapelib. Once activated, configuring
`aspect` with CMake should then find Fastscapelib automatically.

If you have installed Fastscapelib from source like described above, you can
help CMake find the Fastscapelib installation path using:

```
export CMAKE_PREFIX_PATH=/path/to/fastscapelib/install/dir
```

where the given path corresponds to the path that you set during installation
via the `CMAKE_INSTALL_PREFIX` environment variable (see instructions above).

Configuring `aspect` should then find Fastscapelib. Check the output of the
following command run from aspect's source root directory (note: you might need
to set additional arguments or run extra commands in order to find the other
dependencies of `aspect`, we skipped it here):

```
cmake -S. -Bbuild -DASPECT_WITH_FASTSCAPELIB=ON
```
54 changes: 23 additions & 31 deletions contrib/fastscape/fastscape_rewrite_VTK_with_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def get_times_pvd(filename):

times[i] = float(temp_str)

return times
return times


#%% Get file paths (absolute, not relative paths!)
Expand All @@ -54,73 +54,73 @@ def absoluteFilePaths(directory):

# trace generated using paraview version 5.8.0
#
# To ensure correct image size when batch processing, please search
# To ensure correct image size when batch processing, please search
# for and uncomment the line `# renderView*.ViewSize = [*,*]`

for File in FileNames:

#### disable automatic camera reset on 'Show'
paraview.simple._DisableFirstRenderCameraReset()

# create a new 'Legacy VTK Reader'
topography0000 = LegacyVTKReader(FileNames=File)

# get animation scene
animationScene1 = GetAnimationScene()

# get the time-keeper
timeKeeper1 = GetTimeKeeper()

# update animation scene based on data timesteps
animationScene1.UpdateAnimationUsingDataTimeSteps()

# get active view
renderView1 = GetActiveViewOrCreate('RenderView')
# uncomment following to set a specific view size
# renderView1.ViewSize = [882, 554]

# get layout
layout1 = GetLayout()

# show data in view
topography0000Display = Show(topography0000, renderView1, 'StructuredGridRepresentation')

# trace defaults for the display properties.
topography0000Display.Representation = 'Surface'

# reset view to fit data
renderView1.ResetCamera()

# get the material library
materialLibrary1 = GetMaterialLibrary()

# show color bar/color legend
topography0000Display.SetScalarBarVisibility(renderView1, True)

# update the view to ensure updated data information
renderView1.Update()

# get color transfer function/color map for 'H'
hLUT = GetColorTransferFunction('H')

# get opacity transfer function/opacity map for 'H'
hPWF = GetOpacityTransferFunction('H')

# save data
SaveData(File[:-4] + '.vts', proxy=topography0000, ChooseArraysToWrite=1,
PointDataArrays=['HHHHH','basement','catchment','drainage_area','erosion_rate','topography','total_erosion'])

#### saving camera placements for all active views

# current camera placement for renderView1
renderView1.CameraPosition = [225625.0, 25625.0, 878497.0779980461]
renderView1.CameraFocalPoint = [225625.0, 25625.0, 1135.7277145385742]
renderView1.CameraParallelScale = 227077.82689023562

#### uncomment the following to render all views
# RenderAllViews()
# alternatively, if you want to write images, you can use SaveScreenshot(...).

Delete(topography0000)
del topography0000

Expand All @@ -140,17 +140,9 @@ def absoluteFilePaths(directory):

for n, File in enumerate(FileNames):
dataset_attributes = {"timestep": str(times[n]), "group": "", "group": "", "file": os.path.basename(File)[:-4]+'.vts'}

ET.SubElement(doc, "DataSet", attrib=dataset_attributes).text="\n"


tree = ET.ElementTree(root)
tree.write('./VTK/topography.pvd', xml_declaration=True, encoding='utf-8', method="xml")








tree.write('./VTK/topography.pvd', xml_declaration=True, encoding='utf-8', method="xml")
Loading