Permalink
Browse files

Indent cleanup

  • Loading branch information...
1 parent ba8f2e6 commit f9e64529f6f87ebb8d24d0d8317112429b740e3f @mlund committed Dec 2, 2016
View
@@ -13,6 +13,8 @@ CTestTestfile.cmake
*.lo
*.o
+*.dsym
+
# Compiled Dynamic libraries
*.so
*.dylib
@@ -72,6 +72,6 @@
</codeStyleSettings>
</value>
</option>
- <option name="PREFERRED_PROJECT_CODE_STYLE" value="FaunusStyle" />
+ <option name="USE_PER_PROJECT_SETTINGS" value="true" />
</component>
</project>
View
@@ -1,9 +1,9 @@
cmake_minimum_required(VERSION 2.8.5 FATAL_ERROR)
project("Faunus")
-if(POLICY CMP0042)
- cmake_policy(SET CMP0042 OLD)
-endif()
+if (POLICY CMP0042)
+ cmake_policy(SET CMP0042 OLD)
+endif ()
# ----------------------------
# Locate external packages
@@ -15,50 +15,50 @@ enable_testing()
find_package(Eigen3 3.2.9)
if (NOT EIGEN3_FOUND)
- message (FATAL_ERROR "Eigen 3.1.2+ is required.")
-endif()
+ message(FATAL_ERROR "Eigen 3.1.2+ is required.")
+endif ()
include_directories(${EIGEN3_INCLUDE_DIR})
# ------------------------------
# Default build is "Release"
# ------------------------------
include(OptimizationFlags)
-if(NOT CMAKE_BUILD_TYPE)
- set(CMAKE_BUILD_TYPE RelWithDebInfo
- CACHE STRING "Build type: None Debug Release RelWithDebInfo MinSizeRel." FORCE)
-endif()
+if (NOT CMAKE_BUILD_TYPE)
+ set(CMAKE_BUILD_TYPE RelWithDebInfo
+ CACHE STRING "Build type: None Debug Release RelWithDebInfo MinSizeRel." FORCE)
+endif ()
# -----------------
# User options
# -----------------
-option(ENABLE_BABEL "Try to use OpenBabel for file I/O (experimental)" off)
-option(ENABLE_OPENMP "Try to use OpenMP parallization" off)
-option(ENABLE_MPI "Enable MPI code" off)
-option(ENABLE_STATIC "Use static instead of dynamic linkage of faunus library" off)
-option(ENABLE_PYTHON "Try to compile python bindings (experimental!)" on)
+option(ENABLE_BABEL "Try to use OpenBabel for file I/O (experimental)" off)
+option(ENABLE_OPENMP "Try to use OpenMP parallization" off)
+option(ENABLE_MPI "Enable MPI code" off)
+option(ENABLE_STATIC "Use static instead of dynamic linkage of faunus library" off)
+option(ENABLE_PYTHON "Try to compile python bindings (experimental!)" on)
option(ENABLE_APPROXMATH "Use approximate math (Quake inverse sqrt, fast exponentials etc.)" off)
option(ENABLE_HASHTABLE "Use hash tables for bond bookkeeping - may be faster for big systems" off)
-option(ENABLE_UNICODE "Use unicode characters in output" on)
+option(ENABLE_UNICODE "Use unicode characters in output" on)
option(ENABLE_POWERSASA "Fetch 3rd-party SASA calculation software" off)
-mark_as_advanced( CLEAR CMAKE_VERBOSE_MAKEFILE CMAKE_CXX_COMPILER CMAKE_CXX_FLAGS )
-mark_as_advanced( EXECUTABLE_OUTPUT_PATH LIBRARY_OUTPUT_PATH
- CMAKE_OSX_ARCHITECTURES CMAKE_OSX_SYSROOT GCCXML DART_TESTING_TIMEOUT)
+mark_as_advanced(CLEAR CMAKE_VERBOSE_MAKEFILE CMAKE_CXX_COMPILER CMAKE_CXX_FLAGS)
+mark_as_advanced(EXECUTABLE_OUTPUT_PATH LIBRARY_OUTPUT_PATH
+ CMAKE_OSX_ARCHITECTURES CMAKE_OSX_SYSROOT GCCXML DART_TESTING_TIMEOUT)
# -------------------------------
# Get git commit hash
# -------------------------------
find_package(Git)
if (GIT_FOUND)
- execute_process(
- COMMAND ${GIT_EXECUTABLE} log -1 --format="%h\ \(%ci\)"
- WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
- OUTPUT_VARIABLE GIT_COMMIT_HASH
- OUTPUT_STRIP_TRAILING_WHITESPACE
- )
- if (GIT_COMMIT_HASH)
- add_definitions("-DGIT_COMMIT_HASH=${GIT_COMMIT_HASH}")
- endif()
-endif()
+ execute_process(
+ COMMAND ${GIT_EXECUTABLE} log -1 --format="%h\ \(%ci\)"
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+ OUTPUT_VARIABLE GIT_COMMIT_HASH
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+ if (GIT_COMMIT_HASH)
+ add_definitions("-DGIT_COMMIT_HASH=${GIT_COMMIT_HASH}")
+ endif ()
+endif ()
# -------------------------------
# Check C/C++ code generation
@@ -71,12 +71,12 @@ CHECK_CXX_SOURCE_COMPILES("int main() { nullptr; }" nullptr)
CHECK_CXX_SOURCE_COMPILES("auto f()->decltype(int()) {return 0;} int main() {return f();}" decltype_)
CHECK_CXX_SOURCE_COMPILES("#include<memory>\nint main() {std::shared_ptr<int> i;}" smart_pointers)
-if(NOT decltype_)
- message(FATAL_ERROR "Required C++11 features unsupported by compiler.")
-endif()
-if(NOT (auto_type_inference AND unsigned_long_long_int AND long_double AND range_based_for_loop AND nullptr AND smart_pointers) )
- message(FATAL_ERROR "Required C++11 features unsupported by compiler.")
-endif()
+if (NOT decltype_)
+ message(FATAL_ERROR "Required C++11 features unsupported by compiler.")
+endif ()
+if (NOT (auto_type_inference AND unsigned_long_long_int AND long_double AND range_based_for_loop AND nullptr AND smart_pointers))
+ message(FATAL_ERROR "Required C++11 features unsupported by compiler.")
+endif ()
# ---------------------------
# Add source directories
@@ -87,25 +87,25 @@ add_subdirectory(scripts)
add_subdirectory(doc EXCLUDE_FROM_ALL)
if (CMAKE_BUILD_TYPE MATCHES "RelWithDebInfo")
- string(REPLACE "NDEBUG" "_ndebug" CMAKE_CXX_FLAGS_RELWITHDEBINFO ${CMAKE_CXX_FLAGS_RELWITHDEBINFO})
- set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}"
- CACHE STRING "Flags used by the compiler during Release with Debug Info builds" FORCE)
+ string(REPLACE "NDEBUG" "_ndebug" CMAKE_CXX_FLAGS_RELWITHDEBINFO ${CMAKE_CXX_FLAGS_RELWITHDEBINFO})
+ set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}"
+ CACHE STRING "Flags used by the compiler during Release with Debug Info builds" FORCE)
- message(
- "...............................................................\n"
- " Faunus is compiled in Debug mode to enable checks and\n"
- " assertions highly recommended when developing and testing.\n"
- " For production, switch to Release for optimal performance:\n\n"
- " -DCMAKE_BUILD_TYPE=Release\n"
- "***************************************************************\n")
-endif()
+ message(
+ "...............................................................\n"
+ " Faunus is compiled in Debug mode to enable checks and\n"
+ " assertions highly recommended when developing and testing.\n"
+ " For production, switch to Release for optimal performance:\n\n"
+ " -DCMAKE_BUILD_TYPE=Release\n"
+ "***************************************************************\n")
+endif ()
if (CMAKE_BUILD_TYPE MATCHES "Release")
- message(
- "......................................................................\n"
- " Faunus is running in Release mode recommended for production runs.\n"
- " For setting up simulations it is HIGHLY recommended to use Debug\n"
- " mode to enable run-time checks and assertions:\n\n"
- " -DCMAKE_BUILD_TYPE=RelWithDebInfo\n"
- "**********************************************************************\n")
-endif()
+ message(
+ "......................................................................\n"
+ " Faunus is running in Release mode recommended for production runs.\n"
+ " For setting up simulations it is HIGHLY recommended to use Debug\n"
+ " mode to enable run-time checks and assertions:\n\n"
+ " -DCMAKE_BUILD_TYPE=RelWithDebInfo\n"
+ "**********************************************************************\n")
+endif ()
@@ -5,31 +5,36 @@
#include "faunus/textio.h"
#include <faunus/potentials.h>
-namespace Faunus {
+namespace Faunus
+{
/**
* @brief Namespace for bonded interactions
*/
- namespace Bonded {
+ namespace Bonded
+ {
/**
* @brief Base class for two- and manybody potentials
*/
- struct BondedBase {
- vector<int> index; //!< Particle index
-
- inline BondedBase() {};
-
- bool find(int i) const { //!< Determine if particle exists in `index`
- return (std::find(index.begin(), index.end(), i)!=index.end()) ? true : false;
- }
-
- /** @brief Add offset to each index */
- void shift(int offset) {
- assert(offset>=0);
- for (auto &i : index)
- i += offset;
- }
+ struct BondedBase
+ {
+ vector<int> index; //!< Particle index
+
+ inline BondedBase() {};
+
+ bool find( int i ) const
+ { //!< Determine if particle exists in `index`
+ return (std::find(index.begin(), index.end(), i) != index.end()) ? true : false;
+ }
+
+ /** @brief Add offset to each index */
+ void shift( int offset )
+ {
+ assert(offset >= 0);
+ for ( auto &i : index )
+ i += offset;
+ }
};
/**
@@ -45,42 +50,46 @@ namespace Faunus {
* are the force constant and equilibrium distance, respectively. By default, the bond
* type is set to `HARMONIC`.
*/
- struct BondData : public BondedBase {
-
- enum class Type : char {HARMONIC, FENE};
-
- double k; //!< Force constant
- double req; //!< Equilibrium distance
-
- Type type; //!< Bond type (default: HARMONIC)
-
- inline BondData( int i, int j, double k, double req, Type type=Type::HARMONIC )
- : k(k), req(req), type(type)
- {
- index = {i,j};
- }
-
- inline BondData( Tmjson::iterator &it ) {
- index = textio::words2vec<int>( it.key() );
- assert( index.size() == 2);
- k = it.value()["k"] | 0.0;
- req = it.value()["req"] | 0.0;
- string t = it.value()["type"] | string("harmonic");
- if ( t == "harmonic" )
- type = Type::HARMONIC;
- }
-
- /** @brief Write to stream */
- friend std::ostream &operator<<(std::ostream &o, const BondData &b) {
- o << b.index[0] << " " << b.index[1] << " " << b.k << " " << b.req;
- return o;
- }
-
- /** @brief Read from stream */
- BondData& operator<<(std::istream &in) {
- in >> index[0] >> index[1] >> k >> req;
- return *this;
- }
+ struct BondData : public BondedBase
+ {
+
+ enum class Type : char { HARMONIC, FENE };
+
+ double k; //!< Force constant
+ double req; //!< Equilibrium distance
+
+ Type type; //!< Bond type (default: HARMONIC)
+
+ inline BondData( int i, int j, double k, double req, Type type = Type::HARMONIC )
+ : k(k), req(req), type(type)
+ {
+ index = {i, j};
+ }
+
+ inline BondData( Tmjson::iterator &it )
+ {
+ index = textio::words2vec<int>(it.key());
+ assert(index.size() == 2);
+ k = it.value()["k"] | 0.0;
+ req = it.value()["req"] | 0.0;
+ string t = it.value()["type"] | string("harmonic");
+ if ( t == "harmonic" )
+ type = Type::HARMONIC;
+ }
+
+ /** @brief Write to stream */
+ friend std::ostream &operator<<( std::ostream &o, const BondData &b )
+ {
+ o << b.index[0] << " " << b.index[1] << " " << b.k << " " << b.req;
+ return o;
+ }
+
+ /** @brief Read from stream */
+ BondData &operator<<( std::istream &in )
+ {
+ in >> index[0] >> index[1] >> k >> req;
+ return *this;
+ }
};
/**
@@ -97,35 +106,39 @@ namespace Faunus {
*
* @todo Under construction
*/
- struct DihedralData : public BondedBase {
- double k1; //!< Some constant
- double k2; //!< ...andother constant
-
- inline DihedralData() { index={-1,-1,-1,-1}; };
-
- inline DihedralData( Tmjson::iterator &it ) {
- index = textio::words2vec<int>( it.key() );
- assert( index.size() == 4);
- k1 = it.value()["k1"] | 0.0;
- k2 = it.value()["k2"] | 0.0;
- }
-
- /** @brief Write to stream */
- friend std::ostream &operator<<(std::ostream &o, const DihedralData &b) {
- for (auto i : b.index)
- o << i << " ";
- o << b.k1 << " " << b.k2;
- return o;
- }
-
- /** @brief Read from stream */
- DihedralData& operator<<(std::istream &in) {
- index.resize(4);
- for (auto &i : index)
- in >> i;
- in >> k1 >> k2;
- return *this;
- }
+ struct DihedralData : public BondedBase
+ {
+ double k1; //!< Some constant
+ double k2; //!< ...andother constant
+
+ inline DihedralData() { index = {-1, -1, -1, -1}; };
+
+ inline DihedralData( Tmjson::iterator &it )
+ {
+ index = textio::words2vec<int>(it.key());
+ assert(index.size() == 4);
+ k1 = it.value()["k1"] | 0.0;
+ k2 = it.value()["k2"] | 0.0;
+ }
+
+ /** @brief Write to stream */
+ friend std::ostream &operator<<( std::ostream &o, const DihedralData &b )
+ {
+ for ( auto i : b.index )
+ o << i << " ";
+ o << b.k1 << " " << b.k2;
+ return o;
+ }
+
+ /** @brief Read from stream */
+ DihedralData &operator<<( std::istream &in )
+ {
+ index.resize(4);
+ for ( auto &i : index )
+ in >> i;
+ in >> k1 >> k2;
+ return *this;
+ }
};
}//namespace
Oops, something went wrong.

0 comments on commit f9e6452

Please sign in to comment.