Skip to content

Commit

Permalink
progress
Browse files Browse the repository at this point in the history
  • Loading branch information
jngrad committed Jun 14, 2024
1 parent ba1e2be commit 43e1466
Show file tree
Hide file tree
Showing 37 changed files with 197 additions and 74 deletions.
76 changes: 76 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,40 @@ status_pending:
stage: prepare
script: sh maintainer/gh_post_status.sh pending

style:
<<: *global_job_definition
stage: build
dependencies: []
before_script:
- git config --global --add safe.directory ${CI_PROJECT_DIR}
- git submodule deinit .
script:
- sh maintainer/CI/fix_style.sh
tags:
- espresso
- no-cuda
variables:
GIT_SUBMODULE_STRATEGY: none
artifacts:
paths:
- style.patch
expire_in: 1 week
when: on_failure

style_doxygen:
<<: *global_job_definition
stage: build
dependencies: []
script:
- mkdir build
- cd build
- cp ../maintainer/configs/maxset.hpp myconfig.hpp
- cmake .. -D ESPRESSO_BUILD_WITH_CUDA=ON -D ESPRESSO_BUILD_WITH_GSL=ON -D ESPRESSO_BUILD_WITH_HDF5=ON -D ESPRESSO_BUILD_WITH_SCAFACOS=ON -D ESPRESSO_BUILD_WITH_WALBERLA=ON -D ESPRESSO_BUILD_WITH_WALBERLA_FFT=ON -D ESPRESSO_BUILD_WITH_STOKESIAN_DYNAMICS=ON -D ESPRESSO_BUILD_WITH_CALIPER=ON
- sh ../maintainer/CI/dox_warnings.sh
tags:
- espresso
- no-cuda

### Builds without CUDA

default:
Expand Down Expand Up @@ -402,6 +436,29 @@ empty:
- cuda
- numa

check_sphinx:
<<: *global_job_definition
stage: additional_checks
needs:
- cuda12-maxset
when: on_success
script:
- cd ${CI_PROJECT_DIR}/build
- make -t && make sphinx
- make -j2 tutorials
- make check_utils
- bash ${CI_PROJECT_DIR}/maintainer/CI/doc_warnings.sh
- python3 ${CI_PROJECT_DIR}/maintainer/CI/jupyter_warnings.py
artifacts:
paths:
- build/doc/sphinx
expire_in: 1 week
tags:
- espresso
- cuda
- numa
- reuse-artifacts-same-arch

run_tutorials:
<<: *global_job_definition
stage: additional_checks
Expand Down Expand Up @@ -430,6 +487,25 @@ run_tutorials:
only:
- schedules

run_doxygen:
<<: *global_job_definition
stage: additional_checks
needs:
- cuda12-maxset
when: on_success
script:
- cd ${CI_PROJECT_DIR}/build
- make -t && make doxygen
artifacts:
paths:
- build/doc/doxygen
expire_in: 1 week
tags:
- espresso
- no-cuda
- numa
- reuse-artifacts-same-arch

maxset_no_gpu:
<<: *global_job_definition
stage: additional_checks
Expand Down
1 change: 0 additions & 1 deletion maintainer/walberla_kernels/code_generation_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import pystencils_walberla



