37 result = makeAuto<SphericalDomain>(
Vector(0._f), radius);
43 [](
const std::string& name) {
return makeAuto<SphereJob>(name); },
44 "Geometric shape representing a sphere with given radius.");
55 geoCat.
connect(
"Dimensions [km]",
"dimensions", dimensions).
setUnits(1.e3_f);
60 result = makeAuto<BlockDomain>(center, dimensions);
66 [](
const std::string& name) {
return makeAuto<BlockJob>(name); },
67 "Geometric shape representing a block with given dimensions.");
82 result = makeAuto<EllipsoidalDomain>(
Vector(0._f), semiaxes);
88 [](
const std::string& name) {
return makeAuto<EllipsoidJob>(name); },
89 "Geometric shape representing a triaxial ellipsoid.");
116 result = makeAuto<CylindricalDomain>(
Vector(0._f), radius, height,
true);
122 [](
const std::string& name) {
return makeAuto<CylinderJob>(name); },
123 "Geometric shape representing a cylinder aligned with z-axis, using provided radius and height.");
131 static Float evalMaclaurinFormula(
const Float e) {
133 6._f /
sqr(e) * (1._f -
sqr(e));
140 geoCat.
connect(
"Semi-major axis [km]",
"semimajor", semimajorAxis).
setUnits(1.e3_f);
141 geoCat.
connect(
"Spin rate [rev/day]",
"spinRate", spinRate).
setUnits(2._f *
PI / (3600._f * 24._f));
142 geoCat.
connect(
"Density [kg/m^3]",
"density", density);
148 const Float e_max = 0.812670_f;
152 throw InvalidSetup(
"Failed to calculate the eccentricity of Maclaurin spheroid");
154 const Float a = semimajorAxis;
160 "Maclaurin spheroid",
163 [](
const std::string& name) {
return makeAuto<MaclaurinSpheroidJob>(name); },
164 "Creates a Maclaurin spheroid, given the density and the spin rate of the body.");
177 result = makeAuto<HalfSpaceDomain>();
183 [](
const std::string& name) {
return makeAuto<HalfSpaceJob>(name); },
184 "Represents a half space z>0. Note that this cannot be used as a domain for generating particles as the "
185 "volume of the domain is infinite. It can be used as an input to a composite domain (boolean, etc.) or "
186 "as a domain for boundary conditions of a simulation.");
198 geoCat.
connect(
"Variance",
"variance", beta);
199 geoCat.
connect(
"Random seed",
"seed", seed);
204 result = makeAuto<GaussianRandomSphere>(
Vector(0._f), radius, beta, seed);
210 [](
const std::string& name) {
return makeAuto<GaussianSphereJob>(name); },
221 return "triangle mesh";
232 pathCat.
connect(
"Path",
"path", path)
235 {
"Wavefront OBJ file",
"obj" },
236 {
"Stanford PLY file",
"ply" },
238 pathCat.
connect(
"Scaling factor",
"scale", scale);
239 pathCat.
connect(
"Precompute",
"precompute", precompute);
254 result = makeAuto<MeshDomain>(*scheduler, std::move(triangles.
value()), params);
261 [](
const std::string& name) {
return makeAuto<MeshGeometryJob>(name); },
262 "Geometric shape given by provided triangular mesh.");
272 pathCat.
connect(
"Spatial resolution [m]",
"resolution", resolution);
273 pathCat.
connect(
"Iso-surface value",
"level", surfaceLevel);
278 Storage input = std::move(this->getInput<ParticleData>(
"particles")->storage);
296 result = makeAuto<MeshDomain>(*scheduler, std::move(triangles));
303 [](
const std::string& name) {
return makeAuto<ParticleGeometryJob>(name); },
304 "Geometric shape represented by input particles");
319 for (
Size i = 0; i < r.
size(); ++i) {
320 spheres[i] =
Sphere(r[i], r[i][
H]);
327 return boundingBox.
center();
336 for (
const Sphere& s : spheres) {
337 volume += s.volume();
344 for (
const Sphere& s : spheres) {
354 for (
const Sphere& s : spheres) {
388 result = makeShared<SpheresDomain>(r);
395 [](
const std::string& name) {
return makeAuto<SpheresGeometryJob>(name); },
396 "Geometric shape given by a set of spheres, specifies by the input particles.");
435 return domain->
getSubset(vs, output, invertedType);
440 for (
Float& dist : distances) {
462 result = makeShared<InvertDomain>(domain);
469 [](
const std::string& name) {
return makeAuto<InvertGeometryJob>(name); },
470 "Shape modifier that inverts the geometry, i.e. swaps the outside and inside of a shape. This converts a "
471 "sphere into a space with spherical hole, etc.");
483 transformCat.
connect(
"Scaling",
"scaling", scaling);
484 transformCat.
connect(
"Offset",
"offset", offset);
495 result = makeShared<TransformedDomain>(domain, matrix);
499 "transform geometry",
502 [](
const std::string& name) {
return makeAuto<TransformGeometryJob>(name); },
503 "Shape modifier, adding a translation and scaling to the input geometry.");
532 const Size N = 100000;
535 for (
Size i = 0; i <
N; ++i) {
542 if (volume == 0._f) {
579 const Vector v2 = v1 - offset;
597 for (
Size i = 0; i < vs.
size(); ++i) {
604 for (
Size i = 0; i < vs.
size(); ++i) {
629 const Float eps)
const override {
651 boolCat.
connect(
"Operation",
"operation", mode);
660 [](
const std::string& name) {
return makeAuto<BooleanGeometryJob>(name); },
661 "Composite shape that applies given boolean operation to two input shapes.");
#define NOT_IMPLEMENTED
Helper macro marking missing implementation.
@ INSIDE
Marks all vectors inside of the domain.
@ OUTSIDE
Marks all vectors outside of the domain.
INLINE Optional< Float > getRoot(const Interval &range, const Float eps, const TFunctor &functor)
Returns a root of a R->R function on given range.
INLINE Float maxElement(const T &value)
Returns maximum element, simply the value iself by default.
uint32_t Size
Integral type used to index arrays (by default).
double Float
Precision used withing the code. Use Float instead of float or double where precision is important.
Basic interface defining a single run.
VirtualSettings::Category & addGenericCategory(VirtualSettings &connector, std::string &instanceName)
Adds a common settings category, used by all jobs.
Array< Triangle > getSurfaceMesh(IScheduler &scheduler, const Storage &storage, const McConfig &config)
Returns the triangle mesh of the body surface (or surfaces of bodies).
constexpr INLINE T clamp(const T &f, const T &f1, const T &f2)
constexpr INLINE T sqr(const T &f) noexcept
Return a squared value.
INLINE T sqrt(const T f)
Return a squared root of a value.
constexpr INLINE Float pow< 3 >(const Float v)
constexpr INLINE Float sphereSurfaceArea(const Float radius)
Computes a surface area of a sphere given its radius.
constexpr Float PI
Mathematical constants.
Domain represented by triangular mesh.
AutoPtr< IMeshFile > getMeshFile(const Path &path)
Deduces mesh type from extension of given path.
#define NAMESPACE_SPH_END
@ POSITION
Positions (velocities, accelerations) of particles, always a vector quantity,.
Object representing a three-dimensional sphere.
Box getBoundingBox(const Storage &storage, const Float radius)
Convenience function to get the bounding box of all particles.
Objects for generating random vectors.
BasicVector< Float > Vector
static AffineMatrix identity()
static AffineMatrix scale(const Vector &scaling)
INLINE AffineMatrix & translate(const Vector &t)
Object providing safe access to continuous memory of data.
INLINE TCounter size() const
void resize(const TCounter newSize)
Resizes the array to new size.
INLINE void push(U &&u)
Adds new element to the end of the array, resizing the array if necessary.
Wrapper of pointer that deletes the resource from destructor.
virtual void evaluate(const RunSettings &global, IRunCallbacks &UNUSED(callbacks)) override
virtual VirtualSettings getSettings() override
Returns a settings object which allows to query and modify the state of the job.
BooleanDomain(SharedPtr< IDomain > operA, SharedPtr< IDomain > operB, const Vector &offset, const BooleanEnum mode)
virtual void getDistanceToBoundary(ArrayView< const Vector >, Array< Float > &) const override
Returns distances of particles lying close to the boundary.
virtual Float getSurfaceArea() const override
Returns the surface area of the domain.
virtual void getSubset(ArrayView< const Vector > vs, Array< Size > &output, const SubsetType type) const override
Returns an array of indices, marking vectors with given property by their index.
virtual Box getBoundingBox() const override
Returns the bounding box of the domain.
virtual bool contains(const Vector &v1) const override
Checks if the given point lies inside the domain.
virtual Vector getCenter() const override
Returns the center of the domain.
virtual void project(ArrayView< Vector > vs, Optional< ArrayView< Size >> indices) const override
Projects vectors outside of the domain onto its boundary.
virtual Float getVolume() const override
Returns the total volume of the domain.
virtual void addGhosts(ArrayView< const Vector > vs, Array< Ghost > &ghosts, const Float eta, const Float eps) const override
Duplicates positions located close to the boundary, placing copies ("ghosts") symmetrically to the ot...
virtual void evaluate(const RunSettings &global, IRunCallbacks &callbacks) override
Runs the operation provided by the job.
virtual VirtualSettings getSettings() override
Returns a settings object which allows to query and modify the state of the job.
Helper object defining three-dimensional interval (box).
INLINE Box translate(const Vector &offset) const
Returns a box with specified offset.
INLINE void extend(const Vector &v)
Enlarges the box to contain the vector.
INLINE const Vector & lower() const
Returns lower bounds of the box.
INLINE Vector center() const
Returns the center of the box.
INLINE bool contains(const Vector &v) const
Checks if the vector lies inside the box.
INLINE Vector size() const
Returns box dimensions.
INLINE Box intersect(const Box &other) const
Computes the intersection of this box with another one.
INLINE Float volume() const
Returns the volume of the box.
static Box EMPTY()
Syntactic sugar, returns a default-constructed (empty) box.
virtual std::string className() const override
Name representing the type of the job (e.e. "SPH").
virtual VirtualSettings getSettings() override
Returns a settings object which allows to query and modify the state of the job.
virtual UnorderedMap< std::string, ExtJobType > getSlots() const override
Lists all potential inputs of the job.
CylinderJob(const std::string &name)
virtual void evaluate(const RunSettings &global, IRunCallbacks &UNUSED(callbacks)) override
virtual VirtualSettings getSettings() override
Returns a settings object which allows to query and modify the state of the job.
virtual void evaluate(const RunSettings &global, IRunCallbacks &UNUSED(callbacks)) override
EntryControl & setPathType(const PathType &newType)
Sets the type of the path.
EntryControl & setUnits(const Float newMult)
Sets units in which the entry is stored.
EntryControl & setFileFormats(Array< FileFormat > &&formats)
Sets the allowed file formats.
Wrapper of type that either contains a value of given type, or an error message.
Type & value()
Returns the reference to expected value.
virtual void evaluate(const RunSettings &global, IRunCallbacks &UNUSED(callbacks)) override
virtual VirtualSettings getSettings() override
Returns a settings object which allows to query and modify the state of the job.
virtual VirtualSettings getSettings() override
Returns a settings object which allows to query and modify the state of the job.
virtual void evaluate(const RunSettings &global, IRunCallbacks &UNUSED(callbacks)) override
Base class for computational domains.
virtual Float getSurfaceArea() const =0
Returns the surface area of the domain.
virtual void getSubset(ArrayView< const Vector > vs, Array< Size > &output, const SubsetType type) const =0
Returns an array of indices, marking vectors with given property by their index.
virtual void getDistanceToBoundary(ArrayView< const Vector > vs, Array< Float > &distances) const =0
Returns distances of particles lying close to the boundary.
virtual Box getBoundingBox() const =0
Returns the bounding box of the domain.
virtual void project(ArrayView< Vector > vs, Optional< ArrayView< Size >> indices=NOTHING) const =0
Projects vectors outside of the domain onto its boundary.
virtual void addGhosts(ArrayView< const Vector > vs, Array< Ghost > &ghosts, const Float eta=2._f, const Float eps=0.05_f) const =0
Duplicates positions located close to the boundary, placing copies ("ghosts") symmetrically to the ot...
virtual bool contains(const Vector &v) const =0
Checks if the given point lies inside the domain.
virtual Vector getCenter() const =0
Returns the center of the domain.
Base class for jobs providing a geometric shape.
SharedPtr< IDomain > result
Data filled by the job when it finishes.
Callbacks executed by the simulation to provide feedback to the user.
virtual bool shouldAbortRun() const =0
Returns whether current run should be aborted or not.
virtual void onTimeStep(const Storage &storage, Statistics &stats)=0
Called every timestep.
Object representing a 1D interval of real numbers.
Thrown when components of the run are mutually incompatible.
InvertDomain(SharedPtr< IDomain > domain)
virtual void getSubset(ArrayView< const Vector > vs, Array< Size > &output, const SubsetType type) const override
Returns an array of indices, marking vectors with given property by their index.
virtual void project(ArrayView< Vector >, Optional< ArrayView< Size >>) const override
Projects vectors outside of the domain onto its boundary.
virtual void addGhosts(ArrayView< const Vector >, Array< Ghost > &, const Float, const Float) const override
Duplicates positions located close to the boundary, placing copies ("ghosts") symmetrically to the ot...
virtual Box getBoundingBox() const override
Returns the bounding box of the domain.
virtual void getDistanceToBoundary(ArrayView< const Vector > vs, Array< Float > &distances) const override
Returns distances of particles lying close to the boundary.
virtual bool contains(const Vector &v) const override
Checks if the given point lies inside the domain.
virtual Float getSurfaceArea() const override
Returns the surface area of the domain.
virtual Vector getCenter() const override
Returns the center of the domain.
virtual Float getVolume() const override
Returns the total volume of the domain.
virtual void evaluate(const RunSettings &global, IRunCallbacks &callbacks) override
Runs the operation provided by the job.
virtual VirtualSettings getSettings() override
Returns a settings object which allows to query and modify the state of the job.
virtual void evaluate(const RunSettings &global, IRunCallbacks &UNUSED(callbacks)) override
virtual VirtualSettings getSettings() override
Returns a settings object which allows to query and modify the state of the job.
virtual VirtualSettings getSettings() override
Returns a settings object which allows to query and modify the state of the job.
MeshGeometryJob(const std::string &name)
virtual UnorderedMap< std::string, ExtJobType > getSlots() const override
Lists all potential inputs of the job.
virtual std::string className() const override
Name representing the type of the job (e.e. "SPH").
virtual void evaluate(const RunSettings &global, IRunCallbacks &callbacks) override
Runs the operation provided by the job.
INLINE Type & value()
Returns the reference to the stored value.
virtual void evaluate(const RunSettings &global, IRunCallbacks &callbacks) override
Runs the operation provided by the job.
virtual VirtualSettings getSettings() override
Returns a settings object which allows to query and modify the state of the job.
std::string native() const
Returns the native version of the path.
virtual UnorderedMap< std::string, ExtJobType > getSlots() const override
Lists all potential inputs of the job.
SphereJob(const std::string &name)
virtual void evaluate(const RunSettings &global, IRunCallbacks &callbacks) override
Runs the operation provided by the job.
virtual VirtualSettings getSettings() override
Returns a settings object which allows to query and modify the state of the job.
virtual std::string className() const override
Name representing the type of the job (e.e. "SPH").
virtual bool contains(const Vector &v) const override
Checks if the given point lies inside the domain.
SpheresDomain(ArrayView< const Vector > r)
virtual Float getSurfaceArea() const override
Returns the surface area of the domain.
virtual Float getVolume() const override
Returns the total volume of the domain.
virtual void project(ArrayView< Vector >, Optional< ArrayView< Size >>) const override
Projects vectors outside of the domain onto its boundary.
virtual void addGhosts(ArrayView< const Vector >, Array< Ghost > &, const Float, const Float) const override
Duplicates positions located close to the boundary, placing copies ("ghosts") symmetrically to the ot...
virtual Vector getCenter() const override
Returns the center of the domain.
virtual Box getBoundingBox() const override
Returns the bounding box of the domain.
virtual void getSubset(ArrayView< const Vector >, Array< Size > &, const SubsetType) const override
Returns an array of indices, marking vectors with given property by their index.
virtual void getDistanceToBoundary(ArrayView< const Vector >, Array< Float > &) const override
Returns distances of particles lying close to the boundary.
virtual VirtualSettings getSettings() override
Returns a settings object which allows to query and modify the state of the job.
virtual void evaluate(const RunSettings &global, IRunCallbacks &callbacks) override
Runs the operation provided by the job.
Object holding various statistics about current run.
Statistics & set(const StatisticsId idx, TValue &&value)
Sets new values of a statistic.
Container storing all quantities used within the simulations.
Array< TValue > & getValue(const QuantityId key)
Retrieves a quantity values from the storage, given its key and value type.
Wrapper for generating random vectors.
EntryControl & connect(const std::string &name, const std::string &key, TValue &value)
Connects to given reference.
Holds a map of virtual entries, associated with a unique name.
Category & addCategory(const std::string &name)
Creates a new category of entries.
Creating code components based on values from settings.
constexpr Float gravity
Gravitational constant (CODATA 2014)
SharedPtr< IScheduler > getScheduler(const RunSettings &settings=RunSettings::getDefaults())
Helper class, allowing to register job into the global list of jobs.
Function< bool(Float progress)> progressCallback
Generic functor called during MC evaluation.
Float smoothingMult
Multiplier of the smoothing lengths.
Float gridResolution
Absolute size of each produced triangle.
bool precomputeInside
If true, cached volume is created to allow fast calls of contains.
AffineMatrix matrix
Arbitrary transformation matrix applied on the mesh.
Storage storage
Holds all particle positions and other quantities.