31template <
short_t d,
class T,
bool bending>
32gsThinShellAssemblerDWR<d, T, bending>::gsThinShellAssemblerDWR(
33 const gsMultiPatch<T> & patches,
34 const gsMultiBasis<T> & basisL,
35 const gsMultiBasis<T> & basisH,
36 const gsBoundaryConditions<T> & bconditions,
37 const gsFunction<T> & surface_force,
41gsThinShellAssemblerDWR(patches,basisL,basisH,bconditions,surface_force,materialmatrix.get())
46template <
short_t d,
class T,
bool bending>
47gsThinShellAssemblerDWR<d, T, bending>::gsThinShellAssemblerDWR(
48 const gsMultiPatch<T> & patches,
49 const gsMultiBasis<T> & basisL,
50 const gsMultiBasis<T> & basisH,
51 const gsBoundaryConditions<T> & bconditions,
52 const gsFunction<T> & surface_force,
53 gsMaterialMatrixBase<T> * materialmatrix
56 Base(patches,basisL,bconditions,surface_force,materialmatrix),
59 m_assemblerL =
new gsThinShellAssembler<d,T,bending>(patches,basisL,bconditions,surface_force,materialmatrix);
60 m_assemblerH =
new gsThinShellAssembler<d,T,bending>(patches,basisH,bconditions,surface_force,materialmatrix);
62 m_dL = gsVector<T>::Zero(m_assemblerL->numDofs());
63 m_dH = gsVector<T>::Zero(m_assemblerH->numDofs());
66template <
short_t d,
class T,
bool bending>
67ThinShellAssemblerStatus gsThinShellAssemblerDWR<d, T, bending>::_assembleMass(gsThinShellAssemblerBase<T> * assembler, gsSparseMatrix<T> & result,
bool lumped)
70 result = assembler->matrix();
71 GISMO_ENSURE(status==ThinShellAssemblerStatus::Success,
"Assembly failed");
128template <
short_t d,
class T,
bool bending>
131 std::pair<gsSparseMatrix<T>,gsVector<T>> result;
133 m_matrixL = result.first;
134 m_pL = result.second;
135 GISMO_ENSURE(status==ThinShellAssemblerStatus::Success,
"Assembly failed");
139template <
short_t d,
class T,
bool bending>
142 std::pair<gsSparseMatrix<T>,gsVector<T>> result;
144 m_matrixH = result.first;
145 m_pH = result.second;
149template <
short_t d,
class T,
bool bending>
150ThinShellAssemblerStatus gsThinShellAssemblerDWR<d, T, bending>::_assemble(gsThinShellAssemblerBase<T> * assembler, std::pair<gsSparseMatrix<T>,gsVector<T>> & result)
153 result = std::make_pair(assembler->matrix(),assembler->rhs());
154 GISMO_ENSURE(status==ThinShellAssemblerStatus::Success,
"Assembly failed");
158template <
short_t d,
class T,
bool bending>
159ThinShellAssemblerStatus gsThinShellAssemblerDWR<d, T, bending>::_assembleMatrix(gsThinShellAssemblerBase<T> * assembler, gsSparseMatrix<T> & result)
162 result = assembler->matrix();
163 GISMO_ENSURE(status==ThinShellAssemblerStatus::Success,
"Assembly failed");
167template <
short_t d,
class T,
bool bending>
168ThinShellAssemblerStatus gsThinShellAssemblerDWR<d, T, bending>::_assembleMatrix(gsThinShellAssemblerBase<T> * assembler,
const gsMultiPatch<T> & deformed, gsSparseMatrix<T> & result)
171 result = assembler->matrix();
172 GISMO_ENSURE(status==ThinShellAssemblerStatus::Success,
"Assembly failed");
176template <
short_t d,
class T,
bool bending>
177ThinShellAssemblerStatus gsThinShellAssemblerDWR<d, T, bending>::_assemblePrimal(gsThinShellAssemblerBase<T> * assembler,
const gsMultiPatch<T> & deformed, gsVector<T> & result)
180 result = assembler->rhs();
181 GISMO_ENSURE(status==ThinShellAssemblerStatus::Success,
"Assembly failed");
185template <
short_t d,
class T,
bool bending>
186ThinShellAssemblerStatus gsThinShellAssemblerDWR<d, T, bending>::_assemblePrimal(gsThinShellAssemblerBase<T> * assembler, gsVector<T> & result)
189 GISMO_ENSURE(status==ThinShellAssemblerStatus::Success,
"Assembly failed");
190 result = assembler->rhs();
194template <
short_t d,
class T,
bool bending>
195ThinShellAssemblerStatus gsThinShellAssemblerDWR<d, T, bending>::_assembleDual(gsThinShellAssemblerBase<T> * assembler,
const gsMultiPatch<T> & primal,
const gsMultiPatch<T> & deformed, gsVector<T> & result)
197 GISMO_ASSERT(m_component < d || m_component==9,
"Component is out of bounds");
205 gsExprAssembler<T> exprAssembler = assembler->assembler();
206 exprAssembler.cleanUp();
207 GISMO_ENSURE(assembler->options().hasGroup(
"ExprAssembler"),
"The option list does not contain options with the label 'ExprAssembler'!");
208 exprAssembler.setOptions(assembler->options().getGroup(
"ExprAssembler"));
211 geometryMap Gori = exprAssembler.getMap(m_patches);
212 geometryMap Gdef = exprAssembler.getMap(deformed);
215 exprAssembler.initSystem();
216 exprAssembler.initVector(1);
219 space space = exprAssembler.trialSpace(0);
221 space.setup(m_bcs, dirichlet::homogeneous, 0);
224 auto usol = exprAssembler.getCoeff(primal);
227 gsMaterialMatrixEval<T,MaterialOutput::StretchTransform> Tstretchf(assembler->materials(),&deformed,Z);
228 gsMaterialMatrixEval<T,MaterialOutput::PStressTransform> Tpstressf(assembler->materials(),&deformed,Z);
229 auto Tstretch = exprAssembler.getCoeff(Tstretchf);
230 auto Tpstress = exprAssembler.getCoeff(Tpstressf);
233 gsMaterialMatrixEval<T,MaterialOutput::MatrixA> mmAf(assembler->materials(),&deformed,Z);
234 gsMaterialMatrixEval<T,MaterialOutput::MatrixD> mmDf(assembler->materials(),&deformed,Z);
235 auto mmA = exprAssembler.getCoeff(mmAf);
236 auto mmD = exprAssembler.getCoeff(mmDf);
239 gsMaterialMatrixIntegrate<T,MaterialOutput::MatrixA> mmAfi(assembler->materials(),&deformed);
240 gsMaterialMatrixIntegrate<T,MaterialOutput::MatrixB> mmBfi(assembler->materials(),&deformed);
241 gsMaterialMatrixIntegrate<T,MaterialOutput::MatrixC> mmCfi(assembler->materials(),&deformed);
242 gsMaterialMatrixIntegrate<T,MaterialOutput::MatrixD> mmDfi(assembler->materials(),&deformed);
243 auto mmAi = exprAssembler.getCoeff(mmAfi);
244 auto mmBi = exprAssembler.getCoeff(mmBfi);
245 auto mmCi = exprAssembler.getCoeff(mmCfi);
246 auto mmDi = exprAssembler.getCoeff(mmDfi);
249 gsMaterialMatrixEval<T,MaterialOutput::VectorN> S0f(assembler->materials(),&deformed,Z);
250 gsMaterialMatrixEval<T,MaterialOutput::VectorM> S1f(assembler->materials(),&deformed,Z);
251 auto S0 = exprAssembler.getCoeff(S0f);
252 auto S1 = exprAssembler.getCoeff(S1f);
255 gsMaterialMatrixEval<T,MaterialOutput::PStress> P0f(assembler->materials(),&deformed,Z);
256 auto P0 = exprAssembler.getCoeff(P0f);
259 gsMaterialMatrixIntegrate<T,MaterialOutput::VectorN> Nf(assembler->materials(),&deformed);
260 gsMaterialMatrixIntegrate<T,MaterialOutput::VectorM> Mf(assembler->materials(),&deformed);
261 auto N = exprAssembler.getCoeff(Nf);
262 auto M = exprAssembler.getCoeff(Mf);
265 gsFunctionExpr<T> mult2t(
"1",
"0",
"0",
"0",
"1",
"0",
"0",
"0",
"2",2);
266 auto m2 = exprAssembler.getCoeff(mult2t);
270 gsFunctionExpr<T> mult12t(
"1",
"0",
"0",
"0",
"1",
"0",
"0",
"0",
"0.5",2);
271 auto m12 = exprAssembler.getCoeff(mult12t);
277 auto lambda = Cm *
reshape(Tstretch,3,3).tr();
278 auto lambda_der = Cm_der *
reshape(Tstretch,3,3).tr();
282 auto Em_der =
flat(
jac(Gdef).tr() *
jac(space) ) ;
286 auto Emp_der= (Em_der *
reshape(m12,3,3)) *
reshape(Tstretch,3,3).tr();
289 auto Ef = ( deriv2(Gori,sn(Gori).normalized().tr()) - deriv2(Gdef,sn(Gdef).normalized().tr()) ) *
reshape(m2,3,3) ;
290 auto Ef_der = -( deriv2(space,sn(Gdef).normalized().tr() ) + deriv2(Gdef,var1(space,Gdef) ) ) *
reshape(m2,3,3);
293 auto Sm_der = Em_der *
reshape(mmA,3,3);
296 auto Smp_der = Sm_der *
reshape(Tpstress,3,3).tr();
299 auto Sf_der = Ef_der *
reshape(mmD,3,3);
302 auto N_der = Em_der *
reshape(mmAi,3,3) + Ef_der *
reshape(mmBi,3,3);
303 auto M_der = Em_der *
reshape(mmCi,3,3) + Ef_der *
reshape(mmDi,3,3);
305 if (m_goalFunction == GoalFunction::Displacement)
309 auto expr = 2 * space * usol *
meas(Gori);
312 exprAssembler.assemble(expr);
313 result = exprAssembler.rhs();
314 return ThinShellAssemblerStatus::Success;
318 exprAssembler.cleanUp();
319 return ThinShellAssemblerStatus::AssemblyError;
324 auto expr = space * gismo::expr::uv(m_component,3) *
meas(Gori);
327 exprAssembler.assemble(expr);
328 result = exprAssembler.rhs();
329 return ThinShellAssemblerStatus::Success;
333 exprAssembler.cleanUp();
334 return ThinShellAssemblerStatus::AssemblyError;
338 else if (m_goalFunction == GoalFunction::Stretch)
342 auto expr = 2 * lambda_der * lambda.tr() *
meas(Gori);
345 exprAssembler.assemble(expr);
346 result = exprAssembler.rhs();
347 return ThinShellAssemblerStatus::Success;
351 exprAssembler.cleanUp();
352 return ThinShellAssemblerStatus::AssemblyError;
357 auto expr = lambda_der * gismo::expr::uv(m_component,3) *
meas(Gori);
360 exprAssembler.assemble(expr);
361 result = exprAssembler.rhs();
362 return ThinShellAssemblerStatus::Success;
366 exprAssembler.cleanUp();
367 return ThinShellAssemblerStatus::AssemblyError;
371 else if (m_goalFunction == GoalFunction::PStrain)
375 auto expr = 2 * Emp_der * Emp.tr() *
meas(Gori);
378 exprAssembler.assemble(expr);
379 result = exprAssembler.rhs();
380 return ThinShellAssemblerStatus::Success;
384 exprAssembler.cleanUp();
385 return ThinShellAssemblerStatus::AssemblyError;
390 auto expr = Emp_der * gismo::expr::uv(m_component,3) *
meas(Gori);
393 exprAssembler.assemble(expr);
394 result = exprAssembler.rhs();
395 return ThinShellAssemblerStatus::Success;
399 exprAssembler.cleanUp();
400 return ThinShellAssemblerStatus::AssemblyError;
404 else if (m_goalFunction == GoalFunction::PStress)
407 gsMatrix<T> convMat(3,2);
409 convMat(0,0) = convMat(1,1) = 1;
410 gsConstantFunction<T> convFun(convMat.reshape(6,1),2);
411 auto conv = exprAssembler.getCoeff(convFun);
414 auto expr = 2 * Smp_der *
reshape(conv,3,2) * P0 *
meas(Gori);
417 exprAssembler.assemble(expr);
418 result = exprAssembler.rhs();
419 return ThinShellAssemblerStatus::Success;
423 exprAssembler.cleanUp();
424 return ThinShellAssemblerStatus::AssemblyError;
429 GISMO_ASSERT(m_component < 2,
"Can only select principle stress component 0 or 1, but "<<m_component<<
" selected.");
430 auto expr = Smp_der *
reshape(conv,3,2) * gismo::expr::uv(m_component,2) *
meas(Gori);
433 exprAssembler.assemble(expr);
434 result = exprAssembler.rhs();
435 return ThinShellAssemblerStatus::Success;
439 exprAssembler.cleanUp();
440 return ThinShellAssemblerStatus::AssemblyError;
444 else if (m_goalFunction == GoalFunction::MembraneStrain)
448 auto expr = 2 * Em_der * Em.tr() *
meas(Gori);
451 exprAssembler.assemble(expr);
452 result = exprAssembler.rhs();
453 return ThinShellAssemblerStatus::Success;
457 exprAssembler.cleanUp();
458 return ThinShellAssemblerStatus::AssemblyError;
463 auto expr = Em_der * gismo::expr::uv(m_component,3) *
meas(Gori);
466 exprAssembler.assemble(expr);
467 result = exprAssembler.rhs();
468 return ThinShellAssemblerStatus::Success;
472 exprAssembler.cleanUp();
473 return ThinShellAssemblerStatus::AssemblyError;
477 else if (m_goalFunction == GoalFunction::MembraneStress)
481 auto expr = 2 * Sm_der * S0 *
meas(Gori);
484 exprAssembler.assemble(expr);
485 result = exprAssembler.rhs();
486 return ThinShellAssemblerStatus::Success;
490 exprAssembler.cleanUp();
491 return ThinShellAssemblerStatus::AssemblyError;
496 auto expr = Sm_der * gismo::expr::uv(m_component,3) *
meas(Gori);
499 exprAssembler.assemble(expr);
500 result = exprAssembler.rhs();
501 return ThinShellAssemblerStatus::Success;
505 exprAssembler.cleanUp();
506 return ThinShellAssemblerStatus::AssemblyError;
510 else if (m_goalFunction == GoalFunction::MembraneForce)
514 auto expr = 2 * N_der * N *
meas(Gori);
517 exprAssembler.assemble(expr);
518 result = exprAssembler.rhs();
519 return ThinShellAssemblerStatus::Success;
523 exprAssembler.cleanUp();
524 return ThinShellAssemblerStatus::AssemblyError;
529 auto expr = N_der * gismo::expr::uv(m_component,3) *
meas(Gori);
532 exprAssembler.assemble(expr);
533 result = exprAssembler.rhs();
534 return ThinShellAssemblerStatus::Success;
538 exprAssembler.cleanUp();
539 return ThinShellAssemblerStatus::AssemblyError;
543 else if (m_goalFunction == GoalFunction::FlexuralStrain)
547 auto expr = 2 * Ef_der * Ef.tr() *
meas(Gori);
550 exprAssembler.assemble(expr);
551 result = exprAssembler.rhs();
552 return ThinShellAssemblerStatus::Success;
556 exprAssembler.cleanUp();
557 return ThinShellAssemblerStatus::AssemblyError;
562 auto expr = Ef_der * gismo::expr::uv(m_component,3) *
meas(Gori);
565 exprAssembler.assemble(expr);
566 result = exprAssembler.rhs();
567 return ThinShellAssemblerStatus::Success;
571 exprAssembler.cleanUp();
572 return ThinShellAssemblerStatus::AssemblyError;
576 else if (m_goalFunction == GoalFunction::FlexuralStress)
580 auto expr = 2 * Sf_der * S1 *
meas(Gori);
583 exprAssembler.assemble(expr);
584 result = exprAssembler.rhs();
585 return ThinShellAssemblerStatus::Success;
589 exprAssembler.cleanUp();
590 return ThinShellAssemblerStatus::AssemblyError;
595 auto expr = Sf_der * gismo::expr::uv(m_component,3) *
meas(Gori);
598 exprAssembler.assemble(expr);
599 result = exprAssembler.rhs();
600 return ThinShellAssemblerStatus::Success;
604 exprAssembler.cleanUp();
605 return ThinShellAssemblerStatus::AssemblyError;
609 else if (m_goalFunction == GoalFunction::FlexuralMoment)
613 auto expr = 2 * M_der * M *
meas(Gori);
616 exprAssembler.assemble(expr);
617 result = exprAssembler.rhs();
618 return ThinShellAssemblerStatus::Success;
622 exprAssembler.cleanUp();
623 return ThinShellAssemblerStatus::AssemblyError;
628 auto expr = M_der * gismo::expr::uv(m_component,3) *
meas(Gori);
631 exprAssembler.assemble(expr);
632 result = exprAssembler.rhs();
633 return ThinShellAssemblerStatus::Success;
637 exprAssembler.cleanUp();
638 return ThinShellAssemblerStatus::AssemblyError;
646template <
short_t d,
class T,
bool bending>
647ThinShellAssemblerStatus gsThinShellAssemblerDWR<d, T, bending>::_assembleDual(
const bContainer & bnds, gsThinShellAssemblerBase<T> * assembler,
const gsMultiPatch<T> & primal,
const gsMultiPatch<T> & deformed, gsVector<T> & result)
649 GISMO_ASSERT(m_component < d || m_component==9,
"Component is out of bounds");
657 gsExprAssembler<T> exprAssembler = assembler->assembler();
658 exprAssembler.cleanUp();
659 GISMO_ENSURE(assembler->options().hasGroup(
"ExprAssembler"),
"The option list does not contain options with the label 'ExprAssembler'!");
660 exprAssembler.setOptions(assembler->options().getGroup(
"ExprAssembler"));
663 geometryMap Gori = exprAssembler.getMap(m_patches);
664 geometryMap Gdef = exprAssembler.getMap(deformed);
667 exprAssembler.initSystem();
668 exprAssembler.initVector(1);
671 result = exprAssembler.rhs();
672 return ThinShellAssemblerStatus::Success;
676 space space = exprAssembler.trialSpace(0);
678 space.setup(m_bcs, dirichlet::homogeneous, 0);
681 auto usol = exprAssembler.getCoeff(primal);
684 gsMaterialMatrixEval<T,MaterialOutput::StretchTransform> Tstretchf(assembler->materials(),&deformed,Z);
685 gsMaterialMatrixEval<T,MaterialOutput::PStressTransform> Tpstressf(assembler->materials(),&deformed,Z);
686 auto Tstretch = exprAssembler.getCoeff(Tstretchf);
687 auto Tpstress = exprAssembler.getCoeff(Tpstressf);
690 gsMaterialMatrixEval<T,MaterialOutput::MatrixA> mmAf(assembler->materials(),&deformed,Z);
691 gsMaterialMatrixEval<T,MaterialOutput::MatrixD> mmDf(assembler->materials(),&deformed,Z);
692 auto mmA = exprAssembler.getCoeff(mmAf);
693 auto mmD = exprAssembler.getCoeff(mmDf);
696 gsMaterialMatrixIntegrate<T,MaterialOutput::MatrixA> mmAfi(assembler->materials(),&deformed);
697 gsMaterialMatrixIntegrate<T,MaterialOutput::MatrixB> mmBfi(assembler->materials(),&deformed);
698 gsMaterialMatrixIntegrate<T,MaterialOutput::MatrixC> mmCfi(assembler->materials(),&deformed);
699 gsMaterialMatrixIntegrate<T,MaterialOutput::MatrixD> mmDfi(assembler->materials(),&deformed);
700 auto mmAi = exprAssembler.getCoeff(mmAfi);
701 auto mmBi = exprAssembler.getCoeff(mmBfi);
702 auto mmCi = exprAssembler.getCoeff(mmCfi);
703 auto mmDi = exprAssembler.getCoeff(mmDfi);
706 gsMaterialMatrixEval<T,MaterialOutput::VectorN> S0f(assembler->materials(),&deformed,Z);
707 gsMaterialMatrixEval<T,MaterialOutput::VectorM> S1f(assembler->materials(),&deformed,Z);
708 auto S0 = exprAssembler.getCoeff(S0f);
709 auto S1 = exprAssembler.getCoeff(S1f);
712 gsMaterialMatrixEval<T,MaterialOutput::PStress> P0f(assembler->materials(),&deformed,Z);
713 auto P0 = exprAssembler.getCoeff(P0f);
716 gsMaterialMatrixIntegrate<T,MaterialOutput::VectorN> Nf(assembler->materials(),&deformed);
717 gsMaterialMatrixIntegrate<T,MaterialOutput::VectorM> Mf(assembler->materials(),&deformed);
718 auto N = exprAssembler.getCoeff(Nf);
719 auto M = exprAssembler.getCoeff(Mf);
722 gsFunctionExpr<T> mult2t(
"1",
"0",
"0",
"0",
"1",
"0",
"0",
"0",
"2",2);
723 auto m2 = exprAssembler.getCoeff(mult2t);
727 gsFunctionExpr<T> mult12t(
"1",
"0",
"0",
"0",
"1",
"0",
"0",
"0",
"0.5",2);
728 auto m12 = exprAssembler.getCoeff(mult12t);
734 auto lambda = Cm *
reshape(Tstretch,3,3).tr();
735 auto lambda_der = Cm_der *
reshape(Tstretch,3,3).tr();
739 auto Em_der =
flat(
jac(Gdef).tr() *
jac(space) ) ;
743 auto Emp_der= (Em_der *
reshape(m12,3,3)) *
reshape(Tstretch,3,3).tr();
746 auto Ef = ( deriv2(Gori,sn(Gori).normalized().tr()) - deriv2(Gdef,sn(Gdef).normalized().tr()) ) *
reshape(m2,3,3) ;
747 auto Ef_der = -( deriv2(space,sn(Gdef).normalized().tr() ) + deriv2(Gdef,var1(space,Gdef) ) ) *
reshape(m2,3,3);
750 auto Sm_der = Em_der *
reshape(mmA,3,3);
753 auto Smp_der = Sm_der *
reshape(Tpstress,3,3).tr();
756 auto Sf_der = Ef_der *
reshape(mmD,3,3);
759 auto N_der = Em_der *
reshape(mmAi,3,3) + Ef_der *
reshape(mmBi,3,3);
760 auto M_der = Em_der *
reshape(mmCi,3,3) + Ef_der *
reshape(mmDi,3,3);
762 if (m_goalFunction == GoalFunction::Displacement)
766 auto expr = 2 * space * usol *
meas(Gori);
769 exprAssembler.assembleBdr(bnds,expr);
770 result = exprAssembler.rhs();
771 return ThinShellAssemblerStatus::Success;
775 exprAssembler.cleanUp();
776 return ThinShellAssemblerStatus::AssemblyError;
781 auto expr = space * gismo::expr::uv(m_component,3) *
meas(Gori);
784 exprAssembler.assembleBdr(bnds,expr);
785 result = exprAssembler.rhs();
786 return ThinShellAssemblerStatus::Success;
790 exprAssembler.cleanUp();
791 return ThinShellAssemblerStatus::AssemblyError;
795 else if (m_goalFunction == GoalFunction::Stretch)
799 auto expr = 2 * lambda_der * lambda.tr() *
meas(Gori);
802 exprAssembler.assembleBdr(bnds,expr);
803 result = exprAssembler.rhs();
804 return ThinShellAssemblerStatus::Success;
808 exprAssembler.cleanUp();
809 return ThinShellAssemblerStatus::AssemblyError;
814 auto expr = lambda_der * gismo::expr::uv(m_component,3) *
meas(Gori);
817 exprAssembler.assembleBdr(bnds,expr);
818 result = exprAssembler.rhs();
819 return ThinShellAssemblerStatus::Success;
823 exprAssembler.cleanUp();
824 return ThinShellAssemblerStatus::AssemblyError;
828 else if (m_goalFunction == GoalFunction::PStrain)
832 auto expr = 2 * Emp_der * Emp.tr() *
meas(Gori);
835 exprAssembler.assembleBdr(bnds,expr);
836 result = exprAssembler.rhs();
837 return ThinShellAssemblerStatus::Success;
841 exprAssembler.cleanUp();
842 return ThinShellAssemblerStatus::AssemblyError;
847 auto expr = Emp_der * gismo::expr::uv(m_component,3) *
meas(Gori);
850 exprAssembler.assembleBdr(bnds,expr);
851 result = exprAssembler.rhs();
852 return ThinShellAssemblerStatus::Success;
856 exprAssembler.cleanUp();
857 return ThinShellAssemblerStatus::AssemblyError;
861 else if (m_goalFunction == GoalFunction::PStress)
864 gsMatrix<T> convMat(3,2);
866 convMat(0,0) = convMat(1,1) = 1;
867 gsConstantFunction<T> convFun(convMat.reshape(6,1),2);
868 auto conv = exprAssembler.getCoeff(convFun);
871 auto expr = 2 * Smp_der *
reshape(conv,3,2) * P0 *
meas(Gori);
874 exprAssembler.assembleBdr(bnds,expr);
875 result = exprAssembler.rhs();
876 return ThinShellAssemblerStatus::Success;
880 exprAssembler.cleanUp();
881 return ThinShellAssemblerStatus::AssemblyError;
886 GISMO_ASSERT(m_component < 2,
"Can only select principle stress component 0 or 1, but "<<m_component<<
" selected.");
887 auto expr = Smp_der *
reshape(conv,3,2) * gismo::expr::uv(m_component,2) *
meas(Gori);
890 exprAssembler.assembleBdr(bnds,expr);
891 result = exprAssembler.rhs();
892 return ThinShellAssemblerStatus::Success;
896 exprAssembler.cleanUp();
897 return ThinShellAssemblerStatus::AssemblyError;
901 else if (m_goalFunction == GoalFunction::MembraneStrain)
905 auto expr = 2 * Em_der * Em.tr() *
meas(Gori);
908 exprAssembler.assembleBdr(bnds,expr);
909 result = exprAssembler.rhs();
910 return ThinShellAssemblerStatus::Success;
914 exprAssembler.cleanUp();
915 return ThinShellAssemblerStatus::AssemblyError;
920 auto expr = Em_der * gismo::expr::uv(m_component,3) *
meas(Gori);
923 exprAssembler.assembleBdr(bnds,expr);
924 result = exprAssembler.rhs();
925 return ThinShellAssemblerStatus::Success;
929 exprAssembler.cleanUp();
930 return ThinShellAssemblerStatus::AssemblyError;
934 else if (m_goalFunction == GoalFunction::MembraneStress)
938 auto expr = 2 * Sm_der * S0 *
meas(Gori);
941 exprAssembler.assembleBdr(bnds,expr);
942 result = exprAssembler.rhs();
943 return ThinShellAssemblerStatus::Success;
947 exprAssembler.cleanUp();
948 return ThinShellAssemblerStatus::AssemblyError;
953 auto expr = Sm_der * gismo::expr::uv(m_component,3) *
meas(Gori);
956 exprAssembler.assembleBdr(bnds,expr);
957 result = exprAssembler.rhs();
958 return ThinShellAssemblerStatus::Success;
962 exprAssembler.cleanUp();
963 return ThinShellAssemblerStatus::AssemblyError;
967 else if (m_goalFunction == GoalFunction::MembraneForce)
971 auto expr = 2 * N_der * N *
meas(Gori);
974 exprAssembler.assembleBdr(bnds,expr);
975 result = exprAssembler.rhs();
976 return ThinShellAssemblerStatus::Success;
980 exprAssembler.cleanUp();
981 return ThinShellAssemblerStatus::AssemblyError;
986 auto expr = N.tr() * gismo::expr::uv(m_component,3) *
meas(Gori);
989 exprAssembler.assembleBdr(bnds,expr);
990 result = exprAssembler.rhs();
991 return ThinShellAssemblerStatus::Success;
995 exprAssembler.cleanUp();
996 return ThinShellAssemblerStatus::AssemblyError;
1000 else if (m_goalFunction == GoalFunction::FlexuralStrain)
1004 gsFunctionExpr<T> mult110t(
"1",
"0",
"0",
"0",
"1",
"0",
"0",
"0",
"0",2);
1005 auto m110 = exprAssembler.getCoeff(mult2t);
1006 auto expr = 2*Ef_der *
reshape(m110,3,3) * Ef.tr() *
meas(Gori);
1009 exprAssembler.assembleBdr(bnds,expr);
1010 result = exprAssembler.rhs();
1011 return ThinShellAssemblerStatus::Success;
1015 exprAssembler.cleanUp();
1016 return ThinShellAssemblerStatus::AssemblyError;
1021 auto expr = Ef_der * gismo::expr::uv(m_component,3) *
meas(Gori);
1024 exprAssembler.assembleBdr(bnds,expr);
1025 result = exprAssembler.rhs();
1026 return ThinShellAssemblerStatus::Success;
1030 exprAssembler.cleanUp();
1031 return ThinShellAssemblerStatus::AssemblyError;
1035 else if (m_goalFunction == GoalFunction::FlexuralStress)
1039 auto expr = 2 * Sf_der * S1 *
meas(Gori);
1042 exprAssembler.assembleBdr(bnds,expr);
1043 result = exprAssembler.rhs();
1044 return ThinShellAssemblerStatus::Success;
1048 exprAssembler.cleanUp();
1049 return ThinShellAssemblerStatus::AssemblyError;
1054 auto expr = Sf_der * gismo::expr::uv(m_component,3) *
meas(Gori);
1057 exprAssembler.assembleBdr(bnds,expr);
1058 result = exprAssembler.rhs();
1059 return ThinShellAssemblerStatus::Success;
1063 exprAssembler.cleanUp();
1064 return ThinShellAssemblerStatus::AssemblyError;
1068 else if (m_goalFunction == GoalFunction::FlexuralMoment)
1072 auto expr = 2 * M_der * M *
meas(Gori);
1075 exprAssembler.assembleBdr(bnds,expr);
1076 result = exprAssembler.rhs();
1077 return ThinShellAssemblerStatus::Success;
1081 exprAssembler.cleanUp();
1082 return ThinShellAssemblerStatus::AssemblyError;
1087 auto expr = M_der * gismo::expr::uv(m_component,3) *
meas(Gori);
1090 exprAssembler.assembleBdr(bnds,expr);
1091 result = exprAssembler.rhs();
1092 return ThinShellAssemblerStatus::Success;
1096 exprAssembler.cleanUp();
1097 return ThinShellAssemblerStatus::AssemblyError;
1106template <
short_t d,
class T,
bool bending>
1107ThinShellAssemblerStatus gsThinShellAssemblerDWR<d, T, bending>::_assembleDual(
const gsMatrix<T> & points, gsThinShellAssemblerBase<T> * assembler,
const gsMultiPatch<T> & primal,
const gsMultiPatch<T> & deformed, gsVector<T> & result)
1112 gsMatrix<index_t> actives, globalActives;
1114 GISMO_ASSERT(m_component < d || m_component==9,
"Component is out of bounds");
1122 gsExprAssembler<T> exprAssembler = assembler->assembler();
1123 exprAssembler.cleanUp();
1124 GISMO_ENSURE(assembler->options().hasGroup(
"ExprAssembler"),
"The option list does not contain options with the label 'ExprAssembler'!");
1125 exprAssembler.setOptions(assembler->options().getGroup(
"ExprAssembler"));
1128 geometryMap Gori = exprAssembler.getMap(m_patches);
1129 geometryMap Gdef = exprAssembler.getMap(deformed);
1132 exprAssembler.initSystem();
1133 exprAssembler.initVector(1);
1134 if (points.cols()==0)
1136 result = exprAssembler.rhs();
1137 return ThinShellAssemblerStatus::Success;
1141 space space = exprAssembler.trialSpace(0);
1143 space.setup(m_bcs, dirichlet::homogeneous, 0);
1146 auto usol = exprAssembler.getCoeff(primal);
1149 gsMaterialMatrixEval<T,MaterialOutput::StretchTransform> Tstretchf(assembler->materials(),&deformed,Z);
1150 gsMaterialMatrixEval<T,MaterialOutput::PStressTransform> Tpstressf(assembler->materials(),&deformed,Z);
1151 auto Tstretch = exprAssembler.getCoeff(Tstretchf);
1152 auto Tpstress = exprAssembler.getCoeff(Tpstressf);
1155 gsMaterialMatrixEval<T,MaterialOutput::MatrixA> mmAf(assembler->materials(),&deformed,Z);
1156 gsMaterialMatrixEval<T,MaterialOutput::MatrixD> mmDf(assembler->materials(),&deformed,Z);
1157 auto mmA = exprAssembler.getCoeff(mmAf);
1158 auto mmD = exprAssembler.getCoeff(mmDf);
1161 gsMaterialMatrixIntegrate<T,MaterialOutput::MatrixA> mmAfi(assembler->materials(),&deformed);
1162 gsMaterialMatrixIntegrate<T,MaterialOutput::MatrixB> mmBfi(assembler->materials(),&deformed);
1163 gsMaterialMatrixIntegrate<T,MaterialOutput::MatrixC> mmCfi(assembler->materials(),&deformed);
1164 gsMaterialMatrixIntegrate<T,MaterialOutput::MatrixD> mmDfi(assembler->materials(),&deformed);
1165 auto mmAi = exprAssembler.getCoeff(mmAfi);
1166 auto mmBi = exprAssembler.getCoeff(mmBfi);
1167 auto mmCi = exprAssembler.getCoeff(mmCfi);
1168 auto mmDi = exprAssembler.getCoeff(mmDfi);
1171 gsMaterialMatrixEval<T,MaterialOutput::VectorN> S0f(assembler->materials(),&deformed,Z);
1172 gsMaterialMatrixEval<T,MaterialOutput::VectorM> S1f(assembler->materials(),&deformed,Z);
1173 auto S0 = exprAssembler.getCoeff(S0f);
1174 auto S1 = exprAssembler.getCoeff(S1f);
1177 gsMaterialMatrixEval<T,MaterialOutput::PStress> P0f(assembler->materials(),&deformed,Z);
1178 auto P0 = exprAssembler.getCoeff(P0f);
1181 gsMaterialMatrixIntegrate<T,MaterialOutput::VectorN> Nf(assembler->materials(),&deformed);
1182 gsMaterialMatrixIntegrate<T,MaterialOutput::VectorM> Mf(assembler->materials(),&deformed);
1183 auto N = exprAssembler.getCoeff(Nf);
1184 auto M = exprAssembler.getCoeff(Mf);
1187 gsFunctionExpr<T> mult2t(
"1",
"0",
"0",
"0",
"1",
"0",
"0",
"0",
"2",2);
1188 auto m2 = exprAssembler.getCoeff(mult2t);
1192 gsFunctionExpr<T> mult12t(
"1",
"0",
"0",
"0",
"1",
"0",
"0",
"0",
"0.5",2);
1193 auto m12 = exprAssembler.getCoeff(mult12t);
1199 auto lambda = Cm *
reshape(Tstretch,3,3).tr();
1200 auto lambda_der = Cm_der *
reshape(Tstretch,3,3).tr();
1204 auto Em_der =
flat(
jac(Gdef).tr() *
jac(space) ) ;
1208 auto Emp_der= (Em_der *
reshape(m12,3,3)) *
reshape(Tstretch,3,3).tr();
1211 auto Ef = ( deriv2(Gori,sn(Gori).normalized().tr()) - deriv2(Gdef,sn(Gdef).normalized().tr()) ) *
reshape(m2,3,3) ;
1212 auto Ef_der = -( deriv2(space,sn(Gdef).normalized().tr() ) + deriv2(Gdef,var1(space,Gdef) ) ) *
reshape(m2,3,3);
1215 auto Sm_der = Em_der *
reshape(mmA,3,3);
1218 auto Smp_der = Sm_der *
reshape(Tpstress,3,3).tr();
1221 auto Sf_der = Ef_der *
reshape(mmD,3,3);
1224 auto N_der = Em_der *
reshape(mmAi,3,3) + Ef_der *
reshape(mmBi,3,3);
1225 auto M_der = Em_der *
reshape(mmCi,3,3) + Ef_der *
reshape(mmDi,3,3);
1228 gsExprEvaluator<T> ev(exprAssembler);
1229 result.resize(exprAssembler.numDofs());
1231 if (m_goalFunction == GoalFunction::Displacement)
1235 auto expr = 2 * space * usol *
meas(Gori);
1236 for (
index_t k = 0; k!=points.cols(); k++)
1238 tmp = ev.eval(expr,points.col(k));
1239 exprAssembler.integrationElements().basis(pIndex).active_into( points.col(k), actives );
1240 for (
index_t j = 0; j< space.dim(); ++j)
1242 space.mapper().localToGlobal(actives, pIndex, globalActives,j);
1243 for (
index_t i=0; i < globalActives.rows(); ++i)
1244 if (space.mapper().is_free_index(globalActives(i,0)))
1245 result.at(globalActives(i,0)) += tmp(i+j*actives.rows(),0);
1251 auto expr = space * gismo::expr::uv(m_component,3) *
meas(Gori);
1252 for (
index_t k = 0; k!=points.cols(); k++)
1254 tmp = ev.eval(expr,points.col(k));
1255 exprAssembler.integrationElements().basis(pIndex).active_into( points.col(k), actives );
1256 for (
index_t j = 0; j< space.dim(); ++j)
1258 space.mapper().localToGlobal(actives, pIndex, globalActives,j);
1259 for (
index_t i=0; i < globalActives.rows(); ++i)
1260 if (space.mapper().is_free_index(globalActives(i,0)))
1261 result.at(globalActives(i,0)) += tmp(i+j*actives.rows(),0);
1266 else if (m_goalFunction == GoalFunction::Stretch)
1270 auto expr = 2* lambda_der * lambda.tr() *
meas(Gori);
1271 for (
index_t k = 0; k!=points.cols(); k++)
1273 tmp = ev.eval(expr,points.col(k));
1274 exprAssembler.integrationElements().basis(pIndex).active_into( points.col(k), actives );
1275 for (
index_t j = 0; j< space.dim(); ++j)
1277 space.mapper().localToGlobal(actives, pIndex, globalActives,j);
1278 for (
index_t i=0; i < globalActives.rows(); ++i)
1279 if (space.mapper().is_free_index(globalActives(i,0)))
1280 result.at(globalActives(i,0)) += tmp(i+j*actives.rows(),0);
1286 auto expr = lambda_der * gismo::expr::uv(m_component,3) *
meas(Gori);
1287 for (
index_t k = 0; k!=points.cols(); k++)
1289 tmp = ev.eval(expr,points.col(k));
1290 exprAssembler.integrationElements().basis(pIndex).active_into( points.col(k), actives );
1291 for (
index_t j = 0; j< space.dim(); ++j)
1293 space.mapper().localToGlobal(actives, pIndex, globalActives,j);
1294 for (
index_t i=0; i < globalActives.rows(); ++i)
1295 if (space.mapper().is_free_index(globalActives(i,0)))
1296 result.at(globalActives(i,0)) += tmp(i+j*actives.rows(),0);
1301 else if (m_goalFunction == GoalFunction::PStrain)
1305 auto expr = 2 * Emp_der * Emp.tr() *
meas(Gori);
1306 for (
index_t k = 0; k!=points.cols(); k++)
1308 tmp = ev.eval(expr,points.col(k));
1309 exprAssembler.integrationElements().basis(pIndex).active_into( points.col(k), actives );
1310 for (
index_t j = 0; j< space.dim(); ++j)
1312 space.mapper().localToGlobal(actives, pIndex, globalActives,j);
1313 for (
index_t i=0; i < globalActives.rows(); ++i)
1314 if (space.mapper().is_free_index(globalActives(i,0)))
1315 result.at(globalActives(i,0)) += tmp(i+j*actives.rows(),0);
1321 auto expr = Emp_der * gismo::expr::uv(m_component,3) *
meas(Gori);
1322 for (
index_t k = 0; k!=points.cols(); k++)
1324 tmp = ev.eval(expr,points.col(k));
1325 exprAssembler.integrationElements().basis(pIndex).active_into( points.col(k), actives );
1326 for (
index_t j = 0; j< space.dim(); ++j)
1328 space.mapper().localToGlobal(actives, pIndex, globalActives,j);
1329 for (
index_t i=0; i < globalActives.rows(); ++i)
1330 if (space.mapper().is_free_index(globalActives(i,0)))
1331 result.at(globalActives(i,0)) += tmp(i+j*actives.rows(),0);
1336 else if (m_goalFunction == GoalFunction::PStress)
1340 auto expr = 2 * Smp_der * P0 *
meas(Gori);
1341 for (
index_t k = 0; k!=points.cols(); k++)
1343 tmp = ev.eval(expr,points.col(k));
1344 exprAssembler.integrationElements().basis(pIndex).active_into( points.col(k), actives );
1345 for (
index_t j = 0; j< space.dim(); ++j)
1347 space.mapper().localToGlobal(actives, pIndex, globalActives,j);
1348 for (
index_t i=0; i < globalActives.rows(); ++i)
1349 if (space.mapper().is_free_index(globalActives(i,0)))
1350 result.at(globalActives(i,0)) += tmp(i+j*actives.rows(),0);
1356 auto expr = Smp_der * gismo::expr::uv(m_component,3) *
meas(Gori);
1357 for (
index_t k = 0; k!=points.cols(); k++)
1359 tmp = ev.eval(expr,points.col(k));
1360 exprAssembler.integrationElements().basis(pIndex).active_into( points.col(k), actives );
1361 for (
index_t j = 0; j< space.dim(); ++j)
1363 space.mapper().localToGlobal(actives, pIndex, globalActives,j);
1364 for (
index_t i=0; i < globalActives.rows(); ++i)
1365 if (space.mapper().is_free_index(globalActives(i,0)))
1366 result.at(globalActives(i,0)) += tmp(i+j*actives.rows(),0);
1371 else if (m_goalFunction == GoalFunction::MembraneStrain)
1375 auto expr = 2 * Em_der * Em.tr() *
meas(Gori);
1376 for (
index_t k = 0; k!=points.cols(); k++)
1378 tmp = ev.eval(expr,points.col(k));
1379 exprAssembler.integrationElements().basis(pIndex).active_into( points.col(k), actives );
1380 for (
index_t j = 0; j< space.dim(); ++j)
1382 space.mapper().localToGlobal(actives, pIndex, globalActives,j);
1383 for (
index_t i=0; i < globalActives.rows(); ++i)
1384 if (space.mapper().is_free_index(globalActives(i,0)))
1385 result.at(globalActives(i,0)) += tmp(i+j*actives.rows(),0);
1391 auto expr = Em_der * gismo::expr::uv(m_component,3) *
meas(Gori);
1392 for (
index_t k = 0; k!=points.cols(); k++)
1394 tmp = ev.eval(expr,points.col(k));
1395 exprAssembler.integrationElements().basis(pIndex).active_into( points.col(k), actives );
1396 for (
index_t j = 0; j< space.dim(); ++j)
1398 space.mapper().localToGlobal(actives, pIndex, globalActives,j);
1399 for (
index_t i=0; i < globalActives.rows(); ++i)
1400 if (space.mapper().is_free_index(globalActives(i,0)))
1401 result.at(globalActives(i,0)) += tmp(i+j*actives.rows(),0);
1406 else if (m_goalFunction == GoalFunction::MembraneStress)
1410 auto expr = 2 * Sm_der * S0 *
meas(Gori);
1411 for (
index_t k = 0; k!=points.cols(); k++)
1413 tmp = ev.eval(expr,points.col(k));
1414 exprAssembler.integrationElements().basis(pIndex).active_into( points.col(k), actives );
1415 for (
index_t j = 0; j< space.dim(); ++j)
1417 space.mapper().localToGlobal(actives, pIndex, globalActives,j);
1418 for (
index_t i=0; i < globalActives.rows(); ++i)
1419 if (space.mapper().is_free_index(globalActives(i,0)))
1420 result.at(globalActives(i,0)) += tmp(i+j*actives.rows(),0);
1426 auto expr = Sm_der * gismo::expr::uv(m_component,3) *
meas(Gori);
1427 for (
index_t k = 0; k!=points.cols(); k++)
1429 tmp = ev.eval(expr,points.col(k));
1430 exprAssembler.integrationElements().basis(pIndex).active_into( points.col(k), actives );
1431 for (
index_t j = 0; j< space.dim(); ++j)
1433 space.mapper().localToGlobal(actives, pIndex, globalActives,j);
1434 for (
index_t i=0; i < globalActives.rows(); ++i)
1435 if (space.mapper().is_free_index(globalActives(i,0)))
1436 result.at(globalActives(i,0)) += tmp(i+j*actives.rows(),0);
1441 else if (m_goalFunction == GoalFunction::MembraneForce)
1445 auto expr = 2 * N_der * N *
meas(Gori);
1446 for (
index_t k = 0; k!=points.cols(); k++)
1448 tmp = ev.eval(expr,points.col(k));
1449 exprAssembler.integrationElements().basis(pIndex).active_into( points.col(k), actives );
1450 for (
index_t j = 0; j< space.dim(); ++j)
1452 space.mapper().localToGlobal(actives, pIndex, globalActives,j);
1453 for (
index_t i=0; i < globalActives.rows(); ++i)
1454 if (space.mapper().is_free_index(globalActives(i,0)))
1455 result.at(globalActives(i,0)) += tmp(i+j*actives.rows(),0);
1462 auto expr = N.tr() * gismo::expr::uv(m_component,3) *
meas(Gori);
1463 for (
index_t k = 0; k!=points.cols(); k++)
1465 tmp = ev.eval(expr,points.col(k));
1466 exprAssembler.integrationElements().basis(pIndex).active_into( points.col(k), actives );
1467 for (
index_t j = 0; j< space.dim(); ++j)
1469 space.mapper().localToGlobal(actives, pIndex, globalActives,j);
1470 for (
index_t i=0; i < globalActives.rows(); ++i)
1471 if (space.mapper().is_free_index(globalActives(i,0)))
1472 result.at(globalActives(i,0)) += tmp(i+j*actives.rows(),0);
1477 else if (m_goalFunction == GoalFunction::FlexuralStrain)
1481 auto expr = 2 * Ef_der * Ef.tr() *
meas(Gori);
1482 for (
index_t k = 0; k!=points.cols(); k++)
1484 tmp = ev.eval(expr,points.col(k));
1485 exprAssembler.integrationElements().basis(pIndex).active_into( points.col(k), actives );
1486 for (
index_t j = 0; j< space.dim(); ++j)
1488 space.mapper().localToGlobal(actives, pIndex, globalActives,j);
1489 for (
index_t i=0; i < globalActives.rows(); ++i)
1490 if (space.mapper().is_free_index(globalActives(i,0)))
1491 result.at(globalActives(i,0)) += tmp(i+j*actives.rows(),0);
1497 auto expr = Ef_der * gismo::expr::uv(m_component,3) *
meas(Gori);
1498 for (
index_t k = 0; k!=points.cols(); k++)
1500 tmp = ev.eval(expr,points.col(k));
1501 exprAssembler.integrationElements().basis(pIndex).active_into( points.col(k), actives );
1502 for (
index_t j = 0; j< space.dim(); ++j)
1504 space.mapper().localToGlobal(actives, pIndex, globalActives,j);
1505 for (
index_t i=0; i < globalActives.rows(); ++i)
1506 if (space.mapper().is_free_index(globalActives(i,0)))
1507 result.at(globalActives(i,0)) += tmp(i+j*actives.rows(),0);
1512 else if (m_goalFunction == GoalFunction::FlexuralStress)
1516 auto expr = 2 * Sf_der * S1 *
meas(Gori);
1517 for (
index_t k = 0; k!=points.cols(); k++)
1519 tmp = ev.eval(expr,points.col(k));
1520 exprAssembler.integrationElements().basis(pIndex).active_into( points.col(k), actives );
1521 for (
index_t j = 0; j< space.dim(); ++j)
1523 space.mapper().localToGlobal(actives, pIndex, globalActives,j);
1524 for (
index_t i=0; i < globalActives.rows(); ++i)
1525 if (space.mapper().is_free_index(globalActives(i,0)))
1526 result.at(globalActives(i,0)) += tmp(i+j*actives.rows(),0);
1532 auto expr = Sf_der * gismo::expr::uv(m_component,3) *
meas(Gori);
1533 for (
index_t k = 0; k!=points.cols(); k++)
1535 tmp = ev.eval(expr,points.col(k));
1536 exprAssembler.integrationElements().basis(pIndex).active_into( points.col(k), actives );
1537 for (
index_t j = 0; j< space.dim(); ++j)
1539 space.mapper().localToGlobal(actives, pIndex, globalActives,j);
1540 for (
index_t i=0; i < globalActives.rows(); ++i)
1541 if (space.mapper().is_free_index(globalActives(i,0)))
1542 result.at(globalActives(i,0)) += tmp(i+j*actives.rows(),0);
1547 else if (m_goalFunction == GoalFunction::FlexuralMoment)
1551 auto expr = 2 * M_der * M *
meas(Gori);
1552 for (
index_t k = 0; k!=points.cols(); k++)
1554 tmp = ev.eval(expr,points.col(k));
1555 exprAssembler.integrationElements().basis(pIndex).active_into( points.col(k), actives );
1556 for (
index_t j = 0; j< space.dim(); ++j)
1558 space.mapper().localToGlobal(actives, pIndex, globalActives,j);
1559 for (
index_t i=0; i < globalActives.rows(); ++i)
1560 if (space.mapper().is_free_index(globalActives(i,0)))
1561 result.at(globalActives(i,0)) += tmp(i+j*actives.rows(),0);
1568 auto expr = M_der * gismo::expr::uv(m_component,3) *
meas(Gori);
1569 for (
index_t k = 0; k!=points.cols(); k++)
1571 tmp = ev.eval(expr,points.col(k));
1572 exprAssembler.integrationElements().basis(pIndex).active_into( points.col(k), actives );
1573 for (
index_t j = 0; j< space.dim(); ++j)
1575 space.mapper().localToGlobal(actives, pIndex, globalActives,j);
1576 for (
index_t i=0; i < globalActives.rows(); ++i)
1577 if (space.mapper().is_free_index(globalActives(i,0)))
1578 result.at(globalActives(i,0)) += tmp(i+j*actives.rows(),0);
1586 return ThinShellAssemblerStatus::Success;
1620template <
short_t d,
class T,
bool bending>
1621void gsThinShellAssemblerDWR<d, T, bending>::updateMultiPatchL(
const gsMatrix<T> & solVector, gsMultiPatch<T> & result)
1623 m_assemblerL->updateMultiPatch(solVector,result);
1626template <
short_t d,
class T,
bool bending>
1627void gsThinShellAssemblerDWR<d, T, bending>::updateMultiPatchH(
const gsMatrix<T> & solVector, gsMultiPatch<T> & result)
1629 m_assemblerH->updateMultiPatch(solVector,result);
1632template <
short_t d,
class T,
bool bending>
1633void gsThinShellAssemblerDWR<d, T, bending>::constructMultiPatchL(
const gsMatrix<T> & solVector, gsMultiPatch<T> & result)
1635 result = m_assemblerL->constructMultiPatch(solVector);
1638template <
short_t d,
class T,
bool bending>
1639void gsThinShellAssemblerDWR<d, T, bending>::constructMultiPatchH(
const gsMatrix<T> & solVector, gsMultiPatch<T> & result)
1641 result = m_assemblerH->constructMultiPatch(solVector);
1644template <
short_t d,
class T,
bool bending>
1645void gsThinShellAssemblerDWR<d, T, bending>::constructSolutionL(
const gsMatrix<T> & solVector, gsMultiPatch<T> & deformed)
1647 m_assemblerL->constructSolution(solVector,deformed);
1650template <
short_t d,
class T,
bool bending>
1651void gsThinShellAssemblerDWR<d, T, bending>::constructSolutionH(
const gsMatrix<T> & solVector, gsMultiPatch<T> & deformed)
1653 m_assemblerH->constructSolution(solVector,deformed);
1656template <
short_t d,
class T,
bool bending>
1657gsMultiPatch<T> gsThinShellAssemblerDWR<d, T, bending>::constructSolutionL(
const gsMatrix<T> & solVector)
1659 return m_assemblerL->constructSolution(solVector);
1662template <
short_t d,
class T,
bool bending>
1663gsMultiPatch<T> gsThinShellAssemblerDWR<d, T, bending>::constructSolutionH(
const gsMatrix<T> & solVector)
1665 return m_assemblerH->constructSolution(solVector);
1668template <
short_t d,
class T,
bool bending>
1669gsMultiPatch<T> gsThinShellAssemblerDWR<d, T, bending>::constructDisplacementL(
const gsMatrix<T> & solVector)
1671 return m_assemblerL->constructDisplacement(solVector);
1674template <
short_t d,
class T,
bool bending>
1675gsMultiPatch<T> gsThinShellAssemblerDWR<d, T, bending>::constructDisplacementH(
const gsMatrix<T> & solVector)
1677 return m_assemblerH->constructDisplacement(solVector);
1680template <
short_t d,
class T,
bool bending>
1681gsVector<T> gsThinShellAssemblerDWR<d, T, bending>::constructSolutionVectorL(
const gsMultiPatch<T> & deformed)
1683 return m_assemblerL->constructSolutionVector(deformed);
1686template <
short_t d,
class T,
bool bending>
1687gsVector<T> gsThinShellAssemblerDWR<d, T, bending>::constructSolutionVectorH(
const gsMultiPatch<T> & deformed)
1689 return m_assemblerH->constructSolutionVector(deformed);
1692template <
short_t d,
class T,
bool bending>
1693gsMatrix<T> gsThinShellAssemblerDWR<d, T, bending>::projectL2_L(
const gsFunction<T> &fun)
1695 return m_assemblerL->projectL2(fun);
1698template <
short_t d,
class T,
bool bending>
1699gsMatrix<T> gsThinShellAssemblerDWR<d, T, bending>::projectL2_H(
const gsFunction<T> &fun)
1701 return m_assemblerH->projectL2(fun);
1705template <
short_t d,
class T,
bool bending>
1706T gsThinShellAssemblerDWR<d, T, bending>::computeError(
const gsMultiPatch<T> & dualL,
const gsMultiPatch<T> & dualH,
bool withLoads,
1707 std::string filename,
unsigned np,
bool parametric,
bool mesh)
1709 computeError_impl<0>(dualL,dualH,withLoads,filename,np,parametric,mesh);
1713template <
short_t d,
class T,
bool bending>
1714std::vector<T> gsThinShellAssemblerDWR<d, T, bending>::computeErrorElements(
const gsMultiPatch<T> & dualL,
const gsMultiPatch<T> & dualH,
bool withLoads,
1715 std::string filename,
unsigned np,
bool parametric,
bool mesh)
1717 computeError_impl<1>(dualL,dualH,withLoads,filename,np,parametric,mesh);
1721template <
short_t d,
class T,
bool bending>
1722std::vector<T> gsThinShellAssemblerDWR<d, T, bending>::computeErrorDofs(
const gsMultiPatch<T> & dualL,
const gsMultiPatch<T> & dualH,
bool withLoads,
1723 std::string filename,
unsigned np,
bool parametric,
bool mesh)
1725 computeError_impl<2>(dualL,dualH,withLoads,filename,np,parametric,mesh);
1729template <
short_t d,
class T,
bool bending>
1730template <index_t _elWise>
1731void gsThinShellAssemblerDWR<d, T, bending>::computeError_impl(
const gsMultiPatch<T> & dualL,
1732 const gsMultiPatch<T> & dualH,
1734 std::string filename,
1739 gsExprAssembler<T> exprAssembler = m_assemblerH->assembler();
1740 exprAssembler.cleanUp();
1741 GISMO_ENSURE(m_assemblerH->options().hasGroup(
"ExprAssembler"),
"The option list does not contain options with the label 'ExprAssembler'!");
1742 exprAssembler.setOptions(m_assemblerH->options().getGroup(
"ExprAssembler"));
1745 geometryMap Gori = exprAssembler.getMap(m_patches);
1747 auto F = exprAssembler.getCoeff(*m_forceFun, Gori);
1748 auto zsolL = exprAssembler.getCoeff(dualL);
1749 auto zsolH = exprAssembler.getCoeff(dualH);
1751 auto g_N = exprAssembler.getBdrFunction(Gori);
1753 auto expr = (zsolH-zsolL).tr() * F;
1754 auto bexpr= (zsolH-zsolL).tr() * g_N;
1756 gsExprEvaluator<T> ev(exprAssembler);
1758 T integral, bintegral;
1761 integral = ev.integral(expr *
meas(Gori));
1762 bintegral = ev.integralBdrBc( m_bcs.get(
"Neumann"), bexpr *
tv(Gori).norm());
1763 if (m_pLoads.numLoads()!=0 && withLoads)
1764 _applyLoadsToError(dualL,dualH,integral);
1766 m_error = integral+bintegral;
1768 else if (_elWise == 1)
1770 m_error = ev.integralElWise(expr *
meas(Gori));
1771 if (m_pLoads.numLoads()!=0 && withLoads)
1772 _applyLoadsToError(dualL,dualH,m_error);
1773 m_errors = ev.elementwise();
1774 if (m_pLoads.numLoads()!=0 && withLoads)
1775 _applyLoadsToElWiseError(dualL,dualH,m_errors);
1777 else if (_elWise == 2)
1784 if (!filename.empty())
1786 ev.options().setSwitch(
"plot.elements",mesh);
1787 ev.options().setInt(
"plot.npts",np);
1791 ev.writeParaview(expr,Gori,filename);
1795template <
short_t d,
class T,
bool bending>
1796T gsThinShellAssemblerDWR<d, T, bending>::computeError(
const gsMultiPatch<T> & dualL,
const gsMultiPatch<T> & dualH,
const gsMultiPatch<T> & deformed,
bool withLoads,
1797 std::string filename,
unsigned np,
bool parametric,
bool mesh)
1799 computeError_impl<d,bending,0>(dualL,dualH,deformed,withLoads,filename,np,parametric,mesh);
1803template <
short_t d,
class T,
bool bending>
1804std::vector<T> gsThinShellAssemblerDWR<d, T, bending>::computeErrorElements(
const gsMultiPatch<T> & dualL,
const gsMultiPatch<T> & dualH,
const gsMultiPatch<T> & deformed,
bool withLoads,
1805 std::string filename,
unsigned np,
bool parametric,
bool mesh)
1807 computeError_impl<d,bending,1>(dualL,dualH,deformed,withLoads,filename,np,parametric,mesh);
1811template <
short_t d,
class T,
bool bending>
1812std::vector<T> gsThinShellAssemblerDWR<d, T, bending>::computeErrorDofs(
const gsMultiPatch<T> & dualL,
const gsMultiPatch<T> & dualH,
const gsMultiPatch<T> & deformed,
bool withLoads,
1813 std::string filename,
unsigned np,
bool parametric,
bool mesh)
1815 computeError_impl<d,bending,2>(dualL,dualH,deformed,withLoads,filename,np,parametric,mesh);
1819template <
short_t d,
class T,
bool bending>
1820template<
short_t _d,
bool _bending, index_t _elWise>
1821typename std::enable_if<(_d==3) && _bending,
void>::type
1822gsThinShellAssemblerDWR<d, T, bending>::computeError_impl(
const gsMultiPatch<T> & dualL,
const gsMultiPatch<T> & dualH,
const gsMultiPatch<T> & deformed,
bool withLoads,
1824 std::string filename,
unsigned np,
bool ,
bool mesh)
1827 gsExprAssembler<T> exprAssembler = m_assemblerH->assembler();
1828 exprAssembler.cleanUp();
1829 GISMO_ENSURE(m_assemblerH->options().hasGroup(
"ExprAssembler"),
"The option list does not contain options with the label 'ExprAssembler'!");
1830 exprAssembler.setOptions(m_assemblerH->options().getGroup(
"ExprAssembler"));
1833 geometryMap Gori = exprAssembler.getMap(m_patches);
1834 geometryMap Gdef = exprAssembler.getMap(deformed);
1836 gsMaterialMatrixIntegrate<T,MaterialOutput::VectorN> S0f(m_assemblerH->materials(),&deformed);
1837 gsMaterialMatrixIntegrate<T,MaterialOutput::VectorM> S1f(m_assemblerH->materials(),&deformed);
1838 auto S0 = exprAssembler.getCoeff(S0f);
1839 auto S1 = exprAssembler.getCoeff(S1f);
1841 gsFunctionExpr<T> mult2t(
"1",
"0",
"0",
"0",
"1",
"0",
"0",
"0",
"2",2);
1842 auto m2 = exprAssembler.getCoeff(mult2t);
1844 auto F = exprAssembler.getCoeff(*m_forceFun, Gori);
1845 auto zsolL = exprAssembler.getCoeff(dualL);
1846 auto zsolH = exprAssembler.getCoeff(dualH);
1849 Base::homogenizeDirichlet();
1853 auto Em_der =
flat(
jac(Gdef).tr() * (
jac(zsolH) -
jac(zsolL)) ) ;
1857 auto Ef_der = -( deriv2(zsolH,sn(Gdef).normalized().tr() )
1858 - deriv2(zsolL,sn(Gdef).normalized().tr() ) + deriv2(Gdef,var1(zsolH,Gdef) )
1859 - deriv2(Gdef,var1(zsolL,Gdef) ) ) *
reshape(m2,3,3);
1861 auto Fext = (zsolH-zsolL).tr() * F;
1862 auto Fint = ( N * Em_der.tr() + M * Ef_der.tr() );
1864 auto g_N = exprAssembler.getBdrFunction(Gori);
1866 auto expr = ( Fext - Fint );
1867 auto bexpr= (zsolH-zsolL).tr() * g_N;
1869 gsExprEvaluator<T> ev(exprAssembler);
1871 T integral, bintegral = 0;
1875 bintegral = ev.integralBdrBc( m_bcs.get(
"Neumann"), bexpr *
tv(Gori).norm());
1876 integral = ev.integral(expr *
meas(Gori));
1877 if (m_pLoads.numLoads()!=0 && withLoads)
1878 _applyLoadsToError(dualL,dualH,integral);
1880 m_error = integral+bintegral;
1882 else if (_elWise == 1)
1884 m_error = ev.integralElWise(expr *
meas(Gori));
1885 if (m_pLoads.numLoads()!=0 && withLoads)
1886 _applyLoadsToError(dualL,dualH,m_error);
1887 m_errors = ev.elementwise();
1888 if (m_pLoads.numLoads()!=0 && withLoads)
1889 _applyLoadsToElWiseError(dualL,dualH,m_errors);
1891 else if (_elWise == 2)
1913 if (!filename.empty())
1915 ev.options().setSwitch(
"plot.elements",mesh);
1916 ev.options().setInt(
"plot.npts",np);
1920 ev.writeParaview(expr,Gori,filename);
1924template <
short_t d,
class T,
bool bending>
1925template<
short_t _d,
bool _bending, index_t _elWise>
1926typename std::enable_if<!(_d==3 && _bending),
void>::type
1927gsThinShellAssemblerDWR<d, T, bending>::computeError_impl(
const gsMultiPatch<T> & dualL,
1928 const gsMultiPatch<T> & dualH,
1929 const gsMultiPatch<T> & deformed,
1931 std::string filename,
1936 gsExprAssembler<T> exprAssembler = m_assemblerH->assembler();
1937 exprAssembler.cleanUp();
1938 GISMO_ENSURE(m_assemblerH->options().hasGroup(
"ExprAssembler"),
"The option list does not contain options with the label 'ExprAssembler'!");
1939 exprAssembler.setOptions(m_assemblerH->options().getGroup(
"ExprAssembler"));
1942 geometryMap Gori = exprAssembler.getMap(m_patches);
1943 geometryMap Gdef = exprAssembler.getMap(deformed);
1945 gsMaterialMatrixIntegrate<T,MaterialOutput::VectorN> S0f(m_assemblerH->materials(),&deformed);
1946 auto S0 = exprAssembler.getCoeff(S0f);
1948 auto F = exprAssembler.getCoeff(*m_forceFun, Gori);
1950 auto zsolL = exprAssembler.getCoeff(dualL);
1951 auto zsolH = exprAssembler.getCoeff(dualH);
1956 auto Em_der =
flat(
jac(Gdef).tr() * (
jac(zsolH) -
jac(zsolL)) ) ;
1958 auto Fext = (zsolH-zsolL).tr() * F;
1959 auto Fint = ( N * Em_der.tr() );
1961 auto g_N = exprAssembler.getBdrFunction(Gori);
1963 auto expr = ( Fext - Fint );
1964 auto bexpr= (zsolH-zsolL).tr() * g_N;
1966 gsExprEvaluator<T> ev(exprAssembler);
1968 T integral, bintegral;
1971 bintegral = ev.integralBdrBc( m_bcs.get(
"Neumann"), bexpr *
tv(Gori).norm());
1972 integral = ev.integral(expr *
meas(Gori));
1973 m_error = bintegral+integral;
1974 if (m_pLoads.numLoads()!=0 && withLoads)
1975 _applyLoadsToError(dualL,dualH,m_error);
1977 else if (_elWise == 1)
1979 m_error = ev.integralElWise(expr *
meas(Gori));
1980 if (m_pLoads.numLoads()!=0 && withLoads)
1981 _applyLoadsToError(dualL,dualH,m_error);
1982 m_errors = ev.elementwise();
1983 if (m_pLoads.numLoads()!=0 && withLoads)
1984 _applyLoadsToElWiseError(dualL,dualH,m_errors);
1986 else if (_elWise == 2)
2007 if (!filename.empty())
2009 ev.options().setSwitch(
"plot.elements",mesh);
2010 ev.options().setInt(
"plot.npts",np);
2014 ev.writeParaview(expr,Gori,filename);
2018template <
short_t d,
class T,
bool bending>
2019T gsThinShellAssemblerDWR<d, T, bending>::computeSquaredError(
const gsMultiPatch<T> & dualL,
const gsMultiPatch<T> & dualH,
bool withLoads,
2020 std::string filename,
unsigned np,
bool parametric,
bool mesh)
2022 computeSquaredError_impl<0>(dualL,dualH,withLoads,filename,np,parametric,mesh);
2026template <
short_t d,
class T,
bool bending>
2027std::vector<T> gsThinShellAssemblerDWR<d, T, bending>::computeSquaredErrorElements(
const gsMultiPatch<T> & dualL,
const gsMultiPatch<T> & dualH,
bool withLoads,
2028 std::string filename,
unsigned np,
bool parametric,
bool mesh)
2030 computeSquaredError_impl<1>(dualL,dualH,withLoads,filename,np,parametric,mesh);
2034template <
short_t d,
class T,
bool bending>
2035std::vector<T> gsThinShellAssemblerDWR<d, T, bending>::computeSquaredErrorDofs(
const gsMultiPatch<T> & dualL,
const gsMultiPatch<T> & dualH,
bool withLoads,
2036 std::string filename,
unsigned np,
bool parametric,
bool mesh)
2038 computeSquaredError_impl<2>(dualL,dualH,withLoads,filename,np,parametric,mesh);
2042template <
short_t d,
class T,
bool bending>
2043template <index_t _elWise>
2044void gsThinShellAssemblerDWR<d, T, bending>::computeSquaredError_impl(
const gsMultiPatch<T> & dualL,
2045 const gsMultiPatch<T> & dualH,
2047 std::string filename,
2052 gsExprAssembler<T> exprAssembler = m_assemblerH->assembler();
2053 exprAssembler.cleanUp();
2054 GISMO_ENSURE(m_assemblerH->options().hasGroup(
"ExprAssembler"),
"The option list does not contain options with the label 'ExprAssembler'!");
2055 exprAssembler.setOptions(m_assemblerH->options().getGroup(
"ExprAssembler"));
2058 geometryMap Gori = exprAssembler.getMap(m_patches);
2060 auto F = exprAssembler.getCoeff(*m_forceFun, Gori);
2061 auto zsolL = exprAssembler.getCoeff(dualL);
2062 auto zsolH = exprAssembler.getCoeff(dualH);
2064 auto g_N = exprAssembler.getBdrFunction(Gori);
2066 auto expr = ((zsolH-zsolL).tr() * F).sqNorm();
2067 auto bexpr= (zsolH-zsolL).tr() * g_N;
2069 gsExprEvaluator<T> ev(exprAssembler);
2071 T integral, bintegral;
2074 integral = ev.integral(expr *
meas(Gori));
2075 bintegral = ev.integralBdrBc( m_bcs.get(
"Neumann"), bexpr *
tv(Gori).norm());
2076 if (m_pLoads.numLoads()!=0 && withLoads)
2077 _applyLoadsToError(dualL,dualH,integral);
2079 m_error = integral+bintegral;
2081 else if (_elWise == 1)
2083 m_error = ev.integralElWise(expr *
meas(Gori));
2084 if (m_pLoads.numLoads()!=0 && withLoads)
2085 _applyLoadsToError(dualL,dualH,m_error);
2086 m_errors = ev.elementwise();
2087 if (m_pLoads.numLoads()!=0 && withLoads)
2088 _applyLoadsToElWiseError(dualL,dualH,m_errors);
2090 else if (_elWise == 2)
2097 if (!filename.empty())
2099 ev.options().setSwitch(
"plot.elements",mesh);
2100 ev.options().setInt(
"plot.npts",np);
2104 ev.writeParaview(expr,Gori,filename);
2108template <
short_t d,
class T,
bool bending>
2109T gsThinShellAssemblerDWR<d, T, bending>::computeSquaredError(
const gsMultiPatch<T> & dualL,
const gsMultiPatch<T> & dualH,
const gsMultiPatch<T> & deformed,
bool withLoads,
2110 std::string filename,
unsigned np,
bool parametric,
bool mesh)
2112 computeSquaredError_impl<d,bending,0>(dualL,dualH,deformed,withLoads,filename,np,parametric,mesh);
2116template <
short_t d,
class T,
bool bending>
2117std::vector<T> gsThinShellAssemblerDWR<d, T, bending>::computeSquaredErrorElements(
const gsMultiPatch<T> & dualL,
const gsMultiPatch<T> & dualH,
const gsMultiPatch<T> & deformed,
bool withLoads,
2118 std::string filename,
unsigned np,
bool parametric,
bool mesh)
2120 computeSquaredError_impl<d,bending,1>(dualL,dualH,deformed,withLoads,filename,np,parametric,mesh);
2124template <
short_t d,
class T,
bool bending>
2125std::vector<T> gsThinShellAssemblerDWR<d, T, bending>::computeSquaredErrorDofs(
const gsMultiPatch<T> & dualL,
const gsMultiPatch<T> & dualH,
const gsMultiPatch<T> & deformed,
bool withLoads,
2126 std::string filename,
unsigned np,
bool parametric,
bool mesh)
2128 computeSquaredError_impl<d,bending,2>(dualL,dualH,deformed,withLoads,filename,np,parametric,mesh);
2132template <
short_t d,
class T,
bool bending>
2133template<
short_t _d,
bool _bending, index_t _elWise>
2134typename std::enable_if<(_d==3) && _bending,
void>::type
2135gsThinShellAssemblerDWR<d, T, bending>::computeSquaredError_impl(
const gsMultiPatch<T> & dualL,
const gsMultiPatch<T> & dualH,
const gsMultiPatch<T> & deformed,
bool withLoads,
2137 std::string filename,
unsigned np,
bool ,
bool mesh)
2140 gsExprAssembler<T> exprAssembler = m_assemblerH->assembler();
2141 exprAssembler.cleanUp();
2142 GISMO_ENSURE(m_assemblerH->options().hasGroup(
"ExprAssembler"),
"The option list does not contain options with the label 'ExprAssembler'!");
2143 exprAssembler.setOptions(m_assemblerH->options().getGroup(
"ExprAssembler"));
2146 geometryMap Gori = exprAssembler.getMap(m_patches);
2147 geometryMap Gdef = exprAssembler.getMap(deformed);
2149 gsMaterialMatrixIntegrate<T,MaterialOutput::VectorN> S0f(m_assemblerH->materials(),&deformed);
2150 gsMaterialMatrixIntegrate<T,MaterialOutput::VectorM> S1f(m_assemblerH->materials(),&deformed);
2151 auto S0 = exprAssembler.getCoeff(S0f);
2152 auto S1 = exprAssembler.getCoeff(S1f);
2154 gsFunctionExpr<T> mult2t(
"1",
"0",
"0",
"0",
"1",
"0",
"0",
"0",
"2",2);
2155 auto m2 = exprAssembler.getCoeff(mult2t);
2157 auto F = exprAssembler.getCoeff(*m_forceFun, Gori);
2158 auto zsolL = exprAssembler.getCoeff(dualL);
2159 auto zsolH = exprAssembler.getCoeff(dualH);
2162 Base::homogenizeDirichlet();
2166 auto Em_der =
flat(
jac(Gdef).tr() * (
jac(zsolH) -
jac(zsolL)) ) ;
2170 auto Ef_der = -( deriv2(zsolH,sn(Gdef).normalized().tr() )
2171 - deriv2(zsolL,sn(Gdef).normalized().tr() ) + deriv2(Gdef,var1(zsolH,Gdef) )
2172 - deriv2(Gdef,var1(zsolL,Gdef) ) ) *
reshape(m2,3,3);
2174 auto Fext = (zsolH-zsolL).tr() * F;
2175 auto Fint = ( N * Em_der.tr() + M * Ef_der.tr() );
2177 auto g_N = exprAssembler.getBdrFunction(Gori);
2179 auto expr = ( Fext - Fint ).sqNorm();
2180 auto bexpr= (zsolH-zsolL).tr() * g_N;
2182 gsExprEvaluator<T> ev(exprAssembler);
2184 T integral, bintegral;
2187 bintegral = ev.integralBdrBc( m_bcs.get(
"Neumann"), bexpr *
tv(Gori).norm());
2188 integral = ev.integral(expr *
meas(Gori));
2189 if (m_pLoads.numLoads()!=0 && withLoads)
2190 _applyLoadsToError(dualL,dualH,integral);
2192 m_error = integral+bintegral;
2194 else if (_elWise == 1)
2196 m_error = ev.integralElWise(expr *
meas(Gori));
2197 if (m_pLoads.numLoads()!=0 && withLoads)
2198 _applyLoadsToError(dualL,dualH,m_error);
2199 m_errors = ev.elementwise();
2200 if (m_pLoads.numLoads()!=0 && withLoads)
2201 _applyLoadsToElWiseError(dualL,dualH,m_errors);
2203 else if (_elWise == 2)
2225 if (!filename.empty())
2227 ev.options().setSwitch(
"plot.elements",mesh);
2228 ev.options().setInt(
"plot.npts",np);
2232 ev.writeParaview(expr,Gori,filename);
2236template <
short_t d,
class T,
bool bending>
2237template<
short_t _d,
bool _bending, index_t _elWise>
2238typename std::enable_if<!(_d==3 && _bending),
void>::type
2239gsThinShellAssemblerDWR<d, T, bending>::computeSquaredError_impl(
const gsMultiPatch<T> & dualL,
2240 const gsMultiPatch<T> & dualH,
2241 const gsMultiPatch<T> & deformed,
2243 std::string filename,
2248 gsExprAssembler<T> exprAssembler = m_assemblerH->assembler();
2249 exprAssembler.cleanUp();
2250 GISMO_ENSURE(m_assemblerH->options().hasGroup(
"ExprAssembler"),
"The option list does not contain options with the label 'ExprAssembler'!");
2251 exprAssembler.setOptions(m_assemblerH->options().getGroup(
"ExprAssembler"));
2254 geometryMap Gori = exprAssembler.getMap(m_patches);
2255 geometryMap Gdef = exprAssembler.getMap(deformed);
2257 gsMaterialMatrixIntegrate<T,MaterialOutput::VectorN> S0f(m_assemblerH->materials(),&deformed);
2258 auto S0 = exprAssembler.getCoeff(S0f);
2260 auto F = exprAssembler.getCoeff(*m_forceFun, Gori);
2262 auto zsolL = exprAssembler.getCoeff(dualL);
2263 auto zsolH = exprAssembler.getCoeff(dualH);
2268 auto Em_der =
flat(
jac(Gdef).tr() * (
jac(zsolH) -
jac(zsolL)) ) ;
2270 auto Fext = (zsolH-zsolL).tr() * F;
2271 auto Fint = ( N * Em_der.tr() );
2273 auto g_N = exprAssembler.getBdrFunction(Gori);
2275 auto expr = ( Fext - Fint ).sqNorm();
2276 auto bexpr= (zsolH-zsolL).tr() * g_N;
2278 gsExprEvaluator<T> ev(exprAssembler);
2280 T integral, bintegral;
2283 bintegral = ev.integralBdrBc( m_bcs.get(
"Neumann"), bexpr *
tv(Gori).norm());
2284 integral = ev.integral(expr *
meas(Gori));
2285 m_error = bintegral+integral;
2286 if (m_pLoads.numLoads()!=0 && withLoads)
2287 _applyLoadsToError(dualL,dualH,m_error);
2289 else if (_elWise == 1)
2291 m_error = ev.integralElWise(expr *
meas(Gori));
2292 if (m_pLoads.numLoads()!=0 && withLoads)
2293 _applyLoadsToError(dualL,dualH,m_error);
2294 m_errors = ev.elementwise();
2295 if (m_pLoads.numLoads()!=0 && withLoads)
2296 _applyLoadsToElWiseError(dualL,dualH,m_errors);
2298 else if (_elWise == 2)
2319 if (!filename.empty())
2321 ev.options().setSwitch(
"plot.elements",mesh);
2322 ev.options().setInt(
"plot.npts",np);
2326 ev.writeParaview(expr,Gori,filename);
2348template <
short_t d,
class T,
bool bending>
2349T gsThinShellAssemblerDWR<d, T, bending>::computeErrorEig(
const T evPrimalL,
2352 const gsMultiPatch<T> & dualL,
2353 const gsMultiPatch<T> & dualH,
2354 const gsMultiPatch<T> & primal,
2355 const gsMultiPatch<T> & deformed,
2356 std::string filename,
unsigned np,
bool parametric,
bool mesh)
2358 computeErrorEig_impl<0>(evPrimalL, evDualL, evDualH, dualL, dualH, primal, deformed,filename,np,parametric,mesh);
2362template <
short_t d,
class T,
bool bending>
2363std::vector<T> gsThinShellAssemblerDWR<d, T, bending>::computeErrorEigElements(
const T evPrimalL,
2366 const gsMultiPatch<T> & dualL,
2367 const gsMultiPatch<T> & dualH,
2368 const gsMultiPatch<T> & primal,
2369 const gsMultiPatch<T> & deformed,
2370 std::string filename,
unsigned np,
bool parametric,
bool mesh)
2372 computeErrorEig_impl<1>(evPrimalL, evDualL, evDualH, dualL, dualH, primal, deformed,filename,np,parametric,mesh);
2376template <
short_t d,
class T,
bool bending>
2377std::vector<T> gsThinShellAssemblerDWR<d, T, bending>::computeErrorEigDofs(
const T evPrimalL,
2380 const gsMultiPatch<T> & dualL,
2381 const gsMultiPatch<T> & dualH,
2382 const gsMultiPatch<T> & primal,
2383 const gsMultiPatch<T> & deformed,
2384 std::string filename,
unsigned np,
bool parametric,
bool mesh)
2386 computeErrorEig_impl<2>(evPrimalL, evDualL, evDualH, dualL, dualH, primal, deformed,filename,np,parametric,mesh);
2391template <
short_t d,
class T,
bool bending>
2392template <index_t _elWise>
2393void gsThinShellAssemblerDWR<d, T, bending>::computeErrorEig_impl(
const T evPrimalL,
2396 const gsMultiPatch<T> & dualL,
2397 const gsMultiPatch<T> & dualH,
2398 const gsMultiPatch<T> & primal,
2399 const gsMultiPatch<T> & deformed,
2400 std::string filename,
2406 gsExprAssembler<T> exprAssembler = m_assemblerH->assembler();
2407 exprAssembler.cleanUp();
2408 GISMO_ENSURE(m_assemblerH->options().hasGroup(
"ExprAssembler"),
"The option list does not contain options with the label 'ExprAssembler'!");
2409 exprAssembler.setOptions(m_assemblerH->options().getGroup(
"ExprAssembler"));
2412 geometryMap Gori = exprAssembler.getMap(m_patches);
2413 geometryMap Gdef = exprAssembler.getMap(deformed);
2416 exprAssembler.initSystem();
2417 exprAssembler.initVector(1);
2419 gsMaterialMatrixIntegrate<T,MaterialOutput::MatrixA> mmAf_L(m_assemblerH->materials(),&m_patches);
2420 gsMaterialMatrixIntegrate<T,MaterialOutput::MatrixB> mmBf_L(m_assemblerH->materials(),&m_patches);
2421 gsMaterialMatrixIntegrate<T,MaterialOutput::MatrixC> mmCf_L(m_assemblerH->materials(),&m_patches);
2422 gsMaterialMatrixIntegrate<T,MaterialOutput::MatrixD> mmDf_L(m_assemblerH->materials(),&m_patches);
2423 auto mmA_L = exprAssembler.getCoeff(mmAf_L);
2424 auto mmB_L = exprAssembler.getCoeff(mmBf_L);
2425 auto mmC_L = exprAssembler.getCoeff(mmCf_L);
2426 auto mmD_L = exprAssembler.getCoeff(mmDf_L);
2428 gsMaterialMatrixIntegrate<T,MaterialOutput::MatrixA> mmAf_NL(m_assemblerH->materials(),&deformed);
2429 gsMaterialMatrixIntegrate<T,MaterialOutput::MatrixB> mmBf_NL(m_assemblerH->materials(),&deformed);
2430 gsMaterialMatrixIntegrate<T,MaterialOutput::MatrixC> mmCf_NL(m_assemblerH->materials(),&deformed);
2431 gsMaterialMatrixIntegrate<T,MaterialOutput::MatrixD> mmDf_NL(m_assemblerH->materials(),&deformed);
2432 auto mmA_NL = exprAssembler.getCoeff(mmAf_NL);
2433 auto mmB_NL = exprAssembler.getCoeff(mmBf_NL);
2434 auto mmC_NL = exprAssembler.getCoeff(mmCf_NL);
2435 auto mmD_NL = exprAssembler.getCoeff(mmDf_NL);
2437 gsMaterialMatrixIntegrate<T,MaterialOutput::VectorN> S0f(m_assemblerH->materials(),&deformed);
2438 gsMaterialMatrixIntegrate<T,MaterialOutput::VectorM> S1f(m_assemblerH->materials(),&deformed);
2440 auto S0 = exprAssembler.getCoeff(S0f);
2441 auto S1 = exprAssembler.getCoeff(S1f);
2444 gsFunctionExpr<T> mult2t(
"1",
"0",
"0",
"0",
"1",
"0",
"0",
"0",
"2",2);
2445 auto m2 = exprAssembler.getCoeff(mult2t);
2447 auto usol = exprAssembler.getCoeff(primal);
2448 auto zsolL = exprAssembler.getCoeff(dualL);
2449 auto zsolH = exprAssembler.getCoeff(dualH);
2479 auto Em_der_L =
flat(
jac(Gori).tr() * (
jac(usol ) ) ) ;
2480 auto Em_derd_L =
flat(
jac(Gori).tr() * (
jac(zsolH) -
jac(zsolL) ) ) ;
2483 auto Ef_der_L = -( deriv2(usol , sn(Gori).normalized().tr() ) - deriv2(Gori, var1(usol , Gori) ) ) *
reshape(m2, 3, 3);
2485 deriv2(zsolH, sn(Gori).normalized().tr() ) - deriv2(Gori, var1(zsolH, Gori) )
2486 -deriv2(zsolL, sn(Gori).normalized().tr() ) - deriv2(Gori, var1(zsolL, Gori) )
2489 auto N_der_L = Em_der_L *
reshape(mmA_L,3,3) + Ef_der_L *
reshape(mmB_L,3,3);
2490 auto M_der_L = Em_der_L *
reshape(mmC_L,3,3) + Ef_der_L *
reshape(mmD_L,3,3);
2492 auto N_derd_L = Em_derd_L *
reshape(mmA_L,3,3) + Ef_derd_L *
reshape(mmB_L,3,3);
2493 auto M_derd_L = Em_derd_L *
reshape(mmC_L,3,3) + Ef_derd_L *
reshape(mmD_L,3,3);
2495 auto Fint_L = ( N_derd_L * Em_derd_L.tr() + M_derd_L * Ef_derd_L.tr() );
2497 auto N_NL = S0.tr();
2498 auto Em_der_NL =
flat(
jac(Gdef).tr() * (
jac(usol ) ) ) ;
2499 auto Em_derd_NL =
flat(
jac(Gdef).tr() * (
jac(zsolH) -
jac(zsolL) ) ) ;
2501 auto Em_der2 =
flat(
jac(usol).tr() * (
jac(usol) ) ) * N_NL.tr();
2502 auto Emd_der2 =
flat(
jac(usol).tr() * (
jac(zsolH) -
jac(zsolL) ) ) * N_NL.tr();
2504 auto M_NL = S1.tr();
2505 auto Ef_der_NL = -( deriv2(usol , sn(Gdef).normalized().tr() ) - deriv2(Gdef, var1(usol , Gdef) ) ) *
reshape(m2, 3, 3);
2506 auto Ef_derd_NL = -(
2507 deriv2(zsolH, sn(Gdef).normalized().tr() ) - deriv2(Gdef, var1(zsolH, Gdef) )
2508 -deriv2(zsolL, sn(Gdef).normalized().tr() ) - deriv2(Gdef, var1(zsolL, Gdef) )
2512 ( ( deriv2(usol ) ) * ( var1(usol ,Gdef) ).tr() ).tr() *
reshape(m2, 3, 3)
2513 + ( ( deriv2(usol ) ) * ( var1(usol ,Gdef) ).tr() ).tr() *
reshape(m2, 3, 3)
2514 + ( deriv2(Gdef) * ( var2(usol ,usol ,Gdef) ) ).tr() *
reshape(m2, 3, 3)
2518 ( ( deriv2(usol ) ) * ( var1(zsolH,Gdef) - var1(zsolL,Gdef) ).tr() ).tr() *
reshape(m2, 3, 3)
2519 + ( ( deriv2(zsolH) - deriv2(zsolL) ) * ( var1(usol ,Gdef) ).tr() ).tr() *
reshape(m2, 3, 3)
2520 + ( deriv2(Gdef) * ( var2(usol ,zsolH,Gdef) - var2(usol ,zsolL,Gdef) ) ).tr() *
reshape(m2, 3, 3)
2524 auto N_der_NL = Em_der_NL *
reshape(mmA_NL,3,3) + Ef_der_NL *
reshape(mmB_NL,3,3);
2525 auto M_der_NL = Em_der_NL *
reshape(mmC_NL,3,3) + Ef_der_NL *
reshape(mmD_NL,3,3);
2527 auto N_derd_NL = Em_derd_NL *
reshape(mmA_NL,3,3) + Ef_derd_NL *
reshape(mmB_NL,3,3);
2528 auto M_derd_NL = Em_derd_NL *
reshape(mmC_NL,3,3) + Ef_derd_NL *
reshape(mmD_NL,3,3);
2530 auto K_L = ( N_der_L * Em_der_L.tr() + M_der_L * Ef_der_L.tr() );
2531 auto Kd_L = ( N_derd_L * Em_der_L.tr() + M_derd_L * Ef_der_L.tr() );
2532 auto K_NL = ( N_der_NL * Em_der_NL.tr() + M_der_NL * Ef_der_NL.tr() + Em_der2 + Ef_der2 );
2533 auto Kd_NL = ( N_derd_NL * Em_der_NL.tr() + M_derd_NL * Ef_der_NL.tr() + Emd_der2 + Efd_der2 );
2536 auto Bdiff = Kd_NL - Kd_L;
2537 auto Bprimal = K_NL - K_L ;
2539 auto expr = A - evPrimalL * Bdiff + (evDualH - evDualL) * Bprimal;
2541 gsExprEvaluator<T> ev(exprAssembler);
2544 m_error = ev.integral(expr *
meas(Gori)) - (evDualH - evDualL);
2546 else if (_elWise == 1)
2548 m_error = ev.integralElWise(expr *
meas(Gori)) - (evDualH - evDualL);
2549 m_errors = ev.elementwise();
2551 else if (_elWise == 2)
2558 if (!filename.empty())
2560 ev.options().setSwitch(
"plot.elements",mesh);
2561 ev.options().setInt(
"plot.npts",np);
2565 ev.writeParaview(expr,Gori,filename);
2605template <
short_t d,
class T,
bool bending>
2606T gsThinShellAssemblerDWR<d, T, bending>::computeErrorEig(
const T evPrimalL,
2609 const gsMultiPatch<T> & dualL,
2610 const gsMultiPatch<T> & dualH,
2611 const gsMultiPatch<T> & primal,
2612 std::string filename,
unsigned np,
bool parametric,
bool mesh)
2614 computeErrorEig_impl<0>(evPrimalL, evDualL, evDualH, dualL, dualH, primal,filename,np,parametric,mesh);
2618template <
short_t d,
class T,
bool bending>
2619std::vector<T> gsThinShellAssemblerDWR<d, T, bending>::computeErrorEigElements(
const T evPrimalL,
2622 const gsMultiPatch<T> & dualL,
2623 const gsMultiPatch<T> & dualH,
2624 const gsMultiPatch<T> & primal,
2625 std::string filename,
unsigned np,
bool parametric,
bool mesh)
2627 computeErrorEig_impl<1>(evPrimalL, evDualL, evDualH, dualL, dualH, primal,filename,np,parametric,mesh);
2631template <
short_t d,
class T,
bool bending>
2632std::vector<T> gsThinShellAssemblerDWR<d, T, bending>::computeErrorEigDofs(
const T evPrimalL,
2635 const gsMultiPatch<T> & dualL,
2636 const gsMultiPatch<T> & dualH,
2637 const gsMultiPatch<T> & primal,
2638 std::string filename,
unsigned np,
bool parametric,
bool mesh)
2640 computeErrorEig_impl<2>(evPrimalL, evDualL, evDualH, dualL, dualH, primal,filename,np,parametric,mesh);
2644template <
short_t d,
class T,
bool bending>
2645template <index_t _elWise>
2646void gsThinShellAssemblerDWR<d, T, bending>::computeErrorEig_impl(
const T evPrimalL,
2649 const gsMultiPatch<T> & dualL,
2650 const gsMultiPatch<T> & dualH,
2651 const gsMultiPatch<T> & primal,
2652 std::string filename,
2658 gsExprAssembler<T> exprAssembler = m_assemblerH->assembler();
2659 exprAssembler.cleanUp();
2660 GISMO_ENSURE(m_assemblerH->options().hasGroup(
"ExprAssembler"),
"The option list does not contain options with the label 'ExprAssembler'!");
2661 exprAssembler.setOptions(m_assemblerH->options().getGroup(
"ExprAssembler"));
2663 gsMultiPatch<T> deformed = m_patches;
2664 for (
size_t k =0; k!=primal.nPatches(); ++k)
2665 deformed.patch(k).coefs() += primal.patch(k).coefs();
2668 geometryMap Gori = exprAssembler.getMap(m_patches);
2671 exprAssembler.initSystem();
2672 exprAssembler.initVector(1);
2674 gsMaterialMatrixIntegrate<T,MaterialOutput::MatrixA> mmAf(m_assemblerH->materials(),&m_patches);
2675 gsMaterialMatrixIntegrate<T,MaterialOutput::MatrixB> mmBf(m_assemblerH->materials(),&m_patches);
2676 gsMaterialMatrixIntegrate<T,MaterialOutput::MatrixC> mmCf(m_assemblerH->materials(),&m_patches);
2677 gsMaterialMatrixIntegrate<T,MaterialOutput::MatrixD> mmDf(m_assemblerH->materials(),&m_patches);
2678 auto mmA = exprAssembler.getCoeff(mmAf);
2679 auto mmB = exprAssembler.getCoeff(mmBf);
2680 auto mmC = exprAssembler.getCoeff(mmCf);
2681 auto mmD = exprAssembler.getCoeff(mmDf);
2683 gsMaterialMatrixIntegrate<T,MaterialOutput::VectorN> S0f(m_assemblerH->materials(),&m_patches);
2684 gsMaterialMatrixIntegrate<T,MaterialOutput::VectorM> S1f(m_assemblerH->materials(),&m_patches);
2685 gsMaterialMatrixIntegrate<T,MaterialOutput::Density> rhof(m_assemblerH->materials(),&m_patches);
2686 auto S0 = exprAssembler.getCoeff(S0f);
2687 auto S1 = exprAssembler.getCoeff(S1f);
2688 auto rho = exprAssembler.getCoeff(rhof);
2690 gsFunctionExpr<T> mult2t(
"1",
"0",
"0",
"0",
"1",
"0",
"0",
"0",
"2",2);
2691 auto m2 = exprAssembler.getCoeff(mult2t);
2693 auto usol = exprAssembler.getCoeff(primal);
2694 auto zsolL = exprAssembler.getCoeff(dualL);
2695 auto zsolH = exprAssembler.getCoeff(dualH);
2698 auto Em_derd=
flat(
jac(Gori).tr() * (
jac(zsolH) -
jac(zsolL)) ) ;
2699 auto Em_der =
flat(
jac(Gori).tr() * (
jac(usol) ) ) ;
2701 auto Em_derdw=
flat(
jac(Gori).tr() * (
jac(zsolH) -
jac(zsolL)) ) ;
2705 auto Ef_derd= -( deriv2(zsolH, sn(Gori).normalized().tr() )
2706 - deriv2(zsolL, sn(Gori).normalized().tr() ) + deriv2(Gori, var1(zsolH, Gori) )
2707 - deriv2(Gori, var1(zsolL, Gori) ) ) *
reshape(m2, 3, 3);
2708 auto Ef_der = -( deriv2(usol, sn(Gori).normalized().tr() ) + deriv2(Gori, var1(usol, Gori)) ) *
reshape(m2, 3, 3);
2710 auto N_der = Em_derd *
reshape(mmA,3,3) + Ef_derd *
reshape(mmB,3,3);
2711 auto M_der = Em_derd *
reshape(mmC,3,3) + Ef_derd *
reshape(mmD,3,3);
2713 auto Fint = ( N_der * Em_der.tr() + M_der * Ef_der.tr() );
2715 gsExprEvaluator<T> ev(exprAssembler);
2718 auto Bdiff = rho.val() * usol.tr() * (zsolH - zsolL);
2719 auto Bprimal= rho.val() * usol.tr() * usol;
2720 auto expr = A - evPrimalL * Bdiff + (evDualH - evDualL) * Bprimal;
2723 m_error = ev.integral(expr *
meas(Gori)) - (evDualH - evDualL);
2724 else if (_elWise == 1)
2726 m_error = ev.integralElWise(expr *
meas(Gori) ) - (evDualH - evDualL);
2727 m_errors = ev.elementwise();
2729 else if (_elWise == 2)
2734 if (!filename.empty())
2736 ev.options().setSwitch(
"plot.elements",mesh);
2737 ev.options().setInt(
"plot.npts",np);
2741 ev.writeParaview(expr,Gori,filename);
2746template <
short_t d,
class T,
bool bending>
2747T gsThinShellAssemblerDWR<d, T, bending>::computeGoal(
const gsMultiPatch<T> & deformed)
2752 gsExprAssembler<T> exprAssembler = m_assemblerH->assembler();
2753 exprAssembler.cleanUp();
2754 GISMO_ENSURE(m_assemblerH->options().hasGroup(
"ExprAssembler"),
"The option list does not contain options with the label 'ExprAssembler'!");
2755 exprAssembler.setOptions(m_assemblerH->options().getGroup(
"ExprAssembler"));
2758 exprAssembler.initSystem();
2759 exprAssembler.initVector(1);
2762 geometryMap Gori = exprAssembler.getMap(m_patches);
2763 geometryMap Gdef = exprAssembler.getMap(deformed);
2766 gsMaterialMatrixEval<T,MaterialOutput::StretchTransform> Tstretchf(m_assemblerH->materials(),&deformed,Z);
2767 auto Tstretch = exprAssembler.getCoeff(Tstretchf);
2770 gsMaterialMatrixEval<T,MaterialOutput::VectorN> S0f(m_assemblerH->materials(),&deformed,Z);
2771 gsMaterialMatrixEval<T,MaterialOutput::VectorM> S1f(m_assemblerH->materials(),&deformed,Z);
2772 auto S0 = exprAssembler.getCoeff(S0f);
2773 auto S1 = exprAssembler.getCoeff(S1f);
2776 gsMaterialMatrixIntegrate<T,MaterialOutput::VectorN> Nf(m_assemblerH->materials(),&deformed);
2777 gsMaterialMatrixIntegrate<T,MaterialOutput::VectorM> Mf(m_assemblerH->materials(),&deformed);
2778 auto N = exprAssembler.getCoeff(Nf);
2779 auto M = exprAssembler.getCoeff(Mf);
2793 gsMaterialMatrixEval<T,MaterialOutput::PStress> P0f(m_assemblerH->materials(),&deformed,Z);
2794 auto P0 = exprAssembler.getCoeff(P0f);
2797 gsFunctionExpr<T> mult2t(
"1",
"0",
"0",
"0",
"1",
"0",
"0",
"0",
"2",2);
2798 auto m2 = exprAssembler.getCoeff(mult2t);
2802 gsFunctionExpr<T> mult12t(
"1",
"0",
"0",
"0",
"1",
"0",
"0",
"0",
"0.5",2);
2803 auto m12 = exprAssembler.getCoeff(mult12t);
2808 auto lambda =
reshape(Tstretch,3,3) * Cm.tr();
2817 auto Ef = ( deriv2(Gori,sn(Gori).normalized().tr()) - deriv2(Gdef,sn(Gdef).normalized().tr()) ) *
reshape(m2,3,3) ;
2823 gsExprEvaluator<T> ev(exprAssembler);
2824 if (m_goalFunction == GoalFunction::Displacement)
2828 auto expr = (Gdef - Gori).tr() * (Gdef - Gori) *
meas(Gori);
2829 return ev.integral( expr );
2833 auto expr = (Gdef - Gori).tr() * gismo::expr::uv(m_component,3)*
meas(Gori);
2834 return ev.integral( expr );
2837 else if (m_goalFunction == GoalFunction::Stretch)
2848 auto expr = lambda.tr() * lambda *
meas(Gori);
2849 return ev.integral( expr );
2853 auto expr = lambda.tr() * gismo::expr::uv(m_component,3)*
meas(Gori);
2854 return ev.integral( expr );
2857 else if (m_goalFunction == GoalFunction::PStrain)
2861 auto expr = Emp * Emp.tr() *
meas(Gori);
2862 return ev.integral( expr );
2866 auto expr = Emp * gismo::expr::uv(m_component,3) *
meas(Gori);
2867 return ev.integral( expr );
2870 else if (m_goalFunction == GoalFunction::PStress)
2874 auto expr = P0.tr() * P0 *
meas(Gori);
2875 return ev.integral( expr );
2879 GISMO_ASSERT(m_component < 2,
"Can only select principle stress component 0 or 1, but "<<m_component<<
" selected.");
2880 auto expr = P0.tr() * gismo::expr::uv(m_component,2) *
meas(Gori);
2881 return ev.integral( expr );
2885 else if (m_goalFunction == GoalFunction::MembraneStrain)
2890 auto expr = Em.sqNorm() *
meas(Gori);
2891 return ev.integral( expr );
2895 auto expr = Em * gismo::expr::uv(m_component,3) *
meas(Gori);
2896 return ev.integral( expr );
2899 else if (m_goalFunction == GoalFunction::MembraneStress)
2903 auto expr = S0.tr() * S0 *
meas(Gori);
2904 return ev.integral( expr );
2908 auto expr = S0.tr() * gismo::expr::uv(m_component,3) *
meas(Gori);
2909 return ev.integral( expr );
2912 else if (m_goalFunction == GoalFunction::MembraneForce)
2916 auto expr = N.tr() * N *
meas(Gori);
2917 return ev.integral( expr );
2921 auto expr = N.tr() * gismo::expr::uv(m_component,3) *
meas(Gori);
2922 return ev.integral( expr );
2925 else if (m_goalFunction == GoalFunction::FlexuralStrain)
2929 auto expr = Ef * Ef.tr() *
meas(Gori);
2930 return ev.integral( expr );
2934 auto expr = Ef * gismo::expr::uv(m_component,3) *
meas(Gori);
2935 return ev.integral( expr );
2938 else if (m_goalFunction == GoalFunction::FlexuralStress)
2942 auto expr = S1.tr() * S1 *
meas(Gori);
2943 return ev.integral( expr );
2947 auto expr = S1.tr() * gismo::expr::uv(m_component,3) *
meas(Gori);
2948 return ev.integral( expr );
2951 else if (m_goalFunction == GoalFunction::FlexuralMoment)
2955 auto expr = M.tr() * M *
meas(Gori);
2956 return ev.integral( expr );
2960 auto expr = M.tr() * gismo::expr::uv(m_component,3) *
meas(Gori);
2961 return ev.integral( expr );
2968template <
short_t d,
class T,
bool bending>
2969T gsThinShellAssemblerDWR<d, T, bending>::computeGoal(
const bContainer & bnds,
const gsMultiPatch<T> & deformed)
2971 if (bnds.size()==0)
return 0;
2976 gsExprAssembler<T> exprAssembler = m_assemblerH->assembler();
2977 exprAssembler.cleanUp();
2978 GISMO_ENSURE(m_assemblerH->options().hasGroup(
"ExprAssembler"),
"The option list does not contain options with the label 'ExprAssembler'!");
2979 exprAssembler.setOptions(m_assemblerH->options().getGroup(
"ExprAssembler"));
2982 exprAssembler.initSystem();
2983 exprAssembler.initVector(1);
2986 geometryMap Gori = exprAssembler.getMap(m_patches);
2987 geometryMap Gdef = exprAssembler.getMap(deformed);
2990 gsMaterialMatrixEval<T,MaterialOutput::StretchTransform> Tstretchf(m_assemblerH->materials(),&deformed,Z);
2991 auto Tstretch = exprAssembler.getCoeff(Tstretchf);
2994 gsMaterialMatrixEval<T,MaterialOutput::VectorN> S0f(m_assemblerH->materials(),&deformed,Z);
2995 gsMaterialMatrixEval<T,MaterialOutput::VectorM> S1f(m_assemblerH->materials(),&deformed,Z);
2996 auto S0 = exprAssembler.getCoeff(S0f);
2997 auto S1 = exprAssembler.getCoeff(S1f);
3000 gsMaterialMatrixIntegrate<T,MaterialOutput::VectorN> Nf(m_assemblerH->materials(),&deformed);
3001 gsMaterialMatrixIntegrate<T,MaterialOutput::VectorM> Mf(m_assemblerH->materials(),&deformed);
3002 auto N = exprAssembler.getCoeff(Nf);
3003 auto M = exprAssembler.getCoeff(Mf);
3017 gsMaterialMatrixEval<T,MaterialOutput::PStress> P0f(m_assemblerH->materials(),&deformed,Z);
3018 auto P0 = exprAssembler.getCoeff(P0f);
3021 gsFunctionExpr<T> mult2t(
"1",
"0",
"0",
"0",
"1",
"0",
"0",
"0",
"2",2);
3022 auto m2 = exprAssembler.getCoeff(mult2t);
3026 gsFunctionExpr<T> mult12t(
"1",
"0",
"0",
"0",
"1",
"0",
"0",
"0",
"0.5",2);
3027 auto m12 = exprAssembler.getCoeff(mult12t);
3032 auto lambda =
reshape(Tstretch,3,3) * Cm.tr();
3041 auto Ef = ( deriv2(Gori,sn(Gori).normalized().tr()) - deriv2(Gdef,sn(Gdef).normalized().tr()) ) *
reshape(m2,3,3) ;
3047 gsExprEvaluator<T> ev(exprAssembler);
3048 if (m_goalFunction == GoalFunction::Displacement)
3052 auto expr = (Gdef - Gori).tr() * (Gdef - Gori) *
meas(Gori);
3053 return ev.integralBdr( expr,bnds );
3057 auto expr = (Gdef - Gori).tr() * gismo::expr::uv(m_component,3)*
meas(Gori);
3058 return ev.integralBdr( expr,bnds );
3061 else if (m_goalFunction == GoalFunction::Stretch)
3072 auto expr = lambda.tr() * lambda *
meas(Gori);
3073 return ev.integralBdr( expr,bnds );
3077 auto expr = lambda.tr() * gismo::expr::uv(m_component,3)*
meas(Gori);
3078 return ev.integralBdr( expr,bnds );
3081 else if (m_goalFunction == GoalFunction::PStrain)
3085 auto expr = Emp * Emp.tr() *
meas(Gori);
3086 return ev.integralBdr( expr,bnds );
3090 auto expr = Emp * gismo::expr::uv(m_component,3) *
meas(Gori);
3091 return ev.integralBdr( expr,bnds );
3094 else if (m_goalFunction == GoalFunction::PStress)
3098 auto expr = P0.tr() * P0 *
meas(Gori);
3099 return ev.integralBdr( expr,bnds );
3103 GISMO_ASSERT(m_component < 2,
"Can only select principle stress component 0 or 1, but "<<m_component<<
" selected.");
3104 auto expr = P0.tr() * gismo::expr::uv(m_component,2) *
meas(Gori);
3105 return ev.integralBdr( expr,bnds );
3108 else if (m_goalFunction == GoalFunction::MembraneStrain)
3113 auto expr = Em.sqNorm() *
meas(Gori);
3114 return ev.integralBdr( expr,bnds );
3118 auto expr = Em * gismo::expr::uv(m_component,3) *
meas(Gori);
3119 return ev.integralBdr( expr,bnds );
3122 else if (m_goalFunction == GoalFunction::MembraneStress)
3126 auto expr = S0.tr() * S0 *
meas(Gori);
3127 return ev.integralBdr( expr,bnds );
3131 auto expr = S0.tr() * gismo::expr::uv(m_component,3) *
meas(Gori);
3132 return ev.integralBdr( expr,bnds );
3135 else if (m_goalFunction == GoalFunction::MembraneForce)
3139 auto expr = N.tr() * N *
meas(Gori);
3140 return ev.integralBdr( expr,bnds );
3144 auto expr = N.tr() * gismo::expr::uv(m_component,3) *
meas(Gori);
3145 return ev.integralBdr( expr,bnds );
3148 else if (m_goalFunction == GoalFunction::FlexuralStrain)
3152 auto expr = Ef * Ef.tr() *
meas(Gori);
3153 return ev.integralBdr( expr,bnds );
3157 auto expr = Ef * gismo::expr::uv(m_component,3) *
meas(Gori);
3158 return ev.integralBdr( expr,bnds );
3161 else if (m_goalFunction == GoalFunction::FlexuralStress)
3165 auto expr = S1.tr() * S1 *
meas(Gori);
3166 return ev.integralBdr( expr,bnds );
3170 auto expr = S1.tr() * gismo::expr::uv(m_component,3) *
meas(Gori);
3171 return ev.integralBdr( expr,bnds );
3174 else if (m_goalFunction == GoalFunction::FlexuralMoment)
3178 auto expr = M.tr() * M *
meas(Gori);
3179 return ev.integralBdr( expr,bnds );
3183 auto expr = M.tr() * gismo::expr::uv(m_component,3) *
meas(Gori);
3184 return ev.integralBdr( expr,bnds );
3191template <
short_t d,
class T,
bool bending>
3192T gsThinShellAssemblerDWR<d, T, bending>::computeGoal(
const gsMatrix<T> & points,
const gsMultiPatch<T> & deformed)
3194 if (points.cols()==0)
return 0;
3199 gsExprAssembler<T> exprAssembler = m_assemblerH->assembler();
3200 exprAssembler.cleanUp();
3201 GISMO_ENSURE(m_assemblerH->options().hasGroup(
"ExprAssembler"),
"The option list does not contain options with the label 'ExprAssembler'!");
3202 exprAssembler.setOptions(m_assemblerH->options().getGroup(
"ExprAssembler"));
3206 exprAssembler.initSystem();
3207 exprAssembler.initVector(1);
3210 geometryMap Gori = exprAssembler.getMap(m_patches);
3211 geometryMap Gdef = exprAssembler.getMap(deformed);
3214 gsMaterialMatrixEval<T,MaterialOutput::StretchTransform> Tstretchf(m_assemblerH->materials(),&deformed,Z);
3215 auto Tstretch = exprAssembler.getCoeff(Tstretchf);
3219 gsMaterialMatrixEval<T,MaterialOutput::VectorN> S0f(m_assemblerH->materials(),&deformed,Z);
3220 gsMaterialMatrixEval<T,MaterialOutput::VectorM> S1f(m_assemblerH->materials(),&deformed,Z);
3221 auto S0 = exprAssembler.getCoeff(S0f);
3222 auto S1 = exprAssembler.getCoeff(S1f);
3225 gsMaterialMatrixIntegrate<T,MaterialOutput::VectorN> Nf(m_assemblerH->materials(),&deformed);
3226 gsMaterialMatrixIntegrate<T,MaterialOutput::VectorM> Mf(m_assemblerH->materials(),&deformed);
3227 auto N = exprAssembler.getCoeff(Nf);
3228 auto M = exprAssembler.getCoeff(Mf);
3231 gsMaterialMatrixEval<T,MaterialOutput::PStress> P0f(m_assemblerH->materials(),&deformed,Z);
3232 auto P0 = exprAssembler.getCoeff(P0f);
3235 gsFunctionExpr<T> mult2t(
"1",
"0",
"0",
"0",
"1",
"0",
"0",
"0",
"2",2);
3236 auto m2 = exprAssembler.getCoeff(mult2t);
3240 gsFunctionExpr<T> mult12t(
"1",
"0",
"0",
"0",
"1",
"0",
"0",
"0",
"0.5",2);
3241 auto m12 = exprAssembler.getCoeff(mult12t);
3246 auto lambda =
reshape(Tstretch,3,3).tr() * Cm.tr();
3255 auto Ef = ( deriv2(Gori,sn(Gori).normalized().tr()) - deriv2(Gdef,sn(Gdef).normalized().tr()) ) *
reshape(m2,3,3) ;
3260 gsExprEvaluator<T> ev(exprAssembler);
3263 if (m_goalFunction == GoalFunction::Displacement)
3267 auto expr = (Gdef - Gori).tr() * (Gdef - Gori) *
meas(Gori);
3268 for (
index_t k = 0; k!=points.cols(); k++)
3270 tmp = ev.eval( expr, points.col(k));
3271 GISMO_ASSERT(tmp.cols()==tmp.rows() && tmp.cols()==1,
"Goal function must be scalar!");
3278 auto expr = (Gdef - Gori).tr() * gismo::expr::uv(m_component,3)*
meas(Gori);
3279 for (
index_t k = 0; k!=points.cols(); k++)
3281 tmp = ev.eval( expr, points.col(k));
3282 GISMO_ASSERT(tmp.cols()==tmp.rows() && tmp.cols()==1,
"Goal function must be scalar!");
3288 else if (m_goalFunction == GoalFunction::Stretch)
3299 auto expr = lambda.tr() * lambda *
meas(Gori);
3300 for (
index_t k = 0; k!=points.cols(); k++)
3302 tmp = ev.eval( expr, points.col(k));
3303 GISMO_ASSERT(tmp.cols()==tmp.rows() && tmp.cols()==1,
"Goal function must be scalar!");
3310 auto expr = (Gdef - Gori).tr() * gismo::expr::uv(m_component,3)*
meas(Gori);
3311 for (
index_t k = 0; k!=points.cols(); k++)
3313 tmp = ev.eval( expr, points.col(k));
3314 GISMO_ASSERT(tmp.cols()==tmp.rows() && tmp.cols()==1,
"Goal function must be scalar!");
3320 else if (m_goalFunction == GoalFunction::PStrain)
3324 auto expr = Emp * Emp.tr() *
meas(Gori);
3325 for (
index_t k = 0; k!=points.cols(); k++)
3327 tmp = ev.eval( expr, points.col(k));
3328 GISMO_ASSERT(tmp.cols()==tmp.rows() && tmp.cols()==1,
"Goal function must be scalar!");
3335 auto expr = Emp * gismo::expr::uv(m_component,3) *
meas(Gori);
3336 for (
index_t k = 0; k!=points.cols(); k++)
3338 tmp = ev.eval( expr, points.col(k));
3339 GISMO_ASSERT(tmp.cols()==tmp.rows() && tmp.cols()==1,
"Goal function must be scalar!");
3345 else if (m_goalFunction == GoalFunction::PStress)
3349 auto expr = P0.tr() * P0 *
meas(Gori);
3350 for (
index_t k = 0; k!=points.cols(); k++)
3352 tmp = ev.eval( expr, points.col(k));
3353 GISMO_ASSERT(tmp.cols()==tmp.rows() && tmp.cols()==1,
"Goal function must be scalar!");
3360 GISMO_ASSERT(m_component < 2,
"Can only select principle stress component 0 or 1, but "<<m_component<<
" selected.");
3361 auto expr = P0.tr() * gismo::expr::uv(m_component,2) *
meas(Gori);
3362 for (
index_t k = 0; k!=points.cols(); k++)
3364 tmp = ev.eval( expr, points.col(k));
3365 GISMO_ASSERT(tmp.cols()==tmp.rows() && tmp.cols()==1,
"Goal function must be scalar!");
3371 else if (m_goalFunction == GoalFunction::MembraneStrain)
3375 auto expr = Em * Em.tr() *
meas(Gori);
3376 for (
index_t k = 0; k!=points.cols(); k++)
3378 tmp = ev.eval( expr, points.col(k));
3379 GISMO_ASSERT(tmp.cols()==tmp.rows() && tmp.cols()==1,
"Goal function must be scalar!");
3386 auto expr = Em * gismo::expr::uv(m_component,3) *
meas(Gori);
3387 for (
index_t k = 0; k!=points.cols(); k++)
3389 tmp = ev.eval( expr, points.col(k));
3390 GISMO_ASSERT(tmp.cols()==tmp.rows() && tmp.cols()==1,
"Goal function must be scalar!");
3396 else if (m_goalFunction == GoalFunction::MembraneStress)
3400 auto expr = S0.tr() * S0 *
meas(Gori);
3401 for (
index_t k = 0; k!=points.cols(); k++)
3403 tmp = ev.eval( expr, points.col(k));
3404 GISMO_ASSERT(tmp.cols()==tmp.rows() && tmp.cols()==1,
"Goal function must be scalar!");
3411 auto expr = S0.tr() * gismo::expr::uv(m_component,3) *
meas(Gori);
3412 for (
index_t k = 0; k!=points.cols(); k++)
3414 tmp = ev.eval( expr, points.col(k));
3415 GISMO_ASSERT(tmp.cols()==tmp.rows() && tmp.cols()==1,
"Goal function must be scalar!");
3421 else if (m_goalFunction == GoalFunction::MembraneForce)
3425 auto expr = N.tr() * N *
meas(Gori);
3426 for (
index_t k = 0; k!=points.cols(); k++)
3428 tmp = ev.eval( expr, points.col(k));
3429 GISMO_ASSERT(tmp.cols()==tmp.rows() && tmp.cols()==1,
"Goal function must be scalar!");
3436 auto expr = N.tr() * gismo::expr::uv(m_component,3) *
meas(Gori);
3437 for (
index_t k = 0; k!=points.cols(); k++)
3439 tmp = ev.eval( expr, points.col(k));
3440 GISMO_ASSERT(tmp.cols()==tmp.rows() && tmp.cols()==1,
"Goal function must be scalar!");
3446 else if (m_goalFunction == GoalFunction::FlexuralStrain)
3450 auto expr = Ef * Ef.tr() *
meas(Gori);
3451 for (
index_t k = 0; k!=points.cols(); k++)
3453 tmp = ev.eval( expr, points.col(k));
3454 GISMO_ASSERT(tmp.cols()==tmp.rows() && tmp.cols()==1,
"Goal function must be scalar!");
3461 auto expr = Ef * gismo::expr::uv(m_component,3) *
meas(Gori);
3462 for (
index_t k = 0; k!=points.cols(); k++)
3464 tmp = ev.eval( expr, points.col(k));
3465 GISMO_ASSERT(tmp.cols()==tmp.rows() && tmp.cols()==1,
"Goal function must be scalar!");
3471 else if (m_goalFunction == GoalFunction::FlexuralStress)
3475 auto expr = S1.tr() * S1 *
meas(Gori);
3476 for (
index_t k = 0; k!=points.cols(); k++)
3478 tmp = ev.eval( expr, points.col(k));
3479 GISMO_ASSERT(tmp.cols()==tmp.rows() && tmp.cols()==1,
"Goal function must be scalar!");
3486 auto expr = S1.tr() * gismo::expr::uv(m_component,3) *
meas(Gori);
3487 for (
index_t k = 0; k!=points.cols(); k++)
3489 tmp = ev.eval( expr, points.col(k));
3490 GISMO_ASSERT(tmp.cols()==tmp.rows() && tmp.cols()==1,
"Goal function must be scalar!");
3496 else if (m_goalFunction == GoalFunction::FlexuralMoment)
3500 auto expr = M.tr() * M *
meas(Gori);
3501 for (
index_t k = 0; k!=points.cols(); k++)
3503 tmp = ev.eval( expr, points.col(k));
3504 GISMO_ASSERT(tmp.cols()==tmp.rows() && tmp.cols()==1,
"Goal function must be scalar!");
3511 auto expr = M.tr() * gismo::expr::uv(m_component,3) *
meas(Gori);
3512 for (
index_t k = 0; k!=points.cols(); k++)
3514 tmp = ev.eval( expr, points.col(k));
3515 GISMO_ASSERT(tmp.cols()==tmp.rows() && tmp.cols()==1,
"Goal function must be scalar!");
3526template <
short_t d,
class T,
bool bending>
3527T gsThinShellAssemblerDWR<d, T, bending>::matrixNorm(
const gsMultiPatch<T> &primal,
const gsMultiPatch<T> &other)
const
3529 GISMO_ASSERT(m_goalFunction==GoalFunction::Modal,
"Only available for modal goal function");
3531 gsExprAssembler<T> exprAssembler = m_assemblerH->assembler();
3532 exprAssembler.cleanUp();
3533 GISMO_ENSURE(m_assemblerH->options().hasGroup(
"ExprAssembler"),
"The option list does not contain options with the label 'ExprAssembler'!");
3534 exprAssembler.setOptions(m_assemblerH->options().getGroup(
"ExprAssembler"));
3537 geometryMap Gori = exprAssembler.getMap(m_patches);
3540 exprAssembler.initSystem();
3541 exprAssembler.initVector(1);
3543 gsMaterialMatrixIntegrate<T,MaterialOutput::Density> rhof(m_assemblerH->materials(),&m_patches);
3544 auto rho = exprAssembler.getCoeff(rhof);
3546 auto usol = exprAssembler.getCoeff(primal);
3547 auto zsol = exprAssembler.getCoeff(other);
3549 gsExprEvaluator<T> ev(exprAssembler);
3550 return ev.integral(rho.val() * usol.tr() * zsol *
meas(Gori));
3553template <
short_t d,
class T,
bool bending>
3554T gsThinShellAssemblerDWR<d, T, bending>::matrixNorm(
const gsMultiPatch<T> &primal,
const gsMultiPatch<T> &other,
const gsMultiPatch<T> &deformed)
const
3556 GISMO_ASSERT(m_goalFunction==GoalFunction::Buckling,
"Only available for buckling goal function");
3557 gsExprAssembler<T> exprAssembler = m_assemblerH->assembler();
3558 exprAssembler.cleanUp();
3559 GISMO_ENSURE(m_assemblerH->options().hasGroup(
"ExprAssembler"),
"The option list does not contain options with the label 'ExprAssembler'!");
3560 exprAssembler.setOptions(m_assemblerH->options().getGroup(
"ExprAssembler"));
3562 gsMultiPatch<T> defpatches = deformed;
3565 geometryMap Gori = exprAssembler.getMap(m_patches);
3566 geometryMap Gdef = exprAssembler.getMap(defpatches);
3569 exprAssembler.initSystem();
3570 exprAssembler.initVector(1);
3572 gsMaterialMatrixIntegrate<T,MaterialOutput::MatrixA> mmAf_L(m_assemblerH->materials(),&m_patches);
3573 gsMaterialMatrixIntegrate<T,MaterialOutput::MatrixB> mmBf_L(m_assemblerH->materials(),&m_patches);
3574 gsMaterialMatrixIntegrate<T,MaterialOutput::MatrixC> mmCf_L(m_assemblerH->materials(),&m_patches);
3575 gsMaterialMatrixIntegrate<T,MaterialOutput::MatrixD> mmDf_L(m_assemblerH->materials(),&m_patches);
3576 auto mmA_L = exprAssembler.getCoeff(mmAf_L);
3577 auto mmB_L = exprAssembler.getCoeff(mmBf_L);
3578 auto mmC_L = exprAssembler.getCoeff(mmCf_L);
3579 auto mmD_L = exprAssembler.getCoeff(mmDf_L);
3581 gsMaterialMatrixIntegrate<T,MaterialOutput::MatrixA> mmAf_NL(m_assemblerH->materials(),&deformed);
3582 gsMaterialMatrixIntegrate<T,MaterialOutput::MatrixB> mmBf_NL(m_assemblerH->materials(),&deformed);
3583 gsMaterialMatrixIntegrate<T,MaterialOutput::MatrixC> mmCf_NL(m_assemblerH->materials(),&deformed);
3584 gsMaterialMatrixIntegrate<T,MaterialOutput::MatrixD> mmDf_NL(m_assemblerH->materials(),&deformed);
3585 auto mmA_NL = exprAssembler.getCoeff(mmAf_NL);
3586 auto mmB_NL = exprAssembler.getCoeff(mmBf_NL);
3587 auto mmC_NL = exprAssembler.getCoeff(mmCf_NL);
3588 auto mmD_NL = exprAssembler.getCoeff(mmDf_NL);
3590 gsMaterialMatrixIntegrate<T,MaterialOutput::VectorN> S0f(m_assemblerH->materials(),&defpatches);
3591 gsMaterialMatrixIntegrate<T,MaterialOutput::VectorM> S1f(m_assemblerH->materials(),&defpatches);
3592 auto S0 = exprAssembler.getCoeff(S0f);
3593 auto S1 = exprAssembler.getCoeff(S1f);
3595 gsFunctionExpr<T> mult2t(
"1",
"0",
"0",
"0",
"1",
"0",
"0",
"0",
"2",2);
3596 auto m2 = exprAssembler.getCoeff(mult2t);
3598 auto usol = exprAssembler.getCoeff(primal);
3599 auto zsol = exprAssembler.getCoeff(other);
3601 auto Em_der_L =
flat(
jac(Gori).tr() * (
jac(usol ) ) ) ;
3602 auto Ef_der_L = -( deriv2(usol , sn(Gori).normalized().tr() ) - deriv2(Gori, var1(usol , Gori) ) ) *
reshape(m2, 3, 3);
3604 auto Em_derd_L =
flat(
jac(Gori).tr() * (
jac(zsol ) ) ) ;
3605 auto Ef_derd_L = -( deriv2(zsol , sn(Gori).normalized().tr() ) - deriv2(Gori, var1(zsol , Gori) ) ) *
reshape(m2, 3, 3);
3608 auto N_der_L = Em_derd_L *
reshape(mmA_L,3,3) + Ef_derd_L *
reshape(mmB_L,3,3);
3609 auto M_der_L = Em_derd_L *
reshape(mmC_L,3,3) + Ef_derd_L *
reshape(mmD_L,3,3);
3611 auto N_NL = S0.tr();
3612 auto Em_der_NL =
flat(
jac(Gdef).tr() * (
jac(usol ) ) ) ;
3613 auto Ef_der_NL = -( deriv2(usol , sn(Gdef).normalized().tr() ) - deriv2(Gdef, var1(usol , Gdef) ) ) *
reshape(m2, 3, 3);
3615 auto Em_derd_NL =
flat(
jac(Gdef).tr() * (
jac(zsol ) ) ) ;
3616 auto Ef_derd_NL = -( deriv2(zsol , sn(Gdef).normalized().tr() ) - deriv2(Gdef, var1(zsol , Gdef) ) ) *
reshape(m2, 3, 3);
3618 auto Em_der2 =
flat(
jac(usol).tr() * (
jac(zsol ) ) ) * N_NL.tr();
3620 auto M_NL = S1.tr();
3622 ( ( deriv2(zsol ) ) * ( var1(usol ,Gdef) ).tr() ).tr() *
reshape(m2, 3, 3)
3623 + ( ( deriv2(usol ) ) * ( var1(zsol ,Gdef) ).tr() ).tr() *
reshape(m2, 3, 3)
3624 + ( deriv2(Gdef) * ( var2(usol ,zsol ,Gdef) ) ).tr() *
reshape(m2, 3, 3)
3627 auto N_der_NL = Em_derd_NL *
reshape(mmA_NL,3,3) + Ef_derd_NL *
reshape(mmB_NL,3,3);
3628 auto M_der_NL = Em_derd_NL *
reshape(mmC_NL,3,3) + Ef_derd_NL *
reshape(mmD_NL,3,3);
3630 auto K_L = ( N_der_L * Em_der_L.tr() + M_der_L * Ef_der_L.tr() );
3631 auto K_NL = ( N_der_NL * Em_der_NL.tr() + M_der_NL * Ef_der_NL.tr() + Em_der2 + Ef_der2 );
3633 auto Bprimal = K_NL - K_L ;
3635 auto expr = ( Bprimal ) *
meas(Gori);
3637 gsExprEvaluator<T> ev(exprAssembler);
3638 T integral = ev.integral(expr);
3642 auto foundation = exprAssembler.getCoeff(*m_foundFun, Gori);
3643 GISMO_ASSERT(m_foundFun->targetDim()==3,
"Foundation function has dimension "<<m_foundFun->targetDim()<<
", but expected 3");
3645 integral += ev.integral( zsol * foundation.asDiag() * (Gdef - Gori) *
meas(Gori) );
3649 auto pressure = exprAssembler.getCoeff(*m_pressFun, Gori);
3650 GISMO_ASSERT(m_pressFun->targetDim()==1,
"Pressure function has dimension "<<m_pressFun->targetDim()<<
", but expected 1");
3652 integral += ev.integral( pressure.val() * zsol * sn(Gdef).normalized() *
meas(Gori) );
3658template <
short_t d,
class T,
bool bending>
3659void gsThinShellAssemblerDWR<d, T, bending>::_applyLoadsToElWiseError(
const gsMultiPatch<T> &dualL,
const gsMultiPatch<T> &dualH, std::vector<T> & errors)
const
3662 for (
size_t i = 0; i<m_pLoads.numLoads(); ++i )
3664 if (m_pLoads[i].value.size()!=d)
3665 gsWarn<<
"Point load has wrong dimension "<<m_pLoads[i].value.size()<<
" instead of "<<d<<
"\n";
3667 gsMatrix<T> forcePoint;
3668 if ( m_pLoads[i].parametric )
3669 forcePoint = m_pLoads[i].point;
3671 m_patches.patch(m_pLoads[i].patch).invertPoints(m_pLoads[i].point,forcePoint);
3673 std::vector<index_t> elements;
3675 #pragma omp parallel
3677 std::vector<index_t> elements_private;
3679 const int tid = omp_get_thread_num();
3680 const int nt = omp_get_num_threads();
3685 for (
unsigned patchInd=0; patchInd < m_assemblerH->getBasis().nBases(); ++patchInd)
3688 typename gsBasis<T>::domainIter domIt =
3689 m_assemblerH->getBasis().piece(patchInd).makeDomainIterator();
3692 c = patch_cnt + tid;
3693 patch_cnt += domIt->numElements();
3694 for ( domIt->next(tid); domIt->good(); domIt->next(nt) )
3696 for (; domIt->good(); domIt->next() )
3699 bool test = !(((((forcePoint - domIt->lowerCorner()).array() >= 0) &&
3700 (domIt->upperCorner() - forcePoint).array() >= 0) ).array() == 0).any();
3702 elements_private.push_back(c);
3710 elements.insert(elements.end(), elements_private.begin(), elements_private.end());
3715 gsMatrix<T> Lres, Hres;
3716 dualL.patch(m_pLoads[i].patch).eval_into(forcePoint,Lres);
3717 dualH.patch(m_pLoads[i].patch).eval_into(forcePoint,Hres);
3718 gsMatrix<T> result = (Hres-Lres).transpose() * m_pLoads[i].value;
3720 GISMO_ASSERT(result.rows()==result.cols() && result.rows()==1,
"Result must be scalar");
3721 for (
size_t k=0; k!=elements.size(); k++)
3722 errors.at(elements.at(k)) += result(0,0)/elements.size();
3726template <
short_t d,
class T,
bool bending>
3727void gsThinShellAssemblerDWR<d, T, bending>::_applyLoadsToError(
const gsMultiPatch<T> &dualL,
const gsMultiPatch<T> &dualH, T & error)
const
3730 for (
size_t i = 0; i< m_pLoads.numLoads(); ++i )
3732 if (m_pLoads[i].value.size()!=d)
3733 gsWarn<<
"Point load has wrong dimension "<<m_pLoads[i].value.size()<<
" instead of "<<d<<
"\n";
3735 gsMatrix<T> forcePoint;
3736 if ( m_pLoads[i].parametric )
3737 forcePoint = m_pLoads[i].point;
3739 m_patches.patch(m_pLoads[i].patch).invertPoints(m_pLoads[i].point,forcePoint);
3742 gsMatrix<T> Lres, Hres;
3743 dualL.patch(m_pLoads[i].patch).eval_into(forcePoint,Lres);
3744 dualH.patch(m_pLoads[i].patch).eval_into(forcePoint,Hres);
3745 gsMatrix<T> result = (Hres-Lres).transpose() * m_pLoads[i].value;
3747 error += result(0,0);
memory::unique_ptr< gsMaterialMatrixBase > uPtr
Unique pointer for gsGeometry.
Definition gsMaterialMatrixBase.h:44
#define index_t
Definition gsConfig.h:32
Provides declaration of ConstantFunction class.
#define GISMO_ERROR(message)
Definition gsDebug.h:118
#define gsWarn
Definition gsDebug.h:50
#define GISMO_ENSURE(cond, message)
Definition gsDebug.h:102
#define GISMO_ASSERT(cond, message)
Definition gsDebug.h:89
Generic expressions evaluator.
Provides declaration of FunctionExpr class.
Provides a base class for material matrices.
Provides an evaluator for material matrices for thin shells.
Provides an evaluator for material matrices for thin shells.
Provides hyperelastic material matrices.
Provides DWR assembly routines for the Kirchhoff-Love shell.
EIGEN_STRONG_INLINE reshape_expr< E > const reshape(E const &u, index_t n, index_t m)
Reshape an expression.
Definition gsExpressions.h:1925
EIGEN_STRONG_INLINE tangent_expr< T > tv(const gsGeometryMap< T > &u)
The tangent boundary vector of a geometry map in 2D.
Definition gsExpressions.h:4513
EIGEN_STRONG_INLINE meas_expr< T > meas(const gsGeometryMap< T > &G)
The measure of a geometry map.
Definition gsExpressions.h:4555
EIGEN_STRONG_INLINE flat_expr< E > const flat(E const &u)
Make a matrix 2x2 expression "flat".
Definition gsExpressions.h:2031
EIGEN_STRONG_INLINE jac_expr< E > jac(const symbol_expr< E > &u)
The Jacobian matrix of a FE variable.
Definition gsExpressions.h:4528
The G+Smo namespace, containing all definitions for the library.
ThinShellAssemblerStatus
Definition gsThinShellAssembler.h:54