Skip to content

Commit

Permalink
Merge branch 'python' of https://github.com/espressomd/espresso into …
Browse files Browse the repository at this point in the history
…lb_test
  • Loading branch information
KaiSzuttor committed Mar 21, 2019
2 parents bf67964 + 4ad7bc4 commit a892bdd
Show file tree
Hide file tree
Showing 26 changed files with 156 additions and 188 deletions.
7 changes: 4 additions & 3 deletions doc/doxygen/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -1472,13 +1472,13 @@ ENABLE_PREPROCESSING = YES
# compilation will be performed. Macro expansion can be done in a controlled
# way by setting EXPAND_ONLY_PREDEF to YES.

MACRO_EXPANSION = NO
MACRO_EXPANSION = YES

# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
# then the macro expansion is limited to the macros specified with the
# PREDEFINED and EXPAND_AS_DEFINED tags.

EXPAND_ONLY_PREDEF = NO
EXPAND_ONLY_PREDEF = YES

# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files
# pointed to by INCLUDE_PATH will be searched when a #include is found.
Expand Down Expand Up @@ -1515,7 +1515,8 @@ INCLUDE_FILE_PATTERNS = *.h *.hpp *.cuh
# Use the PREDEFINED tag if you want to use a different macro definition that
# overrules the definition found in the source code.

EXPAND_AS_DEFINED =
EXPAND_AS_DEFINED = NEW_CYLINDRICAL_PROFILE_OBSERVABLE \
NEW_PARAMLESS_OBSERVABLE

# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then
# doxygen's preprocessor will remove all references to function-like macros
Expand Down
2 changes: 1 addition & 1 deletion doc/doxygen/gen_doxyconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@

for feature in sorted(defs.allfeatures):
configfile.write(" {} \\\n".format(feature))
configfile.write(" DOXYGEN \\\n".format(feature))
configfile.write(" DOXYGEN\n".format(feature))

configfile.close()
print("Done.")
15 changes: 7 additions & 8 deletions src/core/MpiCallbacks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ struct callback_concept_t {
};

