11 for (
Size i = 0; i < 3; ++i) {
12 t[i] = params.
matrix * t[i];
16 cached.box.extend(t.getBBox());
18 const Vector center = cached.box.center();
23 for (
const Triangle& t : triangles) {
24 cached.volume +=
dot(t[0] - center,
cross(t[1] - center, t[2] - center)) / 6._f;
25 cached.area += t.area();
26 cached.points.push(t.center());
27 cached.normals.push(t.normal());
29 bvh.
build(std::move(bvhTriangles));
36 for (
Size y = 0; y < res; ++y) {
37 for (
Size x = 0; x < res; ++x) {
39 containImpl(cached.box.lower() + cached.box.size() / res *
Vector(x, y, z)) ? 1 : 0;
48 return this->containImpl(v);
57 for (
Size i = 0; i < vs.
size(); ++i) {
64 for (
Size i = 0; i < vs.
size(); ++i) {
85 for (
Size i = 0; i < cached.points.size(); ++i) {
86 ghosts.
push(
Ghost{ cached.points[i] - h * cached.normals[i], 0 });
90 bool MeshDomain::containImpl(
const Vector& v)
const {
100 Vector(0._f, -1._f, 0._f),
102 Vector(0._f, 0._f, -1._f),
105 for (
Vector& dir : dirs) {
115 return insideCnt >= outsideCnt;
#define SPH_ASSERT(x,...)
#define NOT_IMPLEMENTED
Helper macro marking missing implementation.
@ INSIDE
Marks all vectors inside of the domain.
@ OUTSIDE
Marks all vectors outside of the domain.
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.
constexpr INLINE bool isOdd(const T &f)
Domain represented by triangular mesh.
#define NAMESPACE_SPH_END
Helper iterators allowing to save values to containers.
Interface for executing tasks (potentially) asynchronously.
INLINE void parallelFor(IScheduler &scheduler, const Size from, const Size to, TFunctor &&functor)
Executes a functor concurrently from all available threads.
INLINE BasicVector< float > cross(const BasicVector< float > &v1, const BasicVector< float > &v2)
Cross product between two vectors.
BasicVector< Float > Vector
INLINE float dot(const BasicVector< float > &v1, const BasicVector< float > &v2)
Make sure the vector is trivially constructible and destructible, needed for fast initialization of a...
Object providing safe access to continuous memory of data.
INLINE TCounter size() const
INLINE void push(U &&u)
Adds new element to the end of the array, resizing the array if necessary.
StorageType & emplaceBack(TArgs &&... args)
Constructs a new element at the end of the array in place, using the provided arguments.
void clear()
Removes all elements from the array, but does NOT release the memory.
void build(Array< TBvhObject > &&objects)
Contructs the BVH from given set of objects.
Size getAllIntersections(const Ray &ray, TOutIter iter) const
Returns all intersections of the ray.
Interface that allows unified implementation of sequential and parallelized versions of algorithms.
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 bool contains(const Vector &v) const override
Checks if the given point lies inside the domain.
MeshDomain(IScheduler &scheduler, Array< Triangle > &&triangles, const MeshParams ¶ms=MeshParams{})
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 project(ArrayView< Vector > vs, Optional< ArrayView< Size >> indices) const override
Projects vectors outside of the domain onto its boundary.
Helper output iterator that simply ignores the written values.
Wrapper of type value of which may or may not be present.
TValue & cell(const Size x, const Size y, const Size z)
bool precomputeInside
If true, cached volume is created to allow fast calls of contains.
Size volumeResolution
Resolution of the volume, used if precomputeInside == true.
AffineMatrix matrix
Arbitrary transformation matrix applied on the mesh.