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

Lagrange Interpolation Test.[WIP] #52

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -197,3 +197,4 @@ Thumbs.db
!examples/read_and_plot_mesh/mesh/*
!dg_maxwell/tests/mesh/*
!dg_maxwell/tests/msh_parser/mesh/*
!docs/quazar_logo.png
80 changes: 80 additions & 0 deletions .svgs/xi.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 3 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,13 @@ python:

# command to install dependencies
before_install:
- ls -al
- pwd
- cd ..
- ls -al
- sudo apt-get update -qq
- sudo apt-get install -qq build-essential git cmake libfreeimage-dev cmake-curses-gui
- sudo apt-get install -qq build-essential git cmake3 libfreeimage-dev cmake3-curses-gui
- sudo apt-get install -qq libopenblas-dev libfftw3-dev liblapacke-dev libboost-all-dev
- sudo apt-get install -qq libfontconfig1-dev
- sudo apt-get install build-essential cmake cmake-curses-gui xorg-dev libglu1-mesa-dev libxinerama-dev libxcursor-dev
- sudo apt-get install build-essential xorg-dev libglu1-mesa-dev libxinerama-dev libxcursor-dev
- grep MemTotal /proc/meminfo
- cat /proc/cpuinfo
- wget https://github.com/glfw/glfw/archive/3.1.2.zip -O glfw-3.1.2.zip
- unzip glfw-3.1.2.zip
- cd glfw-3.1.2
Expand All @@ -41,21 +37,15 @@ before_install:
- export AF_PATH=$PWD
- cd lib
- export LD_LIBRARY_PATH=$PWD:$LD_LIBRARY_PATH
- echo $LD_LIBRARY_PATH
- cd ../../../../
- cd arrayfire/build
# - make test
- cd ../../
- git clone https://github.com/amanabt/gmshtranslator.git
- cd gmshtranslator
- sudo pip install -e .
- cd ..
- pip install virtualenv
- pwd
- ls -al
- cd DG_Maxwell
- pwd
- ls -al
- virtualenv venv
- source venv/bin/activate

Expand All @@ -64,5 +54,5 @@ install:

script:
- python -c "import dg_maxwell"
- pytest
- pytest --verbose -r P --color=yes

122 changes: 122 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
# Contributing to DG Maxwell
You can contribute to this project by testing, raising issues
and making code contributions. A certain set of guidelines needs
to be followed for cotributing to the project.

## Code Guidelines
This project is mostly written in `Python3`, we follow a certain
set of code guidelines for writing `Python3` code. This project
follows the code guidelines set by the master organization
[Quazar Technologies](https://github.com/quazartech). You may
find the latest code guidelines on this
[link](https://github.com/QuazarTech/Style-Guidelines/blob/master/code_guidelines/python.md).

## Documentation Guidelines
This project uses [Sphinx](http://www.sphinx-doc.org/en/stable/)
to build it's documentation. The documentation lies in the
`docs` directory of the repository. In this project,
python `docstrings` are used to document all the member functions
of a module. Sphinx uses `autodoc` to read this docstring and
convert it into beautiful `html` pages. We follow a
certain set of guidelines for writing the `docstrings` as explained
below.

- Use `reST` syntax to write the documentation. Refer to these links,
[reST](http://www.sphinx-doc.org/en/stable/rest.html#rst-primer) and
[Sphinx Markup Constructs](http://www.sphinx-doc.org/en/stable/markup/index.html#sphinxmarkup)
to write the documentation for `Sphinx`.
- This project uses `numpydoc` for it's documentation. See how to use it
on this [link](https://github.com/numpy/numpy/blob/master/doc/HOWTO_DOCUMENT.rst.txt).
- Give a short description of what the function does.
- Mathematical variables should be written in LaTeX. See
[Math support in Sphinx](http://www.sphinx-doc.org/en/stable/ext/math.html#math-support).
- When using the special LaTeX symbols, use double "\\\\" instead of a
single "\\". For eg, for writing the math symbol
![xi](.svgs/xi.svg), write "\\\\xi" instead of "\\xi".
- If the function implements some mathematical equation, state that
equation and describe the terms occuring in the equation.
- If the algorithm is non-trivial, explain it in the documentation.
- If the algorithm is very lengthy and complicated,
write a LaTeX file explaining the algorithm and state it in the documentation.
Here is an example for stating the link `Full description of the algorithm can
be found here < link >`
- In case you want to insert the URL in the documentation and the URL is
exceeding the 80 characters limit, shorten the URL using
the [Google URL shortener](https://goo.gl/).
- Don't use personal pronouns in the documentation.
- Do not exceed the 80 characters per line limit.

Shown below is an example for documentation of a function
```python
def isoparam_1D(x_nodes, xi):
'''
Maps points in :math:`\\xi` space to :math:`x` space using the formula
:math:`x = \\frac{1 - \\xi}{2} x_0 + \\frac{1 + \\xi}{2} x_1`

Parameters
----------

x_nodes : arrayfire.Array [2 1 1 1]
Element nodes.

xi : arrayfire.Array [N 1 1 1]
Value of :math:`\\xi` coordinate for which the corresponding
:math:`x` coordinate is to be found.

Returns
-------
x : arrayfire.Array
:math:`x` value in the element corresponding to :math:`\\xi`.
''' '''
```

## Documentation Hosting
The documentations for the code is hosted on
[readthedocs(rtd)](https://readthedocs.org). This platform uses the `makefile`
in the `docs` directory to build a documentation and host it on the web if the
documentation build is successful. So, it's necessary to always make sure that
rtd is able to build the documentation successfully. Here are some things to
keep in mind when using rtd to host the documentation.
1.This project uses Sphinx `autodoc` extension to generate
the documentation from the `doc-strings`. But, in doing so, it imports the
actual modules. Those modules often contain some other 3rd party imports.
Sphinx fails if that dependency is not satisfied. So, to avoid that situation,
this project uses `unittest.mock.MagicMock`. This was you can use mock imports.
This code snippet is added in `docs/conf.py`.
```python
from unittest.mock import MagicMock

class Mock(MagicMock):
@classmethod
def __getattr__(cls, name):
return MagicMock()

MOCK_MODULES = ['gmshtranslator', 'gmshtranslator.gmshtranslator', 'arrayfire',
'lagrange', 'scipy', 'numpy', 'matplotlib', 'matplotlib.lines',
'dg_maxwell.params', 'tqdm']
sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES)
```
If you want to add a mock import, add that import name in the `MOCK_MODULES`
list.

## Continuous Integration
This project uses [Travis CI](https://travis-ci.org/) for automatically checking
the `build` and the unit tests.

## Code Quality
This project uses [CODACY](https://www.codacy.com/) to automatically check the
code quality.

## Pull Request Process
This project follows the guidelines set by Quazar Technologies for giving
a pull request. You may find the link to the pull request
[here](https://github.com/QuazarTech/Style-Guidelines/blob/master/github/PR_guidelines.md).
Here are few additional guidelines to be followed when giving a pull request
- Before asking to merge the pull request, make sure that the documentation
build is passing on `rtd`. You may do this by hosting your fork documentation on
`rtd`. Make sure that there are no errors by checking the build log and also
check your documentation on the `rtd` website and make sure to check the
hosted documentation of your fork.
- Make sure that the build is successfull and all the unit tests are passing on
`Travis CI`.
- Check the code quality of your fork with CODACY.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ Also add information on how to contact you by electronic and paper mail.
notice like this when it starts in an interactive mode:

{DG_Maxwell} Copyright (C) {Research Division, Quazar Technologies, Delhi}{2017}
{Shyam Sundar Sankaran, Mani Chandra}
{Balavarun P, Aman Abhishek Tiwari, Mani Chandra}
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ The unit tests are located in the

### Running Unit Tests
To run the unit tests, enter the following commands
```
```bash
$ cd path/to/the/DG_Maxwell/repo
$ pytest
$ pytest --verbose -r P --color=yes
```
* The parameters of the simulation are stored in params.py in
the app folder, These can be changed accordingly.
Expand Down
5 changes: 3 additions & 2 deletions dg_maxwell/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@


# The domain of the function.
x_nodes = af.np_to_af_array(np.array([-1., 1.]))
x_nodes = af.np_to_af_array(np.array([0, 1.]))

# The number of LGL points into which an element is split.
N_LGL = 8

# Number of elements the domain is to be divided into.
N_Elements = 10
N_Elements = 8

# The scheme to be used for integration. Values are either
# 'gauss_quadrature' or 'lobatto_quadrature'
Expand Down Expand Up @@ -133,6 +133,7 @@


# Initializing the amplitudes. Change u_init to required initial conditions.
u_init = af.sin(2 * np.pi * element_LGL)
u = af.constant(0, N_LGL, N_Elements, time.shape[0],\
dtype = af.Dtype.f64)
u[:, :, 0] = u_init
3 changes: 2 additions & 1 deletion dg_maxwell/wave_equation.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def volume_integral_flux(u_n, t_n):

if(params.volume_integral_scheme == 'lobatto_quadrature'\
and params.N_quad == params.N_LGL):

print('option1')
# Flux using u_n, reordered to 1 X N_LGL X N_Elements array.
F_u_n = af.reorder(flux_x(u_n), 2, 0, 1)

Expand Down Expand Up @@ -265,6 +265,7 @@ def volume_integral_flux(u_n, t_n):


else:
print('option3')
# Obtaining the u_n in polynomial form using the value at LGL points.
analytical_form_flux = flux_x(lagrange.\
wave_equation_lagrange(u_n))
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def __getattr__(cls, name):

# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
html_logo = "docs/quazar_logo.png"
html_logo = "quazar_logo.png"

# The name of an image file (relative to this directory) to use as a favicon of
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
Expand Down
Binary file added docs/quazar_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# DG Maxwell examples.

This directory contains the examples demonstrating the usage of
some of the `dg_maxwell` library functions.

## Dependencies
The examples are written in Jupyter notebooks. So, apart from
installation of the main `dg_maxwell` dependencies shown
[here](../README.md), [Jupyter](http://jupyter.org/) also needs
to be installed to run the examples.

## Running Examples
First, a Jupyter server needs to started by entering this command in
a terminal,

```bash
$ jupyter-notebook
```

Among the outputs of the above command, there will be an link on which
jupyter server is hosted, it will look something like this
```bash
http://localhost:8888/?token=58ec8707ab7b1fade9667b783455f4ccc9af5aa95dd6a65e
```

Open the link in your browser. The website will show the local directories.
Navigate to the `DG_Maxwell/examples` directory on that web page and locate
the example you want to run. Click on the file to open the example.

Read [Jupyter Documentation](https://jupyter.readthedocs.io/en/latest/index.html)
for helo with issues regarding Jupyter.
Loading