SPH
IMaterial.cpp
Go to the documentation of this file.
1 #include "quantities/IMaterial.h"
2 #include "sph/kernel/Kernel.h"
3 #include "system/Factory.h"
4 
6 
9 
11  rng = Factory::getRng(settings);
12  scheduler = Factory::getScheduler(settings);
13  kernelRadius = Factory::getKernel<3>(settings).radius();
14  uvMap = Factory::getUvMapping(settings);
15 }
16 
17 void IMaterial::setRange(const QuantityId id, const Interval& range, const Float minimal) {
18  if (range == DEFAULT_RANGE) {
19  // for unbounded range, we don't have to store the value (unbounded range is default)
20  ranges.tryRemove(id);
21  } else {
22  ranges.insert(id, range);
23  }
24 
25  if (minimal == DEFAULT_MINIMAL) {
26  // same thing with minimals - no need to store 0
27  minimals.tryRemove(id);
28  } else {
29  minimals.insert(id, minimal);
30  }
31 }
32 
33 
NAMESPACE_SPH_BEGIN
Definition: BarnesHut.cpp:13
double Float
Precision used withing the code. Use Float instead of float or double where precision is important.
Definition: Globals.h:13
Base class for all particle materials.
SPH kernels.
#define NAMESPACE_SPH_END
Definition: Object.h:12
QuantityId
Unique IDs of basic quantities of SPH particles.
Definition: QuantityIds.h:19
INLINE bool tryRemove(const TKey &key)
Removes element with given key if present, otherwise it does nothing.
Definition: FlatMap.h:99
INLINE TValue & insert(const TKey &key, const TValue &value)
Adds a new element into the map or sets new value of element with the same key.
Definition: FlatMap.h:65
FlatMap< QuantityId, Interval > ranges
Allowed range of quantities.
Definition: IMaterial.h:119
static const Float DEFAULT_MINIMAL
Definition: IMaterial.h:123
FlatMap< QuantityId, Float > minimals
Minimal values used in timestepping, do not affect values of quantities themselves.
Definition: IMaterial.h:116
INLINE const Interval range(const QuantityId id) const
Returns the range of allowed quantity values.
Definition: IMaterial.h:172
INLINE Float minimal(const QuantityId id) const
Returns the scale value of the quantity.
Definition: IMaterial.h:163
static const Interval DEFAULT_RANGE
Default values.
Definition: IMaterial.h:122
void setRange(const QuantityId id, const Interval &range, const Float minimal)
Sets the timestepping parameters of given quantity.
Definition: IMaterial.cpp:17
Object representing a 1D interval of real numbers.
Definition: Interval.h:17
static Interval unbounded()
Returns an unbounded (infinite) interval.
Definition: Interval.h:109
Creating code components based on values from settings.
AutoPtr< IUvMapping > getUvMapping(const RunSettings &settings)
Definition: Factory.cpp:211
AutoPtr< IRng > getRng(const RunSettings &settings)
Definition: Factory.cpp:621
SharedPtr< IScheduler > getScheduler(const RunSettings &settings=RunSettings::getDefaults())
Definition: Factory.cpp:178
MaterialInitialContext()=default
SharedPtr< IScheduler > scheduler
Definition: IMaterial.h:93
AutoPtr< IUvMapping > uvMap
If used, texture mapping coordinates are generated provided mapping.
Definition: IMaterial.h:99
Float kernelRadius
Kernel radius in units of smoothing length.
Definition: IMaterial.h:96
AutoPtr< IRng > rng
Random number generator.
Definition: IMaterial.h:91