OpenLB 1.7
Loading...
Searching...
No Matches
Public Member Functions | List of all members
olb::BlockLatticeSTLreader< T > Class Template Reference

#include <blockLatticeSTLreader.h>

+ Inheritance diagram for olb::BlockLatticeSTLreader< T >:
+ Collaboration diagram for olb::BlockLatticeSTLreader< T >:

Public Member Functions

 BlockLatticeSTLreader (CuboidGeometry3D< T > &cbg3d, LoadBalancer< T > &hlb, const std::string fName, T voxelSize, T stlSize=1, int method=2, bool verbose=false, T overlap=0., T max=0.)
 Constructs a new BlockLatticeSTLreader from a file.
 
 BlockLatticeSTLreader (const std::vector< std::vector< T > > meshPoints, T voxelSize, T stlSize=1, int method=2, bool verbose=false, T overlap=0., T max=0.)
 Constructs a new BlockLatticeSTLreader from a file.
 
 ~BlockLatticeSTLreader () override
 
bool operator() (bool output[], const T input[]) override
 Returns whether node is inside or not.
 
bool distance (T &distance, const Vector< T, 3 > &origin, const Vector< T, 3 > &direction, int iC=-1) override
 Computes distance to closest triangle intersection.
 
signedDistance (int locC, const Vector< T, 3 > &input)
 Computes signed distance to closest triangle in direction of the surface normal in local cuboid locC.
 
signedDistance (const Vector< T, 3 > &input) override
 Computes signed distance to closest triangle in direction of the surface normal.
 
Vector< T, 3 > surfaceNormal (const Vector< T, 3 > &pos, const T meshSize=0) override
 Finds and returns normal of the closest surface (triangle)
 
void print ()
 Prints console output.
 
void writeSTL (std::string stlName="")
 Writes STL mesh in Si units.
 
void writeOctree ()
 Writes Octree.
 
void setNormalsOutside ()
 Rearranges normals of triangles to point outside of geometry.
 
void setBoundaryInsideNodes ()
 Every octree leaf intersected by the STL will be part of the inside nodes.
 
Octree< T > * getTree () const
 Returns tree.
 
STLmesh< T > & getMesh ()
 Returns mesh.
 
- Public Member Functions inherited from olb::IndicatorF3D< T >
virtual Vector< T, 3 > & getMin ()
 
virtual Vector< T, 3 > & getMax ()
 
virtual bool distance (T &distance, const Vector< T, 3 > &origin, T precision, const Vector< T, 3 > &direction)
 
virtual bool distance (T &distance, const Vector< T, 3 > &origin, const Vector< T, 3 > &direction, T precision, T pitch)
 
virtual bool distance (T &distance, const Vector< T, 3 > &origin, const Vector< T, 3 > &direction, int iC=-1)
 
virtual bool distance (T &distance, const Vector< T, 3 > &origin)
 
virtual bool distance (T &distance, const T input[])
 
virtual bool normal (Vector< T, 3 > &normal, const Vector< T, 3 > &origin, const Vector< T, 3 > &direction, int iC=-1)
 returns true and the normal if there was one found for an given origin and direction
 
virtual bool rotOnAxis (Vector< T, 3 > &vec_rot, const Vector< T, 3 > &vec, const Vector< T, 3 > &axis, T &theta)
 Rotate vector around axis by angle theta.
 
virtual bool operator() (bool output[1], const T input[3])
 Returns true if input is inside the indicator.
 
virtual T signedDistance (const Vector< T, 3 > &input)
 Returns signed distance to the nearest point on the indicator surface.
 
virtual Vector< T, 3 > surfaceNormal (const Vector< T, 3 > &pos, const T meshSize)
 Return surface normal.
 
Vector< T, 3 > surfaceNormal (const Vector< T, 3 > &pos, const T meshSize, std::function< Vector< T, 3 >(const Vector< T, 3 > &)> transformPos)
 Return surface normal after possible translation and rotation.
 
bool isInsideBox (Vector< T, 3 > point)
 Returns true if point is inside a cube with corners _myMin and _myMax
 
virtual Vector< T, 3 > getSample (const std::function< T()> &randomness) const
 
- Public Member Functions inherited from olb::GenericF< T, S >
virtual ~GenericF ()=default
 
int getSourceDim () const
 read only access to member variable _m
 
