add sanity checking for thread groups in ASMu2Dmx

This commit is contained in:
Arne Morten Kvarving 2020-05-04 10:14:46 +02:00
parent 204b7c71b7
commit a51f7a65ff
3 changed files with 44 additions and 0 deletions

View File

@ -438,3 +438,33 @@ std::pair<size_t,double> ASMLRSpline::findClosestNode (const Vec3& X) const
return std::make_pair(iclose,distance);
}
bool ASMLRSpline::checkThreadGroups (const IntMat& groups,
const std::vector<const LR::LRSpline*> bases,
const LR::LRSpline* threadBasis)
{
size_t groupId = 1;
bool ok = true;
for (const auto& elms : groups) {
size_t basisId = 1;
for (const LR::LRSpline* basis : bases) {
std::set<int> nodes;
for (int elm : elms) {
std::vector<double> midpoint = threadBasis->getElement(elm)->midpoint();
int bElm = basis->getElementContaining(midpoint);
for (const LR::Basisfunction* func : basis->getElement(bElm)->support()) {
if (nodes.find(func->getId()) != nodes.end()) {
std::cerr << " ** Warning: Function " << func->getId() << " on basis " << basisId << " present for multiple elements in group " << groupId << std::endl;
ok = false;
}
nodes.insert(func->getId());
}
}
++basisId;
}
++groupId;
}
return ok;
}

View File

@ -181,6 +181,14 @@ protected:
//! \param lrspline The spline to perform adaptation for
bool doRefine(const LR::RefineData& prm, LR::LRSpline* lrspline);
//! \brief Santity check thread groups.
//! \param groups The generated thread groups
//! \param bases The bases to check for
//! \param threadBasis The LRSpline the element groups are derived from
static bool checkThreadGroups(const IntMat& groups,
const std::vector<const LR::LRSpline*> bases,
const LR::LRSpline* threadBasis);
LR::LRSpline* geo; //!< Pointer to the actual spline geometry object
};

View File

@ -1093,8 +1093,14 @@ void ASMu2Dmx::generateThreadGroups (const Integrand& integrand, bool silence,
LR::generateThreadGroups(threadGroups,threadBasis,secConstraint);
std::vector<const LR::LRSpline*> bases;
for (const std::shared_ptr<LR::LRSplineSurface>& basis : m_basis)
bases.push_back(basis.get());
if (silence || threadGroups[0].size() < 2) return;
this->checkThreadGroups(threadGroups[0], bases, threadBasis);
std::cout <<"\nMultiple threads are utilized during element assembly.";
for (size_t i = 0; i < threadGroups[0].size(); i++)
std::cout <<"\n Color "<< i+1 <<": "