MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
FvMbCartesianSolverXD< nDim, SysEqn >::CsgPlane Class Reference
Collaboration diagram for FvMbCartesianSolverXD< nDim, SysEqn >::CsgPlane:
[legend]

Public Member Functions

 CsgPlane ()=default
 
 CsgPlane (CsgVector *_normal, MFloat _w)
 
 CsgPlane (CsgVector abc[nDim])
 
 ~CsgPlane ()=default
 
CsgPlane clone ()
 
void flip ()
 
void splitPolygon (CsgPolygon *polygon, std::vector< CsgPolygon > *coplanarFront, std::vector< CsgPolygon > *coplanarBack, std::vector< CsgPolygon > *front, std::vector< CsgPolygon > *back) const
 
void insertCoplanarPolygon (CsgPolygon *polygon, std::vector< CsgPolygon > *coplanarFront, std::vector< CsgPolygon > *coplanarBack) const
 

Public Attributes

CsgVector normal
 
MFloat w {}
 

Static Public Attributes

static constexpr MFloat eps = (nDim == 3) ? 10000 * MFloatEps : 1000 * MFloatEps
 

Detailed Description

template<MInt nDim, class SysEqn>
class FvMbCartesianSolverXD< nDim, SysEqn >::CsgPlane

Definition at line 1517 of file fvmbcartesiansolverxd.h.

Constructor & Destructor Documentation

◆ CsgPlane() [1/3]

template<MInt nDim, class SysEqn >
FvMbCartesianSolverXD< nDim, SysEqn >::CsgPlane::CsgPlane ( )
default

◆ CsgPlane() [2/3]

template<MInt nDim, class SysEqn >
FvMbCartesianSolverXD< nDim, SysEqn >::CsgPlane::CsgPlane ( CsgVector _normal,
MFloat  _w 
)
inline

Definition at line 1524 of file fvmbcartesiansolverxd.h.

1524 {
1525 std::copy(_normal->xx, _normal->xx + nDim, normal.xx);
1526 w = _w;
1527 }

◆ CsgPlane() [3/3]

template<MInt nDim, class SysEqn >
FvMbCartesianSolverXD< nDim, SysEqn >::CsgPlane::CsgPlane ( CsgVector  abc[nDim])
inlineexplicit

Definition at line 1528 of file fvmbcartesiansolverxd.h.

1528 {
1529 IF_CONSTEXPR(nDim == 3) {
1530 CsgVector tmp = abc[1].minus(abc[0]).cross(abc[nDim - 1 /*2*/].minus(abc[0])).unit();
1531 normal = tmp;
1532 w = normal.dot(abc[0]);
1533 }
1534 else IF_CONSTEXPR(nDim == 2) {
1535 CsgVector tmp = abc[1].minus(abc[0]).unit();
1536 normal.xx[0] = -tmp.xx[1];
1537 normal.xx[1] = tmp.xx[0];
1538 w = normal.dot(abc[0]);
1539 }
1540 }
MFloat dot(const CsgVector &a) const

◆ ~CsgPlane()

template<MInt nDim, class SysEqn >
FvMbCartesianSolverXD< nDim, SysEqn >::CsgPlane::~CsgPlane ( )
default

Member Function Documentation

◆ clone()

template<MInt nDim, class SysEqn >
CsgPlane FvMbCartesianSolverXD< nDim, SysEqn >::CsgPlane::clone ( )
inline

Definition at line 1542 of file fvmbcartesiansolverxd.h.

1542 {
1543 CsgPlane tmp(&this->normal, this->w);
1544 return tmp;
1545 }

◆ flip()

template<MInt nDim, class SysEqn >
void FvMbCartesianSolverXD< nDim, SysEqn >::CsgPlane::flip ( )
inline

Definition at line 1546 of file fvmbcartesiansolverxd.h.

1546 {
1547 this->normal.negate();
1548 this->w = -this->w;
1549 }

◆ insertCoplanarPolygon()

template<MInt nDim, class SysEqn >
void FvMbCartesianSolverXD< nDim, SysEqn >::CsgPlane::insertCoplanarPolygon ( CsgPolygon polygon,
std::vector< CsgPolygon > *  coplanarFront,
std::vector< CsgPolygon > *  coplanarBack 
) const
Author

Definition at line 31353 of file fvmbcartesiansolverxd.cpp.

31356 {
31357 ASSERT2(!(std::isnan(polygon->plane.normal.xx[0])), "");
31358
31359 (this->normal.dot((polygon->plane.normal)) > F0 ? coplanarFront : coplanarBack)->push_back(*polygon);
31360}

◆ splitPolygon()

template<MInt nDim, class SysEqn >
void FvMbCartesianSolverXD< nDim, SysEqn >::CsgPlane::splitPolygon ( CsgPolygon polygon,
std::vector< CsgPolygon > *  coplanarFront,
std::vector< CsgPolygon > *  coplanarBack,
std::vector< CsgPolygon > *  front,
std::vector< CsgPolygon > *  back 
) const
Author

Definition at line 31368 of file fvmbcartesiansolverxd.cpp.