int getTargetDim () const
 read only access to member variable _n
 
std::string & getName ()
 read and write access to name
 
std::string const & getName () const
 read only access to name
 
virtual bool operator() (T output[], const S input[])=0
 has to be implemented for 'every' derived class
 
bool operator() (T output[])
 wrapper that call the pure virtual operator() (T output[], const S input[]) from above
 
bool operator() (T output[], S input0)
 
bool operator() (T output[], S input0, S input1)
 
bool operator() (T output[], S input0, S input1, S input2)
 
bool operator() (T output[], S input0, S input1, S input2, S input3)
 

Additional Inherited Members

- Public Types inherited from olb::GenericF< T, S >
using targetType = T
 
using sourceType = S
 
- Public Attributes inherited from olb::GenericF< T, S >
std::shared_ptr< GenericF< T, S > > _ptrCalcC
 memory management, frees resouces (calcClass)
 
- Protected Member Functions inherited from olb::IndicatorF3D< T >
 IndicatorF3D ()
 
- Protected Member Functions inherited from olb::GenericF< T, S >
 GenericF (int targetDim, int sourceDim)
 
- Protected Attributes inherited from olb::IndicatorF3D< T >
Vector< T, 3 > _myMin
 
Vector< T, 3 > _myMax
 

Detailed Description

template<typename T>
class olb::BlockLatticeSTLreader< T >

Definition at line 54 of file blockLatticeSTLreader.h.

Constructor & Destructor Documentation

◆ BlockLatticeSTLreader() [1/2]

template<typename T >
olb::BlockLatticeSTLreader< T >::BlockLatticeSTLreader ( CuboidGeometry3D< T > & cbg3d,
LoadBalancer< T > & hlb,
const std::string fName,
T voxelSize,
T stlSize = 1,
int method = 2,
bool verbose = false,
T overlap = 0.,
T max = 0. )

Constructs a new BlockLatticeSTLreader from a file.

Parameters
fNameThe STL file name
voxelSizeVoxelsize in SI units
stlSizeConversion factor for STL (e.g. STL in mm stlSize=10^-3)
methodChoose indication method 0: fast, less stable 1: slow, more stable (for untight STLs)
verboseGet additional information.

Find center of tree and move by _voxelSize/4.

Create tree

Compute _myMin, _myMax such that they are the smallest (greatest) Voxel inside the STL.

Indicate nodes of the tree. (Inside/Outside)

Definition at line 51 of file blockLatticeSTLreader.hh.

