Merge pull request #56 from PhasicFlow/highResWalls

planeWall high resolution
This commit is contained in:
PhasicFlow 2022-11-28 08:43:28 +03:30 committed by GitHub
commit 14ef70bfdf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 132 additions and 36 deletions

View File

@ -32,6 +32,9 @@ bool pFlow::cuboidWall::readcuboidWall
auto center = dict.getVal<realx3>("center"); auto center = dict.getVal<realx3>("center");
auto edgeLength= dict.getVal<realx3>("edgeLength"); auto edgeLength= dict.getVal<realx3>("edgeLength");
auto numDivs = dict.getValOrSet<int32x3>("numDivs", int32x3(1,1,1));
numDivs = max(numDivs, int32x3(1,1,1));
realx3 p1,p2,p3,p4; realx3 p1,p2,p3,p4;
@ -41,7 +44,7 @@ bool pFlow::cuboidWall::readcuboidWall
p3 = center + edgeLength*realx3(-0.5, 0.5, 0.5); p3 = center + edgeLength*realx3(-0.5, 0.5, 0.5);
p4 = center + edgeLength*realx3(-0.5,-0.5, 0.5); p4 = center + edgeLength*realx3(-0.5,-0.5, 0.5);
planeWall left(p1,p2,p3,p4); planeWall left(p1,p2,p3,p4, numDivs.y(), numDivs.z());
for(const auto& t:left.triangles()) for(const auto& t:left.triangles())
{ {
@ -54,7 +57,7 @@ bool pFlow::cuboidWall::readcuboidWall
p3 = center + edgeLength*realx3( 0.5, 0.5, 0.5); p3 = center + edgeLength*realx3( 0.5, 0.5, 0.5);
p4 = center + edgeLength*realx3( 0.5, 0.5,-0.5); p4 = center + edgeLength*realx3( 0.5, 0.5,-0.5);
planeWall right(p1,p2,p3,p4); planeWall right(p1,p2,p3,p4, numDivs.z(), numDivs.y());
for(const auto& t:right.triangles()) for(const auto& t:right.triangles())
{ {
@ -67,7 +70,7 @@ bool pFlow::cuboidWall::readcuboidWall
p3 = center + edgeLength*realx3( 0.5,-0.5, 0.5); p3 = center + edgeLength*realx3( 0.5,-0.5, 0.5);
p4 = center + edgeLength*realx3( 0.5,-0.5,-0.5); p4 = center + edgeLength*realx3( 0.5,-0.5,-0.5);
planeWall bottom(p1,p2,p3,p4); planeWall bottom(p1,p2,p3,p4, numDivs.z(), numDivs.x());
for(const auto& t:bottom.triangles()) for(const auto& t:bottom.triangles())
{ {
@ -80,7 +83,7 @@ bool pFlow::cuboidWall::readcuboidWall
p3 = center + edgeLength*realx3( 0.5, 0.5, 0.5); p3 = center + edgeLength*realx3( 0.5, 0.5, 0.5);
p4 = center + edgeLength*realx3(-0.5, 0.5, 0.5); p4 = center + edgeLength*realx3(-0.5, 0.5, 0.5);
planeWall top(p1,p2,p3,p4); planeWall top(p1,p2,p3,p4, numDivs.x(), numDivs.z());
for(const auto& t:top.triangles()) for(const auto& t:top.triangles())
{ {
@ -93,7 +96,8 @@ bool pFlow::cuboidWall::readcuboidWall
p3 = center + edgeLength*realx3( 0.5, 0.5,-0.5); p3 = center + edgeLength*realx3( 0.5, 0.5,-0.5);
p4 = center + edgeLength*realx3(-0.5, 0.5,-0.5); p4 = center + edgeLength*realx3(-0.5, 0.5,-0.5);
planeWall back(p1,p2,p3,p4);
planeWall back(p1,p2,p3,p4, numDivs.x(), numDivs.y());
for(const auto& t:back.triangles()) for(const auto& t:back.triangles())
{ {
@ -107,7 +111,7 @@ bool pFlow::cuboidWall::readcuboidWall
p3 = center + edgeLength*realx3( 0.5, 0.5, 0.5); p3 = center + edgeLength*realx3( 0.5, 0.5, 0.5);
p4 = center + edgeLength*realx3( 0.5,-0.5, 0.5); p4 = center + edgeLength*realx3( 0.5,-0.5, 0.5);
planeWall front(p1,p2,p3,p4); planeWall front(p1,p2,p3,p4, numDivs.y(), numDivs.x());
for(const auto& t:front.triangles()) for(const auto& t:front.triangles())
{ {

View File

@ -20,8 +20,7 @@ Licence:
#include "planeWall.H" #include "planeWall.H"
#include "line.H"
bool pFlow::planeWall::readPlaneWall bool pFlow::planeWall::readPlaneWall
( (
@ -33,24 +32,21 @@ bool pFlow::planeWall::readPlaneWall
auto p3 = dict.getVal<realx3>("p3"); auto p3 = dict.getVal<realx3>("p3");
auto p4 = dict.getVal<realx3>("p4"); auto p4 = dict.getVal<realx3>("p4");
auto numDiv12 = max(dict.getValOrSet<int32>("numDiv12",1),1);
auto numDiv23 = max(dict.getValOrSet<int32>("numDiv23",1),1);
if( Wall::checkTrianlge(p1,p2,p3) )
{ if(!checkFlatness(p1,p2,p3,p4))
triangles_.push_back(realx3x3(p1,p2,p3));
}else
{ {
fatalErrorInFunction << fatalErrorInFunction <<
"points p1, p2 and p3 do not form a plane wall in dictionary " << dict.globalName()<<endl; "points p1, p2, p3 and p4 do not form a plane wall in dictionary " << dict.globalName()<<endl;
return false; return false;
} }
if( Wall::checkTrianlge(p3,p4,p1) ) if(!addPlaneWall(p1,p2,p3,p4,numDiv12,numDiv23))
{ {
triangles_.push_back(realx3x3(p3,p4,p1)); fatalErrorInFunction<<
}else "could not create plane wall from dictionary "<< dict.globalName()<<endl;
{
fatalErrorInFunction <<
"points p3, p4 and p1 do not form a plane wall in dictionary " << dict.globalName()<<endl;
return false; return false;
} }
@ -59,6 +55,81 @@ bool pFlow::planeWall::readPlaneWall
} }
bool pFlow::planeWall::addWall4(
const realx3& p1,
const realx3& p2,
const realx3& p3,
const realx3& p4)
{
if(!checkFlatness(p1,p2,p3,p4))return false;
triangles_.push_back(realx3x3(p1,p2,p3));
triangles_.push_back(realx3x3(p3,p4,p1));
return true;
}
bool pFlow::planeWall::checkFlatness(
const realx3& p1,
const realx3& p2,
const realx3& p3,
const realx3& p4)
{
if( !Wall::checkTrianlge(p1,p2,p3) ) return false;
if( !Wall::checkTrianlge(p3,p4,p1) ) return false;
return true;
}
bool pFlow::planeWall::addPlaneWall(
const realx3& p1,
const realx3& p2,
const realx3& p3,
const realx3& p4,
int32 numDiv12,
int32 numDiv23 )
{
real dt12 = 1.0/numDiv12;
real dt23 = 1.0/numDiv23;
real t12 = 0;
line line12(p1,p2);
line line43(p4,p3);
for(int32 i=0; i<numDiv12; i++)
{
auto lp1 = line12.point(t12);
auto lp4 = line43.point(t12);
auto lp2 = line12.point(t12+dt12);
auto lp3 = line43.point(t12+dt12);
line line14(lp1,lp4);
line line23(lp2,lp3);
real t23 = 0;
for(int32 j=0; j<numDiv23; j++)
{
if(
!addWall4(
line14.point(t23),
line23.point(t23),
line23.point(t23+dt23),
line14.point(t23+dt23) )
)
{
return false;
}
t23+=dt23;
}
t12+=dt12;
}
return true;
}
pFlow::planeWall::planeWall() pFlow::planeWall::planeWall()
{} {}
@ -79,26 +150,24 @@ pFlow::planeWall::planeWall(
const realx3& p1, const realx3& p1,
const realx3& p2, const realx3& p2,
const realx3& p3, const realx3& p3,
const realx3& p4) const realx3& p4,
int32 numDiv12,
int32 numDiv23 )
{ {
if( Wall::checkTrianlge(p1,p2,p3) ) if(!checkFlatness(p1,p2,p3,p4))
{ {
triangles_.push_back(realx3x3(p1,p2,p3)); fatalErrorInFunction<<
}else "the input points p1, p2, p3, and p4 are not in the same plane "<<endl;
{
fatalErrorInFunction <<
"points p1, p2 and p3 do not form a plane wall "<<endl;
fatalExit; fatalExit;
} }
if( Wall::checkTrianlge(p3,p4,p1) ) if(!addPlaneWall(p1,p2,p3,p4, numDiv12, numDiv23))
{ {
triangles_.push_back(realx3x3(p3,p4,p1)); fatalErrorInFunction<<
}else "could not create plane wall from input points "<<endl;
{
fatalErrorInFunction <<
"points p3, p4 and p1 do not form a plane wallendl";
fatalExit; fatalExit;
} }
} }

View File

@ -37,6 +37,26 @@ protected:
bool readPlaneWall(const dictionary& dict); bool readPlaneWall(const dictionary& dict);
bool addWall4(
const realx3& p1,
const realx3& p2,
const realx3& p3,
const realx3& p4);
bool checkFlatness(
const realx3& p1,
const realx3& p2,
const realx3& p3,
const realx3& p4);
bool addPlaneWall(
const realx3& p1,
const realx3& p2,
const realx3& p3,
const realx3& p4,
int32 numDiv12 = 1,
int32 numDiv23 = 1);
public: public:
TypeName("planeWall"); TypeName("planeWall");
@ -49,7 +69,9 @@ public:
const realx3& p1, const realx3& p1,
const realx3& p2, const realx3& p2,
const realx3& p3, const realx3& p3,
const realx3& p4); const realx3& p4,
int32 numDiv12 = 1,
int32 numDiv23 = 1);
add_vCtor add_vCtor
( (
@ -58,6 +80,7 @@ public:
dictionary dictionary
); );
}; };
} // pFlow } // pFlow