31373 {
31374 const MInt COPLANAR = 0;
31375 const MInt FRONT = 1;
31376 const MInt BACK = 2;
31377 const MInt SPANNING = 3;
31378
31379 MInt polygonType = 0;
31380 std::vector<MInt> types;
31381
31382 // test normals for equivalence
31383 MBool normalsEqual = false;
31384 IF_CONSTEXPR(nDim == 3) {
31385 if(abs(abs(this->normal.xx[0]) - abs(polygon->plane.normal.xx[0])) < MFloatEps
31386 && abs(abs(this->normal.xx[1]) - abs(polygon->plane.normal.xx[1])) < MFloatEps
31387 && abs(abs(this->normal.xx[2]) - abs(polygon->plane.normal.xx[2])) < MFloatEps)
31388 normalsEqual = true;
31389 }
31390
31391 MBool coplanarVertex = false;
31392 for(MInt i = 0; (unsigned)i < polygon->vertices.size(); i++) {
31393 MFloat t = this->normal.dot((polygon->vertices[i].pos)) - this->w;
31394 MInt type = (t < -eps) ? BACK : (t > eps) ? FRONT : COPLANAR;
31395 polygonType |= type;
31396 types.push_back(type);
31397 IF_CONSTEXPR(nDim == 3) {
31398 if(type == 0) coplanarVertex = true;
31399 }
31400 }
31401 ASSERT2(!(std::isnan(polygon->plane.normal.xx[0])), "");
31402
31403 // Only in 3D the if-clause can result in true
31404 if(normalsEqual && coplanarVertex) polygonType = COPLANAR;
31405
31406 switch(polygonType) {
31407 case COPLANAR:
31408 (this->normal.dot((polygon->plane.normal)) > F0 ? coplanarFront : coplanarBack)->push_back(*polygon);
31409 break;
31410 case FRONT:
31411 front->push_back(*polygon);
31412 break;
31413 case BACK:
31414 back->push_back(*polygon);
31415 break;
31416 case SPANNING: {
31417 std::vector<CsgVertex> f;
31418 std::vector<CsgVertex> b;
31419 IF_CONSTEXPR(nDim == 2) {
31420 MInt i = 0;
31421 MInt j = 1;
31422 MInt ti = types[i], tj = types[j];
31423 CsgVertex vi = polygon->vertices[i];
31424 CsgVertex vj = polygon->vertices[j];
31425 if(ti != BACK) f.push_back(vi);
31426 if(ti != FRONT) b.push_back(ti != BACK ? vi.clone() : vi);
31427 if((ti | tj) == SPANNING) {
31428 MFloat t = (this->w - this->normal.dot((vi.pos))) / this->normal.dot(vj.pos.minus((vi.pos)));
31429 CsgVertex v = vi.interpolate(&vj, t);
31430 f.push_back(v);
31431 b.push_back(v.clone());
31432 }
31433 if(tj != BACK) f.push_back(vj);
31434 if(tj != FRONT) b.push_back(tj != BACK ? vj.clone() : vj);
31435 }
31436 else IF_CONSTEXPR(nDim == 3) {
31437 for(MInt i = 0; (unsigned)i < polygon->vertices.size(); i++) {
31438 MInt j = (i + 1) % polygon->vertices.size();
31439 MInt ti = types[i], tj = types[j];
31440 CsgVertex vi = polygon->vertices[i];
31441 CsgVertex vj = polygon->vertices[j];
31442 if(ti != BACK) f.push_back(vi);
31443 if(ti != FRONT) b.push_back(ti != BACK ? vi.clone() : vi);
31444 if((ti | tj) == SPANNING) {
31445 MFloat t = (this->w - this->normal.dot((vi.pos))) / this->normal.dot(vj.pos.minus((vi.pos)));
31446 CsgVertex v = vi.interpolate(&vj, t);
31447 f.push_back(v);
31448 b.push_back(v.clone());
31449 }
31450 }
31451 }
31452 if(f.size() >= nDim)
31453 front->push_back(
31454 CsgPolygon(f, polygon->setIndex, polygon->faceId, polygon->faceType, polygon->bodyId, polygon->plane));
31455 if(b.size() >= nDim)
31456 back->push_back(
31457 CsgPolygon(b, polygon->setIndex, polygon->faceId, polygon->faceType, polygon->bodyId, polygon->plane));
31458 } break;
31459 default:
31460 break;
31461 }
31462}
int32_t MInt
Definition: maiatypes.h:62
double MFloat
Definition: maiatypes.h:52
bool MBool
Definition: maiatypes.h:58

Member Data Documentation

◆ eps

template<MInt nDim, class SysEqn >
constexpr MFloat FvMbCartesianSolverXD< nDim, SysEqn >::CsgPlane::eps = (nDim == 3) ? 10000 * MFloatEps : 1000 * MFloatEps
staticconstexpr

Definition at line 1519 of file fvmbcartesiansolverxd.h.

◆ normal

template<MInt nDim, class SysEqn >
CsgVector FvMbCartesianSolverXD< nDim, SysEqn >::CsgPlane::normal

Definition at line 1520 of file fvmbcartesiansolverxd.h.

◆ w

template<MInt nDim, class SysEqn >
MFloat FvMbCartesianSolverXD< nDim, SysEqn >::CsgPlane::w {}

Definition at line 1521 of file fvmbcartesiansolverxd.h.


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