Skip to content

Commit

Permalink
Merges develop branch
Browse files Browse the repository at this point in the history
Former-commit-id: 2544a15
  • Loading branch information
zlotny committed Nov 7, 2019
2 parents 0187da7 + 89e3a51 commit a6dc652
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 39 deletions.
42 changes: 24 additions & 18 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
# Contributing
First of all, thank you for contributing to the project! This is becoming a huge project to maintain and improve by only one person, and every bit of help is appreciated.

# Project status notice
DesignSPHysics is currently under development and not ready for consumer use. It contains errors, unfinished features and is prompt to change in any moment. Take that into account when posting issues or contributing to the project.

This document was updated at 31 of July, 2018. It is probable that the project has been modified since then and this document does not contain correct information.
This document was updated at 07 of November, 2019. It is probable that the project has been modified since then and this document does not contain correct information.

# How to contribute
There's 2 main ways to contribute: Opening issues and contributing to the code. Below you can find information about the 2.

## Opening issues
You can open issues in [this github repository](https://github.com/DualSPHysics/DesignSPHysics) to report errors or suggest new features or how to improve them. Keep in mind that there are a lot of things left to do and probably most of the missing features are coming eventually. The most useful feedback right now is error reporting and fixing.
You can open issues in [this github repository](https://github.com/DualSPHysics/DesignSPHysics/issues) to report errors or suggest new features or how to improve them.

## Contributing to the code
To contribute to the project please check the following section (Project Structure) as it contains a brief description about how the project is structure and where to find the related code for each UI element.

To submit code please make your changes onto the `develop` branch and open a pull request. The current maintainer of the code will check it as soon as possible to merge the change onto the branch.

## Code style and architecture
The repository files include a `pylintrc` file meant to be used with the linter *pylint*. It is advised to follow the gidelines of this linter and try to fix any errors, warnings and suggestions it gives.

The focus of the code is to be as autodocumented as possible, and easily readable and undesrtandable. Please **do not** include overly abbreviated variables and do not try to skimp in line length. writing a `super_long_variable_but_easy_to_understand` is fine, `ts_crmp` (too_short_and_cramped) variables are definitely not easy to understand. Avoid that.

Also, the codebase is built around an object/class model, trying to avoid single module functions whenever as possible. For now a few of those remain but in the future all of those files should be integrated on static classes. This way, the code is easy to traverse and jump from one structure to another on editors and IDEs.

# Project structure
## Branches
There are currently 2 branches on the repository:
Expand All @@ -22,37 +32,33 @@ There are currently 2 branches on the repository:

## File structure
This is a brief description on how the project files are structure and what each one contains. It only contains the most relevant files as most of them are brief and self-explanatory.
- `DesignSPHysics.FCMacro`: Macro file designed to use with FreeCAD. It only includes the DesignSPHysics FreeCAD module installed on the system, if there is any.
- `DesignSPHysics.py`: Main code file. From here all the data structures and GUI elements are created.
- `build-release.*`: Scripts to automate installer creation for release.
- `DesignSPHysics.FCMacro`: Macro file designed to use with FreeCAD. It bootstraps the DesignSPHysics application.
- `./mod/main.py`: Main project file. From here all the data structures and GUI elements are created.
- `mod`: DesignSPHysics modules. It contains all the code used by `DesignSPHysics.py`.
- `dataobjects`: Contains dataclasses representing the structure of a DesignSPHysics / DualSPHysics case.
- `lang`: Language files and translations.
- `templates`: Template files used in DesignSPHysics to create batch files, represent information on screen etc.
- `widgets.py`: Contains classes extending visual components to use in the interface.
- `execution_parameters.py`: Contains data classes to structure execution parameters for DualSPHysics
- `dataobjects.py`: Contains data classes to structure different DualSPHysics properties, parameters and configurations
- `enums.py`: Contains enums to manage property data with names.
- `file_tools.py`: Contains helper functions for all of the DesignSPHysics utilities.
- `gui_tools.py`: Similar to `file_tools.py` but containing only utilities related with user interface operations.
- `xmlimporter.py`: Code related with importing existing DualSPHysics cases to DesignSPHysics (uses lib `xmltodict.py`)
- `templates`: Template files used in DesignSPHysics to create files on disk, create the DualSPHysics XML, represent information on screen etc.
- `widgets`: Contains Qt classes with the widgets that compose the GUI
- `xml`: Contains the XML generator files, with its renderers.
- `constants.py`: Contains useful constants for the application.
- `enums.py`: Contains the enums used on the application.
- `*_tools.py`: These files contains little tools related to their name.
- `images`: Images and icons used in the user interface
- `dualsphysics/bin`: DualSPHysics executables.
- `installer`: Installer code.
- `installer.py`: Main installer file. Defines the installer window and its behaviour
- `resource`: Resources used by the installer. Mainly images.

Each one of the files contains plenty of comments in the code and tries to be easily readable and auto documented. For any doubt about what the code does you can open an issue in the GitHub repository.

## Code structure
All the main GUI elements, global data structure and monitor thread are created in the file `DesignSPHysics.py`. Once its execution is finished, all the code is execute as a reaction to a UI component signal.
All the main GUI elements, global data structure etc are created in the file `main.py`. Once its execution is finished, all the code is execute as a reaction to a UI component signal.
For example, when the "Load Case" button is pressed, the function binded to it gets executed and, from there, the related code inside it.

To implement a new UI component with a feature just create, for example, a button and a function to execute when pressed.

The main data structure is a Python Dictionary with different data attached to its keys. To see a reference to the structure, check the `get_default_data()` function in `mod.file_tools`.
The main data structure is a singleton data object named `Case`. It can be accessed like `Case.the()` and only one of them can be in memory at a time.

# Need more help?
If you need help on how to contribute please contact one of the following people
- Andrés Vieira Vázquez - [email protected]
- Lorena Docasar Vázquez - [email protected]
- Orlando García Feal - [email protected]
- José Manuel Domínguez Alonso - [email protected]
Expand Down
32 changes: 14 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,48 +1,44 @@
# DesignSPHysics

DesignSPHysics is a software module built into [FreeCAD](http://www.freecadweb.org/) that provides a Graphical User Interface for [DualSPHysics](http://dual.sphysics.org/).

It is under development since September 2016 and in Beta stage.
DesignSPHysics is a software module built into [FreeCAD](http://www.freecadweb.org/) that provides a Graphical User Interface for [DualSPHysics](http://dual.sphysics.org/). It is under development since September 2016 and in Beta stage.

Check the [Official Webpage](http://design.sphysics.org) for downloads and more information.

![Screenshot](http://design.sphysics.org/img/github-shot-31072018.png)

## Description
DesignSPHysics enables the user to create cases with solids and fluids and exports it to a DualSPHysics compatible format. In addition, it does the hard work for the user, generating the case automatically, simulating, and post-processing, all inside FreeCAD.
DesignSPHysics enables the user to create cases with solids and fluids and exports it to a DualSPHysics compatible format. In addition, it does the hard work for the user, generating the case data automatically, simulating, and post-processing, all inside FreeCAD.

It includes support for pre-processing with GenCase, simulation with DualSPHysics and post-processign with several tools of the DualSPHysics package.

In the future the code will be modular, so integration with different SPH solvers can be used. Right now it's optimized to be used with DualSPHysics 4.X
In the future the code will be modular, so integration with different SPH solvers can be used. Right now it's optimized to be used with DualSPHysics

It is developed as a FreeCAD module with a macro bootstrapper, in Python 3.7, using the QT libraries via PySide.
It is developed as a FreeCAD module with a macro bootstrapper, in Python 3.5+, using the QT libraries via PySide.

## Installation instructions
To install DesignSPHysics you have 2 options: Using an installer (release version) or using a development build (git)
To install DesignSPHysics you have 2 options: Using the FreeCAD Addon manager for an stable version, or installing manually whatever version that you like from git.

### Installing a release version
To install a release version go to the download section of the [official webpage](http://design.sphysics.org) and download the appropriate binary.

Execute the installer (installer.exe on Windows and installer on GNU/Linux) to open the installer. Then press install and it will copy the needed scripts in FreeCAD's macro default folder.
To install a release version, open FreeCAD 0.18+ and go to the menu *Macro -> Macros...* From there, press the *Addons...* button on the bottom right corner, search for DesignSPHysics and click *Install / Update*. FreeCAD will advise you to reboot the application and you'll be set.

It can also be done manually, unpackage release-windows.zip or release-linux.tar.gz, choose 'resource' folder and rename the folder to 'DesignSPHysics'. Then copy the folder to the Mod folder of the FreeCAD installation directory.
Take in mind that as it includes DualSPHysics, the package may take a while to download.

By default, for example, in Windows, it is located in `%appdata%/FreeCAD/Mod` or in Linux in `~/.FreeCAD/Mod`

Next open the folder and copy the file `DesignSPHysics.FCMacro` into the FreeCAD macro directory (`%appdata%/FreeCAD/Macro` on Windows; `~/.FreeCAD/Macro` on GNU/Linux).
To execute DesignSPHysics just open the same Macro dialog and double click DualSPHysics.

### Installing a development build
Clone this repository and rename the folder to 'DesignSPHysics'. Then copy the folder to the Mod folder of the FreeCAD installation directory.
Clone the branch that you like from this repository and rename the folder to 'DesignSPHysics'. Then copy the folder to the Mod folder of the FreeCAD installation directory.

By default, for example, in Windows, it is located in `%appdata%/FreeCAD/Mod` or in Linux in `~/.FreeCAD/Mod`

Then copy the file `DesignSPHysics.FCMacro` of this repository into the FreeCAD macro directory (`%appdata%/FreeCAD/Macro` on Windows; `~/.FreeCAD/Macro` on GNU/Linux)

## Where to get help
You can check the [DesignSPHysics Wiki](http://design.sphysics.org/wiki) to get help. Also, you can post an issue here on GitHub or send an email to any of the people found in the [CONTRIBUTING file](CONTRIBUTING.md).
You can check the [DesignSPHysics Wiki](http://design.sphysics.org/wiki) to get help. Also, you can post an [issue here on GitHub](https://github.com/DualSPHysics/DesignSPHysics/issues) or send an email to any of the people found in the [CONTRIBUTING file](CONTRIBUTING.md).

## Contributing and developing for DesignSPHysics
You can freely contribute to the project, if you want!. You can do it here on GitHub.

## Contributing
Please check the [CONTRIBUTING file](CONTRIBUTING.md) to view information about how to contribute to the project and how it is structured.
Please check the [CONTRIBUTING file](CONTRIBUTING.md) to view information about how to contribute to the project.

## Copyright and License
Copyright (C) 2019
Expand Down
2 changes: 1 addition & 1 deletion mod/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
DIVIDER = 1000
LINE_END = "\n"
PICKLE_PROTOCOL = 1 # Binary mode
VERSION = "0.6.0.1911-06-15"
VERSION = "0.6.0.1911-07-2"
WIDTH_2D = 0.001
MAX_PARTICLE_WARNING = 2000000
DISK_DUMP_FILE_NAME = "designsphysics-{}.log".format(VERSION)
Expand Down
4 changes: 2 additions & 2 deletions mod/xml/renderers/initials_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
class InitialsRenderer():
""" Renders the <initials> tag of the GenCase XML. """

INITIALS_XML = "/templates/gencase/simulationdomain.xml"
INITIALS_XML = "/templates/gencase/initials.xml"

@classmethod
def render(cls, data):
""" Returns the rendered string. """
template = get_template_text(cls.INITIALS_XML)
initials = map(lambda y: template.format(**y["mkbasedproperties"]["initials"]), filter(lambda x: x["initials"] is not None, data["mkbasedproperties"].values()))
initials = map(lambda y: template.format(**y["initials"]), filter(lambda x: x["initials"] is not None, data["mkbasedproperties"].values()))
return LINE_END.join(initials) if initials else ""

0 comments on commit a6dc652

Please sign in to comment.