Suppress dof calculation flag

This commit is contained in:
EvilSpirit 2017-05-11 20:55:41 +07:00 committed by phkahler
parent 7f86a78472
commit 4d58f95b43
4 changed files with 17 additions and 9 deletions

View File

@ -551,9 +551,9 @@ void SolveSpaceUI::SolveGroup(hGroup hg, bool andFindFree) {
SolveResult SolveSpaceUI::TestRankForGroup(hGroup hg, int *rank) { SolveResult SolveSpaceUI::TestRankForGroup(hGroup hg, int *rank) {
Group *g = SK.GetGroup(hg); 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 // 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); WriteEqSystemForGroup(hg);
SolveResult result = sys.SolveRank(g, rank); SolveResult result = sys.SolveRank(g, rank);
FreeAllTemporary(); FreeAllTemporary();

View File

@ -175,6 +175,7 @@ public:
bool suppress; bool suppress;
bool relaxConstraints; bool relaxConstraints;
bool allowRedundant; bool allowRedundant;
bool suppressDofCalculation;
bool allDimsReference; bool allDimsReference;
double scale; double scale;

View File

@ -500,9 +500,9 @@ SolveResult System::Solve(Group *g, int *rank, int *dof, List<hConstraint> *bad,
param.ClearTags(); param.ClearTags();
eq.ClearTags(); eq.ClearTags();
// Since we are allowing redundant, we // Since we are suppressing dof calculation or allowing redundant, we
// don't want to catch result of dof checking without substitution // can't / don't want to catch result of dof checking without substitution
if(g->allowRedundant || !forceDofCheck) { if(g->suppressDofCalculation || g->allowRedundant || !forceDofCheck) {
SolveBySubstitution(); SolveBySubstitution();
} }
@ -542,15 +542,16 @@ SolveResult System::Solve(Group *g, int *rank, int *dof, List<hConstraint> *bad,
} }
// Clear dof value in order to have indication when dof is actually not calculated // Clear dof value in order to have indication when dof is actually not calculated
if(dof != NULL) *dof = -1; if(dof != NULL) *dof = -1;
// We are allowing redundant, so we no need to catch unsolveable + redundant // We are suppressing or allowing redundant, so we no need to catch unsolveable + redundant
rankOk = (!g->allowRedundant) ? TestRank(dof) : true; rankOk = (!g->suppressDofCalculation && !g->allowRedundant) ? TestRank(dof) : true;
// And do the leftovers as one big system // And do the leftovers as one big system
if(!NewtonSolve(0)) { if(!NewtonSolve(0)) {
goto didnt_converge; 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(!rankOk) {
if(andFindBad) FindWhichToRemoveToFixJacobian(g, bad, forceDofCheck); if(andFindBad) FindWhichToRemoveToFixJacobian(g, bad, forceDofCheck);
} else { } else {
@ -614,7 +615,7 @@ SolveResult System::SolveRank(Group *g, int *rank, int *dof, List<hConstraint> *
if(!rankOk) { if(!rankOk) {
// When we are testing with redundant allowed, we don't want to have additional info // 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 // 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); if(andFindBad) FindWhichToRemoveToFixJacobian(g, bad, true);
} }
} else { } else {

View File

@ -261,6 +261,8 @@ void TextWindow::ScreenChangeGroupOption(int link, uint32_t v) {
case 'e': g->allowRedundant = !(g->allowRedundant); break; case 'e': g->allowRedundant = !(g->allowRedundant); break;
case 'D': g->suppressDofCalculation = !(g->suppressDofCalculation); break;
case 'v': g->visible = !(g->visible); break; case 'v': g->visible = !(g->visible); break;
case 'd': g->allDimsReference = !(g->allDimsReference); break; case 'd': g->allDimsReference = !(g->allDimsReference); break;
@ -511,6 +513,10 @@ void TextWindow::ShowGroupInfo() {
&TextWindow::ScreenChangeGroupOption, &TextWindow::ScreenChangeGroupOption,
g->allowRedundant ? CHECK_TRUE : CHECK_FALSE); 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", Printf(false, " %f%Ld%Fd%s treat all dimensions as reference",
&TextWindow::ScreenChangeGroupOption, &TextWindow::ScreenChangeGroupOption,
g->allDimsReference ? CHECK_TRUE : CHECK_FALSE); g->allDimsReference ? CHECK_TRUE : CHECK_FALSE);