G+Smo  25.01.0
Geometry + Simulation Modules
 
Loading...
Searching...
No Matches
gsThinShellAssemblerDWR.hpp
Go to the documentation of this file.
1
16#pragma once
17
23
27
28namespace gismo
29{
30
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,
38 typename gsMaterialMatrixBase<T>::uPtr & materialmatrix
39 )
40:
41gsThinShellAssemblerDWR(patches,basisL,basisH,bconditions,surface_force,materialmatrix.get())
42{
43
44}
45
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
54 )
55 :
56 Base(patches,basisL,bconditions,surface_force,materialmatrix),
57 m_bcs(bconditions)
58{
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);
61
62 m_dL = gsVector<T>::Zero(m_assemblerL->numDofs());
63 m_dH = gsVector<T>::Zero(m_assemblerH->numDofs());
64 }
65
66template <short_t d, class T, bool bending>
67ThinShellAssemblerStatus gsThinShellAssemblerDWR<d, T, bending>::_assembleMass(gsThinShellAssemblerBase<T> * assembler, gsSparseMatrix<T> & result, bool lumped)
68{
69 ThinShellAssemblerStatus status = assembler->assembleMass(lumped);
70 result = assembler->matrix();
71 GISMO_ENSURE(status==ThinShellAssemblerStatus::Success,"Assembly failed");
72 return status;
73}
74
75// template <short_t d, class T, bool bending>
76// gsSparseMatrix<T> gsThinShellAssemblerDWR<d, T, bending>::_assembleMassLM(gsThinShellAssemblerBase<T> * assembler, bool lumped)
77// {
78// gsExprAssembler<T> assembler(1,1);
79// // Elements used for numerical integration
80
81// assembler.setIntegrationElements(m_assemblerH->getBasis());
82 // GISMO_ENSURE(m_assemblerL->options().hasGroup("ExprAssembler"),"The option list does not contain options with the label 'ExprAssembler'!");
83 // exprAssembler.setOptions(m_assemblerL->options().getGroup("ExprAssembler"));
84
85
86// // Initialize the geometry maps
87// geometryMap m_ori = assembler.getMap(m_patches); // this map is used for integrals
88
89// // Set the discretization space
90// space spaceL = assembler.getSpace(m_assemblerL->getBasis(), d, 0); // last argument is the space ID
91// space spaceH = assembler.getTestSpace(spaceL , m_assemblerH->getBasis());
92
93// this->_assembleDirichlet();
94
95// // Initialize stystem
96// assembler.initSystem();
97
98// gsMaterialMatrixIntegrate<T,MaterialOutput::Density> m_mm(m_materialMat,&m_patches);
99// auto mm0 = assembler.getCoeff(m_mm);
100
101// space m_space = assembler.trialSpace(0);
102
103// // assemble system
104// assembler.assemble(mm0.val()*spaceL*spaceH.tr()*meas(m_ori));
105// return assembler.matrix();
106
107 // m_assembler.cleanUp();
108 // m_assembler.setOptions(m_options);
109
110 // m_assembler.getMap(m_patches); // this map is used for integrals
111
112 // // Initialize stystem
113 // m_assembler.initSystem();
114
115 // gsMaterialMatrixIntegrate<T,MaterialOutput::Density> m_mm(m_materialMat,&m_patches);
116 // auto mm0 = m_assembler.getCoeff(m_mm);
117
118 // space m_space = m_assembler.trialSpace(0);
119 // geometryMap m_ori = m_assembler.exprData()->getMap();
120
121 // // assemble system
122 // if (!lumped)
123 // m_assembler.assemble(mm0.val()*m_space*m_space.tr()*meas(m_ori));
124 // else
125 // m_assembler.assemble(mm0.val()*(m_space.rowSum())*meas(m_ori));
126// }
127
128template <short_t d, class T, bool bending>
129ThinShellAssemblerStatus gsThinShellAssemblerDWR<d, T, bending>::assembleL()
130{
131 std::pair<gsSparseMatrix<T>,gsVector<T>> result;
132 ThinShellAssemblerStatus status = _assemble(m_assemblerL,result);
133 m_matrixL = result.first;
134 m_pL = result.second;
135 GISMO_ENSURE(status==ThinShellAssemblerStatus::Success,"Assembly failed");
136 return status;
137}
138
139template <short_t d, class T, bool bending>
140ThinShellAssemblerStatus gsThinShellAssemblerDWR<d, T, bending>::assembleH()
141{
142 std::pair<gsSparseMatrix<T>,gsVector<T>> result;
143 ThinShellAssemblerStatus status = _assemble(m_assemblerH,result);
144 m_matrixH = result.first;
145 m_pH = result.second;
146 return status;
147}
148
149template <short_t d, class T, bool bending>
150ThinShellAssemblerStatus gsThinShellAssemblerDWR<d, T, bending>::_assemble(gsThinShellAssemblerBase<T> * assembler, std::pair<gsSparseMatrix<T>,gsVector<T>> & result)
151{
152 ThinShellAssemblerStatus status = assembler->assemble();
153 result = std::make_pair(assembler->matrix(),assembler->rhs());
154 GISMO_ENSURE(status==ThinShellAssemblerStatus::Success,"Assembly failed");
155 return status;
156}
157
158template <short_t d, class T, bool bending>
159ThinShellAssemblerStatus gsThinShellAssemblerDWR<d, T, bending>::_assembleMatrix(gsThinShellAssemblerBase<T> * assembler, gsSparseMatrix<T> & result)
160{
161 ThinShellAssemblerStatus status = assembler->assemble();
162 result = assembler->matrix();
163 GISMO_ENSURE(status==ThinShellAssemblerStatus::Success,"Assembly failed");
164 return status;
165}
166
167template <short_t d, class T, bool bending>
168ThinShellAssemblerStatus gsThinShellAssemblerDWR<d, T, bending>::_assembleMatrix(gsThinShellAssemblerBase<T> * assembler, const gsMultiPatch<T> & deformed, gsSparseMatrix<T> & result)
169{
170 ThinShellAssemblerStatus status = assembler->assembleMatrix(deformed);
171 result = assembler->matrix();
172 GISMO_ENSURE(status==ThinShellAssemblerStatus::Success,"Assembly failed");
173 return status;
174}
175
176template <short_t d, class T, bool bending>
177ThinShellAssemblerStatus gsThinShellAssemblerDWR<d, T, bending>::_assemblePrimal(gsThinShellAssemblerBase<T> * assembler, const gsMultiPatch<T> & deformed, gsVector<T> & result)
178{
179 ThinShellAssemblerStatus status = assembler->assembleVector(deformed);
180 result = assembler->rhs();
181 GISMO_ENSURE(status==ThinShellAssemblerStatus::Success,"Assembly failed");
182 return status;
183}
184
185template <short_t d, class T, bool bending>
186ThinShellAssemblerStatus gsThinShellAssemblerDWR<d, T, bending>::_assemblePrimal(gsThinShellAssemblerBase<T> * assembler, gsVector<T> & result)
187{
188 ThinShellAssemblerStatus status = assembler->assemble();
189 GISMO_ENSURE(status==ThinShellAssemblerStatus::Success,"Assembly failed");
190 result = assembler->rhs();
191 return status;
192}
193
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)
196{
197 GISMO_ASSERT(m_component < d || m_component==9,"Component is out of bounds");
198
199 // For the stretches
200 // ! Only works with Z=0 for now, since principal stresses and directions are implemented for Z=0, since principal stresses and directions are implemented for Z=0
201 gsMatrix<T> Z(1,1);
202 Z.setZero();
204
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"));
209
210 // Geometries
211 geometryMap Gori = exprAssembler.getMap(m_patches); // this map is used for integrals
212 geometryMap Gdef = exprAssembler.getMap(deformed);
213
214 // Initialize vector
215 exprAssembler.initSystem();
216 exprAssembler.initVector(1);
217
218 // Space
219 space space = exprAssembler.trialSpace(0);
220 // Homogenize Dirichlet
221 space.setup(m_bcs, dirichlet::homogeneous, 0);
222
223 // Solution
224 auto usol = exprAssembler.getCoeff(primal);
225
226 // Transformation for stretches
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);
231
232 // Material tensors at Z
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);
237
238 // Material tensors integrated
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);
247
248 // Stress tensors
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);
253
254 // Principal stress tensors
255 gsMaterialMatrixEval<T,MaterialOutput::PStress> P0f(assembler->materials(),&deformed,Z);
256 auto P0 = exprAssembler.getCoeff(P0f);
257
258 // Force and moment tensors
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);
263
264 // Helper matrix for flexural components
265 gsFunctionExpr<T> mult2t("1","0","0","0","1","0","0","0","2",2);
266 auto m2 = exprAssembler.getCoeff(mult2t);
267
268 // Deformation gradient and its first variation
269 // To compensate for the flat, since flat does [E11,E22,2*E12]
270 gsFunctionExpr<T> mult12t("1","0","0","0","1","0","0","0","0.5",2);
271 auto m12 = exprAssembler.getCoeff(mult12t);
272
273 auto Cm = flat( jac(Gdef).tr() * jac(Gdef) ) * reshape(m12,3,3);
274 auto Cm_der = 2* flat( jac(Gdef).tr() * jac(space) ) * reshape(m12,3,3);
275
276 // Principal stretch and its first variation
277 auto lambda = Cm * reshape(Tstretch,3,3).tr();
278 auto lambda_der = Cm_der * reshape(Tstretch,3,3).tr();
279
280 // Membrane strain and its first variation
281 auto Em = 0.5 * ( flat(jac(Gdef).tr()*jac(Gdef)) - flat(jac(Gori).tr()* jac(Gori)) ) ;
282 auto Em_der = flat( jac(Gdef).tr() * jac(space) ) ;
283
284 // Principal membrane strain and its first variation
285 auto Emp = (Em * reshape(m12,3,3)) * reshape(Tstretch,3,3).tr();
286 auto Emp_der= (Em_der * reshape(m12,3,3)) * reshape(Tstretch,3,3).tr();
287
288 // Flexural strain and its first variation
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);
291
292 // Membrane stress (its first variation)
293 auto Sm_der = Em_der * reshape(mmA,3,3);
294
295 // Principal membrane stress (its first variation)
296 auto Smp_der = Sm_der * reshape(Tpstress,3,3).tr();
297
298 // Flexural stress (its first variation)
299 auto Sf_der = Ef_der * reshape(mmD,3,3);
300
301 // Membrane force (its first variation)
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);
304
305 if (m_goalFunction == GoalFunction::Displacement)
306 {
307 if (m_component==9)
308 {
309 auto expr = 2 * space * usol * meas(Gori);
310 try
311 {
312 exprAssembler.assemble(expr);
313 result = exprAssembler.rhs();
314 return ThinShellAssemblerStatus::Success;
315 }
316 catch (...)
317 {
318 exprAssembler.cleanUp();
319 return ThinShellAssemblerStatus::AssemblyError;
320 }
321 }
322 else
323 {
324 auto expr = space * gismo::expr::uv(m_component,3) * meas(Gori);
325 try
326 {
327 exprAssembler.assemble(expr);
328 result = exprAssembler.rhs();
329 return ThinShellAssemblerStatus::Success;
330 }
331 catch (...)
332 {
333 exprAssembler.cleanUp();
334 return ThinShellAssemblerStatus::AssemblyError;
335 }
336 }
337 }
338 else if (m_goalFunction == GoalFunction::Stretch)
339 {
340 if (m_component==9)
341 {
342 auto expr = 2 * lambda_der * lambda.tr() * meas(Gori);
343 try
344 {
345 exprAssembler.assemble(expr);
346 result = exprAssembler.rhs();
347 return ThinShellAssemblerStatus::Success;
348 }
349 catch (...)
350 {
351 exprAssembler.cleanUp();
352 return ThinShellAssemblerStatus::AssemblyError;
353 }
354 }
355 else
356 {
357 auto expr = lambda_der * gismo::expr::uv(m_component,3) * meas(Gori);
358 try
359 {
360 exprAssembler.assemble(expr);
361 result = exprAssembler.rhs();
362 return ThinShellAssemblerStatus::Success;
363 }
364 catch (...)
365 {
366 exprAssembler.cleanUp();
367 return ThinShellAssemblerStatus::AssemblyError;
368 }
369 }
370 }
371 else if (m_goalFunction == GoalFunction::PStrain)
372 {
373 if (m_component==9)
374 {
375 auto expr = 2 * Emp_der * Emp.tr() * meas(Gori);
376 try
377 {
378 exprAssembler.assemble(expr);
379 result = exprAssembler.rhs();
380 return ThinShellAssemblerStatus::Success;
381 }
382 catch (...)
383 {
384 exprAssembler.cleanUp();
385 return ThinShellAssemblerStatus::AssemblyError;
386 }
387 }
388 else
389 {
390 auto expr = Emp_der * gismo::expr::uv(m_component,3) * meas(Gori);
391 try
392 {
393 exprAssembler.assemble(expr);
394 result = exprAssembler.rhs();
395 return ThinShellAssemblerStatus::Success;
396 }
397 catch (...)
398 {
399 exprAssembler.cleanUp();
400 return ThinShellAssemblerStatus::AssemblyError;
401 }
402 }
403 }
404 else if (m_goalFunction == GoalFunction::PStress)
405 {
406 // to convert P0 from a vector of length 2 to 3, this matrix is [[1,0],[0,1],[0,0]]
407 gsMatrix<T> convMat(3,2);
408 convMat.setZero();
409 convMat(0,0) = convMat(1,1) = 1;
410 gsConstantFunction<T> convFun(convMat.reshape(6,1),2);
411 auto conv = exprAssembler.getCoeff(convFun);
412 if (m_component==9)
413 {
414 auto expr = 2 * Smp_der * reshape(conv,3,2) * P0 * meas(Gori);
415 try
416 {
417 exprAssembler.assemble(expr);
418 result = exprAssembler.rhs();
419 return ThinShellAssemblerStatus::Success;
420 }
421 catch (...)
422 {
423 exprAssembler.cleanUp();
424 return ThinShellAssemblerStatus::AssemblyError;
425 }
426 }
427 else
428 {
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);
431 try
432 {
433 exprAssembler.assemble(expr);
434 result = exprAssembler.rhs();
435 return ThinShellAssemblerStatus::Success;
436 }
437 catch (...)
438 {
439 exprAssembler.cleanUp();
440 return ThinShellAssemblerStatus::AssemblyError;
441 }
442 }
443 }
444 else if (m_goalFunction == GoalFunction::MembraneStrain)
445 {
446 if (m_component==9)
447 {
448 auto expr = 2 * Em_der * Em.tr() * meas(Gori);
449 try
450 {
451 exprAssembler.assemble(expr);
452 result = exprAssembler.rhs();
453 return ThinShellAssemblerStatus::Success;
454 }
455 catch (...)
456 {
457 exprAssembler.cleanUp();
458 return ThinShellAssemblerStatus::AssemblyError;
459 }
460 }
461 else
462 {
463 auto expr = Em_der * gismo::expr::uv(m_component,3) * meas(Gori);
464 try
465 {
466 exprAssembler.assemble(expr);
467 result = exprAssembler.rhs();
468 return ThinShellAssemblerStatus::Success;
469 }
470 catch (...)
471 {
472 exprAssembler.cleanUp();
473 return ThinShellAssemblerStatus::AssemblyError;
474 }
475 }
476 }
477 else if (m_goalFunction == GoalFunction::MembraneStress)
478 {
479 if (m_component==9)
480 {
481 auto expr = 2 * Sm_der * S0 * meas(Gori);
482 try
483 {
484 exprAssembler.assemble(expr);
485 result = exprAssembler.rhs();
486 return ThinShellAssemblerStatus::Success;
487 }
488 catch (...)
489 {
490 exprAssembler.cleanUp();
491 return ThinShellAssemblerStatus::AssemblyError;
492 }
493 }
494 else
495 {
496 auto expr = Sm_der * gismo::expr::uv(m_component,3) * meas(Gori);
497 try
498 {
499 exprAssembler.assemble(expr);
500 result = exprAssembler.rhs();
501 return ThinShellAssemblerStatus::Success;
502 }
503 catch (...)
504 {
505 exprAssembler.cleanUp();
506 return ThinShellAssemblerStatus::AssemblyError;
507 }
508 }
509 }
510 else if (m_goalFunction == GoalFunction::MembraneForce)
511 {
512 if (m_component==9)
513 {
514 auto expr = 2 * N_der * N * meas(Gori);
515 try
516 {
517 exprAssembler.assemble(expr);
518 result = exprAssembler.rhs();
519 return ThinShellAssemblerStatus::Success;
520 }
521 catch (...)
522 {
523 exprAssembler.cleanUp();
524 return ThinShellAssemblerStatus::AssemblyError;
525 }
526 }
527 else
528 {
529 auto expr = N_der * gismo::expr::uv(m_component,3) * meas(Gori);
530 try
531 {
532 exprAssembler.assemble(expr);
533 result = exprAssembler.rhs();
534 return ThinShellAssemblerStatus::Success;
535 }
536 catch (...)
537 {
538 exprAssembler.cleanUp();
539 return ThinShellAssemblerStatus::AssemblyError;
540 }
541 }
542 }
543 else if (m_goalFunction == GoalFunction::FlexuralStrain)
544 {
545 if (m_component==9)
546 {
547 auto expr = 2 * Ef_der * Ef.tr() * meas(Gori);
548 try
549 {
550 exprAssembler.assemble(expr);
551 result = exprAssembler.rhs();
552 return ThinShellAssemblerStatus::Success;
553 }
554 catch (...)
555 {
556 exprAssembler.cleanUp();
557 return ThinShellAssemblerStatus::AssemblyError;
558 }
559 }
560 else
561 {
562 auto expr = Ef_der * gismo::expr::uv(m_component,3) * meas(Gori);
563 try
564 {
565 exprAssembler.assemble(expr);
566 result = exprAssembler.rhs();
567 return ThinShellAssemblerStatus::Success;
568 }
569 catch (...)
570 {
571 exprAssembler.cleanUp();
572 return ThinShellAssemblerStatus::AssemblyError;
573 }
574 }
575 }
576 else if (m_goalFunction == GoalFunction::FlexuralStress)
577 {
578 if (m_component==9)
579 {
580 auto expr = 2 * Sf_der * S1 * meas(Gori);
581 try
582 {
583 exprAssembler.assemble(expr);
584 result = exprAssembler.rhs();
585 return ThinShellAssemblerStatus::Success;
586 }
587 catch (...)
588 {
589 exprAssembler.cleanUp();
590 return ThinShellAssemblerStatus::AssemblyError;
591 }
592 }
593 else
594 {
595 auto expr = Sf_der * gismo::expr::uv(m_component,3) * meas(Gori);
596 try
597 {
598 exprAssembler.assemble(expr);
599 result = exprAssembler.rhs();
600 return ThinShellAssemblerStatus::Success;
601 }
602 catch (...)
603 {
604 exprAssembler.cleanUp();
605 return ThinShellAssemblerStatus::AssemblyError;
606 }
607 }
608 }
609 else if (m_goalFunction == GoalFunction::FlexuralMoment)
610 {
611 if (m_component==9)
612 {
613 auto expr = 2 * M_der * M * meas(Gori);
614 try
615 {
616 exprAssembler.assemble(expr);
617 result = exprAssembler.rhs();
618 return ThinShellAssemblerStatus::Success;
619 }
620 catch (...)
621 {
622 exprAssembler.cleanUp();
623 return ThinShellAssemblerStatus::AssemblyError;
624 }
625 }
626 else
627 {
628 auto expr = M_der * gismo::expr::uv(m_component,3) * meas(Gori);
629 try
630 {
631 exprAssembler.assemble(expr);
632 result = exprAssembler.rhs();
633 return ThinShellAssemblerStatus::Success;
634 }
635 catch (...)
636 {
637 exprAssembler.cleanUp();
638 return ThinShellAssemblerStatus::AssemblyError;
639 }
640 }
641 }
642 else
643 GISMO_ERROR("Goal function not known");
644}
645
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)
648{
649 GISMO_ASSERT(m_component < d || m_component==9,"Component is out of bounds");
650
651 // For the stretches
652 // ! Only works with Z=0 for now, since principal stresses and directions are implemented for Z=0, since principal stresses and directions are implemented for Z=0
653 gsMatrix<T> Z(1,1);
654 Z.setZero();
656
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"));
661
662 // Geometries
663 geometryMap Gori = exprAssembler.getMap(m_patches); // this map is used for integrals
664 geometryMap Gdef = exprAssembler.getMap(deformed);
665
666 // Initialize vector
667 exprAssembler.initSystem();
668 exprAssembler.initVector(1);
669 if (bnds.size()==0)
670 {
671 result = exprAssembler.rhs();
672 return ThinShellAssemblerStatus::Success;
673 }
674
675 // Space
676 space space = exprAssembler.trialSpace(0);
677 // Homogenize Dirichlet
678 space.setup(m_bcs, dirichlet::homogeneous, 0);
679
680 // Solution
681 auto usol = exprAssembler.getCoeff(primal);
682
683 // Transformation for stretches
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);
688
689 // Material tensors at Z
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);
694
695 // Material tensors integrated
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);
704
705 // Stress tensors
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);
710
711 // Principal stress tensors
712 gsMaterialMatrixEval<T,MaterialOutput::PStress> P0f(assembler->materials(),&deformed,Z);
713 auto P0 = exprAssembler.getCoeff(P0f);
714
715 // Force and moment tensors
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);
720
721 // Helper matrix for flexural components
722 gsFunctionExpr<T> mult2t("1","0","0","0","1","0","0","0","2",2);
723 auto m2 = exprAssembler.getCoeff(mult2t);
724
725 // Deformation gradient and its first variation
726 // To compensate for the flat, since flat does [E11,E22,2*E12]
727 gsFunctionExpr<T> mult12t("1","0","0","0","1","0","0","0","0.5",2);
728 auto m12 = exprAssembler.getCoeff(mult12t);
729
730 auto Cm = flat( jac(Gdef).tr() * jac(Gdef) ) * reshape(m12,3,3);
731 auto Cm_der = 2* flat( jac(Gdef).tr() * jac(space) ) * reshape(m12,3,3);
732
733 // Principal stretch and its first variation
734 auto lambda = Cm * reshape(Tstretch,3,3).tr();
735 auto lambda_der = Cm_der * reshape(Tstretch,3,3).tr();
736
737 // Membrane strain and its first variation
738 auto Em = 0.5 * ( flat(jac(Gdef).tr()*jac(Gdef)) - flat(jac(Gori).tr()* jac(Gori)) ) ;
739 auto Em_der = flat( jac(Gdef).tr() * jac(space) ) ;
740
741 // Principal membrane strain and its first variation
742 auto Emp = (Em * reshape(m12,3,3)) * reshape(Tstretch,3,3).tr();
743 auto Emp_der= (Em_der * reshape(m12,3,3)) * reshape(Tstretch,3,3).tr();
744
745 // Flexural strain and its first variation
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);
748
749 // Membrane stress (its first variation)
750 auto Sm_der = Em_der * reshape(mmA,3,3);
751
752 // Principal membrane stress (its first variation)
753 auto Smp_der = Sm_der * reshape(Tpstress,3,3).tr();
754
755 // Flexural stress (its first variation)
756 auto Sf_der = Ef_der * reshape(mmD,3,3);
757
758 // Membrane force (its first variation)
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);
761
762 if (m_goalFunction == GoalFunction::Displacement)
763 {
764 if (m_component==9)
765 {
766 auto expr = 2 * space * usol * meas(Gori);
767 try
768 {
769 exprAssembler.assembleBdr(bnds,expr);
770 result = exprAssembler.rhs();
771 return ThinShellAssemblerStatus::Success;
772 }
773 catch (...)
774 {
775 exprAssembler.cleanUp();
776 return ThinShellAssemblerStatus::AssemblyError;
777 }
778 }
779 else
780 {
781 auto expr = space * gismo::expr::uv(m_component,3) * meas(Gori);
782 try
783 {
784 exprAssembler.assembleBdr(bnds,expr);
785 result = exprAssembler.rhs();
786 return ThinShellAssemblerStatus::Success;
787 }
788 catch (...)
789 {
790 exprAssembler.cleanUp();
791 return ThinShellAssemblerStatus::AssemblyError;
792 }
793 }
794 }
795 else if (m_goalFunction == GoalFunction::Stretch)
796 {
797 if (m_component==9)
798 {
799 auto expr = 2 * lambda_der * lambda.tr() * meas(Gori);
800 try
801 {
802 exprAssembler.assembleBdr(bnds,expr);
803 result = exprAssembler.rhs();
804 return ThinShellAssemblerStatus::Success;
805 }
806 catch (...)
807 {
808 exprAssembler.cleanUp();
809 return ThinShellAssemblerStatus::AssemblyError;
810 }
811 }
812 else
813 {
814 auto expr = lambda_der * gismo::expr::uv(m_component,3) * meas(Gori);
815 try
816 {
817 exprAssembler.assembleBdr(bnds,expr);
818 result = exprAssembler.rhs();
819 return ThinShellAssemblerStatus::Success;
820 }
821 catch (...)
822 {
823 exprAssembler.cleanUp();
824 return ThinShellAssemblerStatus::AssemblyError;
825 }
826 }
827 }
828 else if (m_goalFunction == GoalFunction::PStrain)
829 {
830 if (m_component==9)
831 {
832 auto expr = 2 * Emp_der * Emp.tr() * meas(Gori);
833 try
834 {
835 exprAssembler.assembleBdr(bnds,expr);
836 result = exprAssembler.rhs();
837 return ThinShellAssemblerStatus::Success;
838 }
839 catch (...)
840 {
841 exprAssembler.cleanUp();
842 return ThinShellAssemblerStatus::AssemblyError;
843 }
844 }
845 else
846 {
847 auto expr = Emp_der * gismo::expr::uv(m_component,3) * meas(Gori);
848 try
849 {
850 exprAssembler.assembleBdr(bnds,expr);
851 result = exprAssembler.rhs();
852 return ThinShellAssemblerStatus::Success;
853 }
854 catch (...)
855 {
856 exprAssembler.cleanUp();
857 return ThinShellAssemblerStatus::AssemblyError;
858 }
859 }
860 }
861 else if (m_goalFunction == GoalFunction::PStress)
862 {
863 // to convert P0 from a vector of length 2 to 3, this matrix is [[1,0],[0,1],[0,0]]
864 gsMatrix<T> convMat(3,2);
865 convMat.setZero();
866 convMat(0,0) = convMat(1,1) = 1;
867 gsConstantFunction<T> convFun(convMat.reshape(6,1),2);
868 auto conv = exprAssembler.getCoeff(convFun);
869 if (m_component==9)
870 {
871 auto expr = 2 * Smp_der * reshape(conv,3,2) * P0 * meas(Gori);
872 try
873 {
874 exprAssembler.assembleBdr(bnds,expr);
875 result = exprAssembler.rhs();
876 return ThinShellAssemblerStatus::Success;
877 }
878 catch (...)
879 {
880 exprAssembler.cleanUp();
881 return ThinShellAssemblerStatus::AssemblyError;
882 }
883 }
884 else
885 {
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);
888 try
889 {
890 exprAssembler.assembleBdr(bnds,expr);
891 result = exprAssembler.rhs();
892 return ThinShellAssemblerStatus::Success;
893 }
894 catch (...)
895 {
896 exprAssembler.cleanUp();
897 return ThinShellAssemblerStatus::AssemblyError;
898 }
899 }
900 }
901 else if (m_goalFunction == GoalFunction::MembraneStrain)
902 {
903 if (m_component==9)
904 {
905 auto expr = 2 * Em_der * Em.tr() * meas(Gori);
906 try
907 {
908 exprAssembler.assembleBdr(bnds,expr);
909 result = exprAssembler.rhs();
910 return ThinShellAssemblerStatus::Success;
911 }
912 catch (...)
913 {
914 exprAssembler.cleanUp();
915 return ThinShellAssemblerStatus::AssemblyError;
916 }
917 }
918 else
919 {
920 auto expr = Em_der * gismo::expr::uv(m_component,3) * meas(Gori);
921 try
922 {
923 exprAssembler.assembleBdr(bnds,expr);
924 result = exprAssembler.rhs();
925 return ThinShellAssemblerStatus::Success;
926 }
927 catch (...)
928 {
929 exprAssembler.cleanUp();
930 return ThinShellAssemblerStatus::AssemblyError;
931 }
932 }
933 }
934 else if (m_goalFunction == GoalFunction::MembraneStress)
935 {
936 if (m_component==9)
937 {
938 auto expr = 2 * Sm_der * S0 * meas(Gori);
939 try
940 {
941 exprAssembler.assembleBdr(bnds,expr);
942 result = exprAssembler.rhs();
943 return ThinShellAssemblerStatus::Success;
944 }
945 catch (...)
946 {
947 exprAssembler.cleanUp();
948 return ThinShellAssemblerStatus::AssemblyError;
949 }
950 }
951 else
952 {
953 auto expr = Sm_der * gismo::expr::uv(m_component,3) * meas(Gori);
954 try
955 {
956 exprAssembler.assembleBdr(bnds,expr);
957 result = exprAssembler.rhs();
958 return ThinShellAssemblerStatus::Success;
959 }
960 catch (...)
961 {
962 exprAssembler.cleanUp();
963 return ThinShellAssemblerStatus::AssemblyError;
964 }
965 }
966 }
967 else if (m_goalFunction == GoalFunction::MembraneForce)
968 {
969 if (m_component==9)
970 {
971 auto expr = 2 * N_der * N * meas(Gori);
972 try
973 {
974 exprAssembler.assembleBdr(bnds,expr);
975 result = exprAssembler.rhs();
976 return ThinShellAssemblerStatus::Success;
977 }
978 catch (...)
979 {
980 exprAssembler.cleanUp();
981 return ThinShellAssemblerStatus::AssemblyError;
982 }
983 }
984 else
985 {
986 auto expr = N.tr() * gismo::expr::uv(m_component,3) * meas(Gori);
987 try
988 {
989 exprAssembler.assembleBdr(bnds,expr);
990 result = exprAssembler.rhs();
991 return ThinShellAssemblerStatus::Success;
992 }
993 catch (...)
994 {
995 exprAssembler.cleanUp();
996 return ThinShellAssemblerStatus::AssemblyError;
997 }
998 }
999 }
1000 else if (m_goalFunction == GoalFunction::FlexuralStrain)
1001 {
1002 if (m_component==9)
1003 {
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);
1007 try
1008 {
1009 exprAssembler.assembleBdr(bnds,expr);
1010 result = exprAssembler.rhs();
1011 return ThinShellAssemblerStatus::Success;
1012 }
1013 catch (...)
1014 {
1015 exprAssembler.cleanUp();
1016 return ThinShellAssemblerStatus::AssemblyError;
1017 }
1018 }
1019 else
1020 {
1021 auto expr = Ef_der * gismo::expr::uv(m_component,3) * meas(Gori);
1022 try
1023 {
1024 exprAssembler.assembleBdr(bnds,expr);
1025 result = exprAssembler.rhs();
1026 return ThinShellAssemblerStatus::Success;
1027 }
1028 catch (...)
1029 {
1030 exprAssembler.cleanUp();
1031 return ThinShellAssemblerStatus::AssemblyError;
1032 }
1033 }
1034 }
1035 else if (m_goalFunction == GoalFunction::FlexuralStress)
1036 {
1037 if (m_component==9)
1038 {
1039 auto expr = 2 * Sf_der * S1 * meas(Gori);
1040 try
1041 {
1042 exprAssembler.assembleBdr(bnds,expr);
1043 result = exprAssembler.rhs();
1044 return ThinShellAssemblerStatus::Success;
1045 }
1046 catch (...)
1047 {
1048 exprAssembler.cleanUp();
1049 return ThinShellAssemblerStatus::AssemblyError;
1050 }
1051 }
1052 else
1053 {
1054 auto expr = Sf_der * gismo::expr::uv(m_component,3) * meas(Gori);
1055 try
1056 {
1057 exprAssembler.assembleBdr(bnds,expr);
1058 result = exprAssembler.rhs();
1059 return ThinShellAssemblerStatus::Success;
1060 }
1061 catch (...)
1062 {
1063 exprAssembler.cleanUp();
1064 return ThinShellAssemblerStatus::AssemblyError;
1065 }
1066 }
1067 }
1068 else if (m_goalFunction == GoalFunction::FlexuralMoment)
1069 {
1070 if (m_component==9)
1071 {
1072 auto expr = 2 * M_der * M * meas(Gori);
1073 try
1074 {
1075 exprAssembler.assembleBdr(bnds,expr);
1076 result = exprAssembler.rhs();
1077 return ThinShellAssemblerStatus::Success;
1078 }
1079 catch (...)
1080 {
1081 exprAssembler.cleanUp();
1082 return ThinShellAssemblerStatus::AssemblyError;
1083 }
1084 }
1085 else
1086 {
1087 auto expr = M_der * gismo::expr::uv(m_component,3) * meas(Gori);
1088 try
1089 {
1090 exprAssembler.assembleBdr(bnds,expr);
1091 result = exprAssembler.rhs();
1092 return ThinShellAssemblerStatus::Success;
1093 }
1094 catch (...)
1095 {
1096 exprAssembler.cleanUp();
1097 return ThinShellAssemblerStatus::AssemblyError;
1098 }
1099 }
1100 }
1101 else
1102 GISMO_ERROR("Goal function not known");
1103}
1104
1105
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)
1108{
1109 /* SINGLE PATCH IMPLEMENTATION */
1110 index_t pIndex = 0;
1111 gsMatrix<T> tmp;
1112 gsMatrix<index_t> actives, globalActives;
1113
1114 GISMO_ASSERT(m_component < d || m_component==9,"Component is out of bounds");
1115
1116 // For the stretches
1117 // ! Only works with Z=0 for now, since principal stresses and directions are implemented for Z=0
1118 gsMatrix<T> Z(1,1);
1119 Z.setZero();
1121
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"));
1126
1127 // Geometries
1128 geometryMap Gori = exprAssembler.getMap(m_patches); // this map is used for integrals
1129 geometryMap Gdef = exprAssembler.getMap(deformed);
1130
1131 // Initialize vector
1132 exprAssembler.initSystem();
1133 exprAssembler.initVector(1);
1134 if (points.cols()==0)
1135 {
1136 result = exprAssembler.rhs();
1137 return ThinShellAssemblerStatus::Success;
1138 }
1139
1140 // Space
1141 space space = exprAssembler.trialSpace(0);
1142 // Homogenize Dirichlet
1143 space.setup(m_bcs, dirichlet::homogeneous, 0);
1144
1145 // Solution
1146 auto usol = exprAssembler.getCoeff(primal);
1147
1148 // Transformation for stretches
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);
1153
1154 // Material tensors at Z
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);
1159
1160 // Material tensors integrated
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);
1169
1170 // Stress tensors
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);
1175
1176 // Principal stress tensors
1177 gsMaterialMatrixEval<T,MaterialOutput::PStress> P0f(assembler->materials(),&deformed,Z);
1178 auto P0 = exprAssembler.getCoeff(P0f);
1179
1180 // Force and moment tensors
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);
1185
1186 // Helper matrix for flexural components
1187 gsFunctionExpr<T> mult2t("1","0","0","0","1","0","0","0","2",2);
1188 auto m2 = exprAssembler.getCoeff(mult2t);
1189
1190 // Deformation gradient and its first variation
1191 // To compensate for the flat, since flat does [E11,E22,2*E12]
1192 gsFunctionExpr<T> mult12t("1","0","0","0","1","0","0","0","0.5",2);
1193 auto m12 = exprAssembler.getCoeff(mult12t);
1194
1195 auto Cm = flat( jac(Gdef).tr() * jac(Gdef) ) * reshape(m12,3,3);
1196 auto Cm_der = 2* flat( jac(Gdef).tr() * jac(space) ) * reshape(m12,3,3);
1197
1198 // Principal stretch and its first variation
1199 auto lambda = Cm * reshape(Tstretch,3,3).tr();
1200 auto lambda_der = Cm_der * reshape(Tstretch,3,3).tr();
1201
1202 // Membrane strain and its first variation
1203 auto Em = 0.5 * ( flat(jac(Gdef).tr()*jac(Gdef)) - flat(jac(Gori).tr()* jac(Gori)) ) ;
1204 auto Em_der = flat( jac(Gdef).tr() * jac(space) ) ;
1205
1206 // Principal membrane strain and its first variation
1207 auto Emp = (Em * reshape(m12,3,3)) * reshape(Tstretch,3,3).tr();
1208 auto Emp_der= (Em_der * reshape(m12,3,3)) * reshape(Tstretch,3,3).tr();
1209
1210 // Flexural strain and its first variation
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);
1213
1214 // Membrane stress (its first variation)
1215 auto Sm_der = Em_der * reshape(mmA,3,3);
1216
1217 // Principal membrane stress (its first variation)
1218 auto Smp_der = Sm_der * reshape(Tpstress,3,3).tr();
1219
1220 // Flexural stress (its first variation)
1221 auto Sf_der = Ef_der * reshape(mmD,3,3);
1222
1223 // Membrane force (its first variation)
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);
1226
1227
1228 gsExprEvaluator<T> ev(exprAssembler);
1229 result.resize(exprAssembler.numDofs());
1230 result.setZero();
1231 if (m_goalFunction == GoalFunction::Displacement)
1232 {
1233 if (m_component==9)
1234 {
1235 auto expr = 2 * space * usol * meas(Gori);
1236 for (index_t k = 0; k!=points.cols(); k++)
1237 {
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)
1241 {
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);
1246 }
1247 }
1248 }
1249 else
1250 {
1251 auto expr = space * gismo::expr::uv(m_component,3) * meas(Gori);
1252 for (index_t k = 0; k!=points.cols(); k++)
1253 {
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)
1257 {
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);
1262 }
1263 }
1264 }
1265 }
1266 else if (m_goalFunction == GoalFunction::Stretch)
1267 {
1268 if (m_component==9)
1269 {
1270 auto expr = 2* lambda_der * lambda.tr() * meas(Gori);//<<<--------NOTE: Square missing?
1271 for (index_t k = 0; k!=points.cols(); k++)
1272 {
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)
1276 {
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);
1281 }
1282 }
1283 }
1284 else
1285 {
1286 auto expr = lambda_der * gismo::expr::uv(m_component,3) * meas(Gori);
1287 for (index_t k = 0; k!=points.cols(); k++)
1288 {
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)
1292 {
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);
1297 }
1298 }
1299 }
1300 }
1301 else if (m_goalFunction == GoalFunction::PStrain)
1302 {
1303 if (m_component==9)
1304 {
1305 auto expr = 2 * Emp_der * Emp.tr() * meas(Gori);
1306 for (index_t k = 0; k!=points.cols(); k++)
1307 {
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)
1311 {
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);
1316 }
1317 }
1318 }
1319 else
1320 {
1321 auto expr = Emp_der * gismo::expr::uv(m_component,3) * meas(Gori);
1322 for (index_t k = 0; k!=points.cols(); k++)
1323 {
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)
1327 {
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);
1332 }
1333 }
1334 }
1335 }
1336 else if (m_goalFunction == GoalFunction::PStress)
1337 {
1338 if (m_component==9)
1339 {
1340 auto expr = 2 * Smp_der * P0 * meas(Gori);
1341 for (index_t k = 0; k!=points.cols(); k++)
1342 {
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)
1346 {
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);
1351 }
1352 }
1353 }
1354 else
1355 {
1356 auto expr = Smp_der * gismo::expr::uv(m_component,3) * meas(Gori);
1357 for (index_t k = 0; k!=points.cols(); k++)
1358 {
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)
1362 {
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);
1367 }
1368 }
1369 }
1370 }
1371 else if (m_goalFunction == GoalFunction::MembraneStrain)
1372 {
1373 if (m_component==9)
1374 {
1375 auto expr = 2 * Em_der * Em.tr() * meas(Gori);
1376 for (index_t k = 0; k!=points.cols(); k++)
1377 {
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)
1381 {
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);
1386 }
1387 }
1388 }
1389 else
1390 {
1391 auto expr = Em_der * gismo::expr::uv(m_component,3) * meas(Gori);
1392 for (index_t k = 0; k!=points.cols(); k++)
1393 {
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)
1397 {
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);
1402 }
1403 }
1404 }
1405 }
1406 else if (m_goalFunction == GoalFunction::MembraneStress)
1407 {
1408 if (m_component==9)
1409 {
1410 auto expr = 2 * Sm_der * S0 * meas(Gori);
1411 for (index_t k = 0; k!=points.cols(); k++)
1412 {
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)
1416 {
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);
1421 }
1422 }
1423 }
1424 else
1425 {
1426 auto expr = Sm_der * gismo::expr::uv(m_component,3) * meas(Gori);
1427 for (index_t k = 0; k!=points.cols(); k++)
1428 {
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)
1432 {
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);
1437 }
1438 }
1439 }
1440 }
1441 else if (m_goalFunction == GoalFunction::MembraneForce)
1442 {
1443 if (m_component==9)
1444 {
1445 auto expr = 2 * N_der * N * meas(Gori);
1446 for (index_t k = 0; k!=points.cols(); k++)
1447 {
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)
1451 {
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);
1456 }
1457 }
1458 }
1459 else
1460 {
1461 // remove N_der from this scipe
1462 auto expr = N.tr() * gismo::expr::uv(m_component,3) * meas(Gori);
1463 for (index_t k = 0; k!=points.cols(); k++)
1464 {
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)
1468 {
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);
1473 }
1474 }
1475 }
1476 }
1477 else if (m_goalFunction == GoalFunction::FlexuralStrain)
1478 {
1479 if (m_component==9)
1480 {
1481 auto expr = 2 * Ef_der * Ef.tr() * meas(Gori);
1482 for (index_t k = 0; k!=points.cols(); k++)
1483 {
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)
1487 {
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);
1492 }
1493 }
1494 }
1495 else
1496 {
1497 auto expr = Ef_der * gismo::expr::uv(m_component,3) * meas(Gori);
1498 for (index_t k = 0; k!=points.cols(); k++)
1499 {
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)
1503 {
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);
1508 }
1509 }
1510 }
1511 }
1512 else if (m_goalFunction == GoalFunction::FlexuralStress)
1513 {
1514 if (m_component==9)
1515 {
1516 auto expr = 2 * Sf_der * S1 * meas(Gori);
1517 for (index_t k = 0; k!=points.cols(); k++)
1518 {
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)
1522 {
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);
1527 }
1528 }
1529 }
1530 else
1531 {
1532 auto expr = Sf_der * gismo::expr::uv(m_component,3) * meas(Gori);
1533 for (index_t k = 0; k!=points.cols(); k++)
1534 {
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)
1538 {
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);
1543 }
1544 }
1545 }
1546 }
1547 else if (m_goalFunction == GoalFunction::FlexuralMoment)
1548 {
1549 if (m_component==9)
1550 {
1551 auto expr = 2 * M_der * M * meas(Gori);
1552 for (index_t k = 0; k!=points.cols(); k++)
1553 {
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)
1557 {
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);
1562 }
1563 }
1564 }
1565 else
1566 {
1567 // remove N_der from this scipe
1568 auto expr = M_der * gismo::expr::uv(m_component,3) * meas(Gori);
1569 for (index_t k = 0; k!=points.cols(); k++)
1570 {
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)
1574 {
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);
1579 }
1580 }
1581 }
1582 }
1583 else
1584 GISMO_ERROR("Goal function not known");
1585
1586 return ThinShellAssemblerStatus::Success;
1587};
1588
1589
1590// template <short_t d, class T, bool bending>
1591// gsVector<T> gsThinShellAssemblerDWR<d, T, bending>::_assembleDual_point(const gsMatrix<T> & points, gsThinShellAssemblerBase<T> * assembler, const gsMatrix<T> & tmp)
1592// {
1593// /* SINGLE PATCH IMPLEMENTATION */
1594// index_t pIndex = 0;
1595// gsVector<T> result;
1596// gsMatrix<index_t> actives, globalActives;
1597
1598// space space = exprAssembler.trialSpace(0);
1599
1600// result.resize(exprAssembler.numDofs());
1601// result.setZero();
1602
1603// for (index_t k = 0; k!=u.cols(); k++)
1604// {
1605// tmp = ev.eval(expr,u.col(k));
1606// basis.front().basis(pIndex).active_into( u.col(k), actives ); // note: takes the first patch of pids as patch id. Works for non-overlapping patches.
1607// for (index_t j = 0; j< space.dim(); ++j)
1608// {
1609// space.mapper().localToGlobal(actives, pIndex, globalActives,j);
1610// for (index_t i=0; i < globalActives.rows(); ++i)
1611// if (v.mapper().is_free_index(globalActs(i,0)))
1612// result.at(globalActives(i,0)) += tmp(i,0);
1613// }
1614
1615// }
1616
1617// return result;
1618// }
1619
1620template <short_t d, class T, bool bending>
1621void gsThinShellAssemblerDWR<d, T, bending>::updateMultiPatchL(const gsMatrix<T> & solVector, gsMultiPatch<T> & result)
1622{
1623 m_assemblerL->updateMultiPatch(solVector,result);
1624}
1625
1626template <short_t d, class T, bool bending>
1627void gsThinShellAssemblerDWR<d, T, bending>::updateMultiPatchH(const gsMatrix<T> & solVector, gsMultiPatch<T> & result)
1628{
1629 m_assemblerH->updateMultiPatch(solVector,result);
1630}
1631
1632template <short_t d, class T, bool bending>
1633void gsThinShellAssemblerDWR<d, T, bending>::constructMultiPatchL(const gsMatrix<T> & solVector, gsMultiPatch<T> & result)
1634{
1635 result = m_assemblerL->constructMultiPatch(solVector);
1636}
1637
1638template <short_t d, class T, bool bending>
1639void gsThinShellAssemblerDWR<d, T, bending>::constructMultiPatchH(const gsMatrix<T> & solVector, gsMultiPatch<T> & result)
1640{
1641 result = m_assemblerH->constructMultiPatch(solVector);
1642}
1643
1644template <short_t d, class T, bool bending>
1645void gsThinShellAssemblerDWR<d, T, bending>::constructSolutionL(const gsMatrix<T> & solVector, gsMultiPatch<T> & deformed)
1646{
1647 m_assemblerL->constructSolution(solVector,deformed);
1648}
1649
1650template <short_t d, class T, bool bending>
1651void gsThinShellAssemblerDWR<d, T, bending>::constructSolutionH(const gsMatrix<T> & solVector, gsMultiPatch<T> & deformed)
1652{
1653 m_assemblerH->constructSolution(solVector,deformed);
1654}
1655
1656template <short_t d, class T, bool bending>
1657gsMultiPatch<T> gsThinShellAssemblerDWR<d, T, bending>::constructSolutionL(const gsMatrix<T> & solVector)
1658{
1659 return m_assemblerL->constructSolution(solVector);
1660}
1661
1662template <short_t d, class T, bool bending>
1663gsMultiPatch<T> gsThinShellAssemblerDWR<d, T, bending>::constructSolutionH(const gsMatrix<T> & solVector)
1664{
1665 return m_assemblerH->constructSolution(solVector);
1666}
1667
1668template <short_t d, class T, bool bending>
1669gsMultiPatch<T> gsThinShellAssemblerDWR<d, T, bending>::constructDisplacementL(const gsMatrix<T> & solVector)
1670{
1671 return m_assemblerL->constructDisplacement(solVector);
1672}
1673
1674template <short_t d, class T, bool bending>
1675gsMultiPatch<T> gsThinShellAssemblerDWR<d, T, bending>::constructDisplacementH(const gsMatrix<T> & solVector)
1676{
1677 return m_assemblerH->constructDisplacement(solVector);
1678}
1679
1680template <short_t d, class T, bool bending>
1681gsVector<T> gsThinShellAssemblerDWR<d, T, bending>::constructSolutionVectorL(const gsMultiPatch<T> & deformed)
1682{
1683 return m_assemblerL->constructSolutionVector(deformed);
1684}
1685
1686template <short_t d, class T, bool bending>
1687gsVector<T> gsThinShellAssemblerDWR<d, T, bending>::constructSolutionVectorH(const gsMultiPatch<T> & deformed)
1688{
1689 return m_assemblerH->constructSolutionVector(deformed);
1690}
1691
1692template <short_t d, class T, bool bending>
1693gsMatrix<T> gsThinShellAssemblerDWR<d, T, bending>::projectL2_L(const gsFunction<T> &fun)
1694{
1695 return m_assemblerL->projectL2(fun);
1696}
1697
1698template <short_t d, class T, bool bending>
1699gsMatrix<T> gsThinShellAssemblerDWR<d, T, bending>::projectL2_H(const gsFunction<T> &fun)
1700{
1701 return m_assemblerH->projectL2(fun);
1702}
1703
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)
1708{
1709 computeError_impl<0>(dualL,dualH,withLoads,filename,np,parametric,mesh);
1710 return m_error;
1711}
1712
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)
1716{
1717 computeError_impl<1>(dualL,dualH,withLoads,filename,np,parametric,mesh);
1718 return m_errors;
1719}
1720
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)
1724{
1725 computeError_impl<2>(dualL,dualH,withLoads,filename,np,parametric,mesh);
1726 return m_errors;
1727}
1728
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,
1733 bool withLoads,
1734 std::string filename,
1735 unsigned np,
1736 bool /*parametric*/,
1737 bool mesh)
1738{
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"));
1743
1744 // Geometries
1745 geometryMap Gori = exprAssembler.getMap(m_patches);
1746
1747 auto F = exprAssembler.getCoeff(*m_forceFun, Gori);
1748 auto zsolL = exprAssembler.getCoeff(dualL);
1749 auto zsolH = exprAssembler.getCoeff(dualH);
1750
1751 auto g_N = exprAssembler.getBdrFunction(Gori);
1752
1753 auto expr = (zsolH-zsolL).tr() * F;
1754 auto bexpr= (zsolH-zsolL).tr() * g_N;
1755
1756 gsExprEvaluator<T> ev(exprAssembler);
1757
1758 T integral, bintegral;
1759 if (_elWise == 0)
1760 {
1761 integral = ev.integral(expr * meas(Gori)); // this one before otherwise it gives an error (?)
1762 bintegral = ev.integralBdrBc( m_bcs.get("Neumann"), bexpr * tv(Gori).norm());
1763 if (m_pLoads.numLoads()!=0 && withLoads)
1764 _applyLoadsToError(dualL,dualH,integral);
1765
1766 m_error = integral+bintegral;
1767 }
1768 else if (_elWise == 1) // element-wise
1769 {
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);
1776 }
1777 else if (_elWise == 2) // function-wise
1778 {
1779 integral = 0;
1780 }
1781 else
1782 GISMO_ERROR("Unknown");
1783
1784 if (!filename.empty())
1785 {
1786 ev.options().setSwitch("plot.elements",mesh);
1787 ev.options().setInt("plot.npts",np);
1788 // if (parametric)
1789 // ev.writeParaview(expr,filename);
1790 // else
1791 ev.writeParaview(expr,Gori,filename);
1792 }
1793}
1794
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)
1798{
1799 computeError_impl<d,bending,0>(dualL,dualH,deformed,withLoads,filename,np,parametric,mesh);
1800 return m_error;
1801}
1802
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)
1806{
1807 computeError_impl<d,bending,1>(dualL,dualH,deformed,withLoads,filename,np,parametric,mesh);
1808 return m_errors;
1809}
1810
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)
1814{
1815 computeError_impl<d,bending,2>(dualL,dualH,deformed,withLoads,filename,np,parametric,mesh);
1816 return m_errors;
1817}
1818
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,
1823 // bool withLoads,
1824 std::string filename, unsigned np, bool /*parametric*/, bool mesh)
1825
1826{
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"));
1831
1832 // Geometries
1833 geometryMap Gori = exprAssembler.getMap(m_patches); // this map is used for integrals
1834 geometryMap Gdef = exprAssembler.getMap(deformed);
1835
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);
1840
1841 gsFunctionExpr<T> mult2t("1","0","0","0","1","0","0","0","2",2);
1842 auto m2 = exprAssembler.getCoeff(mult2t);
1843
1844 auto F = exprAssembler.getCoeff(*m_forceFun, Gori);
1845 auto zsolL = exprAssembler.getCoeff(dualL);
1846 auto zsolH = exprAssembler.getCoeff(dualH);
1847 // auto m_thick = exprAssembler.getCoeff(*m_thickFun, m_ori);
1848
1849 Base::homogenizeDirichlet();
1850
1851 auto N = S0.tr();
1852 // auto Em_der = flat( jac(Gdef).tr() * jac(m_space) ) ;
1853 auto Em_der = flat( jac(Gdef).tr() * (jac(zsolH) - jac(zsolL)) ) ;
1854
1855 auto M = S1.tr(); // output is a column
1856 // auto Ef_der = -( deriv2(space,sn(Gdef).normalized().tr() ) + deriv2(Gdef,var1(space,Gdef) ) ) * reshape(m2,3,3);
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);
1860
1861 auto Fext = (zsolH-zsolL).tr() * F;
1862 auto Fint = ( N * Em_der.tr() + M * Ef_der.tr() );
1863
1864 auto g_N = exprAssembler.getBdrFunction(Gori);
1865
1866 auto expr = ( Fext - Fint );
1867 auto bexpr= (zsolH-zsolL).tr() * g_N;
1868
1869 gsExprEvaluator<T> ev(exprAssembler);
1870
1871 T integral, bintegral = 0;
1872 if (_elWise == 0)
1873 {
1874 if (withLoads)
1875 bintegral = ev.integralBdrBc( m_bcs.get("Neumann"), bexpr * tv(Gori).norm()); // goes wrong with sizes?
1876 integral = ev.integral(expr * meas(Gori));
1877 if (m_pLoads.numLoads()!=0 && withLoads)
1878 _applyLoadsToError(dualL,dualH,integral);
1879
1880 m_error = integral+bintegral;
1881 }
1882 else if (_elWise == 1) // element-wise
1883 {
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);
1890 }
1891 else if (_elWise == 2) // function-wise
1892 {
1893 integral = 0;
1894 }
1895 else
1896 GISMO_ERROR("Unknown");
1897
1898 // if (m_foundInd)
1899 // {
1900 // auto foundation = exprAssembler.getCoeff(*m_foundFun, Gori);
1901 // GISMO_ASSERT(m_foundFun->targetDim()==3,"Foundation function has dimension "<<m_foundFun->targetDim()<<", but expected 3");
1902
1903 // integral += ev.integral( ( zsolH - zsolL ) * foundation.asDiag() * (Gdef - Gori) * meas(Gori) ); // [v_x,v_y,v_z] diag([k_x,k_y,k_z]) [u_x; u_y; u_z]
1904 // }
1905 // if (m_pressInd)
1906 // {
1907 // auto pressure = exprAssembler.getCoeff(*m_pressFun, Gori);
1908 // GISMO_ASSERT(m_pressFun->targetDim()==1,"Pressure function has dimension "<<m_pressFun->targetDim()<<", but expected 1");
1909
1910 // integral += ev.integral( pressure.val() * ( zsolH - zsolL ) * sn(Gdef).normalized() * meas(Gori) );
1911 // }
1912
1913 if (!filename.empty())
1914 {
1915 ev.options().setSwitch("plot.elements",mesh);
1916 ev.options().setInt("plot.npts",np);
1917 // if (parametric)
1918 // ev.writeParaview(expr,filename);
1919 // else
1920 ev.writeParaview(expr,Gori,filename);
1921 }
1922}
1923
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,
1930 bool withLoads,
1931 std::string filename,
1932 unsigned np,
1933 bool /*parametric*/,
1934 bool mesh)
1935{
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"));
1940
1941 // Geometries
1942 geometryMap Gori = exprAssembler.getMap(m_patches); // this map is used for integrals
1943 geometryMap Gdef = exprAssembler.getMap(deformed);
1944
1945 gsMaterialMatrixIntegrate<T,MaterialOutput::VectorN> S0f(m_assemblerH->materials(),&deformed);
1946 auto S0 = exprAssembler.getCoeff(S0f);
1947
1948 auto F = exprAssembler.getCoeff(*m_forceFun, Gori);
1949
1950 auto zsolL = exprAssembler.getCoeff(dualL);
1951 auto zsolH = exprAssembler.getCoeff(dualH);
1952 // auto m_thick = exprAssembler.getCoeff(*m_thickFun, m_ori);
1953
1954 auto N = S0.tr();
1955 // auto Em_der = flat( jac(Gdef).tr() * jac(m_space) ) ;
1956 auto Em_der = flat( jac(Gdef).tr() * (jac(zsolH) - jac(zsolL)) ) ;
1957
1958 auto Fext = (zsolH-zsolL).tr() * F;
1959 auto Fint = ( N * Em_der.tr() );
1960
1961 auto g_N = exprAssembler.getBdrFunction(Gori);
1962
1963 auto expr = ( Fext - Fint );
1964 auto bexpr= (zsolH-zsolL).tr() * g_N;
1965
1966 gsExprEvaluator<T> ev(exprAssembler);
1967
1968 T integral, bintegral;
1969 if (_elWise == 0)
1970 {
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);
1976 }
1977 else if (_elWise == 1) // element-wise
1978 {
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);
1985 }
1986 else if (_elWise == 2) // function-wise
1987 {
1988 integral = 0;
1989 }
1990 else
1991 GISMO_ERROR("Unknown");
1992 // if (m_foundInd)
1993 // {
1994 // auto foundation = exprAssembler.getCoeff(*m_foundFun, Gori);
1995 // GISMO_ASSERT(m_foundFun->targetDim()==3,"Foundation function has dimension "<<m_foundFun->targetDim()<<", but expected 3");
1996
1997 // integral += ev.integral( ( zsolH - zsolL ) * foundation.asDiag() * (Gdef - Gori) * meas(Gori) ); // [v_x,v_y,v_z] diag([k_x,k_y,k_z]) [u_x; u_y; u_z]
1998 // }
1999 // if (m_pressInd)
2000 // {
2001 // auto pressure = exprAssembler.getCoeff(*m_pressFun, Gori);
2002 // GISMO_ASSERT(m_pressFun->targetDim()==1,"Pressure function has dimension "<<m_pressFun->targetDim()<<", but expected 1");
2003
2004 // integral += ev.integral( pressure.val() * ( zsolH - zsolL ) * sn(Gdef).normalized() * meas(Gori) );
2005 // }
2006
2007 if (!filename.empty())
2008 {
2009 ev.options().setSwitch("plot.elements",mesh);
2010 ev.options().setInt("plot.npts",np);
2011 // if (parametric)
2012 // ev.writeParaview(expr,filename);
2013 // else
2014 ev.writeParaview(expr,Gori,filename);
2015 }
2016}
2017
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)
2021{
2022 computeSquaredError_impl<0>(dualL,dualH,withLoads,filename,np,parametric,mesh);
2023 return m_error;
2024}
2025
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)
2029{
2030 computeSquaredError_impl<1>(dualL,dualH,withLoads,filename,np,parametric,mesh);
2031 return m_errors;
2032}
2033
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)
2037{
2038 computeSquaredError_impl<2>(dualL,dualH,withLoads,filename,np,parametric,mesh);
2039 return m_errors;
2040}
2041
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,
2046 bool withLoads,
2047 std::string filename,
2048 unsigned np,
2049 bool /*parametric*/,
2050 bool mesh)
2051{
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"));
2056
2057 // Geometries
2058 geometryMap Gori = exprAssembler.getMap(m_patches);
2059
2060 auto F = exprAssembler.getCoeff(*m_forceFun, Gori);
2061 auto zsolL = exprAssembler.getCoeff(dualL);
2062 auto zsolH = exprAssembler.getCoeff(dualH);
2063
2064 auto g_N = exprAssembler.getBdrFunction(Gori);
2065
2066 auto expr = ((zsolH-zsolL).tr() * F).sqNorm();
2067 auto bexpr= (zsolH-zsolL).tr() * g_N;
2068
2069 gsExprEvaluator<T> ev(exprAssembler);
2070
2071 T integral, bintegral;
2072 if (_elWise == 0)
2073 {
2074 integral = ev.integral(expr * meas(Gori)); // this one before otherwise it gives an error (?)
2075 bintegral = ev.integralBdrBc( m_bcs.get("Neumann"), bexpr * tv(Gori).norm());
2076 if (m_pLoads.numLoads()!=0 && withLoads)
2077 _applyLoadsToError(dualL,dualH,integral);
2078
2079 m_error = integral+bintegral;
2080 }
2081 else if (_elWise == 1) // element-wise
2082 {
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);
2089 }
2090 else if (_elWise == 2) // function-wise
2091 {
2092 integral = 0;
2093 }
2094 else
2095 GISMO_ERROR("Unknown");
2096
2097 if (!filename.empty())
2098 {
2099 ev.options().setSwitch("plot.elements",mesh);
2100 ev.options().setInt("plot.npts",np);
2101 // if (parametric)
2102 // ev.writeParaview(expr,filename);
2103 // else
2104 ev.writeParaview(expr,Gori,filename);
2105 }
2106}
2107
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)
2111{
2112 computeSquaredError_impl<d,bending,0>(dualL,dualH,deformed,withLoads,filename,np,parametric,mesh);
2113 return m_error;
2114}
2115
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)
2119{
2120 computeSquaredError_impl<d,bending,1>(dualL,dualH,deformed,withLoads,filename,np,parametric,mesh);
2121 return m_errors;
2122}
2123
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)
2127{
2128 computeSquaredError_impl<d,bending,2>(dualL,dualH,deformed,withLoads,filename,np,parametric,mesh);
2129 return m_errors;
2130}
2131
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,
2136 // bool withLoads,
2137 std::string filename, unsigned np, bool /*parametric*/, bool mesh)
2138
2139{
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"));
2144
2145 // Geometries
2146 geometryMap Gori = exprAssembler.getMap(m_patches); // this map is used for integrals
2147 geometryMap Gdef = exprAssembler.getMap(deformed);
2148
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);
2153
2154 gsFunctionExpr<T> mult2t("1","0","0","0","1","0","0","0","2",2);
2155 auto m2 = exprAssembler.getCoeff(mult2t);
2156
2157 auto F = exprAssembler.getCoeff(*m_forceFun, Gori);
2158 auto zsolL = exprAssembler.getCoeff(dualL);
2159 auto zsolH = exprAssembler.getCoeff(dualH);
2160 // auto m_thick = exprAssembler.getCoeff(*m_thickFun, m_ori);
2161
2162 Base::homogenizeDirichlet();
2163
2164 auto N = S0.tr();
2165 // auto Em_der = flat( jac(Gdef).tr() * jac(m_space) ) ;
2166 auto Em_der = flat( jac(Gdef).tr() * (jac(zsolH) - jac(zsolL)) ) ;
2167
2168 auto M = S1.tr(); // output is a column
2169 // auto Ef_der = -( deriv2(space,sn(Gdef).normalized().tr() ) + deriv2(Gdef,var1(space,Gdef) ) ) * reshape(m2,3,3);
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);
2173
2174 auto Fext = (zsolH-zsolL).tr() * F;
2175 auto Fint = ( N * Em_der.tr() + M * Ef_der.tr() );
2176
2177 auto g_N = exprAssembler.getBdrFunction(Gori);
2178
2179 auto expr = ( Fext - Fint ).sqNorm();
2180 auto bexpr= (zsolH-zsolL).tr() * g_N;
2181
2182 gsExprEvaluator<T> ev(exprAssembler);
2183
2184 T integral, bintegral;
2185 if (_elWise == 0)
2186 {
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);
2191
2192 m_error = integral+bintegral;
2193 }
2194 else if (_elWise == 1) // element-wise
2195 {
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);
2202 }
2203 else if (_elWise == 2) // function-wise
2204 {
2205 integral = 0;
2206 }
2207 else
2208 GISMO_ERROR("Unknown");
2209
2210 // if (m_foundInd)
2211 // {
2212 // auto foundation = exprAssembler.getCoeff(*m_foundFun, Gori);
2213 // GISMO_ASSERT(m_foundFun->targetDim()==3,"Foundation function has dimension "<<m_foundFun->targetDim()<<", but expected 3");
2214
2215 // integral += ev.integral( ( zsolH - zsolL ) * foundation.asDiag() * (Gdef - Gori) * meas(Gori) ); // [v_x,v_y,v_z] diag([k_x,k_y,k_z]) [u_x; u_y; u_z]
2216 // }
2217 // if (m_pressInd)
2218 // {
2219 // auto pressure = exprAssembler.getCoeff(*m_pressFun, Gori);
2220 // GISMO_ASSERT(m_pressFun->targetDim()==1,"Pressure function has dimension "<<m_pressFun->targetDim()<<", but expected 1");
2221
2222 // integral += ev.integral( pressure.val() * ( zsolH - zsolL ) * sn(Gdef).normalized() * meas(Gori) );
2223 // }
2224
2225 if (!filename.empty())
2226 {
2227 ev.options().setSwitch("plot.elements",mesh);
2228 ev.options().setInt("plot.npts",np);
2229 // if (parametric)
2230 // ev.writeParaview(expr,filename);
2231 // else
2232 ev.writeParaview(expr,Gori,filename);
2233 }
2234}
2235
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,
2242 bool withLoads,
2243 std::string filename,
2244 unsigned np,
2245 bool /*parametric*/,
2246 bool mesh)
2247{
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"));
2252
2253 // Geometries
2254 geometryMap Gori = exprAssembler.getMap(m_patches); // this map is used for integrals
2255 geometryMap Gdef = exprAssembler.getMap(deformed);
2256
2257 gsMaterialMatrixIntegrate<T,MaterialOutput::VectorN> S0f(m_assemblerH->materials(),&deformed);
2258 auto S0 = exprAssembler.getCoeff(S0f);
2259
2260 auto F = exprAssembler.getCoeff(*m_forceFun, Gori);
2261
2262 auto zsolL = exprAssembler.getCoeff(dualL);
2263 auto zsolH = exprAssembler.getCoeff(dualH);
2264 // auto m_thick = exprAssembler.getCoeff(*m_thickFun, m_ori);
2265
2266 auto N = S0.tr();
2267 // auto Em_der = flat( jac(Gdef).tr() * jac(m_space) ) ;
2268 auto Em_der = flat( jac(Gdef).tr() * (jac(zsolH) - jac(zsolL)) ) ;
2269
2270 auto Fext = (zsolH-zsolL).tr() * F;
2271 auto Fint = ( N * Em_der.tr() );
2272
2273 auto g_N = exprAssembler.getBdrFunction(Gori);
2274
2275 auto expr = ( Fext - Fint ).sqNorm();
2276 auto bexpr= (zsolH-zsolL).tr() * g_N;
2277
2278 gsExprEvaluator<T> ev(exprAssembler);
2279
2280 T integral, bintegral;
2281 if (_elWise == 0)
2282 {
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);
2288 }
2289 else if (_elWise == 1) // element-wise
2290 {
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);
2297 }
2298 else if (_elWise == 2) // function-wise
2299 {
2300 integral = 0;
2301 }
2302 else
2303 GISMO_ERROR("Unknown");
2304 // if (m_foundInd)
2305 // {
2306 // auto foundation = exprAssembler.getCoeff(*m_foundFun, Gori);
2307 // GISMO_ASSERT(m_foundFun->targetDim()==3,"Foundation function has dimension "<<m_foundFun->targetDim()<<", but expected 3");
2308
2309 // integral += ev.integral( ( zsolH - zsolL ) * foundation.asDiag() * (Gdef - Gori) * meas(Gori) ); // [v_x,v_y,v_z] diag([k_x,k_y,k_z]) [u_x; u_y; u_z]
2310 // }
2311 // if (m_pressInd)
2312 // {
2313 // auto pressure = exprAssembler.getCoeff(*m_pressFun, Gori);
2314 // GISMO_ASSERT(m_pressFun->targetDim()==1,"Pressure function has dimension "<<m_pressFun->targetDim()<<", but expected 1");
2315
2316 // integral += ev.integral( pressure.val() * ( zsolH - zsolL ) * sn(Gdef).normalized() * meas(Gori) );
2317 // }
2318
2319 if (!filename.empty())
2320 {
2321 ev.options().setSwitch("plot.elements",mesh);
2322 ev.options().setInt("plot.npts",np);
2323 // if (parametric)
2324 // ev.writeParaview(expr,filename);
2325 // else
2326 ev.writeParaview(expr,Gori,filename);
2327 }
2328}
2329
2330
2348template <short_t d, class T, bool bending>
2349T gsThinShellAssemblerDWR<d, T, bending>::computeErrorEig( const T evPrimalL,
2350 const T evDualL,
2351 const T evDualH,
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)
2357{
2358 computeErrorEig_impl<0>(evPrimalL, evDualL, evDualH, dualL, dualH, primal, deformed,filename,np,parametric,mesh);
2359 return m_error;
2360}
2361
2362template <short_t d, class T, bool bending>
2363std::vector<T> gsThinShellAssemblerDWR<d, T, bending>::computeErrorEigElements( const T evPrimalL,
2364 const T evDualL,
2365 const T evDualH,
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)
2371{
2372 computeErrorEig_impl<1>(evPrimalL, evDualL, evDualH, dualL, dualH, primal, deformed,filename,np,parametric,mesh);
2373 return m_errors;
2374}
2375
2376template <short_t d, class T, bool bending>
2377std::vector<T> gsThinShellAssemblerDWR<d, T, bending>::computeErrorEigDofs( const T evPrimalL,
2378 const T evDualL,
2379 const T evDualH,
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)
2385{
2386 computeErrorEig_impl<2>(evPrimalL, evDualL, evDualH, dualL, dualH, primal, deformed,filename,np,parametric,mesh);
2387 return m_errors;
2388}
2389
2390
2391template <short_t d, class T, bool bending>
2392template <index_t _elWise>
2393void gsThinShellAssemblerDWR<d, T, bending>::computeErrorEig_impl( const T evPrimalL,
2394 const T evDualL,
2395 const T evDualH,
2396 const gsMultiPatch<T> & dualL,
2397 const gsMultiPatch<T> & dualH,
2398 const gsMultiPatch<T> & primal,
2399 const gsMultiPatch<T> & deformed,
2400 std::string filename,
2401 unsigned np,
2402 bool /*parametric*/,
2403 bool mesh)
2404{
2405 // Everything is evaluated in the lower basis L
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"));
2410
2411 // Geometries
2412 geometryMap Gori = exprAssembler.getMap(m_patches); // this map is used for integrals
2413 geometryMap Gdef = exprAssembler.getMap(deformed);
2414
2415 // Initialize vector
2416 exprAssembler.initSystem();
2417 exprAssembler.initVector(1);
2418
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);
2427
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);
2436
2437 gsMaterialMatrixIntegrate<T,MaterialOutput::VectorN> S0f(m_assemblerH->materials(),&deformed);
2438 gsMaterialMatrixIntegrate<T,MaterialOutput::VectorM> S1f(m_assemblerH->materials(),&deformed);
2439 // gsMaterialMatrixIntegrate<T,MaterialOutput::Density> rhof(m_assemblerH->materials(),deformed);
2440 auto S0 = exprAssembler.getCoeff(S0f);
2441 auto S1 = exprAssembler.getCoeff(S1f);
2442 // auto rho = exprAssembler.getCoeff(rhof);
2443
2444 gsFunctionExpr<T> mult2t("1","0","0","0","1","0","0","0","2",2);
2445 auto m2 = exprAssembler.getCoeff(mult2t);
2446
2447 auto usol = exprAssembler.getCoeff(primal);
2448 auto zsolL = exprAssembler.getCoeff(dualL);
2449 auto zsolH = exprAssembler.getCoeff(dualH);
2450
2451 // // Matrix K_L
2452 // auto N = S0.tr();
2453 // auto Em_der = flat( jac(Gori).tr() * (jac(zsolH) - jac(zsolL)) ) ;
2454
2455 // auto M = S1.tr(); // output is a column
2456 // auto Ef_der = -(deriv2(zsolH, sn(Gori).normalized().tr()) - deriv2(zsolL, sn(Gori).normalized().tr()) + deriv2(Gori, var1(zsolH, Gori)) - deriv2(Gori, var1(zsolL, Gori))) * reshape(m2, 3, 3);
2457
2458 // auto N_der = Em_der * reshape(mmA,3,3) + Ef_der * reshape(mmB,3,3);
2459 // auto M_der = Em_der * reshape(mmC,3,3) + Ef_der * reshape(mmD,3,3);
2460
2461 // auto Fint = ( N_der * Em_der.tr() + M_der * Ef_der.tr() );
2462
2463 // // Matrix K_NL
2464 // auto Em_der2 = flatdot( jac(Gdef),jac(zsolH), N ) - flatdot( jac(Gdef),jac(zsolL), N );
2465 // auto Ef_der2 = -(flatdot2( deriv2(m_space), var1(m_space,m_def).tr(), m_M ).symmetrize()
2466 // + var2dot(m_space,m_space,m_def, m_M ))
2467
2468 /*
2469 Weak form:
2470 Wint(u,v) = int eps(u,v)'*n(u) + kappa(u,v)'*m(u) dint
2471
2472 Jacobian
2473 Wint(u,v,w) = int eps(u,v)'*n(u,w)' + eps''(u,v,w)*n(u) + kappa(u,v)'*m'(u,w) + kappa''(u,v,w)*m(u) dint
2474
2475 */
2476
2477
2478 auto N_L = S0.tr();
2479 auto Em_der_L = flat( jac(Gori).tr() * ( jac(usol ) ) ) ;
2480 auto Em_derd_L = flat( jac(Gori).tr() * ( jac(zsolH) - jac(zsolL) ) ) ;
2481
2482 auto M_L = S1.tr(); // output is a column
2483 auto Ef_der_L = -( deriv2(usol , sn(Gori).normalized().tr() ) - deriv2(Gori, var1(usol , Gori) ) ) * reshape(m2, 3, 3);
2484 auto Ef_derd_L = -(
2485 deriv2(zsolH, sn(Gori).normalized().tr() ) - deriv2(Gori, var1(zsolH, Gori) )
2486 -deriv2(zsolL, sn(Gori).normalized().tr() ) - deriv2(Gori, var1(zsolL, Gori) )
2487 ) * reshape(m2, 3, 3);
2488
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);
2491
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);
2494
2495 auto Fint_L = ( N_derd_L * Em_derd_L.tr() + M_derd_L * Ef_derd_L.tr() );
2496
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) ) ) ;
2500
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();
2503
2504 auto M_NL = S1.tr(); // output is a column
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) )
2509 ) * reshape(m2, 3, 3);
2510
2511 auto Ef_der2 = -(
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)
2515 ) * M_NL.tr();
2516
2517 auto Efd_der2 = -(
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)
2521 ) * M_NL.tr();
2522
2523
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);
2526
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);
2529
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 );
2534
2535 auto A = Kd_L;
2536 auto Bdiff = Kd_NL - Kd_L;
2537 auto Bprimal = K_NL - K_L ;
2538
2539 auto expr = A - evPrimalL * Bdiff + (evDualH - evDualL) * Bprimal;
2540
2541 gsExprEvaluator<T> ev(exprAssembler);
2542 if (_elWise == 0)
2543 {
2544 m_error = ev.integral(expr * meas(Gori)) - (evDualH - evDualL);
2545 }
2546 else if (_elWise == 1)
2547 {
2548 m_error = ev.integralElWise(expr * meas(Gori)) - (evDualH - evDualL);
2549 m_errors = ev.elementwise();
2550 }
2551 else if (_elWise == 2)
2552 {
2553 m_error = 0;
2554 }
2555 else
2556 GISMO_ERROR("Unknown");
2557
2558 if (!filename.empty())
2559 {
2560 ev.options().setSwitch("plot.elements",mesh);
2561 ev.options().setInt("plot.npts",np);
2562 // if (parametric)
2563 // ev.writeParaview(expr,filename);
2564 // else
2565 ev.writeParaview(expr,Gori,filename);
2566 }
2567}
2568
2569// template <short_t d, class T, bool bending>
2570// gsMatrix<T> gsThinShellAssemblerDWR<d, T, bending>::evalErrorEig( gsMatrix<T> & u,
2571// const T evPrimalL,
2572// const T evDualL,
2573// const T evDualH,
2574// const gsMultiPatch<T> & dualL,
2575// const gsMultiPatch<T> & dualH,
2576// const gsMultiPatch<T> & primal,
2577// const gsMultiPatch<T> & deformed)
2578// {
2579// gsExprAssembler<T> exprAssembler = m_assemblerH->assembler();
2580// exprAssembler.cleanUp();
2581 // GISMO_ENSURE(m_assemblerH->options().hasGroup("ExprAssembler"),"The option list does not contain options with the label 'ExprAssembler'!");
2582 // exprAssembler.setOptions(m_assemblerH->options().getGroup("ExprAssembler"));
2583
2584// gsExprEvaluator<T> ev(exprAssembler);
2585
2586// return ev.eval(expr,u);
2587// }
2588
2605template <short_t d, class T, bool bending>
2606T gsThinShellAssemblerDWR<d, T, bending>::computeErrorEig( const T evPrimalL,
2607 const T evDualL,
2608 const T evDualH,
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)
2613{
2614 computeErrorEig_impl<0>(evPrimalL, evDualL, evDualH, dualL, dualH, primal,filename,np,parametric,mesh);
2615 return m_error;
2616}
2617
2618template <short_t d, class T, bool bending>
2619std::vector<T> gsThinShellAssemblerDWR<d, T, bending>::computeErrorEigElements( const T evPrimalL,
2620 const T evDualL,
2621 const T evDualH,
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)
2626{
2627 computeErrorEig_impl<1>(evPrimalL, evDualL, evDualH, dualL, dualH, primal,filename,np,parametric,mesh);
2628 return m_errors;
2629}
2630
2631template <short_t d, class T, bool bending>
2632std::vector<T> gsThinShellAssemblerDWR<d, T, bending>::computeErrorEigDofs( const T evPrimalL,
2633 const T evDualL,
2634 const T evDualH,
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)
2639{
2640 computeErrorEig_impl<2>(evPrimalL, evDualL, evDualH, dualL, dualH, primal,filename,np,parametric,mesh);
2641 return m_errors;
2642}
2643
2644template <short_t d, class T, bool bending>
2645template <index_t _elWise>
2646void gsThinShellAssemblerDWR<d, T, bending>::computeErrorEig_impl( const T evPrimalL,
2647 const T evDualL,
2648 const T evDualH,
2649 const gsMultiPatch<T> & dualL,
2650 const gsMultiPatch<T> & dualH,
2651 const gsMultiPatch<T> & primal,
2652 std::string filename,
2653 unsigned np,
2654 bool /*parametric*/,
2655 bool mesh)
2656{
2657 // Everything is evaluated in the lower basis L
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"));
2662
2663 gsMultiPatch<T> deformed = m_patches;
2664 for ( size_t k =0; k!=primal.nPatches(); ++k) // Deform the geometry
2665 deformed.patch(k).coefs() += primal.patch(k).coefs(); // Gdef points to mp_def, therefore updated
2666
2667 // Geometries
2668 geometryMap Gori = exprAssembler.getMap(m_patches); // this map is used for integrals
2669
2670 // Initialize vector
2671 exprAssembler.initSystem();
2672 exprAssembler.initVector(1);
2673
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);
2682
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);
2689
2690 gsFunctionExpr<T> mult2t("1","0","0","0","1","0","0","0","2",2);
2691 auto m2 = exprAssembler.getCoeff(mult2t);
2692
2693 auto usol = exprAssembler.getCoeff(primal);
2694 auto zsolL = exprAssembler.getCoeff(dualL);
2695 auto zsolH = exprAssembler.getCoeff(dualH);
2696
2697 auto N = S0.tr();
2698 auto Em_derd= flat( jac(Gori).tr() * (jac(zsolH) - jac(zsolL)) ) ;
2699 auto Em_der = flat( jac(Gori).tr() * (jac(usol) ) ) ;
2700
2701 auto Em_derdw= flat( jac(Gori).tr() * (jac(zsolH) - jac(zsolL)) ) ;
2702
2703
2704 auto M = S1.tr(); // output is a column
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);
2709
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);
2712
2713 auto Fint = ( N_der * Em_der.tr() + M_der * Ef_der.tr() );
2714
2715 gsExprEvaluator<T> ev(exprAssembler);
2716
2717 auto A = Fint;
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;
2721
2722 if (_elWise == 0)
2723 m_error = ev.integral(expr * meas(Gori)) - (evDualH - evDualL);
2724 else if (_elWise == 1)
2725 {
2726 m_error = ev.integralElWise(expr * meas(Gori) ) - (evDualH - evDualL);
2727 m_errors = ev.elementwise();
2728 }
2729 else if (_elWise == 2)
2730 m_error = 0;
2731 else
2732 GISMO_ERROR("Unknown");
2733
2734 if (!filename.empty())
2735 {
2736 ev.options().setSwitch("plot.elements",mesh);
2737 ev.options().setInt("plot.npts",np);
2738 // if (parametric)
2739 // ev.writeParaview(expr,filename);
2740 // else
2741 ev.writeParaview(expr,Gori,filename);
2742 }
2743}
2744
2745//============================================================
2746template <short_t d, class T, bool bending>
2747T gsThinShellAssemblerDWR<d, T, bending>::computeGoal(const gsMultiPatch<T> & deformed)
2748{
2749 gsMatrix<T> Z(1,1);
2750 Z.setZero();
2751
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"));
2756
2757 // Initialize vector
2758 exprAssembler.initSystem();
2759 exprAssembler.initVector(1);
2760
2761 // Geometries
2762 geometryMap Gori = exprAssembler.getMap(m_patches); // this map is used for integrals
2763 geometryMap Gdef = exprAssembler.getMap(deformed);
2764
2765 // Transformation for stretches
2766 gsMaterialMatrixEval<T,MaterialOutput::StretchTransform> Tstretchf(m_assemblerH->materials(),&deformed,Z);
2767 auto Tstretch = exprAssembler.getCoeff(Tstretchf);
2768
2769 // Stress tensors
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);
2774
2775 // Force tensors
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);
2780
2782 // gsMaterialMatrixIntegrate<T,MaterialOutput::VectorN> S0if(m_assemblerH->materials(),&deformed);
2783 // gsMaterialMatrixIntegrate<T,MaterialOutput::VectorM> S1if(m_assemblerH->materials(),&deformed);
2784 // auto S0i = exprAssembler.getCoeff(S0if);
2785 // auto S1i = exprAssembler.getCoeff(S1if);
2786 // gsMaterialMatrixIntegrate<T,MaterialOutput::MatrixD> mmAfi(m_assemblerH->materials(),&deformed);
2787 // auto mmAi = exprAssembler.getCoeff(mmAfi);
2788 // gsMaterialMatrixIntegrate<T,MaterialOutput::MatrixD> mmDfi(m_assemblerH->materials(),&deformed);
2789 // auto mmDi = exprAssembler.getCoeff(mmDfi);
2791
2792 // Principal stress tensors
2793 gsMaterialMatrixEval<T,MaterialOutput::PStress> P0f(m_assemblerH->materials(),&deformed,Z);
2794 auto P0 = exprAssembler.getCoeff(P0f);
2795
2796 // Helper matrix for flexural components
2797 gsFunctionExpr<T> mult2t("1","0","0","0","1","0","0","0","2",2);
2798 auto m2 = exprAssembler.getCoeff(mult2t);
2799
2800 // Deformation gradient
2801 // To compensate for the flat, since flat does [E11,E22,2*E12]
2802 gsFunctionExpr<T> mult12t("1","0","0","0","1","0","0","0","0.5",2);
2803 auto m12 = exprAssembler.getCoeff(mult12t);
2804
2805 auto Cm = flat( jac(Gdef).tr() * jac(Gdef) ) * reshape(m12,3,3);
2806
2807 // Principal stretch
2808 auto lambda = reshape(Tstretch,3,3) * Cm.tr();
2809
2810 // Membrane strain
2811 auto Em = 0.5 * ( flat(jac(Gdef).tr()*jac(Gdef)) - flat(jac(Gori).tr()* jac(Gori)) ) ;
2812
2813 // Principal membrane strain
2814 auto Emp = (Em * reshape(m12,3,3)) * reshape(Tstretch,3,3).tr();
2815
2816 // Flexural strain
2817 auto Ef = ( deriv2(Gori,sn(Gori).normalized().tr()) - deriv2(Gdef,sn(Gdef).normalized().tr()) ) * reshape(m2,3,3) ;
2818
2819
2820 // Membrane force (its first variation)
2821 // auto N_der = Em_der * reshape(mmA,3,3) + Ef_der * reshape(mmB,3,3);
2822
2823 gsExprEvaluator<T> ev(exprAssembler);
2824 if (m_goalFunction == GoalFunction::Displacement)
2825 {
2826 if (m_component==9)
2827 {
2828 auto expr = (Gdef - Gori).tr() * (Gdef - Gori) * meas(Gori);
2829 return ev.integral( expr );
2830 }
2831 else
2832 {
2833 auto expr = (Gdef - Gori).tr() * gismo::expr::uv(m_component,3)*meas(Gori);
2834 return ev.integral( expr );
2835 }
2836 }
2837 else if (m_goalFunction == GoalFunction::Stretch)
2838 {
2839 /*
2840 NOTE:
2841 - Cm * Transformation does only give the in-plane stretches, since C is constructed with the in-plane jacobians (Gdef) only. In fact, Cm should have a third entry with the Jacobian Determinant J0, but this one is hard to compute the variations for.
2842 */
2843 if (m_component==9)
2844 {
2845 // gsMaterialMatrixEval<T,MaterialOutput::Stretch> lambdaf(m_assemblerH->materials(),&deformed,Z);
2846 // auto lambda = exprAssembler.getCoeff(lambdaf);
2847 // auto expr1 = gismo::expr::pow(lambda.tr() * lambda,2) * meas(Gori);
2848 auto expr = lambda.tr() * lambda * meas(Gori);
2849 return ev.integral( expr );
2850 }
2851 else
2852 {
2853 auto expr = lambda.tr() * gismo::expr::uv(m_component,3)*meas(Gori);
2854 return ev.integral( expr );
2855 }
2856 }
2857 else if (m_goalFunction == GoalFunction::PStrain)
2858 {
2859 if (m_component==9)
2860 {
2861 auto expr = Emp * Emp.tr() * meas(Gori);
2862 return ev.integral( expr );
2863 }
2864 else
2865 {
2866 auto expr = Emp * gismo::expr::uv(m_component,3) * meas(Gori);
2867 return ev.integral( expr );
2868 }
2869 }
2870 else if (m_goalFunction == GoalFunction::PStress)
2871 {
2872 if (m_component==9)
2873 {
2874 auto expr = P0.tr() * P0 * meas(Gori);
2875 return ev.integral( expr );
2876 }
2877 else
2878 {
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 );
2882 }
2883 }
2884
2885 else if (m_goalFunction == GoalFunction::MembraneStrain)
2886 {
2887 if (m_component==9)
2888 {
2889 // auto expr = Em * Em.tr() * meas(Gori);
2890 auto expr = Em.sqNorm() * meas(Gori);
2891 return ev.integral( expr );
2892 }
2893 else
2894 {
2895 auto expr = Em * gismo::expr::uv(m_component,3) * meas(Gori);
2896 return ev.integral( expr );
2897 }
2898 }
2899 else if (m_goalFunction == GoalFunction::MembraneStress)
2900 {
2901 if (m_component==9)
2902 {
2903 auto expr = S0.tr() * S0 * meas(Gori);
2904 return ev.integral( expr );
2905 }
2906 else
2907 {
2908 auto expr = S0.tr() * gismo::expr::uv(m_component,3) * meas(Gori);
2909 return ev.integral( expr );
2910 }
2911 }
2912 else if (m_goalFunction == GoalFunction::MembraneForce)
2913 {
2914 if (m_component==9)
2915 {
2916 auto expr = N.tr() * N * meas(Gori);
2917 return ev.integral( expr );
2918 }
2919 else
2920 {
2921 auto expr = N.tr() * gismo::expr::uv(m_component,3) * meas(Gori);
2922 return ev.integral( expr );
2923 }
2924 }
2925 else if (m_goalFunction == GoalFunction::FlexuralStrain)
2926 {
2927 if (m_component==9)
2928 {
2929 auto expr = Ef * Ef.tr() * meas(Gori);
2930 return ev.integral( expr );
2931 }
2932 else
2933 {
2934 auto expr = Ef * gismo::expr::uv(m_component,3) * meas(Gori);
2935 return ev.integral( expr );
2936 }
2937 }
2938 else if (m_goalFunction == GoalFunction::FlexuralStress)
2939 {
2940 if (m_component==9)
2941 {
2942 auto expr = S1.tr() * S1 * meas(Gori);
2943 return ev.integral( expr );
2944 }
2945 else
2946 {
2947 auto expr = S1.tr() * gismo::expr::uv(m_component,3) * meas(Gori);
2948 return ev.integral( expr );
2949 }
2950 }
2951 else if (m_goalFunction == GoalFunction::FlexuralMoment)
2952 {
2953 if (m_component==9)
2954 {
2955 auto expr = M.tr() * M * meas(Gori);
2956 return ev.integral( expr );
2957 }
2958 else
2959 {
2960 auto expr = M.tr() * gismo::expr::uv(m_component,3) * meas(Gori);
2961 return ev.integral( expr );
2962 }
2963 }
2964 else
2965 GISMO_ERROR("Goal function not known");
2966}
2967
2968template <short_t d, class T, bool bending>
2969T gsThinShellAssemblerDWR<d, T, bending>::computeGoal(const bContainer & bnds, const gsMultiPatch<T> & deformed)
2970{
2971 if (bnds.size()==0) return 0;
2972
2973 gsMatrix<T> Z(1,1);
2974 Z.setZero();
2975
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"));
2980
2981 // Initialize vector
2982 exprAssembler.initSystem();
2983 exprAssembler.initVector(1);
2984
2985 // Geometries
2986 geometryMap Gori = exprAssembler.getMap(m_patches); // this map is used for integrals
2987 geometryMap Gdef = exprAssembler.getMap(deformed);
2988
2989 // Transformation for stretches
2990 gsMaterialMatrixEval<T,MaterialOutput::StretchTransform> Tstretchf(m_assemblerH->materials(),&deformed,Z);
2991 auto Tstretch = exprAssembler.getCoeff(Tstretchf);
2992
2993 // Stress tensors
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);
2998
2999 // Force tensors
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);
3004
3006 // gsMaterialMatrixIntegrate<T,MaterialOutput::VectorN> S0if(m_assemblerH->materials(),&deformed);
3007 // gsMaterialMatrixIntegrate<T,MaterialOutput::VectorM> S1if(m_assemblerH->materials(),&deformed);
3008 // auto S0i = exprAssembler.getCoeff(S0if);
3009 // auto S1i = exprAssembler.getCoeff(S1if);
3010 // gsMaterialMatrixIntegrate<T,MaterialOutput::MatrixD> mmAfi(m_assemblerH->materials(),&deformed);
3011 // auto mmAi = exprAssembler.getCoeff(mmAfi);
3012 // gsMaterialMatrixIntegrate<T,MaterialOutput::MatrixD> mmDfi(m_assemblerH->materials(),&deformed);
3013 // auto mmDi = exprAssembler.getCoeff(mmDfi);
3015
3016 // Principal stress tensors
3017 gsMaterialMatrixEval<T,MaterialOutput::PStress> P0f(m_assemblerH->materials(),&deformed,Z);
3018 auto P0 = exprAssembler.getCoeff(P0f);
3019
3020 // Helper matrix for flexural components
3021 gsFunctionExpr<T> mult2t("1","0","0","0","1","0","0","0","2",2);
3022 auto m2 = exprAssembler.getCoeff(mult2t);
3023
3024 // Deformation gradient
3025 // To compensate for the flat, since flat does [E11,E22,2*E12]
3026 gsFunctionExpr<T> mult12t("1","0","0","0","1","0","0","0","0.5",2);
3027 auto m12 = exprAssembler.getCoeff(mult12t);
3028
3029 auto Cm = flat( jac(Gdef).tr() * jac(Gdef) ) * reshape(m12,3,3);
3030
3031 // Principal stretch
3032 auto lambda = reshape(Tstretch,3,3) * Cm.tr();
3033
3034 // Membrane strain
3035 auto Em = 0.5 * ( flat(jac(Gdef).tr()*jac(Gdef)) - flat(jac(Gori).tr()* jac(Gori)) ) ;
3036
3037 // Principal membrane strain
3038 auto Emp = (Em * reshape(m12,3,3)) * reshape(Tstretch,3,3).tr();
3039
3040 // Flexural strain
3041 auto Ef = ( deriv2(Gori,sn(Gori).normalized().tr()) - deriv2(Gdef,sn(Gdef).normalized().tr()) ) * reshape(m2,3,3) ;
3042
3043
3044 // Membrane force (its first variation)
3045 // auto N_der = Em_der * reshape(mmA,3,3) + Ef_der * reshape(mmB,3,3);
3046
3047 gsExprEvaluator<T> ev(exprAssembler);
3048 if (m_goalFunction == GoalFunction::Displacement)
3049 {
3050 if (m_component==9)
3051 {
3052 auto expr = (Gdef - Gori).tr() * (Gdef - Gori) * meas(Gori);
3053 return ev.integralBdr( expr,bnds );
3054 }
3055 else
3056 {
3057 auto expr = (Gdef - Gori).tr() * gismo::expr::uv(m_component,3)*meas(Gori);
3058 return ev.integralBdr( expr,bnds );
3059 }
3060 }
3061 else if (m_goalFunction == GoalFunction::Stretch)
3062 {
3063 /*
3064 NOTE:
3065 - Cm * Transformation does only give the in-plane stretches, since C is constructed with the in-plane jacobians (Gdef) only. In fact, Cm should have a third entry with the Jacobian Determinant J0, but this one is hard to compute the variations for.
3066 */
3067 if (m_component==9)
3068 {
3069 // gsMaterialMatrixEval<T,MaterialOutput::Stretch> lambdaf(m_assemblerH->materials(),&deformed,Z);
3070 // auto lambda = exprAssembler.getCoeff(lambdaf);
3071 // auto expr1 = gismo::expr::pow(lambda.tr() * lambda,2) * meas(Gori);
3072 auto expr = lambda.tr() * lambda * meas(Gori);
3073 return ev.integralBdr( expr,bnds );
3074 }
3075 else
3076 {
3077 auto expr = lambda.tr() * gismo::expr::uv(m_component,3)*meas(Gori);
3078 return ev.integralBdr( expr,bnds );
3079 }
3080 }
3081 else if (m_goalFunction == GoalFunction::PStrain)
3082 {
3083 if (m_component==9)
3084 {
3085 auto expr = Emp * Emp.tr() * meas(Gori);
3086 return ev.integralBdr( expr,bnds );
3087 }
3088 else
3089 {
3090 auto expr = Emp * gismo::expr::uv(m_component,3) * meas(Gori);
3091 return ev.integralBdr( expr,bnds );
3092 }
3093 }
3094 else if (m_goalFunction == GoalFunction::PStress)
3095 {
3096 if (m_component==9)
3097 {
3098 auto expr = P0.tr() * P0 * meas(Gori);
3099 return ev.integralBdr( expr,bnds );
3100 }
3101 else
3102 {
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 );
3106 }
3107 }
3108 else if (m_goalFunction == GoalFunction::MembraneStrain)
3109 {
3110 if (m_component==9)
3111 {
3112 // auto expr = Em * Em.tr() * meas(Gori);
3113 auto expr = Em.sqNorm() * meas(Gori);
3114 return ev.integralBdr( expr,bnds );
3115 }
3116 else
3117 {
3118 auto expr = Em * gismo::expr::uv(m_component,3) * meas(Gori);
3119 return ev.integralBdr( expr,bnds );
3120 }
3121 }
3122 else if (m_goalFunction == GoalFunction::MembraneStress)
3123 {
3124 if (m_component==9)
3125 {
3126 auto expr = S0.tr() * S0 * meas(Gori);
3127 return ev.integralBdr( expr,bnds );
3128 }
3129 else
3130 {
3131 auto expr = S0.tr() * gismo::expr::uv(m_component,3) * meas(Gori);
3132 return ev.integralBdr( expr,bnds );
3133 }
3134 }
3135 else if (m_goalFunction == GoalFunction::MembraneForce)
3136 {
3137 if (m_component==9)
3138 {
3139 auto expr = N.tr() * N * meas(Gori);
3140 return ev.integralBdr( expr,bnds );
3141 }
3142 else
3143 {
3144 auto expr = N.tr() * gismo::expr::uv(m_component,3) * meas(Gori);
3145 return ev.integralBdr( expr,bnds );
3146 }
3147 }
3148 else if (m_goalFunction == GoalFunction::FlexuralStrain)
3149 {
3150 if (m_component==9)
3151 {
3152 auto expr = Ef * Ef.tr() * meas(Gori);
3153 return ev.integralBdr( expr,bnds );
3154 }
3155 else
3156 {
3157 auto expr = Ef * gismo::expr::uv(m_component,3) * meas(Gori);
3158 return ev.integralBdr( expr,bnds );
3159 }
3160 }
3161 else if (m_goalFunction == GoalFunction::FlexuralStress)
3162 {
3163 if (m_component==9)
3164 {
3165 auto expr = S1.tr() * S1 * meas(Gori);
3166 return ev.integralBdr( expr,bnds );
3167 }
3168 else
3169 {
3170 auto expr = S1.tr() * gismo::expr::uv(m_component,3) * meas(Gori);
3171 return ev.integralBdr( expr,bnds );
3172 }
3173 }
3174 else if (m_goalFunction == GoalFunction::FlexuralMoment)
3175 {
3176 if (m_component==9)
3177 {
3178 auto expr = M.tr() * M * meas(Gori);
3179 return ev.integralBdr( expr,bnds );
3180 }
3181 else
3182 {
3183 auto expr = M.tr() * gismo::expr::uv(m_component,3) * meas(Gori);
3184 return ev.integralBdr( expr,bnds );
3185 }
3186 }
3187 else
3188 GISMO_ERROR("Goal function not known");
3189}
3190
3191template <short_t d, class T, bool bending>
3192T gsThinShellAssemblerDWR<d, T, bending>::computeGoal(const gsMatrix<T> & points, const gsMultiPatch<T> & deformed)
3193{
3194 if (points.cols()==0) return 0;
3195
3196 gsMatrix<T> Z(1,1);
3197 Z.setZero();
3198
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"));
3203
3204
3205 // Initialize vector
3206 exprAssembler.initSystem();
3207 exprAssembler.initVector(1);
3208
3209 // Geometries
3210 geometryMap Gori = exprAssembler.getMap(m_patches); // this map is used for integrals
3211 geometryMap Gdef = exprAssembler.getMap(deformed);
3212
3213 // Transformation for stretches
3214 gsMaterialMatrixEval<T,MaterialOutput::StretchTransform> Tstretchf(m_assemblerH->materials(),&deformed,Z);
3215 auto Tstretch = exprAssembler.getCoeff(Tstretchf);
3216 // Material tensors
3217
3218 // Stress tensors
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);
3223
3224 // Force tensors
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);
3229
3230 // Principal stress tensors
3231 gsMaterialMatrixEval<T,MaterialOutput::PStress> P0f(m_assemblerH->materials(),&deformed,Z);
3232 auto P0 = exprAssembler.getCoeff(P0f);
3233
3234 // // Helper matrix for flexural components
3235 gsFunctionExpr<T> mult2t("1","0","0","0","1","0","0","0","2",2);
3236 auto m2 = exprAssembler.getCoeff(mult2t);
3237
3238 // Deformation gradient
3239 // To compensate for the flat, since flat does [E11,E22,2*E12]
3240 gsFunctionExpr<T> mult12t("1","0","0","0","1","0","0","0","0.5",2);
3241 auto m12 = exprAssembler.getCoeff(mult12t);
3242
3243 auto Cm = flat( jac(Gdef).tr() * jac(Gdef) ) * reshape(m12,3,3);
3244
3245 // Principal stretch
3246 auto lambda = reshape(Tstretch,3,3).tr() * Cm.tr();
3247
3248 // Membrane strain
3249 auto Em = 0.5 * ( flat(jac(Gdef).tr()*jac(Gdef)) - flat(jac(Gori).tr()* jac(Gori)) ) ;
3250
3251 // Principal membrane strain
3252 auto Emp = (Em * reshape(m12,3,3)) * reshape(Tstretch,3,3).tr();
3253
3254 // Flexural strain
3255 auto Ef = ( deriv2(Gori,sn(Gori).normalized().tr()) - deriv2(Gdef,sn(Gdef).normalized().tr()) ) * reshape(m2,3,3) ;
3256
3257 // Membrane force (its first variation)
3258 // auto N_der = Em_der * reshape(mmA,3,3) + Ef_der * reshape(mmB,3,3);
3259
3260 gsExprEvaluator<T> ev(exprAssembler);
3261 T result = 0;
3262 gsMatrix<T> tmp;
3263 if (m_goalFunction == GoalFunction::Displacement)
3264 {
3265 if (m_component==9)
3266 {
3267 auto expr = (Gdef - Gori).tr() * (Gdef - Gori) * meas(Gori);
3268 for (index_t k = 0; k!=points.cols(); k++)
3269 {
3270 tmp = ev.eval( expr, points.col(k));
3271 GISMO_ASSERT(tmp.cols()==tmp.rows() && tmp.cols()==1,"Goal function must be scalar!");
3272 result += tmp(0,0);
3273 }
3274 return result;
3275 }
3276 else
3277 {
3278 auto expr = (Gdef - Gori).tr() * gismo::expr::uv(m_component,3)*meas(Gori);
3279 for (index_t k = 0; k!=points.cols(); k++)
3280 {
3281 tmp = ev.eval( expr, points.col(k));
3282 GISMO_ASSERT(tmp.cols()==tmp.rows() && tmp.cols()==1,"Goal function must be scalar!");
3283 result += tmp(0,0);
3284 }
3285 return result;
3286 }
3287 }
3288 else if (m_goalFunction == GoalFunction::Stretch)
3289 {
3290 /*
3291 NOTE:
3292 - Cm * Transformation does only give the in-plane stretches, since C is constructed with the in-plane jacobians (Gdef) only. In fact, Cm should have a third entry with the Jacobian Determinant J0, but this one is hard to compute the variations for.
3293 */
3294 if (m_component==9)
3295 {
3296 // gsMaterialMatrixEval<T,MaterialOutput::Stretch> lambdaf(m_assemblerH->materials(),&deformed,Z);
3297 // auto lambda = exprAssembler.getCoeff(lambdaf);
3298 // auto expr1 = gismo::expr::pow(lambda.tr() * lambda,2) * meas(Gori);
3299 auto expr = lambda.tr() * lambda * meas(Gori);
3300 for (index_t k = 0; k!=points.cols(); k++)
3301 {
3302 tmp = ev.eval( expr, points.col(k));
3303 GISMO_ASSERT(tmp.cols()==tmp.rows() && tmp.cols()==1,"Goal function must be scalar!");
3304 result += tmp(0,0);
3305 }
3306 return result;
3307 }
3308 else
3309 {
3310 auto expr = (Gdef - Gori).tr() * gismo::expr::uv(m_component,3)*meas(Gori);
3311 for (index_t k = 0; k!=points.cols(); k++)
3312 {
3313 tmp = ev.eval( expr, points.col(k));
3314 GISMO_ASSERT(tmp.cols()==tmp.rows() && tmp.cols()==1,"Goal function must be scalar!");
3315 result += tmp(0,0);
3316 }
3317 return result;
3318 }
3319 }
3320 else if (m_goalFunction == GoalFunction::PStrain)
3321 {
3322 if (m_component==9)
3323 {
3324 auto expr = Emp * Emp.tr() * meas(Gori);
3325 for (index_t k = 0; k!=points.cols(); k++)
3326 {
3327 tmp = ev.eval( expr, points.col(k));
3328 GISMO_ASSERT(tmp.cols()==tmp.rows() && tmp.cols()==1,"Goal function must be scalar!");
3329 result += tmp(0,0);
3330 }
3331 return result;
3332 }
3333 else
3334 {
3335 auto expr = Emp * gismo::expr::uv(m_component,3) * meas(Gori);
3336 for (index_t k = 0; k!=points.cols(); k++)
3337 {
3338 tmp = ev.eval( expr, points.col(k));
3339 GISMO_ASSERT(tmp.cols()==tmp.rows() && tmp.cols()==1,"Goal function must be scalar!");
3340 result += tmp(0,0);
3341 }
3342 return result;
3343 }
3344 }
3345 else if (m_goalFunction == GoalFunction::PStress)
3346 {
3347 if (m_component==9)
3348 {
3349 auto expr = P0.tr() * P0 * meas(Gori);
3350 for (index_t k = 0; k!=points.cols(); k++)
3351 {
3352 tmp = ev.eval( expr, points.col(k));
3353 GISMO_ASSERT(tmp.cols()==tmp.rows() && tmp.cols()==1,"Goal function must be scalar!");
3354 result += tmp(0,0);
3355 }
3356 return result;
3357 }
3358 else
3359 {
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++)
3363 {
3364 tmp = ev.eval( expr, points.col(k));
3365 GISMO_ASSERT(tmp.cols()==tmp.rows() && tmp.cols()==1,"Goal function must be scalar!");
3366 result += tmp(0,0);
3367 }
3368 return result;
3369 }
3370 }
3371 else if (m_goalFunction == GoalFunction::MembraneStrain)
3372 {
3373 if (m_component==9)
3374 {
3375 auto expr = Em * Em.tr() * meas(Gori);
3376 for (index_t k = 0; k!=points.cols(); k++)
3377 {
3378 tmp = ev.eval( expr, points.col(k));
3379 GISMO_ASSERT(tmp.cols()==tmp.rows() && tmp.cols()==1,"Goal function must be scalar!");
3380 result += tmp(0,0);
3381 }
3382 return result;
3383 }
3384 else
3385 {
3386 auto expr = Em * gismo::expr::uv(m_component,3) * meas(Gori);
3387 for (index_t k = 0; k!=points.cols(); k++)
3388 {
3389 tmp = ev.eval( expr, points.col(k));
3390 GISMO_ASSERT(tmp.cols()==tmp.rows() && tmp.cols()==1,"Goal function must be scalar!");
3391 result += tmp(0,0);
3392 }
3393 return result;
3394 }
3395 }
3396 else if (m_goalFunction == GoalFunction::MembraneStress)
3397 {
3398 if (m_component==9)
3399 {
3400 auto expr = S0.tr() * S0 * meas(Gori);
3401 for (index_t k = 0; k!=points.cols(); k++)
3402 {
3403 tmp = ev.eval( expr, points.col(k));
3404 GISMO_ASSERT(tmp.cols()==tmp.rows() && tmp.cols()==1,"Goal function must be scalar!");
3405 result += tmp(0,0);
3406 }
3407 return result;
3408 }
3409 else
3410 {
3411 auto expr = S0.tr() * gismo::expr::uv(m_component,3) * meas(Gori);
3412 for (index_t k = 0; k!=points.cols(); k++)
3413 {
3414 tmp = ev.eval( expr, points.col(k));
3415 GISMO_ASSERT(tmp.cols()==tmp.rows() && tmp.cols()==1,"Goal function must be scalar!");
3416 result += tmp(0,0);
3417 }
3418 return result;
3419 }
3420 }
3421 else if (m_goalFunction == GoalFunction::MembraneForce)
3422 {
3423 if (m_component==9)
3424 {
3425 auto expr = N.tr() * N * meas(Gori);
3426 for (index_t k = 0; k!=points.cols(); k++)
3427 {
3428 tmp = ev.eval( expr, points.col(k));
3429 GISMO_ASSERT(tmp.cols()==tmp.rows() && tmp.cols()==1,"Goal function must be scalar!");
3430 result += tmp(0,0);
3431 }
3432 return result;
3433 }
3434 else
3435 {
3436 auto expr = N.tr() * gismo::expr::uv(m_component,3) * meas(Gori);
3437 for (index_t k = 0; k!=points.cols(); k++)
3438 {
3439 tmp = ev.eval( expr, points.col(k));
3440 GISMO_ASSERT(tmp.cols()==tmp.rows() && tmp.cols()==1,"Goal function must be scalar!");
3441 result += tmp(0,0);
3442 }
3443 return result;
3444 }
3445 }
3446 else if (m_goalFunction == GoalFunction::FlexuralStrain)
3447 {
3448 if (m_component==9)
3449 {
3450 auto expr = Ef * Ef.tr() * meas(Gori);
3451 for (index_t k = 0; k!=points.cols(); k++)
3452 {
3453 tmp = ev.eval( expr, points.col(k));
3454 GISMO_ASSERT(tmp.cols()==tmp.rows() && tmp.cols()==1,"Goal function must be scalar!");
3455 result += tmp(0,0);
3456 }
3457 return result;
3458 }
3459 else
3460 {
3461 auto expr = Ef * gismo::expr::uv(m_component,3) * meas(Gori);
3462 for (index_t k = 0; k!=points.cols(); k++)
3463 {
3464 tmp = ev.eval( expr, points.col(k));
3465 GISMO_ASSERT(tmp.cols()==tmp.rows() && tmp.cols()==1,"Goal function must be scalar!");
3466 result += tmp(0,0);
3467 }
3468 return result;
3469 }
3470 }
3471 else if (m_goalFunction == GoalFunction::FlexuralStress)
3472 {
3473 if (m_component==9)
3474 {
3475 auto expr = S1.tr() * S1 * meas(Gori);
3476 for (index_t k = 0; k!=points.cols(); k++)
3477 {
3478 tmp = ev.eval( expr, points.col(k));
3479 GISMO_ASSERT(tmp.cols()==tmp.rows() && tmp.cols()==1,"Goal function must be scalar!");
3480 result += tmp(0,0);
3481 }
3482 return result;
3483 }
3484 else
3485 {
3486 auto expr = S1.tr() * gismo::expr::uv(m_component,3) * meas(Gori);
3487 for (index_t k = 0; k!=points.cols(); k++)
3488 {
3489 tmp = ev.eval( expr, points.col(k));
3490 GISMO_ASSERT(tmp.cols()==tmp.rows() && tmp.cols()==1,"Goal function must be scalar!");
3491 result += tmp(0,0);
3492 }
3493 return result;
3494 }
3495 }
3496 else if (m_goalFunction == GoalFunction::FlexuralMoment)
3497 {
3498 if (m_component==9)
3499 {
3500 auto expr = M.tr() * M * meas(Gori);
3501 for (index_t k = 0; k!=points.cols(); k++)
3502 {
3503 tmp = ev.eval( expr, points.col(k));
3504 GISMO_ASSERT(tmp.cols()==tmp.rows() && tmp.cols()==1,"Goal function must be scalar!");
3505 result += tmp(0,0);
3506 }
3507 return result;
3508 }
3509 else
3510 {
3511 auto expr = M.tr() * gismo::expr::uv(m_component,3) * meas(Gori);
3512 for (index_t k = 0; k!=points.cols(); k++)
3513 {
3514 tmp = ev.eval( expr, points.col(k));
3515 GISMO_ASSERT(tmp.cols()==tmp.rows() && tmp.cols()==1,"Goal function must be scalar!");
3516 result += tmp(0,0);
3517 }
3518 return result;
3519 }
3520 }
3521 else
3522 GISMO_ERROR("Goal function not known");
3523
3524}
3525
3526template <short_t d, class T, bool bending>
3527T gsThinShellAssemblerDWR<d, T, bending>::matrixNorm(const gsMultiPatch<T> &primal, const gsMultiPatch<T> &other) const
3528{
3529 GISMO_ASSERT(m_goalFunction==GoalFunction::Modal,"Only available for modal goal function");
3530
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"));
3535
3536 // Geometries
3537 geometryMap Gori = exprAssembler.getMap(m_patches); // this map is used for integrals
3538
3539 // Initialize vector
3540 exprAssembler.initSystem();
3541 exprAssembler.initVector(1);
3542
3543 gsMaterialMatrixIntegrate<T,MaterialOutput::Density> rhof(m_assemblerH->materials(),&m_patches); // note: is this right?
3544 auto rho = exprAssembler.getCoeff(rhof);
3545
3546 auto usol = exprAssembler.getCoeff(primal);
3547 auto zsol = exprAssembler.getCoeff(other);
3548
3549 gsExprEvaluator<T> ev(exprAssembler);
3550 return ev.integral(rho.val() * usol.tr() * zsol * meas(Gori));
3551}
3552
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
3555{
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"));
3561
3562 gsMultiPatch<T> defpatches = deformed;
3563
3564 // Geometries
3565 geometryMap Gori = exprAssembler.getMap(m_patches); // this map is used for integrals
3566 geometryMap Gdef = exprAssembler.getMap(defpatches);
3567
3568 // Initialize vector
3569 exprAssembler.initSystem();
3570 exprAssembler.initVector(1);
3571
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);
3580
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);
3589
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);
3594
3595 gsFunctionExpr<T> mult2t("1","0","0","0","1","0","0","0","2",2);
3596 auto m2 = exprAssembler.getCoeff(mult2t);
3597
3598 auto usol = exprAssembler.getCoeff(primal);
3599 auto zsol = exprAssembler.getCoeff(other);
3600
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);
3603
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);
3606
3607
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);
3610
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);
3614
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);
3617
3618 auto Em_der2 = flat( jac(usol).tr() * ( jac(zsol ) ) ) * N_NL.tr();
3619
3620 auto M_NL = S1.tr(); // output is a column
3621 auto Ef_der2 = -(
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)
3625 ) * M_NL.tr();
3626
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);
3629
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 );
3632
3633 auto Bprimal = K_NL - K_L ;
3634
3635 auto expr = ( Bprimal ) * meas(Gori);
3636
3637 gsExprEvaluator<T> ev(exprAssembler);
3638 T integral = ev.integral(expr);
3639
3640 if (m_foundInd)
3641 {
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");
3644
3645 integral += ev.integral( zsol * foundation.asDiag() * (Gdef - Gori) * meas(Gori) ); // [v_x,v_y,v_z] diag([k_x,k_y,k_z]) [u_x; u_y; u_z]
3646 }
3647 if (m_pressInd)
3648 {
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");
3651
3652 integral += ev.integral( pressure.val() * zsol * sn(Gdef).normalized() * meas(Gori) );
3653 }
3654
3655 return integral;
3656}
3657
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
3660{
3661
3662 for (size_t i = 0; i<m_pLoads.numLoads(); ++i )
3663 {
3664 if (m_pLoads[i].value.size()!=d)
3665 gsWarn<<"Point load has wrong dimension "<<m_pLoads[i].value.size()<<" instead of "<<d<<"\n";
3666 // Compute actives and values of basis functions on point load location.
3667 gsMatrix<T> forcePoint;
3668 if ( m_pLoads[i].parametric ) // in parametric space
3669 forcePoint = m_pLoads[i].point;
3670 else // in physical space
3671 m_patches.patch(m_pLoads[i].patch).invertPoints(m_pLoads[i].point,forcePoint);
3672
3673 std::vector<index_t> elements;
3674
3675 #pragma omp parallel
3676 {
3677 std::vector<index_t> elements_private;
3678#ifdef _OPENMP
3679 const int tid = omp_get_thread_num();
3680 const int nt = omp_get_num_threads();
3681 index_t patch_cnt = 0;
3682#endif
3683
3684 index_t c = 0;
3685 for (unsigned patchInd=0; patchInd < m_assemblerH->getBasis().nBases(); ++patchInd)
3686 {
3687 // Initialize domain element iterator
3688 typename gsBasis<T>::domainIter domIt =
3689 m_assemblerH->getBasis().piece(patchInd).makeDomainIterator();
3690
3691#ifdef _OPENMP
3692 c = patch_cnt + tid;
3693 patch_cnt += domIt->numElements();// a bit costy
3694 for ( domIt->next(tid); domIt->good(); domIt->next(nt) )
3695#else
3696 for (; domIt->good(); domIt->next() )
3697#endif
3698 {
3699 bool test = !(((((forcePoint - domIt->lowerCorner()).array() >= 0) &&
3700 (domIt->upperCorner() - forcePoint).array() >= 0) ).array() == 0).any();
3701 if (test)
3702 elements_private.push_back(c);
3703 #ifdef _OPENMP
3704 c += nt;
3705 #else
3706 c++;
3707 #endif
3708 }
3709#pragma omp critical
3710 elements.insert(elements.end(), elements_private.begin(), elements_private.end());
3711 }
3712 }
3713
3714 // Compute load value on the point
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;
3719 // Distribute load over all the elements
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();
3723 }
3724}
3725
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
3728{
3729
3730 for (size_t i = 0; i< m_pLoads.numLoads(); ++i )
3731 {
3732 if (m_pLoads[i].value.size()!=d)
3733 gsWarn<<"Point load has wrong dimension "<<m_pLoads[i].value.size()<<" instead of "<<d<<"\n";
3734 // Compute actives and values of basis functions on point load location.
3735 gsMatrix<T> forcePoint;
3736 if ( m_pLoads[i].parametric ) // in parametric space
3737 forcePoint = m_pLoads[i].point;
3738 else // in physical space
3739 m_patches.patch(m_pLoads[i].patch).invertPoints(m_pLoads[i].point,forcePoint);
3740
3741 // Compute load value on the point
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;
3746 // Add load tot total error
3747 error += result(0,0);
3748 }
3749}
3750
3751
3752} // namespace gismo
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