Skip to content

Commit

Permalink
add: Cp continuity along periodic boundaries (subdivision)
Browse files Browse the repository at this point in the history
  • Loading branch information
timovanopstal committed Feb 23, 2017
1 parent d175c46 commit ddace43
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 66 deletions.
127 changes: 61 additions & 66 deletions Apps/Common/MultiPatchModelGenerator.C
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,7 @@ bool MultiPatchModelGenerator2D::createTopology (SIMinput& sim) const

ASMs2D* pch0 = static_cast<ASMs2D*>(sim.getPatch(1));
size_t nb = pch0->getNoBasis();

for (size_t b = 1; b <= nb; ++b) {
Go::SplineSurface* srf = pch0->getBasis(b);
int p1 = srf->order_u();
Expand All @@ -542,41 +543,37 @@ bool MultiPatchModelGenerator2D::createTopology (SIMinput& sim) const

for (size_t j = 0; j < ny; ++j)
for (size_t i = 0; i < nx-1; ++i) {
if (!sim.addConnection(IJ(i,j), IJ(i+1,j), 2, 1, 0, b, true, 1, thick(1)))
if (!sim.addConnection(IJ(i,j),IJ(i+1,j),2,1,0,b,true,1,thick(1)))
return false;
}

for (size_t j = 0; j < ny-1; ++j)
for (size_t i = 0; i < nx; ++i)
if (!sim.addConnection(IJ(i,j), IJ(i,j+1), 4, 3, 0, b, true, 1, thick(2)))
if (!sim.addConnection(IJ(i,j),IJ(i,j+1),4,3,0,b,true,1,thick(2)))
return false;
}

if (periodic_x)
for (size_t j = 0; j < ny; ++j)
if (nx > 1) {
if (!sim.addConnection(IJ(0,j), IJ(nx-1,j), 1, 2, 0, 0, false))
return false;
}
else {
IFEM::cout <<"\tPeriodic I-direction P"<< IJ(0,j) << std::endl;
ASMs2D* pch = dynamic_cast<ASMs2D*>(sim.getPatch(IJ(0,j), true));
if (pch)
pch->closeEdges(1);
if (basisIsIn(nb, b, periodic_x))
if (nx < 2) {
std::cerr << "MultiPatchModelGenerator2D::createTopology: smooth"
<< " periodicity only supported across patches (nx > 1).\n";
return false;
} else {
for (size_t j = 0; j < ny; ++j)
if (!sim.addConnection(IJ(0,j),IJ(nx-1,j),1,2,0,b,false,1,thick(1)))
return false;
}

if (periodic_y)
for (size_t i = 0; i < nx; ++i)
if (ny > 1) {
if (!sim.addConnection(IJ(i,0), IJ(i,ny-1), 3, 4, 0, 0, false))
return false;
}
else {
IFEM::cout <<"\tPeriodic J-direction P"<< IJ(i,0)<< std::endl;
ASMs2D* pch = dynamic_cast<ASMs2D*>(sim.getPatch(IJ(i,0), true));
if (pch)
pch->closeEdges(2);
if (basisIsIn(nb, b, periodic_y))
if (ny < 2) {
std::cerr << "MultiPatchModelGenerator2D::createTopology: smooth"
<< " periodicity only supported across patches (ny > 1).\n";
return false;
} else {
for (size_t i = 0; i < nx; ++i)
if (!sim.addConnection(IJ(i,0),IJ(i,ny-1),3,4,0,b,false,1,thick(2)))
return false;
}
}

return true;
}
Expand Down Expand Up @@ -969,6 +966,7 @@ bool MultiPatchModelGenerator3D::createTopology (SIMinput& sim) const

ASMs3D* pch0 = static_cast<ASMs3D*>(sim.getPatch(1));
size_t nb = pch0->getNoBasis();

for (size_t b = 1; b <= nb; ++b) {
Go::SplineVolume* vol = pch0->getBasis(b);
int p1 = vol->order(0);
Expand All @@ -985,60 +983,57 @@ bool MultiPatchModelGenerator3D::createTopology (SIMinput& sim) const
for (size_t k = 0; k < nz; ++k)
for (size_t j = 0; j < ny; ++j)
for (size_t i = 0; i < nx-1; ++i)
if (!sim.addConnection(IJK(i,j,k), IJK(i+1,j,k), 2, 1, 0, b, true, 2, thick(1)))
if (!sim.addConnection(IJK(i,j,k),IJK(i+1,j,k),2,1,0,b,true,2,thick(1)))
return false;

for (size_t k = 0; k < nz; ++k)
for (size_t j = 0; j < ny-1; ++j)
for (size_t i = 0; i < nx; ++i)
if (!sim.addConnection(IJK(i,j,k), IJK(i,j+1,k), 4, 3, 0, b, true, 2, thick(2)))
if (!sim.addConnection(IJK(i,j,k),IJK(i,j+1,k),4,3,0,b,true,2,thick(2)))
return false;

for (size_t k = 0; k < nz-1; ++k)
for (size_t j = 0; j < ny; ++j)
for (size_t i = 0; i < nx; ++i)
if (!sim.addConnection(IJK(i,j,k), IJK(i,j,k+1), 6, 5, 0, b, true, 2, thick(3)))
if (!sim.addConnection(IJK(i,j,k),IJK(i,j,k+1),6,5,0,b,true,2,thick(3)))
return false;
}