53 : _cuboidGeometry (cbg3d),
54 _loadBalancer(hlb),
55 _voxelSize(voxelSize),
56 _stlSize(stlSize),
57 _overlap(overlap),
58 _fName(fName),
59 _mesh(fName, stlSize),
60 _verbose(verbose),
61 clout(std::cout, "BlockLatticeSTLreader")
62{
63 this->getName() = "BlockLatticeSTLreader";
64
65 if (_verbose) {
66 clout << "Voxelizing ..." << std::endl;
67 }
68
69 Vector<T,3> extension = _mesh.getMax() - _mesh.getMin();
70 if ( util::nearZero(max) ) {
71 max = util::max(extension[0], util::max(extension[1], extension[2])) + _voxelSize;
72 }
73 int j = 0;
74 for (; _voxelSize * util::pow(2, j) < max; j++)
75 ;
76 Vector<T,3> center;
77 T radius = _voxelSize * util::pow(2, j - 1);
78
80 for (unsigned i = 0; i < 3; i++) {
81 center[i] = (_mesh.getMin()[i] + _mesh.getMax()[i]) / 2. - _voxelSize / 4.;
82 }
83
85 _tree = new Octree<T>(center, radius, &_mesh, j, _overlap);
86
88 for (int i = 0; i < 3; i++) {
89 this->_myMin[i] = center[i] + _voxelSize / 2.;
90 this->_myMax[i] = center[i] - _voxelSize / 2.;
91 }
92 for (int i = 0; i < 3; i++) {
93 while (this->_myMin[i] > _mesh.getMin()[i]) {
94 this->_myMin[i] -= _voxelSize;
95 }
96 while (this->_myMax[i] < _mesh.getMax()[i]) {
97 this->_myMax[i] += _voxelSize;
98 }
99 this->_myMax[i] -= _voxelSize;
100 this->_myMin[i] += _voxelSize;
101 }
102
104 switch (method) {
105 case 1:
106 indicate1();
107 break;
108 case 3:
109 indicate3();
110 break;
111 case 4:
112 indicate2_Xray();
113 break;
114 case 5:
115 indicate2_Yray();
116 break;
117 default:
118 indicate2();
119 break;
120 }
121
122 if (_verbose) {
123 print();
124 }
125
126 clout <<"creating of the lists for signed distance function"<< std::endl;
127 _trianglesInCuboidList.resize(_loadBalancer.size());
128 //_cuboidGeometry.getNc();
129 for( int iC=0; iC < _loadBalancer.size();iC++)
130 {
131 //_trainglesInCuboidList.emplace_back();
132 int globC = _loadBalancer.glob(iC);
133 auto& cuboid = _cuboidGeometry.get(globC);
134 for (STLtriangle<T>& triangle : _mesh.getTriangles())
135 {
136 Vector<T,3> center = triangle.getCenter() ;
137 if (cuboid.checkInters(center[0], center[1], center[2], 3))
138 {
139 _trianglesInCuboidList[iC].push_back(triangle);
140
141 }
142 }
143 }
144
145
146 if (_verbose) {
147
148 clout << "Voxelizing ... OK" << std::endl;
149 }
150}
void print()
Prints console output.
std::string & getName()
read and write access to name
Definition genericF.hh:51
Pack< T > max(Pack< T > rhs, Pack< T > lhs)
Definition 256.h:416
T triangle(Vector< T, 2 > p, Vector< T, 2 > a, Vector< T, 2 > b, Vector< T, 2 > c) any_platform
Exact signed distance to the surface of two-dimensional triangle.
Definition sdf.h:143
cpu::simd::Pack< T > max(cpu::simd::Pack< T > rhs, cpu::simd::Pack< T > lhs)
Definition pack.h:130
cpu::simd::Pack< T > pow(cpu::simd::Pack< T > base, cpu::simd::Pack< T > exp)
Definition pack.h:112
bool nearZero(const ADf< T, DIM > &a)
Definition aDiff.h:1087

References olb::IndicatorF3D< T >::_myMax, olb::IndicatorF3D< T >::_myMin, olb::GenericF< T, S >::getName(), olb::util::max(), olb::util::nearZero(), olb::util::pow(), and olb::BlockLatticeSTLreader< T >::print().

+ Here is the call graph for this function:

◆ BlockLatticeSTLreader() [2/2]

template<typename T >
olb::BlockLatticeSTLreader< T >::BlockLatticeSTLreader ( const std::vector< std::vector< T > > meshPoints,
T voxelSize,
T stlSize = 1,
int method = 2,
bool verbose = false,
T overlap = 0.,
T max = 0. )

Constructs a new BlockLatticeSTLreader from a file.

Parameters
fNameThe STL file name
voxelSizeVoxelsize in SI units
stlSizeConversion factor for STL (e.g. STL in mm stlSize=10^-3)
methodChoose indication method 0: fast, less stable 1: slow, more stable (for untight STLs)
verboseGet additional information.

Find center of tree and move by _voxelSize/4.

Create tree

Compute _myMin, _myMax such that they are the smallest (greatest) Voxel inside the STL.

Definition at line 156 of file blockLatticeSTLreader.hh.

