49 <<
" boundaries, received "<<
m_boundary.nPatches()<<
".");
61 virtual const gsGeometry<T> &
compute() = 0;
104 template <
typename T>
template <
short_t d>
108 "Expecting "<<2*d<<
" boundaries");
115 m_boundary.computeTopology(1e-3);
116 GISMO_ASSERT(m_boundary.nBoundary()==0,
"The input boundary is not closed.");
120 m_boundary.closeGaps(1e-3);
125 std::vector<Boundary_t*> input;
127 std::vector<short_t> perm;
130 for (
unsigned k = 0; k!=2*d; ++k)
132 for (
unsigned l = k+1; l!=2*d; ++l)
133 if ( (k!=l) && (m_boundary.findInterface(k,l)==NULL) )
135 input.push_back( dynamic_cast<Boundary_t*>(&m_boundary.patch(k)) );
138 "Could not convert to the expected geometry type.");
139 input.push_back( dynamic_cast<Boundary_t*>(&m_boundary.patch(l)) );
142 "Could not convert to the expected geometry type.");
148 GISMO_ASSERT(input.size()==2*d,
"Pairs not correctly identified.");
158 for (
unsigned k = 2; k<2*d; k+=2)
161 if ( ! input[k]->isPatchCorner(v) )
163 std::swap(input[k], input[k+1]);
164 std::swap(perm [k], perm [k+1]);
165 GISMO_ASSERT(input[k]->isPatchCorner(v),
"No joint found");
168 input[k]->setOriginCorner(v);
172 m_boundary.permute(perm);
179 v = input[1]->coefAtCorner(c);
181 for (
unsigned k = 3; k<2*d; k+=2)
182 if ( input[k]->isPatchCorner(v) )
191 for (
unsigned k = 1; k<2*d; k+=2)
192 input[k]->setFurthestCorner(v);
195 m_boundary.computeTopology();
197 GISMO_ASSERT(m_boundary.nBoundary()==0,
"Something went wrong with boundary identification.");
201 std::fill(perm.begin(),perm.end(),0);
202 for (
unsigned k = 0; k!=2*(d-1); ++k)
206 if (bi->first() .side() - k-1 != 0 )
208 if (bi->second().side() - k-1 != 0 )
213 gsWarn<<
"Topology is not the expected one.";
217 for (
unsigned k = 0; k!=2*d; ++k)
219 input[k]->swapDirections(0,1);
221 m_boundary.computeTopology();
226 "Something went wrong with boundary identification.");
233 std::vector<gsBSplineBasis<T>*> cBases(d);
239 for (
unsigned k = 0; k<2*d; k+=2)
241 for (
unsigned l = 0; l!=d-1; ++l)
243 if ( input[k]->basis().degree(l) != input[k+1]->basis().degree(l) )
245 gsWarn<<
"*** Degrees: "<< input[k]->basis().degree(l) <<
", "
246 << input[k+1]->basis().degree(l) <<
"differ.\n";
248 if ( input[k]->knots(l) != input[k+1]->knots(l) )
251 gsWarn<<
"*** Knots differ.\n";
260 for (
unsigned k = 0; k!=d-1; ++k)
262 cBases[k] = input[2*d-2]->basis().component( k ).clone().release();
265 cBases[d-1] = input.front()->basis().component(d-2).clone().release();
284 coefs.setZero(resultBasis.
size(), m_boundary.geoDim());
287 for (
short_t i = 0; i<d; i++ )
289 for (
int s = 0; s<2; s++ )
292 const gsMatrix<T> & bCoefs = input[2*i+s]->coefs();
295 bdr = resultBasis.
boundary(static_cast<boxSide>(1+2*i+s));
298 "Wrong dim "<<s <<
": "<<bdr.rows()<<
" != "<<bCoefs.rows()
299 <<
" at patch "<< 2*i+s <<
", side "<<
static_cast<boxSide>(1+2*i+s)
300 <<
".\n Component:\n"<< input[2*i+s]->basis()
301 <<
"\n ResultBasis:\n"<< resultBasis
305 for (
index_t k = 0; k< bCoefs.rows(); k++ )
306 coefs.row( bdr(k,0) ) = bCoefs.row(k);
Abstract base class representing a geometry map.
Definition: gsGeometry.h:92
Traits for BSplineBasis in more dimensions.
Definition: gsBSplineBasis.h:31
index_t size() const
Returns the number of elements in the basis.
Definition: gsTensorBasis.h:108
#define short_t
Definition: gsConfig.h:35
Struct that defines the boundary sides and corners and types of a geometric object.
Definition: gsBoundary.h:55
virtual const gsGeometry< T > & compute()=0
Main routine that performs the computation (to be implemented in derived classes) ...
const gsGeometry< T > & result() const
Returns the resulting patch. Assumes that compute() has been called before.
Definition: gsPatchGenerator.h:72
#define index_t
Definition: gsConfig.h:32
A tensor product B-spline basis.
Definition: gsTensorBSplineBasis.h:36
#define GISMO_ASSERT(cond, message)
Definition: gsDebug.h:89
void preparePatch(gsTensorBSplineBasis< d, T > &resultBasis, gsMatrix< T > &coefs)
Resolves the configuration of the input boundaries and creates a patch filled with the boundary coeff...
Definition: gsPatchGenerator.h:105
#define gsWarn
Definition: gsDebug.h:50
Provides declaration of the MultiPatch class.
const gsGeometry< T > & compute(const gsMultiPatch< T > &boundary)
Main routine that receives input and performs the computation.
Definition: gsPatchGenerator.h:64
Container class for a set of geometry patches and their topology, that is, the interface connections ...
Definition: gsMultiPatch.h:33
Struct which represents a certain side of a box.
Definition: gsBoundary.h:84
gsGeometry< T > * m_result
Resulting patch.
Definition: gsPatchGenerator.h:97
Abstract class that accepts a set of input boundaries and computes a new geometry.
Definition: gsPatchGenerator.h:31
gsMultiPatch< T > m_boundary
Input boundaries.
Definition: gsPatchGenerator.h:94
gsPatchGenerator(const gsMultiPatch< T > &boundary)
Constructs a patch generator object by a collection of geometries defining the boundaries of a patch...
Definition: gsPatchGenerator.h:44
static boxCorner getFirst(short_t)
helper for iterating on corners of an n-dimensional box
Definition: gsBoundary.h:356
Struct which represents an interface between two patches.
Definition: gsBoundary.h:649
const gsMultiPatch< T > & input()
Returns the input boundaries.
Definition: gsPatchGenerator.h:79
static boxCorner getEnd(short_t dim)
helper for iterating on corners of an n-dimensional box
Definition: gsBoundary.h:372
Struct which represents a certain corner of a hyper-cube.
Definition: gsBoundary.h:291
gsMatrix< index_t > boundary(boxSide const &s) const
Returns the indices of the basis functions that are nonzero at the domain boundary as single-column-m...
Definition: gsBasis.h:520