本文整理汇总了C++中SpatialLocalizer::giveNodeClosestToPoint方法的典型用法代码示例。如果您正苦于以下问题:C++ SpatialLocalizer::giveNodeClosestToPoint方法的具体用法?C++ SpatialLocalizer::giveNodeClosestToPoint怎么用?C++ SpatialLocalizer::giveNodeClosestToPoint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SpatialLocalizer
的用法示例。
在下文中一共展示了SpatialLocalizer::giveNodeClosestToPoint方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: findSlaveToMasterMap
void PrescribedGradientBCPeriodic :: findSlaveToMasterMap()
{
FloatArray coord;
SpatialLocalizer *sl = this->domain->giveSpatialLocalizer();
//Set *masterSet = this->domain->giveSet(2);
const IntArray &nodes = this->domain->giveSet(this->set)->giveNodeList(); // Split into slave set and master set?
int nsd = jump.giveSize();
std :: vector< FloatArray > jumps;
// Construct all the possible jumps;
jumps.reserve((2 << (nsd-1)) - 1);
if ( nsd != 3 ) {
OOFEM_ERROR("Only 3d implemented yet!");
}
jumps.emplace_back(jump);
jumps.emplace_back(FloatArray{jump.at(1), jump.at(2), 0.});
jumps.emplace_back(FloatArray{jump.at(1), 0., jump.at(3)});
jumps.emplace_back(FloatArray{0., jump.at(2), jump.at(3)});
jumps.emplace_back(FloatArray{jump.at(1), 0., 0.});
jumps.emplace_back(FloatArray{0., jump.at(2), 0.});
jumps.emplace_back(FloatArray{0., 0., jump.at(3)});
this->slavemap.clear();
for ( int inode : nodes ) {
Node *masterNode = NULL;
Node *node = this->domain->giveNode(inode);
const FloatArray &masterCoord = *node->giveCoordinates();
//printf("node %d\n", node->giveLabel()); masterCoord.printYourself();
// The difficult part, what offset to subtract to find the master side;
for ( FloatArray &testJump : jumps ) {
coord.beDifferenceOf(masterCoord, testJump);
masterNode = sl->giveNodeClosestToPoint(coord, fabs(jump.at(1))*1e-5);
if ( masterNode != NULL ) {
//printf("Found master (%d) to node %d (distance = %e)\n", masterNode->giveNumber(), node->giveNumber(),
// masterNode->giveCoordinates()->distance(coord));
break;
}
}
if ( masterNode != NULL ) {
this->slavemap.insert({node->giveNumber(), masterNode->giveNumber()});
} else {
OOFEM_ERROR("Couldn't find master node!");
}
}
}