/**
* @brief Concrete implementation of @class callback_concept_t.
* @brief Concrete implementation of @ref callback_concept_t.
*
* This is an implementation of a callback for a specific callable
* F and a set of arguments to call it with.
* @p F and a set of arguments to call it with.
*/
template <class F, class... Args>
struct callback_model_t final : public callback_concept_t {
Expand Down Expand Up @@ -129,7 +129,7 @@ auto make_model_impl(CRef &&c, FunctorTypes<C, R, Args...>) {
}

/**
* @brief Make a @class callback_model_t for a functor or lambda.
* @brief Make a @ref callback_model_t for a functor or lambda.
*
* The signature is deduced from F::operator() const, which has
* to exist and can not be overloaded.
Expand All @@ -139,7 +139,7 @@ template <typename F> auto make_model(F &&f) {
}

/**
* @brief Make a @class callback_model_t for a function pointer.
* @brief Make a @ref callback_model_t for a function pointer.
*
* This instantiates a implementation of a callback for a function
* pointer. The main task here is to transfer the signature from
Expand Down Expand Up @@ -319,8 +319,7 @@ class MpiCallbacks {
* in the MPI loop.
*
* @param id The callback to call.
* @param par1 First parameter to pass to the callback.
* @param par2 Second parameter to pass to the callback.
* @param args Arguments for the callback.
*/
template <class... Args> void call(int id, Args &&... args) const {
/** Can only be call from master */
Expand Down Expand Up @@ -352,7 +351,7 @@ class MpiCallbacks {
* The method can only be called the master
* and has the prerequisite that the other nodes are
* in the MPI loop. Also the function has to be previously
* registered e.g. with the @def REGISTER_CALLBACK macro.
* registered e.g. with the @ref REGISTER_CALLBACK macro.
*
* @param fp Pointer to the function to call.
* @param args Arguments for the callback.
Expand Down Expand Up @@ -446,7 +445,7 @@ using CallbackHandle = MpiCallbacks::CallbackHandle<Args...>;
/**
* @brief Helper class to atomatically add callbacks.
*
* Should not be used directly, but via @def REGISTER_CALLBACK.
* Should not be used directly, but via @ref REGISTER_CALLBACK.
*/
class RegisterCallback {

Expand Down
10 changes: 0 additions & 10 deletions src/core/communication.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,14 +327,4 @@ std::vector<int> mpi_resort_particles(int global_flag);

/*@}*/

/** \name Event codes for \ref mpi_bcast_event
* These codes are used by \ref mpi_bcast_event to notify certain changes
* of doing something now.
*/
/*@{*/
#define P3M_COUNT_CHARGES 0
#define CHECK_PARTICLES 2
#define P3M_COUNT_DIPOLES 5
/*@}*/

#endif
3 changes: 1 addition & 2 deletions src/core/debug.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
*/
void check_particle_consistency();

/** check the consistency of the cells and particle_node. Called from
* mpi_bcast_event(CHECK_PARTICLES)
/** check the consistency of the cells and particle_node.
*/
void check_particles();

Expand Down
4 changes: 2 additions & 2 deletions src/core/event.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ void on_temperature_change();

/** called every time other parameters (timestep,...) are changed. Note that
* this does not happen automatically. The callback procedure of the changed
* variable is responsible for that by calling \ref mpi_bcast_event (2).
* @param parameter is the FIELD_* identifier of the field changed.
* variable is responsible for that.
* @param parameter is the @ref Fields identifier of the field changed.
*/
void on_parameter_change(int parameter);

Expand Down
50 changes: 8 additions & 42 deletions src/core/forces_inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -509,24 +509,19 @@ inline int calc_bond_pair_force(Particle *p1, Particle *p2,
*/
inline void add_bonded_force(Particle *p1) {
Particle *p3 = nullptr, *p4 = nullptr;
Bonded_ia_parameters *iaparams;
int i, j, bond_broken = 1;
int bond_broken = 1;

i = 0;
int i = 0;
while (i < p1->bl.n) {
double dx[3] = {0., 0., 0.};
double force[3] = {0., 0., 0.};
double force2[3] = {0., 0., 0.};
double force3[3] = {0., 0., 0.};
#if defined(OIF_LOCAL_FORCES)
double force4[3] = {0., 0., 0.};
#endif
#ifdef ROTATION
double torque1[3] = {0., 0., 0.};
double torque2[3] = {0., 0., 0.};
#endif
int type_num = p1->bl.e[i++];
iaparams = &bonded_ia_params[type_num];
auto iaparams = &bonded_ia_params[type_num];
int type = iaparams->type;
int n_partners = iaparams->num;

Expand Down Expand Up @@ -616,11 +611,6 @@ inline void add_bonded_force(Particle *p1) {
#ifdef IMMERSED_BOUNDARY
case BONDED_IA_IBM_TRIEL:
bond_broken = IBM_Triel_CalcForce(p1, p2, p3, iaparams);
// These may be added later on, but we set them to zero because the
// force has already been added in IBM_Triel_CalcForce
force[0] = force2[0] = force3[0] = 0;
force[1] = force2[1] = force3[1] = 0;
force[2] = force2[2] = force3[2] = 0;
break;
#endif
default:
Expand All @@ -646,29 +636,9 @@ inline void add_bonded_force(Particle *p1) {
// IMMERSED_BOUNDARY
#ifdef IMMERSED_BOUNDARY
case BONDED_IA_IBM_TRIBEND: {
// First build neighbor list. This includes all nodes around the central
// node.
const int numNeighbors = iaparams->num;
auto **neighbors = new Particle *[numNeighbors];
// Three are already there
neighbors[0] = p2;
neighbors[1] = p3;
neighbors[2] = p4;
// Get rest
for (int j = 3; j < numNeighbors; j++)
neighbors[j] = local_particles[p1->bl.e[i++]];

IBM_Tribend_CalcForce(p1, numNeighbors, neighbors, *iaparams);
IBM_Tribend_CalcForce(p1, p2, p3, p4, *iaparams);
bond_broken = 0;

// Clean up
delete[] neighbors;

// These may be added later on, but we set them to zero because the
// force has
force[0] = force2[0] = force3[0] = 0;
force[1] = force2[1] = force3[1] = 0;
force[2] = force2[2] = force3[2] = 0;
break;
}
#endif
Expand Down Expand Up @@ -701,7 +671,7 @@ inline void add_bonded_force(Particle *p1) {
continue;
}

for (j = 0; j < 3; j++) {
for (int j = 0; j < 3; j++) {
switch (type) {
case BONDED_IA_THERMALIZED_DIST:
p1->f.f[j] += force[j];
Expand All @@ -710,10 +680,6 @@ inline void add_bonded_force(Particle *p1) {
default:
p1->f.f[j] += force[j];
p2->f.f[j] -= force[j];
#ifdef ROTATION
p1->f.torque[j] += torque1[j];
p2->f.torque[j] += torque2[j];
#endif
}
}
break;
Expand All @@ -725,7 +691,7 @@ inline void add_bonded_force(Particle *p1) {
continue;
}

for (j = 0; j < 3; j++) {
for (int j = 0; j < 3; j++) {
switch (type) {
default:
p1->f.f[j] += force[j];
Expand All @@ -744,7 +710,7 @@ inline void add_bonded_force(Particle *p1) {

switch (type) {
case BONDED_IA_DIHEDRAL:
for (j = 0; j < 3; j++) {
for (int j = 0; j < 3; j++) {
p1->f.f[j] += force[j];
p2->f.f[j] += force2[j];
p3->f.f[j] += force3[j];
Expand All @@ -754,7 +720,7 @@ inline void add_bonded_force(Particle *p1) {

#ifdef OIF_LOCAL_FORCES
case BONDED_IA_OIF_LOCAL_FORCES:
for (j = 0; j < 3; j++) {
for (int j = 0; j < 3; j++) {
p1->f.f[j] += force2[j];
p2->f.f[j] += force[j];
p3->f.f[j] += force3[j];
Expand Down
22 changes: 2 additions & 20 deletions src/core/immersed_boundary/ibm_tribend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,36 +27,18 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "immersed_boundary/ibm_tribend.hpp"
#include "particle_data.hpp"

// DEBUG
/*double maxBendingForce;
double maxBendingDist;
double maxX;*/

/*************
IBM_Tribend_CalcForce
Calculate the bending force and add it to the particles
**************/

void IBM_Tribend_CalcForce(Particle *p1, const int numPartners,
Particle **const partners,
const Bonded_ia_parameters &iaparams) {
// move to separate function
if (numPartners != 3) {
throw std::runtime_error("IBM_Tribend expects 3 bond partners.");
}

Particle *p2 = partners[0];
Particle *p3 = partners[1];
Particle *p4 = partners[2];

void IBM_Tribend_CalcForce(Particle *p1, Particle *p2, Particle *p3,
Particle *p4, const Bonded_ia_parameters &iaparams) {
assert(p1);
assert(p2);
assert(p3);
assert(p4);

// ************* This is Wolfgang's code **************
// with some corrections by Achim

// Get vectors making up the two triangles
double dx1[3], dx2[3], dx3[3];
get_mi_vector(dx1, p1->r.p, p3->r.p);
Expand Down
8 changes: 2 additions & 6 deletions src/core/immersed_boundary/ibm_tribend.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.

#include "bonded_interactions/bonded_interaction_data.hpp"

// DEBUG stuff
extern double maxBendingForce, maxBendingDist, maxX;

// This function is used to set the parameters
// Also calculates and stores the reference state
int IBM_Tribend_SetParams(const int bond_type, const int ind1, const int ind2,
Expand All @@ -41,9 +38,8 @@ int IBM_Tribend_SetParams(const int bond_type, const int ind1, const int ind2,
int IBM_Tribend_ResetParams(const int bond_type, const double kb);

// This function calculates and adds the actual force
void IBM_Tribend_CalcForce(Particle *p1, const int numPartners,
Particle **const partners,
const Bonded_ia_parameters &iaparams);
void IBM_Tribend_CalcForce(Particle *p1, Particle *p2, Particle *p3,
Particle *p4, const Bonded_ia_parameters &iaparams);

#endif

Expand Down
3 changes: 3 additions & 0 deletions src/core/unit_tests/AS_erfc_part_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ using Utils::AS_erfc_part;

#include <cmath>

/* Check that it can be used in constexpr context */
static_assert((AS_erfc_part(0.), true), "");

BOOST_AUTO_TEST_CASE(approx) {
for (double x = 0.0; x <= 1.; x += 0.01) {
auto const approx = AS_erfc_part(x);
Expand Down
12 changes: 12 additions & 0 deletions src/core/unit_tests/int_pow_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,20 @@
#include <boost/test/unit_test.hpp>

#include "utils/math/int_pow.hpp"
#include "utils/math/sqr.hpp"
using Utils::int_pow;
using Utils::sqr;

#include <limits>

auto const eps = std::numeric_limits<double>::epsilon();

/* Check that it can be used in constexpr context */
static_assert((int_pow<11>(2.), true), "");

/* Check that it can be used in constexpr context */
static_assert((sqr(2.), true), "");

BOOST_AUTO_TEST_CASE(even) {
const double x = 3.14159;

Expand All @@ -45,3 +53,7 @@ BOOST_AUTO_TEST_CASE(odd) {
BOOST_CHECK_CLOSE((x * x) * x, int_pow<3>(x), eps);
BOOST_CHECK_CLOSE((x * x) * (x * x) * x, int_pow<5>(x), 100. * eps);
}

BOOST_AUTO_TEST_CASE(square) {
BOOST_CHECK_EQUAL(int_pow<2>(3.1415), sqr(3.1415));
}
3 changes: 3 additions & 0 deletions src/core/unit_tests/sgn_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
#include "utils/math/sgn.hpp"
using Utils::sgn;

/* Check that it can be used in constexpr context */
static_assert(sgn(1), "");

BOOST_AUTO_TEST_CASE(pos) { BOOST_CHECK(1 == sgn(89)); }
BOOST_AUTO_TEST_CASE(nul) { BOOST_CHECK(0 == sgn(0)); }
BOOST_AUTO_TEST_CASE(neg) { BOOST_CHECK(-1 == sgn(-89)); }
9 changes: 2 additions & 7 deletions src/core/utils/Array.hpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
#ifndef UTILS_ARRAY_HPP
#define UTILS_ARRAY_HPP

#include "device_qualifier.hpp"

#include <boost/serialization/access.hpp>
#include <cstddef>

#if defined(__CUDACC__)
#define DEVICE_QUALIFIER __host__ __device__
#else
#define DEVICE_QUALIFIER
#endif

namespace Utils {

namespace detail {
Expand Down Expand Up @@ -135,5 +131,4 @@ template <typename T, std::size_t N> struct Array {
};

} // namespace Utils
#undef DEVICE_QUALIFIER
#endif
Loading

0 comments on commit a892bdd

Please sign in to comment.