28 class 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,
43 dim = basisRefs.front().dim();
47 T E = options.getReal(
"YoungsModulus");
48 T pr = options.getReal(
"PoissonsRatio");
49 lambda = E * pr / ( ( 1. + pr ) * ( 1. - 2. * pr ) );
50 mu = E / ( 2. * ( 1. + pr ) );
51 forceScaling = options.getReal(
"ForceScaling");
52 localStiffening = options.getReal(
"LocalStiff");
54 I = gsMatrix<T>::Identity(dim,dim);
55 matrixTraceTensor<T>(C,I,I);
57 symmetricIdentityTensor<T>(Ctemp,I);
60 globalIndices.resize(dim);
61 blockNumbers.resize(dim);
64 inline void evaluate(
const gsBasisRefs<T> & basisRefs,
65 const gsGeometry<T> & geo,
66 const gsMatrix<T> & quNodes)
77 basisRefs.front().active_into(quNodes.col(0),localIndicesDisp);
78 N_D = localIndicesDisp.rows();
80 basisRefs.front().evalAllDers_into(quNodes,1,basisValuesDisp);
82 pde_ptr->rhs()->eval_into(md.values[0],forceValues);
85 inline void assemble(gsDomainIterator<T> & element,
86 const gsVector<T> & quWeights)
89 localMat.setZero(dim*N_D,dim*N_D);
90 localRhs.setZero(dim*N_D,1);
92 for (
index_t q = 0; q < quWeights.rows(); ++q)
95 const T weightForce = quWeights[q] * md.measure(q);
96 const T weightBody = quWeights[q] * pow(md.measure(q),1-localStiffening);
98 transformGradients(md,q,basisValuesDisp[1],physGrad);
100 for (
index_t i = 0; i < N_D; i++)
103 setB<T>(B_i,I,physGrad.col(i));
104 tempK = B_i.transpose() * C;
106 for (
index_t j = 0; j < N_D; j++)
108 setB<T>(B_j,I,physGrad.col(j));
110 for (
short_t di = 0; di < dim; ++di)
111 for (
short_t dj = 0; dj < dim; ++dj)
112 localMat(di*N_D+i,dj*N_D+j) += weightBody * K(di,dj);
116 for (
short_t d = 0; d < dim; ++d)
117 localRhs.middleRows(d*N_D,N_D).noalias() += weightForce * forceScaling * forceValues(d,q) * basisValuesDisp[0].col(q) ;
121 inline void localToGlobal(
const int patchIndex,
122 const std::vector<gsMatrix<T> > & eliminatedDofs,
123 gsSparseSystem<T> & system)
126 for (
short_t d = 0; d < dim; ++d)
128 system.mapColIndices(localIndicesDisp, patchIndex, globalIndices[d], d);
129 blockNumbers.at(d) = d;
132 system.pushToRhs(localRhs,globalIndices,blockNumbers);
133 system.pushToMatrix(localMat,globalIndices,eliminatedDofs,blockNumbers,blockNumbers);
135 if (elimMat !=
nullptr)
139 for (
short_t dJ = 0; dJ < dim; ++dJ)
141 for (
short_t dI = 0; dI < dim; ++dI)
142 for (
index_t i = 0; i < N_D; ++i)
143 if (system.colMapper(dI).is_free_index(globalIndices[dI].at(i)))
145 system.mapToGlobalRowIndex(localIndicesDisp.at(i),patchIndex,globalI,dI);
146 for (
index_t j = 0; j < N_D; ++j)
147 if (!system.colMapper(dJ).is_free_index(globalIndices[dJ].at(j)))
149 globalElimJ = system.colMapper(dJ).global_to_bindex(globalIndices[dJ].at(j));
150 elimMat->coeffRef(globalI,elimSize+globalElimJ) += localMat(N_D*dI+i,N_D*dJ+j);
153 elimSize += eliminatedDofs[dJ].rows();
161 const gsBasePde<T> * pde_ptr;
163 T lambda, mu, forceScaling, localStiffening;
167 gsMatrix<T> localMat;
168 gsMatrix<T> localRhs;
170 gsMatrix<index_t> localIndicesDisp;
175 std::vector<gsMatrix<T> > basisValuesDisp;
177 gsMatrix<T> forceValues;
179 gsSparseMatrix<T> * elimMat;
181 gsMatrix<T> C, Ctemp,physGrad, B_i, tempK, B_j, K, I;
183 std::vector< gsMatrix<index_t> > globalIndices;
184 gsVector<index_t> blockNumbers;
#define short_t
Definition: gsConfig.h:35
#define index_t
Definition: gsConfig.h:32
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:48
Creates a variety of quadrature rules.
IMHO, a useless class, but it is necessary to use the gsAssembler class. Contains proper information ...
The density of the measure pull back.
Definition: gsForwardDeclarations.h:76
Tensor operations for elasticity.
Value of the object.
Definition: gsForwardDeclarations.h:72
Gradient transformation matrix.
Definition: gsForwardDeclarations.h:77
This object is a cache for computed values from an evaluator.