From 9d3f4797cadba64186128140b3454fa5fe5c0213 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Tue, 17 Jul 2018 08:07:24 -0500 Subject: [PATCH 1/5] Expand style guide for C++ code --- docs/source/devguide/styleguide.rst | 103 +++++++++++++++++++++------- 1 file changed, 79 insertions(+), 24 deletions(-) diff --git a/docs/source/devguide/styleguide.rst b/docs/source/devguide/styleguide.rst index ccf6bf5217..e0e67a6d62 100644 --- a/docs/source/devguide/styleguide.rst +++ b/docs/source/devguide/styleguide.rst @@ -182,37 +182,83 @@ Always use C++-style comments (``//``) as opposed to C-style (``/**/``). (It is more difficult to comment out a large section of code that uses C-style comments.) -Header files should always use include guards with the following style (See -`SF.8 `_: - -.. code-block:: C++ - - #ifndef MODULE_NAME_H - #define MODULE_NAME_H - ... - content - ... - #endif // MODULE_NAME_H - Do not use C-style casting. Always use the C++-style casts ``static_cast``, ``const_cast``, or ``reinterpret_cast``. (See `ES.49 `_) +Source Files +------------ + +Use a ``.cpp`` suffix for code files and ``.h`` for header files. + +Header files should always use include guards with the following style (See +`SF.8 `_): + +.. code-block:: C++ + + #ifndef OPENMC_MODULE_NAME_H + #define OPENMC_MODULE_NAME_H + + namespace openmc { + ... + content + ... + } + + #endif // OPENMC_MODULE_NAME_H + +Avoid hidden dependencies by always including a related header file first, +followed by C/C++ library includes, other library includes, and then local +includes. For example: + +.. code-block:: C++ + + // foo.cpp + #include "foo.h" + + #include + #include + #include + + #include "hdf5.h" + #include "pugixml.hpp" + + #include "error.h" + #include "random_lcg.h" + Naming ------ -In general, write your code in lower-case. Having code in all caps does not -enhance code readability or otherwise. - Struct and class names should be CamelCase, e.g. ``HexLattice``. Functions (including member functions) should be lower-case with underscores, e.g. ``get_indices``. -Local variables, global variables, and struct/class attributes should be -lower-case with underscores (e.g. ``n_cells``) except for physics symbols that -are written differently by convention (e.g. ``E`` for energy). +Local variables, global variables, and struct/class member variables should be +lower-case with underscores (e.g., ``n_cells``) except for physics symbols that +are written differently by convention (e.g., ``E`` for energy). Data members of +classes (but not structs) additionally have trailing underscores (e.g., +``a_class_member_``). -Const variables should be in upper-case with underscores, e.g. ``SQRT_PI``. +Accessors and mutators (get and set functions) may be named like +variables. These often correspond to actual member variables, but this is not +required. For example, ``int count()`` and ``void set_count(int count)``. + +Variables declared constexpr or const that have static storage duration (exist +for the duration of the program) should be upper-case with underscores, +e.g., ``SQRT_PI``. + +Use C++-style declarator layout (see `NL.18 +`_): +pointer and reference operators in declarations should be placed adject to the +base type rather than the variable name. Avoid declaring multiple names in a +single declaration to avoid confusion: + +.. code-block:: C++ + + T* p; // good + T& p; // good + T *p; // bad + T* p, q; // misleading Curly braces ------------ @@ -280,6 +326,13 @@ the same line or omit the braces entirely. for (int i = 0; i < 5; i++) content(); +Documentation +------------- + +Classes, structs, and functions are to be annotated for the `Doxygen +`_ documentation generation tool. Use the +``\`` form of Doxygen commands, e.g., ``\brief`` instead of ``@brief``. + ------ Python ------ @@ -288,15 +341,17 @@ Style for Python code should follow PEP8_. Docstrings for functions and methods should follow numpydoc_ style. -Python code should work with both Python 2.7+ and Python 3.0+. +Python code should work with Python 3.4+. -Use of third-party Python packages should be limited to numpy_, scipy_, and -h5py_. Use of other third-party packages must be implemented as optional -dependencies rather than required dependencies. +Use of third-party Python packages should be limited to numpy_, scipy_, +matplotlib_, pandas_, and h5py_. Use of other third-party packages must be +implemented as optional dependencies rather than required dependencies. .. _C++ Core Guidelines: http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines .. _PEP8: https://www.python.org/dev/peps/pep-0008/ .. _numpydoc: https://github.com/numpy/numpy/blob/master/doc/HOWTO_DOCUMENT.rst.txt .. _numpy: http://www.numpy.org/ -.. _scipy: http://www.scipy.org/ +.. _scipy: https://www.scipy.org/ +.. _matplotlib: https://matplotlib.org/ +.. _pandas: https://pandas.pydata.org/ .. _h5py: http://www.h5py.org/ From b6f56865ddd21f007c9a532cabbf8b7f8d78614f Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Tue, 17 Jul 2018 08:43:53 -0500 Subject: [PATCH 2/5] Reformat README as a markdown file --- README.md | 58 +++++++++++++++++++++++++++++++++++++++ readme.rst | 80 ------------------------------------------------------ 2 files changed, 58 insertions(+), 80 deletions(-) create mode 100644 README.md delete mode 100644 readme.rst diff --git a/README.md b/README.md new file mode 100644 index 0000000000..ac5847cfad --- /dev/null +++ b/README.md @@ -0,0 +1,58 @@ +# OpenMC Monte Carlo Particle Transport Code + +[![License](https://img.shields.io/github/license/mit-crpg/openmc.svg)](http://openmc.readthedocs.io/en/latest/license.html) +[![Travis CI build status (Linux)](https://travis-ci.org/mit-crpg/openmc.svg?branch=develop)](https://travis-ci.org/mit-crpg/openmc) +[![Code Coverage](https://coveralls.io/repos/github/mit-crpg/openmc/badge.svg?branch=develop)](https://coveralls.io/github/mit-crpg/openmc?branch=develop) + +The OpenMC project aims to provide a fully-featured Monte Carlo particle +transport code based on modern methods. It is a constructive solid geometry, +continuous-energy transport code that uses HDF5 format cross sections. The +project started under the Computational Reactor Physics Group at MIT. + +Complete documentation on the usage of OpenMC is hosted on Read the Docs (both +for the [latest release](http://openmc.readthedocs.io/en/stable/) and +[developmental](http://openmc.readthedocs.io/en/latest/) version). If you are +interested in the project or would like to help and contribute, please send a +message to the OpenMC User's Group [mailing +list](https://groups.google.com/forum/?fromgroups=#!forum/openmc-users). + +## Installation + +Detailed [installation +instructions](http://openmc.readthedocs.io/en/stable/usersguide/install.html) +can be found in the User's Guide. + +## Citing + +If you use OpenMC in your research, please consider giving proper attribution by +citing the following publication: + +- Paul K. Romano, Nicholas E. Horelik, Bryan R. Herman, Adam G. Nelson, Benoit + Forget, and Kord Smith, "[OpenMC: A State-of-the-Art Monte Carlo Code for + Research and Development](https://doi.org/10.1016/j.anucene.2014.07.048)," + *Ann. Nucl. Energy*, **82**, 90--97 (2015). + +## Troubleshooting + +If you run into problems compiling, installing, or running OpenMC, first check +the [Troubleshooting +section](http://openmc.readthedocs.io/en/stable/usersguide/troubleshoot.html) in +the User's Guide. If you are not able to find a solution to your problem there, +please send a message to the User's Group [mailing +list](https://groups.google.com/forum/?fromgroups=#!forum/openmc-users). + +## Reporting Bugs + +OpenMC is hosted on GitHub and all bugs are reported and tracked through the +[Issues](https://github.com/mit-crpg/openmc/issues) feature on GitHub. However, +GitHub Issues should not be used for common troubleshooting purposes. If you are +having trouble installing the code or getting your model to run properly, you +should first send a message to the User's Group mailing list. If it turns out +your issue really is a bug in the code, an issue will then be created on +GitHub. If you want to request that a feature be added to the code, you may +create an Issue on github. + +## License + +OpenMC is distributed under the MIT/X +[license](http://openmc.readthedocs.io/en/stable/license.html). diff --git a/readme.rst b/readme.rst deleted file mode 100644 index 32cbb34e14..0000000000 --- a/readme.rst +++ /dev/null @@ -1,80 +0,0 @@ -========================================== -OpenMC Monte Carlo Particle Transport Code -========================================== - -|licensebadge| |travisbadge| |coverallsbadge| - -The OpenMC project aims to provide a fully-featured Monte Carlo particle -transport code based on modern methods. It is a constructive solid geometry, -continuous-energy transport code that uses HDF5 format cross sections. The -project started under the Computational Reactor Physics Group at MIT. - -Complete documentation on the usage of OpenMC is hosted on Read the Docs (both -for the `latest release`_ and developmental_ version). If you are interested in -the project or would like to help and contribute, please send a message to the -OpenMC User's Group `mailing list`_. - ------------- -Installation ------------- - -Detailed `installation instructions`_ can be found in the User's Guide. - ------- -Citing ------- - -If you use OpenMC in your research, please consider giving proper attribution by -citing the following publication: - -- Paul K. Romano, Nicholas E. Horelik, Bryan R. Herman, Adam G. Nelson, Benoit - Forget, and Kord Smith, "`OpenMC: A State-of-the-Art Monte Carlo Code for - Research and Development `_," - *Ann. Nucl. Energy*, **82**, 90--97 (2015). - ---------------- -Troubleshooting ---------------- - -If you run into problems compiling, installing, or running OpenMC, first check -the `Troubleshooting section`_ in the User's Guide. If you are not able to find -a solution to your problem there, please send a message to the User's Group -`mailing list`_. - --------------- -Reporting Bugs --------------- - -OpenMC is hosted on GitHub and all bugs are reported and tracked through the -Issues_ feature on GitHub. However, GitHub Issues should not be used for common -troubleshooting purposes. If you are having trouble installing the code or -getting your model to run properly, you should first send a message to the -User's Group `mailing list`_. If it turns out your issue really is a bug in the -code, an issue will then be created on GitHub. If you want to request that a -feature be added to the code, you may create an Issue on github. - -------- -License -------- - -OpenMC is distributed under the MIT/X license_. - -.. _latest release: http://openmc.readthedocs.io/en/stable/ -.. _developmental: http://openmc.readthedocs.io/en/latest/ -.. _mailing list: https://groups.google.com/forum/?fromgroups=#!forum/openmc-users -.. _installation instructions: http://openmc.readthedocs.io/en/stable/usersguide/install.html -.. _Troubleshooting section: http://openmc.readthedocs.io/en/stable/usersguide/troubleshoot.html -.. _Issues: https://github.com/mit-crpg/openmc/issues -.. _license: http://openmc.readthedocs.io/en/stable/license.html - -.. |licensebadge| image:: https://img.shields.io/github/license/mit-crpg/openmc.svg - :target: http://openmc.readthedocs.io/en/latest/license.html - :alt: License - -.. |travisbadge| image:: https://travis-ci.org/mit-crpg/openmc.svg?branch=develop - :target: https://travis-ci.org/mit-crpg/openmc - :alt: Travis CI build status (Linux) - -.. |coverallsbadge| image:: https://coveralls.io/repos/github/mit-crpg/openmc/badge.svg?branch=develop - :target: https://coveralls.io/github/mit-crpg/openmc?branch=develop - :alt: Code Coverage From ebbf855a7bf45c3c1a64facf0256d0dc9ba46c79 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Tue, 17 Jul 2018 15:42:59 -0500 Subject: [PATCH 3/5] Add CONTRIBUTING.md and code of conduct --- CODE_OF_CONDUCT.md | 73 ++++++++++++++++++++++++++++++++++++++++++++++ CONTRIBUTING.md | 46 +++++++++++++++++++++++++++++ 2 files changed, 119 insertions(+) create mode 100644 CODE_OF_CONDUCT.md create mode 100644 CONTRIBUTING.md diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000000..5aa0bcd34a --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,73 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, sex characteristics, gender identity and expression, +level of experience, education, socio-economic status, nationality, personal +appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at openmc@anl.gov. All complaints will +be reviewed and investigated and will result in a response that is deemed +necessary and appropriate to the circumstances. The project team is obligated to +maintain confidentiality with regard to the reporter of an incident. Further +details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html + +[homepage]: https://www.contributor-covenant.org diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000000..d02a543f87 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,46 @@ +# Contributing to OpenMC + +Welcome, and thank you for considering contributing to OpenMC! We look forward +to welcoming new members to the community and will do our best to help you get +up to speed. + +## Code of Conduct + +Participants in the OpenMC project are expected to follow and uphold the [Code +of Conduct](CODE_OF_CONDUCT.md). Please report any unacceptable behavior to +openmc@anl.gov. + +## Resources + +- [GitHub Repository](https://github.com/mit-crpg/openmc) +- [Documentation](http://openmc.readthedocs.io/en/latest) +- [User's Mailing List](openmc-users@googlegroups.com) +- [Developer's Mailing List](openmc-dev@googlegroups.com) +- [Slack Community](https://openmc.slack.com/signup) (If you don't see your + domain listed, contact openmc@anl.gov) + +## How to Report Bugs + +OpenMC is hosted on GitHub and all bugs are reported and tracked through the +[Issues](https://github.com/mit-crpg/openmc/issues) listed on GitHub. + +## How to Suggest Enhancements + +We welcome suggestions for new features or enhancements to the code and +encourage you to submit them as Issues on GitHub. However, it's important to +recognize that our development team is relatively small are does not have +unlimited time to devote to new feature suggestions. If you are interested in +working on the feature you are requesting, indicate so in the issue and the +development team will be happy to discuss it. + +## How to Submit Changes + +All changes to OpenMC happen through pull requests. For a full overview of the +process, see the developer's guide section on [Development +Workflow](http://openmc.readthedocs.io/en/latest/devguide/workflow.html). + +## Code Style + +Before you run off to make changes to the code, please have a look at our [style +guide](http://openmc.readthedocs.io/en/latest/devguide/styleguide.html), which +is used when reviewing new contributions. From 8c70101849a66c644408cd624802bd5a51f692f7 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Wed, 25 Jul 2018 06:30:26 -0500 Subject: [PATCH 4/5] Clarify enforcement in code of conduct --- CODE_OF_CONDUCT.md | 7 +++++-- CONTRIBUTING.md | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 5aa0bcd34a..d29d42adc4 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -58,8 +58,11 @@ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at openmc@anl.gov. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to -maintain confidentiality with regard to the reporter of an incident. Further -details of specific enforcement policies may be posted separately. +maintain confidentiality with regard to the reporter of an incident. However, +note that some project team members may have a legal obligation to report +certain forms of harassment because of their affiliation (for example, staff and +faculty at universities in the United States). Further details of specific +enforcement policies may be posted separately. Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d02a543f87..92f8d0870d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -28,7 +28,7 @@ OpenMC is hosted on GitHub and all bugs are reported and tracked through the We welcome suggestions for new features or enhancements to the code and encourage you to submit them as Issues on GitHub. However, it's important to -recognize that our development team is relatively small are does not have +recognize that our development team is relatively small and does not have unlimited time to devote to new feature suggestions. If you are interested in working on the feature you are requesting, indicate so in the issue and the development team will be happy to discuss it. From bd74e7a81d304e5a103be424f61a2e4a6417e3b3 Mon Sep 17 00:00:00 2001 From: Sterling Harper Date: Sun, 29 Jul 2018 21:08:33 -0400 Subject: [PATCH 5/5] Fix indexing error with cell_set_temperature --- src/geometry_header.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/geometry_header.F90 b/src/geometry_header.F90 index 758fc54da7..2c943706d7 100644 --- a/src/geometry_header.F90 +++ b/src/geometry_header.F90 @@ -736,7 +736,7 @@ contains ! find which material is associated with this cell (material_index ! is the index into the materials array) if (present(instance)) then - material_index = cells(index) % material(instance) + material_index = cells(index) % material(instance + 1) else material_index = cells(index) % material(1) end if