From 2b3cbb612ba3ddd5558514ba6c569635977ddab6 Mon Sep 17 00:00:00 2001
From: Van Dung Nguyen <vdg.nguyen@gmail.com>
Date: Thu, 29 Oct 2020 10:06:30 +0100
Subject: [PATCH] add fraction tolerance

---
 NonLinearSolver/modelReduction/DeepMaterialNetworks.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/NonLinearSolver/modelReduction/DeepMaterialNetworks.cpp b/NonLinearSolver/modelReduction/DeepMaterialNetworks.cpp
index 07fbc4265..27d6a83bf 100644
--- a/NonLinearSolver/modelReduction/DeepMaterialNetworks.cpp
+++ b/NonLinearSolver/modelReduction/DeepMaterialNetworks.cpp
@@ -722,7 +722,8 @@ void BimaterialHomogenization::computeBimaterial(const fullMatrix<double>& C1, c
                         fullMatrix<double>* DCeffDnormal1,fullMatrix<double>* DCeffDnormal2, fullMatrix<double>* DCeffDnormal3) const
 {
   double tol = 1e-10;
-  if (C1.norm() < tol*C2.norm())
+  double tolF = 1e-6;
+  if ((C1.norm() < tol*C2.norm()) || (f1 < tolF*f2))
   {
     // C1 is void
     Ceff  = C2;
@@ -743,7 +744,7 @@ void BimaterialHomogenization::computeBimaterial(const fullMatrix<double>& C1, c
       fullMatrixOperation::allocateAndMakeZero(*DCeffDnormal3,Ceff.size1(),Ceff.size2());
     };
   }
-  else if (C2.norm() < tol*C1.norm())
+  else if ((C2.norm() < tol*C1.norm()) || (f2 < tolF*f1))
   {
     Ceff = C1;
     Ceff.scale(f1);
-- 
GitLab