50 coeff_A_ptr = cdr->diffusion ();
51 coeff_b_ptr = cdr->convection();
52 coeff_c_ptr = cdr->reaction ();
53 rhs_ptr = cdr->rhs ();
58 "Not yet tested for multiple right-hand-sides");
84 coeff_A_ptr( & coeff_A),coeff_b_ptr( & coeff_b),coeff_c_ptr( & coeff_c),
85 flagStabType( flagStabilization )
117 basis.active_into(md.points.col(0), actives);
118 numActive = actives.rows();
121 basis.evalAllDers_into(md.points, 2, basisData,
true);
127 coeff_A_ptr->eval_into(md.values[0], coeff_A_vals);
128 coeff_b_ptr->eval_into(md.values[0], coeff_b_vals);
129 coeff_c_ptr->eval_into(md.values[0], coeff_c_vals);
132 rhs_ptr->eval_into(md.values[0], rhsVals);
135 localMat.setZero(numActive, numActive);
136 localRhs.setZero(numActive, rhsVals.rows());
150 const unsigned d = element.
dim();
157 gsMatrix<T> supgMat( localMat.rows(), localMat.cols() );
160 for (
index_t k = 0; k < quWeights.rows(); ++k)
163 const T weight = quWeights[k] * md.measure(k);
166 transformGradients (md, k, basisGrads, physBasisGrad);
167 transformDeriv2Hgrad (md, k, basisGrads, basis2ndDerivs, physBasisd2);
181 gsMatrix<T> b_basisGrads = coeff_b_vals.col(k).transpose() * physBasisGrad;
186 localRhs.noalias() += weight * ( basisVals.col(k) * rhsVals.col(k).transpose() ) ;
189 localMat.noalias() += weight * (physBasisGrad.transpose() * ( tmp_A * physBasisGrad) );
191 localMat.noalias() += weight * (basisVals.col(k) * b_basisGrads);
193 localMat.noalias() += weight * coeff_c_vals(0,k) * (basisVals.col(k) * basisVals.col(k).transpose());
199 const typename gsFuncData<T>::matrixTransposeView J = md.jacobian(k);
203 grad_b_basisGradsT.setZero();
206 for(
index_t fct_i = 0; fct_i < N; ++fct_i )
209 tmp_basis2ndDerivs.setZero();
212 tmp_basis2ndDerivs(0,0) = physBasisd2(fct_i, 0);
213 tmp_basis2ndDerivs(1,1) = physBasisd2(fct_i, 1);
214 tmp_basis2ndDerivs(0,1) =
215 tmp_basis2ndDerivs(1,0) = physBasisd2(fct_i, 2);
219 tmp_basis2ndDerivs(0,0) = physBasisd2(fct_i, 0);
220 tmp_basis2ndDerivs(1,1) = physBasisd2(fct_i, 1);
221 tmp_basis2ndDerivs(2,2) = physBasisd2(fct_i, 2);
222 tmp_basis2ndDerivs(0,1) =
223 tmp_basis2ndDerivs(1,0) = physBasisd2(fct_i, 3);
224 tmp_basis2ndDerivs(0,2) =
225 tmp_basis2ndDerivs(2,0) = physBasisd2(fct_i, 4);
226 tmp_basis2ndDerivs(1,2) =
227 tmp_basis2ndDerivs(2,1) = physBasisd2(fct_i, 5);
231 GISMO_ERROR(
"What kind of dimension are you using? Should be 2 or 3.");
235 for(
unsigned i = 0; i < d; ++i )
236 for(
unsigned j = 0; j < d; ++j )
237 grad_b_basisGradsT(fct_i, i) += coeff_b_vals(j,k) * tmp_basis2ndDerivs(j,i);
240 supgMat.noalias() += weight * grad_b_basisGradsT * ( tmp_A * physBasisGrad );
241 supgMat.noalias() += weight * (b_basisGrads.transpose() * b_basisGrads);
242 supgMat.noalias() += weight * coeff_c_vals(0,k) * ( b_basisGrads.transpose() * basisVals.col(k).transpose());
254 localMat.noalias() += supgParam * supgMat;
258 inline void localToGlobal(
const index_t patchIndex,
266 system.
push(localMat, localRhs, actives, eliminatedDofs.front(), 0, 0);
284 coeff_b_ptr->eval_into( phys_pts, b_at_phys_pts );
288 b_norm += b_at_phys_pts(i,0) * b_at_phys_pts(i,0);
289 b_norm = math::sqrt( b_norm );
291 T SUPG_param = (T)(0.0);
299 md.points.resize( 2, 4*N1 );
300 aMat.resize( 2, 4*N1 );
302 for(
index_t i = 0; i <= N; ++i )
306 aMat(1,i) = (T)(0.0);
308 aMat(1,i+N1) = (T)(1.0);
310 aMat(0,i+2*N1) = (T)(0.0);
312 aMat(0,i+3*N1) = (T)(1.0);
352 for(
index_t di = 0; di < d; ++di )
353 for(
index_t i = 0; i < aMat.cols(); ++i)
355 md.points(di,i) = ( (T)(1) - aMat(di,i) )*lo[di] + aMat(di,i) * up[di];
358 base->computeMap(md);
359 gsMatrix<T> b_proj = md.values[0].transpose() * b_at_phys_pts;
361 T b_proj_min = b_proj(0,0);
362 T b_proj_max = b_proj(0,0);
363 for(
index_t i = 0; i < b_proj.size(); i++)
365 if( b_proj_min > b_proj(i) )
366 b_proj_min = b_proj(i);
367 if( b_proj_max < b_proj(i) )
368 b_proj_max = b_proj(i);
370 SUPG_param = ( b_proj_max - b_proj_min ) / ( (T)(2) * b_norm );
390 std::vector<gsMatrix<T> > basisData;
A basis represents a family of scalar basis functions defined over a common parameter domain.
Definition gsBasis.h:79
A convection-diffusion-reaction PDE, including source term on the right-hand side.
Definition gsConvDiffRePde.h:36
Class which enables iteration over all elements of a parameter domain.
Definition gsDomainIterator.h:68
virtual const gsVector< T > & lowerCorner() const
Returns the lower corner of the current element.
Definition gsDomainIterator.h:140
short_t dim() const
Return dimension of the elements.
Definition gsDomainIterator.h:115
virtual const gsVector< T > & upperCorner() const
Returns the upper corner of the current element.
Definition gsDomainIterator.h:151
A function from a n-dimensional domain to an m-dimensional image.
Definition gsFunction.h:60
virtual short_t targetDim() const
Dimension of the target space.
Definition gsFunctionSet.h:595
virtual void computeMap(gsMapData< T > &InOut) const
Computes map function data.
Definition gsFunction.hpp:817
Abstract base class representing a geometry map.
Definition gsGeometry.h:93
the gsMapData is a cache of pre-computed function (map) values.
Definition gsFuncData.h:349
A matrix with arbitrary coefficient type and fixed or dynamic size.
Definition gsMatrix.h:41
Class which holds a list of parameters/options, and provides easy access to them.
Definition gsOptionList.h:33
index_t askInt(const std::string &label, const index_t &value=0) const
Reads value for option label from options.
Definition gsOptionList.cpp:117
Abstract class representing a PDE (partial differential equation).
Definition gsPde.h:44
Class representing a reference quadrature rule.
Definition gsQuadRule.h:29
A sparse linear system indexed by sets of degrees of freedom.
Definition gsSparseSystem.h:30
void push(const gsMatrix< T > &localMat, const gsMatrix< T > &localRhs, const gsMatrix< index_t > &actives, const gsMatrix< T > &eliminatedDofs, const size_t r=0, const size_t c=0)
push pushes the local system matrix and rhs for an element to the global system,
Definition gsSparseSystem.h:972
void mapColIndices(const gsMatrix< index_t > &actives, const index_t patchIndex, gsMatrix< index_t > &result, const index_t c=0) const
mapColIndices Maps a set of basis indices by the corresponding dofMapper.
Definition gsSparseSystem.h:584
A vector with arbitrary coefficient type and fixed or dynamic size.
Definition gsVector.h:37
Visitor for the convection-diffusion-reaction equation.
Definition gsVisitorCDR.h:39
gsVisitorCDR(const gsPde< T > &pde)
Constructor.
Definition gsVisitorCDR.h:45
void initialize(const gsBasis< T > &basis, const index_t, const gsOptionList &options, gsQuadRule< T > &rule)
Initialize.
Definition gsVisitorCDR.h:92
gsVisitorCDR(const gsFunction< T > &rhs, const gsFunction< T > &coeff_A, const gsFunction< T > &coeff_b, const gsFunction< T > &coeff_c, stabilizerCDR::method flagStabilization=stabilizerCDR::SUPG)
Constructor for gsVisitorCDR, convection-diffusion-reaction.
Definition gsVisitorCDR.h:78
T getSUPGParameter(const gsVector< T > &lo, const gsVector< T > &up)
Returns the parameter required for SUPG.
Definition gsVisitorCDR.h:270
void assemble(gsDomainIterator< T > &element, const gsVector< T > &quWeights)
Assemble.
Definition gsVisitorCDR.h:140
void evaluate(const gsBasis< T > &basis, const gsGeometry< T > &geo, const gsMatrix< T > &quNodes)
Evaluate on element.
Definition gsVisitorCDR.h:108
#define index_t
Definition gsConfig.h:32
#define GISMO_ERROR(message)
Definition gsDebug.h:118
#define GISMO_ASSERT(cond, message)
Definition gsDebug.h:89
The G+Smo namespace, containing all definitions for the library.
@ NEED_VALUE
Value of the object.
Definition gsForwardDeclarations.h:72
@ NEED_GRAD_TRANSFORM
Gradient transformation matrix.
Definition gsForwardDeclarations.h:77
@ NEED_MEASURE
The density of the measure pull back.
Definition gsForwardDeclarations.h:76
static gsQuadRule< T > get(const gsBasis< T > &basis, const gsOptionList &options, short_t fixDir=-1)
Constructs a quadrature rule based on input options.
Definition gsQuadrature.h:51
method
Definition gsCDRAssembler.h:29
@ SUPG
Use SUPG.
Definition gsCDRAssembler.h:30
@ none
Do not use a stabilizer.
Definition gsCDRAssembler.h:31