1#ifndef UTOPIA_CORE_SPACE_HH
2#define UTOPIA_CORE_SPACE_HH
7#include <spdlog/spdlog.h>
9#include "../data_io/cfg_utils.hh"
26template<std::
size_t num_dims>
52 static_assert(
dim > 0,
"Space::dim needs to be >= 1");
64 static_assert(
dim > 0,
"Space::dim needs to be >= 1");
81 template<
bool include_high_value_boundary=true>
149 template<
class NormType=std::
size_t>
161 if (
not cfg[
"periodic"]) {
162 throw std::invalid_argument(
"Missing config entry `periodic` to "
163 "set up a Space object!");
190 if (
dim != cfg[
"extent"].size()) {
191 throw std::invalid_argument(fmt::format(
192 "Invalid size of `space.extent` sequence ({}) for "
193 "selected space dimensionality ({})!",
194 cfg[
"extent"].size(),
dim
200 if (
ext.min() <= 0.) {
201 ext.print(
"Invalid `space.extent`:");
202 throw std::invalid_argument(
203 "The space extent needs to be strictly positive in "
204 "all entries, but it contained at least one element <= 0! "
205 "Check the `space.extent` config node to address this."
Container select_entities(const Manager &mngr, const DataIO::Config &sel_cfg)
Select entities according to parameters specified in a configuration.
Definition select.hh:213
DataIO::Config Config
Type of a variadic dictionary-like data structure used throughout Utopia.
Definition types.hh:80
arma::Col< double >::fixed< dim > SpaceVecType
Type for vector-like data that is associated with a physical space.
Definition types.hh:61
The Space bundles properties about the physical space a model resides in.
Definition space.hh:27
SpaceVec map_into_space(const SpaceVec &pos) const
Map a position (potentially outside space's extent) back into space.
Definition space.hh:103
SpaceVecType< dim > SpaceVec
The type for vectors relating to physical space.
Definition space.hh:33
Space()
Default constructor i.e. constructing a space with default parameters.
Definition space.hh:59
SpaceVec setup_extent(const Config &cfg) const
Construct a space extent vector from a config node.
Definition space.hh:182
auto distance(const SpaceVec &pos_0, const SpaceVec &pos_1, const NormType p=2) const
The distance of two coordinates in space.
Definition space.hh:150
SpaceVec displacement(const SpaceVec &pos_0, const SpaceVec &pos_1) const
Compute the displacement vector between two coordinates.
Definition space.hh:124
SpaceVec setup_extent() const
Construct a default space extent vector (valued 1 in each dimension)
Definition space.hh:169
bool setup_periodic(const Config &cfg) const
Setup the member periodic from a config node.
Definition space.hh:160
bool contains(const SpaceVec &pos) const
Whether this space contains the given coordinate (without mapping it)
Definition space.hh:82
const SpaceVec extent
The physical (euclidean) extent of the space.
Definition space.hh:39
Space(const Config &cfg)
Construct a Space using information from a config node.
Definition space.hh:47
const bool periodic
Whether the space is to be assumed periodic.
Definition space.hh:36
static constexpr std::size_t dim
The dimensionality of the space.
Definition space.hh:30