26 const bool overintegrate,
33 m_over(overintegrate),
36 GISMO_ENSURE(m_reg<m_deg,
"regularity cannot be greater or equal to the order!");
38 m_dim = m_basis->dim();
40 GISMO_ASSERT( m_fixDir <
short_t(m_dim) && m_fixDir>-2,
"Invalid input fixDir = "<<m_fixDir);
42 m_nodes.resize(m_dim);
43 m_weights.resize(m_dim);
52 for (
size_t d = 0; d != m_dim; d++)
54 m_end = m_basis->support().col(1);
55 if (
short_t(d)==m_fixDir && m_fixDir!=-1)
59 m_weights[d].resize(2);
68 knots = this->
_init(Bbasis);
70 #if __cplusplus >= 201103L || _MSC_VER >= 1600
71 std::tie(greville,integral) = this->
_integrate(knots);
74 tmp1.first.swap(greville);
75 tmp1.second.swap(integral);
79 #if __cplusplus >= 201103L || _MSC_VER >= 1600
80 std::tie(m_nodes[d],m_weights[d]) = this->
_compute(knots,greville,integral);
83 tmp2.first.swap(m_nodes[d]);
84 tmp2.second.swap(m_weights[d]);
89 for (
index_t k=0; k!=m_nodes[d].size(); k++)
90 m_maps[d][m_nodes[d].at(k)] = m_weights[d].at(k);
142 std::vector<gsVector<T> > elNodes(m_dim), elWeights(m_dim);
144 for (
size_t d = 0; d!=m_dim; d++)
146 elNodes[d].resize(m_nodes[d].size());
147 elWeights[d].resize(m_weights[d].size());
148 for (
typename std::map<T,T>::const_iterator it = m_maps[d].lower_bound(lower[d]); it!= ( upper[d]==m_end[d] ? m_maps[d].end() : m_maps[d].lower_bound(upper[d]) ); it++, k++)
150 elNodes[d].at(k) = it->first;
151 elWeights[d].at(k) = it->second;
153 elNodes[d].conservativeResize(k);
154 elWeights[d].conservativeResize(k);
155 size *= elNodes[d].size();
163 nodes.resize(m_dim,size);
164 weights.resize(size);
171 tmpNodes = elNodes[0].transpose();
172 tmpWeights = elWeights[0].transpose();
174 for (
size_t d = 1; d!=m_dim; d++)
176 nodes.block( 0, 0, d, tmpNodes.cols()*elNodes[d].size() ) = tmpNodes.replicate(1,elNodes[d].size());
178 ones.setOnes(tmpNodes.cols());
179 for (k = 0; k != elNodes[d].size(); k++)
181 nodes.block(d,k*ones.size(),1,ones.size()) = ones.transpose()*elNodes[d].
at(k);
182 weights.segment(k*ones.size(),ones.size()) = (ones.transpose()*elWeights[d].
at(k)).cwiseProduct(tmpWeights);
185 tmpWeights.transpose() = weights.segment(0,tmpWeights.cols()*elWeights[d].size());
186 tmpNodes = nodes.block( 0, 0, d+1, tmpNodes.cols()*elNodes[d].size() );
190 template<
class T>
void
194 GISMO_ASSERT( 1 == m_nodes.size(),
"Inconsistent quadrature mapping (dimension != 1)");
196 nodes.resize(1,m_nodes[0].size());
197 weights.resize(m_weights[0].size());
199 for (
typename std::map<T,T>::const_iterator it = m_maps[0].lower_bound(startVal); it!= ( endVal==m_end[0] ? m_maps[0].end() : m_maps[0].lower_bound(endVal) ); it++, k++)
201 nodes.
at(k) = it->first;
202 weights.
at(k) = it->second;
204 nodes.conservativeResize(1,k);
205 weights.conservativeResize(k);
219 index_t rmin = *std::min_element(multiplicities.begin(), multiplicities.end());
220 index_t rdiff = (m_deg-m_reg)-rmin ;
240 T lowerLength = (knots(1)-knots.
first())/static_cast<T>(numOver+1);
241 T upperLength = (knots.
last()-knots(knots.
uSize()-2))/
static_cast<T
>(numOver+1);
242 for (
index_t k=0; k!=numOver; k++)
244 knots.
insert(knots.
first()+
static_cast<T
>(k+1)*lowerLength);
245 knots.
insert(knots.
last()-
static_cast<T
>(k+1)*upperLength);
254 typedef typename gsKnotVector<T>::const_iterator knotIterator;
255 knotIterator prevKnot = knots.
begin();
257 for (knotIterator it = knots.
begin()+1; it!=knots.
end(); it++ )
259 diff.push_back(*it-*prevKnot);
263 T max = *std::max_element(diff.begin(),diff.end());
264 std::vector<index_t> maxIdx;
266 for (
typename std::vector<T>::iterator it = diff.begin(); it!=diff.end(); it++,k++)
273 static_cast<index_t>(std::ceil(maxIdx.size()/2.))-1);
274 knots.
insert((knots.
at(i) + knots.
at(i+1))/2.) ;
309 typename gsBasis<T>::domainIter domIt = basis.makeDomainIterator();
310 for (; domIt->good(); domIt->next() )
312 quRule.mapTo(domIt->lowerCorner(),domIt->upperCorner(),nodes,weights);
313 basis.active_into(nodes,actives);
314 basis.eval_into(nodes,tmp);
316 for (
index_t k = 0; k!=weights.size(); k++)
317 integrals(actives.
at(k),0) += tmp(k,0);
320 return std::make_pair(greville,integrals);
334 GISMO_ENSURE((size % 2 == 0),
"Number of points should be even!");
337 nodes.resize(size/2);
338 weights.resize(size/2);
339 for (
index_t k = 0; k!=size/2; k++)
341 nodes.
at(k) = 0.5 * (greville.
at(2*k) + greville.
at(2*k+1));
342 weights.
at(k) = integrals(2*k,0) + integrals(2*k+1,0);
348 gsMatrix<T> vals,dvals,vals_tmp,dvals_tmp,res,dres;
350 vals.resize(size,size/2); vals.setZero();
351 dvals.resize(size,size/2); dvals.setZero();
355 for (it = 0; it != itMax; it++)
358 basis.active_into(nodes.transpose(),actives);
359 basis.eval_into(nodes.transpose(),vals_tmp);
360 basis.deriv_into(nodes.transpose(),dvals_tmp);
361 for (
index_t act=0; act!=actives.rows(); act++)
362 for (
index_t pt=0; pt!=actives.cols(); pt++)
364 vals(actives(act,pt),pt) = vals_tmp(act,pt);
365 dvals(actives(act,pt),pt) = dvals_tmp(act,pt);
369 res = vals * weights - integrals;
371 dres.block(0,0,size,size/2) = vals;
372 dres.block(0,size/2,size,size/2) = dvals * weights.asDiagonal();
375 m_solver.compute(dres.sparseView());
376 update = m_solver.solve(-res);
379 weights += update.head(size/2);
380 nodes += update.tail(size/2);
382 GISMO_ENSURE(nodes.minCoeff() > knots.
first(),
"Construction failed: min(nodes) < min(knots) minCoef = "<<nodes.minCoeff()<<
"; min(knots) = "<<knots.
first());
383 GISMO_ENSURE(nodes.maxCoeff() < knots.
last(),
"Construction failed: max(nodes) > max(knots) maxCoef = "<<nodes.maxCoeff()<<
"; min(knots) = "<<knots.
last());
386 if (res.norm() < tol)
390 return std::make_pair(nodes,weights);
index_t size() const
size
Definition: gsBSplineBasis.h:165
multContainer multiplicities() const
Returns vector of multiplicities of the knots.
Definition: gsKnotVector.hpp:714
Class representing a reference quadrature rule.
Definition: gsQuadRule.h:28
#define short_t
Definition: gsConfig.h:35
Provides declaration of Basis abstract interface.
#define index_t
Definition: gsConfig.h:32
#define GISMO_ENSURE(cond, message)
Definition: gsDebug.h:102
void greville_into(gsMatrix< T > &result) const
Definition: gsKnotVector.hpp:991
T last() const
Get the last knot.
Definition: gsKnotVector.h:728
void insert(T knot, mult_t mult=1)
Inserts knot knot into the knot vector with multiplicity mult.
Definition: gsKnotVector.hpp:325
#define GISMO_ASSERT(cond, message)
Definition: gsDebug.h:89
gsKnotVector< T > _init(const gsBSplineBasis< T > *Bbasis) const
Initializes the knot vector for the patch-rule implementation.
Definition: gsPatchRule.hpp:209
std::pair< gsMatrix< T >, gsVector< T > > _integrate(const gsKnotVector< T > &knots) const
Integrates all basis functions from a knot vector (numerically with Gauss)
Definition: gsPatchRule.hpp:291
A univariate B-spline basis.
Definition: gsBSplineBasis.h:694
T at(index_t i) const
Returns the i-th element of the vectorization of the matrix.
Definition: gsMatrix.h:211
Provides a list of labeled parameters/options that can be set and accessed easily.
T first() const
Get the first knot.
Definition: gsKnotVector.h:721
std::pair< gsVector< T >, gsVector< T > > _compute(const gsKnotVector< T > &knots, const gsMatrix< T > &greville, const gsVector< T > &integrals, const T tol=1e-10) const
Computes the points and weights for the patch rule using Newton iterations.
Definition: gsPatchRule.hpp:324
const KnotVectorType & knots(int i=0) const
Returns the knot vector of the basis.
Definition: gsBSplineBasis.h:369
void increaseMultiplicity(const mult_t i=1, bool boundary=false)
Definition: gsKnotVector.hpp:874
T at(index_t i) const
Returns the i-th element of the vector.
Definition: gsVector.h:177
void mapTo(const gsVector< T > &lower, const gsVector< T > &upper, gsMatrix< T > &nodes, gsVector< T > &weights) const
Maps the points in the d-dimensional cube with points lower and upper.
Definition: gsPatchRule.hpp:133
gsPatchRule()
Default empty constructor.
Definition: gsPatchRule.h:93
void reduceMultiplicity(const mult_t i=1, bool boundary=false)
Definition: gsKnotVector.hpp:903
void degreeDecrease(int const &i=1, bool updateInterior=false)
Inverse of degreeIncrease.
Definition: gsKnotVector.h:775
iterator end() const
Returns iterator pointing past the end of the repeated knots.
Definition: gsKnotVector.hpp:124
T at(const size_t &i) const
Returns the value of the i - th knot (counted with repetitions).
Definition: gsKnotVector.h:865
Class for representing a knot vector.
Definition: gsKnotVector.h:79
EIGEN_STRONG_INLINE abs_expr< E > abs(const E &u)
Absolute value.
Definition: gsExpressions.h:4486
iterator begin() const
Returns iterator pointing to the beginning of the repeated knots.
Definition: gsKnotVector.hpp:117
size_t uSize() const
Number of unique knots (i.e., without repetitions).
Definition: gsKnotVector.h:245
Class that represents the (tensor) Gauss-Legendre quadrature rule.
Definition: gsGaussRule.h:27
void degreeIncrease(int const &i=1)
Definition: gsKnotVector.h:759
int degree() const
Returns the degree of the knot vector.
Definition: gsKnotVector.hpp:700
A basis represents a family of scalar basis functions defined over a common parameter domain...
Definition: gsBasis.h:78