158 : _voxelSize(voxelSize),
159 _stlSize(stlSize),
160 _overlap(overlap),
161 _fName("meshPoints.stl"),
162 _mesh(meshPoints, stlSize),
163 _verbose(verbose),
164 clout(std::cout, "BlockLatticeSTLreader")
165{
166 this->getName() = "BlockLatticeSTLreader";
167
168 if (_verbose) {
169 clout << "Voxelizing ..." << std::endl;
170 }
171
172 Vector<T,3> extension = _mesh.getMax() - _mesh.getMin();
173 if ( util::nearZero(max) ) {
174 max = util::max(extension[0], util::max(extension[1], extension[2])) + _voxelSize;
175 }
176 int j = 0;
177 for (; _voxelSize * util::pow(2, j) < max; j++)
178 ;
179 Vector<T,3> center;
180 T radius = _voxelSize * util::pow(2, j - 1);
181
183 for (unsigned i = 0; i < 3; i++) {
184 center[i] = (_mesh.getMin()[i] + _mesh.getMax()[i]) / 2. - _voxelSize / 4.;
185 }
186
188
189 _tree = new Octree<T>(center, radius, &_mesh, j, _overlap);
190
192 for (int i = 0; i < 3; i++) {
193 this->_myMin[i] = center[i] + _voxelSize / 2.;
194 this->_myMax[i] = center[i] - _voxelSize / 2.;
195 }
196 for (int i = 0; i < 3; i++) {
197 while (this->_myMin[i] > _mesh.getMin()[i]) {
198 this->_myMin[i] -= _voxelSize;
199 }
200 while (this->_myMax[i] < _mesh.getMax()[i]) {
201 this->_myMax[i] += _voxelSize;
202 }
203 this->_myMax[i] -= _voxelSize;
204 this->_myMin[i] += _voxelSize;
205 }
206 //automaticly choose the method with minimum extension in its direction
207
208 /*if(extension[0] == std::min_element(extension.begin(), extension.end())){
209 method = 4;
210 }
211 else if(extension[1] == std::min_element(extension.begin(), extension.end())){
212 method = 5;
213 }
214 else if(extension[2] == std::min_element(extension.begin(), extension.end())){
215 method = 0;
216 }
217 */
218
219
220 // Indicate nodes of the tree. (Inside/Outside)
221 switch (method) {
222 case 1:
223 indicate1();
224 break;
225 case 3:
226 indicate3();
227 break;
228 case 4:
229 indicate2_Xray();
230 break;
231 case 5:
232 indicate2_Yray();
233 break;
234 default:
235 indicate2();
236 break;
237 }
238
239 if (_verbose) {
240 print();
241 }
242 if (_verbose) {
243 clout << "Voxelizing ... OK" << std::endl;
244 }
245}

References olb::IndicatorF3D< T >::_myMax, olb::IndicatorF3D< T >::_myMin, olb::GenericF< T, S >::getName(), olb::util::max(), olb::util::nearZero(), olb::util::pow(), and olb::BlockLatticeSTLreader< T >::print().

+ Here is the call graph for this function:

◆ ~BlockLatticeSTLreader()

template<typename T >
olb::BlockLatticeSTLreader< T >::~BlockLatticeSTLreader ( )
override

Definition at line 248 of file blockLatticeSTLreader.hh.

249{
250 delete _tree;
251}

Member Function Documentation

◆ distance()

template<typename T >
bool olb::BlockLatticeSTLreader< T >::distance ( T & distance,
const Vector< T, 3 > & origin,
const Vector< T, 3 > & direction,
int iC = -1 )
override

Computes distance to closest triangle intersection.

Definition at line 601 of file blockLatticeSTLreader.hh.

