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

Temporary PR for testing devel #563

Open
wants to merge 49 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
f622eee
Migrate from poetry to uv
icui Feb 5, 2025
d10e107
Avoid automatic building
icui Feb 6, 2025
94affc9
Merge branch 'devel' into issue-161
icui Feb 7, 2025
8bc81f5
Update docs for uv.
icui Feb 7, 2025
5a1ca04
Add function to access field of a medium
icui Feb 7, 2025
7fa5c7d
added html_baseurl to conf.py
int-ptr-ptr Feb 20, 2025
0edded2
docs/requirements.txt: sphinx 8.0.0
int-ptr-ptr Feb 20, 2025
561ce2d
Merge pull request #497 from int-ptr-ptr:readthedocs-buildfix
Rohit-Kakodkar Feb 24, 2025
2d6fb85
Merge pull request #459 from PrincetonUniversity/issue-458
icui Feb 24, 2025
240222e
refactor point_properties and property_container
icui Feb 24, 2025
e778c3b
Compute derivated perperties on the fly.
icui Feb 25, 2025
c09796f
Update macro location.
icui Feb 25, 2025
558545b
Rename Base to base_type
icui Feb 26, 2025
0dee5ec
Fix typo in impl_store_on_device.
icui Feb 26, 2025
a2b81db
Merge pull request #515 from PrincetonUniversity/issue-514
icui Feb 26, 2025
450c926
Merge remote-tracking branch 'origin/issue-514' into issue-513
icui Feb 26, 2025
b09b9c2
Merge host and device access functions.
icui Feb 26, 2025
6354577
Rename medium::properties to medium::impl_material
icui Feb 27, 2025
185f6db
Move impl/material.hpp
icui Feb 27, 2025
3a1c36b
Merge material_properties and properties_container
icui Feb 27, 2025
d53af06
Fixed a typo.
icui Feb 27, 2025
222ad0c
Update view_type for properties_container.
icui Feb 27, 2025
0e6f120
Merge branch 'issue-489' into issue-513
icui Feb 27, 2025
fa074ec
Merge branch 'issue-513' into issue-523
icui Feb 27, 2025
63e426e
Move impl_properties to impl/values
icui Feb 27, 2025
119d628
Create shared parent class for containers.
icui Feb 27, 2025
974a0ff
Refactor kernels_container
icui Feb 27, 2025
1e14192
Refactor kernels.
icui Feb 28, 2025
f65d83b
Merge pull request #509 from PrincetonUniversity/issue-489
icui Mar 3, 2025
4df6e08
Make on_device always constexr.
icui Mar 3, 2025
bb4c111
Merge pull request #518 from PrincetonUniversity/issue-513
icui Mar 3, 2025
ddee938
Merge pull request #524 from PrincetonUniversity/issue-523
icui Mar 3, 2025
49d3abf
Bug fix.
icui Mar 4, 2025
1322bd0
Remove material_kernels.
icui Mar 4, 2025
81be972
Update plot.py
icui Mar 4, 2025
a9245c8
Merge branch 'issue-493' into issue-525
icui Mar 4, 2025
9c110e6
Merge branch 'issue-493' into issue-525
icui Mar 4, 2025
da3119d
Update on_device template.
icui Mar 4, 2025
a8a86b9
Renamings in point/impl and medium/impl
icui Mar 4, 2025
2dc8e47
Merge kernel and property writer.
icui Mar 4, 2025
ae21b6f
Rename medium_writer to write_contaner
icui Mar 5, 2025
28fb748
Merge branch 'devel' into issue-161
icui Mar 5, 2025
2c49c9e
Update documentation.
icui Mar 5, 2025
98ad071
Miniupdate
lsawade Mar 5, 2025
98b6fa6
Merge pull request #454 from PrincetonUniversity/issue-161
icui Mar 5, 2025
ac84de2
Merge pull request #549 from PrincetonUniversity/issue-525
icui Mar 5, 2025
7923695
Merge pull request #551 from PrincetonUniversity/issue-550
icui Mar 5, 2025
df539da
Merge branch 'devel' into issue-493
icui Mar 5, 2025
f48c2d6
Merge pull request #552 from PrincetonUniversity/issue-493
icui Mar 6, 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
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repos:
- id: requirements-txt-fixer
- id: trailing-whitespace
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: "v15.0.6"
rev: "v19.1.7"
hooks:
- id: clang-format
types_or: [c++]
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
# }
# html_logo = ''
github_url = "https://github.com/PrincetonUniversity/SPECFEMPP"
# html_baseurl = ''
html_baseurl = 'https://specfem2d-kokkos.readthedocs.io/'

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.. _architecture:

