From 4d58f95b43ac97a3f09dc7912e1fa1f74ad2c985 Mon Sep 17 00:00:00 2001 From: EvilSpirit Date: Thu, 11 May 2017 20:55:41 +0700 Subject: [PATCH] Suppress dof calculation flag --- src/generate.cpp | 4 ++-- src/sketch.h | 1 + src/system.cpp | 15 ++++++++------- src/textscreens.cpp | 6 ++++++ 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/generate.cpp b/src/generate.cpp index aaca684..fdb19b8 100644 --- a/src/generate.cpp +++ b/src/generate.cpp @@ -551,9 +551,9 @@ void SolveSpaceUI::SolveGroup(hGroup hg, bool andFindFree) { SolveResult SolveSpaceUI::TestRankForGroup(hGroup hg, int *rank) { Group *g = SK.GetGroup(hg); - // If redundant is allowed, there is + // If we don't calculate dof or redundant is allowed, there is // no point to solve rank because this result is not meaningful - if(g->allowRedundant) return SolveResult::OKAY; + if(g->suppressDofCalculation || g->allowRedundant) return SolveResult::OKAY; WriteEqSystemForGroup(hg); SolveResult result = sys.SolveRank(g, rank); FreeAllTemporary(); diff --git a/src/sketch.h b/src/sketch.h index dc5a19e..33853d9 100644 --- a/src/sketch.h +++ b/src/sketch.h @@ -175,6 +175,7 @@ public: bool suppress; bool relaxConstraints; bool allowRedundant; + bool suppressDofCalculation; bool allDimsReference; double scale; diff --git a/src/system.cpp b/src/system.cpp index baed79c..f1a3f67 100644 --- a/src/system.cpp +++ b/src/system.cpp @@ -500,9 +500,9 @@ SolveResult System::Solve(Group *g, int *rank, int *dof, List *bad, param.ClearTags(); eq.ClearTags(); - // Since we are allowing redundant, we - // don't want to catch result of dof checking without substitution - if(g->allowRedundant || !forceDofCheck) { + // Since we are suppressing dof calculation or allowing redundant, we + // can't / don't want to catch result of dof checking without substitution + if(g->suppressDofCalculation || g->allowRedundant || !forceDofCheck) { SolveBySubstitution(); } @@ -542,15 +542,16 @@ SolveResult System::Solve(Group *g, int *rank, int *dof, List *bad, } // Clear dof value in order to have indication when dof is actually not calculated if(dof != NULL) *dof = -1; - // We are allowing redundant, so we no need to catch unsolveable + redundant - rankOk = (!g->allowRedundant) ? TestRank(dof) : true; + // We are suppressing or allowing redundant, so we no need to catch unsolveable + redundant + rankOk = (!g->suppressDofCalculation && !g->allowRedundant) ? TestRank(dof) : true; // And do the leftovers as one big system if(!NewtonSolve(0)) { goto didnt_converge; } - rankOk = TestRank(dof); + // Here we are want to calculate dof even when redundant is allowed, so just handle suppressing + rankOk = (!g->suppressDofCalculation) ? TestRank(dof) : true; if(!rankOk) { if(andFindBad) FindWhichToRemoveToFixJacobian(g, bad, forceDofCheck); } else { @@ -614,7 +615,7 @@ SolveResult System::SolveRank(Group *g, int *rank, int *dof, List * if(!rankOk) { // When we are testing with redundant allowed, we don't want to have additional info // about redundants since this test is working only for single redundant constraint - if(!g->allowRedundant) { + if(!g->suppressDofCalculation && !g->allowRedundant) { if(andFindBad) FindWhichToRemoveToFixJacobian(g, bad, true); } } else { diff --git a/src/textscreens.cpp b/src/textscreens.cpp index 2255382..ba5d977 100644 --- a/src/textscreens.cpp +++ b/src/textscreens.cpp @@ -261,6 +261,8 @@ void TextWindow::ScreenChangeGroupOption(int link, uint32_t v) { case 'e': g->allowRedundant = !(g->allowRedundant); break; + case 'D': g->suppressDofCalculation = !(g->suppressDofCalculation); break; + case 'v': g->visible = !(g->visible); break; case 'd': g->allDimsReference = !(g->allDimsReference); break; @@ -511,6 +513,10 @@ void TextWindow::ShowGroupInfo() { &TextWindow::ScreenChangeGroupOption, g->allowRedundant ? CHECK_TRUE : CHECK_FALSE); + Printf(false, " %f%LD%Fd%s suppress dof calculation (improves solver performance)", + &TextWindow::ScreenChangeGroupOption, + g->suppressDofCalculation ? CHECK_TRUE : CHECK_FALSE); + Printf(false, " %f%Ld%Fd%s treat all dimensions as reference", &TextWindow::ScreenChangeGroupOption, g->allDimsReference ? CHECK_TRUE : CHECK_FALSE);