28class gsVisitorLinearElasticity
32 gsVisitorLinearElasticity(
const gsPde<T> & pde_, gsSparseMatrix<T> * elimMatrix =
nullptr)
33 : pde_ptr(static_cast<const gsBasePde<T>*>(&pde_)),
37 void initialize(
const gsBasisRefs<T> & basisRefs,
39 const gsOptionList & options,
44 dim = basisRefs.front().dim();
48 T E = options.getReal(
"YoungsModulus");
49 T pr = options.getReal(
"PoissonsRatio");
50 lambda = E * pr / ( ( 1. + pr ) * ( 1. - 2. * pr ) );
51 mu = E / ( 2. * ( 1. + pr ) );
52 forceScaling = options.getReal(
"ForceScaling");
53 localStiffening = options.getReal(
"LocalStiff");
55 I = gsMatrix<T>::Identity(dim,dim);
56 matrixTraceTensor<T>(C,I,I);
58 symmetricIdentityTensor<T>(Ctemp,I);
61 globalIndices.resize(dim);
62 blockNumbers.resize(dim);
65 inline void evaluate(
const gsBasisRefs<T> & basisRefs,
66 const gsGeometry<T> & geo,
67 const gsMatrix<T> & quNodes)
78 basisRefs.front().active_into(quNodes.col(0),localIndicesDisp);
79 N_D = localIndicesDisp.rows();
81 basisRefs.front().evalAllDers_into(quNodes,1,basisValuesDisp);
83 pde_ptr->rhs()->eval_into(md.values[0],forceValues);
86 inline void assemble(gsDomainIterator<T> & element,
87 const gsVector<T> & quWeights)
91 localMat.setZero(dim*N_D,dim*N_D);
92 localRhs.setZero(dim*N_D,1);
94 for (
index_t q = 0; q < quWeights.rows(); ++q)
97 const T weightForce = quWeights[q] * md.measure(q);
98 const T weightBody = quWeights[q] * pow(md.measure(q),1-localStiffening);
100 transformGradients(md,q,basisValuesDisp[1],physGrad);
102 for (
index_t i = 0; i < N_D; i++)
105 setB<T>(B_i,I,physGrad.col(i));
106 tempK = B_i.transpose() * C;
108 for (
index_t j = 0; j < N_D; j++)
110 setB<T>(B_j,I,physGrad.col(j));
112 for (
short_t di = 0; di < dim; ++di)
113 for (
short_t dj = 0; dj < dim; ++dj)
114 localMat(di*N_D+i,dj*N_D+j) += weightBody * K(di,dj);
118 for (
short_t d = 0; d < dim; ++d)
119 localRhs.middleRows(d*N_D,N_D).noalias() += weightForce * forceScaling * forceValues(d,q) * basisValuesDisp[0].col(q) ;
123 inline void localToGlobal(
const int patchIndex,
124 const std::vector<gsMatrix<T> > & eliminatedDofs,
125 gsSparseSystem<T> & system)
128 for (
short_t d = 0; d < dim; ++d)
130 system.mapColIndices(localIndicesDisp, patchIndex, globalIndices[d], d);
131 blockNumbers.at(d) = d;
134 system.pushToRhs(localRhs,globalIndices,blockNumbers);
135 system.pushToMatrix(localMat,globalIndices,eliminatedDofs,blockNumbers,blockNumbers);
137 if (elimMat !=
nullptr)
141 for (
short_t dJ = 0; dJ < dim; ++dJ)
143 for (
short_t dI = 0; dI < dim; ++dI)
144 for (
index_t i = 0; i < N_D; ++i)
145 if (system.colMapper(dI).is_free_index(globalIndices[dI].at(i)))
147 system.mapToGlobalRowIndex(localIndicesDisp.at(i),patchIndex,globalI,dI);
148 for (
index_t j = 0; j < N_D; ++j)
149 if (!system.colMapper(dJ).is_free_index(globalIndices[dJ].at(j)))
151 globalElimJ = system.colMapper(dJ).global_to_bindex(globalIndices[dJ].at(j));
152 elimMat->coeffRef(globalI,elimSize+globalElimJ) += localMat(N_D*dI+i,N_D*dJ+j);
155 elimSize += eliminatedDofs[dJ].rows();
163 const gsBasePde<T> * pde_ptr;
165 T lambda, mu, forceScaling, localStiffening;
169 gsMatrix<T> localMat;
170 gsMatrix<T> localRhs;
172 gsMatrix<index_t> localIndicesDisp;
177 std::vector<gsMatrix<T> > basisValuesDisp;
179 gsMatrix<T> forceValues;
181 gsSparseMatrix<T> * elimMat;
183 gsMatrix<T> C, Ctemp,physGrad, B_i, tempK, B_j, K, I;
185 std::vector< gsMatrix<index_t> > globalIndices;
186 gsVector<index_t> blockNumbers;
IMHO, a useless class, but it is necessary to use the gsAssembler class. Contains proper information ...
#define short_t
Definition gsConfig.h:35
#define index_t
Definition gsConfig.h:32
#define GISMO_UNUSED(x)
Definition gsDebug.h:112
This object is a cache for computed values from an evaluator.
Creates a variety of quadrature rules.
Tensor operations for elasticity.
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