00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00037
00038
00039 #ifndef NewTemplate3Dep_CPP
00040 #define NewTemplate3Dep_CPP
00041
00042 #include "NewTemplate3Dep.h"
00043
00044
00045 const straintensor NewTemplate3Dep::ZeroStrain;
00046 const stresstensor NewTemplate3Dep::ZeroStress;
00047 const BJtensor NewTemplate3Dep::ZeroI4(4, def_dim_4, 0.0);
00048 const int NewTemplate3Dep::ISMAX = 32;
00049 const int NewTemplate3Dep::ITMAX = 40;
00050 const double NewTemplate3Dep::TOL = 1.0e-7;
00051 const double NewTemplate3Dep::FTOL = 1.0e-7;
00052
00053
00054 Matrix NewTemplate3Dep::D(6,6);
00055 Vector NewTemplate3Dep::sigma(6);
00056 Vector NewTemplate3Dep::epsilon(6);
00057
00058 BJmatrix NewTemplate3Dep::TangentMatrix( 6, 6, 0.0);
00059
00060
00061
00062 NewTemplate3Dep::NewTemplate3Dep( int tag,
00063 MaterialParameter *ptr_material_parameter_in,
00064 ElasticState *ptr_elastic_state_in,
00065 YieldFunction *ptr_yield_function_in ,
00066 PlasticFlow *ptr_plastic_flow_in,
00067 ScalarEvolution **ptr_scalar_evolution_in,
00068 TensorEvolution **ptr_tensor_evolution_in,
00069 int caseIndex_in, int subStep_in)
00070 :NDMaterial(tag, ND_TAG_NewTemplate3Dep), caseIndex(caseIndex_in), subStep(subStep_in), divergeOrnot(0)
00071 {
00072 if ( ptr_material_parameter_in )
00073 ptr_material_parameter = ptr_material_parameter_in->newObj();
00074 else {
00075 cout << "NewTemplate3Dep:: NewTemplate3Dep failed to construct the input parameters. " << endln;
00076 exit(1);
00077 }
00078
00079 if ( ptr_elastic_state_in )
00080 ptr_elastic_state = ptr_elastic_state_in->newObj();
00081 else{
00082 cout << "NewTemplate3Dep:: NewTemplate3Dep failed to get copy of elastic material. " << endln;
00083 exit(1);
00084 }
00085
00086 if ( ptr_yield_function_in )
00087 ptr_yield_function = ptr_yield_function_in->newObj();
00088 else {
00089 cout << "NewTemplate3Dep:: NewTemplate3Dep failed to construct the yield function. " << endln;
00090 exit(1);
00091 }
00092
00093 if ( ptr_plastic_flow_in )
00094 ptr_plastic_flow = ptr_plastic_flow_in->newObj();
00095 else {
00096 cout << "NewTemplate3Dep:: NewTemplate3Dep failed to construct the plastic flow. " << endln;
00097 exit(1);
00098 }
00099
00100
00101 if ( ptr_material_parameter_in->getNum_Internal_Scalar() > 0 ) {
00102 ptr_scalar_evolution = new ScalarEvolution* [ptr_material_parameter_in->getNum_Internal_Scalar()];
00103 for (int i = 0; i < ptr_material_parameter_in->getNum_Internal_Scalar(); i++)
00104 ptr_scalar_evolution[i] = (ptr_scalar_evolution_in[i])->newObj();
00105 }
00106 else
00107 ptr_scalar_evolution = NULL;
00108
00109
00110 if ( ptr_material_parameter_in->getNum_Internal_Tensor() > 0 ) {
00111 ptr_tensor_evolution = new TensorEvolution* [ptr_material_parameter_in->getNum_Internal_Tensor()];
00112 for (int i = 0; i < ptr_material_parameter_in->getNum_Internal_Tensor(); i++)
00113 ptr_tensor_evolution[i] = (ptr_tensor_evolution_in[i])->newObj();
00114 }
00115 else
00116 ptr_tensor_evolution = NULL;
00117
00118 int err;
00119 err = this->revertToStart();
00120 }
00121
00122
00123
00124 NewTemplate3Dep::NewTemplate3Dep( int tag,
00125 MaterialParameter *ptr_material_parameter_in,
00126 ElasticState *ptr_elastic_state_in,
00127 YieldFunction *ptr_yield_function_in ,
00128 PlasticFlow *ptr_plastic_flow_in,
00129 ScalarEvolution **ptr_scalar_evolution_in,
00130 int caseIndex_in, int subStep_in)
00131 :NDMaterial(tag, ND_TAG_NewTemplate3Dep), caseIndex(caseIndex_in), subStep(subStep_in), divergeOrnot(0)
00132 {
00133 if ( ptr_material_parameter_in )
00134 ptr_material_parameter = ptr_material_parameter_in->newObj();
00135 else {
00136 cout << "NewTemplate3Dep:: NewTemplate3Dep failed to construct the input parameters. " << endln;
00137 exit(1);
00138 }
00139
00140 if ( ptr_elastic_state_in )
00141 ptr_elastic_state = ptr_elastic_state_in->newObj();
00142 else{
00143 cout << "NewTemplate3Dep:: NewTemplate3Dep failed to get copy of elastic material. " << endln;
00144 exit(1);
00145 }
00146
00147 if ( ptr_yield_function_in )
00148 ptr_yield_function = ptr_yield_function_in->newObj();
00149 else {
00150 cout << "NewTemplate3Dep:: NewTemplate3Dep failed to construct the yield function. " << endln;
00151 exit(1);
00152 }
00153
00154 if ( ptr_plastic_flow_in )
00155 ptr_plastic_flow = ptr_plastic_flow_in->newObj();
00156 else {
00157 cout << "NewTemplate3Dep:: NewTemplate3Dep failed to construct the plastic flow. " << endln;
00158 exit(1);
00159 }
00160
00161
00162 if ( ptr_material_parameter_in->getNum_Internal_Scalar() > 0 ) {
00163 ptr_scalar_evolution = new ScalarEvolution* [ptr_material_parameter_in->getNum_Internal_Scalar()];
00164 for (int i = 0; i < ptr_material_parameter_in->getNum_Internal_Scalar(); i++)
00165 ptr_scalar_evolution[i] = (ptr_scalar_evolution_in[i])->newObj();
00166 }
00167 else
00168 ptr_scalar_evolution = NULL;
00169
00170
00171 ptr_tensor_evolution = NULL;
00172
00173 int err;
00174 err = this->revertToStart();
00175 }
00176
00177
00178
00179 NewTemplate3Dep::NewTemplate3Dep( int tag,
00180 MaterialParameter *ptr_material_parameter_in,
00181 ElasticState *ptr_elastic_state_in,
00182 YieldFunction *ptr_yield_function_in ,
00183 PlasticFlow *ptr_plastic_flow_in,
00184 TensorEvolution **ptr_tensor_evolution_in,
00185 int caseIndex_in, int subStep_in)
00186 :NDMaterial(tag, ND_TAG_NewTemplate3Dep), caseIndex(caseIndex_in), subStep(subStep_in), divergeOrnot(0)
00187 {
00188 if ( ptr_material_parameter_in )
00189 ptr_material_parameter = ptr_material_parameter_in->newObj();
00190 else {
00191 cout << "NewTemplate3Dep:: NewTemplate3Dep failed to construct the input parameters. " << endln;
00192 exit(1);
00193 }
00194
00195 if ( ptr_elastic_state_in )
00196 ptr_elastic_state = ptr_elastic_state_in->newObj();
00197 else{
00198 cout << "NewTemplate3Dep:: NewTemplate3Dep failed to get copy of elastic material. " << endln;
00199 exit(1);
00200 }
00201
00202 if ( ptr_yield_function_in )
00203 ptr_yield_function = ptr_yield_function_in->newObj();
00204 else {
00205 cout << "NewTemplate3Dep:: NewTemplate3Dep failed to construct the yield function. " << endln;
00206 exit(1);
00207 }
00208
00209 if ( ptr_plastic_flow_in )
00210 ptr_plastic_flow = ptr_plastic_flow_in->newObj();
00211 else {
00212 cout << "NewTemplate3Dep:: NewTemplate3Dep failed to construct the plastic flow. " << endln;
00213 exit(1);
00214 }
00215
00216
00217 ptr_scalar_evolution = NULL;
00218
00219
00220 if ( ptr_material_parameter_in->getNum_Internal_Tensor() > 0 ) {
00221 ptr_tensor_evolution = new TensorEvolution* [ptr_material_parameter_in->getNum_Internal_Tensor()];
00222 for (int i = 0; i < ptr_material_parameter_in->getNum_Internal_Tensor(); i++)
00223 ptr_tensor_evolution[i] = ptr_tensor_evolution_in[i]->newObj();
00224 }
00225 else
00226 ptr_tensor_evolution = NULL;
00227
00228 int err;
00229 err = this->revertToStart();
00230 }
00231
00232
00233
00234 NewTemplate3Dep::NewTemplate3Dep( int tag,
00235 MaterialParameter *ptr_material_parameter_in,
00236 ElasticState *ptr_elastic_state_in,
00237 YieldFunction *ptr_yield_function_in ,
00238 PlasticFlow *ptr_plastic_flow_in,
00239 int caseIndex_in, int subStep_in)
00240 :NDMaterial(tag, ND_TAG_NewTemplate3Dep), caseIndex(caseIndex_in), subStep(subStep_in), divergeOrnot(0)
00241 {
00242 if ( ptr_material_parameter_in )
00243 ptr_material_parameter = ptr_material_parameter_in->newObj();
00244 else {
00245 cout << "NewTemplate3Dep:: NewTemplate3Dep failed to construct the input parameters. " << endln;
00246 exit(1);
00247 }
00248
00249 if ( ptr_elastic_state_in )
00250 ptr_elastic_state = ptr_elastic_state_in->newObj();
00251 else{
00252 cout << "NewTemplate3Dep:: NewTemplate3Dep failed to get copy of elastic material. " << endln;
00253 exit(1);
00254 }
00255
00256 if ( ptr_yield_function_in )
00257 ptr_yield_function = ptr_yield_function_in->newObj();
00258 else {
00259 cout << "NewTemplate3Dep:: NewTemplate3Dep failed to construct the yield function. " << endln;
00260 exit(1);
00261 }
00262
00263 if ( ptr_plastic_flow_in )
00264 ptr_plastic_flow = ptr_plastic_flow_in->newObj();
00265 else {
00266 cout << "NewTemplate3Dep:: NewTemplate3Dep failed to construct the plastic flow. " << endln;
00267 exit(1);
00268 }
00269
00270
00271 ptr_scalar_evolution = NULL;
00272
00273
00274 ptr_tensor_evolution = NULL;
00275
00276 int err;
00277 err = this->revertToStart();
00278 }
00279
00280
00281
00282 NewTemplate3Dep::NewTemplate3Dep()
00283 : NDMaterial(0, ND_TAG_NewTemplate3Dep),
00284 ptr_material_parameter(NULL),
00285 ptr_elastic_state(NULL),
00286 ptr_yield_function(NULL),
00287 ptr_plastic_flow(NULL),
00288 ptr_scalar_evolution(NULL),
00289 ptr_tensor_evolution(NULL),
00290 caseIndex(0), subStep(1), divergeOrnot(0)
00291 {
00292 int err;
00293 err = this->revertToStart();
00294 }
00295
00296
00297
00298 NewTemplate3Dep::~NewTemplate3Dep()
00299 {
00300 if (ptr_elastic_state)
00301 delete ptr_elastic_state;
00302
00303 for (int i = 0; i < ptr_material_parameter->getNum_Internal_Scalar(); i++) {
00304 if (ptr_scalar_evolution[i])
00305 delete ptr_scalar_evolution[i];
00306 }
00307 if (ptr_scalar_evolution)
00308 delete [] ptr_scalar_evolution;
00309
00310 for (int j = 0; j < ptr_material_parameter->getNum_Internal_Tensor(); j++) {
00311 if (ptr_tensor_evolution[j])
00312 delete ptr_tensor_evolution[j];
00313 }
00314 if (ptr_tensor_evolution)
00315 delete [] ptr_tensor_evolution;
00316
00317 if (ptr_yield_function)
00318 delete ptr_yield_function;
00319
00320 if (ptr_plastic_flow)
00321 delete ptr_plastic_flow;
00322
00323 if (ptr_material_parameter)
00324 delete ptr_material_parameter;
00325 }
00326
00327
00328
00329 int NewTemplate3Dep::setTrialStrain (const Vector &v)
00330 {
00331 straintensor temp;
00332
00333 temp.val(1,1) = v(0);
00334 temp.val(2,2) = v(1);
00335 temp.val(3,3) = v(2);
00336 temp.val(1,2) = 0.5 * v(3);
00337 temp.val(2,1) = 0.5 * v(3);
00338 temp.val(3,1) = 0.5 * v(4);
00339 temp.val(1,3) = 0.5 * v(4);
00340 temp.val(2,3) = 0.5 * v(5);
00341 temp.val(3,2) = 0.5 * v(5);
00342
00343 return this->setTrialStrainIncr(temp - getStrainTensor());
00344 }
00345
00346
00347
00348 int NewTemplate3Dep::setTrialStrain (const Vector &v, const Vector &r)
00349 {
00350 return this->setTrialStrainIncr(v);;
00351 }
00352
00353
00354
00355 int NewTemplate3Dep::setTrialStrainIncr (const Vector &v)
00356 {
00357 straintensor temp;
00358
00359 temp.val(1,1) = v(0);
00360 temp.val(2,2) = v(1);
00361 temp.val(3,3) = v(2);
00362 temp.val(1,2) = 0.5 * v(3);
00363 temp.val(2,1) = 0.5 * v(3);
00364 temp.val(3,1) = 0.5 * v(4);
00365 temp.val(1,3) = 0.5 * v(4);
00366 temp.val(2,3) = 0.5 * v(5);
00367 temp.val(3,2) = 0.5 * v(5);
00368
00369 return this->setTrialStrainIncr(temp);
00370 }
00371
00372
00373
00374 int NewTemplate3Dep::setTrialStrainIncr (const Vector &v, const Vector &r)
00375 {
00376 return this->setTrialStrainIncr(v);
00377 }
00378
00379
00380
00381 const Matrix& NewTemplate3Dep::getTangent (void)
00382 {
00383 D(0,0) = Stiffness.cval(1,1,1,1);
00384 D(0,1) = Stiffness.cval(1,1,2,2);
00385 D(0,2) = Stiffness.cval(1,1,3,3);
00386 D(0,3) = Stiffness.cval(1,1,1,2) *0.5;
00387 D(0,4) = Stiffness.cval(1,1,1,3) *0.5;
00388 D(0,5) = Stiffness.cval(1,1,2,3) *0.5;
00389
00390 D(1,0) = Stiffness.cval(2,2,1,1);
00391 D(1,1) = Stiffness.cval(2,2,2,2);
00392 D(1,2) = Stiffness.cval(2,2,3,3);
00393 D(1,3) = Stiffness.cval(2,2,1,2) *0.5;
00394 D(1,4) = Stiffness.cval(2,2,1,3) *0.5;
00395 D(1,5) = Stiffness.cval(2,2,2,3) *0.5;
00396
00397 D(2,0) = Stiffness.cval(3,3,1,1);
00398 D(2,1) = Stiffness.cval(3,3,2,2);
00399 D(2,2) = Stiffness.cval(3,3,3,3);
00400 D(2,3) = Stiffness.cval(3,3,1,2) *0.5;
00401 D(2,4) = Stiffness.cval(3,3,1,3) *0.5;
00402 D(2,5) = Stiffness.cval(3,3,2,3) *0.5;
00403
00404 D(3,0) = Stiffness.cval(1,2,1,1);
00405 D(3,1) = Stiffness.cval(1,2,2,2);
00406 D(3,2) = Stiffness.cval(1,2,3,3);
00407 D(3,3) = Stiffness.cval(1,2,1,2) *0.5;
00408 D(3,4) = Stiffness.cval(1,2,1,3) *0.5;
00409 D(3,5) = Stiffness.cval(1,2,2,3) *0.5;
00410
00411 D(4,0) = Stiffness.cval(1,3,1,1);
00412 D(4,1) = Stiffness.cval(1,3,2,2);
00413 D(4,2) = Stiffness.cval(1,3,3,3);
00414 D(4,3) = Stiffness.cval(1,3,1,2) *0.5;
00415 D(4,4) = Stiffness.cval(1,3,1,3) *0.5;
00416 D(4,5) = Stiffness.cval(1,3,2,3) *0.5;
00417
00418 D(5,0) = Stiffness.cval(2,3,1,1);
00419 D(5,1) = Stiffness.cval(2,3,2,2);
00420 D(5,2) = Stiffness.cval(2,3,3,3);
00421 D(5,3) = Stiffness.cval(2,3,1,2) *0.5;
00422 D(5,4) = Stiffness.cval(2,3,1,3) *0.5;
00423 D(5,5) = Stiffness.cval(2,3,2,3) *0.5;
00424
00425 return D;
00426 }
00427
00428
00429
00430
00431
00432 const BJmatrix& NewTemplate3Dep::getTangentBJmatrix(void)
00433 {
00434 TangentMatrix.val(0,0) = Stiffness.cval(1,1,1,1);
00435 TangentMatrix.val(0,1) = Stiffness.cval(1,1,2,2);
00436 TangentMatrix.val(0,2) = Stiffness.cval(1,1,3,3);
00437 TangentMatrix.val(0,3) = Stiffness.cval(1,1,1,2) *0.5;
00438 TangentMatrix.val(0,4) = Stiffness.cval(1,1,1,3) *0.5;
00439 TangentMatrix.val(0,5) = Stiffness.cval(1,1,2,3) *0.5;
00440
00441 TangentMatrix.val(1,0) = Stiffness.cval(2,2,1,1);
00442 TangentMatrix.val(1,1) = Stiffness.cval(2,2,2,2);
00443 TangentMatrix.val(1,2) = Stiffness.cval(2,2,3,3);
00444 TangentMatrix.val(1,3) = Stiffness.cval(2,2,1,2) *0.5;
00445 TangentMatrix.val(1,4) = Stiffness.cval(2,2,1,3) *0.5;
00446 TangentMatrix.val(1,5) = Stiffness.cval(2,2,2,3) *0.5;
00447
00448 TangentMatrix.val(2,0) = Stiffness.cval(3,3,1,1);
00449 TangentMatrix.val(2,1) = Stiffness.cval(3,3,2,2);
00450 TangentMatrix.val(2,2) = Stiffness.cval(3,3,3,3);
00451 TangentMatrix.val(2,3) = Stiffness.cval(3,3,1,2) *0.5;
00452 TangentMatrix.val(2,4) = Stiffness.cval(3,3,1,3) *0.5;
00453 TangentMatrix.val(2,5) = Stiffness.cval(3,3,2,3) *0.5;
00454
00455 TangentMatrix.val(3,0) = Stiffness.cval(1,2,1,1);
00456 TangentMatrix.val(3,1) = Stiffness.cval(1,2,2,2);
00457 TangentMatrix.val(3,2) = Stiffness.cval(1,2,3,3);
00458 TangentMatrix.val(3,3) = Stiffness.cval(1,2,1,2) *0.5;
00459 TangentMatrix.val(3,4) = Stiffness.cval(1,2,1,3) *0.5;
00460 TangentMatrix.val(3,5) = Stiffness.cval(1,2,2,3) *0.5;
00461
00462 TangentMatrix.val(4,0) = Stiffness.cval(1,3,1,1);
00463 TangentMatrix.val(4,1) = Stiffness.cval(1,3,2,2);
00464 TangentMatrix.val(4,2) = Stiffness.cval(1,3,3,3);
00465 TangentMatrix.val(4,3) = Stiffness.cval(1,3,1,2) *0.5;
00466 TangentMatrix.val(4,4) = Stiffness.cval(1,3,1,3) *0.5;
00467 TangentMatrix.val(4,5) = Stiffness.cval(1,3,2,3) *0.5;
00468
00469 TangentMatrix.val(5,0) = Stiffness.cval(2,3,1,1);
00470 TangentMatrix.val(5,1) = Stiffness.cval(2,3,2,2);
00471 TangentMatrix.val(5,2) = Stiffness.cval(2,3,3,3);
00472 TangentMatrix.val(5,3) = Stiffness.cval(2,3,1,2) *0.5;
00473 TangentMatrix.val(5,4) = Stiffness.cval(2,3,1,3) *0.5;
00474 TangentMatrix.val(5,5) = Stiffness.cval(2,3,2,3) *0.5;
00475
00476
00477 return TangentMatrix;
00478 }
00479
00480
00481
00482 const Vector& NewTemplate3Dep::getStress (void)
00483 {
00484 sigma(0) = TrialStress.cval(1,1);
00485 sigma(1) = TrialStress.cval(2,2);
00486 sigma(2) = TrialStress.cval(3,3);
00487 sigma(3) = TrialStress.cval(1,2);
00488 sigma(4) = TrialStress.cval(1,3);
00489 sigma(5) = TrialStress.cval(2,3);
00490
00491 return sigma;
00492 }
00493
00494
00495
00496 const Vector& NewTemplate3Dep::getStrain (void)
00497 {
00498 epsilon(0) = TrialStrain.cval(1,1);
00499 epsilon(1) = TrialStrain.cval(2,2);
00500 epsilon(2) = TrialStrain.cval(3,3);
00501 epsilon(3) = TrialStrain.cval(1,2) *2.0;
00502 epsilon(4) = TrialStrain.cval(1,3) *2.0;
00503 epsilon(5) = TrialStrain.cval(2,3) *2.0;
00504
00505 return epsilon;
00506 }
00507
00508
00509 int NewTemplate3Dep::setTrialStrain(const Tensor& v)
00510 {
00511 return this->setTrialStrainIncr( v - getStrainTensor() );
00512 }
00513
00514
00515
00516 int NewTemplate3Dep::setTrialStrain(const Tensor& v, const Tensor& r)
00517 {
00518 return this->setTrialStrainIncr( v - getStrainTensor() );
00519 }
00520
00521
00522 int NewTemplate3Dep::setTrialStrainIncr(const Tensor& strain_increment)
00523 {
00524 switch(caseIndex)
00525 {
00526 case (0):
00527 return this->Explicit(strain_increment, this->subStep);
00528
00529 case (1):
00530 return this->Implicit(strain_increment, this->subStep);
00531
00532 case (2):
00533 return this->ImplicitLineSearch(strain_increment);
00534
00535 case (3):
00536 return this->ScaledExplicit(strain_increment, this->subStep);
00537
00538
00539 default:
00540 return 0;
00541 }
00542 }
00543
00544
00545 int NewTemplate3Dep::setTrialStrainIncr(const Tensor& v, const Tensor& r)
00546 {
00547 return this->setTrialStrainIncr(v);
00548 }
00549
00550
00551 double NewTemplate3Dep::getRho(void)
00552 {
00553 double rho = 0.0;
00554 if (ptr_material_parameter->getNum_Material_Constant() > 0)
00555 rho = ptr_material_parameter->getMaterial_Constant(0);
00556 else {
00557 cout << "Error!! NewTemplate3Dep:: number of input parameter for material constants less than 1. " << endln;
00558 cout << "Remind: NewTemplate3Dep:: the 1st material constant is the density. " << endln;
00559 exit(1);
00560 }
00561
00562 return rho;
00563 }
00564
00565
00566 const BJtensor& NewTemplate3Dep::getTangentTensor(void)
00567 {
00568 return this->Stiffness;
00569 }
00570
00571
00572 const stresstensor& NewTemplate3Dep::getStressTensor(void)
00573 {
00574 return this->TrialStress;
00575 }
00576
00577
00578
00579 const straintensor& NewTemplate3Dep::getStrainTensor(void)
00580 {
00581 return this->TrialStrain;
00582 }
00583
00584
00585 const straintensor& NewTemplate3Dep::getPlasticStrainTensor(void)
00586 {
00587 return this->TrialPlastic_Strain;
00588 }
00589
00590
00591
00592
00593
00594
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604
00605
00606
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625
00626
00627
00628
00629
00630
00631
00632
00633
00634
00635
00636
00637
00638
00639
00640
00641
00642
00643
00644
00645
00646
00647
00648
00649
00650
00651
00652
00653
00654
00655
00656
00657
00658
00659
00660
00661
00662
00663
00664
00665
00666
00667
00668
00669
00670
00671
00672
00673
00674
00675
00676
00677
00678
00679
00680
00681
00682
00683
00684
00685
00686
00687
00688
00689
00690
00691
00692
00693
00694
00695
00696
00697
00698
00699
00700
00701
00702
00703
00704
00705
00706
00707
00708
00709
00710
00711
00712
00713
00714
00715
00716
00717
00718
00719
00720
00721
00722
00723
00724
00725
00726
00727
00728
00729
00730
00731
00732
00733
00734
00735
00736
00737
00738
00739
00740
00741
00742
00743
00744
00745
00746
00747
00748
00749
00750
00751
00752
00753
00754
00755
00756
00757
00758
00759
00760
00761
00762
00763
00764
00765
00766
00767
00768
00769
00770
00771
00772
00773
00774
00775
00776
00777
00778
00779
00780
00781
00782
00783
00784
00785
00786
00787
00788
00789
00790
00791
00792
00793
00794
00795
00796
00797
00798
00799
00800
00801
00802
00803
00804
00805
00806
00807
00808
00809
00810
00811
00812
00813
00814
00815
00816
00817
00818
00819
00820
00821
00822
00823
00824
00825
00826
00827
00828
00829
00830
00831
00832
00833
00834
00835
00836
00837
00838
00839
00840
00841
00842
00843
00844
00845 int NewTemplate3Dep::commitState(void)
00846 {
00847 int err = 0;
00848
00849 CommitStress.Initialize(TrialStress);
00850 CommitStrain.Initialize(TrialStrain);
00851 CommitPlastic_Strain.Initialize(TrialPlastic_Strain);
00852
00853 return err;
00854 }
00855
00856
00857 int NewTemplate3Dep::revertToLastCommit(void)
00858 {
00859 int err = 0;
00860
00861 TrialStress.Initialize(CommitStress);
00862 TrialStrain.Initialize(CommitStrain);
00863 TrialPlastic_Strain.Initialize(CommitPlastic_Strain);
00864
00865 return err;
00866 }
00867
00868
00869 int NewTemplate3Dep::revertToStart(void)
00870 {
00871 int err = 0;
00872
00873 CommitStress = ptr_elastic_state->getStress();
00874 CommitStrain = ptr_elastic_state->getStrain();
00875 CommitPlastic_Strain.Initialize(ZeroStrain);
00876
00877 TrialStress.Initialize(CommitStress);
00878 TrialStrain.Initialize(CommitStrain);
00879 TrialPlastic_Strain.Initialize(ZeroStrain);
00880
00881 Stiffness = ptr_elastic_state->getElasticStiffness(*ptr_material_parameter);
00882
00883 return err;
00884 }
00885
00886
00887 NDMaterial * NewTemplate3Dep::getCopy(void)
00888 {
00889 NDMaterial* tmp = new NewTemplate3Dep(this->getTag(),
00890 this->ptr_material_parameter,
00891 this->ptr_elastic_state,
00892 this->ptr_yield_function,
00893 this->ptr_plastic_flow,
00894 this->ptr_scalar_evolution,
00895 this->ptr_tensor_evolution,
00896 this->caseIndex,
00897 this->subStep);
00898 return tmp;
00899 }
00900
00901
00902
00903 NDMaterial * NewTemplate3Dep::getCopy(const char *code)
00904 {
00905 if (strcmp(code,"ThreeDimensional") == 0) {
00906 NewTemplate3Dep* tmp = new NewTemplate3Dep( this->getTag(),
00907 this->ptr_material_parameter,
00908 this->ptr_elastic_state,
00909 this->ptr_yield_function,
00910 this->ptr_plastic_flow,
00911 this->ptr_scalar_evolution,
00912 this->ptr_tensor_evolution,
00913 this->caseIndex,
00914 this->subStep);
00915 return tmp;
00916 }
00917 else {
00918 cout << "NewTemplate3Dep::getCopy failed to get model: " << code << endln;
00919 exit(1);
00920 }
00921 return 0;
00922 }
00923
00924
00925 const char *NewTemplate3Dep::getType(void) const
00926 {
00927 return "ThreeDimensional";
00928 }
00929
00930
00931 int NewTemplate3Dep::sendSelf(int commitTag, Channel &theChannel)
00932 {
00933
00934 # ifdef _PARALLEL_PROCESSING
00935 static ID idData(13);
00936
00937 idData.Zero();
00938
00939 idData(0) = this->getTag();
00940
00941 if ( ptr_material_parameter != NULL ) idData(1) = 1;
00942 if ( ptr_elastic_state != NULL ) idData(2) = 1;
00943 if ( ptr_yield_function != NULL ) idData(3) = 1;
00944 if ( ptr_plastic_flow != NULL ) idData(4) = 1;
00945 if ( ptr_scalar_evolution != NULL ) idData(5) = 1;
00946 if ( ptr_tensor_evolution != NULL ) idData(6) = 1;
00947
00948 idData(7) = caseIndex;
00949
00950 if ( ptr_elastic_state != NULL ) idData(8) = ptr_elastic_state->getClassTag();
00951 if ( ptr_yield_function != NULL ) idData(9) = ptr_yield_function ->getClassTag();
00952 if ( ptr_plastic_flow != NULL ) idData(10) = ptr_plastic_flow->getClassTag();
00953
00954 idData(11) = subStep;
00955 idData(12) = divergeOrnot;
00956
00957 static ID *pID_ScalarTags = NULL;
00958 if ( ptr_scalar_evolution != NULL ) {
00959 const int NumScalar = ptr_material_parameter->getNum_Internal_Scalar();
00960 pID_ScalarTags = new ID(NumScalar);
00961 for (int i=0; i<NumScalar; i++) (*pID_ScalarTags)(i) = ptr_scalar_evolution[i]->getClassTag();
00962 }
00963
00964 static ID *pID_TensorTags = NULL;
00965 if ( ptr_tensor_evolution != NULL ) {
00966 const int NumTensor = ptr_material_parameter->getNum_Internal_Tensor();
00967 pID_TensorTags = new ID(NumTensor);
00968 for (int i=0; i<NumTensor; i++) (*pID_TensorTags)(i) = ptr_tensor_evolution[i]->getClassTag();
00969 }
00970
00971 if (theChannel.sendID(this->getDbTag(), commitTag, idData) < 0) {
00972 std::cerr << "NewTemplate3Dep::sendSelf -- failed to send ID\n";
00973 return -1;
00974 }
00975
00976 if ( ptr_material_parameter != NULL )
00977 if (ptr_material_parameter->sendSelf(commitTag, theChannel) < 0) {
00978 std::cerr << "NewTemplate3Dep::sendSelf -- MaterialParameters failed to send self\n";
00979 return -1;
00980 }
00981
00982 if ( ptr_elastic_state != NULL )
00983 if (ptr_elastic_state->sendSelf(commitTag, theChannel) < 0) {
00984 std::cerr << "NewTemplate3Dep::sendSelf -- ElasticState failed to send self\n";
00985 return -1;
00986 }
00987
00988 if ( ptr_yield_function != NULL )
00989 if (ptr_yield_function->sendSelf(commitTag, theChannel) < 0) {
00990 std::cerr << "NewTemplate3Dep::sendSelf -- YieldFunction failed to send self\n";
00991 return -1;
00992 }
00993
00994 if ( ptr_plastic_flow != NULL )
00995 if (ptr_plastic_flow->sendSelf(commitTag, theChannel) < 0) {
00996 std::cerr << "NewTemplate3Dep::sendSelf -- PlasticFlow failed to send self\n";
00997 return -1;
00998 }
00999
01000 if ( ptr_scalar_evolution != NULL ) {
01001 if (theChannel.sendID(this->getDbTag(), commitTag, *pID_ScalarTags) < 0) {
01002 std::cerr << "NewTemplate3Dep::sendSelf -- failed to send pID_ScalarTags\n";
01003 return -1;
01004 }
01005
01006 delete pID_ScalarTags;
01007
01008 for (int i=0; i<ptr_material_parameter->getNum_Internal_Scalar(); i++) {
01009 if (ptr_scalar_evolution[i]->sendSelf(commitTag, theChannel) < 0) {
01010 std::cerr << "NewTemplate3Dep::sendSelf -- ScalarEvolution failed to send self\n";
01011 return -1;
01012 }
01013 }
01014 }
01015
01016
01017 if ( ptr_tensor_evolution != NULL ) {
01018 if (theChannel.sendID(this->getDbTag(), commitTag, *pID_TensorTags) < 0) {
01019 std::cerr << "NewTemplate3Dep::sendSelf -- failed to send pID_TensorTags\n";
01020 return -1;
01021 }
01022 delete pID_TensorTags;
01023
01024 for (int i=0; i<ptr_material_parameter->getNum_Internal_Tensor(); i++) {
01025 if (ptr_tensor_evolution[i]->sendSelf(commitTag, theChannel) < 0) {
01026 std::cerr << "NewTemplate3Dep::sendSelf -- TensorEvolution failed to send self\n";
01027 return -1;
01028 }
01029 }
01030 }
01031 # endif
01032 return 0;
01033 }
01034
01035
01036 int NewTemplate3Dep::recvSelf(int commitTag, Channel &theChannel, FEM_ObjectBroker &theBroker)
01037 {
01038
01039 # ifdef _PARALLEL_PROCESSING
01040 int dataTag = this->getDbTag();
01041 static ID idData(13);
01042 static ID *pID_ScalarTags = NULL, *pID_TensorTags=NULL;
01043 idData.Zero();
01044
01045 if (theChannel.recvID(dataTag, commitTag, idData) < 0) {
01046 std::cerr << "NewTemplate3Dep::recvSelf -- failed to recv ID\n";
01047 return -1;
01048 }
01049
01050 this->setTag(idData(0));
01051
01052 if ( idData(1) != 0) {
01053
01054
01055
01056 ptr_material_parameter = theBroker.getNewMaterialParameterPtr();
01057
01058 if (ptr_material_parameter->recvSelf(commitTag, theChannel, theBroker) < 0) {
01059 std::cerr << "NewTemplate3Dep::recvSelf -- MaterialParameter failed to recv self\n";
01060 return -1;
01061 }
01062
01063 }
01064
01065 if ( idData(2) != 0) {
01066
01067
01068
01069 ptr_elastic_state = theBroker.getNewElasticStatePtr(idData(8));
01070
01071 if (ptr_elastic_state->recvSelf(commitTag, theChannel, theBroker) < 0) {
01072 std::cerr << "NewTemplate3Dep::recvSelf -- ElasticState failed to recv self\n";
01073 return -1;
01074 }
01075
01076 }
01077
01078 if ( idData(3) != 0) {
01079
01080
01081
01082 ptr_yield_function = theBroker.getNewYieldFunctionPtr(idData(9));
01083
01084 if (ptr_yield_function->recvSelf(commitTag, theChannel, theBroker) < 0) {
01085 std::cerr << "NewTemplate3Dep::recvSelf -- YieldFunction failed to recv self\n";
01086 return -1;
01087 }
01088
01089 }
01090
01091 if ( idData(4) != 0) {
01092
01093
01094
01095 ptr_plastic_flow = theBroker.getNewPlasticFlowPtr(idData(10));
01096
01097 if (ptr_plastic_flow->recvSelf(commitTag, theChannel, theBroker) < 0) {
01098 std::cerr << "NewTemplate3Dep::recvSelf -- PlasticFlow failed to recv self\n";
01099 return -1;
01100 }
01101
01102 }
01103
01104 if ( idData(5) != 0) {
01105
01106 const int NumScalar = ptr_material_parameter->getNum_Internal_Scalar();
01107
01108 pID_ScalarTags = new ID(NumScalar);
01109 if (theChannel.recvID(dataTag, commitTag, *pID_ScalarTags) < 0) {
01110 std::cerr << "NewTemplate3Dep::recvSelf -- failed to recv pID_ScalarTags\n";
01111 return -1;
01112 }
01113
01114 ptr_scalar_evolution = new ScalarEvolution* [NumScalar];
01115 for (int i = 0; i < NumScalar; i++) {
01116 ptr_scalar_evolution[i] = theBroker.getNewScalarEvolutionPtr((*pID_ScalarTags)(i));
01117 if (ptr_scalar_evolution[i]->recvSelf(commitTag, theChannel, theBroker) < 0) {
01118 std::cerr << "NewTemplate3Dep::recvSelf -- ScalarEvolution failed to recv self\n";
01119 return -1;
01120 }
01121 }
01122
01123 delete pID_ScalarTags;
01124
01125 }
01126
01127 if ( idData(6) != 0) {
01128
01129 const int NumTensor = ptr_material_parameter->getNum_Internal_Tensor();
01130
01131 pID_TensorTags = new ID(NumTensor);
01132 if (theChannel.recvID(dataTag, commitTag, *pID_TensorTags) < 0) {
01133 std::cerr << "NewTemplate3Dep::recvSelf -- failed to recv pID_TensorTags\n";
01134 return -1;
01135 }
01136
01137 ptr_tensor_evolution = new TensorEvolution* [NumTensor];
01138 for (int i = 0; i < NumTensor; i++) {
01139 ptr_tensor_evolution[i] = theBroker.getNewTensorEvolutionPtr((*pID_TensorTags)(i));
01140 if (ptr_tensor_evolution[i]->recvSelf(commitTag, theChannel, theBroker) < 0) {
01141 std::cerr << "NewTemplate3Dep::recvSelf -- TensorEvolution failed to recv self\n";
01142 return -1;
01143 }
01144 }
01145
01146 delete pID_TensorTags;
01147
01148 }
01149
01150 caseIndex = idData(7);
01151 subStep = idData(11);
01152 divergeOrnot = idData(12);
01153
01154 this->revertToStart();
01155
01156 # endif
01157 return 0;
01158
01159 }
01160
01161
01162 void NewTemplate3Dep::Print(OPS_Stream& s, int flag)
01163 {
01164 s << (*this);
01165 }
01166
01167
01168 int NewTemplate3Dep::Explicit(const straintensor& strain_incr, int NumStep_in)
01169 {
01170 int err = 0;
01171 int i = 0;
01172 int iStep = 0;
01173 double f_start = 0.0;
01174 double f_pred = 0.0;
01175
01176 BJtensor Ee(4, def_dim_4, 0.0);
01177 BJtensor Ep(4, def_dim_4, 0.0);
01178
01179 straintensor intersection_strain;
01180 stresstensor intersection_stress;
01181 double intersection_factor = 0.0;
01182
01183 int Num_internal_scalar = 0;
01184 int Num_internal_tensor = 0;
01185 int Num_internal_scalar_YF = 0;
01186 int Num_internal_tensor_YF = 0;
01187
01188 double upper = 0.0;
01189 double lower = 0.0;
01190 double Delta_lambda = 0.0;
01191 double hardMod = 0.0;
01192 double h_s = 0.0;
01193 double xi_s = 0.0;
01194 stresstensor dFods;
01195 straintensor dQods;
01196 BJtensor Hq(2, def_dim_2, 0.0);
01197 BJtensor Hf(2, def_dim_2, 0.0);
01198
01199 stresstensor h_t;
01200 stresstensor xi_t;
01201
01202 straintensor incr_strain;
01203 stresstensor incr_stress;
01204 straintensor incr_Pstrain;
01205 stresstensor ep_stress;
01206 stresstensor predicted_stress;
01207
01208 straintensor start_stress;
01209 stresstensor start_strain;
01210 straintensor start_Pstrain;
01211
01212 for (iStep = 1; iStep <= NumStep_in; iStep++) {
01213 start_stress = getStressTensor();
01214 start_strain = getStrainTensor();
01215 start_Pstrain = getPlasticStrainTensor();
01216
01217 intersection_stress.Initialize(start_stress);
01218
01219 err += ptr_elastic_state->setStress(start_stress);
01220 err += ptr_elastic_state->setStrain(start_strain);
01221 Ee = ptr_elastic_state->getElasticStiffness(*ptr_material_parameter);
01222
01223 incr_strain = strain_incr *(1.0/(double)(NumStep_in));
01224 incr_stress = Ee("ijpq") * incr_strain("pq");
01225 incr_stress.null_indices();
01226
01227 predicted_stress = start_stress + incr_stress;
01228
01229 f_start = ptr_yield_function->YieldFunctionValue( start_stress, *ptr_material_parameter );
01230 f_pred = ptr_yield_function->YieldFunctionValue( predicted_stress, *ptr_material_parameter );
01231
01232
01233 # ifdef _TEACHING_MODE
01234 fprintf(stdout,"explicit f_start = %12.4e",f_start);
01235 fprintf(stdout,"explicit f_pred = %12.4e",f_pred);
01236 # endif
01237
01238
01239
01240 if ( (f_start < 0.0 && f_pred <= FTOL) || f_start > f_pred ) {
01241 TrialStrain = start_strain + incr_strain;
01242 TrialStress.Initialize(predicted_stress);
01243
01244 if (iStep == NumStep_in)
01245 Stiffness = Ee;
01246 }
01247 else {
01248
01249 if ( f_start < 0.0 ) {
01250 intersection_factor = zbrentstress( start_stress, predicted_stress, 0.0, 1.0, TOL );
01251 intersection_stress = yield_surface_cross( start_stress, predicted_stress, intersection_factor );
01252 intersection_strain = start_strain + (incr_strain * intersection_factor);
01253
01254 incr_stress = predicted_stress - intersection_stress;
01255
01256 err += ptr_elastic_state->setStress(intersection_stress);
01257 err += ptr_elastic_state->setStrain(intersection_strain);
01258 Ee = ptr_elastic_state->getElasticStiffness(*ptr_material_parameter);
01259 }
01260
01261
01262 Delta_lambda = 0.0;
01263
01264 dFods = ptr_yield_function->StressDerivative( intersection_stress, *ptr_material_parameter );
01265 dQods = ptr_plastic_flow->PlasticFlowTensor( intersection_stress, intersection_strain, *ptr_material_parameter );
01266
01267
01268 Hq = Ee("ijkl") * dQods("kl");
01269 Hq.null_indices();
01270
01271
01272 Hf = dFods("ij") * Ee("ijkl");
01273 Hf.null_indices();
01274
01275
01276 upper = ( dFods("ij") * incr_stress("ij") ).trace();
01277
01278
01279 lower = ( Hf("ij") * dQods("ij") ).trace();
01280
01281 hardMod = 0.0;
01282
01283
01284 Num_internal_scalar_YF = ptr_yield_function->getNumInternalScalar();
01285 for (i = 0; i < Num_internal_scalar_YF; i++) {
01286 h_s = ptr_scalar_evolution[i]->H(*ptr_plastic_flow, intersection_stress, intersection_strain, *ptr_material_parameter);
01287 xi_s = ptr_yield_function->InScalarDerivative( intersection_stress, *ptr_material_parameter, i+1);
01288 hardMod += h_s * xi_s;
01289 }
01290
01291
01292 Num_internal_tensor_YF = ptr_yield_function->getNumInternalTensor();
01293 for (i = 0; i < Num_internal_tensor_YF; i++) {
01294 h_t = ptr_tensor_evolution[i]->Hij(*ptr_plastic_flow, intersection_stress, intersection_strain, *ptr_material_parameter);
01295 xi_t = ptr_yield_function->InTensorDerivative( intersection_stress, *ptr_material_parameter, i+1);
01296 hardMod += ( h_t("mn") * xi_t("mn") ).trace();
01297 }
01298
01299 lower -= hardMod;
01300
01301 Delta_lambda = upper / lower;
01302
01303 if (Delta_lambda < 0.0)
01304 Delta_lambda = 0.0;
01305
01306
01307 incr_Pstrain = dQods * Delta_lambda;
01308 ep_stress = predicted_stress - (Hq *Delta_lambda);
01309
01310 TrialStress.Initialize(ep_stress);
01311 TrialStrain = start_strain + incr_strain;
01312 TrialPlastic_Strain = start_Pstrain + incr_Pstrain;
01313
01314
01315 Num_internal_scalar = ptr_material_parameter->getNum_Internal_Scalar();
01316 for (i = 0; i < Num_internal_scalar; i++) {
01317 double dS = ( ptr_scalar_evolution[i]->H(*ptr_plastic_flow, intersection_stress, intersection_strain, *ptr_material_parameter) ) *Delta_lambda;
01318 double S = ptr_material_parameter->getInternal_Scalar(i);
01319 err += ptr_material_parameter->setInternal_Scalar(i, S + dS );
01320 }
01321
01322
01323 Num_internal_tensor = ptr_material_parameter->getNum_Internal_Tensor();
01324 for (i = 0; i < Num_internal_tensor; i++) {
01325 stresstensor dT = ptr_tensor_evolution[i]->Hij(*ptr_plastic_flow, intersection_stress, intersection_strain, *ptr_material_parameter) *Delta_lambda;
01326 stresstensor T = ptr_material_parameter->getInternal_Tensor(i);
01327 err += ptr_material_parameter->setInternal_Tensor(i, T + dT );
01328 }
01329
01330
01331 if (iStep == NumStep_in) {
01332 Ep = Hq("pq") * Hf("mn");
01333 Ep.null_indices();
01334 Ep = Ep * (1.0/lower);
01335
01336 if ( Delta_lambda > 0.0 )
01337 Stiffness = Ee - Ep;
01338 else
01339 Stiffness = Ee;
01340 }
01341
01342 }
01343
01344 }
01345
01346 return err;
01347 }
01348
01349
01350 int NewTemplate3Dep::Implicit(const straintensor& strain_incr, int NumStep_in)
01351 {
01352
01353
01354
01355 int err = 0;
01356 int i = 0;
01357 int j = 0;
01358 int iStep = 0;
01359 double YieldFun = 0.0;
01360
01361 BJtensor Ee(4, def_dim_4, 0.0);
01362
01363
01364 BJtensor Ce(4, def_dim_4, 0.0);
01365
01366 int Num_internal_scalar_YF = 0;
01367 int Num_internal_tensor_YF = 0;
01368 int Num_internal_scalar = 0;
01369 int Num_internal_tensor = 0;
01370
01371 stresstensor start_stress;
01372 stresstensor start_strain;
01373 straintensor start_Pstrain;
01374
01375 straintensor incr_strain;
01376 stresstensor incr_stress;
01377 stresstensor PredictedStress;
01378
01379 double start_InScalar = 0.0;
01380 tensor start_InTensor(2, def_dim_2, 0.0);
01381 tensor start_InTensor2(2, def_dim_2, 0.0);
01382
01383 this->divergeOrnot = 0;
01384
01385 for (iStep = 1; iStep <= NumStep_in; iStep++)
01386 {
01387 start_stress = getStressTensor();
01388 start_strain = getStrainTensor();
01389 start_Pstrain = getPlasticStrainTensor();
01390
01391 Num_internal_scalar = ptr_material_parameter->getNum_Internal_Scalar();
01392 if (Num_internal_scalar > 1)
01393 {
01394 cout << "Error, NewTemplate3Dep::Backward Agorithm, scalar internal variables more than 1!" << endln;
01395 exit(1);
01396 }
01397 else if (Num_internal_scalar == 1)
01398 {
01399 start_InScalar = ptr_material_parameter->getInternal_Scalar(0);
01400 }
01401
01402 Num_internal_tensor = ptr_material_parameter->getNum_Internal_Tensor();
01403 if (Num_internal_tensor > 2)
01404 {
01405 cout << "Error, NewTemplate3Dep::Backward Agorithm, scalar internal variables more than 1!" << endln;
01406 exit(1);
01407 }
01408 else if (Num_internal_tensor == 1)
01409 {
01410 start_InTensor = ptr_material_parameter->getInternal_Tensor(0);
01411 }
01412 else if (Num_internal_tensor == 2)
01413 {
01414 start_InTensor = ptr_material_parameter->getInternal_Tensor(0);
01415 start_InTensor2 = ptr_material_parameter->getInternal_Tensor(1);
01416 }
01417
01418 err += ptr_elastic_state->setStress(start_stress);
01419 err += ptr_elastic_state->setStrain(start_strain);
01420
01421 Ee = ptr_elastic_state->getElasticStiffness(*ptr_material_parameter);
01422
01423 incr_strain = strain_incr *(1.0/(double)(NumStep_in));
01424
01425
01426 incr_stress = Ee("ijpq") * incr_strain("pq");
01427 incr_stress.null_indices();
01428 PredictedStress = start_stress + incr_stress;
01429
01430 TrialStrain = start_strain + incr_strain;
01431
01432
01433
01434
01435
01436
01437
01438
01439 incr_stress = Ee("ijpq") * incr_strain("pq");
01440 incr_stress.null_indices();
01441 PredictedStress = start_stress + incr_stress;
01442
01443 # ifdef _TEACHING_MODE
01444 PredictedStress.report(" NewTemplate3Dep::Implicit( PredictedStress");
01445 #endif
01446
01447 TrialStress.Initialize(PredictedStress);
01448 TrialPlastic_Strain.Initialize(start_Pstrain);
01449
01450 YieldFun = ptr_yield_function->YieldFunctionValue(TrialStress, *ptr_material_parameter);
01451
01452
01453 if ( YieldFun <= FTOL )
01454
01455 {
01456 if (iStep == NumStep_in)
01457 {
01458 Stiffness = Ee;
01459 }
01460
01461 }
01462 else
01463
01464 {
01465
01466
01467 double YieldFun1 = 0.0;
01468 double YieldFun2 = 0.0;
01469 double YieldFun_relative = 0.0;
01470
01471 double Delta_lambda = 0.0;
01472 double d2_lambda = 0.0;
01473 double RNorm = 0.0;
01474 double RNorm_relative = 0.0;
01475 int iter_counter = 0;
01476 double upper = 0.0;
01477 double lower = 0.0;
01478
01479 stresstensor dFods;
01480 double dFodq = 0.0;
01481 stresstensor dFoda;
01482 stresstensor dFoda2;
01483
01484 straintensor m;
01485 double hi = 0.0;
01486 straintensor hk;
01487 straintensor hk2;
01488
01489 stresstensor Dstress;
01490 double Dq = 0.0;
01491 tensor Da(2, def_dim_2, 0.0);
01492 tensor Da2(2, def_dim_2, 0.0);
01493
01494 stresstensor Rstress;
01495 double Rq = 0.0;
01496 tensor Ra(2, def_dim_2, 0.0);
01497 tensor Ra2(2, def_dim_2, 0.0);
01498
01499 tensor dmods(4, def_dim_4, 0.0);
01500
01501 straintensor DPlastic_Strain;
01502
01503 Matrix M66(6, 6);
01504 Vector V6(6);
01505 Vector T6(6);
01506
01507 double S = 0.0;
01508 stresstensor T;
01509 stresstensor T2;
01510
01511 int numMV = 6 + Num_internal_scalar + Num_internal_tensor*6;
01512
01513 Matrix CC(numMV, numMV);
01514 Matrix CI(numMV, numMV);
01515 Vector R19(numMV);
01516 Vector N19(numMV);
01517 Vector M19(numMV);
01518 Vector D19(numMV);
01519 Vector T19(numMV);
01520
01521 BJtensor Ttemp(4, def_dim_4, 0.0);
01522
01523
01524 YieldFun_relative = YieldFun*FTOL > TOL ? YieldFun*FTOL : TOL;
01525 YieldFun1 = YieldFun;
01526
01527
01528 do
01529 {
01530
01531
01532
01533 M19.Zero();
01534
01535 m = ptr_plastic_flow->PlasticFlowTensor(TrialStress, TrialStrain, *ptr_material_parameter);
01536 m = Ee("ijpq") * m("pq");
01537 m.null_indices();
01538
01539 err += Tensor2VectorSysR2(m, V6);
01540 for (i=0; i<6; i++)
01541 M19(i) = V6(i);
01542
01543 if (Num_internal_scalar == 1)
01544 {
01545 hi =
01546 ptr_scalar_evolution[0]->H(*ptr_plastic_flow, TrialStress, TrialStrain, *ptr_material_parameter);
01547
01548 M19(6) = -hi;
01549 }
01550
01551 if (Num_internal_tensor >= 1)
01552 {
01553 hk =
01554 ptr_tensor_evolution[0]->Hij(*ptr_plastic_flow, TrialStress, TrialStrain, *ptr_material_parameter);
01555
01556 err += Tensor2VectorSysR2(hk, V6);
01557
01558 for (i=0; i<6; i++)
01559 M19(6+Num_internal_scalar+i) = -V6(i);
01560 }
01561
01562 if (Num_internal_tensor == 2)
01563 {
01564 hk2 =
01565 ptr_tensor_evolution[1]->Hij(*ptr_plastic_flow, TrialStress, TrialStrain, *ptr_material_parameter);
01566
01567 err += Tensor2VectorSysR2(hk2, V6);
01568
01569 for (i=0; i<6; i++)
01570 M19(12+Num_internal_scalar+i) = -V6(i);
01571 }
01572
01573
01574 N19.Zero();
01575
01576 dFods = ptr_yield_function->StressDerivative(TrialStress, *ptr_material_parameter);
01577
01578
01579
01580 err += Tensor2VectorSysR2(dFods, V6);
01581
01582 for (i=0; i<6; i++)
01583 N19(i) = V6(i);
01584
01585 Num_internal_scalar_YF = ptr_yield_function->getNumInternalScalar();
01586 if (Num_internal_scalar_YF > 1)
01587 {
01588 cout << "Error, NewTemplate3Dep::Backward Agorithm, scalar internal variables more than 1!" << endln;
01589 exit(1);
01590 }
01591
01592 else if (Num_internal_scalar_YF == 1)
01593 {
01594 dFodq = ptr_yield_function->InScalarDerivative(TrialStress, *ptr_material_parameter, 1);
01595 N19(6) = dFodq;
01596 }
01597
01598 Num_internal_tensor_YF = ptr_yield_function->getNumInternalTensor();
01599
01600 if (Num_internal_tensor_YF > 2)
01601 {
01602 cout << "Error, NewTemplate3Dep::Backward Agorithm, tensor internal variables more than 1!" << endln;
01603 exit(1);
01604 }
01605 else if (Num_internal_tensor_YF == 1)
01606 {
01607 dFoda = ptr_yield_function->InTensorDerivative(TrialStress, *ptr_material_parameter, 1);
01608 err += Tensor2VectorSysR2(dFoda, V6);
01609 for (i=0; i<6; i++)
01610 N19(6+Num_internal_scalar+i) = V6(i);
01611 }
01612 else if (Num_internal_tensor_YF == 2)
01613 {
01614 dFoda = ptr_yield_function->InTensorDerivative(TrialStress, *ptr_material_parameter, 1);
01615 err += Tensor2VectorSysR2(dFoda, V6);
01616 for (i=0; i<6; i++)
01617 N19(6+Num_internal_scalar+i) = V6(i);
01618
01619 dFoda2 = ptr_yield_function->InTensorDerivative(TrialStress, *ptr_material_parameter, 2);
01620 err += Tensor2VectorSysR2(dFoda2, V6);
01621 for (i=0; i<6; i++)
01622 N19(12+Num_internal_scalar+i) = V6(i);
01623 }
01624
01625
01626 if (iter_counter == 0)
01627 {
01628 R19.Zero();
01629 CI.Zero();
01630
01631 for (i=0; i<numMV; i++)
01632 CI(i, i) = 1.0;
01633 }
01634
01635
01636 upper = 0.0;
01637 lower = 0.0;
01638
01639
01640
01641
01642
01643
01644
01645
01646
01647 T19.addMatrixVector(0.0, CI, R19, 1.0);
01648 for (i=0; i<numMV; i++)
01649 upper += N19(i) * T19(i);
01650
01651
01652
01653 T19.addMatrixVector(0.0, CI, M19, 1.0);
01654 for (i=0; i<numMV; i++)
01655 lower += N19(i) * T19(i);
01656
01657 d2_lambda = (YieldFun - upper) / lower;
01658
01659
01660 iter_counter++;
01661
01662 Delta_lambda += d2_lambda;
01663
01664
01665
01666
01667 T19 = R19 + M19*d2_lambda;
01668
01669 D19.addMatrixVector(0.0, CI, T19, -1.0);
01670
01671 err += Vector2TensorSysR2(D19, Dstress, 0);
01672
01673 # ifdef _TEACHING_MODE
01674 TrialStress.report(" NewTemplate3Dep::Implicit( TrialStress");
01675 #endif
01676 TrialStress += Dstress;
01677
01678
01679
01680
01681
01682 if (Num_internal_scalar == 1)
01683 {
01684
01685 Dq = D19(6);
01686
01687
01688
01689
01690
01691 S = ptr_material_parameter->getInternal_Scalar(0);
01692 err += ptr_material_parameter->setInternal_Scalar(0, S + Dq );
01693 }
01694
01695 if (Num_internal_tensor >= 1)
01696 {
01697 err += Vector2TensorSysR2(D19, Da, 6+Num_internal_scalar);
01698 stresstensor T = ptr_material_parameter->getInternal_Tensor(0);
01699 err += ptr_material_parameter->setInternal_Tensor(0, T + Da );
01700 }
01701
01702 if (Num_internal_tensor == 2)
01703 {
01704 err += Vector2TensorSysR2(D19, Da2, 12+Num_internal_scalar);
01705 stresstensor T2 = ptr_material_parameter->getInternal_Tensor(1);
01706 err += ptr_material_parameter->setInternal_Tensor(1, T2 + Da2 );
01707 }
01708
01709 DPlastic_Strain = Ce("ijkl")*Dstress("kl");
01710 DPlastic_Strain.null_indices();
01711
01712 TrialPlastic_Strain -= DPlastic_Strain;
01713
01714 YieldFun = ptr_yield_function->YieldFunctionValue(TrialStress, *ptr_material_parameter);
01715
01716
01717 YieldFun2 = YieldFun;
01718
01719 if ( (fabs(YieldFun2) > fabs(YieldFun1) || iter_counter == ITMAX) && this->caseIndex == 2 )
01720 {
01721 this->divergeOrnot = 1;
01722
01723 cout << "Error, NewTemplate3Dep::Backward Agorithm, this->divergeOrnot = 1 !" << endln;
01724
01725 return 0;
01726 }
01727
01728 YieldFun1 = YieldFun;
01729
01730
01731 R19.Zero();
01732
01733
01734 Rstress = TrialStress - PredictedStress + (m *Delta_lambda);
01735
01736
01737
01738
01739
01740
01741
01742 err += Tensor2VectorSysR2(Rstress, V6);
01743 for (i=0; i<6; i++)
01744 R19(i) = V6(i);
01745
01746 if (Num_internal_scalar == 1)
01747 {
01748
01749
01750
01751
01752
01753 S = ptr_material_parameter->getInternal_Scalar(0);
01754 Rq = S - start_InScalar - (hi *Delta_lambda);
01755 R19(6) = Rq;
01756 }
01757
01758 if (Num_internal_tensor >= 1)
01759 {
01760 T = ptr_material_parameter->getInternal_Tensor(0);
01761 Ra = T - start_InTensor - (hk *Delta_lambda);
01762 err += Tensor2VectorSysR2(Ra, V6);
01763 for (i=0; i<6; i++)
01764 R19(6+Num_internal_scalar+i) = V6(i);
01765 }
01766
01767 if (Num_internal_tensor == 2)
01768 {
01769 T2 = ptr_material_parameter->getInternal_Tensor(1);
01770 Ra2 = T2 - start_InTensor2 - (hk2 *Delta_lambda);
01771 err += Tensor2VectorSysR2(Ra2, V6);
01772 for (i=0; i<6; i++)
01773 R19(12+Num_internal_scalar+i) = V6(i);
01774 }
01775
01776 RNorm = R19.Norm();
01777
01778
01779
01780 CC.Zero();
01781
01782 dmods = ptr_plastic_flow->Dm_Ds(TrialStress, TrialStrain, *ptr_material_parameter);
01783 dmods = Ee("ijpq") * dmods("pqmn");
01784 dmods.null_indices();
01785
01786
01787 err += Tensor2MatrixSysR4(dmods, M66);
01788 for (i=0; i<6; i++) {
01789 for (j=0; j<6; j++) {
01790 CC(i, j) = M66(i, j);
01791 }
01792 }
01793
01794
01795 if (Num_internal_scalar == 1 && Num_internal_tensor == 0)
01796 {
01797
01798 tensor dmodq(2, def_dim_2, 0.0);
01799
01800 tensor dhiods(2, def_dim_2, 0.0);
01801 double dhiodq = 0.0;
01802
01803 dmodq = ptr_plastic_flow->Dm_Diso(TrialStress, TrialStrain, *ptr_material_parameter);
01804 dmodq = Ee("ijpq") * dmodq("pq");
01805 dmodq.null_indices();
01806
01807 err += Tensor2VectorSysR2(dmodq, V6);
01808 for (i=0; i<6; i++)
01809 CC(i, 6) = V6(i);
01810
01811 dhiods = ptr_scalar_evolution[0]->DH_Ds(*ptr_plastic_flow, TrialStress, TrialStrain, *ptr_material_parameter);
01812 dhiodq = ptr_scalar_evolution[0]->DH_Diso(*ptr_plastic_flow, TrialStress, TrialStrain, *ptr_material_parameter);
01813
01814 err += Tensor2VectorSysR2(dhiods, V6);
01815 for (i=0; i<6; i++)
01816 CC(6, i) = -V6(i);
01817
01818 CC(6, 6) = -dhiodq;
01819 }
01820
01821
01822 if (Num_internal_scalar == 1 && Num_internal_tensor == 1)
01823 {
01824 tensor dmodq(2, def_dim_2, 0.0);
01825 tensor dmoda(4, def_dim_4, 0.0);
01826
01827 tensor dhiods(2, def_dim_2, 0.0);
01828 double dhiodq = 0.0;
01829 tensor dhioda(2, def_dim_2, 0.0);
01830
01831 tensor dhkods(4, def_dim_4, 0.0);
01832 tensor dhkodq(2, def_dim_2, 0.0);
01833 tensor dhkoda(4, def_dim_4, 0.0);
01834
01835 dmodq = ptr_plastic_flow->Dm_Diso(TrialStress, TrialStrain, *ptr_material_parameter);
01836 dmoda = ptr_plastic_flow->Dm_Dkin(TrialStress, TrialStrain, *ptr_material_parameter);
01837 dmodq = Ee("ijpq") * dmodq("pq");
01838 dmodq.null_indices();
01839 dmoda = Ee("ijpq") * dmoda("pqmn");
01840 dmoda.null_indices();
01841
01842 err += Tensor2VectorSysR2(dmodq, V6);
01843 for (i=0; i<6; i++)
01844 CC(i, 6) = V6(i);
01845
01846 err += Tensor2MatrixSysR4(dmoda, M66);
01847 for (i=0; i<6; i++)
01848 {
01849 for (j=0; j<6; j++)
01850 {
01851 CC(i, 7+j) = M66(i,j);
01852 }
01853 }
01854
01855 dhiods = ptr_scalar_evolution[0]->DH_Ds(*ptr_plastic_flow, TrialStress, TrialStrain, *ptr_material_parameter);
01856 dhiodq = ptr_scalar_evolution[0]->DH_Diso(*ptr_plastic_flow, TrialStress, TrialStrain, *ptr_material_parameter);
01857 dhioda = ptr_scalar_evolution[0]->DH_Dkin(*ptr_plastic_flow, TrialStress, TrialStrain, *ptr_material_parameter);
01858
01859 err += Tensor2VectorSysR2(dhiods, V6);
01860 for (i=0; i<6; i++)
01861 CC(6, i) = -V6(i);
01862
01863 CC(6, 6) = -dhiodq;
01864
01865 err += Tensor2VectorSysR2(dhioda, V6);
01866 for (i=0; i<6; i++)
01867 CC(6, 7+i) = -V6(i);
01868
01869 dhkods = ptr_tensor_evolution[0]->DHij_Ds(*ptr_plastic_flow, TrialStress, TrialStrain, *ptr_material_parameter);
01870 dhkodq = ptr_tensor_evolution[0]->DHij_Diso(*ptr_plastic_flow, TrialStress, TrialStrain, *ptr_material_parameter);
01871 dhkoda = ptr_tensor_evolution[0]->DHij_Dkin(*ptr_plastic_flow, TrialStress, TrialStrain, *ptr_material_parameter);
01872
01873 err += Tensor2MatrixSysR4(dhkods, M66);
01874 for (i=0; i<6; i++) {
01875 for (j=0; j<6; j++) {
01876 CC(7+i, j) = -M66(i,j);
01877 }
01878 }
01879
01880 err += Tensor2VectorSysR2(dhkodq, V6);
01881 for (i=0; i<6; i++)
01882 CC(7+i, 6) = -V6(i);
01883
01884 err += Tensor2MatrixSysR4(dhkoda, M66);
01885 for (i=0; i<6; i++) {
01886 for (j=0; j<6; j++) {
01887 CC(7+i, 7+j) = -M66(i,j);
01888 }
01889 }
01890
01891 }
01892
01893
01894 if (Num_internal_scalar == 1 && Num_internal_tensor == 2)
01895 {
01896 tensor dmodq(2, def_dim_2, 0.0);
01897 tensor dmoda(4, def_dim_4, 0.0);
01898 tensor dmoda2(4, def_dim_4, 0.0);
01899
01900 tensor dhiods(2, def_dim_2, 0.0);
01901 double dhiodq = 0.0;
01902 tensor dhioda(2, def_dim_2, 0.0);
01903 tensor dhioda2(2, def_dim_2, 0.0);
01904
01905 tensor dhkods(4, def_dim_4, 0.0);
01906 tensor dhkodq(2, def_dim_2, 0.0);
01907 tensor dhkoda(4, def_dim_4, 0.0);
01908 tensor dhkoda2(4, def_dim_4, 0.0);
01909
01910 tensor dhk2ods(4, def_dim_4, 0.0);
01911 tensor dhk2odq(2, def_dim_2, 0.0);
01912 tensor dhk2oda(4, def_dim_4, 0.0);
01913 tensor dhk2oda2(4, def_dim_4, 0.0);
01914
01915 dmodq = ptr_plastic_flow->Dm_Diso(TrialStress, TrialStrain, *ptr_material_parameter);
01916 dmoda = ptr_plastic_flow->Dm_Dkin(TrialStress, TrialStrain, *ptr_material_parameter);
01917 dmoda2 = ptr_plastic_flow->Dm_Dkin2(TrialStress, TrialStrain, *ptr_material_parameter);
01918 dmodq = Ee("ijpq") * dmodq("pq");
01919 dmodq.null_indices();
01920 dmoda = Ee("ijpq") * dmoda("pqmn");
01921 dmoda.null_indices();
01922 dmoda2 = Ee("ijpq") * dmoda2("pqmn");
01923 dmoda2.null_indices();
01924
01925 err += Tensor2VectorSysR2(dmodq, V6);
01926 for (i=0; i<6; i++)
01927 CC(i, 6) = V6(i);
01928
01929
01930
01931
01932
01933
01934
01935 err += Tensor2MatrixSysR4(dmoda, M66);
01936 for (i=0; i<6; i++) {
01937 for (j=0; j<6; j++) {
01938 CC(i, 7+j) = M66(i,j);
01939 }
01940 }
01941
01942 err += Tensor2MatrixSysR4(dmoda2, M66);
01943 for (i=0; i<6; i++) {
01944 for (j=0; j<6; j++) {
01945 CC(i, 13+j) = M66(i,j);
01946 }
01947 }
01948
01949 dhiods = ptr_scalar_evolution[0]->DH_Ds(*ptr_plastic_flow, TrialStress, TrialStrain, *ptr_material_parameter);
01950 dhiodq = ptr_scalar_evolution[0]->DH_Diso(*ptr_plastic_flow, TrialStress, TrialStrain, *ptr_material_parameter);
01951 dhioda = ptr_scalar_evolution[0]->DH_Dkin(*ptr_plastic_flow, TrialStress, TrialStrain, *ptr_material_parameter);
01952 dhioda2 = ptr_scalar_evolution[0]->DH_Dkin2(*ptr_plastic_flow, TrialStress, TrialStrain, *ptr_material_parameter);
01953
01954 err += Tensor2VectorSysR2(dhiods, V6);
01955 for (i=0; i<6; i++)
01956 CC(6, i) = -V6(i);
01957
01958 CC(6, 6) = -dhiodq;
01959
01960 err += Tensor2VectorSysR2(dhioda, V6);
01961 for (i=0; i<6; i++)
01962 CC(6, 7+i) = -V6(i);
01963
01964 err += Tensor2VectorSysR2(dhioda2, V6);
01965 for (i=0; i<6; i++)
01966 CC(6, 13+i) = -V6(i);
01967
01968 dhkods = ptr_tensor_evolution[0]->DHij_Ds(*ptr_plastic_flow, TrialStress, TrialStrain, *ptr_material_parameter);
01969 dhkodq = ptr_tensor_evolution[0]->DHij_Diso(*ptr_plastic_flow, TrialStress, TrialStrain, *ptr_material_parameter);
01970 dhkoda = ptr_tensor_evolution[0]->DHij_Dkin(*ptr_plastic_flow, TrialStress, TrialStrain, *ptr_material_parameter);
01971 dhkoda2 = ptr_tensor_evolution[0]->DHij_Dkin2(*ptr_plastic_flow, TrialStress, TrialStrain, *ptr_material_parameter);
01972
01973 err += Tensor2MatrixSysR4(dhkods, M66);
01974 for (i=0; i<6; i++) {
01975 for (j=0; j<6; j++) {
01976 CC(7+i, j) = -M66(i,j);
01977 }
01978 }
01979
01980 err += Tensor2VectorSysR2(dhkodq, V6);
01981 for (i=0; i<6; i++)
01982 CC(7+i, 6) = -V6(i);
01983
01984 err += Tensor2MatrixSysR4(dhkoda, M66);
01985 for (i=0; i<6; i++) {
01986 for (j=0; j<6; j++) {
01987 CC(7+i, 7+j) = -M66(i,j);
01988 }
01989 }
01990
01991 err += Tensor2MatrixSysR4(dhkoda2, M66);
01992 for (i=0; i<6; i++) {
01993 for (j=0; j<6; j++) {
01994 CC(7+i, 13+j) = -M66(i,j);
01995 }
01996 }
01997
01998 dhk2ods = ptr_tensor_evolution[1]->DHij_Ds(*ptr_plastic_flow, TrialStress, TrialStrain, *ptr_material_parameter);
01999 dhk2odq = ptr_tensor_evolution[1]->DHij_Diso(*ptr_plastic_flow, TrialStress, TrialStrain, *ptr_material_parameter);
02000 dhk2oda = ptr_tensor_evolution[1]->DHij_Dkin(*ptr_plastic_flow, TrialStress, TrialStrain, *ptr_material_parameter);
02001 dhk2oda2 = ptr_tensor_evolution[1]->DHij_Dkin2(*ptr_plastic_flow, TrialStress, TrialStrain, *ptr_material_parameter);
02002
02003 err += Tensor2MatrixSysR4(dhk2ods, M66);
02004 for (i=0; i<6; i++) {
02005 for (j=0; j<6; j++) {
02006 CC(13+i, j) = -M66(i,j);
02007 }
02008 }
02009
02010 err += Tensor2VectorSysR2(dhk2odq, V6);
02011 for (i=0; i<6; i++)
02012 CC(13+i, 6) = -V6(i);
02013
02014 err += Tensor2MatrixSysR4(dhk2oda, M66);
02015 for (i=0; i<6; i++) {
02016 for (j=0; j<6; j++) {
02017 CC(13+i, 7+j) = -M66(i,j);
02018 }
02019 }
02020
02021 err += Tensor2MatrixSysR4(dhk2oda2, M66);
02022 for (i=0; i<6; i++) {
02023 for (j=0; j<6; j++) {
02024 CC(13+i, 13+j) = -M66(i,j);
02025 }
02026 }
02027
02028 }
02029
02030
02031 if (Num_internal_scalar == 0 && Num_internal_tensor == 1)
02032 {
02033 tensor dmoda(4, def_dim_4, 0.0);
02034
02035 tensor dhkods(4, def_dim_4, 0.0);
02036 tensor dhkoda(4, def_dim_4, 0.0);
02037
02038 dmoda = ptr_plastic_flow->Dm_Dkin(TrialStress, TrialStrain, *ptr_material_parameter);
02039 dmoda = Ee("ijpq") * dmoda("pqmn");
02040 dmoda.null_indices();
02041
02042 err += Tensor2MatrixSysR4(dmoda, M66);
02043 for (i=0; i<6; i++) {
02044 for (j=0; j<6; j++) {
02045 CC(i, 6+j) = M66(i,j);
02046 }
02047 }
02048
02049 dhkods = ptr_tensor_evolution[0]->DHij_Ds(*ptr_plastic_flow, TrialStress, TrialStrain, *ptr_material_parameter);
02050 dhkoda = ptr_tensor_evolution[0]->DHij_Dkin(*ptr_plastic_flow, TrialStress, TrialStrain, *ptr_material_parameter);
02051
02052 err += Tensor2MatrixSysR4(dhkods, M66);
02053 for (i=0; i<6; i++) {
02054 for (j=0; j<6; j++) {
02055 CC(6+i, j) = -M66(i,j);
02056 }
02057 }
02058
02059 err += Tensor2MatrixSysR4(dhkoda, M66);
02060 for (i=0; i<6; i++) {
02061 for (j=0; j<6; j++) {
02062 CC(6+i, 6+j) = -M66(i,j);
02063 }
02064 }
02065
02066 }
02067
02068
02069 if (Num_internal_scalar == 0 && Num_internal_tensor == 2)
02070 {
02071 tensor dmoda(4, def_dim_4, 0.0);
02072 tensor dmoda2(4, def_dim_4, 0.0);
02073
02074 tensor dhkods(4, def_dim_4, 0.0);
02075 tensor dhkoda(4, def_dim_4, 0.0);
02076 tensor dhkoda2(4, def_dim_4, 0.0);
02077
02078 tensor dhk2ods(4, def_dim_4, 0.0);
02079 tensor dhk2oda(4, def_dim_4, 0.0);
02080 tensor dhk2oda2(4, def_dim_4, 0.0);
02081
02082 dmoda = ptr_plastic_flow->Dm_Dkin(TrialStress, TrialStrain, *ptr_material_parameter);
02083 dmoda2 = ptr_plastic_flow->Dm_Dkin2(TrialStress, TrialStrain, *ptr_material_parameter);
02084 dmoda = Ee("ijpq") * dmoda("pqmn");
02085 dmoda.null_indices();
02086 dmoda2 = Ee("ijpq") * dmoda2("pqmn");
02087 dmoda2.null_indices();
02088
02089 err += Tensor2MatrixSysR4(dmoda, M66);
02090 for (i=0; i<6; i++) {
02091 for (j=0; j<6; j++) {
02092 CC(i, 6+j) = M66(i,j);
02093 }
02094 }
02095
02096 err += Tensor2MatrixSysR4(dmoda2, M66);
02097 for (i=0; i<6; i++) {
02098 for (j=0; j<6; j++) {
02099 CC(i, 12+j) = M66(i,j);
02100 }
02101 }
02102
02103 dhkods = ptr_tensor_evolution[0]->DHij_Ds(*ptr_plastic_flow, TrialStress, TrialStrain, *ptr_material_parameter);
02104 dhkoda = ptr_tensor_evolution[0]->DHij_Dkin(*ptr_plastic_flow, TrialStress, TrialStrain, *ptr_material_parameter);
02105 dhkoda2 = ptr_tensor_evolution[0]->DHij_Dkin2(*ptr_plastic_flow, TrialStress, TrialStrain, *ptr_material_parameter);
02106
02107 err += Tensor2MatrixSysR4(dhkods, M66);
02108 for (i=0; i<6; i++) {
02109 for (j=0; j<6; j++) {
02110 CC(6+i, j) = -M66(i,j);
02111 }
02112 }
02113
02114 err += Tensor2MatrixSysR4(dhkoda, M66);
02115 for (i=0; i<6; i++) {
02116 for (j=0; j<6; j++) {
02117 CC(6+i, 6+j) = -M66(i,j);
02118 }
02119 }
02120
02121 err += Tensor2MatrixSysR4(dhkoda2, M66);
02122 for (i=0; i<6; i++) {
02123 for (j=0; j<6; j++) {
02124 CC(6+i, 12+j) = -M66(i,j);
02125 }
02126 }
02127
02128 dhk2ods = ptr_tensor_evolution[1]->DHij_Ds(*ptr_plastic_flow, TrialStress, TrialStrain, *ptr_material_parameter);
02129 dhk2oda = ptr_tensor_evolution[1]->DHij_Dkin(*ptr_plastic_flow, TrialStress, TrialStrain, *ptr_material_parameter);
02130 dhk2oda2 = ptr_tensor_evolution[1]->DHij_Dkin2(*ptr_plastic_flow, TrialStress, TrialStrain, *ptr_material_parameter);
02131
02132 err += Tensor2MatrixSysR4(dhk2ods, M66);
02133 for (i=0; i<6; i++) {
02134 for (j=0; j<6; j++) {
02135 CC(12+i, j) = -M66(i,j);
02136 }
02137 }
02138
02139 err += Tensor2MatrixSysR4(dhk2oda, M66);
02140 for (i=0; i<6; i++) {
02141 for (j=0; j<6; j++) {
02142 CC(12+i, 6+j) = -M66(i,j);
02143 }
02144 }
02145
02146 err += Tensor2MatrixSysR4(dhk2oda2, M66);
02147 for (i=0; i<6; i++) {
02148 for (j=0; j<6; j++) {
02149 CC(12+i, 12+j) = -M66(i,j);
02150 }
02151 }
02152
02153 }
02154
02155 CC *= Delta_lambda;
02156
02157 for (i=0; i<numMV; i++)
02158 CC(i, i) = 1.0 + CC(i, i);
02159
02160 err += CC.Invert(CI);
02161
02162
02163
02164
02165
02166
02167
02168
02169 }
02170 while ( (fabs(YieldFun) > YieldFun_relative || RNorm > TOL) && iter_counter < ITMAX);
02171
02172
02173
02174
02175
02176
02177
02178
02179
02180
02181
02182
02183
02184
02185
02186
02187
02188
02189 M19.Zero();
02190
02191 m = ptr_plastic_flow->PlasticFlowTensor(TrialStress, TrialStrain, *ptr_material_parameter);
02192 m = Ee("ijpq") * m("pq");
02193 m.null_indices();
02194 err += Tensor2VectorSysR2(m, V6);
02195 for (i=0; i<6; i++)
02196 M19(i) = V6(i);
02197
02198 if (Num_internal_scalar == 1)
02199 {
02200 hi = ptr_scalar_evolution[0]->H(*ptr_plastic_flow, TrialStress, TrialStrain, *ptr_material_parameter);
02201 M19(6) = -hi;
02202 }
02203
02204 if (Num_internal_tensor >= 1)
02205 {
02206 hk = ptr_tensor_evolution[0]->Hij(*ptr_plastic_flow, TrialStress, TrialStrain, *ptr_material_parameter);
02207 err += Tensor2VectorSysR2(hk, V6);
02208 for (i=0; i<6; i++)
02209 M19(6+Num_internal_scalar+i) = -V6(i);
02210 }
02211
02212 if (Num_internal_tensor == 2)
02213 {
02214 hk2 = ptr_tensor_evolution[1]->Hij(*ptr_plastic_flow, TrialStress, TrialStrain, *ptr_material_parameter);
02215 err += Tensor2VectorSysR2(hk2, V6);
02216 for (i=0; i<6; i++)
02217 M19(12+Num_internal_scalar+i) = -V6(i);
02218 }
02219
02220
02221 N19.Zero();
02222
02223 dFods = ptr_yield_function->StressDerivative(TrialStress, *ptr_material_parameter);
02224 err += Tensor2VectorSysR2(dFods, V6);
02225
02226 for (i=0; i<6; i++)
02227 N19(i) = V6(i);
02228
02229 if (Num_internal_scalar_YF == 1)
02230 {
02231 dFodq = ptr_yield_function->InScalarDerivative(TrialStress, *ptr_material_parameter, 1);
02232 N19(6) = dFodq;
02233 }
02234
02235 if (Num_internal_tensor_YF == 1)
02236 {
02237 dFoda = ptr_yield_function->InTensorDerivative(TrialStress, *ptr_material_parameter, 1);
02238 err += Tensor2VectorSysR2(dFoda, V6);
02239 for (i=0; i<6; i++)
02240 N19(6+Num_internal_scalar+i) = V6(i);
02241 }
02242
02243 else if (Num_internal_tensor_YF == 2)
02244 {
02245 dFoda = ptr_yield_function->InTensorDerivative(TrialStress, *ptr_material_parameter, 1);
02246 err += Tensor2VectorSysR2(dFoda, V6);
02247 for (i=0; i<6; i++)
02248 N19(6+Num_internal_scalar+i) = V6(i);
02249
02250 dFoda2 = ptr_yield_function->InTensorDerivative(TrialStress, *ptr_material_parameter, 2);
02251 err += Tensor2VectorSysR2(dFoda2, V6);
02252 for (i=0; i<6; i++)
02253 N19(12+Num_internal_scalar+i) = V6(i);
02254 }
02255
02256
02257
02258 if (iStep == NumStep_in)
02259 {
02260 T19.Zero();
02261 R19.Zero();
02262 for (i=0; i<numMV; i++)
02263 {
02264 for (j=0; j<numMV; j++)
02265 {
02266 T19(i) += CI(j, i) * N19(j);
02267 R19(i) += CI(i, j) * M19(j);
02268 }
02269 }
02270
02271 lower = 0.0;
02272 for (i=0; i<numMV; i++)
02273 lower += N19(i) * R19(i);
02274
02275 M66.Zero();
02276 for (i=0; i<6; i++)
02277 {
02278 for (j=0; j<6; j++)
02279 {
02280 M66(i, j) = CI(i, j) - R19(i) * T19(j) / lower;
02281 }
02282 }
02283
02284 err += Matrix2TensorSysR4(M66, Ttemp);
02285 Stiffness = Ttemp("ijkl") * Ee("klmn");
02286 Stiffness.null_indices();
02287 }
02288
02289 }
02290
02291 }
02292
02293 return err;
02294 }
02295
02296
02297
02298 int NewTemplate3Dep::ImplicitLineSearch(const straintensor& strain_incr)
02299 {
02300 int err = 0;
02301
02302 int Num_internal_scalar = 0;
02303 int Num_internal_tensor = 0;
02304
02305 straintensor s_stress;
02306 stresstensor s_strain;
02307 straintensor s_Pstrain;
02308
02309 s_stress = getStressTensor();
02310 s_strain = getStrainTensor();
02311 s_Pstrain = getPlasticStrainTensor();
02312
02313 double s_InScalar = 0.0;
02314 tensor s_InTensor(2, def_dim_2, 0.0);
02315 tensor s_InTensor2(2, def_dim_2, 0.0);
02316
02317 Num_internal_scalar = ptr_material_parameter->getNum_Internal_Scalar();
02318 if (Num_internal_scalar > 1) {
02319 cout << "Error, NewTemplate3Dep::Backward Agorithm, scalar internal variables more than 1!" << endln;
02320 exit(1);
02321 }
02322 else if (Num_internal_scalar == 1) {
02323 s_InScalar = ptr_material_parameter->getInternal_Scalar(0);
02324 }
02325
02326 Num_internal_tensor = ptr_material_parameter->getNum_Internal_Tensor();
02327 if (Num_internal_tensor > 2) {
02328 cout << "Error, NewTemplate3Dep::Backward Agorithm, scalar internal variables more than 1!" << endln;
02329 exit(1);
02330 }
02331 else if (Num_internal_tensor == 1) {
02332 s_InTensor = ptr_material_parameter->getInternal_Tensor(0);
02333 }
02334 else if (Num_internal_tensor == 2) {
02335 s_InTensor = ptr_material_parameter->getInternal_Tensor(0);
02336 s_InTensor2 = ptr_material_parameter->getInternal_Tensor(1);
02337 }
02338
02339 this->subStep = 1;
02340 int num_step = 1;
02341
02342
02343 do
02344 {
02345 err = Implicit(strain_incr, num_step);
02346
02347 if (divergeOrnot == 1)
02348 {
02349
02350
02351 TrialStress.Initialize(s_stress);
02352 TrialStrain.Initialize(s_strain);
02353 TrialPlastic_Strain.Initialize(s_Pstrain);
02354 if (Num_internal_scalar == 1)
02355 err += ptr_material_parameter->setInternal_Scalar(0, s_InScalar );
02356 if (Num_internal_tensor == 1)
02357 err += ptr_material_parameter->setInternal_Tensor(0, s_InTensor );
02358 else if (Num_internal_tensor == 2)
02359 {
02360 err += ptr_material_parameter->setInternal_Tensor(0, s_InTensor );
02361 err += ptr_material_parameter->setInternal_Tensor(1, s_InTensor2 );
02362 }
02363
02364
02365 num_step *= 2;
02366 }
02367
02368 } while (divergeOrnot == 1);
02369
02370
02371 return err;
02372
02373 }
02374
02375
02376
02377
02378
02379
02380
02381 int NewTemplate3Dep::ScaledExplicit(const straintensor& strain_incr, int NumStep_in)
02382 {
02383 int err = 0;
02384 int i = 0;
02385 int iStep = 0;
02386 double f_start = 0.0;
02387 double f_pred = 0.0;
02388
02389 double f_final = 0.0;
02390
02391 BJtensor Ee(4, def_dim_4, 0.0);
02392 BJtensor Ep(4, def_dim_4, 0.0);
02393
02394 straintensor intersection_strain;
02395 stresstensor intersection_stress;
02396 double intersection_factor = 0.0;
02397
02398 int Num_internal_scalar = 0;
02399 int Num_internal_tensor = 0;
02400 int Num_internal_scalar_YF = 0;
02401 int Num_internal_tensor_YF = 0;
02402
02403 double upper = 0.0;
02404 double lower = 0.0;
02405 double Delta_lambda = 0.0;
02406 double hardMod = 0.0;
02407 double h_s = 0.0;
02408 double xi_s = 0.0;
02409 stresstensor dFods;
02410 straintensor dQods;
02411 BJtensor Hq(2, def_dim_2, 0.0);
02412 BJtensor Hf(2, def_dim_2, 0.0);
02413
02414 stresstensor h_t;
02415 stresstensor xi_t;
02416
02417 straintensor incr_strain;
02418 stresstensor incr_stress;
02419 straintensor incr_Pstrain;
02420 stresstensor ep_stress;
02421 stresstensor predicted_stress;
02422
02423 straintensor start_stress;
02424 stresstensor start_strain;
02425 straintensor start_Pstrain;
02426
02427
02428 stresstensor scaling_of_explicit_stress;
02429
02430 for (iStep = 1; iStep <= NumStep_in; iStep++) {
02431 start_stress = getStressTensor();
02432 start_strain = getStrainTensor();
02433 start_Pstrain = getPlasticStrainTensor();
02434
02435 intersection_stress.Initialize(start_stress);
02436
02437 err += ptr_elastic_state->setStress(start_stress);
02438 err += ptr_elastic_state->setStrain(start_strain);
02439 Ee = ptr_elastic_state->getElasticStiffness(*ptr_material_parameter);
02440
02441 incr_strain = strain_incr *(1.0/(double)(NumStep_in));
02442 incr_stress = Ee("ijpq") * incr_strain("pq");
02443 incr_stress.null_indices();
02444
02445 predicted_stress = start_stress + incr_stress;
02446
02447 f_start = ptr_yield_function->YieldFunctionValue( start_stress, *ptr_material_parameter );
02448 f_pred = ptr_yield_function->YieldFunctionValue( predicted_stress, *ptr_material_parameter );
02449
02450
02451 # ifdef _TEACHING_MODE
02452 fprintf(stdout,"explicit f_start = %12.4e",f_start);
02453 fprintf(stdout,"explicit f_pred = %12.4e",f_pred);
02454 # endif
02455
02456
02457
02458 if ( (f_start < 0.0 && f_pred <= FTOL) || f_start > f_pred )
02459 {
02460 TrialStrain = start_strain + incr_strain;
02461 TrialStress.Initialize(predicted_stress);
02462
02463 if (iStep == NumStep_in)
02464 Stiffness = Ee;
02465 }
02466 else
02467 {
02468
02469 if ( f_start < 0.0 )
02470 {
02471 intersection_factor = zbrentstress( start_stress, predicted_stress, 0.0, 1.0, TOL );
02472 intersection_stress = yield_surface_cross( start_stress, predicted_stress, intersection_factor );
02473 intersection_strain = start_strain + (incr_strain * intersection_factor);
02474
02475 incr_stress = predicted_stress - intersection_stress;
02476
02477 err += ptr_elastic_state->setStress(intersection_stress);
02478 err += ptr_elastic_state->setStrain(intersection_strain);
02479 Ee = ptr_elastic_state->getElasticStiffness(*ptr_material_parameter);
02480 }
02481
02482
02483 Delta_lambda = 0.0;
02484
02485 dFods = ptr_yield_function->StressDerivative( intersection_stress, *ptr_material_parameter );
02486 dQods = ptr_plastic_flow->PlasticFlowTensor( intersection_stress, intersection_strain, *ptr_material_parameter );
02487
02488
02489 Hq = Ee("ijkl") * dQods("kl");
02490 Hq.null_indices();
02491
02492
02493 Hf = dFods("ij") * Ee("ijkl");
02494 Hf.null_indices();
02495
02496
02497 upper = ( dFods("ij") * incr_stress("ij") ).trace();
02498
02499
02500 lower = ( Hf("ij") * dQods("ij") ).trace();
02501
02502 hardMod = 0.0;
02503
02504
02505 Num_internal_scalar_YF = ptr_yield_function->getNumInternalScalar();
02506 for (i = 0; i < Num_internal_scalar_YF; i++)
02507 {
02508 h_s = ptr_scalar_evolution[i]->H(*ptr_plastic_flow, intersection_stress, intersection_strain, *ptr_material_parameter);
02509 xi_s = ptr_yield_function->InScalarDerivative( intersection_stress, *ptr_material_parameter, i+1);
02510 hardMod += h_s * xi_s;
02511 }
02512
02513
02514 Num_internal_tensor_YF = ptr_yield_function->getNumInternalTensor();
02515 for (i = 0; i < Num_internal_tensor_YF; i++)
02516 {
02517 h_t = ptr_tensor_evolution[i]->Hij(*ptr_plastic_flow, intersection_stress, intersection_strain, *ptr_material_parameter);
02518 xi_t = ptr_yield_function->InTensorDerivative( intersection_stress, *ptr_material_parameter, i+1);
02519 hardMod += ( h_t("mn") * xi_t("mn") ).trace();
02520 }
02521
02522 lower -= hardMod;
02523
02524 Delta_lambda = upper / lower;
02525
02526 if (Delta_lambda < 0.0)
02527 Delta_lambda = 0.0;
02528
02529
02530 incr_Pstrain = dQods * Delta_lambda;
02531 ep_stress = predicted_stress - (Hq *Delta_lambda);
02532
02533
02534 TrialStress.Initialize(ep_stress);
02535 TrialStrain = start_strain + incr_strain;
02536 TrialPlastic_Strain = start_Pstrain + incr_Pstrain;
02537
02538
02539 Num_internal_scalar = ptr_material_parameter->getNum_Internal_Scalar();
02540 for (i = 0; i < Num_internal_scalar; i++)
02541 {
02542 double dS = ( ptr_scalar_evolution[i]->H(*ptr_plastic_flow, intersection_stress, intersection_strain, *ptr_material_parameter) ) *Delta_lambda;
02543 double S = ptr_material_parameter->getInternal_Scalar(i);
02544 err += ptr_material_parameter->setInternal_Scalar(i, S + dS );
02545 }
02546
02547
02548 Num_internal_tensor = ptr_material_parameter->getNum_Internal_Tensor();
02549 for (i = 0; i < Num_internal_tensor; i++)
02550 {
02551 stresstensor dT = ptr_tensor_evolution[i]->Hij(*ptr_plastic_flow, intersection_stress, intersection_strain, *ptr_material_parameter) *Delta_lambda;
02552 stresstensor T = ptr_material_parameter->getInternal_Tensor(i);
02553 err += ptr_material_parameter->setInternal_Tensor(i, T + dT );
02554 }
02555
02556
02557
02558 lower = (dFods("ij") * dFods("ij")).trace();
02559 f_final = ptr_yield_function->YieldFunctionValue( ep_stress, *ptr_material_parameter );
02560 scaling_of_explicit_stress = dFods("ij") * (f_final/lower);
02561
02562 ep_stress = ep_stress - scaling_of_explicit_stress;
02563 TrialStress.Initialize(ep_stress);
02564
02565
02566
02567
02568
02569 if (iStep == NumStep_in)
02570 {
02571 Ep = Hq("pq") * Hf("mn");
02572 Ep.null_indices();
02573 Ep = Ep * (1.0/lower);
02574
02575 if ( Delta_lambda > 0.0 )
02576 Stiffness = Ee - Ep;
02577 else
02578 Stiffness = Ee;
02579 }
02580
02581 }
02582
02583
02584
02585
02586 }
02587
02588 return err;
02589 }
02590
02591
02592
02593
02594
02595
02596
02597
02598
02599
02600 stresstensor NewTemplate3Dep::yield_surface_cross(const stresstensor & start_stress,
02601 const stresstensor & end_stress, double a)
02602 {
02603 stresstensor delta_stress = end_stress - start_stress;
02604 stresstensor intersection_stress = start_stress + delta_stress * a;
02605
02606 return intersection_stress;
02607 }
02608
02609
02610
02611 double NewTemplate3Dep::zbrentstress(const stresstensor& start_stress,
02612 const stresstensor& end_stress,
02613 double x1, double x2, double tol) const
02614 {
02615 double EPS = d_macheps();
02616
02617 int iter;
02618 double a = x1;
02619 double b = x2;
02620 double c = 0.0;
02621 double d = 0.0;
02622 double e = 0.0;
02623 double min1 = 0.0;
02624 double min2 = 0.0;
02625 double fc = 0.0;
02626 double p = 0.0;
02627 double q = 0.0;
02628 double r = 0.0;
02629 double s = 0.0;
02630 double tol1 = 0.0;
02631 double xm = 0.0;
02632
02633 double fa = func(start_stress, end_stress, *ptr_material_parameter, a);
02634 double fb = func(start_stress, end_stress, *ptr_material_parameter, b);
02635
02636 if ( (fb * fa) > 0.0) {
02637 cout << "\a\n Root must be bracketed in ZBRENTstress " << endln;
02638 exit(1);
02639 }
02640
02641 fc = fb;
02642 for ( iter = 1; iter <= ISMAX; iter++ ) {
02643 if ( (fb * fc) > 0.0) {
02644 c = a;
02645 fc = fa;
02646 e = d = b - a;
02647 }
02648 if ( fabs(fc) < fabs(fb) ) {
02649 a = b;
02650 b = c;
02651 c = a;
02652 fa = fb;
02653 fb = fc;
02654 fc = fa;
02655 }
02656 tol1 = 2.0 * EPS * fabs(b) + 0.5 * tol;
02657 xm = 0.5 * (c - b);
02658 if ( fabs(xm) <= tol1 || fb == 0.0 )
02659 return b;
02660
02661 if ( fabs(e) >= tol1 && fabs(fa) > fabs(fb) ) {
02662 s = fb / fa;
02663 if (a == c) {
02664 p = 2.0 * xm * s;
02665 q = 1.0 - s;
02666 }
02667 else {
02668 q = fa / fc;
02669 r = fb / fc;
02670 p = s * ( 2.0 * xm * q * (q - r) - (b - a) * (r - 1.0) );
02671 q = (q - 1.0) * (r - 1.0) * (s - 1.0);
02672 }
02673 if (p > 0.0)
02674 q = -q;
02675 p = fabs(p);
02676 min1 = 3.0 * xm * q - fabs(tol1*q);
02677 min2 = fabs(e*q);
02678 if (2.0*p < (min1 < min2 ? min1 : min2)) {
02679 e = d;
02680 d = p/q;
02681 }
02682 else {
02683 d = xm;
02684 e = d;
02685 }
02686 }
02687 else {
02688 d = xm;
02689 e = d;
02690 }
02691 a = b;
02692 fa = fb;
02693 if (fabs(d) > tol1)
02694 b += d;
02695 else
02696 b += (xm > 0.0 ? fabs(tol1) : -fabs(tol1));
02697 fb = func(start_stress, end_stress, *ptr_material_parameter, b);
02698 }
02699
02700 return 0.0;
02701 }
02702
02703
02704 double NewTemplate3Dep::func(const stresstensor& start_stress,
02705 const stresstensor& end_stress,
02706 const MaterialParameter& ptr_material_parameter,
02707 double alfa ) const
02708 {
02709 stresstensor alfa_stress = ( start_stress * (1.0 - alfa) ) + ( end_stress * alfa );
02710
02711 double f = ptr_yield_function->YieldFunctionValue( alfa_stress, ptr_material_parameter );
02712
02713 return f;
02714 }
02715
02716
02717 int NewTemplate3Dep::Tensor2MatrixSysR4(const tensor& T, Matrix& M)
02718 {
02719 int rank = T.rank();
02720 if (rank != 4) {
02721 cout << "NewTemplate3Dep::Tensor2MatrixSysR4 - tensor must be of rank 4" << endln;
02722 return 1;
02723 }
02724
02725 int nr = M.noRows();
02726 int nc = M.noCols();
02727 if (nr != 6 || nc != 6) {
02728 cout << "NewTemplate3Dep::Tensor2MatrixSysR4 - matrix must be of (6, 6)" << endln;;
02729 return 1;
02730 }
02731
02732 double sqrt2 = sqrt(2.0);
02733 double two = 2.0;
02734
02735
02736
02737 M(0,0) = T.cval(1,1,1,1);
02738 M(0,1) = T.cval(1,1,2,2);
02739 M(0,2) = T.cval(1,1,3,3);
02740 M(0,3) = T.cval(1,1,1,2) *sqrt2;
02741 M(0,4) = T.cval(1,1,2,3) *sqrt2;
02742 M(0,5) = T.cval(1,1,1,3) *sqrt2;
02743
02744 M(1,0) = T.cval(2,2,1,1);
02745 M(1,1) = T.cval(2,2,2,2);
02746 M(1,2) = T.cval(2,2,3,3);
02747 M(1,3) = T.cval(2,2,1,2) *sqrt2;
02748 M(1,4) = T.cval(2,2,2,3) *sqrt2;
02749 M(1,5) = T.cval(2,2,1,3) *sqrt2;
02750
02751 M(2,0) = T.cval(3,3,1,1);
02752 M(2,1) = T.cval(3,3,2,2);
02753 M(2,2) = T.cval(3,3,3,3);
02754 M(2,3) = T.cval(3,3,1,2) *sqrt2;
02755 M(2,4) = T.cval(3,3,2,3) *sqrt2;
02756 M(2,5) = T.cval(3,3,1,3) *sqrt2;
02757
02758 M(3,0) = T.cval(1,2,1,1) *sqrt2;
02759 M(3,1) = T.cval(1,2,2,2) *sqrt2;
02760 M(3,2) = T.cval(1,2,3,3) *sqrt2;
02761 M(3,3) = T.cval(1,2,1,2) *two;
02762 M(3,4) = T.cval(1,2,2,3) *two;
02763 M(3,5) = T.cval(1,2,1,3) *two;
02764
02765 M(4,0) = T.cval(2,3,1,1) *sqrt2;
02766 M(4,1) = T.cval(2,3,2,2) *sqrt2;
02767 M(4,2) = T.cval(2,3,3,3) *sqrt2;
02768 M(4,3) = T.cval(2,3,1,2) *two;
02769 M(4,4) = T.cval(2,3,2,3) *two;
02770 M(4,5) = T.cval(2,3,1,3) *two;
02771
02772 M(5,0) = T.cval(1,3,1,1) *sqrt2;
02773 M(5,1) = T.cval(1,3,2,2) *sqrt2;
02774 M(5,2) = T.cval(1,3,3,3) *sqrt2;
02775 M(5,3) = T.cval(1,3,1,2) *two;
02776 M(5,4) = T.cval(1,3,2,3) *two;
02777 M(5,5) = T.cval(1,3,1,3) *two;
02778
02779 return 0;
02780 }
02781
02782
02783 int NewTemplate3Dep::Tensor2VectorSysR2(const tensor& T, Vector& V)
02784 {
02785 int rank = T.rank();
02786 if (rank != 2) {
02787 cout << "NewTemplate3Dep::Tensor2VectorSysR2 - tensor must be of rank 4" << endln;
02788 return 1;
02789 }
02790
02791 int nsize = V.Size();
02792 if (nsize != 6) {
02793 cout << "NewTemplate3Dep::Tensor2VectorSysR2 - matrix must be of size 6" << endln;
02794 return 1;
02795 }
02796
02797 double sqrt2 = sqrt(2.0);
02798
02799
02800
02801 V(0) = T.cval(1,1);
02802 V(1) = T.cval(2,2);
02803 V(2) = T.cval(3,3);
02804 V(3) = T.cval(1,2) *sqrt2;
02805 V(4) = T.cval(2,3) *sqrt2;
02806 V(5) = T.cval(1,3) *sqrt2;
02807
02808 return 0;
02809 }
02810
02811
02812 int NewTemplate3Dep::Matrix2TensorSysR4(const Matrix& M, tensor& T)
02813 {
02814 int rank = T.rank();
02815 if (rank != 4) {
02816 cout << "NewTemplate3Dep::Matrix2TensorSysR4 - tensor must be of rank 4" << endln;
02817 return 1;
02818 }
02819
02820 int nr = M.noRows();
02821 int nc = M.noCols();
02822 if (nr < 6 || nc < 6) {
02823 cout << "NewTemplate3Dep::Matrix2TensorSysR4 - matrix must be no less than (6, 6)" << endln;
02824 return 1;
02825 }
02826
02827 double sqrthalf = sqrt(0.5);
02828 double half = 0.5;
02829
02830
02831
02832 T.val(1,1,1,1) = M(0,0);
02833 T.val(1,1,2,2) = M(0,1);
02834 T.val(1,1,3,3) = M(0,2);
02835 T.val(1,1,1,2) = T.val(1,1,2,1) = M(0,3) *sqrthalf;
02836 T.val(1,1,2,3) = T.val(1,1,3,2) = M(0,4) *sqrthalf;
02837 T.val(1,1,1,3) = T.val(1,1,3,1) = M(0,5) *sqrthalf;
02838
02839 T.val(2,2,1,1) = M(1,0);
02840 T.val(2,2,2,2) = M(1,1);
02841 T.val(2,2,3,3) = M(1,2);
02842 T.val(2,2,1,2) = T.val(2,2,2,1) = M(1,3) *sqrthalf;
02843 T.val(2,2,2,3) = T.val(2,2,3,2) = M(1,4) *sqrthalf;
02844 T.val(2,2,1,3) = T.val(2,2,3,1) = M(1,5) *sqrthalf;
02845
02846 T.val(3,3,1,1) = M(2,0);
02847 T.val(3,3,2,2) = M(2,1);
02848 T.val(3,3,3,3) = M(2,2);
02849 T.val(3,3,1,2) = T.val(3,3,2,1) = M(2,3) *sqrthalf;
02850 T.val(3,3,2,3) = T.val(3,3,3,2) = M(2,4) *sqrthalf;
02851 T.val(3,3,1,3) = T.val(3,3,3,1) = M(2,5) *sqrthalf;
02852
02853 T.val(1,2,1,1) = T.val(2,1,1,1) = M(3,0) *sqrthalf;
02854 T.val(1,2,2,2) = T.val(2,1,2,2) = M(3,1) *sqrthalf;
02855 T.val(1,2,3,3) = T.val(2,1,3,3) = M(3,2) *sqrthalf;
02856 T.val(1,2,1,2) = T.val(2,1,1,2) = T.val(1,2,2,1) = T.val(2,1,2,1) = M(3,3) *half;
02857 T.val(1,2,2,3) = T.val(2,1,2,3) = T.val(1,2,3,2) = T.val(2,1,3,2) = M(3,4) *half;
02858 T.val(1,2,1,3) = T.val(2,1,1,3) = T.val(1,2,3,1) = T.val(2,1,3,1) = M(3,5) *half;
02859
02860 T.val(2,3,1,1) = T.val(3,2,1,1) = M(4,0) *sqrthalf;
02861 T.val(2,3,2,2) = T.val(3,2,2,2) = M(4,1) *sqrthalf;
02862 T.val(2,3,3,3) = T.val(3,2,3,3) = M(4,2) *sqrthalf;
02863 T.val(2,3,1,2) = T.val(3,2,1,2) = T.val(2,3,2,1) = T.val(3,2,2,1) = M(4,3) *half;
02864 T.val(2,3,2,3) = T.val(3,2,2,3) = T.val(2,3,3,2) = T.val(3,2,3,2) = M(4,4) *half;
02865 T.val(2,3,1,3) = T.val(3,2,1,3) = T.val(2,3,3,1) = T.val(3,2,3,1) = M(4,5) *half;
02866
02867 T.val(1,3,1,1) = T.val(3,1,1,1) = M(5,0) *sqrthalf;
02868 T.val(1,3,2,2) = T.val(3,1,2,2) = M(5,1) *sqrthalf;
02869 T.val(1,3,3,3) = T.val(3,1,3,3) = M(5,2) *sqrthalf;
02870 T.val(1,3,1,2) = T.val(3,1,1,2) = T.val(1,3,2,1) = T.val(3,1,2,1) = M(5,3) *half;
02871 T.val(1,3,2,3) = T.val(3,1,2,3) = T.val(1,3,3,2) = T.val(3,1,3,2) = M(5,4) *half;
02872 T.val(1,3,1,3) = T.val(3,1,1,3) = T.val(1,3,3,1) = T.val(3,1,3,1) = M(5,5) *half;
02873
02874 return 0;
02875 }
02876
02877
02878 int NewTemplate3Dep::Vector2TensorSysR2(const Vector& V, tensor& T, int Num0)
02879 {
02880 int rank = T.rank();
02881 if (rank != 2) {
02882 cout << "NewTemplate3Dep::Vector2TensorSysR2 - tensor must be of rank 4" << endln;
02883 return 1;
02884 }
02885
02886 int nsize = V.Size();
02887 if (nsize < 6) {
02888 cout << "NewTemplate3Dep::Vector2TensorSysR2 - matrix less than size 6" << endln;
02889 return 1;
02890 }
02891
02892 double sqrthalf = sqrt(0.5);
02893
02894
02895
02896 T.val(1,1) = V(Num0+0);
02897 T.val(2,2) = V(Num0+1);
02898 T.val(3,3) = V(Num0+2);
02899 T.val(1,2) = T.val(2,1) = V(Num0+3) *sqrthalf;
02900 T.val(2,3) = T.val(3,2) = V(Num0+4) *sqrthalf;
02901 T.val(1,3) = T.val(3,1) = V(Num0+5) *sqrthalf;
02902
02903 return 0;
02904 }
02905
02906
02907
02908 int NewTemplate3Dep::Stiffness2Compliance(const tensor& S, tensor& C)
02909 {
02910 int rank = 0;
02911 int err = 0;
02912
02913 rank = S.rank();
02914 if (rank != 4) {
02915 cout << "NewTemplate3Dep::Stiffness2Compliance - tensor must be of rank 4" << endln;
02916 return 1;
02917 }
02918
02919 rank = C.rank();
02920 if (rank != 4) {
02921 cout << "NewTemplate3Dep::Stiffness2Compliance - tensor must be of rank 4" << endln;
02922 return 1;
02923 }
02924
02925 Matrix S66(6,6);
02926 Matrix C66(6,6);
02927
02928 err += Tensor2MatrixSysR4(S, S66);
02929 err += S66.Invert(C66);
02930 err += Matrix2TensorSysR4(C66, C);
02931
02932 return err;
02933 }
02934
02935
02936 #endif
02937