40 for (
int i=0; i<sz; i++) {
49 double xval,yval,xvalimag,yvalimag;
50 xval = x.
val().real();
51 yval = y.
val().real();
52 xvalimag = x.
val().imag();
53 yvalimag = y.
val().imag();
54 if(
abs(xvalimag) > 1.e-12 ||
abs(yvalimag)> 1.e-12)
58 REAL angle =
atan2(yval,xval);
60 double r = xval*xval+yval*yval;
61 for (
int i=0; i<sz; i++) {
68 static FADFADSTATE FADatan2(FADFADSTATE y, FADFADSTATE x)
71 FADFADSTATE result(sz,
atan2(y.val(),x.val()));
73 for (
int i=0; i<sz; i++) {
74 result.fastAccessDx(i) = (-y.val()*x.fastAccessDx(i) + x.val()*y.fastAccessDx(i))/r;
79 static FADFADSTATE FADsin(FADFADSTATE x)
85 FADFADSTATE sina(sz,sinaval);
86 for (
int i=0; i<sz; i++) {
87 sina.fastAccessDx(i) = cosaval*x.dx(i);
92 static FADFADSTATE FADcos(FADFADSTATE x)
97 FADFADSTATE cosa(sz,cosaval);
98 for (
int i=0; i<sz; i++) {
99 cosa.fastAccessDx(i) = -sinaval*x.
dx(i);
104 static FADFADSTATE FADexp(FADFADSTATE x)
108 FADFADSTATE expa(sz,expaval);
109 for (
int i=0; i<sz; i++) {
110 expa.fastAccessDx(i) = expaval*x.
dx(i);
115 static FADFADSTATE FADsqrt(FADFADSTATE x)
119 FADFADSTATE resa(sz,fadres);
120 for (
int i=0; i<sz; i++) {
121 resa.fastAccessDx(i) = REAL(0.5)/fadres*x.
dx(i);
126 static FADFADSTATE FADatan(FADFADSTATE x)
130 FADFADSTATE resa(sz,fadres);
131 for (
int i=0; i<sz; i++) {
132 resa.fastAccessDx(i) = 1./(1.+x.val()*x.val())*x.dx(i);
137 static FADFADSTATE FADcosh(FADFADSTATE x)
142 FADFADSTATE resa(sz,coshval);
143 for (
int i=0; i<sz; i++) {
144 resa.fastAccessDx(i) = sinhval*x.dx(i);
149 static FADFADSTATE FADsinh(FADFADSTATE x)
154 FADFADSTATE resa(sz,sinhval);
155 for (
int i=0; i<sz; i++) {
156 resa.fastAccessDx(i) = coshval*x.
dx(i);
161 static const REAL FI = 1.;
162 static const REAL a = 0.5;
163 static const REAL b = 0.5;
166 std::cout <<
"TPZAnalyticSolution::TPZAnalyticSolution(const TPZAnalyticSolution &cp): One should not invoke this copy constructor";
171 std::cout <<
"TPZAnalyticSolution & TPZAnalyticSolution::operator=(const TPZAnalyticSolution ©): One should not invoke this copy constructor";
177 REAL TElasticity2DAnalytic::gE = 1.;
179 REAL TElasticity2DAnalytic::gPoisson = 0.3;
181 int TElasticity2DAnalytic::gOscilatoryElasticity = 0;
183 TElasticity2DAnalytic::TElasticity2DAnalytic(
const TElasticity2DAnalytic &cp) :
TPZAnalyticSolution(cp),fProblemType(cp.fProblemType) {
184 std::cout <<
"TElasticity2DAnalytic::TElasticity2DAnalytic(const TElasticity2DAnalytic &cp): One should not invoke this copy constructor";
188 TElasticity2DAnalytic & TElasticity2DAnalytic::operator=(
const TElasticity2DAnalytic ©){
189 fProblemType = copy.fProblemType;
191 gPoisson = copy.gPoisson;
198 typedef FADFADSTATE TVar;
199 if(fProblemType == Etest1)
201 FADFADSTATE
tmp = (FADFADSTATE)(1./27.)*x[0]*x[0]*x[1]*x[1];
202 disp[0] = tmp*FADcos((FADFADSTATE)(6.*M_PI)*x[0])*FADsin((FADFADSTATE)(7.*M_PI)*x[1]);
203 disp[1] = (FADFADSTATE)(0.2)*FADexp(x[1])*FADsin((FADFADSTATE)(4.*M_PI)*x[0]);
206 else if(fProblemType == Etest2)
210 disp[0] = ((1.-x[0]*x[0])*(1.+x[1]*x[1]*x[1]*x[1]));
211 disp[1] = ((1.-x[1]*x[1])*(1.+x[0]*x[0]*x[0]*x[0]));
214 else if(fProblemType ==ERot)
218 disp[0] =(FADFADSTATE)-x[1];
219 disp[1] =(FADFADSTATE) x[0];
223 else if(fProblemType == EShear)
227 disp[0] += (FADFADSTATE) x[1];
228 disp[1] += (FADFADSTATE) 0. ;
230 else if(fProblemType == EStretchx)
234 disp[0] += (FADFADSTATE) x[0];
235 disp[1] += (FADFADSTATE) 0.;
237 else if(fProblemType == EUniAxialx)
239 if (fPlaneStress == 0) {
240 disp[0] = x[0]*(1.-gPoisson*gPoisson)/gE;
241 disp[1] = -x[1]*(1.+gPoisson)*gPoisson/gE;
246 disp[1] = -x[1]*gPoisson/gE;
249 else if(fProblemType ==EStretchy)
253 disp[0] += (FADFADSTATE) 0.;
254 disp[1] += (FADFADSTATE) x[1];
256 else if(fProblemType==EDispx)
263 else if(fProblemType==EDispy)
267 disp[0] += (FADFADSTATE) 0.;
268 disp[0] += (FADFADSTATE) 1.;
270 else if (fProblemType == EThiago){
271 disp[0] = FADcos(M_PI * x[0]) * FADsin(2 * M_PI * x[1]);
272 disp[1] = FADcos(M_PI * x[1]) * FADsin(M_PI * x[0]);
273 }
else if(fProblemType == EPoly){
275 disp[1] = x[1] * x[0];
276 }
else if(fProblemType==EBend)
278 typedef TVar FADFADSTATE;
279 TVar poiss = gPoisson;
281 if(fPlaneStress == 0)
283 poiss = poiss/(1.-poiss);
284 elast /= (1-gPoisson*gPoisson);
286 disp[0] = 5.*x[0]*x[1]/elast;
287 disp[1] = (-poiss*5.*x[1]*x[1]/2.-5.*x[0]*x[0]/2.)/elast;
290 else if(fProblemType == ELoadedBeam)
294 G = gE/(2.*(1.+gPoisson));
295 if (fPlaneStress == 0) {
296 Est = gE/((1.-gPoisson*gPoisson));
297 nust = gPoisson/(1-gPoisson);
306 disp[0] = MI*
h*
h*x[1]/(2.*G)+ MI*x[0]*x[0]*x[1]/(2.*Est)-MI *x[1]*x[1]*x[1]/(6.*G)+MI*nust*x[1]*x[1]*x[1]/(6.*Est);
307 disp[1] = -MI*x[0]*x[0]*x[0]/(6.*Est)-MI*nust*x[0]*x[1]*x[1]/(2.*Est);
309 else if(fProblemType == ESquareRoot)
311 TVar Est,nust,G, kappa;
312 TVar theta = FADatan2(x[1],x[0]);
313 TVar r = FADsqrt(x[0]*x[0]+x[1]*x[1]);
314 G = gE/(2.*(1.+gPoisson));
315 if (fPlaneStress == 0) {
318 Est = gE/((1.-gPoisson*gPoisson));
319 nust = gPoisson/(1.-gPoisson);
320 kappa = 3.-4.*gPoisson;
326 kappa = (3.-gPoisson)/(1.+gPoisson);
328 TVar costh = FADcos(theta/2.);
329 TVar sinth = FADsin(theta/2.);
330 disp[0] = 1./(2.*G)*FADsqrt(r/(2.*M_PI))*costh*(kappa-1.+2.*sinth*sinth);
331 disp[1] = 1./(2.*G)*FADsqrt(r/(2.*M_PI))*sinth*(kappa+1.-2.*costh*costh);
333 else if(fProblemType == ESquareRootLower)
335 TVar Est,nust,G, kappa;
336 TVar theta = FADatan2(x[1],x[0]);
340 TVar r = FADsqrt(x[0]*x[0]+x[1]*x[1]);
341 G = gE/(2.*(1.+gPoisson));
342 if (fPlaneStress == 0) {
345 Est = gE/((1.-gPoisson*gPoisson));
346 nust = gPoisson/(1.-gPoisson);
347 kappa = 3.-4.*gPoisson;
353 kappa = (3.-gPoisson)/(1.+gPoisson);
355 TVar costh = FADcos(theta/2.);
356 TVar sinth = FADsin(theta/2.);
357 disp[0] = 1./(2.*G)*FADsqrt(r/(2.*M_PI))*costh*(kappa-1.+2.*sinth*sinth);
358 disp[1] = 1./(2.*G)*FADsqrt(r/(2.*M_PI))*sinth*(kappa+1.-2.*costh*costh);
360 else if(fProblemType == ESquareRootUpper)
362 TVar Est,nust,G, kappa;
363 TVar theta = FADatan2(x[1],x[0]);
367 TVar r = FADsqrt(x[0]*x[0]+x[1]*x[1]);
368 G = gE/(2.*(1.+gPoisson));
369 if (fPlaneStress == 0) {
372 Est = gE/((1.-gPoisson*gPoisson));
373 nust = gPoisson/(1.-gPoisson);
374 kappa = 3.-4.*gPoisson;
380 kappa = (3.-gPoisson)/(1.+gPoisson);
382 TVar costh = FADcos(theta/2.);
383 TVar sinth = FADsin(theta/2.);
384 disp[0] = 1./(2.*G)*FADsqrt(r/(2.*M_PI))*costh*(kappa-1.+2.*sinth*sinth);
385 disp[1] = 1./(2.*G)*FADsqrt(r/(2.*M_PI))*sinth*(kappa+1.-2.*costh*costh);
393 template<
typename TVar1,
typename TVar2>
396 if (fProblemType == Etest1) {
397 disp[0] = TVar2(1. / 27.) * x[0] * x[0] * x[1] * x[1] *
cos(TVar2(6. * M_PI) * x[0]) *
sin(TVar2(7. * M_PI) * x[1]);
398 disp[1] = TVar2(0.2) *
exp(x[1]) *
sin(TVar2(4. * M_PI) * x[0]);
399 }
else if (fProblemType == Etest2) {
402 disp[0] = ((TVar2(1) - x[0] * x[0])*(1. + x[1] * x[1] * x[1] * x[1]));
403 disp[1] = ((TVar2(1) - x[1] * x[1])*(1. + x[0] * x[0] * x[0] * x[0]));
405 else if (fProblemType == ERot)
407 disp[0] = (TVar2) - x[1];
408 disp[1] = (TVar2) x[0];
410 else if (fProblemType == EShear)
414 disp[0] += (TVar2) x[1];
415 disp[1] += (TVar2) 0.;
416 }
else if (fProblemType == EStretchx)
420 disp[0] += (TVar2) x[0];
421 disp[1] += (TVar2) 0.;
422 }
else if (fProblemType == EUniAxialx) {
423 if (fPlaneStress == 0) {
424 disp[0] = x[0]*(1. - gPoisson * gPoisson) / gE;
425 disp[1] = -x[1]*(1. + gPoisson) * gPoisson / gE;
428 disp[1] = -x[1] * gPoisson / gE;
430 }
else if (fProblemType == EStretchy)
434 disp[0] += (TVar2) 0.;
435 disp[1] += (TVar2) x[1];
436 }
else if (fProblemType == EDispx) {
441 }
else if (fProblemType == EDispy) {
444 disp[0] += (TVar2) 0.;
445 disp[0] += (TVar2) 1.;
446 }
else if (fProblemType == EThiago){
451 disp[0] = (TVar2)
cos(M_PI * x[0])*(TVar2)
sin(2 * M_PI * x[1]);
452 disp[1] = (TVar2)
cos(M_PI * x[1])*(TVar2)
sin(M_PI * x[0]);
453 }
else if(fProblemType == EPoly){
455 disp[1] = x[1] * x[0];
456 }
else if (fProblemType == EBend) {
457 TVar2 poiss = gPoisson;
459 if (fPlaneStress == 0) {
460 poiss = poiss / (1. - poiss);
461 elast /= (1 - gPoisson * gPoisson);
463 disp[0] = 5. * x[0] * x[1] / elast;
464 disp[1] = (-poiss * 5. * x[1] * x[1] / 2. - 5. * x[0] * x[0] / 2.) / elast;
465 }
else if (fProblemType == ELoadedBeam) {
468 G = gE / (2. * (1. + gPoisson));
469 if (fPlaneStress == 0) {
472 Est = gE / ((1. - gPoisson * gPoisson));
473 nust = gPoisson / (1 - gPoisson);
478 disp[0] = MI *
h *
h * x[1] / (2. * G) + MI * x[0] * x[0] * x[1] / (2. * Est) - MI * x[1] * x[1] * x[1] / (6. * G) + MI * nust * x[1] * x[1] * x[1] / (6. * Est);
479 disp[1] = -MI * x[0] * x[0] * x[0] / (6. * Est) - MI * nust * x[0] * x[1] * x[1] / (2. * Est);
480 }
else if (fProblemType == ESquareRoot) {
484 TVar2 Est, nust, G, kappa;
485 TVar2 theta =
atan2(x[1], x[0]);
486 TVar2 r =
sqrt(x[0] * x[0] + x[1] * x[1]);
487 G = gE / (2. * (1. + gPoisson));
488 if (fPlaneStress == 0) {
491 Est = gE / ((1. - gPoisson * gPoisson));
492 nust = gPoisson / (1 - gPoisson);
493 kappa = 3. - 4. * gPoisson;
497 kappa = (3. - gPoisson) / (1 + gPoisson);
499 TVar2 costh =
cos(theta / 2.);
500 TVar2 sinth =
sin(theta / 2.);
501 disp[0] = 1 / (2. * G) *
sqrt(r / (2. * M_PI)) * costh * (kappa - 1. + 2. * sinth * sinth);
502 disp[1] = 1 / (2. * G) *
sqrt(r / (2. * M_PI)) * sinth * (kappa + 1. - 2. * costh * costh);
505 }
else if (fProblemType == ESquareRootLower) {
509 TVar2 Est, nust, G, kappa;
510 TVar2 theta =
atan2(x[1], x[0]);
512 theta -= (2. * M_PI);
514 TVar2 r =
sqrt(x[0] * x[0] + x[1] * x[1]);
515 G = gE / (2. * (1. + gPoisson));
516 if (fPlaneStress == 0) {
519 Est = gE / ((1. - gPoisson * gPoisson));
520 nust = gPoisson / (1 - gPoisson);
521 kappa = 3. - 4. * gPoisson;
525 kappa = (3. - gPoisson) / (1 + gPoisson);
527 TVar2 costh =
cos(theta / 2.);
528 TVar2 sinth =
sin(theta / 2.);
529 disp[0] = 1 / (2. * G) *
sqrt(r / (2. * M_PI)) * costh * (kappa - 1. + 2. * sinth * sinth);
530 disp[1] = 1 / (2. * G) *
sqrt(r / (2. * M_PI)) * sinth * (kappa + 1. - 2. * costh * costh);
533 }
else if (fProblemType == ESquareRootUpper) {
537 TVar2 Est, nust, G, kappa;
538 TVar2 theta =
atan2(x[1], x[0]);
540 theta += (2. * M_PI);
542 TVar2 r =
sqrt(x[0] * x[0] + x[1] * x[1]);
543 G = gE / (2. * (1. + gPoisson));
544 if (fPlaneStress == 0) {
547 Est = gE / ((1. - gPoisson * gPoisson));
548 nust = gPoisson / (1 - gPoisson);
549 kappa = 3. - 4. * gPoisson;
553 kappa = (3. - gPoisson) / (1 + gPoisson);
555 TVar2 costh =
cos(theta / 2.);
556 TVar2 sinth =
sin(theta / 2.);
557 disp[0] = 1 / (2. * G) *
sqrt(r / (2. * M_PI)) * costh * (kappa - 1. + 2. * sinth * sinth);
558 disp[1] = 1 / (2. * G) *
sqrt(r / (2. * M_PI)) * sinth * (kappa + 1. - 2. * costh * costh);
580 void TElasticity2DAnalytic::Elastic(
const TPZVec<TVar> &x, TVar &Elast, TVar &nu)
582 if(gOscilatoryElasticity != 0)
584 Elast = (TVar(100.) * (TVar(1.) + TVar(0.3) *
sin(TVar(10 * M_PI) * (x[0] - TVar(0.5))) *
cos(TVar(10. * M_PI) * x[1])));
606 for (
int i=0; i<xstate.size(); i++) {
610 STATE E = 1,nu = 0.3;
611 Elastic(xstate,E,nu);
621 for(
int i=0; i<3; i++)
627 for(
int j=0; j<3; j++)
629 temp.fastAccessDx(j) = temp3;
632 temp.fastAccessDx(i) = temp2;
640 for (
int i=0; i<2; i++) {
641 for (
int j=0; j<2; j++)
643 grad(j,i) = result[i].d(j);
663 for(
int i=0; i<3; i++) xst[i] = x[i];
671 for(
int i=0; i<2; i++)
680 u[0] = result[0].val();
681 u[1] = result[1].val();
682 for (
int i=0; i<2; i++) {
683 for (
int j=0; j<2; j++)
685 gradu(i,j) = result[j].d(i);
699 if (fPlaneStress == 0)
701 STATE Fac = E/((STATE)1.+nu)/((STATE(1.)-STATE(2.)*nu));
702 sigma(0,0) = Fac*((STATE(1.)-nu)*grad(0,0)+nu*grad(1,1));
703 sigma(1,1) = Fac*((STATE(1.)-nu)*grad(1,1)+nu*grad(0,0));
704 sigma(0,1) = E/(STATE(2.)*(STATE(1.)+nu))*(grad(0,1)+grad(1,0));
705 sigma(1,0) = sigma(0,1);
709 STATE Fac = E/((STATE)1.-nu*nu);
710 sigma(0,0) = Fac*(grad(0,0)+nu*grad(1,1));
711 sigma(1,1) = Fac*(grad(1,1)+nu*grad(0,0));
712 sigma(0,1) = E/(STATE(2.)*(STATE(1.)+nu))*(grad(0,1)+grad(1,0));
713 sigma(1,0) = sigma(0,1);
723 if (fPlaneStress == 0)
726 sigma(0,0) = Fac*((
Fad<STATE>(1.)-nu)*grad(0,0)+nu*grad(1,1));
727 sigma(1,1) = Fac*((
Fad<STATE>(1.)-nu)*grad(1,1)+nu*grad(0,0));
729 sigma(1,0) = sigma(0,1);
734 TVar Fac = E/((TVar)1.-nu*nu);
735 sigma(0,0) = Fac*(grad(0,0)+nu*grad(1,1));
736 sigma(1,1) = Fac*(grad(1,1)+nu*grad(0,0));
737 sigma(0,1) = E/(TVar(2.)*(TVar(1.)+nu))*(grad(0,1)+grad(1,0));
738 sigma(1,0) = sigma(0,1);
748 for(
int i=0; i<2; i++)
754 divsigma[0] = sigma(0,0).dx(0)+sigma(0,1).dx(1);
755 divsigma[1] = sigma(1,0).dx(0)+sigma(1,1).dx(1);
764 TElasticity3DAnalytic::TElasticity3DAnalytic(
const TElasticity3DAnalytic &cp) :
TPZAnalyticSolution(cp),fProblemType(cp.fProblemType),fE(cp.fE),fPoisson(cp.fPoisson) {
765 std::cout <<
"TElasticity3DAnalytic::TElasticity3DAnalytic(const TElasticity3DAnalytic &cp): One should not invoke this copy constructor";
769 TElasticity3DAnalytic & TElasticity3DAnalytic::operator=(
const TElasticity3DAnalytic ©){
770 fProblemType = copy.fProblemType;
772 fPoisson = copy.fPoisson;
780 if(fProblemType == Etest1)
782 disp[0] = TVar(1./27.)*x[0]*x[0]*x[1]*x[1]*
cos(TVar(6.*M_PI)*x[0])*
sin(TVar(7.*M_PI)*x[1]);
783 disp[1] = TVar(0.2)*
exp(x[1])*
sin(TVar(4.*M_PI)*x[0]);
784 disp[2] = x[0]*TVar(0.);
786 else if(fProblemType == Etest2)
790 disp[0] = ((1.-x[0]*x[0])*(1.+x[1]*x[1]*x[1]*x[1]));
791 disp[1] = ((1.-x[1]*x[1])*(1.+x[0]*x[0]*x[0]*x[0]));
792 disp[2] = x[0]*TVar(0.);
795 else if(fProblemType ==ERot)
799 disp[0] = (TVar)-x[1];
800 disp[1] = (TVar)x[0];
801 disp[2] = x[0]*TVar(0.);
804 else if(fProblemType == EShear)
808 disp[0] += (TVar) x[1];
809 disp[1] += (TVar) 0. ;
810 disp[2] = x[0]*TVar(0.);
812 else if(fProblemType == EStretchx)
816 disp[0] += (TVar) x[0];
817 disp[1] += (TVar) 0.;
818 disp[2] = x[0]*TVar(0.);
820 else if(fProblemType == EUniAxialx)
822 disp[0] += (TVar) x[0]/fE;
823 disp[1] += (TVar) -x[1]*fPoisson/fE;
824 disp[2] = -x[2]*fPoisson/fE;
826 else if(fProblemType ==EStretchy)
830 disp[0] += (TVar) 0.;
831 disp[1] += (TVar) x[1];
832 disp[2] = x[0]*TVar(0.);
834 else if(fProblemType==EDispx)
840 disp[2] = x[0]*TVar(0.);
842 else if(fProblemType==EDispy)
846 disp[0] += (TVar) 0.;
847 disp[0] += (TVar) 1.;
848 disp[2] = x[0]*TVar(0.);
850 else if(fProblemType==EBend)
852 TVar poiss = fPoisson;
854 disp[0] = 5.*x[0]*x[1]/elast;
855 disp[1] = (-poiss*5.*x[1]*x[1]/2.-5.*x[0]*x[0]/2.)/elast;
858 else if(fProblemType == ELoadedBeam)
860 TVar Est = fE,nust = fPoisson,G;
862 G = fE/(2.*(1.+fPoisson));
864 Est = fE/((1.-fPoisson*fPoisson));
865 nust = fPoisson/(1-fPoisson);
868 int i1 = (offset+1)%3;
869 int i2 = (offset+2)%3;
871 disp[i0] = MI*
h*
h*x[i1]/(2.*G)+MI * x[i0]*x[i0]*x[i1]/(2.*Est)-MI *x[i1]*x[i1]*x[i1]/(6.*G)+MI*nust*x[i1]*x[i1]*x[i1]/(6.*Est);
872 disp[i1] = -MI*x[i0]*x[i0]*x[i0]/(6.*Est)-MI*nust*x[i0]*x[i1]*x[i1]/(2.*Est);
875 else if(fProblemType == ETestShearMoment)
877 disp[0] = -((TVar) FI/fE*fPoisson) *x[0]*x[1]*x[2];
878 disp[1] = ((TVar) FI/fE) *((TVar)(fPoisson/2.)*(x[0]*x[0]-x[1]*x[1])*x[2]-((TVar)(1./6.)*x[2]*x[2]*x[2]));
879 TVar disp2A = FI/fE*(1./2.* x[1]*(fPoisson*x[0]*x[0]+x[2]*x[2])+1./6.*fPoisson*x[1]*x[1]*x[1]+(1.+fPoisson)*(b*b*x[1]-1./3.*x[1]*x[1]*x[1])-1./3.*a*a*fPoisson*x[1]);
880 TVar series = (TVar) 0.;
881 TVar minusone = (TVar) -1;
882 for (
int i=1; i<5; i++) {
883 series += (minusone/TVar(i*i*i)*
cos(i*M_PI*x[0]/a)*
sinh(i*M_PI*x[1]/a)/
cosh(i*M_PI*b/a));
884 minusone *= (TVar) -1.;
886 series *= (-4.*a*a*a*fPoisson/(M_PI*M_PI*M_PI));
887 disp[2] = disp2A+series;
889 else if(fProblemType == ESphere)
892 TVar radius2 = xc[0]*xc[0]+xc[1]*xc[1]+xc[2]*xc[2];
893 TVar radius =
sqrt(radius2);
894 TVar acube = 10.*10.*10.;
895 TVar bcube = 50.*50.*50.;
897 TVar ur = pi*acube/(2.*fE*(bcube-acube)*radius2)*(2.*(1.-2.*fPoisson)*radius2*radius+(1.+fPoisson)*bcube);
898 TVar cosphi = xc[2]/radius;
899 TVar xyradius =
sqrt(xc[0]*xc[0]+xc[1]*xc[1]);
900 TVar sinphi = xyradius/radius;
901 TVar costheta = xc[0]/xyradius;
902 TVar sintheta = xc[1]/xyradius;
904 disp[0] = ur*sinphi*costheta;
905 disp[1] = ur*sinphi*sintheta;
916 typedef FADFADSTATE TVar;
917 if(fProblemType == Etest1)
919 FADFADSTATE tmp = (FADFADSTATE)(1./27.)*x[0]*x[0]*x[1]*x[1];
920 disp[0] = tmp*FADcos((FADFADSTATE)(6.*M_PI)*x[0])*FADsin((FADFADSTATE)(7.*M_PI)*x[1]);
921 disp[1] = (FADFADSTATE)(0.2)*FADexp(x[1])*FADsin((FADFADSTATE)(4.*M_PI)*x[0]);
922 disp[2] = x[0]*TVar(0.);
925 else if(fProblemType == Etest2)
929 disp[0] = ((1.-x[0]*x[0])*(1.+x[1]*x[1]*x[1]*x[1]));
930 disp[1] = ((1.-x[1]*x[1])*(1.+x[0]*x[0]*x[0]*x[0]));
931 disp[2] = x[0]*TVar(0.);
934 else if(fProblemType ==ERot)
938 disp[0] =(FADFADSTATE)-x[1];
939 disp[1] =(FADFADSTATE) x[0];
940 disp[2] = x[0]*TVar(0.);
944 else if(fProblemType == EShear)
948 disp[0] += (FADFADSTATE) x[1];
949 disp[1] += (FADFADSTATE) 0. ;
950 disp[2] = x[0]*TVar(0.);
952 else if(fProblemType == EStretchx)
956 disp[0] += (FADFADSTATE) x[0];
957 disp[1] += (FADFADSTATE) 0.;
958 disp[2] = x[0]*TVar(0.);
960 else if(fProblemType == EUniAxialx)
962 disp[0] += (TVar) x[0]/fE;
963 disp[1] += (TVar) -x[1]*fPoisson/fE;
964 disp[2] = -x[2]*fPoisson/fE;
966 else if(fProblemType ==EStretchy)
970 disp[0] += (FADFADSTATE) 0.;
971 disp[1] += (FADFADSTATE) x[1];
972 disp[2] = x[0]*TVar(0.);
974 else if(fProblemType==EDispx)
980 disp[2] = x[0]*TVar(0.);
982 else if(fProblemType==EDispy)
986 disp[0] += (FADFADSTATE) 0.;
987 disp[0] += (FADFADSTATE) 1.;
988 disp[2] = x[0]*TVar(0.);
990 else if(fProblemType==EBend)
992 TVar poiss = fPoisson;
994 disp[0] = 5.*x[0]*x[1]/elast;
995 disp[1] = (-poiss*5.*x[1]*x[1]/2.-5.*x[0]*x[0]/2.)/elast;
998 else if(fProblemType == ELoadedBeam)
1000 TVar Est = fE,nust = fPoisson,G;
1001 REAL MI = 5,
h = 1.;
1002 G = fE/(2.*(1.+fPoisson));
1004 Est = fE/((1.-fPoisson*fPoisson));
1005 nust = fPoisson/(1.-fPoisson);
1008 int i1 = (offset+1)%3;
1009 int i2 = (offset+2)%3;
1011 disp[i0] = MI*
h*
h*x[i1]/(2.*G)+MI * x[i0]*x[i0]*x[i1]/(2.*Est)-MI *x[i1]*x[i1]*x[i1]/(6.*G)+MI*nust*x[i1]*x[i1]*x[i1]/(6.*Est);
1012 disp[i1] = -MI*x[i0]*x[i0]*x[i0]/(6.*Est)-MI*nust*x[i0]*x[i1]*x[i1]/(2.*Est);
1013 disp[i2] = x[i2]*0.;
1015 else if(fProblemType == ETestShearMoment)
1017 disp[0] = -((TVar) FI/fE*fPoisson) *x[0]*x[1]*x[2];
1018 disp[1] = ((TVar) FI/fE) *((TVar)(fPoisson/2.)*(x[0]*x[0]-x[1]*x[1])*x[2]-((TVar)(1./6.)*x[2]*x[2]*x[2]));
1019 TVar disp2A = FI/fE*(1./2.* x[1]*(fPoisson*x[0]*x[0]+x[2]*x[2])+1./6.*fPoisson*x[1]*x[1]*x[1]+(1.+fPoisson)*(b*b*x[1]-1./3.*x[1]*x[1]*x[1])-1./3.*a*a*fPoisson*x[1]);
1020 TVar series = (TVar) 0.;
1021 TVar minusone = (TVar) -1;
1022 for (
int i=1; i<5; i++) {
1024 series += (minusone/(TVar)(i*i*i)*FADcos(ivar*M_PI*x[0]/a)*FADsinh(ivar*M_PI*x[1]/a)/FADcosh(ivar*M_PI*b/a));
1025 minusone *= (TVar) -1.;
1027 series *= (-4.*a*a*a*fPoisson/(M_PI*M_PI*M_PI));
1028 disp[2] = disp2A+series;
1030 else if(fProblemType == ESphere)
1033 TVar radius2 = xc[0]*xc[0]+xc[1]*xc[1]+xc[2]*xc[2];
1034 TVar radius = FADsqrt(radius2);
1035 TVar acube = 10.*10.*10.;
1036 TVar bcube = 50.*50.*50.;
1038 TVar ur = pi*acube/(2.*fE*(bcube-acube)*radius2)*(2.*(1.-2.*fPoisson)*radius2*radius+(1.+fPoisson)*bcube);
1039 TVar cosphi = xc[2]/radius;
1040 TVar xyradius = FADsqrt(xc[0]*xc[0]+xc[1]*xc[1]);
1041 TVar sinphi = xyradius/radius;
1042 TVar costheta = xc[0]/xyradius;
1043 TVar sintheta = xc[1]/xyradius;
1044 disp[2] = ur*cosphi;
1045 disp[0] = ur*sinphi*costheta;
1046 disp[1] = ur*sinphi*sintheta;
1054 template<
class TVar>
1055 void TElasticity3DAnalytic::Elastic(
const TPZVec<TVar> &x, TVar &Elast, TVar &nu)
const 1059 nu = TVar(fPoisson);
1074 for (
int i=0; i<xstate.size(); i++) {
1077 STATE E = 1.,nu = 0.3;
1085 template<
class TVar>
1096 for(
int i=0; i<sz; i++)
1105 for (
int i=0; i<sz; i++) {
1106 for (
int j=0; j<sz; j++)
1108 grad(j,i) = result[i].d(j);
1118 for(
int i=0; i<sz; i++)
1126 for (
int i=0; i<sz; i++) {
1127 u[i] = result[i].val();
1128 for (
int j=0; j<sz; j++)
1130 gradu(i,j) = result[j].d(i);
1169 template<
class TVar>
1175 TVar Fac = E/((TVar)1.+nu)/((TVar(1.)-TVar(2.)*nu));
1179 sigma(0,0) = Fac*((TVar(1.)-nu)*grad(0,0)+nu*grad(1,1)+nu*grad(2,2));
1180 sigma(1,1) = Fac*((TVar(1.)-nu)*grad(1,1)+nu*grad(0,0)+nu*grad(2,2));
1181 sigma(2,2) = Fac*((TVar(1.)-nu)*grad(2,2)+nu*grad(0,0)+nu*grad(1,1));
1182 sigma(0,1) = E/(TVar(2.)*(TVar(1.)+nu))*(grad(0,1)+grad(1,0));
1183 sigma(1,0) = sigma(0,1);
1184 sigma(0,2) = E/(TVar(2.)*(TVar(1.)+nu))*(grad(0,2)+grad(2,0));
1185 sigma(2,0) = sigma(0,2);
1186 sigma(1,2) = E/(TVar(2.)*(TVar(1.)+nu))*(grad(1,2)+grad(2,1));
1187 sigma(2,1) = sigma(1,2);
1193 for (
int i=0; i<3; i++) {
1196 Sigma<STATE>(xloc,tensor);
1219 template<
class TVar>
1224 for(
int i=0; i<sz; i++)
1230 for (
int i=0; i<3; i++) {
1231 divsigma[i] = sigma(i,0).dx(0)+sigma(i,1).dx(1)+sigma(i,2).dx(2);
1242 TLaplaceExample1::TLaplaceExample1(
const TLaplaceExample1 &cp) :
TPZAnalyticSolution(cp),fExact(cp.fExact) {
1243 std::cout <<
"TLaplaceExample1::TLaplaceExample1(const TLaplaceExample1 &cp): One should not invoke this copy constructor";
1247 TLaplaceExample1 & TLaplaceExample1::operator=(
const TLaplaceExample1 ©){
1248 fExact = copy.fExact;
1252 template<
class TVar>
1256 for (
int i = 0; i<xloc.size(); i++) {
1257 xloc[i] -= fCenter[i];
1260 for (
int i=0; i<fDimension; i++) {
1261 r2 += xloc[i]*xloc[i];
1264 disp[0] = xloc[0]*(TVar)(0.);
1277 disp[0] += (TVar)(1.);
1278 for(
int i=0; i<fDimension; i++) disp[0] *=
sin((TVar)M_PI*xloc[i]);
1283 disp[0] += (TVar)(1.);
1284 for(
int i=0; i<fDimension; i++) disp[0] *=
sin((TVar)M_PI*xloc[i]*10.);
1290 disp[0] += (TVar)(1.);
1291 for(
int i=0; i<fDimension; i++) disp[0] *=
sin((TVar)M_PI*xloc[i]*2.);
1296 disp[0] += (TVar)(1.);
1297 for(
int i=0; i<fDimension; i++) disp[0] *=
sin((TVar)M_PI*xloc[i]*1.1);
1302 disp[0] += (TVar)(1.);
1303 for(
int i=0; i<fDimension; i++) disp[0] *=
cos((TVar)M_PI*2.*xloc[i]);
1308 TVar atanco = (r-(TVar)0.5)*100.;
1310 TVar mult = (TVar(1)+TVar(0.3)*
sin(TVar(M_PI)*xloc[0]*freq))*(TVar(1)+TVar(0.5)*
cos(TVar(M_PI)*r*freq));
1311 disp[0] =
atan(atanco)*mult;
1314 case EArcTanSingular:
1319 else if(fDimension==3)
1324 TVar arc = Force*(RCircle*RCircle-r2);
1326 for (
int i=0; i<fDimension; i++) {
1327 Prod *= x[i]*(1.-x[i]);
1329 TVar temp = 0.5*M_PI +
atan(arc);
1338 TVar theta =
atan2(xloc[1], xloc[0]);
1340 if (thetaval < (0.)) theta += 2. * M_PI;
1343 if (xval[0] > 0 && xval[1] < 1e-15 && xval[1] > -1.e-15) {
1347 TVar factor =
pow(r,TVar (2.)/TVar (3.));
1348 disp[0] = factor * (
sin((TVar) (2.) * theta / TVar(3.)));
1357 case ESinSinDirNonHom:
1360 disp[0]=(
sin((TVar)M_PI*2.*xloc[0]))*
sin((TVar)M_PI*2.*xloc[1])+(TVar)1./(xloc[0]+xloc[1]+(TVar)(1.));
1366 case ESteklovNonConst:
1368 TVar coefs[] = {1., 0.44721359549995787, 2.3333333333333326,
1369 -0.7453559924999296, 0.5555555555555556,
1370 -0.9441175904999111, -0.48148148148148173,
1371 -2.4017026424997736};
1372 TVar lambda = 0.53544094560246;
1373 TVar t =
atan2(xloc[1], xloc[0]);
1375 if(tval < (0.)) t += 2.*M_PI;
1377 if((xval[0] >=(0.)) && (xval[1] >=(0.))){
1380 disp[0]=
pow(r, lambda)*(TVar(coefs[0])*
cos(lambda *t) + TVar(coefs[1])*
sin(lambda*t) );
1386 if(( xval[0] <= (0.)) && (xval[1] >=(0.))){
1389 disp[0]=
pow(r, lambda)*(TVar(coefs[2])*
cos(lambda*t) + TVar(coefs[3])*
sin(lambda* t));
1394 if((xval[0] <(0.)) && ( xval[1] <= (0.))){
1396 disp[0]=
pow(r, lambda)*(TVar(coefs[4] )*
cos(lambda*t) + TVar(coefs[5])*
sin(lambda* t));
1400 if(( xval[0] >= (0.)) && ( xval[1] < (0.))){
1403 disp[0]=
pow(r, lambda)*(TVar(coefs[6])*
cos(lambda*t) + TVar(coefs[7])*
sin(lambda* t));
1413 case EGalvisNonConst:
1420 if((xval[0] <= (0.)) && (xval[1] <= (0.))){
1422 TVar u1 =
sin(M_PI*(xloc[0]+TVar(1.))/(k1+1.));
1423 TVar u2 = TVar(4.)*(xloc[1]+TVar(1.))*(k2-xloc[1])/((k2+TVar(1.))*(k2+TVar(1.)));
1430 if(( xval[0] > (0.)) && (xval[1] < (0.))){
1433 TVar u1 =
sin(M_PI*(k1*xloc[0]+TVar(1.))/(k1 + TVar(1.)));
1434 TVar u2 = TVar(4.)*(xloc[1]+TVar(1.))*(k2-xloc[1])/((k2+TVar(1.))*(k2+TVar(1.)));
1441 if((xval[0] < (0.)) && ( xval[1] >= (0.))){
1443 TVar u1 =
sin(M_PI*(xloc[0]+TVar(1.))/(k1+TVar(1.)));
1444 TVar u2 = TVar(4.)*(k2*xloc[1]+TVar(1.))*(k2-k2*xloc[1])/((k2+TVar(1.))*(k2+TVar(1.)));
1450 if(( xval[0] >= (0.)) && ( xval[1] >= (0.))){
1453 TVar u1 =
sin(M_PI*(k1*xloc[0]+TVar(1.))/(k1+TVar(1.)));
1454 TVar u2 = TVar(4.)*(k2*xloc[1]+TVar(1.))*(k2-k2*xloc[1])/((k2+TVar(1.))*(k2+TVar(1.)));
1466 case EBoundaryLayer:{
1467 TVar term1 = xloc[0]*xloc[1]*(1.-xloc[0])*(1.-xloc[1]);
1468 TVar term2 =
exp(TVar(10.)*xloc[0])*
exp(TVar(10.)*xloc[1]);
1469 TVar factor = TVar(537930);
1471 disp[0] = (term1*term2)/factor;
1481 disp[0] = xloc[0]*xloc[1]*xloc[2]*(TVar(1.)-xloc[0])*(TVar(1.)-xloc[1])*(TVar(1.)-xloc[2]);
1485 case ESinCosCircle:{
1487 TVar coef =
pow(r, TVar(4.));
1488 TVar theta=
atan2(xloc[1],xloc[0]);
1489 disp[0] = coef*
sin(TVar(2.)*theta)*
cos(TVar(2.)*theta);
1495 disp[0] =
exp(M_PI*x[0])*
sin(M_PI*x[1]);
1509 if(fDimension == -1){
1515 typedef FADFADSTATE TVar;
1517 for (
int i = 0; i<xloc.size(); i++) {
1518 xloc[i] -= fCenter[i];
1521 for (
int i=0; i<fDimension; i++) {
1522 r2 += xloc[i]*xloc[i];
1524 TVar r = FADsqrt(r2);
1525 disp[0] = (TVar)(0.)*xloc[0];
1535 disp[0] += (TVar)(1.);
1536 for(
int i=0; i<fDimension; i++) disp[0] *= FADsin((TVar)M_PI*xloc[i]);
1541 disp[0] += (TVar)(1.);
1542 for(
int i=0; i<fDimension; i++) disp[0] *= FADsin((TVar)M_PI*xloc[i]*10.);
1547 disp[0] += (TVar)(1.);
1548 for(
int i=0; i<fDimension; i++) disp[0] *= FADsin((TVar)M_PI*xloc[i]*2.);
1555 disp[0] += (TVar)(1.);
1556 for(
int i=0; i<fDimension; i++) disp[0] *= FADsin((TVar)M_PI*xloc[i]*1.1);
1561 disp[0] += (TVar)(1.);
1562 for(
int i=0; i<fDimension; i++) disp[0] *= FADcos((TVar)M_PI*2.*xloc[i]);
1567 TVar atanco = (r-(TVar)0.5)*100.;
1569 TVar mult = (TVar(1)+TVar(0.3)*FADsin(TVar(M_PI)*xloc[0]*freq))*(TVar(1)+TVar(0.5)*FADcos(TVar(M_PI)*r*freq));
1570 disp[0] = FADatan(atanco)*mult;
1573 case EArcTanSingular:
1578 else if(fDimension==3)
1583 TVar arc = Force*(RCircle*RCircle-r2);
1585 for (
int i=0; i<fDimension; i++) {
1586 Prod *= x[i]*(1.-x[i]);
1588 TVar temp = 0.5*M_PI + FADatan(arc);
1592 case ESinSinDirNonHom:
1595 disp[0]=(FADsin((TVar)M_PI*2.*xloc[0]))*FADsin((TVar)M_PI*2.*xloc[1])+(TVar)1./(xloc[0]+xloc[1]+(TVar)(1.));
1603 TVar theta=FADatan2(xloc[1],xloc[0]);
1604 #ifdef STATE_COMPLEX 1605 if( theta.val().val().real() < 0.) theta += 2.*M_PI;
1607 if( theta < TVar(0.)) theta += 2.*M_PI;
1611 #ifdef STATE_COMPLEX 1612 if ((xloc[0].
val().
val().real() > 0.) && (xloc[1].val().val().real() < (1e-15)) && (xloc[1].val().val().real() > (-1e-15))) {
1616 if ((xloc[0] > TVar(0.)) && (xloc[1] < TVar (1e-15)) && (xloc[1] > TVar(-1e-15))) {
1622 TVar factor =
pow(r,TVar (2.)/TVar (3.));
1623 disp[0] = factor*(FADsin((TVar)(2.)*theta/TVar(3.)));
1628 case ESteklovNonConst:
1631 TVar coefs[] = {1., 0.44721359549995787, 2.3333333333333326,
1632 -0.7453559924999296, 0.5555555555555556,
1633 -0.9441175904999111, -0.48148148148148173,
1634 -2.4017026424997736};
1635 TVar lambda = 0.53544094560246;
1636 #ifdef STATE_COMPLEX 1637 double xr = xloc[0].val().val().real();
1638 double yr = xloc[1].val().val().real();
1640 double xr = xloc[0].val().val();
1641 double yr = xloc[1].val().val();
1643 TVar t = FADatan2(xloc[1], xloc[0]);
1644 double tval =
atan2(yr,xr);
1645 if(tval < (0.)) t += TVar(2.*M_PI);
1647 if((xr >= (0.)) && (yr >= (0.))){
1650 disp[0]=
pow(r, lambda)*(TVar(coefs[0])*FADcos(lambda *t) + TVar(coefs[1])*FADsin(lambda*t));
1656 if(( xr < (0)) && (yr >(0.))){
1659 disp[0]=
pow(r, lambda)*(TVar(coefs[2])*FADcos(lambda*t) + TVar(coefs[3])*FADsin(lambda* t));
1664 if((xr < (0.)) && ( yr <= (0.))){
1666 disp[0]=
pow(r, lambda)*(TVar(coefs[4] )*FADcos(lambda*t) + TVar(coefs[5])*FADsin(lambda* t));
1670 if(( xr >= (0.)) && ( yr < 0.)){
1673 disp[0]=
pow(r, lambda)*(TVar(coefs[6])*FADcos(lambda*t) + TVar(coefs[7])*FADsin(lambda* t));
1684 case EGalvisNonConst:
1689 #ifdef STATE_COMPLEX 1690 double xr = xloc[0].
val().val().real();
1691 double yr = xloc[1].val().val().real();
1693 double xr = xloc[0].val().val();
1694 double yr = xloc[1].val().val();
1698 if((xr <= (0.)) && (yr <= (0.))){
1700 TVar u1 = FADsin(M_PI*(xloc[0]+TVar(1.))/(k1+1.));
1701 TVar u2 = TVar(4.)*(xloc[1]+TVar(1.))*(k2-xloc[1])/((k2+TVar(1.))*(k2+TVar(1.)));
1708 if(( xr > (0.)) && (yr < (0.))){
1711 TVar u1 = FADsin(M_PI*(k1*xloc[0]+TVar(1.))/(k1 + TVar(1.)));
1712 TVar u2 = TVar(4.)*(xloc[1]+TVar(1.))*(k2-xloc[1])/((k2+TVar(1.))*(k2+TVar(1.)));
1719 if((xr < (0.)) && ( yr >= (0.))){
1721 TVar u1 = FADsin(M_PI*(xloc[0]+TVar(1.))/(k1+TVar(1.)));
1722 TVar u2 = TVar(4.)*(k2*xloc[1]+TVar(1.))*(k2-k2*xloc[1])/((k2+TVar(1.))*(k2+TVar(1.)));
1728 if(( xr >= (0.)) && ( yr >= (0.))){
1731 TVar u1 = FADsin(M_PI*(k1*xloc[0]+TVar(1.))/(k1+TVar(1.)));
1732 TVar u2 = TVar(4.)*(k2*xloc[1]+TVar(1.))*(k2-k2*xloc[1])/((k2+TVar(1.))*(k2+TVar(1.)));
1742 case EBoundaryLayer:{
1743 TVar term1 = xloc[0]*xloc[1]*(1.-xloc[0])*(1.-xloc[1]);
1744 TVar term2 = FADexp(TVar(10.)*xloc[0])*FADexp(TVar(10.)*xloc[1]);
1745 TVar factor = TVar(537930);
1747 disp[0] = (term1*term2)/factor;
1755 disp[0] = xloc[0]*xloc[1]*xloc[2]*(TVar(1.)-xloc[0])*(TVar(1.)-xloc[1])*(TVar(1.)-xloc[2]);
1761 case ESinCosCircle:{
1763 TVar coef =
pow(r, TVar(4.));
1764 TVar theta=FADatan2(xloc[1],xloc[0]);
1765 disp[0] = coef*FADsin(TVar(2.)*theta)*FADcos(TVar(2.)*theta);
1772 disp[0] = FADexp(M_PI*x[0])*FADsin(M_PI*x[1]);
1776 disp[0] = xloc[0]*0.;
1788 template<
class TVar>
1789 void TLaplaceExample1::Permeability(
const TPZVec<TVar> &x, TVar &Perm)
1797 for (
unsigned int i = 0; i<xloc.size(); ++i) {
1801 Permeability(xloc, Perm);
1806 deriv(3,0) = 1./Perm;
1807 deriv(4,1) = 1./Perm;
1808 deriv(5,2) = 1./Perm;
1811 template<
class TVar>
1815 for(
int i=0; i<3; i++)
1823 for (
int i=0; i<3; i++)
1825 grad[i] = result[0].d(i);
1834 for(
int i=0; i<3; i++)
1842 for (
int i=0; i<3; i++)
1844 grad[i] = result[0].d(i);
1851 for(
int i=0; i<3; i++)
1861 u[0] = result[0].val();
1862 for (
int i=0; i<3; i++) {
1863 for (
int j=0; j<1; j++)
1865 gradu(i,j) = result[j].d(i);
1872 template<
class TVar>
1880 for(
int rowIndex =0; rowIndex < 3 ; rowIndex++) sigma(rowIndex) =0;
1884 for(
int rowIndex =0; rowIndex < 3 ; rowIndex++)
for(
int colIndex=0; colIndex < 3; colIndex++)
1886 Perm = (TVar) fTensorPerm.
GetVal(rowIndex,colIndex);
1887 sigma(rowIndex) -= Perm*grad[colIndex];
1891 template<
class TVar>
1892 void TLaplaceExample1::DivSigma(
const TPZVec<REAL> &x, TVar &divsigma)
const 1895 for(
int i=0; i<3; i++)
1900 SigmaLoc(xfad,sigma);
1901 divsigma = sigma(0).dx(0)+sigma(1).dx(1)+sigma(2).dx(2);
1909 void TLaplaceExample1::DivSigma<STATE>(
const TPZVec<REAL> &x, STATE &divsigma)
const;
1922 template<
class TVar>
1925 switch(fProblemType)
1931 disp[0] =
sin(M_PI*x[0])*
sin(M_PI*x[1])*
exp(-2.*M_PI*M_PI*fTime);
1934 disp[0] =
cos(M_PI_2*x[0])*
cos(M_PI_2*x[1])*
exp(-M_PI*M_PI_2*fTime);
1944 switch(fProblemType)
1950 disp[0] = FADsin(M_PI*x[0])*FADsin(M_PI*x[1])*FADexp(-2.*M_PI*M_PI*fTime);
1953 disp[0] = FADcos(M_PI_2*x[0])*FADcos(M_PI_2*x[1])*FADexp(-M_PI*M_PI_2*fTime);
1961 template<
class TVar>
1962 void TLaplaceExampleTimeDependent::Permeability(
const TPZVec<TVar> &x, TVar &Perm)
const 1968 template<
class TVar>
1972 for(
int i=0; i<2; i++)
1981 for (
int i=0; i<2; i++)
1983 grad[i] = result[0].d(i);
1990 for(
int i=0; i<2; i++)
1999 u[0] = result[0].val();
2000 for (
int i=0; i<2; i++) {
2001 for (
int j=0; j<1; j++)
2003 gradu(i,j) = result[j].d(i);
2009 template<
class TVar>
2014 Permeability(x, Perm);
2017 sigma(0) = -Perm*grad[0];
2018 sigma(1) = -Perm*grad[1];
2027 for(
int i=0; i<3; i++) xst[i] = x[i];
2029 Permeability(xst, Perm);
2032 sigma(0) = -Perm*grad[0];
2033 sigma(1) = -Perm*grad[1];
2037 template<
class TVar>
2038 void TLaplaceExampleTimeDependent::DivSigma(
const TPZVec<REAL> &x, TVar &divsigma)
const 2041 for(
int i=0; i<2; i++)
2047 divsigma = sigma(0).dx(0)+sigma(1).dx(1);
2053 void TLaplaceExampleTimeDependent::DivSigma(
const TPZVec<REAL> &x, STATE &divsigma)
const;
2056 template<
class TVar>
2065 flux[0] = -1.*
sin(x1)*
sin(x2);
2066 flux[1] = -1.*
cos(x1)*
cos(x2);
2070 flux[0] = 1. -
exp(lambda*x1)*
cos(2.*
Pi*x2);
2071 flux[1] = (lambda/(2.*
Pi))*
exp(lambda*x1)*
sin(2.*
Pi*x2);
2086 FADFADSTATE x1 = x[0];
2087 FADFADSTATE x2 = x[1];
2092 flux[0] = -1.*FADsin(x1)*FADsin(x2);
2093 flux[1] = -1.*FADcos(x1)*FADcos(x2);
2097 flux[0] = 1. - FADexp(lambda*x1)*FADcos(2.*
Pi*x2);
2098 flux[1] = (lambda/(2.*
Pi))*FADexp(lambda*x1)*FADsin(2.*
Pi*x2);
2110 template<
class TVar>
2111 void TStokesAnalytic::pressure(
const TPZVec<TVar> &x, TVar &p)
const 2123 p = -(1./2.)*
exp(2.*lambda*x1);
2126 flux[0] = 1. -
exp(lambda*x1)*
cos(2.*
Pi*x2);
2127 flux[1] = (lambda/(2.*
Pi))*
exp(lambda*x1)*
sin(2.*
Pi*x2);
2128 p = -(1./2.)*
exp(2.*lambda*x1);
2129 p += (1./2.)*(flux[0]*flux[0]+flux[1]*flux[1]);
2142 FADFADSTATE x1 = x[0];
2143 FADFADSTATE x2 = x[1];
2149 p = FADcos(x1)*FADsin(x2);
2152 p = -(1./2.)*FADexp(2.*lambda*x1);
2155 flux[0] = 1. - FADexp(lambda*x1)*FADcos(2.*
Pi*x2);
2156 flux[1] = (lambda/(2.*
Pi))*FADexp(lambda*x1)*FADsin(2.*
Pi*x2);
2157 p = -(1./2.)*FADexp(2.*lambda*x1);
2158 p += (1./2.)*(flux[0]*flux[0]+flux[1]*flux[1]);
2169 template<
class TVar>
2173 for(
int i=0; i<2; i++)
2182 for (
int i=0; i<2; i++) {
2183 for (
int j=0; j<2; j++)
2185 gradu(i,j) = result[i].d(j);
2190 template<
class TVar>
2195 grad.Transpose(&gradT);
2196 for(
int i=0; i<3; i++)
2198 for(
int j=0; j<3; j++)
2200 Du(i,j) = 0.5*(grad(i,j)+gradT(i,j));
2206 template<
class TVar>
2213 for(
int i=0; i<Du.
Rows(); i++)
2215 for(
int j=0; j<Du.
Cols(); j++)
2217 Du(i,j) *= 2.*fvisco;
2221 for (
int i=0; i< pIdentity.Rows(); i++) {
2224 sigma = Du-pIdentity;
2227 template<
class TVar>
2233 for(
int i=0; i<Du.
Rows(); i++)
2235 for(
int j=0; j<Du.
Cols(); j++)
2237 Du(i,j) *= 2.*fvisco;
2241 for (
int i=0; i< pIdentity.Rows(); i++) {
2245 for(
int i=0; i<sigma.
Rows(); i++)
2247 for(
int j=0; j<sigma.
Cols(); j++)
2249 sigma(i,j) = Du(i,j)-pIdentity(i,j);
2262 for(
int i=0; i<3; i++) xstate[i] = x[i];
2264 for(
int i=0; i<Du.
Rows(); i++)
2266 for(
int j=0; j<Du.
Cols(); j++)
2268 Du(i,j) *= 2.*fvisco;
2271 pressure(xstate, p);
2272 for (
int i=0; i< pIdentity.Rows(); i++) {
2275 sigma = Du-pIdentity;
2286 template<
class TVar>
2291 for(
int i=0; i<sz; i++)
2297 for (
int i=0; i<3; i++) {
2298 divsigma[i] = sigma(i,0).dx(0)+sigma(i,1).dx(1)+sigma(i,2).dx(2);
2310 for(
int i=0; i<3; i++) xst[i] = x[i];
2311 DivSigma(x, locforce);
2313 switch(fProblemType)
2316 force[0] = -locforce[0];
2317 force[1] = -locforce[1];
2318 force[2] = -locforce[2];
2327 for (
int e=0; e<3; e++) {
2328 for (
int f=0;
f<3;
f++) {
2329 gradU_beta[e] += grad(e,
f)*beta[
f];
2333 force[0] = -locforce[0]+gradU_beta[0];
2334 force[1] = -locforce[1]+gradU_beta[1];
2335 force[2] = -locforce[2]+gradU_beta[2];
2338 case ENavierStokesCDG:
2344 for (
int e=0; e<3; e++) {
2345 for (
int f=0;
f<3;
f++) {
2346 gradU_beta[e] += grad(e,
f)*beta[
f];
2350 for (
int e=0; e<3; e++) {
2351 for (
int f=0;
f<3;
f++) {
2352 gradUt_beta[e] += grad(
f,e)*beta[
f];
2356 force[0] = -locforce[0]+gradU_beta[0]-gradUt_beta[0];
2357 force[1] = -locforce[1]+gradU_beta[1]-gradUt_beta[1];
2358 force[2] = -locforce[2]+gradU_beta[2]-gradUt_beta[2];
2377 for(
int i=0; i<3; i++)
2386 for (
int i = 0; i < 3; i++) {
2387 sol[i] = u_result[i].val();
2389 for(
int i=0; i<fDimension; i++) {
2390 for (
int j=0; j<fDimension; j++)
2392 gradsol(i,j) = u_result[j].d(i);
2396 pressure(xfad, p_result);
2397 sol[3] = p_result.
val();
int fSignConvention
integer to correct for the sign convention of the forcing term
TPZFlopCounter atan2(const TPZFlopCounter &val1, const TPZFlopCounter &val2)
Returns the arc tangent in radians and increments the counter of the Arc Tangent. ATAN2 returns the ...
Contains TPZAnalysis class which implements the sequence of actions to perform a finite element analy...
Contains definitions to LOGPZ_DEBUG, LOGPZ_INFO, LOGPZ_WARN, LOGPZ_ERROR and LOGPZ_FATAL, and the implementation of the inline InitializePZLOG(string) function using log4cxx library or not. It must to be called out of "#ifdef LOG4CXX" scope.
Implements a vector class which allows to use external storage provided by the user. Utility.
virtual void resize(const int64_t newsize)
Contains declaration of TPZCheckGeom class which performs a series of consistency tests on geometric ...
clarg::argBool h("-h", "help message", false)
TinyFad< 8, T > abs(const TinyFad< 8, T > &in)
This class implements a simple vector storage scheme for a templated class T. Utility.
REAL val(STATE &number)
Returns value of the variable.
AutoPointerMutexArrayInit tmp
Contains the TPZSymetricSpStructMatrix class which implements sparse structural matrices.
TPZAnalyticSolution & operator=(const TPZAnalyticSolution ©)
int Zero() override
Makes Zero all the elements.
int64_t size() const
Returns the number of elements of the vector.
Contains declaration of TPZMesh class which defines a geometrical mesh and contains a corresponding l...
expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ cosh
#define DebugStop()
Returns a message to user put a breakpoint in.
Contains the TPZSkylineStructMatrix class which implements SkyLine Structural Matrices.
Contains the declaration of the TPZBuildmultiphysicsMesh class.
int64_t Rows() const
Returns number of rows.
expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ sqrt
int Redim(const int64_t newRows, const int64_t newCols) override
Redimension a matrix and ZERO your elements.
static REAL angle
Angle in radians to test.
TPZFlopCounter pow(const TPZFlopCounter &orig, const TPZFlopCounter &xp)
Returns the power and increments the counter of the power.
expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ sinh
expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ atan
Contains TPZStepSolver class which defines step solvers class.
int64_t Cols() const
Returns number of cols.
expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ exp
int Resize(const int64_t newRows, const int64_t wCols) override
Redimension a matrix, but maintain your elements.
Contains the TPZVTKGeoMesh class which implements the graphical mesh to VTK environment to geometric ...
const Vector< T > & dx() const
TPZFlopCounter cos(const TPZFlopCounter &orig)
Returns the cosine in radians and increments the counter of the Cosine.
const TVar & GetVal(const int64_t row, const int64_t col) const override
Get values without bounds checking This method is faster than "Get" if DEBUG is defined.
Non abstract class which implements full matrices with preallocated storage with (N+1) entries...