diff --git a/Apps/Common/MultiPatchModelGenerator.C b/Apps/Common/MultiPatchModelGenerator.C index 1eb6a5815..42919f730 100644 --- a/Apps/Common/MultiPatchModelGenerator.C +++ b/Apps/Common/MultiPatchModelGenerator.C @@ -969,6 +969,12 @@ bool MultiPatchModelGenerator3D::createTopology (SIMinput& sim) const ASMs3D* pch0 = static_cast(sim.getPatch(1)); size_t nb = pch0->getNoBasis(); + auto&& basis_is_in = [nb,this](int basis, int periodic) { + for (size_t p=0; pgetBasis(b); int p1 = vol->order(0); @@ -985,60 +991,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(sim.getPatch(IJK(0,j,k), true)); - if (pch) - pch->closeFaces(1); - } + if (basis_is_in(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(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(sim.getPatch(IJK(i,j,0), true)); - if (pch) - pch->closeFaces(3); - } + if (basis_is_in(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 (basis_is_in(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; }