2424#include " IDoFLinearSystemFactory.h"
2525#include " ArcaneFemFunctions.h"
2626#include " NLDynamicModule.h"
27+ #include " LawDispatcher.h"
2728
2829/* ---------------------------------------------------------------------------*/
2930/* ---------------------------------------------------------------------------*/
@@ -455,9 +456,9 @@ _applyInitialCellConditions(){
455456 for (Integer i = 0 , nb = options ()->lawModel ().size (); i < nb; ++i){
456457
457458 CellGroup cell_group = options ()->lawModel [i]->cellGroup ();
458- Integer ilaw = options ()->lawModel [i]->iLawParam ();
459- TypesNLDynamic::eLawType lawtyp = options ()->lawModel [i]->lawType ();
460- Integer nblaw = options ()->lawModel [i]->nbLawParam ();
459+ auto ilaw = options ()->lawModel [i]->iLawParam ();
460+ auto lawtyp = options ()->lawModel [i]->lawType ();
461+ auto nblaw = options ()->lawModel [i]->nbLawParam ();
461462 m_nb_law_param = math::max (m_nb_law_param, nblaw);
462463
463464 bool is_default = (m_law_param_file.empty () || nblaw == 2 );
@@ -552,6 +553,7 @@ _applyInitialCellConditions(){
552553void NLDynamicModule::
553554_initGaussStep ()
554555{
556+ Real eps{1.0e-15 };
555557 auto gauss_point (m_gauss_on_cells.gaussCellConnectivityView ());
556558
557559 VariableDoFReal& gauss_jacobian (m_gauss_on_cells.gaussJacobian ());
@@ -597,7 +599,7 @@ _initGaussStep()
597599 else
598600 jacobian = ArcaneFemFunctions::MeshOperation::computeLengthEdge2 (cell, m_node_coord) / 2 .;
599601
600- if (fabs (jacobian) < REL_PREC ) {
602+ if (fabs (jacobian) < eps ) {
601603 ARCANE_FATAL (" Cell jacobian is null" );
602604 }
603605 gauss_jacobian[gauss_pti] = jacobian;
@@ -1583,6 +1585,7 @@ Real3x3 NLDynamicModule::
15831585_computeJacobian (const ItemWithNodes& cell,const Int32& ig, const RealUniqueArray& vec, Real& jacobian) {
15841586
15851587 auto n = cell.nbNode ();
1588+ Real eps{1.0e-15 };
15861589
15871590 // Jacobian matrix computed at the integration point
15881591 Real3x3 jac;
@@ -1602,17 +1605,16 @@ _computeJacobian(const ItemWithNodes& cell,const Int32& ig, const RealUniqueArra
16021605 }
16031606
16041607 Int32 ndim = ArcaneFemFunctions::MeshOperation::getGeomDimension (cell);
1605- // if (NDIM == 3)
1608+
16061609 if (ndim == 3 )
16071610 jacobian = math::matrixDeterminant (jac);
16081611
1609- // else if (NDIM == 2) {
16101612 else if (ndim == 2 )
16111613 jacobian = jac.x .x * jac.y .y - jac.x .y * jac.y .x ;
16121614 else
16131615 jacobian = ArcaneFemFunctions::MeshOperation::computeLengthEdge2 (cell, m_node_coord) / 2 .;
16141616
1615- if (fabs (jacobian) < REL_PREC ) {
1617+ if (fabs (jacobian) < eps ) {
16161618 ARCANE_FATAL (" Cell jacobian is null" );
16171619 }
16181620 return jac;
@@ -2343,19 +2345,73 @@ _assembleLinearRHS(){
23432345/* ---------------------------------------------------------------------------*/
23442346// ! Stress prediction
23452347//
2346- bool NLDynamicModule::stress_prediction (bool init, bool isRef)
2348+ void NLDynamicModule::stress_prediction (bool init, bool isRef)
23472349{
2348- bool stop = false ;
2349- return stop;
2350+ auto gauss_point (m_gauss_on_cells.gaussCellConnectivityView ());
2351+
2352+ VariableDoFArrayReal3x3& gauss_stress (m_gauss_on_cells.gaussStress ());
2353+ VariableDoFArrayReal3x3& gauss_strain (m_gauss_on_cells.gaussStrain ());
2354+ VariableDoFArrayReal3x3& gauss_strain_plastic (m_gauss_on_cells.gaussStrainPlastic ());
2355+ VariableDoFArrayReal& gauss_lawparam (m_gauss_on_cells.gaussLawParam ());
2356+
2357+ ENUMERATE_CELL (icell, allCells ()) {
2358+ const Cell& cell = *icell;
2359+ auto cell_type = cell.type ();
2360+ auto cell_nbnod = cell.nbNode ();
2361+ Int32 numcell = cell.localId ();
2362+
2363+ auto is_default = m_default_law[cell];
2364+ auto lawtyp = static_cast <TypesNLDynamic::eLawType>(m_law[cell]);
2365+ auto ilaw = m_iparam_law[cell];
2366+ LawDispatcher cell_law (lawtyp, is_default);
2367+ auto nblaw = cell_law.getNbLawParam ();
2368+ RealUniqueArray lawparams (nblaw);
2369+
2370+ auto cell_nbgauss = ArcaneFemFunctions::FemGaussQuadrature::getNbGaussPointsfromOrder (cell_type, ninteg);
2371+
2372+ for (Int32 ig = 0 ; ig < cell_nbgauss; ++ig) {
2373+ DoFLocalId gauss_pti = gauss_point.dofId (cell, ig);
2374+ Int32 gaussnum = gauss_pti.localId ();
2375+
2376+ Tensor2 epsn;
2377+ epsn.fromReal3x3ToTensor2 (gauss_strain[gauss_pti][1 ]);
2378+ Tensor2 sign;
2379+ sign.fromReal3x3ToTensor2 (gauss_stress[gauss_pti][1 ]);
2380+ Tensor2 epspn;
2381+ epspn.fromReal3x3ToTensor2 (gauss_strain_plastic[gauss_pti][1 ]);
2382+ Tensor2 deps;
2383+ {
2384+ // calcul deps à faire avec unodes
2385+ }
2386+
2387+ for (Int32 ip = 0 ; ip < nblaw; ++ip) {
2388+ lawparams[ip] = gauss_lawparam[gauss_pti][ip];
2389+ }
2390+ cell_law.setLawParams (lawparams);
2391+ cell_law.setStrain (epsn);
2392+ cell_law.setStress (sign);
2393+ cell_law.setPlasticStrain (epspn);
2394+ cell_law.setStrainIncrement (deps);
2395+
2396+ // bool isRef = false at prediction
2397+ // => it avoids computing tangent stiffness operator
2398+ cell_law.computeStress (isRef);
2399+
2400+ // Current plastic strains and stresses have been updated by the law
2401+ gauss_strain_plastic[gauss_pti][2 ] = fromTensor2Real3x3 (cell_law.getPlasticStrain ());
2402+ gauss_stress[gauss_pti][2 ] = fromTensor2Real3x3 (cell_law.getStress ());
2403+ gauss_strain[gauss_pti][2 ] = fromTensor2Real3x3 (epsn + deps);
2404+
2405+ }
2406+ }
23502407}
2408+
23512409/* ---------------------------------------------------------------------------*/
23522410/* ---------------------------------------------------------------------------*/
23532411// ! Stress correction
23542412//
2355- bool NLDynamicModule::stress_correction (bool is_converge )
2413+ void NLDynamicModule::stress_correction (bool isRef )
23562414{
2357- bool stop = false ;
2358- return stop;
23592415}
23602416
23612417/* ---------------------------------------------------------------------------*/
0 commit comments