Skip to content

Commit

Permalink
addressed compiler warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
mlund committed Dec 31, 2018
1 parent 7904708 commit b4a1d4c
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 29 deletions.
5 changes: 2 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -245,14 +245,13 @@ set(hdrs
)

# Compiler spacific flagg

## GCC
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
add_compile_options(-Wall -Wextra -pedantic-errors -Werror -Wunreachable-code
add_compile_options(-Wall -Wextra -Wpedantic -Wunreachable-code -Wstrict-aliasing
-Wno-sign-compare -Wno-unused-local-typedefs -Wno-unknown-pragmas)
## Clang
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -pedantic-errors -Werror -Wunreachable-code
add_compile_options(-Wall -Wextra -Wpedantic -Wunreachable-code
-Wstrict-aliasing -Wno-sign-compare -Wno-unused-local-typedef -Wno-unknown-pragmas)
endif()

Expand Down
21 changes: 11 additions & 10 deletions docs/_docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,15 @@ but should compile on most unix operating systems and possibly under Cygwin (Win

- CMake 3.9+
- C/C++14 compiler (Clang 3.5+, GCC 6+, etc.)
- Python 3.6+ with `ruamel_yaml` or `yaml`
- Python 3.6+ with the following packages:
- `ruamel_yaml` or `yaml`

The following are optional:

- Message Passing Interface (MPI)
- Pandoc (for building documentation)
- `pandoc`
- `pypandoc`
- `BeautifulSoup4`

**macOS tip:**
Apple's developer tools, Xcode, is a quick way obtain
Expand All @@ -61,8 +64,8 @@ Dependencies will automatically be downloaded.
~~~ bash
cd faunus
cmake . [OPTIONS]
make
make test
make faunus
make usagetips # optional, requires `pandoc`, `pypandoc`, `BeautifulSoup4`
make install
~~~

Expand All @@ -71,22 +74,21 @@ The following options are available:
CMake Option | Description
------------------------------------ | ---------------------------------------
`-DENABLE_MPI=OFF` | Enable MPI
`-DENABLE_OPENMP=OFF` | Enable OpenMP support
`-DENABLE_OPENMP=ON` | Enable OpenMP support
`-DENABLE_PYTHON=ON` | Build python bindings (experimental)
`-DENABLE_POWERSASA=ON` | Enable SASA routines (external download)
`-DCMAKE_BUILD_TYPE=RelWithDebInfo` | Alternatives: `Debug` or `Release` (faster)
`-DCMAKE_CXX_FLAGS_RELEASE="..."` | Compiler options for Release mode
`-DCMAKE_CXX_FLAGS_DEBUG="..."` | Compiler options for Debug mode
`-DCMAKE_INSTALL_PREFIX:PATH="..."` | Install location (default: `/usr/local`)
`-DMYPLAYGROUND="absolute path"` | Add additional source directory
`-DPYTHON_EXECUTABLE="..."` | Full path to Python executable
`-DPYTHON_INCLUDE_DIR="..."` | Full path to python headers
`-DPYTHON_LIBRARY="..."` | Full path to python library, i.e. libpythonX.dylib/so


### Python libraries in odd locations

Should you have multiple compilers or python distributions, be specific:
Should there are multiple compilers or python distributions, be specific:

~~~ bash
CC=/opt/bin/clang CXX=/opt/bin/clang++ cmake . \
Expand Down Expand Up @@ -116,7 +118,7 @@ rm -fR CMakeCache.txt CMakeFiles
## Creating a conda package (advanced usage)

The basic steps for creating a conda package is outlined below, albeit
details may depend on your build environment. See also the `.travis.yml`
details depend on the build environment. See also the `.travis.yml`
configuration file in the main repository.

~~~ bash
Expand All @@ -128,8 +130,7 @@ anaconda login
anaconda upload -u USER ... # see output from build step
~~~

Instead of uploading to anaconda.org you
can install a local copy directly after the build step above:
Instead of uploading to anaconda.org, install a local copy directly after the build step above:

~~~ bash
conda install -c USER faunus --use-local
Expand Down
6 changes: 0 additions & 6 deletions scripts/extracttips.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@
import pypandoc
import re

from sympy.external import import_module
#from .errors import LaTeXParsingError # noqa
from sympy.parsing.latex import parse_latex
from sympy import init_printing
from sympy import pprint, pretty

with open('manual.html', 'r') as f:
data=f.read()
soup = BeautifulSoup(data)
Expand Down
3 changes: 1 addition & 2 deletions src/geometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,7 @@ namespace Faunus {
}
}

bool Chameleon::collision(const Point &a, double r) const {
assert(std::fabs(r)<1e-6 && "collision test w. radius unimplemented.");
bool Chameleon::collision(const Point &a) const {
double r2 = radius*radius;
switch (type) {
case SPHERE:
Expand Down
4 changes: 2 additions & 2 deletions src/geometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ namespace Faunus {
virtual void randompos( Point&, Random& ) const=0; //!< Generate random position
virtual Point vdist( const Point&, const Point& ) const=0; //!< (Minimum) distance between two points
virtual void boundary( Point& ) const=0; //!< Apply boundary conditions
virtual bool collision( const Point&, double=0) const=0; //!< Overlap with boundaries
virtual bool collision(const Point&) const=0; //!< Overlap with boundaries
virtual Point getLength() const=0; //!< Side lengths

inline double sqdist( const Point &a, const Point &b ) const {
Expand Down Expand Up @@ -131,7 +131,7 @@ namespace Faunus {
Point setVolume(double V, VolumeMethod method=ISOTROPIC) override;
Point getLength() const override; //!< Enscribed box
void randompos( Point &m, Random &rand ) const override;
bool collision(const Point &a, double r=0) const override;
bool collision(const Point &a) const override;
void from_json(const json &j);
void to_json(json &j) const;

Expand Down
2 changes: 1 addition & 1 deletion src/molecule.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ namespace Faunus {
else { // insert molecule
if ( keeppos ) { // keep original positions (no rotation/trans)
for ( auto &i : v ) // ...but let's make sure it fits
if ( geo.collision(i.pos, 0))
if (geo.collision(i.pos))
throw std::runtime_error("Error: Inserted molecule does not fit in container");
} else {
Point cm; // new mass center position
Expand Down
10 changes: 6 additions & 4 deletions src/move.h
Original file line number Diff line number Diff line change
Expand Up @@ -1263,8 +1263,10 @@ namespace Faunus {
public:
using BasePointerVector<Movebase>::vec;
inline Propagator() {}
inline Propagator(const json &j, Tspace &spc, MPI::MPIController&) {

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
inline Propagator(const json &j, Tspace &spc, MPI::MPIController &mpi) {
#pragma GCC diagnostic pop
if (j.count("random")==1)
Movebase::slump = j["random"]; // slump is static --> shared for all moves

Expand All @@ -1280,11 +1282,11 @@ namespace Faunus {
else if (it.key()=="charge") this->template push_back<Move::ChargeMove<Tspace>>(spc);
else if (it.key()=="speciation") this->template push_back<Move::SpeciationMove<Tspace>>(spc);
else if (it.key()=="cluster") this->template push_back<Move::Cluster<Tspace>>(spc);
// more moves go here...
// new moves go here...
#ifdef ENABLE_MPI
else if (it.key()=="temper") this->template push_back<Move::ParallelTempering<Tspace>>(spc, mpi);
// new moves requiring MPI go here...
#endif

if (vec.size()==oldsize+1) {
vec.back()->from_json( it.value() );
addWeight(vec.back()->repeat);
Expand Down
2 changes: 1 addition & 1 deletion src/pyfaunus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ PYBIND11_MODULE(pyfaunus, m)
.def("getVolume", &Geometry::GeometryBase::getVolume, "Get container volume", "dim"_a=3)
.def("setVolume", &Geometry::GeometryBase::setVolume, "Set container volume", "volume"_a,
"method"_a=Geometry::ISOTROPIC)
.def("collision", &Geometry::GeometryBase::collision, "pos"_a, "radius"_a=0, "Checks if point is inside container")
.def("collision", &Geometry::GeometryBase::collision, "pos"_a, "Checks if point is inside container")
.def("getLength", &Geometry::GeometryBase::getLength, "Get cuboid sidelengths")
.def("vdist", &Geometry::GeometryBase::vdist, "Minimum vector distance, a-b", "a"_a, "b"_a)
.def("sqdist", &Geometry::GeometryBase::sqdist, "Squared minimum distance, |a-b|^2", "a"_a, "b"_a)
Expand Down
2 changes: 2 additions & 0 deletions src/space.h
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,9 @@ namespace Faunus {
for (auto& i : g)
i.pos = i.pos.cwiseProduct(scale);
else { // scale mass center and translate
#ifndef NDEBUG
Point oldcm = g.cm;
#endif
Point delta = g.cm.cwiseProduct(scale) - g.cm;
g.cm = g.cm.cwiseProduct(scale);
for (auto &i : g) {
Expand Down

0 comments on commit b4a1d4c

Please sign in to comment.