Skip to content
Snippets Groups Projects
Commit fa8d4e1f authored by Lambert Theisen's avatar Lambert Theisen
Browse files

Start bundling into a package

parent 97e0bcfb
No related branches found
No related tags found
2 merge requests!5Update to version 1.1,!4Feat/create package
Showing
with 91 additions and 36 deletions
......@@ -42,3 +42,6 @@ examples/**/*.pdf
# Ignore matrices
*.mat
# Ignore pip folder
*egg-info/*
\ No newline at end of file
......@@ -26,7 +26,7 @@ build:environment:
- docker build --cache-from $CI_REGISTRY_IMAGE:latest --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA --tag $CI_REGISTRY_IMAGE:latest .
# - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA # no need
- docker push $CI_REGISTRY_IMAGE:latest
when: manual # skips 15min, but has to be done manually if Dockerfile changes
only: tags # skips 15min, but has to be done manually if Dockerfile changes
build:doc:
stage: build
......@@ -48,12 +48,22 @@ build:doc:
- ${DOCS_DIRECTORY}/_build/latex/
expire_in: 6 month
build:app:
stage: build
image:
name: $CI_REGISTRY_IMAGE:latest
entrypoint: [""]
script:
- pip install .
# **************************************************************************** #
# test
# **************************************************************************** #
.test: # dot means "hidden", acts as base class
stage: test
dependencies:
- build:app
image:
name: $CI_REGISTRY_IMAGE:latest # use prebuilt image in Gitlab's registry
entrypoint: [""] # == Repo. Has to be done if Dockerfile has own entrypoint
......
......@@ -37,6 +37,10 @@ RUN \
COPY requirements.txt /tmp/
RUN pip install --requirement /tmp/requirements.txt
# Install the fenicsR13 package (puts it into the PATH)
COPY . /tmp/
RUN pip install --editable /tmp/.
# Replace default FEniCS Docker WELCOME screen with custom WELCOME screen
COPY WELCOME .
RUN echo "Built: $(date)" >> WELCOME
\ No newline at end of file
include README.rst
\ No newline at end of file
......@@ -77,7 +77,7 @@ To run a simulation execute the solver main program ``fenicsR13.py`` (which is l
.. code-block:: bash
# Run program with given input file:
python3 ../../src/fenicsR13.py input.yml
fenicsR13 input.yml
Output files will be written to a folder which is named after the ``output_folder`` keyword of the ``input.yml``. For immediate inspection the output folder contains simple visualizations in PDF files for each of the fields (temperature, pressure,...).
......@@ -103,7 +103,7 @@ We provide a simple example of a flow through a finite-length channel in 2D.
# Create mesh:
./create_mesh.sh
# Run program with given input file:
python3 ../../src/fenicsR13.py input.yml
fenicsR13 input.yml
In the output folder the results can be post-processed to demonstrate the `Knudsen paradox`_ in a simple table.
......@@ -130,7 +130,7 @@ We can test the convergence of the R13 discretization on a simple double-cylindr
# Meshes are already in Git:
ls ../mesh
# Run program with given input file:
python3 ../../src/fenicsR13.py inputs/r13_1_coeffs_nosources_norot_inflow_p1p1p1p1p1_stab.yml
fenicsR13 inputs/r13_1_coeffs_nosources_norot_inflow_p1p1p1p1p1_stab.yml
# Go to folder with simulation results (=casename in input.yml)
cd r13_1_coeffs_nosources_norot_inflow_p1p1p1p1p1_stab
# Open errors:
......@@ -150,7 +150,7 @@ FEniCS allows simple parallelization using MPI
# Parallel execution ("-u" to flash stdout)
# Usage: mpirun -n <numberOfProcesses> <serialCommand>
# E.g.: mpirun -n 4 python3 -u ../../src/fenicsR13.py input.yml
# E.g.: mpirun -n 4 fenicsR13 input.yml
Building the Docker Image Locally
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
......@@ -207,7 +207,7 @@ Developer Tips
.. code-block:: bash
htop -p `{ python3 ../../src/fenicsR13.py inputs/1_coeffs_nosources_norot_inflow_p1p1p1p1p1_stab.yml > /dev/null & } && echo $!`
htop -p `{ fenicsR13 inputs/1_coeffs_nosources_norot_inflow_p1p1p1p1p1_stab.yml > /dev/null & } && echo $!`
- Use doctest with ``python3 -m doctest -v src/meshes.py``
- Run ``pydocstyle`` once in a while
......@@ -317,7 +317,7 @@ Further Installation Tips
**Interactive Jupyter Notebooks with Microsoft's Visual Studio Code**
This is may be a convenient solution.
Run a file with ``%run ../../src/fenicsr13.py``
Run a file with ``%run ../../fenicsr13/fenicsr13.py``
**X11 Window Forwarding on OSX**
......
#!/bin/bash
python3 ../../src/geoToH5.py channel.geo channel5.h5 "-setnumber p 5"
\ No newline at end of file
geoToH5 channel.geo channel5.h5 "-setnumber p 5"
\ No newline at end of file
#!/bin/bash
python3 ../../src/geoToH5.py knudsen_pump.geo knudsen_pump4.h5 "-setnumber p 4"
\ No newline at end of file
geoToH5 knudsen_pump.geo knudsen_pump4.h5 "-setnumber p 4"
\ No newline at end of file
#!/bin/bash
python3 ../../src/geoToH5.py lid.geo lid5.h5 "-setnumber p 5"
\ No newline at end of file
geoToH5 lid.geo lid5.h5 "-setnumber p 5"
\ No newline at end of file
......@@ -14,7 +14,7 @@ class TestExamples(object):
All tests are compared against reference errors.
"""
solver_path = "../../src/fenicsR13.py"
solver_path = "fenicsR13"
def run_solver(self, inputfile, working_dir_):
"""
......@@ -23,7 +23,7 @@ class TestExamples(object):
Test fails if subprocess return Exception or error.
"""
subprocess.check_call([
"python3", self.solver_path, inputfile
self.solver_path, inputfile
], cwd=working_dir_)
# @pytest.fixture(scope="module", autouse=True)
......
# pylint: disable=invalid-name,missing-module-docstring
from .fenicsR13 import *
from .geoToH5 import *
from .input import *
from .meshes import *
from .postprocessor import *
from .solver import *
from .tensoroperations import *
......@@ -15,10 +15,10 @@ import sys
import gc
import dolfin as df
import meshes
from input import Input
from solver import Solver
from postprocessor import Postprocessor
from fenicsR13.meshes import H5Mesh
from fenicsR13.input import Input
from fenicsR13.solver import Solver
from fenicsR13.postprocessor import Postprocessor
def print_information():
r"""
......@@ -63,10 +63,13 @@ def main():
.. code-block:: bash
# Install fenicsR13
pip install .
# Usage: <path_to_program> <input_file>
# Goto case folder:
cd tests/r13
python3 ../../src/fenicsR13.py inputs/ \
fenicsR13 inputs/ \
r13_1_coeffs_nosources_norot_inflow_p1p1p1p1p1_stab.yml
"""
......@@ -108,7 +111,7 @@ def main():
mesh_name = mesh_names[p]
current_mesh = meshes.H5Mesh(mesh_name)
current_mesh = H5Mesh(mesh_name)
solver = Solver(params, current_mesh, p)
solver.assemble()
......
......@@ -5,13 +5,19 @@
"""
Converter from geo-format to a mesh in h5-format.
Installation:
.. coe-block:: bash
pip install .
Usage:
.. code-block:: bash
Usage: python3 <path_to_geoToH5.py> <geo_file> <h5_file> \
[<gmsh cli arguments>]
E.g.: python3 ../../src/geoToH5.py lid.geo lid5.h5 "-setnumber p 5"
E.g.: geoToH5 lid.geo lid5.h5 "-setnumber p 5"
"""
import os
......@@ -29,7 +35,7 @@ def geo_to_h5():
if not 3 <= len(sys.argv) <= 4:
print("""
Usage: python3 <path_to_geoToH5.py> <geo_file> <h5_file> [<gmsh cli arguments>]
E.g.: python3 ../../src/geoToH5.py lid.geo lid5.h5 "-setnumber p 5"
E.g.: geoToH5 lid.geo lid5.h5 "-setnumber p 5"
""")
return
......@@ -68,10 +74,3 @@ E.g.: python3 ../../src/geoToH5.py lid.geo lid5.h5 "-setnumber p 5"
file.write(mesh, "/mesh")
file.write(subdomains, "/subdomains")
file.write(boundaries, "/boundaries")
def main():
"Execute the converter."
geo_to_h5()
if __name__ == '__main__':
main()
File moved
File moved
File moved
......@@ -12,7 +12,7 @@ import time as time_module
import dolfin as df
import ufl
import numpy as np
import tensoroperations as to
import fenicsR13.tensoroperations as to
class Solver:
......@@ -47,8 +47,8 @@ class Solver:
Example
-------
>>> # Example usage:
>>> from input import Input
>>> from meshes import H5Mesh
>>> from fenicsR13.input import Input
>>> from fenicsR13.meshes import H5Mesh
>>> params = Input(
... "tests/heat/inputs/heat_01_coeffs_p1p1_stab.yml"
... ) # doctest: +ELLIPSIS
......@@ -1131,8 +1131,8 @@ class Solver:
>>> print(rhs.get_local())
[ 0.25 0.5 0.25]
>>> # Assign LHS to solver
>>> from input import Input
>>> from meshes import H5Mesh
>>> from fenicsR13.input import Input
>>> from fenicsR13.meshes import H5Mesh
>>> params = Input(
... "tests/heat/inputs/heat_01_coeffs_p1p1_stab.yml"
... ) # doctest: +ELLIPSIS
......
File moved
[pytest]
testpaths = src examples/test_examples.py tests
testpaths = fenicsR13 examples/test_examples.py tests
addopts = --doctest-modules --cov --cov-report=term --cov-report=html
setup.py 0 → 100644
"Setup file"
from setuptools import setup
def readme(): # pylint: disable=missing-function-docstring
with open('README.rst') as file:
return file.read()
setup(
name="fenicsR13",
version="1.0",
description="FEniCS (FEM) Solver for Non.-Eq.-Gases Based on R13 Equations",
long_description=readme(),
url="https://git.rwth-aachen.de/lamBOO/fenicsR13",
author="Lambert Theisen, Manuel Torrilhon",
author_email="lambert.theisen@rwth-aachen.de, mt@mathcces.rwth-aachen.de",
license="None",
packages=["fenicsR13"],
zip_safe=False,
entry_points={
"console_scripts": [
"fenicsR13=fenicsR13.fenicsR13:main",
"geoToH5=fenicsR13.geoToH5:geo_to_h5"
],
}
)
......@@ -15,7 +15,7 @@ class TestHeatConvergence(object):
"""
working_dir = "tests/heat"
solver_path = "../../src/fenicsR13.py"
solver_path = "fenicsR13"
def run_solver(self, inputfile):
"""
......@@ -24,7 +24,7 @@ class TestHeatConvergence(object):
Test fails if subprocess return Exception or error.
"""
subprocess.check_call([
"python3", self.solver_path, inputfile
self.solver_path, inputfile
], cwd=self.working_dir)
def compare_errors(self, errorsfile, ref_errorsfile):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment