27 const bool overintegrate,
34 m_over(overintegrate),
37 GISMO_ENSURE(m_reg<m_deg,
"regularity cannot be greater or equal to the order!");
39 m_dim = m_basis->dim();
41 GISMO_ASSERT( m_fixDir <
short_t(m_dim) && m_fixDir>-2,
"Invalid input fixDir = "<<m_fixDir);
43 m_nodes.resize(m_dim);
44 m_weights.resize(m_dim);
53 for (
size_t d = 0; d != m_dim; d++)
55 m_end = m_basis->support().col(1);
56 if (
short_t(d)==m_fixDir && m_fixDir!=-1)
60 m_weights[d].resize(2);
69 knots = this->
_init(Bbasis);
71 #if __cplusplus >= 201103L || _MSC_VER >= 1600
72 std::tie(greville,integral) = this->
_integrate(knots);
75 tmp1.first.swap(greville);
76 tmp1.second.swap(integral);
80 #if __cplusplus >= 201103L || _MSC_VER >= 1600
81 std::tie(m_nodes[d],m_weights[d]) = this->
_compute(knots,greville,integral);
84 tmp2.first.swap(m_nodes[d]);
85 tmp2.second.swap(m_weights[d]);
90 for (
index_t k=0; k!=m_nodes[d].size(); k++)
91 m_maps[d][m_nodes[d].at(k)] = m_weights[d].at(k);
143 std::vector<gsVector<T> > elNodes(m_dim), elWeights(m_dim);
145 for (
size_t d = 0; d!=m_dim; d++)
147 elNodes[d].resize(m_nodes[d].size());
148 elWeights[d].resize(m_weights[d].size());
149 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++)
151 elNodes[d].at(k) = it->first;
152 elWeights[d].at(k) = it->second;
154 elNodes[d].conservativeResize(k);
155 elWeights[d].conservativeResize(k);
156 size *= elNodes[d].size();
164 nodes.resize(m_dim,size);
165 weights.resize(size);
172 tmpNodes = elNodes[0].transpose();
173 tmpWeights = elWeights[0].transpose();
175 for (
size_t d = 1; d!=m_dim; d++)
177 nodes.block( 0, 0, d, tmpNodes.cols()*elNodes[d].size() ) = tmpNodes.replicate(1,elNodes[d].size());
179 ones.setOnes(tmpNodes.cols());
180 for (k = 0; k != elNodes[d].size(); k++)
182 nodes.block(d,k*ones.size(),1,ones.size()) = ones.transpose()*elNodes[d].at(k);
183 weights.segment(k*ones.size(),ones.size()) = (ones.transpose()*elWeights[d].at(k)).cwiseProduct(tmpWeights);
186 tmpWeights.transpose() = weights.segment(0,tmpWeights.cols()*elWeights[d].size());
187 tmpNodes = nodes.block( 0, 0, d+1, tmpNodes.cols()*elNodes[d].size() );
191template<
class T>
void
195 GISMO_ASSERT( 1 == m_nodes.size(),
"Inconsistent quadrature mapping (dimension != 1)");
197 nodes.resize(1,m_nodes[0].size());
198 weights.resize(m_weights[0].size());
200 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++)
202 nodes.
at(k) = it->first;
203 weights.
at(k) = it->second;
205 nodes.conservativeResize(1,k);
206 weights.conservativeResize(k);
220 index_t rmin = *std::min_element(multiplicities.begin(), multiplicities.end());
221 index_t rdiff = (m_deg-m_reg)-rmin ;
241 T lowerLength = (knots(1)-knots.
first())/
static_cast<T
>(numOver+1);
242 T upperLength = (knots.
last()-knots(knots.
uSize()-2))/
static_cast<T
>(numOver+1);
243 for (
index_t k=0; k!=numOver; k++)
245 knots.
insert(knots.
first()+
static_cast<T
>(k+1)*lowerLength);
246 knots.
insert(knots.
last()-
static_cast<T
>(k+1)*upperLength);
255 typedef typename gsKnotVector<T>::const_iterator knotIterator;
256 knotIterator prevKnot = knots.
begin();
258 for (knotIterator it = knots.
begin()+1; it!=knots.
end(); it++ )
260 diff.push_back(*it-*prevKnot);
264 T max = *std::max_element(diff.begin(),diff.end());
265 std::vector<index_t> maxIdx;
267 for (
typename std::vector<T>::iterator it = diff.begin(); it!=diff.end(); it++,k++)
269 if (math::abs(*it-max)/(max)<1e-15)
274 static_cast<index_t>(std::ceil(maxIdx.size()/2.))-1);
275 knots.
insert((knots.
at(i) + knots.
at(i+1))/2.) ;
310 typename gsBasis<T>::domainIter domIt = basis.makeDomainIterator();
311 for (; domIt->good(); domIt->next() )
313 quRule.
mapTo(domIt->lowerCorner(),domIt->upperCorner(),nodes,weights);
314 basis.active_into(nodes,actives);
315 basis.eval_into(nodes,tmp);
317 for (
index_t k = 0; k!=weights.size(); k++)
318 integrals(actives.
at(k),0) += tmp(k,0);
321 return std::make_pair(greville,integrals);
335 GISMO_ENSURE((size % 2 == 0),
"Number of points should be even!");
338 nodes.resize(size/2);
339 weights.resize(size/2);
340 for (
index_t k = 0; k!=size/2; k++)
342 nodes.
at(k) = 0.5 * (greville.
at(2*k) + greville.
at(2*k+1));
343 weights.
at(k) = integrals(2*k,0) + integrals(2*k+1,0);
349 gsMatrix<T> vals,dvals,vals_tmp,dvals_tmp,res,dres;
351 vals.resize(size,size/2); vals.setZero();
352 dvals.resize(size,size/2); dvals.setZero();
356 for (it = 0; it != itMax; it++)
359 basis.active_into(nodes.transpose(),actives);
360 basis.eval_into(nodes.transpose(),vals_tmp);
361 basis.deriv_into(nodes.transpose(),dvals_tmp);
362 for (
index_t act=0; act!=actives.rows(); act++)
363 for (
index_t pt=0; pt!=actives.cols(); pt++)
365 vals(actives(act,pt),pt) = vals_tmp(act,pt);
366 dvals(actives(act,pt),pt) = dvals_tmp(act,pt);
370 res = vals * weights - integrals;
372 dres.block(0,0,size,size/2) = vals;
373 dres.block(0,size/2,size,size/2) = dvals * weights.asDiagonal();
376 m_solver.compute(dres.sparseView());
377 update = m_solver.solve(-res);
380 weights += update.head(size/2);
381 nodes += update.tail(size/2);
383 GISMO_ENSURE(nodes.minCoeff() > knots.
first(),
"Construction failed: min(nodes) < min(knots) minCoef = "<<nodes.minCoeff()<<
"; min(knots) = "<<knots.
first());
384 GISMO_ENSURE(nodes.maxCoeff() < knots.
last(),
"Construction failed: max(nodes) > max(knots) maxCoef = "<<nodes.maxCoeff()<<
"; min(knots) = "<<knots.
last());
387 if (res.norm() < tol)
391 return std::make_pair(nodes,weights);
A univariate B-spline basis.
Definition gsBSplineBasis.h:700
A basis represents a family of scalar basis functions defined over a common parameter domain.
Definition gsBasis.h:79
Class that represents the (tensor) Gauss-Legendre quadrature rule.
Definition gsGaussRule.h:28
Class for representing a knot vector.
Definition gsKnotVector.h:80
void greville_into(gsMatrix< T > &result) const
Definition gsKnotVector.hpp:991
void reduceMultiplicity(const mult_t i=1, bool boundary=false)
Definition gsKnotVector.hpp:903
T at(const size_t &i) const
Returns the value of the i - th knot (counted with repetitions).
Definition gsKnotVector.h:865
iterator begin() const
Returns iterator pointing to the beginning of the repeated knots.
Definition gsKnotVector.hpp:117
T first() const
Get the first knot.
Definition gsKnotVector.h:721
int degree() const
Returns the degree of the knot vector.
Definition gsKnotVector.hpp:700
multContainer multiplicities() const
Returns vector of multiplicities of the knots.
Definition gsKnotVector.hpp:714
T last() const
Get the last knot.
Definition gsKnotVector.h:728
void degreeIncrease(int const &i=1)
Definition gsKnotVector.h:759
void insert(T knot, mult_t mult=1)
Inserts knot knot into the knot vector with multiplicity mult.
Definition gsKnotVector.hpp:325
void degreeDecrease(int const &i=1, bool updateInterior=false)
Inverse of degreeIncrease.
Definition gsKnotVector.h:775
size_t uSize() const
Number of unique knots (i.e., without repetitions).
Definition gsKnotVector.h:245
iterator end() const
Returns iterator pointing past the end of the repeated knots.
Definition gsKnotVector.hpp:124
void increaseMultiplicity(const mult_t i=1, bool boundary=false)
Definition gsKnotVector.hpp:874
A matrix with arbitrary coefficient type and fixed or dynamic size.
Definition gsMatrix.h:41
T at(index_t i) const
Returns the i-th element of the vectorization of the matrix.
Definition gsMatrix.h:211
gsPatchRule()
Default empty constructor.
Definition gsPatchRule.h:91
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:325
gsKnotVector< T > _init(const gsBSplineBasis< T > *Bbasis) const
Initializes the knot vector for the patch-rule implementation.
Definition gsPatchRule.hpp:210
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:134
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:292
Class representing a reference quadrature rule.
Definition gsQuadRule.h:29
virtual void mapTo(const gsVector< T > &lower, const gsVector< T > &upper, gsMatrix< T > &nodes, gsVector< T > &weights) const
Maps quadrature rule (i.e., points and weights) from the reference domain to an element.
Definition gsQuadRule.h:177
const KnotVectorType & knots(int i=0) const
Returns the knot vector of the basis.
Definition gsBSplineBasis.h:371
index_t size() const
Returns the number of elements in the basis.
Definition gsBSplineBasis.h:165
A vector with arbitrary coefficient type and fixed or dynamic size.
Definition gsVector.h:37
T at(index_t i) const
Returns the i-th element of the vector.
Definition gsVector.h:177
Provides declaration of BSplineBasis class.
Provides declaration of Basis abstract interface.
#define short_t
Definition gsConfig.h:35
#define index_t
Definition gsConfig.h:32
#define GISMO_ENSURE(cond, message)
Definition gsDebug.h:102
#define GISMO_ASSERT(cond, message)
Definition gsDebug.h:89
Provides a list of labeled parameters/options that can be set and accessed easily.
The G+Smo namespace, containing all definitions for the library.