def earmark_generated_kernels():
"""
Add an earmark at the beginning of generated kernels to document the
Expand Down
4 changes: 3 additions & 1 deletion maintainer/walberla_kernels/generate_lb_kernels.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ def paramlist(parameters, keys):
params
)

block_offsets = tuple(ps.TypedSymbol(f"block_offset_{i}", np.uint32) for i in range(3))
block_offsets = tuple(
ps.TypedSymbol(f"block_offset_{i}", np.uint32)
for i in range(3))

# generate thermalized LB
collision_rule_thermalized = lbmpy.creationfunctions.create_lb_collision_rule(
Expand Down
10 changes: 5 additions & 5 deletions maintainer/walberla_kernels/lbmpy_espresso.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ def data_initialisation(self, direction):
cell_args = [f"it.{direction}() + {bb_vec[i]}".replace('+ -', '-')
for i, direction in enumerate("xyz")]
code = [
"auto const InitialisationAdditionalData = elementInitialiser(",
f"Cell({', '.join(cell_args)}), blocks, *block);",
"element.vel_0 = InitialisationAdditionalData[0];",
"element.vel_1 = InitialisationAdditionalData[1];",
"element.vel_2 = InitialisationAdditionalData[2];",
"auto const InitialisationAdditionalData = elementInitialiser(",
f"Cell({', '.join(cell_args)}), blocks, *block);",
"element.vel_0 = InitialisationAdditionalData[0];",
"element.vel_1 = InitialisationAdditionalData[1];",
"element.vel_2 = InitialisationAdditionalData[2];",
]
return "\n".join(code)

Expand Down
4 changes: 2 additions & 2 deletions src/core/unit_tests/p3m_test.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2010-2022 The ESPResSo project
* Copyright (C) 2020-2022 The ESPResSo project
*
* This file is part of ESPResSo.
*
Expand All @@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#define BOOST_TEST_MODULE p3m test
#define BOOST_TEST_MODULE "P3M utility functions"
#define BOOST_TEST_DYN_LINK
#include <boost/test/unit_test.hpp>

Expand Down
2 changes: 1 addition & 1 deletion src/shapes/include/shapes/Ellipsoid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#define SHAPES_ELLIPSOID_HPP

#include "Shape.hpp"
#include <utils/Array.hpp>

#include <utils/Vector.hpp>

namespace Shapes {
Expand Down
7 changes: 4 additions & 3 deletions src/shapes/src/HollowConicalFrustum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@
#include <shapes/HollowConicalFrustum.hpp>

#include <utils/Vector.hpp>
#include <utils/math/abs.hpp>
#include <utils/math/coordinate_transformation.hpp>

#include <cmath>

namespace Shapes {
void HollowConicalFrustum::calculate_dist(const Utils::Vector3d &pos,
double &dist,
Expand Down Expand Up @@ -70,7 +71,7 @@ void HollowConicalFrustum::calculate_dist(const Utils::Vector3d &pos,
*/

auto endpoint_angle = pos_phi;
if (Utils::abs(pos_phi) < m_central_angle / 2.) {
if (std::fabs(pos_phi) < m_central_angle / 2.) {
// Cannot use Utils::sgn because of pos_phi==0 corner case
endpoint_angle =
pos_phi > 0. ? m_central_angle / 2. : -m_central_angle / 2.;
Expand All @@ -93,7 +94,7 @@ void HollowConicalFrustum::calculate_dist(const Utils::Vector3d &pos,
/* It can be that the projection onto the (infinite) line is outside the
* frustum. In that case, the closest point is actually one of the endpoints.
*/
if (Utils::abs(pos_closest_hcf_frame[2]) > m_length / 2.) {
if (std::fabs(pos_closest_hcf_frame[2]) > m_length / 2.) {
pos_closest_hcf_frame =
pos_closest_hcf_frame[2] > 0. ? r1_endpoint : r2_endpoint;
}
Expand Down
60 changes: 42 additions & 18 deletions src/utils/include/utils/Vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include <initializer_list>
#include <iterator>
#include <numeric>
#include <span>
#include <type_traits>
#include <vector>

Expand Down Expand Up @@ -79,11 +80,21 @@ template <typename T, std::size_t N> class Vector : public Array<T, N> {

public:
template <class Range>
explicit Vector(Range const &rng) : Vector(std::begin(rng), std::end(rng)) {}
explicit Vector(Range const &rng)
: Vector(std::begin(rng), std::end(rng)) {}
explicit constexpr Vector(T const (&v)[N]) : Base() {
copy_init(std::begin(v), std::end(v));
}

explicit constexpr Vector(std::span<T> span) : Base() {
if (span.size() != N) {
throw std::length_error(
"Construction of Vector from Container of wrong length.");
}

copy_init(span.begin(), span.end());
}

constexpr Vector(std::initializer_list<T> v) : Base() {
if (N != v.size()) {
throw std::length_error(
Expand All @@ -103,26 +114,31 @@ template <typename T, std::size_t N> class Vector : public Array<T, N> {
}
}

/**
* @brief Create a vector that has all entries set to
* one value.
*/
static Vector<T, N> broadcast(T const &s) {
Vector<T, N> ret;
std::fill(ret.begin(), ret.end(), s);

/** @brief Create a vector that has all entries set to the same value. */
DEVICE_QUALIFIER static constexpr Vector<T, N>
broadcast(typename Base::value_type const &value) {
Vector<T, N> ret{};
for (std::size_t i = 0u; i != N; ++i) {
ret[i] = value;
}
return ret;
}

std::vector<T> as_vector() const { return std::vector<T>(begin(), end()); }

operator std::vector<T>() const { return as_vector(); }

constexpr std::span<T, N> as_span() const {
return std::span<T, N>(const_cast<T *>(begin()), size());
}

constexpr operator std::span<T, N>() const { return as_span(); }

template <class U> explicit operator Vector<U, N>() const {
Vector<U, N> ret;

std::transform(begin(), end(), ret.begin(),
[](auto e) { return static_cast<U>(e); });
[](auto const &e) { return static_cast<U>(e); });

return ret;
}
Expand All @@ -140,7 +156,7 @@ template <typename T, std::size_t N> class Vector : public Array<T, N> {
Vector &normalize() {
auto const l = norm();
if (l > T(0)) {
for (std::size_t i = 0; i < N; i++)
for (std::size_t i = 0u; i < N; ++i)
this->operator[](i) /= l;
}

Expand Down Expand Up @@ -247,8 +263,7 @@ template <std::size_t N, typename T>
Vector<T, N> operator-(Vector<T, N> const &a) {
Vector<T, N> ret;

std::transform(std::begin(a), std::end(a), std::begin(ret),
[](T const &v) { return -v; });
std::transform(std::begin(a), std::end(a), std::begin(ret), std::negate<T>());

return ret;
}
Expand Down Expand Up @@ -300,6 +315,15 @@ Vector<T, N> operator/(Vector<T, N> const &a, T const &b) {
return ret;
}

template <std::size_t N, typename T>
Vector<T, N> operator/(T const &a, Vector<T, N> const &b) {
Vector<T, N> ret;

std::transform(std::begin(b), std::end(b), ret.begin(),
[a](T const &val) { return a / val; });
return ret;
}

template <std::size_t N, typename T>
Vector<T, N> &operator/=(Vector<T, N> &a, T const &b) {
std::transform(std::begin(a), std::end(a), std::begin(a),
Expand Down Expand Up @@ -367,7 +391,7 @@ auto hadamard_product(Vector<T, N> const &a, Vector<U, N> const &b) {

Vector<R, N> ret;
std::transform(a.cbegin(), a.cend(), b.cbegin(), ret.begin(),
[](auto ai, auto bi) { return ai * bi; });
[](auto const &ai, auto const &bi) { return ai * bi; });

return ret;
}
Expand Down Expand Up @@ -410,7 +434,7 @@ auto hadamard_division(Vector<T, N> const &a, Vector<U, N> const &b) {

Vector<R, N> ret;
std::transform(a.cbegin(), a.cend(), b.cbegin(), ret.begin(),
[](auto ai, auto bi) { return ai / bi; });
[](auto const &ai, auto const &bi) { return ai / bi; });

return ret;
}
Expand Down Expand Up @@ -448,11 +472,11 @@ auto hadamard_division(T const &a, U const &b) {
}

template <typename T> Vector<T, 3> unit_vector(unsigned int i) {
if (i == 0)
if (i == 0u)
return {T{1}, T{0}, T{0}};
if (i == 1)
if (i == 1u)
return {T{0}, T{1}, T{0}};
if (i == 2)
if (i == 2u)
return {T{0}, T{0}, T{1}};
throw std::domain_error("coordinate out of range");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ESPRESSO_CYLINDER_TRANSFORMATION_PARAMETERS_HPP
#define ESPRESSO_CYLINDER_TRANSFORMATION_PARAMETERS_HPP

#pragma once

#include <cmath>
#include <limits>
#include <stdexcept>
#include <string>

#include <utils/math/abs.hpp>
#include <utils/math/orthonormal_vec.hpp>

namespace Utils {
Expand Down Expand Up @@ -63,30 +64,28 @@ class CylindricalTransformationParameters {

private:
void validate() const {
auto constexpr eps = 10 * std::numeric_limits<double>::epsilon();
if (Utils::abs(m_orientation * m_axis) > eps) {
auto constexpr eps = 10. * std::numeric_limits<double>::epsilon();
if (std::fabs(m_orientation * m_axis) > eps) {
throw std::runtime_error(
"CylindricalTransformationParameters: Axis and orientation must be "
"orthogonal. Scalar product is " +
std::to_string(m_orientation * m_axis));
}
if (Utils::abs(m_axis.norm() - 1) > eps) {
if (std::fabs(m_axis.norm() - 1.) > eps) {
throw std::runtime_error("CylindricalTransformationParameters: Axis must "
"be normalized. Norm is " +
std::to_string(m_axis.norm()));
}
if (Utils::abs(m_orientation.norm() - 1) > eps) {
if (std::fabs(m_orientation.norm() - 1.) > eps) {
throw std::runtime_error("CylindricalTransformationParameters: "
"orientation must be normalized. Norm is " +
std::to_string(m_orientation.norm()));
}
}

const Utils::Vector3d m_center{};
const Utils::Vector3d m_axis{0, 0, 1};
const Utils::Vector3d m_orientation{1, 0, 0};
Utils::Vector3d const m_center{};
Utils::Vector3d const m_axis{0., 0., 1.};
Utils::Vector3d const m_orientation{1., 0., 0.};
};

} // namespace Utils

#endif // ESPRESSO_CYLINDER_TRANSFORMATION_PARAMETERS_HPP
2 changes: 2 additions & 0 deletions src/utils/include/utils/math/sqr.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/*
* Copyright (C) 2010-2022 The ESPResSo project
* Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009,2010
* Max-Planck-Institute for Polymer Research, Theory Group
*
* This file is part of ESPResSo.
*
Expand Down
1 change: 1 addition & 0 deletions src/utils/include/utils/quaternion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include "utils/Array.hpp"
#include "utils/Vector.hpp"
#include "utils/matrix.hpp"
#include "utils/serialization/array.hpp"

#include <cassert>
#include <cstddef>
Expand Down
Loading

0 comments on commit 43e1466

Please sign in to comment.