本文整理汇总了C++中teuchos::RCP::Nseg方法的典型用法代码示例。如果您正苦于以下问题:C++ RCP::Nseg方法的具体用法?C++ RCP::Nseg怎么用?C++ RCP::Nseg使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类teuchos::RCP
的用法示例。
在下文中一共展示了RCP::Nseg方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReportError
InterfaceT)::ProjectNodes_SlavetoMaster_Orthogonal()
{
if (!IsComplete()) {
std::stringstream oss;
oss << "***ERR*** "
"MoertelT::Interface::ProjectNodes_SlavetoMaster_Orthogonal:\n"
<< "***ERR*** Complete() not called on interface " << Id() << "\n"
<< "***ERR*** file/line: " << __FILE__ << "/" << __LINE__ << "\n";
throw MoertelT::ReportError(oss);
}
if (lcomm_ == Teuchos::null) return true;
int mside = MortarSide();
int sside = OtherSide(mside);
// iterate over all nodes of the slave side and project those belonging to me
std::map<int, Teuchos::RCP<MoertelT::MOERTEL_TEMPLATE_CLASS(NodeT)>>::iterator
scurr;
for (scurr = rnode_[sside].begin(); scurr != rnode_[sside].end(); ++scurr) {
Teuchos::RCP<MoertelT::MOERTEL_TEMPLATE_CLASS(NodeT)> snode = scurr->second;
#if 0
std::cout << "now projecting\n " << *snode;
#endif
if (NodePID(snode->Id()) != lcomm_->getRank()) continue;
const double* sx = snode->XCoords();
double mindist = 1.0e+20;
Teuchos::RCP<MoertelT::MOERTEL_TEMPLATE_CLASS(NodeT)> closenode =
Teuchos::null;
// find a node on the master side, that is closest to me
std::map<int, Teuchos::RCP<MoertelT::MOERTEL_TEMPLATE_CLASS(NodeT)>>::
iterator mcurr;
for (mcurr = rnode_[mside].begin(); mcurr != rnode_[mside].end(); ++mcurr) {
Teuchos::RCP<MoertelT::MOERTEL_TEMPLATE_CLASS(NodeT)> mnode =
mcurr->second;
const double* mx = mnode->XCoords();
// build distance | mnode->XCoords() - snode->XCoords() |
double dist = 0.0;
for (int i = 0; i < 3; ++i) dist += (mx[i] - sx[i]) * (mx[i] - sx[i]);
dist = sqrt(dist);
if (dist <= mindist) {
mindist = dist;
closenode = mnode;
}
// std::cout << "snode " << snode->Id() << " mnode " << mnode->Id() << "
// mindist " << mindist << " dist " << dist << std::endl;
}
if (closenode == Teuchos::null) {
std::stringstream oss;
oss << "***ERR*** "
"MoertelT::Interface::ProjectNodes_SlavetoMaster_Orthogonal:\n"
<< "***ERR*** Weired: for slave node " << snode->Id()
<< " no closest master node found\n"
<< "***ERR*** file/line: " << __FILE__ << "/" << __LINE__ << "\n";
throw MoertelT::ReportError(oss);
}
// get segments attached to closest node cnode
int nmseg = closenode->Nseg();
MoertelT::SEGMENT_TEMPLATE_CLASS(SegmentT)** msegs = closenode->Segments();
// create a projection-iterator
MoertelT::MOERTEL_TEMPLATE_CLASS(ProjectorT)
projector(IsOneDimensional(), OutLevel());
// loop segments and find all projections onto them
int nsseg = snode->Nseg();
MoertelT::SEGMENT_TEMPLATE_CLASS(SegmentT)** ssegs = snode->Segments();
for (int i = 0; i < nmseg; ++i) {
// loop all segments that are adjacent to the slave node
for (int j = 0; j < nsseg; ++j) {
// project the slave node onto that master segment
double xi[2];
xi[0] = xi[1] = 0.0;
double gap;
projector.ProjectNodetoSegment_Orthogonal_to_Slave(
*snode, *(msegs[i]), xi, gap, *(ssegs[j]));
// check whether this projection is good
bool ok = false;
if (IsOneDimensional()) {
if (abs(xi[0]) < 1.01) ok = true;
} else {
std::stringstream oss;
oss << "***ERR*** "
"MoertelT::Interface::ProjectNodes_SlavetoMaster_Orthogonal:\n"
<< "***ERR*** not impl. for 3D\n"
<< "***ERR*** file/line: " << __FILE__ << "/" << __LINE__ << "\n";
throw MoertelT::ReportError(oss);
}
if (ok) // the projection is good
{
// create a projected node and store it in snode
MoertelT::MOERTEL_TEMPLATE_CLASS(ProjectedNodeT)* pnode =
new MoertelT::MOERTEL_TEMPLATE_CLASS(ProjectedNodeT)(
//.........这里部分代码省略.........
示例2: ReportError
/*----------------------------------------------------------------------*
| project nodes master to slave along slave cont. normal field |
*----------------------------------------------------------------------*/
bool MOERTEL::Interface::ProjectNodes_MastertoSlave_NormalField()
{
if (!IsComplete())
{
std::stringstream oss;
oss << "***ERR*** MOERTEL::Interface::ProjectNodes_MastertoSlave_NormalField:\n"
<< "***ERR*** Complete() not called on interface " << Id() << "\n"
<< "***ERR*** file/line: " << __FILE__ << "/" << __LINE__ << "\n";
throw ReportError(oss);
}
if (!lComm()) return true;
int mside = MortarSide();
int sside = OtherSide(mside);
// iterate over all nodes of the master side and project those belonging to me
std::map<int,Teuchos::RCP<MOERTEL::Node> >::iterator mcurr;
for (mcurr=rnode_[mside].begin(); mcurr!=rnode_[mside].end(); ++mcurr)
{
Teuchos::RCP<MOERTEL::Node> mnode = mcurr->second;
if (NodePID(mnode->Id()) != lComm()->MyPID())
continue;
const double* mx = mnode->X();
double mindist = 1.0e+20;
Teuchos::RCP<MOERTEL::Node> closenode = Teuchos::null;
// find a node on the slave side that is closest to me
std::map<int,Teuchos::RCP<MOERTEL::Node> >::iterator scurr;
for (scurr=rnode_[sside].begin(); scurr!=rnode_[sside].end(); ++scurr)
{
Teuchos::RCP<MOERTEL::Node> snode = scurr->second;
const double* sx = snode->X();
// build distance | snode->X() - mnode->X() |
double dist = 0.0;
for (int i=0; i<3; ++i) dist += (mx[i]-sx[i])*(mx[i]-sx[i]);
dist = sqrt(dist);
if (dist < mindist)
{
mindist = dist;
closenode = snode;
}
}
if (closenode == Teuchos::null)
{
std::stringstream oss;
oss << "***ERR*** MOERTEL::Interface::ProjectNodes_MastertoSlave_NormalField:\n"
<< "***ERR*** Weired: for master node " << mnode->Id() << " no closest master node found\n"
<< "***ERR*** file/line: " << __FILE__ << "/" << __LINE__ << "\n";
throw ReportError(oss);
}
#if 0
cout << "snode " << *mnode;
cout << "closenode " << *closenode;
#endif
// get segments attached to closest node closenode
int nseg = closenode->Nseg();
MOERTEL::Segment** segs = closenode->Segments();
// create a projection operator
MOERTEL::Projector projector(IsOneDimensional(),OutLevel());
// loop these segments and find best projection
double bestdist[2];
const double tol = 0.2;
double bestgap = 0.0, gap;
bestdist[0] = bestdist[1] = 1.0e+20;
MOERTEL::Segment* bestseg = NULL;
for (int i=0; i<nseg; ++i)
{
// project the master node on the slave segment along the segments interpolated normal field
double xi[2]; xi[0] = xi[1] = 0.0;
projector.ProjectNodetoSegment_SegmentNormal(*mnode,*(segs[i]),xi,gap);
// check whether xi is better then previous projections
if (IsOneDimensional())
{
if (abs(xi[0]) < abs(bestdist[0]))
{
bestdist[0] = xi[0];
bestdist[1] = xi[1];
bestseg = segs[i];
bestgap = gap;
}
}
else
{
double third = 1./3.;
// it's 'inside' with some tolerance
if ( xi[0]<=1.+tol && xi[1]<=abs(1.-xi[0])+tol && xi[0]>=0.-tol && xi[1]>=0.-tol )
{
// it's better in both directions
if ( sqrt((xi[0]-third)*(xi[0]-third)) < sqrt((bestdist[0]-third)*(bestdist[0]-third)) &&
sqrt((xi[1]-third)*(xi[1]-third)) < sqrt((bestdist[1]-third)*(bestdist[1]-third)) )
//.........这里部分代码省略.........