603{
604 Octree<T>* node = nullptr;
605 Vector<T,3> dir(direction);
606 dir = normalize(dir);
607 Vector<T,3> extends = _mesh.getMax() - _mesh.getMin();
608 Vector<T,3> pt(origin);
609 Vector<T,3> q;
610 Vector<T,3> s;
611 Vector<T,3> center = _mesh.getMin() + 1 / 2. * extends;
612 T step = _voxelSize / 1000., a = 0;
613
614 for (int i = 0; i < 3; i++) {
615 extends[i] /= 2.;
616 }
617
618 if (!(_mesh.getMin()[0] < origin[0] && origin[0] < _mesh.getMax()[0]
619 && _mesh.getMin()[1] < origin[1] && origin[1] < _mesh.getMax()[1]
620 && _mesh.getMin()[2] < origin[2] && origin[2] < _mesh.getMax()[2])) {
621 T t = T(), d = T();
622 bool foundQ = false;
623
624 if (dir[0] > 0) {
625 d = _mesh.getMin()[0];
626 t = (d - origin[0]) / dir[0];
627 pt[0] = origin[0] + (t + step) * dir[0];
628 pt[1] = origin[1] + (t + step) * dir[1];
629 pt[2] = origin[2] + (t + step) * dir[2];
630
631 if (_mesh.getMin()[1] < pt[1] && pt[1] < _mesh.getMax()[1]
632 && _mesh.getMin()[2] < pt[2] && pt[2] < _mesh.getMax()[2]) {
633 foundQ = true;
634 }
635 }
636 else if (dir[0] < 0) {
637 d = _mesh.getMax()[0];
638 t = (d - origin[0]) / dir[0];
639 pt[0] = origin[0] + (t + step) * dir[0];
640 pt[1] = origin[1] + (t + step) * dir[1];
641 pt[2] = origin[2] + (t + step) * dir[2];
642 if (_mesh.getMin()[1] < pt[1] && pt[1] < _mesh.getMax()[1]
643 && _mesh.getMin()[2] < pt[2] && pt[2] < _mesh.getMax()[2]) {
644 foundQ = true;
645 }
646 }
647
648 if (dir[1] > 0 && !foundQ) {
649 d = _mesh.getMin()[1];
650 t = (d - origin[1]) / dir[1];
651 pt[0] = origin[0] + (t + step) * dir[0];
652 pt[1] = origin[1] + (t + step) * dir[1];
653 pt[2] = origin[2] + (t + step) * dir[2];
654 if (_mesh.getMin()[0] < pt[0] && pt[0] < _mesh.getMax()[0]
655 && _mesh.getMin()[2] < pt[2] && pt[2] < _mesh.getMax()[2]) {
656 foundQ = true;
657 }
658 }
659 else if (dir[1] < 0 && !foundQ) {
660 d = _mesh.getMax()[1];
661 t = (d - origin[1]) / dir[1];
662 pt[0] = origin[0] + (t + step) * dir[0];
663 pt[1] = origin[1] + (t + step) * dir[1];
664 pt[2] = origin[2] + (t + step) * dir[2];
665 if (_mesh.getMin()[0] < pt[0] && pt[0] < _mesh.getMax()[0]
666 && _mesh.getMin()[2] < pt[2] && pt[2] < _mesh.getMax()[2]) {
667 foundQ = true;
668 }
669 }
670
671 if (dir[2] > 0 && !foundQ) {
672 d = _mesh.getMin()[2];
673 t = (d - origin[2]) / dir[2];
674 pt[0] = origin[0] + (t + step) * dir[0];
675 pt[1] = origin[1] + (t + step) * dir[1];
676 pt[2] = origin[2] + (t + step) * dir[2];
677 if (_mesh.getMin()[0] < pt[0] && pt[0] < _mesh.getMax()[0]
678 && _mesh.getMin()[1] < pt[1] && pt[1] < _mesh.getMax()[1]) {
679 foundQ = true;
680 }
681 }
682 else if (dir[2] < 0 && !foundQ) {
683 d = _mesh.getMax()[2];
684 t = (d - origin[2]) / dir[2];
685 pt[0] = origin[0] + (t + step) * dir[0];
686 pt[1] = origin[1] + (t + step) * dir[1];
687 pt[2] = origin[2] + (t + step) * dir[2];
688 if (_mesh.getMin()[0] < pt[0] && pt[0] < _mesh.getMax()[0]
689 && _mesh.getMin()[1] < pt[1] && pt[1] < _mesh.getMax()[1]) {
690 foundQ = true;
691 }
692 }
693
694 if (!foundQ) {
695 return false;
696 }
697 }
698
699 while ((util::fabs(pt[0] - center[0]) < extends[0])
700 && (util::fabs(pt[1] - center[1]) < extends[1])
701 && (util::fabs(pt[2] - center[2]) < extends[2])) {
702 node = _tree->find(pt);
703 if (node->closestIntersection(Vector<T,3>(origin), dir, q, a)) {
704 Vector<T,3> vek(q - Vector<T,3>(origin));
705 distance = norm(vek);
706 return true;
707 }
708 else {
709 Octree<T>* tmpNode = _tree->find(pt);
710 tmpNode->intersectRayNode(pt, dir, s);
711 for (int i = 0; i < 3; i++) {
712 pt[i] = s[i] + step * dir[i];
713 }
714 }
715 }
716
717 if (_verbose) {
718 clout << "Returning false" << std::endl;
719 }
720 return false;
721}
bool distance(T &distance, const Vector< T, 3 > &origin, const Vector< T, 3 > &direction, int iC=-1) override
Computes distance to closest triangle intersection.
platform_constant Fraction t[Q]
platform_constant Fraction s[Q]
constexpr int q() any_platform
constexpr int d() any_platform
cpu::simd::Pack< T > fabs(cpu::simd::Pack< T > value)
Definition pack.h:106
constexpr T norm(const ScalarVector< T, D, IMPL > &a)
Euclidean vector norm.
constexpr Vector< T, D > normalize(const ScalarVector< T, D, IMPL > &a, T scale=T{1})
Definition vector.h:245

