32 gsVisitorMuscle(
const gsPde<T> & pde_,
33 const gsPiecewiseFunction<T> & muscleTendon_,
34 const gsVector<T> & fiberDir_,
35 const gsMultiPatch<T> & displacement_,
36 const gsMultiPatch<T> & pressure_)
37 : pde_ptr(static_cast<const gsBasePde<T>*>(&pde_)),
38 muscleTendon(muscleTendon_),
40 displacement(displacement_),
43 void initialize(
const gsBasisRefs<T> & basisRefs,
45 const gsOptionList & options,
49 dim = basisRefs.front().dim();
55 T YM_muscle = options.getReal(
"MuscleYoungsModulus");
56 T PR_muscle = options.getReal(
"MusclePoissonsRatio");
57 T YM_tendon = options.getReal(
"TendonYoungsModulus");
58 T PR_tendon = options.getReal(
"TendonPoissonsRatio");
59 lambda_inv_muscle = ( 1. + PR_muscle ) * ( 1. - 2. * PR_muscle ) / YM_muscle / PR_muscle ;
60 mu_muscle = YM_muscle / ( 2. * ( 1. + PR_muscle ) );
61 lambda_inv_tendon = ( 1. + PR_tendon) * ( 1. - 2. * PR_tendon) / YM_tendon / PR_tendon;
62 mu_tendon = YM_tendon / ( 2. * ( 1. + PR_tendon ) );
63 forceScaling = options.getReal(
"ForceScaling");
64 maxMuscleStress = options.getReal(
"MaxMuscleStress");
65 optFiberStretch = options.getReal(
"OptFiberStretch");
66 deltaW = options.getReal(
"DeltaW");
67 powerNu = options.getReal(
"PowerNu");
68 alpha = options.getReal(
"Alpha");
69 I = gsMatrix<T>::Identity(dim,dim);
71 globalIndices.resize(dim+1);
72 blockNumbers.resize(dim+1);
75 inline void evaluate(
const gsBasisRefs<T> & basisRefs,
76 const gsGeometry<T> & geo,
77 const gsMatrix<T> & quNodes)
88 basisRefs.front().active_into(quNodes.col(0),localIndicesDisp);
89 N_D = localIndicesDisp.rows();
90 basisRefs.back().active_into(quNodes.col(0), localIndicesPres);
91 N_P = localIndicesPres.rows();
93 basisRefs.front().evalAllDers_into(quNodes,1,basisValuesDisp);
95 basisRefs.back().eval_into(quNodes,basisValuesPres);
97 pde_ptr->rhs()->eval_into(md.values[0],forceValues);
99 mdDisplacement.points = quNodes;
103 displacement.patch(patch).computeMap(mdDisplacement);
106 pressure.patch(patch).eval_into(quNodes,pressureValues);
108 muscleTendon.piece(patch).eval_into(quNodes,muscleTendonValues);
111 inline void assemble(gsDomainIterator<T> & element,
112 const gsVector<T> & quWeights)
116 localMat.setZero(dim*N_D + N_P, dim*N_D + N_P);
117 localRhs.setZero(dim*N_D + N_P,1);
119 for (
index_t q = 0; q < quWeights.rows(); ++q)
122 const T mu = muscleTendonValues.at(q) * mu_muscle + (1-muscleTendonValues.at(q))*mu_tendon;
123 const T lambda_inv = muscleTendonValues.at(q) * lambda_inv_muscle + (1-muscleTendonValues.at(q))*lambda_inv_tendon;
125 const T weight = quWeights[q] * md.measure(q);
127 transformGradients(md,q,basisValuesDisp[1],physGradDisp);
129 physDispJac = mdDisplacement.jacobian(q)*(md.jacobian(q).cramerInverse());
133 T J = F.determinant();
135 RCG = F.transpose() * F;
138 RCGinv = RCG.cramerInverse();
140 S = (pressureValues.at(q)-mu)*RCGinv + mu*I;
143 fiberDirPhys = md.jacobian(q)*fiberDir;
144 fiberDirPhys /= fiberDirPhys.norm();
146 M = fiberDirPhys * fiberDirPhys.transpose();
148 T fiberStretch = sqrt((M*RCG).trace());
149 T ratioInExp = (fiberStretch/optFiberStretch-1)/deltaW;
150 T megaExp = exp(-1*pow(
abs(ratioInExp),powerNu));
151 S += M * maxMuscleStress * alpha * muscleTendonValues.at(q)/ pow(fiberStretch,2) * megaExp;
154 symmetricIdentityTensor<T>(C,RCGinv);
155 C *= mu-pressureValues.at(q);
158 matrixTraceTensor<T>(Ctemp,M,M);
159 C += -1*Ctemp*alpha*maxMuscleStress*megaExp/pow(fiberStretch,3)* muscleTendonValues.at(q)*
160 (2 + powerNu*pow(ratioInExp,powerNu-1)/deltaW/optFiberStretch);
163 for (
index_t i = 0; i < N_D; i++)
165 setB<T>(B_i,F,physGradDisp.col(i));
166 materialTangentTemp = B_i.transpose() * C;
168 geometricTangentTemp = S * physGradDisp.col(i);
170 for (
index_t j = 0; j < N_D; j++)
172 setB<T>(B_j,F,physGradDisp.col(j));
173 materialTangent = materialTangentTemp * B_j;
174 T geometricTangent = geometricTangentTemp.transpose() * physGradDisp.col(j);
176 for (
short_t d = 0; d < dim; ++d)
177 materialTangent(d,d) += geometricTangent;
179 for (
short_t di = 0; di < dim; ++di)
180 for (
short_t dj = 0; dj < dim; ++dj)
181 localMat(di*N_D+i, dj*N_D+j) += weight * materialTangent(di,dj);
185 voigtStress<T>(Svec,S);
187 localResidual = B_i.transpose() * Svec;
188 for (
short_t d = 0; d < dim; d++)
189 localRhs(d*N_D+i) -= weight * localResidual(d);
192 divV = F.cramerInverse().transpose() * physGradDisp;
193 for (
short_t d = 0; d < dim; ++d)
195 block = weight*basisValuesPres.col(q)*divV.row(d);
196 localMat.block(dim*N_D,d*N_D,N_P,N_D) += block.block(0,0,N_P,N_D);
197 localMat.block(d*N_D,dim*N_D,N_D,N_P) += block.transpose().block(0,0,N_D,N_P);
200 if (
abs(lambda_inv) > 0)
201 localMat.block(dim*N_D,dim*N_D,N_P,N_P) -=
202 (weight*lambda_inv*basisValuesPres.col(q)*basisValuesPres.col(q).transpose()).block(0,0,N_P,N_P);
204 localRhs.middleRows(dim*N_D,N_P) += weight*basisValuesPres.col(q)*(lambda_inv*pressureValues.at(q)-log(J));
206 for (
short_t d = 0; d < dim; ++d)
207 localRhs.middleRows(d*N_D,N_D).noalias() += weight * forceScaling * forceValues(d,q) * basisValuesDisp[0].col(q) ;
211 inline void localToGlobal(
const int patchIndex,
212 const std::vector<gsMatrix<T> > & eliminatedDofs,
213 gsSparseSystem<T> & system)
216 for (
short_t d = 0; d < dim; ++d)
218 system.mapColIndices(localIndicesDisp,patchIndex,globalIndices[d],d);
219 blockNumbers.at(d) = d;
222 system.mapColIndices(localIndicesPres, patchIndex, globalIndices[dim], dim);
223 blockNumbers.at(dim) = dim;
225 system.pushToRhs(localRhs,globalIndices,blockNumbers);
226 system.pushToMatrix(localMat,globalIndices,eliminatedDofs,blockNumbers,blockNumbers);
232 const gsBasePde<T> * pde_ptr;
234 const gsPiecewiseFunction<T> & muscleTendon;
236 const gsVector<T> & fiberDir;
239 T lambda_inv_muscle, mu_muscle, lambda_inv_tendon, mu_tendon, forceScaling;
241 T maxMuscleStress, optFiberStretch, deltaW, powerNu, alpha;
245 gsMatrix<T> localMat;
246 gsMatrix<T> localRhs;
248 gsMatrix<index_t> localIndicesDisp;
249 gsMatrix<index_t> localIndicesPres;
254 std::vector<gsMatrix<T> > basisValuesDisp;
257 gsMatrix<T> basisValuesPres;
259 gsMatrix<T> forceValues;
261 const gsMultiPatch<T> & displacement;
263 gsMapData<T> mdDisplacement;
265 const gsMultiPatch<T> & pressure;
267 gsMatrix<T> pressureValues;
269 gsMatrix<T> muscleTendonValues;
272 gsMatrix<T> C, Ctemp, physGradDisp, physDispJac, F, RCG, E, S, RCGinv, B_i, materialTangentTemp, B_j, materialTangent, divV, block, I, M;
273 gsVector<T> geometricTangentTemp, Svec, localResidual, fiberDirPhys;
275 std::vector< gsMatrix<index_t> > globalIndices;
276 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
#define GISMO_ENSURE(cond, message)
Definition gsDebug.h:102
This object is a cache for computed values from an evaluator.
Creates a variety of quadrature rules.
Tensor operations for elasticity.
EIGEN_STRONG_INLINE abs_expr< E > abs(const E &u)
Absolute value.
Definition gsExpressions.h:4486
The G+Smo namespace, containing all definitions for the library.
@ NEED_VALUE
Value of the object.
Definition gsForwardDeclarations.h:72
@ NEED_DERIV
Gradient of the object.
Definition gsForwardDeclarations.h:73
@ 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