ibgoctree.cxx
来自「有限元学习研究用源代码(老外的),供科研人员参考」· CXX 代码 · 共 334 行
CXX
334 行
#include "ibgoctree.hxx"
#include "wzwarning.hxx"
void gpo(ibgoctree g){g->po();}
void gpn(ibgoctree g, wzIndex n){g->pn(n);}
void gpe(ibgoctree g, wzIndex e){g->pe(e);}
void gpf(ibgoctree g, wzIndex e){g->pf(e);}
void gpl(ibgoctree g, wzIndex e){g->pl(e);}
void gpp(ibgoctree g, wzIndex e){g->pp(e);}
void gpc(ibgoctree g, wzIndex e){g->pc(e);}
void gpq(ibgoctree g, wzIndex e){g->pq(e);}
void gpb(ibgoctree g, wzIndex e){g->pb(e);}
static int suppress_unreachable_warning = 1;
void ibgOctree::generate()
{
// refine();
findFaces();
findEdges();
findVertices();
if(suppress_unreachable_warning) return;
gpo(this);
gpn(this,1);
gpe(this,1);
gpf(this,1);
gpp(this,1);
gpc(this,1);
gpq(this,1);
gpb(this,1);
}
void ibgOctree::generateWithoutEdges()
{
findFaces();
}
void ibgOctreeData::po()
{
wzOutput& pout = wzOutput::Default;
pout("<>D grid with <> nodes")<<GridDim,nodes.last();
pout(", <> bnodes, <> faces, <> lines, <> planes, <> edges")<<
bnodes.last(),faces.last(),lines.last(),planes.last(),edges.last();
if(GridDim==3) pout(", <> cells")<<cells.last();
pout("<>")<<"\n";
}
void ibgOctreeData::pn(ibgiNode n)
{
int c,no,bn;
wzOutput& pout = wzOutput::Default;
if(nodes.invalid(n)){
pout("invalid node <> (last is <>)\n")<<n,nodes.last();
return;
}
pout("node <>: [<>,<>,<>] (region <>)\n")<<n,nX[0][n],nX[1][n],nX[2][n],(wzIndex)nPoint[n].region();
if(GridDim==2){
pout(
" < 5> \n"
" y| \n"
" | \n"
" < 5>----< 5>----< %> \n"
" | x \n"
" | \n"
" < 5> \n"
);
if(is_defined(no= nUp[1][n])) pout<<no;
else if(is_outside(no)) pout<<"out";
else pout<<"und";
if(is_defined(no= nDown[0][n])) pout<<no;
else if(is_outside(no)) pout<<"out";
else pout<<"und";
pout << n;
if(is_defined(no= nUp[0][n])) pout<<no;
else if(is_outside(no)) pout<<"out";
else pout<<"und";
if(is_defined(no= nDown[1][n])) pout<<no;
else if(is_outside(no)) pout<<"out";
else pout<<"und";
}else if(GridDim==3){
pout(
" < 5> \n"
" z| \n"
" | < 5> \n"
" |/ \n"
" < 5>----< 5>----< %> \n"
" /| x \n"
" < 5>| \n"
" | \n"
" < 5> \n"
);
if(is_defined(no= nUp[2][n])) pout<<no;
else if(is_outside(no)) pout<<"out";
else pout<<"und";
if(is_defined(no= nUp[1][n])) pout<<no;
else if(is_outside(no)) pout<<"out";
else pout<<"und";
if(is_defined(no= nDown[0][n])) pout<<no;
else if(is_outside(no)) pout<<"out";
else pout<<"und";
pout << n;
if(is_defined(no= nUp[0][n])) pout<<no;
else if(is_outside(no)) pout<<"out";
else pout<<"und";
if(is_defined(no= nDown[1][n])) pout<<no;
else if(is_outside(no)) pout<<"out";
else pout<<"und";
if(is_defined(no= nDown[2][n])) pout<<no;
else if(is_outside(no)) pout<<"out";
else pout<<"und";
pout("cells:\n"
" < 5>---------< 5> \n"
" / | / | \n"
" < 5>--------< 5>| \n"
" z| | | | \n"
" | y| | | \n"
" | < 5>------|-< 5> \n"
" | / x| / \n"
" < 5>--------< 5> \n"
);
if((c=nCell[cdirnpp][n])>0) pout << c;
else pout << "out";
if((c=nCell[cdirppp][n])>0) pout << c;
else pout << "out";
if((c=nCell[cdirnnp][n])>0) pout << c;
else pout << "out";
if((c=nCell[cdirpnp][n])>0) pout << c;
else pout << "out";
if((c=nCell[cdirnpn][n])>0) pout << c;
else pout << "out";
if((c=nCell[cdirppn][n])>0) pout << c;
else pout << "out";
if((c=nCell[cdirnnn][n])>0) pout << c;
else pout << "out";
if((c=nCell[cdirpnn][n])>0) pout << c;
else pout << "out";
}
if(nBoundary.allocated() && (bn=nBoundary[n])){
if(bnType[bn] & ibgoHidden)
pout("is hidden bnode <>\n")<<bn;
else
pout("is visible bnode <>\n")<<bn;
}
}
void ibgOctreeData::pe(ibgIndex e)
{
wzOutput& pout = wzOutput::Default;
if(edges.invalid(e)){
pout("invalid edge <> (last is <>)\n")<<e,edges.last();
return;
}
pout("edge <> [<>,<>,<>] on <> from face <>\n")<<
e,ePoint[e].x(),ePoint[e].y(),ePoint[e].z(),ePlane[e],eFace[e];
cogFlag2 f1(ePoint[e],ePointFace[e],ePointDown[e],ePointUp[e]);
f1.print();
}
void ibgOctreeData::pf(ibgIndex f)
{
wzOutput& pout = wzOutput::Default;
char *typ;
if(faces.invalid(f)){
pout("invalid face <> (last is <>)\n")<<f,faces.last();
return;
}
if(fType[f] & ibgoHidden) typ = "hidden";
else typ = "visible";
pout("<> face <> [<>,<>,<>] on <> (neighbours <>,<>)\n")<<
typ,f,fPoint[f].x(),fPoint[f].y(),fPoint[f].z(),fLine[f],fUp[f],fDown[f];
cogFlag1 f1(fPoint[f],fPointDown[f],fPointUp[f]);
f1.print();
}
void ibgOctreeData::pl(ibgIndex l)
{
int bu,bo,nu,no,f;
wzOutput& pout = wzOutput::Default;
if(lines.invalid(l)){
pout("invalid line <> (last is <>)\n")<<l,lines.last();
return;
}
pout("line <> from <>(<>) to <>(<>) ")<<l,
bu=lNodeDown[l],nu=bnBase[bu],
bo=lNodeUp [l],no=bnBase[bo];
pout("([<>,<>,<>] --> [<>,<>,<>])\n")
,nPoint[nu][0],nPoint[nu][1],nPoint[nu][2]
,nPoint[no][0],nPoint[no][1],nPoint[no][2];
if(f=lFaceUp[l]){
if(f==lFaceDown[l]){
pout(" with face <> [<>,<>,<>]\n")<<f
,fPoint[f].x(),fPoint[f].y(),fPoint[f].z();
}else{
pout(" with faces <>,..., <>\n")<<f,lFaceDown[l];
}
}
}
void ibgOctreeData::pp(ibgIndex p)
{
int c,i;
char* type[3]={"yz","xz","xy"};
wzOutput& pout = wzOutput::Default;
if(planes.invalid(p)){
pout("invalid plane <> (last is <>)\n")<<p,planes.last();
return;
}
pout("<>-plane <>\n"
" nodes boundary nodes \n"
" < 5>---------< 5> < 5>---------< 5> \n"
" | | | | \n"
" | | | | \n"
" | | | | \n"
" < 5>---------< 5> < 5>---------< 5> \n")<<
type[pDirection(p)],p,
bnBase[pNode[2][p]],bnBase[pNode[3][p]],
pNode[2][p],pNode[3][p],
bnBase[pNode[0][p]],bnBase[pNode[1][p]],
pNode[0][p],pNode[1][p];
if(pEdge[p]) pout(" first edge <>\n")<<pEdge[p];
if(PlaneSides){
pout(" <> ")<<"cells:";
for(i=0;i<PlaneSides;i++){
c = pCell[i][p];
if(c<=0) pout( " <> ")<<-c;
else pout( " <> (boundary <>) ")<<bcBase[c],c;
}
pout("<>")<<"\n";
}
}
void ibgOctreeData::pc(ibgIndex bc)
{
int c;
wzOutput& pout = wzOutput::Default;
if(bcells.invalid(bc)){
pout("invalid boundary cell <> (last is <>)\n")<<bc,bcells.last();
return;
}
pout( "boundary cell <> of <> (<> edges)\n")<<bc,c=bcBase[bc],bcType[bc];
pout(
" < 5>---------< 5> \n"
" / | / | \n"
"< 7> < 5>--------< 5>| \n"
" z| | | | \n"
" | y| | | \n"
" | < 5>------|-< 5> < 7> \n"
" | / x| / \n"
"< 7> < 5>--------< 5> < 7> \n"
" < 7> < 7> \n")
,nBoundary[cNode[cdirnpp][c]],nBoundary[cNode[cdirppp][c]]
,nPoint[cNode[cdirppp][c]].z()
,nBoundary[cNode[cdirnnp][c]],nBoundary[cNode[cdirpnp][c]]
,nBoundary[cNode[cdirnpn][c]],nBoundary[cNode[cdirppn][c]]
,nPoint[cNode[cdirppp][c]].y()
,nPoint[cNode[cdirnnn][c]].z()
,nBoundary[cNode[cdirnnn][c]],nBoundary[cNode[cdirpnn][c]]
,nPoint[cNode[cdirnnn][c]].y()
,nPoint[cNode[cdirnnn][c]].x()
,nPoint[cNode[cdirppp][c]].x();
}
void ibgOctreeData::pq(ibgiCell c)
{
wzOutput& pout = wzOutput::Default;
if(cells.invalid(c)){
pout("invalid cell <> (last is <>)\n")<<c,cells.last();
return;
}
pout( "cell <> <> <>\n")<<c;
if(cBoundary[c]) pout<<"bcell:",cBoundary[c];
else pout<<"","";
pout(
" < 5>---------< 5> \n"
" / | / | \n"
"< 7> < 5>--------< 5>| \n"
" z| | | | \n"
" | y| | | \n"
" | < 5>------|-< 5> < 7> \n"
" | / x | / \n"
"< 7> < 5>--------< 5> < 7> \n"
" < 7> < 7> \n")
,cNode[cdirnpp][c],cNode[cdirppp][c]
,nPoint[cNode[cdirppp][c]].z()
,cNode[cdirnnp][c],cNode[cdirpnp][c]
,cNode[cdirnpn][c],cNode[cdirppn][c]
,nPoint[cNode[cdirppp][c]].y()
,nPoint[cNode[cdirnnn][c]].z()
,cNode[cdirnnn][c],cNode[cdirpnn][c]
,nPoint[cNode[cdirnnn][c]].y()
,nPoint[cNode[cdirnnn][c]].x()
,nPoint[cNode[cdirppp][c]].x();
}
void ibgOctreeData::pb(ibgIndex bn)
{
int o,n;
char* typ;
wzOutput& pout = wzOutput::Default;
if(bnodes.invalid(bn)){
pout("invalid boundary node <> (last is <>)\n")<<bn,bnodes.last();
return;
}
if(bnType[bn] & ibgoHidden) typ = "hidden";
else typ = "visible";
pout("<> bnode <> of <>, [<>,<>,<>] up: <> <> <> down: <> <> <>\n")<<
typ,bn,n=bnBase[bn],
nX[0][n],nX[1][n],nX[2][n];
for(o=0;o<3;o++){
if(o>=GridDim) pout<<"";
else if(bnUp[o][bn]) pout<<bnUp[o][bn];
else pout<<"und";
}
for(o=0;o<3;o++){
if(o>=GridDim) pout<<"";
else if(bnDown[o][bn]) pout<<bnDown[o][bn];
else pout<<"und";
}
if(GridDim==3){
pout(
" planes: | - - | + - | - + | + + |\n"
" xy: | <3> | <3> | <3> | <3> |\n"
" xz: | <3> | <3> | <3> | <3> |\n"
" yz: | <3> | <3> | <3> | <3> |\n");
for(o=0;o<12;o++){
if(bnPlane[o][bn]) pout<<bnPlane[o][bn];
else pout<<"und";
}
}else if(GridDim==2){
pout(
" planes xy: nn <> pn <> np <> pp <>\n");
for(o=0;o<4;o++){
if(bnPlane[o][bn]) pout<<bnPlane[o][bn];
else pout<<"und";
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?