References olb::Octree< T >::closestIntersection(), olb::util::fabs(), olb::Octree< T >::find(), olb::Octree< T >::intersectRayNode(), olb::norm(), and olb::normalize().

+ Here is the call graph for this function:

◆ getMesh()

template<typename T >
STLmesh< T > & olb::BlockLatticeSTLreader< T >::getMesh ( )
inline

Returns mesh.

Definition at line 179 of file blockLatticeSTLreader.h.

180 {
181 return _mesh;
182 };

◆ getTree()

template<typename T >
Octree< T > * olb::BlockLatticeSTLreader< T >::getTree ( ) const
inline

Returns tree.

Definition at line 172 of file blockLatticeSTLreader.h.

173 {
174 return _tree;
175 };

◆ operator()()

template<typename T >
bool olb::BlockLatticeSTLreader< T >::operator() ( bool output[],
const T input[] )
override

Returns whether node is inside or not.

Definition at line 587 of file blockLatticeSTLreader.hh.

588{
589 output[0] = false;
590 T coords = _tree->getRadius();
591 Vector<T,3> c(_tree->getCenter());
592 if (c[0] - coords < input[0] && input[0] < c[0] + coords && c[1] - coords < input[1]
593 && input[1] < c[1] + coords && c[2] - coords < input[2] && input[2] < c[2] + coords) {
594 std::vector<T> tmp(input, input + 3);
595 output[0] = _tree->find(tmp)->getInside();
596 }
597 return true;
598}
platform_constant int c[Q][D]

◆ print()

template<typename T >
void olb::BlockLatticeSTLreader< T >::print ( )

Prints console output.

Definition at line 842 of file blockLatticeSTLreader.hh.

843{
844 _mesh.print();
845 _tree->print();
846 clout << "voxelSize=" << _voxelSize << "; stlSize=" << _stlSize << std::endl;
847 clout << "minPhysR(VoxelMesh)=(" << this->_myMin[0] << "," << this->_myMin[1]
848 << "," << this->_myMin[2] << ")";
849 clout << "; maxPhysR(VoxelMesh)=(" << this->_myMax[0] << ","
850 << this->_myMax[1] << "," << this->_myMax[2] << ")" << std::endl;
851}
+ Here is the caller graph for this function:

◆ setBoundaryInsideNodes()

template<typename T >
void olb::BlockLatticeSTLreader< T >::setBoundaryInsideNodes ( )

Every octree leaf intersected by the STL will be part of the inside nodes.

Artificially enlarges all details that would otherwise be cut off by the voxelSize.

Definition at line 893 of file blockLatticeSTLreader.hh.

894{
895 std::vector<Octree<T>*> leafs;
896 _tree->getLeafs(leafs);
897 for (auto it = leafs.begin(); it != leafs.end(); ++it) {
898 if ((*it)->getBoundaryNode()) {
899 (*it)->setInside(true);
900 }
901 }
902}

◆ setNormalsOutside()

template<typename T >
void olb::BlockLatticeSTLreader< T >::setNormalsOutside ( )

Rearranges normals of triangles to point outside of geometry.

Definition at line 871 of file blockLatticeSTLreader.hh.

872{
873 unsigned int noTris = _mesh.triangleSize();
874 Vector<T,3> center;
875 //Octree<T>* node = nullptr;
876 for (unsigned int i = 0; i < noTris; i++) {
877 center = _mesh.getTri(i).getCenter();
878 if (_tree->find(
879 center + _mesh.getTri(i).normal * util::sqrt(3.) * _voxelSize)->getInside()) {
880 // cout << "Wrong direction" << std::endl;
881 Vector<T,3> pt(_mesh.getTri(i).point[0].coords);
882 _mesh.getTri(i).point[0].coords = _mesh.getTri(i).point[2].coords;
883 _mesh.getTri(i).point[2].coords = pt;
884 _mesh.getTri(i).init();
885 // _mesh.getTri(i).getNormal()[0] *= -1.;
886 // _mesh.getTri(i).getNormal()[1] *= -1.;
887 // _mesh.getTri(i).getNormal()[2] *= -1.;
888 }
889 }
890}
cpu::simd::Pack< T > sqrt(cpu::simd::Pack< T > value)
Definition pack.h:100

