Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SofaBaseLinearSolver] Remove virtual function BaseLinearSolver::isMultiGroup #1063

Merged
merged 9 commits into from
Jul 19, 2019
7 changes: 0 additions & 7 deletions SofaKernel/framework/sofa/core/behavior/LinearSolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,6 @@ class SOFA_CORE_API BaseLinearSolver : public objectmodel::BaseObject
SOFA_ABSTRACT_CLASS(BaseLinearSolver, objectmodel::BaseObject);
SOFA_BASE_CAST_IMPLEMENTATION(BaseLinearSolver)

/// Check if this solver handle multiple independent integration groups, placed as child nodes in the scene graph.
/// If this is the case, then when collisions occur, the CollisionGroupManager can simply group the interacting groups into new child nodes without creating a new solver to handle them.
virtual bool isMultiGroup() const
{
return false;
}

bool insertInNode( objectmodel::BaseNode* node ) override;
bool removeInNode( objectmodel::BaseNode* node ) override;

Expand Down
4 changes: 2 additions & 2 deletions SofaKernel/modules/SofaBaseLinearSolver/CGLinearSolver.inl
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,9 @@ void CGLinearSolver<TMatrix,TVector>::solve(Matrix& M, Vector& x, Vector& b)


std::map < std::string, sofa::helper::vector<SReal> >& graph = *f_graph.beginEdit();
sofa::helper::vector<SReal>& graph_error = graph[(this->isMultiGroup()) ? this->currentNode->getName()+std::string("-Error") : std::string("Error")];
sofa::helper::vector<SReal>& graph_error = graph[std::string("Error")];
graph_error.clear();
sofa::helper::vector<SReal>& graph_den = graph[(this->isMultiGroup()) ? this->currentNode->getName()+std::string("-Denominator") : std::string("Denominator")];
sofa::helper::vector<SReal>& graph_den = graph[std::string("Denominator")];
graph_den.clear();
graph_error.push_back(1);
unsigned nb_iter = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,37 +281,8 @@ simulation::Node* DefaultCollisionGroupManager::getIntegrationNode(core::Collisi

if (listSolver.empty())
return NULL;
simulation::Node* solvernode = static_cast<simulation::Node*>(listSolver.back()->getContext());
if (solvernode->linearSolver.empty())
return solvernode; // no linearsolver
core::behavior::BaseLinearSolver * linearSolver = solvernode->linearSolver[0];
if (!linearSolver->isMultiGroup())
{
return solvernode;
}
// This solver handles multiple groups, we have to find which group contains this collision model
// First move up to the node of the initial mechanical object
while (node->mechanicalMapping && node->mechanicalMapping->getMechFrom()[0])
node = static_cast<simulation::Node*>(node->mechanicalMapping->getMechFrom()[0]->getContext());

// Then check if it is one of the child nodes of the solver node
for (simulation::Node::ChildIterator it = solvernode->child.begin(), itend = solvernode->child.end(); it != itend; ++it)
if (*it == node)
{
return it->get();
}

// Then check if it is a child of one of the child nodes of the solver node
for (simulation::Node::ChildIterator it = solvernode->child.begin(), itend = solvernode->child.end(); it != itend; ++it)
if (node->hasParent(it->get()))
return it->get();

// Then check if it is a grand-childs of one of the child nodes of the solver node
for (simulation::Node::ChildIterator it = solvernode->child.begin(), itend = solvernode->child.end(); it != itend; ++it)
if (node->getContext()->hasAncestor(it->get()))
return it->get();

// group not found, simply return the solver node
simulation::Node* solvernode = static_cast<simulation::Node*>(listSolver.back()->getContext());
return solvernode;
}

Expand Down
2 changes: 1 addition & 1 deletion modules/SofaGeneralLinearSolver/MinResLinearSolver.inl
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void MinResLinearSolver<TMatrix,TVector>::solve(Matrix& A, Vector& x, Vector& b)


std::map < std::string, sofa::helper::vector<SReal> >& graph = *f_graph.beginEdit();
sofa::helper::vector<SReal>& graph_error = graph[(this->isMultiGroup()) ? this->currentNode->getName()+std::string("-Error") : std::string("Error")];
sofa::helper::vector<SReal>& graph_error = graph[std::string("Error")];
graph_error.clear();
graph_error.push_back(1);

Expand Down