SPH
MeshDomain.h
Go to the documentation of this file.
1 #pragma once
2 
7 
9 #include "objects/finders/Bvh.h"
12 
14 
15 class IScheduler;
16 
17 struct MeshParams {
20 
22  bool precomputeInside = true;
23 
26 };
27 
28 
30 class MeshDomain : public IDomain {
31 private:
32  Bvh<BvhTriangle> bvh;
33  Volume<char> mask;
34 
36  struct {
42  } cached;
43 
44 public:
45  MeshDomain(IScheduler& scheduler, Array<Triangle>&& triangles, const MeshParams& params = MeshParams{});
46 
47  virtual Vector getCenter() const override {
48  return cached.box.center();
49  }
50 
51  virtual Box getBoundingBox() const override {
52  return cached.box;
53  }
54 
55  virtual Float getVolume() const override {
56  return cached.volume;
57  }
58 
59  virtual Float getSurfaceArea() const override {
60  return cached.area;
61  }
62 
63  virtual bool contains(const Vector& v) const override;
64 
65  virtual void getSubset(ArrayView<const Vector> vs,
66  Array<Size>& output,
67  const SubsetType type) const override;
68 
71  }
72 
73  virtual void project(ArrayView<Vector> vs, Optional<ArrayView<Size>> indices) const override;
74 
75  virtual void addGhosts(ArrayView<const Vector> vs,
76  Array<Ghost>& ghosts,
77  const Float eta,
78  const Float eps) const override;
79 
80 private:
81  bool containImpl(const Vector& v) const;
82 };
83 
#define NOT_IMPLEMENTED
Helper macro marking missing implementation.
Definition: Assert.h:100
NAMESPACE_SPH_BEGIN
Definition: BarnesHut.cpp:13
Object defining computational domain.
SubsetType
Definition: Domain.h:16
uint32_t Size
Integral type used to index arrays (by default).
Definition: Globals.h:16
double Float
Precision used withing the code. Use Float instead of float or double where precision is important.
Definition: Globals.h:13
#define NAMESPACE_SPH_END
Definition: Object.h:12
static AffineMatrix identity()
Definition: AffineMatrix.h:132
Object providing safe access to continuous memory of data.
Definition: ArrayView.h:17
Generic dynamically allocated resizable storage.
Definition: Array.h:43
Helper object defining three-dimensional interval (box).
Definition: Box.h:17
Base class for computational domains.
Definition: Domain.h:29
Interface that allows unified implementation of sequential and parallelized versions of algorithms.
Definition: Scheduler.h:27
Domain represented by triangular mesh.
Definition: MeshDomain.h:30
Float area
Definition: MeshDomain.h:41
virtual Box getBoundingBox() const override
Returns the bounding box of the domain.
Definition: MeshDomain.h:51
Array< Vector > normals
Definition: MeshDomain.h:38
virtual Float getVolume() const override
Returns the total volume of the domain.
Definition: MeshDomain.h:55
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.
Definition: MeshDomain.cpp:54
Float volume
Definition: MeshDomain.h:40
virtual bool contains(const Vector &v) const override
Checks if the given point lies inside the domain.
Definition: MeshDomain.cpp:46
virtual void getDistanceToBoundary(ArrayView< const Vector >, Array< Float > &) const override
Returns distances of particles lying close to the boundary.
Definition: MeshDomain.h:69
Array< Vector > points
Definition: MeshDomain.h:37
MeshDomain(IScheduler &scheduler, Array< Triangle > &&triangles, const MeshParams &params=MeshParams{})
Definition: MeshDomain.cpp:7
virtual Vector getCenter() const override
Returns the center of the domain.
Definition: MeshDomain.h:47
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...
Definition: MeshDomain.cpp:79
virtual Float getSurfaceArea() const override
Returns the surface area of the domain.
Definition: MeshDomain.h:59
virtual void project(ArrayView< Vector > vs, Optional< ArrayView< Size >> indices) const override
Projects vectors outside of the domain onto its boundary.
Definition: MeshDomain.cpp:75
Wrapper of type value of which may or may not be present.
Definition: Optional.h:23
bool precomputeInside
If true, cached volume is created to allow fast calls of contains.
Definition: MeshDomain.h:22
Size volumeResolution
Resolution of the volume, used if precomputeInside == true.
Definition: MeshDomain.h:25
AffineMatrix matrix
Arbitrary transformation matrix applied on the mesh.
Definition: MeshDomain.h:19