if (periodic_x)
for (size_t k = 0; k < nz; ++k)
for (size_t j = 0; j < ny; ++j)
if (nx > 1) {
if (!sim.addConnection(IJK(0,j,k), IJK(nx-1,j,k), 1, 2, 0, 0, false, 2))
return false;
} else {
IFEM::cout <<"\tPeriodic I-direction P"<< IJK(0,j,k) << std::endl;
ASMs3D* pch = dynamic_cast<ASMs3D*>(sim.getPatch(IJK(0,j,k), true));
if (pch)
pch->closeFaces(1);
}
if (basisIsIn(nb, b, periodic_x))
if (nx < 2) {
std::cerr << "MultiPatchModelGenerator3D::createTopology: smooth"
<< " periodicity only supported across patches (nx > 1).\n";
return false;
} else {
for (size_t k = 0; k < nz; ++k)
for (size_t j = 0; j < ny; ++j)
if (!sim.addConnection(IJK(0,j,k),IJK(nx-1,j,k),1,2,0,b,false,2,thick(1)))
return false;
}

if (periodic_y)
for (size_t k = 0; k < nz; ++k)
for (size_t i = 0; i < nx; ++i)
if (ny > 1) {
if (!sim.addConnection(IJK(i,0,k), IJK(i,ny-1,k), 3, 4, 0, 0, false, 2))
return false;
} else {
IFEM::cout <<"\tPeriodic J-direction P"<< IJK(i,0,k) << std::endl;
ASMs3D* pch = dynamic_cast<ASMs3D*>(sim.getPatch(IJK(i,0,k), true));
if (pch)
pch->closeFaces(2);
}

if (periodic_z)
for (size_t j = 0; j < ny; ++j)
for (size_t i = 0; i < nx; ++i)
if (nz > 1) {
if (!sim.addConnection(IJK(i,j,0), IJK(i,j,nz-1), 5, 6, 0, 0, false, 2))
return false;
} else {
IFEM::cout <<"\tPeriodic K-direction P"<< IJK(i,j,0) << std::endl;
ASMs3D* pch = dynamic_cast<ASMs3D*>(sim.getPatch(IJK(i,j,0), true));
if (pch)
pch->closeFaces(3);
}
if (basisIsIn(nb, b, periodic_y))
if (ny < 2) {
std::cerr << "MultiPatchModelGenerator3D::createTopology: smooth"
<< " periodicity only supported across patches (ny > 1).\n";
return false;
} else {
for (size_t k = 0; k < nz; ++k)
for (size_t i = 0; i < nx; ++i)
if (!sim.addConnection(IJK(i,0,k),IJK(i,ny-1,k),3,4,0,b,false,2,thick(2)))
return false;
}

if (basisIsIn(nb, b, periodic_z))
if (nz < 2) {
std::cerr << "MultiPatchModelGenerator3D::createTopology: smooth"
<< " periodicity only supported across patches (nz > 1).\n";
return false;
} else {
for (size_t j = 0; j < ny; ++j)
for (size_t i = 0; i < nx; ++i)
if (!sim.addConnection(IJK(i,j,0),IJK(i,j,nz-1),5,6,0,b,false,2,thick(3)))
return false;
}
}

return true;
}
Expand Down
11 changes: 11 additions & 0 deletions Apps/Common/MultiPatchModelGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@
//! \param[in] old Spline basis to extend
//! \return New spline basis
Go::BsplineBasis extendedBasis(const Go::BsplineBasis& old);
//! \brief Helper for parsing periodic_? variable
//! \param[in] nb Number of bases
//! \param[in] basis Basis index under scrutiny
//! \param[in] periodic Periodicity information to parse
//! \return true if basis is periodic, false otherwise
//! \return New spline basis
static bool basisIsIn(size_t nb, int basis, int periodic) {
for (size_t p=0; p<nb; ++p)
if (basis == (periodic/(int)pow(10,p))%10)
return true;
return false; };


/*!
Expand Down

0 comments on commit ddace43

Please sign in to comment.