@@ -400,6 +400,56 @@ namespace mgis::behaviour::internals {
400400 return r;
401401 } // end of integrate
402402
403+ /* !
404+ * \brief perform the integration of the behaviour over a range of integration
405+ * points.
406+ */
407+ static BehaviourIntegrationResult integrate_debug (
408+ MaterialDataManager& m,
409+ const BehaviourIntegrationOptions& opts,
410+ const real dt,
411+ const size_type b,
412+ const size_type e,
413+ const debug::BehaviourIntegrationFailureAnalyser& analyser) {
414+ // workspace
415+ auto & ws = m.getBehaviourIntegrationWorkSpace ();
416+ auto v = internals::initializeBehaviourDataView (ws);
417+ auto behaviour_evaluators = internals::buildBehaviourEvaluators (ws, m);
418+ // loop over integration points
419+ auto r = BehaviourIntegrationResult{};
420+ auto rdt0 = r.time_step_increase_factor ;
421+ const real Ke = encodeBehaviourIntegrationOptions (opts);
422+ real bopts[Behaviour::nopts + 1 ]; // option passed to the behaviour
423+ for (auto i = b; i != e; ++i) {
424+ internals::evaluate (ws, behaviour_evaluators, i);
425+ internals::updateView (v, m, i);
426+ auto rdt = rdt0;
427+ v.error_message [0 ] = ' \0 ' ;
428+ v.rdt = &rdt;
429+ v.dt = dt;
430+ if ((opts.integration_type !=
431+ IntegrationType::INTEGRATION_NO_TANGENT_OPERATOR) &&
432+ (m.K_stride != 0 )) {
433+ v.K = m.K .data () + m.K_stride * i;
434+ } else {
435+ v.K = &bopts[0 ];
436+ }
437+ v.K [0 ] = Ke;
438+ const auto ri = integrate_debug (v, m.b , analyser);
439+ r.exit_status = std::min (ri, r.exit_status );
440+ r.time_step_increase_factor = std::min (rdt, r.time_step_increase_factor );
441+ if (ri == 0 ) {
442+ r.n = i;
443+ } else if (ri == -1 ) {
444+ r.n = i;
445+ v.error_message [511 ] = ' \0 ' ;
446+ r.error_message = std::string (v.error_message );
447+ return r;
448+ }
449+ }
450+ return r;
451+ } // end of integrate_debug
452+
403453 /* !
404454 * \brief execute the given post-processing over a range of integration
405455 * points.
@@ -658,6 +708,23 @@ namespace mgis::behaviour {
658708 return internals::integrate (m, opts, dt, 0 , m.n );
659709 } // end of integrate
660710
711+ BehaviourIntegrationResult integrate_debug (
712+ MaterialDataManager& m,
713+ const BehaviourIntegrationOptions& opts,
714+ const real dt) {
715+ const auto & a = debug::getDefaultBehaviourIntegrationFailureAnalyser ();
716+ return integrate_debug (m, opts, dt, a);
717+ } // end of integrate_debug
718+
719+ BehaviourIntegrationResult integrate_debug (
720+ MaterialDataManager& m,
721+ const BehaviourIntegrationOptions& opts,
722+ const real dt,
723+ const debug::BehaviourIntegrationFailureAnalyser& analyser) {
724+ internals::allocate (m, opts);
725+ return internals::integrate_debug (m, opts, dt, 0 , m.n , analyser);
726+ } // end of integrate
727+
661728 BehaviourIntegrationResult integrate (MaterialDataManager& m,
662729 const BehaviourIntegrationOptions& opts,
663730 const real dt,
@@ -668,6 +735,28 @@ namespace mgis::behaviour {
668735 return internals::integrate (m, opts, dt, b, e);
669736 } // end of integrate
670737
738+ BehaviourIntegrationResult integrate_debug (
739+ MaterialDataManager& m,
740+ const BehaviourIntegrationOptions& opts,
741+ const real dt,
742+ const size_type b,
743+ const size_type e) {
744+ const auto & a = debug::getDefaultBehaviourIntegrationFailureAnalyser ();
745+ return integrate_debug (m, opts, dt, b, e, a);
746+ } // end of integrate_debug
747+
748+ BehaviourIntegrationResult integrate_debug (
749+ MaterialDataManager& m,
750+ const BehaviourIntegrationOptions& opts,
751+ const real dt,
752+ const size_type b,
753+ const size_type e,
754+ const debug::BehaviourIntegrationFailureAnalyser& analyser) {
755+ internals::allocate (m, opts);
756+ internals::checkIntegrationPointsRange (m, b, e);
757+ return internals::integrate_debug (m, opts, dt, b, e, analyser);
758+ } // end of integrate
759+
671760 MultiThreadedBehaviourIntegrationResult integrate (
672761 mgis::ThreadPool& p,
673762 MaterialDataManager& m,
@@ -704,6 +793,52 @@ namespace mgis::behaviour {
704793 return res;
705794 } // end of integrate
706795
796+ MultiThreadedBehaviourIntegrationResult integrate_debug (
797+ mgis::ThreadPool& p,
798+ MaterialDataManager& m,
799+ const BehaviourIntegrationOptions& opts,
800+ const real dt) {
801+ const auto & a = debug::getDefaultBehaviourIntegrationFailureAnalyser ();
802+ return integrate_debug (p, m, opts, dt, a);
803+ } // end if integrate_debug
804+
805+ MultiThreadedBehaviourIntegrationResult integrate_debug (
806+ mgis::ThreadPool& p,
807+ MaterialDataManager& m,
808+ const BehaviourIntegrationOptions& opts,
809+ const real dt,
810+ const debug::BehaviourIntegrationFailureAnalyser& analyser) {
811+ m.setThreadSafe (true );
812+ internals::allocate (m, opts);
813+ // get number of threads
814+ const auto nth = p.getNumberOfThreads ();
815+ const auto d = m.n / nth;
816+ const auto r = m.n % nth;
817+ size_type b = 0 ;
818+ std::vector<std::future<ThreadedTaskResult<BehaviourIntegrationResult>>>
819+ tasks;
820+ tasks.reserve (nth);
821+ for (size_type i = 0 ; i != r; ++i) {
822+ tasks.push_back (p.addTask ([&m, &opts, dt, b, d, &analyser] {
823+ return internals::integrate_debug (m, opts, dt, b, b + d + 1 , analyser);
824+ }));
825+ b += d + 1 ;
826+ }
827+ for (size_type i = r; i != nth; ++i) {
828+ tasks.push_back (p.addTask ([&m, &opts, dt, b, d, &analyser] {
829+ return internals::integrate_debug (m, opts, dt, b, b + d, analyser);
830+ }));
831+ b += d;
832+ }
833+ auto res = MultiThreadedBehaviourIntegrationResult{};
834+ for (auto & t : tasks) {
835+ const auto & ri = *(t.get ());
836+ res.exit_status = std::min (res.exit_status , ri.exit_status );
837+ res.results .push_back (ri);
838+ }
839+ return res;
840+ } // end of integrate_debug
841+
707842 int integrate (mgis::ThreadPool& p,
708843 MaterialDataManager& m,
709844 const IntegrationType it,
@@ -714,6 +849,26 @@ namespace mgis::behaviour {
714849 return r.exit_status ;
715850 } // end of integrate
716851
852+ int integrate_debug (mgis::ThreadPool& p,
853+ MaterialDataManager& m,
854+ const IntegrationType it,
855+ const real dt) {
856+ const auto & a = debug::getDefaultBehaviourIntegrationFailureAnalyser ();
857+ return integrate_debug (p, m, it, dt, a);
858+ }
859+
860+ int integrate_debug (
861+ mgis::ThreadPool& p,
862+ MaterialDataManager& m,
863+ const IntegrationType it,
864+ const real dt,
865+ const debug::BehaviourIntegrationFailureAnalyser& analyser) {
866+ BehaviourIntegrationOptions opts;
867+ opts.integration_type = it;
868+ const auto r = integrate_debug (p, m, opts, dt, analyser);
869+ return r.exit_status ;
870+ } // end of integrate_debug
871+
717872 int integrate (MaterialDataManager& m,
718873 const IntegrationType it,
719874 const real dt,
@@ -725,6 +880,28 @@ namespace mgis::behaviour {
725880 return r.exit_status ;
726881 } // end of integrate
727882
883+ int integrate_debug (MaterialDataManager& m,
884+ const IntegrationType it,
885+ const real dt,
886+ const size_type b,
887+ const size_type e) {
888+ const auto & a = debug::getDefaultBehaviourIntegrationFailureAnalyser ();
889+ return integrate_debug (m, it, dt, b, e, a);
890+ } // end of integrate
891+
892+ int integrate_debug (
893+ MaterialDataManager& m,
894+ const IntegrationType it,
895+ const real dt,
896+ const size_type b,
897+ const size_type e,
898+ const debug::BehaviourIntegrationFailureAnalyser& analyser) {
899+ BehaviourIntegrationOptions opts;
900+ opts.integration_type = it;
901+ const auto r = integrate_debug (m, opts, dt, b, e, analyser);
902+ return r.exit_status ;
903+ } // end of integrate
904+
728905 static void copy (State& s, const auto & src) {
729906 if (src.stored_energy != nullptr ) {
730907 s.stored_energy = *(src.stored_energy );
@@ -757,6 +934,11 @@ namespace mgis::behaviour {
757934 s.external_state_variables .begin ());
758935 } // end of copy
759936
937+ int integrate_debug (BehaviourDataView& d, const Behaviour& b) {
938+ const auto & a = debug::getDefaultBehaviourIntegrationFailureAnalyser ();
939+ return integrate_debug (d, b, a);
940+ } // end of integrate_debug
941+
760942 int integrate_debug (
761943 BehaviourDataView& d,
762944 const Behaviour& b,
0 commit comments