References olb::util::sqrt().

+ Here is the call graph for this function:

◆ signedDistance() [1/2]

template<typename T >
T olb::BlockLatticeSTLreader< T >::signedDistance ( const Vector< T, 3 > & input)
override

Computes signed distance to closest triangle in direction of the surface normal.

Definition at line 818 of file blockLatticeSTLreader.hh.

819{
820 int iC = -1;
821 int globC = _cuboidGeometry.get_iC(input, 0);
822 if (_loadBalancer.isLocal(globC)) {
823 iC = _loadBalancer.loc(globC);
824 } else {
825 globC = _cuboidGeometry.get_iC(input, 3);
826 if (_loadBalancer.isLocal(globC)) {
827 iC = _loadBalancer.loc(globC);
828 } else {
829 throw std::runtime_error("Distance origin must be located within local cuboid (overlap)");
830 }
831 }
832 return signedDistance(iC, input);
833}
T signedDistance(int locC, const Vector< T, 3 > &input)
Computes signed distance to closest triangle in direction of the surface normal in local cuboid locC.

◆ signedDistance() [2/2]

template<typename T >
T olb::BlockLatticeSTLreader< T >::signedDistance ( int locC,
const Vector< T, 3 > & input )

Computes signed distance to closest triangle in direction of the surface normal in local cuboid locC.

Definition at line 787 of file blockLatticeSTLreader.hh.

788{
789 T distance = std::numeric_limits<T>::max();
790 auto& triangles = _trianglesInCuboidList[iC];
791 STLtriangle<T> _triangle;
792 Vector<T,3> normal;
793 for (const STLtriangle<T>& triangle : triangles)
794 {
795 PhysR<T,3> pointOnTriangle = triangle.closestPtPointTriangle(input);
796 T distance2 = util::min(distance, norm(pointOnTriangle - input));
797 //TODO! There could be a problem with concave surfaces on STL when there is a bigger distance there could be no point on the triangle and function does not work!
798 if(distance2 < distance && triangle.isPointInside(pointOnTriangle))
799 {
800 distance =distance2;
801 _triangle = triangle;
802 normal = normalize(pointOnTriangle - input);
803 }
804 }
805 if(util::dotProduct3D(normal, _triangle.getNormal())> 0)
806 {
807
809 }
810 else
811 {
813 }
814 return distance;
815}
virtual bool normal(Vector< T, 3 > &normal, const Vector< T, 3 > &origin, const Vector< T, 3 > &direction, int iC=-1)
returns true and the normal if there was one found for an given origin and direction
cpu::simd::Pack< T > min(cpu::simd::Pack< T > rhs, cpu::simd::Pack< T > lhs)
Definition pack.h:124
T dotProduct3D(const Vector< T, 3 > &a, const Vector< T, 3 > &b)
dot product, only valid in 3d

References olb::util::dotProduct3D(), olb::util::fabs(), olb::STLtriangle< T >::getNormal(), olb::util::min(), olb::norm(), and olb::normalize().

+ Here is the call graph for this function:

◆ surfaceNormal()

template<typename T >
Vector< T, 3 > olb::BlockLatticeSTLreader< T >::surfaceNormal ( const Vector< T, 3 > & pos,
const T meshSize = 0 )
override

Finds and returns normal of the closest surface (triangle)

Definition at line 836 of file blockLatticeSTLreader.hh.

837{
838 return evalSurfaceNormal(pos);
839}

◆ writeOctree()

template<typename T >
void olb::BlockLatticeSTLreader< T >::writeOctree ( )

Writes Octree.

Definition at line 854 of file blockLatticeSTLreader.hh.

855{
856 _tree->write(_fName);
857}

◆ writeSTL()

template<typename T >
void olb::BlockLatticeSTLreader< T >::writeSTL ( std::string stlName = "")

Writes STL mesh in Si units.

Definition at line 860 of file blockLatticeSTLreader.hh.

861{
862 if (stlName == "") {
863 _mesh.write(_fName);
864 }
865 else {
866 _mesh.write(stlName);
867 }
868}

The documentation for this class was generated from the following files: