Skip to content

Commit

Permalink
improved configure output
Browse files Browse the repository at this point in the history
  • Loading branch information
clonker committed Jan 23, 2018
1 parent 14a4ddc commit 0f1a59e
Show file tree
Hide file tree
Showing 46 changed files with 307 additions and 136 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ install:
- if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then export BUILD_TYPE="RelWithDebInfo"; else export BUILD_TYPE="Release"; fi

script:
- conda-build --version
- conda build -c conda-forge -q tools/conda-recipe

after_success:
Expand Down
2 changes: 2 additions & 0 deletions include/readdy/api/ObservableHandle.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ class ObservableHandle {
*/
observable_id getId() const;

std::string getType() const;

/**
* Triggers a flush, i.e., everything that can be written will be written
*/
Expand Down
21 changes: 17 additions & 4 deletions include/readdy/api/SimulationScheme.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,13 @@ class SimulationScheme {
*/
virtual void run(time_step_type steps) {
// show every 100 time steps
const auto progressOutputStride = 100;
if(!_updateCallback) {
_updateCallback = [this, steps, progressOutputStride](time_step_type current) {
_updateCallback = [this, steps](time_step_type current) {
log::info("Simulation progress: {} / {} steps", (current - start), steps);
};
}
auto defaultContinueCriterion = [this, steps, progressOutputStride](const time_step_type current) {
if (progressOutputStride > 0 && (current - start) % progressOutputStride == 0) {
auto defaultContinueCriterion = [this, steps](const time_step_type current) {
if (current != start && _progressOutputStride > 0 && (current - start) % _progressOutputStride == 0) {
_updateCallback(current);
}
return current < start + steps;
Expand All @@ -122,6 +121,16 @@ class SimulationScheme {
return _updateCallback;
}

/**
* show progress every N steps
* @return N steps
*/
std::size_t &progressOutputStride() {
return _progressOutputStride;
}



protected:
template<typename SchemeType>
friend class SchemeConfigurator;
Expand Down Expand Up @@ -174,6 +183,10 @@ class SimulationScheme {
* the starting point
*/
time_step_type start = 0;
/**
* show progress every N steps
*/
std::size_t _progressOutputStride = 100;
/**
* cref to the performance root node
*/
Expand Down
7 changes: 7 additions & 0 deletions include/readdy/api/bits/ObservableHandle_misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,11 @@ inline void ObservableHandle::flush() {

inline ObservableHandle::ObservableHandle() : ObservableHandle(0, nullptr) { }

inline std::string ObservableHandle::getType() const {
if(observable) {
return observable->type();
}
throw std::runtime_error("No observable attached to this handle, therefore no type");
}

NAMESPACE_END(readdy)
27 changes: 21 additions & 6 deletions include/readdy/common/ReaDDyVec3.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@
#include <array>
#include <cmath>
#include <string>
#include <ostream>
#include <algorithm>
#include <type_traits>
#include <sstream>
#include <ostream>
#include "Index.h"
#include "FloatingPoints.h"

Expand All @@ -59,7 +60,7 @@ class ReaDDyMatrix {
}

template<typename... T, typename = typename std::enable_if_t<sizeof...(T) == N*M>>
ReaDDyMatrix(T &&... elems) : _data{{static_cast<scalar>(std::forward<T>(elems))...}} {}
explicit ReaDDyMatrix(T &&... elems) : _data{{static_cast<scalar>(std::forward<T>(elems))...}} {}

explicit ReaDDyMatrix(data_arr data) : _data(data) {}

Expand Down Expand Up @@ -102,9 +103,10 @@ class ReaDDyMatrix {
return *this;
}

friend ReaDDyMatrix operator+(ReaDDyMatrix lhs, const ReaDDyMatrix &rhs) {
lhs += rhs;
return lhs;
friend ReaDDyMatrix operator+(const ReaDDyMatrix &lhs, const ReaDDyMatrix &rhs) {
ReaDDyMatrix copy(lhs);
copy += rhs;
return copy;
}

template<typename arithmetic, typename detail::is_arithmetic_type<arithmetic> = 0>
Expand Down Expand Up @@ -133,6 +135,19 @@ class ReaDDyMatrix {
return _data != rhs._data;
}

friend std::ostream &operator<<(std::ostream &os, const ReaDDyMatrix &matrix) {
std::stringstream ss;
ss << "Matrix " << ReaDDyMatrix::n() << " x " << ReaDDyMatrix::m() << ": " << std::endl;
for(index_type i = 0; i < ReaDDyMatrix::n(); ++i) {
for(index_type j = 0; j < ReaDDyMatrix::m(); ++j) {
ss << matrix.at(i, j) << " ";
}
ss << std::endl;
}
os << ss.str();
return os;
}

private:
data_arr _data;
util::Index2D _index{static_cast<std::size_t>(N), static_cast<std::size_t>(M)};
Expand Down Expand Up @@ -245,7 +260,7 @@ class READDY_API ReaDDyVec3 {
}

friend std::ostream &operator<<(std::ostream &os, const ReaDDyVec3 &vec) {
os << "ReaDDyVec3(" << vec[0] << ", " << vec[1] << ", " << vec[2] << ")";
os << "(" << vec[0] << ", " << vec[1] << ", " << vec[2] << ")";
return os;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class SCPUCalculateForces : public readdy::model::actions::CalculateForces {
auto &neighborList = *stateModel.getNeighborList();

stateModel.energy() = 0;
stateModel.virial() = {0, 0, 0, 0, 0, 0, 0, 0, 0};
stateModel.virial() = Matrix33{0, 0, 0, 0, 0, 0, 0, 0, 0};

const auto &potentials = context.potentials();
auto &topologies = stateModel.topologies();
Expand Down
4 changes: 4 additions & 0 deletions include/readdy/model/_internal/ObservableWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ class ObservableWrapper : public ObservableBase {
throw std::runtime_error("not supported");
}

std::string type() const override {
throw std::runtime_error("not supported");
}

protected:
void initializeDataSet(File &file, const std::string &dataSetName, unsigned int flushStride) override {
throw std::runtime_error("not supported");
Expand Down
10 changes: 8 additions & 2 deletions include/readdy/model/observables/Aggregators.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,16 @@ NAMESPACE_BEGIN(observables)
class MeanSquaredDisplacement
: public Combiner<std::pair<std::vector<time_step_type>, std::vector<scalar>>, Particles> {
public:
MeanSquaredDisplacement(Kernel* kernel, stride_type stride, std::vector<std::string> typesToCount,
MeanSquaredDisplacement(Kernel *kernel, stride_type stride, std::vector<std::string> typesToCount,
Particles *particlesObservable);

MeanSquaredDisplacement(Kernel* kernel, stride_type stride, const std::vector<particle_type_type> &typesToCount,
MeanSquaredDisplacement(Kernel *kernel, stride_type stride, const std::vector<particle_type_type> &typesToCount,
Particles *particlesObservable);

void evaluate() override = 0;

std::string type() const override;

protected:
std::vector<particle_type_type> typesToCount;
};
Expand Down Expand Up @@ -77,6 +79,10 @@ class Trivial
resultTimes.push_back(this->currentTimeStep());
resultValues.push_back(currentInput);
};

std::string type() const override {
return "Trivial";
}
};

NAMESPACE_END(observables)
Expand Down
2 changes: 2 additions & 0 deletions include/readdy/model/observables/Energy.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ class Energy : public Observable<scalar> {

void evaluate() override;

std::string type() const override;

private:
struct Impl;
std::unique_ptr<Impl> pimpl;
Expand Down
2 changes: 2 additions & 0 deletions include/readdy/model/observables/Forces.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ class Forces : public Observable<std::vector<Vec3>> {

virtual ~Forces();

std::string type() const override;

void flush() override;

protected:
Expand Down
2 changes: 2 additions & 0 deletions include/readdy/model/observables/HistogramAlongAxis.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ class HistogramAlongAxis : public Observable<std::vector<scalar>> {

virtual ~HistogramAlongAxis();

std::string type() const override;

protected:
struct Impl;
std::unique_ptr<Impl> pimpl;
Expand Down
3 changes: 3 additions & 0 deletions include/readdy/model/observables/NParticles.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ class NParticles : public Observable<std::vector<unsigned long>> {
NParticles(Kernel* kernel, stride_type stride, std::vector<particle_type_type> typesToCount);

NParticles(const NParticles&) = delete;

std::string type() const override;

NParticles& operator=(const NParticles&) = delete;
NParticles(NParticles&&) = default;
NParticles& operator=(NParticles&&) = delete;
Expand Down
2 changes: 2 additions & 0 deletions include/readdy/model/observables/Observable.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ class ObservableBase {
*/
virtual void flush() = 0;

virtual std::string type() const = 0;

protected:
friend class readdy::model::Kernel;

Expand Down
2 changes: 2 additions & 0 deletions include/readdy/model/observables/Particles.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ class Particles

void flush() override;

std::string type() const override;

protected:
void initializeDataSet(File &file, const std::string &dataSetName, stride_type flushStride) override;

Expand Down
5 changes: 5 additions & 0 deletions include/readdy/model/observables/Positions.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ class Positions : public Observable<std::vector<Vec3>> {

void append() override;

public:
std::string type() const override;

protected:

std::vector<particle_type_type> typesToCount;

struct Impl;
Expand Down
2 changes: 2 additions & 0 deletions include/readdy/model/observables/RadialDistribution.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ class RadialDistribution : public Observable<std::pair<std::vector<scalar>, std:

const std::vector<scalar> &getBinBorders() const;

std::string type() const override;

void evaluate() override;

void flush() override;
Expand Down
2 changes: 2 additions & 0 deletions include/readdy/model/observables/ReactionCounts.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ class ReactionCounts : public Observable<reactions::reaction_counts_map> {

void flush() override;

std::string type() const override;


protected:
void initialize(Kernel *kernel) override;
Expand Down
2 changes: 2 additions & 0 deletions include/readdy/model/observables/Reactions.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ class Reactions : public Observable<std::vector<reactions::ReactionRecord>> {

virtual ~Reactions();

std::string type() const override;

void flush() override;

protected:
Expand Down
2 changes: 2 additions & 0 deletions include/readdy/model/observables/Virial.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ class Virial : public Observable<Matrix33> {

~Virial();

std::string type() const override;

void flush() override;

protected:
Expand Down
4 changes: 4 additions & 0 deletions include/readdy/model/observables/io/Trajectory.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ class Trajectory : public Observable<std::vector<TrajectoryEntry>> {

virtual void flush() override;

std::string type() const override;

protected:
void initializeDataSet(File &file, const std::string &dataSetName, unsigned int flushStride) override;

Expand All @@ -84,6 +86,8 @@ class FlatTrajectory : public Observable<std::vector<TrajectoryEntry>> {

virtual void flush() override;

std::string type() const override;

protected:
void initializeDataSet(File &file, const std::string &dataSetName, unsigned int flushStride) override;

Expand Down
2 changes: 0 additions & 2 deletions include/readdy/model/potentials/PotentialsOrder2.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,6 @@ class WeakInteractionPiecewiseHarmonic : public PotentialOrder2 {
public:
Configuration(scalar desiredParticleDistance, scalar depthAtDesiredDistance, scalar noInteractionDistance);

friend std::ostream &operator<<(std::ostream &os, const Configuration &configuration);

private:
friend class WeakInteractionPiecewiseHarmonic;

Expand Down
4 changes: 2 additions & 2 deletions include/readdy/model/potentials/misc/PotentialRegistry_misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ inline std::string PotentialRegistry::describe() const {
if (!potentialsOrder1().empty()) {
description += fmt::format(" - potentials of order 1:{}", rus::newline);
for (const auto &types : potentialsOrder1()) {
description += fmt::format(" * for type {}{}", find_pot_name(types.first), rus::newline);
description += fmt::format(" * for type \"{}\"{}", find_pot_name(types.first), rus::newline);
for (auto pot : types.second) {
description += fmt::format(" * {}{}", pot->describe(), rus::newline);
}
Expand All @@ -146,7 +146,7 @@ inline std::string PotentialRegistry::describe() const {
if (!potentialsOrder2().empty()) {
description += fmt::format(" - potentials of order 2:{}", rus::newline);
for (const auto &types : potentialsOrder2()) {
description += fmt::format(" * for types {} and {}{}", find_pot_name(std::get<0>(types.first)),
description += fmt::format(" * for types \"{}\" and \"{}\"{}", find_pot_name(std::get<0>(types.first)),
find_pot_name(std::get<1>(types.first)), rus::newline);
for (auto pot : types.second) {
description += fmt::format(" * {}{}", pot->describe(), rus::newline);
Expand Down
8 changes: 8 additions & 0 deletions include/readdy/model/topologies/TopologyRegistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,14 @@ class TopologyRegistry {
const util::particle_type_pair &types_to, const topology_type_pair &topology_types_to,
scalar rate, scalar radius, reactions::STRMode mode);

std::size_t nStructuralReactions() const {
return std::accumulate(_registry.begin(), _registry.end(), 0_z,
[](std::size_t current, const type_registry::const_iterator::value_type &other) {
return current + other.second.structural_reactions.size();
}
);
}

/**
* Convenience function for adding spatial reaction.
*
Expand Down
2 changes: 1 addition & 1 deletion kernels/cpu/src/CPUKernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void CPUKernel::initialize() {
}
_stateModel.reactionRecords().clear();
_stateModel.resetReactionCounts();
_stateModel.virial() = {0, 0, 0, 0, 0, 0, 0, 0, 0};
_stateModel.virial() = Matrix33{0, 0, 0, 0, 0, 0, 0, 0, 0};
}

}
Expand Down
2 changes: 1 addition & 1 deletion kernels/cpu/src/actions/CPUCalculateForces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void CPUCalculateForces::perform(const util::PerformanceNode &node) {
auto &topologies = stateModel.topologies();

stateModel.energy() = 0;
stateModel.virial() = {0, 0, 0, 0, 0, 0, 0, 0, 0};
stateModel.virial() = Matrix33{0, 0, 0, 0, 0, 0, 0, 0, 0};

const auto &potOrder1 = ctx.potentials().potentialsOrder1();
const auto &potOrder2 = ctx.potentials().potentialsOrder2();
Expand Down
2 changes: 1 addition & 1 deletion kernels/singlecpu/src/SCPUKernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void SCPUKernel::initialize() {
}
getSCPUKernelStateModel().reactionRecords().clear();
getSCPUKernelStateModel().resetReactionCounts();
getSCPUKernelStateModel().virial() = {0, 0, 0, 0, 0, 0, 0, 0, 0};
getSCPUKernelStateModel().virial() = Matrix33{0, 0, 0, 0, 0, 0, 0, 0, 0};
}

}
Expand Down
2 changes: 1 addition & 1 deletion kernels/singlecpu/test/TestNeighborList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ TEST_P(TestSCPUNeighborList, Diffuse) {
auto n_steps = 3U;
auto n_particles = 1000;
#else
auto n_steps = 20U;
auto n_steps = 5U;
auto n_particles = 3000;
#endif

Expand Down
4 changes: 4 additions & 0 deletions readdy/main/model/Aggregators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ MeanSquaredDisplacement::MeanSquaredDisplacement(Kernel *const kernel, stride_ty
Particles *particlesObservable)
: Combiner(kernel, stride, particlesObservable), typesToCount(std::move(typesToCount)) {}

std::string MeanSquaredDisplacement::type() const {
return "Mean squared displacement";
}

}
}
}
Loading

0 comments on commit 0f1a59e

Please sign in to comment.