SPECFEM++ Architecture
====================
======================

SPECFEM++ is designed with portability and modularity as primary goals. The goal is develop a code that is easy to maintain and extend, while maintaining performance characteristics of original `SPECFEM2D solver <https://specfem2d.readthedocs.io>`_. This is achieved using C++ templatized classes.

Expand Down
6 changes: 3 additions & 3 deletions docs/developer_documentation/git_workflow.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Git development workflow
=========================
========================

At SPECFEM++ we follow master-develop workflow. The master (main) branch is always a stable working code and is generally synced with the latest release of SPECFEM++. The develop branch is a stable code with potentially new features which haven't been released in the latest version of SPECFEM++ yet. If you are contributing to SPECFEM++ then issue your `pull request <https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests>`_ against the develop branch.

Expand All @@ -15,11 +15,11 @@ To make a change to SPECFEM++ (This development workflow is similar to the one s

.. note::

It is also recommended that you run :code:`poetry install` every time you pull the develop branch. Please check :ref:`style section<style>` for more information on poetry.
It is also recommended that you run :code:`uv sync --extra dev` every time you pull the develop branch. Please check :ref:`style section<style>` for more information on uv.

.. note::

Please also install pre-commit hooks after you've cloned repo. :code:`poetry run pre-commit install`
Please also install pre-commit hooks after you've cloned repo. :code:`uv run pre-commit install`

- Next create a feature branch against develop branch called a feature branch. Please be explicit while naming the feature branch.

Expand Down
48 changes: 19 additions & 29 deletions docs/developer_documentation/style.rst
Original file line number Diff line number Diff line change
@@ -1,72 +1,62 @@
Style
======
=====

Pre-commit
----------

SPECFEM++ uses pre-commit to check style. Pre-commit can be installed inside python virtual environments. There are several methods for creating virtual environments, but I've found poetry tool is great at managing python environments. Especailly in collaborative environments poetry gives easy method for managing consistency of environments between all contributors via :code:`pyproject.toml` and :code:`poetry.lock` files.
SPECFEM++ uses pre-commit to check style. Pre-commit can be installed inside python virtual environments. There are several methods for creating virtual environments, but I've found uv tool is great at managing python environments. Especailly in collaborative environments uv gives easy method for managing consistency of environments between all contributors via :code:`pyproject.toml` and :code:`uv.lock` files.

Install poetry
~~~~~~~~~~~~~~~
Install uv
~~~~~~~~~~

Download and install poetry using the `official instructions <https://python-poetry.org/docs/#installation>`_.
Download and install uv using the `official instructions <https://docs.astral.sh/uv/getting-started/installation>`_.

Install SPECFEM++ development environment
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. code-block:: bash

poetry install
uv sync --extra dev

When you run this command one of two things happen,

1. If a correct version of a package already exists within :code:`poetry.lock` file then poetry installs that version. Here the assumption is that a `poetry.lock` already exists, if not then one is created for you (within SPECFEM++ `poetry.lock` should already exist). `poetry.lock` ensures that all developers have consistent environments.
1. If a correct version of a package already exists within :code:`uv.lock` file then uv installs that version. Here the assumption is that a `uv.lock` already exists, if not then one is created for you (within SPECFEM++ `uv.lock` should already exist). `uv.lock` ensures that all developers have consistent environments.

2. If a correct version of a package doesn't exist within :code:`poetry.lock` then poetry will install a correct version and update `poetry.lock` file.
2. If a correct version of a package doesn't exist within :code:`uv.lock` then uv will install a correct version and update `uv.lock` file.

.. note::

Make sure you commit :code:`poetry.lock` and :code:`pyproject.toml` files upstream to the remote if you add any packages.
Make sure you commit :code:`uv.lock` and :code:`pyproject.toml` files upstream to the remote if you add any packages.

.. note::

It is also recommended that you run :code:`poetry install` every time you pull the develop branch
It is also recommended that you run :code:`uv sync --extra dev` every time you pull the develop branch

Using your python/poetry environment
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Using your python/uv environment
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If you're in the SPECFEM++ root directory you should have access to the poetry environment. To run a command within the environment either

1. Explicitly activate the environment using :code:`poetry shell` as shown below

.. code-block:: bash

poetry shell
python <script_name>.py

Or

2. Directly run the command within environment using :code:`poetry run`
If you're in the SPECFEM++ root directory with an IDE with Python support, you should have access to the uv environment directly.
To explicitly activate the environment, you can run the following command

.. code-block:: bash

poetry run python <script_name>.py
source .venv/bin/activate

Pre-commit hooks
~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~

Next, we install pre-commit hooks to check style. Pre-commit hooks are defined in :code:`.pre-commit-config.yaml` within SPECFEM++ root directory. More documentation on pre-commit hooks can be found `here <https://pre-commit.com/hooks.html>`_.

To enable the hooks (This only needs to be done when you clone the repo or there is an update to :code:`.pre-commit-config.yaml`)

.. code-block:: bash

poetry run pre-commit install
uv run pre-commit install

After this, pre-commit should run every time you commit a change. Ensuring that coding style is consistent across all developers.

To manually run pre-commit on all files

.. code-block:: bash

poetry run pre-commit run --all-files
uv run pre-commit run --all-files
1 change: 1 addition & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
sphinx==8.0.0
breathe
furo
sphinx-copybutton
Expand Down
14 changes: 7 additions & 7 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ The examples use [snakemake](https://snakemake.readthedocs.io/en/stable/) to run

## Running the examples

To run the examples, you first need to install poetry following these [instructions](https://python-poetry.org/docs/#installation). Once you've done so, you can install the dependencies for the examples by running the following command in the current directory:
To run the examples, you first need to install uv following these [instructions](https://docs.astral.sh/uv/getting-started/installation). Once you've done so, you can install the dependencies for the examples by running the following command in the current directory:

```bash
# verify poetry is installed
poetry --version
# verify uv is installed
uv --version

# install dependencies
poetry install
uv sync --extra examples

```

Expand All @@ -26,10 +26,10 @@ After installing the dependencies, you can run the examples by running the follo
cd <example directory>

# run the example
poetry run snakemake -j 1
uv run snakemake -j 1

# or to run the example on a slurm cluster
poetry run snakemake --executor slurm -j 1
uv run snakemake --executor slurm -j 1

```

Expand All @@ -40,6 +40,6 @@ To clean up the example directory, you can run the following command in the dire
```bash

# clean up the example
poetry run snakemake clean
uv run snakemake clean -j 1

```
17 changes: 10 additions & 7 deletions examples/Tromp_2005/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@ This example reproduces the results from Fig 9 of [Tromp et al. 2005](https://do

## Running the examples

To run the examples, you first need to install poetry following these [instructions](https://python-poetry.org/docs/#installation). Once you've done so, you can install the dependencies for the examples by running the following command in the current directory:
To run the examples, you first need to install uv following these
[instructions](https://docs.astral.sh/uv/getting-started/installation). Once you've done
so, you can install the dependencies for the examples by running the following
command in the current directory:

```bash
# verify poetry is installed
poetry --version
# verify uv is installed
uv --version

# install dependencies
poetry install
uv sync --extra examples

```

Expand All @@ -22,10 +25,10 @@ After installing the dependencies, you can run the examples by running the follo
cd <example directory>

# run the example
poetry run snakemake -j 1
uv run snakemake -j 1

# or to run the example on a slurm cluster
poetry run snakemake --executor slurm -j 1
uv run snakemake --executor slurm -j 1

```

Expand All @@ -36,6 +39,6 @@ To clean up the example directory, you can run the following command in the dire
```bash

# clean up the example
poetry run snakemake clean
uv run snakemake clean -j 1

```
18 changes: 12 additions & 6 deletions examples/Tromp_2005/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
def load_data(directory):
X = np.loadtxt(directory + "/ElasticIsotropic/X.txt")
Z = np.loadtxt(directory + "/ElasticIsotropic/Z.txt")
rho = np.loadtxt(directory + "/ElasticIsotropic/rho.txt")
kappa = np.loadtxt(directory + "/ElasticIsotropic/kappa.txt")
mu = np.loadtxt(directory + "/ElasticIsotropic/mu.txt")
rhop = np.loadtxt(directory + "/ElasticIsotropic/rhop.txt")
alpha = np.loadtxt(directory + "/ElasticIsotropic/alpha.txt")
beta = np.loadtxt(directory + "/ElasticIsotropic/beta.txt")
data = np.loadtxt(directory + "/ElasticIsotropic/data.txt").reshape(6, X.shape[0])

rho = data[0, :]
mu = data[1, :]
kappa = data[2, :]
rhop = data[3, :]
alpha = data[4, :]
beta = data[5, :]

return X, Z, rho, kappa, mu, rhop, alpha, beta

Expand Down Expand Up @@ -97,3 +99,7 @@ def plot_kernels(input_directory, output):
plt.savefig(output, dpi=300)

return


if __name__ == "__main__":
plot_kernels("OUTPUT_FILES/Kernels", "Kernels_out.png")
16 changes: 8 additions & 8 deletions examples/fluid-solid-bathymetry/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ publication [Pipatprathanporn et al.

## Running the examples

To run the examples, you first need to install poetry following these
[instructions](https://python-poetry.org/docs/#installation). Once you've done
To run the examples, you first need to install uv following these
[instructions](https://docs.astral.sh/uv/getting-started/installation). Once you've done
so, you can install the dependencies for the examples by running the following
command in the current directory:

```bash
# verify poetry is installed
poetry --version
# verify uv is installed
uv --version

# install dependencies
poetry install
uv sync --extra examples

```

Expand All @@ -27,10 +27,10 @@ following command within the example directory you want to run:
```bash

# run the example
poetry run snakemake -j 1
uv run snakemake -j 1

# or to run the example on a slurm cluster
poetry run snakemake --executor slurm -j 1
uv run snakemake --executor slurm -j 1

```

Expand Down Expand Up @@ -68,6 +68,6 @@ directory of the example you want to clean up:
```bash

# clean up the example
poetry run snakemake clean
uv run snakemake clean -j 1

```
16 changes: 8 additions & 8 deletions examples/fluid-solid-interface/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ guide on this example, please refer to the

## Running the examples

To run the examples, you first need to install poetry following these
[instructions](https://python-poetry.org/docs/#installation). Once you've done
To run the examples, you first need to install uv following these
[instructions](https://docs.astral.sh/uv/getting-started/installation). Once you've done
so, you can install the dependencies for the examples by running the following
command in the current directory:

```bash
# verify poetry is installed
poetry --version
# verify uv is installed
uv --version

# install dependencies
poetry install
uv sync --extra examples

```

Expand All @@ -27,10 +27,10 @@ following command within the example directory you want to run:
```bash

# run the example
poetry run snakemake -j 1
uv run snakemake -j 1

# or to run the example on a slurm cluster
poetry run snakemake --executor slurm -j 1
uv run snakemake --executor slurm -j 1

```

Expand All @@ -42,6 +42,6 @@ directory of the example you want to clean up:
```bash

# clean up the example
poetry run snakemake clean
uv run snakemake clean -j 1

```
17 changes: 10 additions & 7 deletions examples/homogeneous-medium-flat-topography/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@ In this example we simulate wave propagation through a 2-dimensional homogeneous

## Running the examples

To run the examples, you first need to install poetry following these [instructions](https://python-poetry.org/docs/#installation). Once you've done so, you can install the dependencies for the examples by running the following command in the current directory:
To run the examples, you first need to install uv following these
[instructions](https://docs.astral.sh/uv/getting-started/installation). Once you've done
so, you can install the dependencies for the examples by running the following
command in the current directory:

```bash
# verify poetry is installed
poetry --version
# verify uv is installed
uv --version

# install dependencies
poetry install
uv sync --extra examples

```

Expand All @@ -20,10 +23,10 @@ After installing the dependencies, you can run the examples by running the follo
```bash

# run the example
poetry run snakemake -j 1
uv run snakemake -j 1

# or to run the example on a slurm cluster
poetry run snakemake --executor slurm -j 1
uv run snakemake --executor slurm -j 1

```

Expand All @@ -34,6 +37,6 @@ To clean up the example directory, you can run the following command in the dire
```bash

# clean up the example
poetry run snakemake clean
uv run snakemake clean -j 1

```
Loading