void CrackFrontDefinition::orderEndNodes(std::vector<unsigned int> &end_nodes) { //Choose the node to be the first node. Do that based on undeformed coordinates for repeatability. Node & node0 = _mesh.node(end_nodes[0]); Node & node1 = _mesh.node(end_nodes[1]); Real tol = 1e-14; unsigned int num_pos_coor0 = 0; unsigned int num_pos_coor1 = 0; Real dist_from_origin0 = 0.0; Real dist_from_origin1 = 0.0; for (unsigned int i=0; i<3; ++i) { dist_from_origin0 += node0(i)*node0(i); dist_from_origin1 += node1(i)*node1(i); if (node0(i) > tol) { ++num_pos_coor0; } if (node1(i) > tol) { ++num_pos_coor1; } } dist_from_origin0 = std::sqrt(dist_from_origin0); dist_from_origin1 = std::sqrt(dist_from_origin1); bool switch_ends = false; if (num_pos_coor1 > num_pos_coor0) { switch_ends = true; } else { if (std::abs(dist_from_origin1 - dist_from_origin0) > tol) { if (dist_from_origin1 < dist_from_origin0) { switch_ends = true; } } else { if (end_nodes[1] < end_nodes[0]) { switch_ends = true; } } } if (switch_ends) { unsigned int tmp_node = end_nodes[1]; end_nodes[1] = end_nodes[0]; end_nodes[0] = tmp_node; } }
Box createBox(Set *vertices, Set *edges, unsigned numX, unsigned numY, unsigned numZ) { uassert(numX >= 1 && numY >= 1 && numZ >= 1); vector<ElementRef> points(numX*numY*numZ); for(unsigned x = 0; x < numX; ++x) { for(unsigned y = 0; y < numY; ++y) { for(unsigned z = 0; z < numZ; ++z) { points[node0(x,y,z)] = vertices->add(); } } } map<Box::Coord, ElementRef> coords2edges; // x edges for(unsigned x = 0; x < numX-1; ++x) { for(unsigned y = 0; y < numY; ++y) { for(unsigned z = 0; z < numZ; ++z) { Box::Coord coord(points[node0(x,y,z)], points[node1X(x,y,z)]); simit::ElementRef edge = edges->add(coord.first, coord.second); coords2edges[coord] = edge; } } } // y edges for(unsigned x = 0; x < numX; ++x) { for(unsigned y = 0; y < numY - 1; ++y) { for(unsigned z = 0; z < numZ; ++z) { Box::Coord coord(points[node0(x,y,z)], points[node1Y(x,y,z)]); simit::ElementRef edge = edges->add(coord.first, coord.second); coords2edges[coord] = edge; } } } // z edges for(unsigned x = 0; x < numX; ++x) { for(unsigned y = 0; y < numY; ++y) { for(unsigned z = 0; z < numZ-1; ++z) { Box::Coord coord(points[node0(x,y,z)], points[node1Z(x,y,z)]); simit::ElementRef edge = edges->add(coord.first, coord.second); coords2edges[coord] = edge; } } } return Box(numX, numY, numZ, points, coords2edges); }
int main(int argc, char **argv) { if (argc == 2 && strncmp(NODE0, argv[1], strlen(NODE0)) == 0) { return node0(SOCKET_ADDR); } else if (argc == 2 && strncmp (NODE1, argv[1], strlen (NODE1)) == 0) { return node1(SOCKET_ADDR); } else { fprintf (stderr, "Usage: pair %s|%s <ARG> ...\n", NODE0, NODE1); return 1; } }
int main(int argc, char** argv) { if (strcmp(NODE0, argv[1]) == 0 && argc > 1) return node0(argv[2]); else if (strcmp(NODE1, argv[1]) == 0 && argc > 2) return node1(argv[2], argv[3]); else printf("error"); return 0; }
/* --- main --- */ int main(const int argc, const char **argv) { if(strncmp(NODE0, argv[1], strlen(NODE0)) == 0 && argc > 1) { return node0(argv[2]); } else if(strncmp(NODE1, argv[1], strlen(NODE1)) == 0 && argc > 2) { return node1(argv[2], argv[3]); } else { fprintf(stderr, "Usage: pipeline %s|%s <URL> <ARG> ...'\n", NODE0, NODE1); return 1; } }
int main (const int argc, const char **argv) { if (strncmp (NODE0, argv[1], strlen (NODE0)) == 0 && argc > 1) return node0 (argv[2]); else if (strncmp (NODE1, argv[1], strlen (NODE1)) == 0 && argc > 1) return node1 (argv[2]); else { fprintf (stderr, "Usage: reqrep %s|%s <URL> <ARG> ...\n", NODE0, NODE1); return 1; } }
int nano_proc (const int argc, const char **argv) { if (strncmp (NODE0, argv[2], strlen (NODE0)) == 0 && argc > 2) return node0 (argv[3]); else if (strncmp (NODE1, argv[2], strlen (NODE1)) == 0 && argc > 3) return node1 (argv[3], argv[4]); else { fprintf (stderr, "Usage: pipeline %s|%s <URL> <ARG> ...'\n", NODE0, NODE1); return 1; } }
int node(const char *name) { int sock; if (!strcmp(name, "node0")) { sock = node0(); } else if (!strcmp(name, "node1")) { sock = node1(); } else if (!strcmp(name, "node2")) { sock = node2(); } else if (!strcmp(name, "node3")) { sock = node3(); } else { return -1; } return bus_on(sock, name); }
const char *Graph::s() const { String w; w << "Graph: "; if (flag(GFLAG_HALFEDGES)) w << " HALFEDGES"; if (flag(GFLAG_ALLOWLOOPS)) w << " ALLOWLOOPS"; if (flag(GFLAG_MULTIGRAPH)) w << " MULTIGRAPH"; w << "\n"; for (int i = 0; i < nodes_.length(); i++) { Node &n = node0(i); // if (n.deleted()) continue; w << fmt(i,3) << ": " << n.s() << "\n"; } String &s3 = Debug::str(); s3.set(w); return s3.chars(); }
Node &Graph::node(int id) const { Node &n = node0(id); // ASSERT(!n.deleted()); return n; }