void mindist_trajectory(float* coords, float* box, int* groups1, int* groups2, int gn1, int gn2, int na, int nf, int pbc, float* dist) { float mindist; int a,b,g1,g2,n1,n2,g1atm,g2atm,f; float coo1[3], coo2[3]; int nf3 = nf*3; // Precalculate 3 * nframes for the coordinate lookup macro int groupprod = gn1*gn2; // Iterate over all frames for (f=0; f < nf; f++){ // Iterate over the two group sets for (g1=0; g1 < gn1; g1++){ for (g2=0; g2 < gn2; g2++){ mindist = -1; // Iterate over atoms in the two groups for (a = 0; a < na; a++) { g1atm = groups1[g1 * na + a]; if (g1atm == -1) break; //get_coords(coords, g1atm, f, nf, coo1); //const float* coo1 = &coords[g1atm*dim]; for (b=0; b < na; b++) { g2atm = groups2[g2 * na + b]; if (g2atm == -1) break; //get_coords(coords, g2atm, f, nf, coo2); //const float* coo2 = &coords[g2atm*dim]; float d[3]; d[0] = coords[Xf(g1atm,f,nf,nf3)]-coords[Xf(g2atm,f,nf,nf3)]; d[1] = coords[Yf(g1atm,f,nf,nf3)]-coords[Yf(g2atm,f,nf,nf3)]; d[2] = coords[Zf(g1atm,f,nf,nf3)]-coords[Zf(g2atm,f,nf,nf3)]; if (pbc){ d[0] = d[0] - box[0] * round(d[0] / box[0]); d[1] = d[1] - box[1] * round(d[1] / box[1]); d[2] = d[2] - box[2] * round(d[2] / box[2]); } //printf("coor: %f %f %f / %f %f %f\n", coo1[0], coo1[1], coo1[2], coo2[0], coo2[1], coo2[2]); float D = d[0]*d[0]+d[1]*d[1]+d[2]*d[2]; //printf("index: %d/%d dist: %f\n", g1atm, g2atm, sqrt(D)); if (D < mindist || mindist < 0) { mindist = D; } } } //printf("%d %d %d %d: %f\n", g1, gn2, g2, g1*gn2+g2, sqrt(mindist)); dist[g1*gn2+g2+(f*groupprod)] = sqrt(mindist); // Add here the f } } } }
//helper: computes a facet horizontal and vertical extensions void ComputeFacetExtensions(CCVector3& N, ccPolyline* facetContour, double& horizExt, double& vertExt) { //horizontal and vertical extensions horizExt = vertExt = 0; CCLib::GenericIndexedCloudPersist* vertCloud = facetContour->getAssociatedCloud(); if (vertCloud) { //oriRotMat.applyRotation(N); //DGM: oriRotMat is only for display! //we assume that at this point the "up" direction is always (0,0,1) CCVector3 Xf(1,0,0), Yf(0,1,0); //we get the horizontal vector on the plane CCVector3 D = CCVector3(0,0,1).cross(N); if (D.norm2() > ZERO_TOLERANCE) //otherwise the facet is horizontal! { Yf = D; Yf.normalize(); Xf = N.cross(Yf); } const CCVector3* G = CCLib::Neighbourhood(vertCloud).getGravityCenter(); ccBBox box; for (unsigned i=0; i<vertCloud->size(); ++i) { const CCVector3 P = *(vertCloud->getPoint(i)) - *G; CCVector3 p( P.dot(Xf), P.dot(Yf), 0 ); box.add(p); } vertExt = box.getDiagVec().x; horizExt = box.getDiagVec().y; } }
dvec CanteraGas::calculateReactantMixture(const std::string& fuel, const std::string& oxidizer, double equivalenceRatio) { size_t mC = thermo.elementIndex("C"); size_t mO = thermo.elementIndex("O"); size_t mH = thermo.elementIndex("H"); double Cf(0), Hf(0), Of(0); // moles of C/H/O in fuel double Co(0), Ho(0), Oo(0); // moles of C/H/O in oxidizer dvec Xf(nSpec), Xo(nSpec), Xr(nSpec); thermo.setState_TPX(300.0, pressure, fuel); getMoleFractions(Xf); thermo.setState_TPX(300.0, pressure, oxidizer); getMoleFractions(Xo); dvec a(thermo.nElements()); for (size_t k=0; k<nSpec; k++) { thermo.getAtoms(k, &a[0]); if (mC != npos) { Cf += a[mC]*Xf[k]; Co += a[mC]*Xo[k]; } if (mH != npos) { Hf += a[mH]*Xf[k]; Ho += a[mH]*Xo[k]; } if (mO != npos) { Of += a[mO]*Xf[k]; Oo += a[mO]*Xo[k]; } } double stoichAirFuelRatio = -(Of-2*Cf-Hf/2)/(Oo-2*Co-Ho/2); Xr = Xf * equivalenceRatio + stoichAirFuelRatio * Xo; Xr /= Xr.sum(); return Xr; }
void sys_init_sockets(void) { INFO("Init Windows Sockets..."); WSADATA wsaData; int result = WSAStartup(MAKEWORD(2,2), &wsaData); switch (result) { case 0: // success break; case WSASYSNOTREADY: Xf(init_winsock, "%s", XSTR_NETWORK": underlying network subsystem is not ready for network communication"); case WSAVERNOTSUPPORTED: Xf(init_winsock, "%s", XSTR_NETWORK": version of Windows Sockets support requested is not provided by this particular Windows Sockets implementation"); case WSAEINPROGRESS: Xf(init_winsock, "%s", XSTR_NETWORK": blocking Windows Sockets 1.1 operation is in progress"); case WSAEPROCLIM: Xf(init_winsock, "%s", XSTR_NETWORK": limit on the number of tasks supported by the Windows Sockets implementation has been reached"); case WSAEFAULT: Xf(init_winsock, "%s", XSTR_NETWORK": lpWSAData parameter is not a valid pointer"); default: Xf(init_winsock, XSTR_NETWORK": Winsock error: %d", result); } const char *desc = wsaData.szDescription; const char *status = wsaData.szSystemStatus; int major = LOBYTE(wsaData.wVersion); int minor = HIBYTE(wsaData.wVersion); INFOf("Windows Sockets spec %d.%d implemented by %s (%s)\n", minor, major, desc, status); UNUSED(desc); UNUSED(status); UNUSED(major); UNUSED(minor); INFO("Init Windows Sockets... Done!"); return; err_init_winsock: exit(-1); }
void parcel::setRelaxationTimes ( label celli, scalar& tauMomentum, scalarField& tauEvaporation, scalar& tauHeatTransfer, scalarField& tauBoiling, const spray& sDB, const scalar rho, const vector& Up, const scalar temperature, const scalar pressure, const scalarField& Yfg, const scalarField& m0, const scalar dt ) { const liquidMixture& fuels = sDB.fuels(); scalar mCell = rho*sDB.mesh().V()[cell()]; scalarField mfg(Yfg*mCell); label Ns = sDB.composition().Y().size(); label Nf = fuels.components().size(); // Tf is based on the 1/3 rule scalar Tf = T() + (temperature - T())/3.0; // calculate mixture properties scalar W = 0.0; scalar kMixture = 0.0; scalar cpMixture = 0.0; scalar muf = 0.0; for(label i=0; i<Ns; i++) { scalar Y = sDB.composition().Y()[i][celli]; W += Y/sDB.gasProperties()[i].W(); // Using mass-fractions to average... kMixture += Y*sDB.gasProperties()[i].kappa(Tf); cpMixture += Y*sDB.gasProperties()[i].Cp(Tf); muf += Y*sDB.gasProperties()[i].mu(Tf); } W = 1.0/W; scalarField Xf(Nf, 0.0); scalarField Yf(Nf, 0.0); scalarField psat(Nf, 0.0); scalarField msat(Nf, 0.0); for(label i=0; i<Nf; i++) { label j = sDB.liquidToGasIndex()[i]; scalar Y = sDB.composition().Y()[j][celli]; scalar Wi = sDB.gasProperties()[j].W(); Yf[i] = Y; Xf[i] = Y*W/Wi; psat[i] = fuels.properties()[i].pv(pressure, temperature); msat[i] = min(1.0, psat[i]/pressure)*Wi/W; } scalar nuf = muf/rho; scalar liquidDensity = fuels.rho(pressure, T(), X()); scalar liquidcL = fuels.cp(pressure, T(), X()); scalar heatOfVapour = fuels.hl(pressure, T(), X()); // calculate the partial rho of the fuel vapour // alternative is to use the mass fraction // however, if rhoFuelVap is small (zero) // d(mass)/dt = 0 => no evaporation... hmmm... is that good? NO! // Assume equilibrium at drop-surface => pressure @ surface // = vapour pressure to calculate fuel-vapour density @ surface scalar pressureAtSurface = fuels.pv(pressure, T(), X()); scalar rhoFuelVap = pressureAtSurface*fuels.W(X())/(specie::RR*Tf); scalarField Xs(sDB.fuels().Xs(pressure, temperature, T(), Xf, X())); scalarField Ys(Nf, 0.0); scalar Wliq = 0.0; for(label i=0; i<Nf; i++) { label j = sDB.liquidToGasIndex()[i]; scalar Wi = sDB.gasProperties()[j].W(); Wliq += Xs[i]*Wi; } for(label i=0; i<Nf; i++) { label j = sDB.liquidToGasIndex()[i]; scalar Wi = sDB.gasProperties()[j].W(); Ys[i] = Xs[i]*Wi/Wliq; } scalar Reynolds = Re(Up, nuf); scalar Prandtl = Pr(cpMixture, muf, kMixture); // calculate the characteritic times if(liquidCore_> 0.5) { // no drag for parcels in the liquid core.. tauMomentum = GREAT; } else { tauMomentum = sDB.drag().relaxationTime ( Urel(Up), d(), rho, liquidDensity, nuf, dev() ); } // store the relaxationTime since it is needed in some breakup models. tMom_ = tauMomentum; tauHeatTransfer = sDB.heatTransfer().relaxationTime ( liquidDensity, d(), liquidcL, kMixture, Reynolds, Prandtl ); // evaporation-properties are evaluated at averaged temperature // set the boiling conditions true if pressure @ surface is 99.9% // of the pressure // this is mainly to put a limit on the evaporation time, // since tauEvaporation is very very small close to the boiling point. for(label i=0; i<Nf; i++) { scalar Td = min(T(), 0.999*fuels.properties()[i].Tc()); bool boiling = fuels.properties()[i].pv(pressure, Td) >= 0.999*pressure; scalar Di = fuels.properties()[i].D(pressure, Td); scalar Schmidt = Sc(nuf, Di); scalar partialPressure = Xf[i]*pressure; // saturated vapour if(partialPressure > psat[i]) { tauEvaporation[i] = GREAT; } // not saturated vapour else { if (!boiling) { // for saturation evaporation, only use 99.99% for numerical robustness scalar dm = max(SMALL, 0.9999*msat[i] - mfg[i]); tauEvaporation[i] = sDB.evaporation().relaxationTime ( d(), fuels.properties()[i].rho(pressure, Td), rhoFuelVap, Di, Reynolds, Schmidt, Xs[i], Xf[i], m0[i], dm, dt ); } else { scalar Nusselt = sDB.heatTransfer().Nu(Reynolds, Prandtl); // calculating the boiling temperature of the liquid at ambient pressure scalar tBoilingSurface = Td; label Niter = 0; scalar deltaT = 10.0; scalar dp0 = fuels.properties()[i].pv(pressure, tBoilingSurface) - pressure; while ((Niter < 200) && (mag(deltaT) > 1.0e-3)) { Niter++; scalar pBoil = fuels.properties()[i].pv(pressure, tBoilingSurface); scalar dp = pBoil - pressure; if ( (dp > 0.0) && (dp0 > 0.0) ) { tBoilingSurface -= deltaT; } else { if ( (dp < 0.0) && (dp0 < 0.0) ) { tBoilingSurface += deltaT; } else { deltaT *= 0.5; if ( (dp > 0.0) && (dp0 < 0.0) ) { tBoilingSurface -= deltaT; } else { tBoilingSurface += deltaT; } } } dp0 = dp; } scalar vapourSurfaceEnthalpy = 0.0; scalar vapourFarEnthalpy = 0.0; for(label k = 0; k < sDB.gasProperties().size(); k++) { vapourSurfaceEnthalpy += sDB.composition().Y()[k][celli]*sDB.gasProperties()[k].H(tBoilingSurface); vapourFarEnthalpy += sDB.composition().Y()[k][celli]*sDB.gasProperties()[k].H(temperature); } scalar kLiquid = fuels.properties()[i].K(pressure, 0.5*(tBoilingSurface+T())); tauBoiling[i] = sDB.evaporation().boilingTime ( fuels.properties()[i].rho(pressure, Td), fuels.properties()[i].cp(pressure, Td), heatOfVapour, kMixture, Nusselt, temperature - T(), d(), liquidCore(), sDB.runTime().value() - ct(), Td, tBoilingSurface, vapourSurfaceEnthalpy, vapourFarEnthalpy, cpMixture, temperature, kLiquid ); } } } }
void GQuiver::poseStampedCallback(const geometry_msgs::PoseStamped msg) { sourceFrame = Frame::findFrame(msg.header.frame_id); if (sourceFrame < 0) { publishStatus(Gadget::ERROR, "No transform from fixed frame to message frame"); return; } if (!availableFrames[sourceFrame].valid) { publishStatus(Gadget::ERROR, "No transform from fixed frame to message frame"); return; } Ogre::SceneNode * node; // If none exists, create a blank rendered frame if (xCones.size() == 0) { // Create scene node node = graphicNode->createChildSceneNode(); sceneNodes.push_back(node); addFrameToNode(node); } else { node = sceneNodes[0]; } tf::StampedTransform & tran = availableFrames[sourceFrame].extrapTransform; tf::Vector3 & pos = tran.getOrigin(); tf::Quaternion rot = tran.getRotation(); Ogre::Quaternion Qf(rot.w(), rot.x(), rot.y(), rot.z()); Ogre::Vector3 Xf(pos.x(), pos.y(), pos.z()); Ogre::Quaternion Qe(msg.pose.orientation.w, msg.pose.orientation.x, msg.pose.orientation.y, msg.pose.orientation.z); Ogre::Vector3 Xe(msg.pose.position.x, msg.pose.position.y, msg.pose.position.z); // Set pose indicator position node->setPosition(Xf + Qf * Xe); node->setOrientation(Qf * Qe); node->setScale(scale, scale, scale); if (drawXAxis) { xCones[0]->setColor(Ogre::ColourValue(xColour[0] / 255.f, xColour[1] / 255.f, xColour[2] / 255.f, 1)); xCylinders[0]->setColor(Ogre::ColourValue(xColour[0] / 255.f, xColour[1] / 255.f, xColour[2] / 255.f, 1)); } if (drawYAxis) { yCones[0]->setColor(Ogre::ColourValue(yColour[0] / 255.f, yColour[1] / 255.f, yColour[2] / 255.f, 1)); yCylinders[0]->setColor(Ogre::ColourValue(yColour[0] / 255.f, yColour[1] / 255.f, yColour[2] / 255.f, 1)); } if (drawZAxis) { zCones[0]->setColor(Ogre::ColourValue(zColour[0] / 255.f, zColour[1] / 255.f, zColour[2] / 255.f, 1)); zCylinders[0]->setColor(Ogre::ColourValue(zColour[0] / 255.f, zColour[1] / 255.f, zColour[2] / 255.f, 1)); } publishStatus(Gadget::OKAY, "Okay"); msgsRecieved++; }
void GQuiver::poseArrayCallback(const geometry_msgs::PoseArray msg) { sourceFrame = Frame::findFrame(msg.header.frame_id); if (sourceFrame < 0) { publishStatus(Gadget::ERROR, "No transform from fixed frame to message frame"); return; } if (!availableFrames[sourceFrame].valid) { publishStatus(Gadget::ERROR, "No transform from fixed frame to message frame"); return; } // Cull axes to keep their number within the limit while (sceneNodes.size() > msg.poses.size()) { removeFirstIn(); } while (sceneNodes.size() < msg.poses.size()) { // Create scene node at odo position Ogre::SceneNode * newNode = graphicNode->createChildSceneNode(); sceneNodes.push_back(newNode); addFrameToNode(newNode); } tf::StampedTransform & tran = availableFrames[sourceFrame].extrapTransform; tf::Vector3 & pos = tran.getOrigin(); tf::Quaternion rot = tran.getRotation(); Ogre::Quaternion Qf(rot.w(), rot.x(), rot.y(), rot.z()); Ogre::Vector3 Xf(pos.x(), pos.y(), pos.z()); for (int i = 0; i < msg.poses.size(); i++) { Ogre::Quaternion Qe(msg.poses[i].orientation.w, msg.poses[i].orientation.x, msg.poses[i].orientation.y, msg.poses[i].orientation.z); Ogre::Vector3 Xe(msg.poses[i].position.x, msg.poses[i].position.y, msg.poses[i].position.z); Ogre::Vector3 X1 = Xf + Qf * Xe; Ogre::Quaternion Q1 = Qf * Qe; Ogre::SceneNode * node = sceneNodes[i]; node->setPosition(X1); node->setOrientation(Q1); node->setScale(scale, scale, scale); if (drawXAxis) { xCones[i]->setColor(Ogre::ColourValue(xColour[0] / 255.f, xColour[1] / 255.f, xColour[2] / 255.f, 1)); xCylinders[i]->setColor(Ogre::ColourValue(xColour[0] / 255.f, xColour[1] / 255.f, xColour[2] / 255.f, 1)); } if (drawYAxis) { yCones[i]->setColor(Ogre::ColourValue(yColour[0] / 255.f, yColour[1] / 255.f, yColour[2] / 255.f, 1)); yCylinders[i]->setColor(Ogre::ColourValue(yColour[0] / 255.f, yColour[1] / 255.f, yColour[2] / 255.f, 1)); } if (drawZAxis) { zCones[i]->setColor(Ogre::ColourValue(zColour[0] / 255.f, zColour[1] / 255.f, zColour[2] / 255.f, 1)); zCylinders[i]->setColor(Ogre::ColourValue(zColour[0] / 255.f, zColour[1] / 255.f, zColour[2] / 255.f, 1)); } } publishStatus(Gadget::OKAY, "Okay"); msgsRecieved++; }
void GQuiver::odometryCallback(const nav_msgs::Odometry msg) { sourceFrame = Frame::findFrame(msg.header.frame_id); if (sourceFrame < 0) { publishStatus(Gadget::ERROR, "No transform from fixed frame to message frame"); return; } if (!availableFrames[sourceFrame].valid) { publishStatus(Gadget::ERROR, "No transform from fixed frame to message frame"); return; } // Cull axes to keep their number within the limit while (sceneNodes.size() > countLimit) { removeFirstIn(); } tf::StampedTransform & tran = availableFrames[sourceFrame].extrapTransform; tf::Vector3 & pos = tran.getOrigin(); tf::Quaternion rot = tran.getRotation(); Ogre::Quaternion Qf(rot.w(), rot.x(), rot.y(), rot.z()); Ogre::Vector3 Xf(pos.x(), pos.y(), pos.z()); Ogre::Quaternion Qe(msg.pose.pose.orientation.w, msg.pose.pose.orientation.x, msg.pose.pose.orientation.y, msg.pose.pose.orientation.z); Ogre::Vector3 Xe(msg.pose.pose.position.x, msg.pose.pose.position.y, msg.pose.pose.position.z); Ogre::Vector3 X1 = Xf + Qf * Xe; Ogre::Quaternion Q1 = Qf * Qe; if (sceneNodes.size() > 0) { Ogre::Vector3 X2 = sceneNodes.back()->getPosition(); Ogre::Quaternion Q2 = sceneNodes.back()->getOrientation(); if ((X1 - X2).normalise() < positionTolerance) { return; } if (acos((Q2.Inverse() * Q1).w) * 2 < angleTolerance) { return; } } // Create scene node at odo position Ogre::SceneNode * newNode = graphicNode->createChildSceneNode(); newNode->setPosition(X1); newNode->setOrientation(Q1); newNode->setScale(scale, scale, scale); sceneNodes.push_back(newNode); addFrameToNode(newNode); publishStatus(Gadget::OKAY, "Okay"); msgsRecieved++; }
void abcd::distributeRhs() { mpi::broadcast(inter_comm, use_xf, 0); if(icntl[Controls::block_size] < nrhs) icntl[Controls::block_size] = nrhs; mpi::broadcast(inter_comm, icntl[Controls::block_size], 0); if(comm.rank() == 0) { int r_pos = 0; // Build my part of the RHS //int r = std::accumulate(partitions.begin(), partitions.end(), 0, sum_rows); int r = 0; for(int i = 0; i < nb_local_parts; i++){ r += partitions[i].dim(0); } if(rhs == nullptr){ rhs = new double[n_l * nrhs]; srand(10); B = MV_ColMat_double(m_l, icntl[Controls::block_size]); nrmXf = 0; Xf = MV_ColMat_double(A.dim(1), nrhs); for(int j = 0; j < nrhs; j++){ for(int i = 0; i < A.dim(1); i++){ rhs[i + j * n_l] = (double)((rand())%100+1)/99.0; } } for(int j = 0; j < nrhs; j++){ VECTOR_double xf_col(A.dim(1)); for(int i = 0; i < A.dim(1); i++) { xf_col[i] = rhs[i + j * A.dim(1)]; } Xf.setCol(xf_col, j); } MV_ColMat_double BB = smv(A, Xf); for(int j = 0; j < nrhs; j++){ double unscaled; for(int i = 0; i < A.dim(1); i++) { unscaled = rhs[i + j * A.dim(1)] * dcol_[i]; if(abs(unscaled) > nrmXf) nrmXf = abs(unscaled); Xf(i, j) = unscaled; } } for(int j = 0; j < nrhs; j++){ //VECTOR_double t(rhs+j*m_l, m_l); //B.setCol(t, j); //B.push_back(t); B(MV_VecIndex(0, m_l-1), MV_VecIndex(0,nrhs-1)) = BB; } } else { B = MV_ColMat_double(m_l, icntl[Controls::block_size], 0); if(row_perm.size() != 0){ for(int j = 0; j < nrhs; j++){ for(int i = 0; i < m_l; i++) { B(i, j) = rhs[row_perm[i] + j*m_l]; } } } else { for(int j = 0; j < nrhs; j++){ for(int i = 0; i < m_l; i++) { B(i, j) = rhs[i + j*m_l]; } } } diagScaleRhs(B); } int good_rhs = 0; if (infNorm(B) == 0) { good_rhs = -9; mpi::broadcast(inter_comm, good_rhs, 0); stringstream err_msg; err_msg << "On process [" << comm.rank() << "], the given right-hand side is zero"; info[Controls::status] = good_rhs; throw std::runtime_error(err_msg.str()); } mpi::broadcast(inter_comm, good_rhs, 0); if(icntl[Controls::block_size] > nrhs) { double *rdata = new double[n_l * (icntl[Controls::block_size] - nrhs)]; srand(n_l); for(int i=0; i< n_l*(icntl[Controls::block_size]-nrhs); i++){ rdata[i] = (double)((rand())%10)/99.9 + 1; //rdata[i] = i+1; } MV_ColMat_double BR(rdata, n_l, icntl[Controls::block_size] - nrhs, MV_Matrix_::ref); MV_ColMat_double RR = smv(A, BR); B(MV_VecIndex(0,B.dim(0)-1),MV_VecIndex(nrhs,icntl[Controls::block_size]-1)) = RR(MV_VecIndex(0,B.dim(0)-1), MV_VecIndex(0, icntl[Controls::block_size]-nrhs - 1)); delete[] rdata; } r_pos += r; double *b_ptr = B.ptr(); // temp solution : // send Xf to everybody double *xf_ptr = Xf.ptr(); // for other masters except me! for(int k = 1; k < parallel_cg; k++) { inter_comm.send(k, 171, xf_ptr, Xf.dim(0)); } // for other masters except me! for(int k = 1; k < parallel_cg; k++) { // get the partitions that will be sent to the master inter_comm.send(k, 17, nrhs); } for(int k = 1; k < parallel_cg; k++) { for(int j = 0; j < icntl[Controls::block_size]; j++) { for(size_t i = 0; i < partitionsSets[k].size(); i++){ int p = partitionsSets[k][i]; inter_comm.send(k, 18, b_ptr + strow[p] + j * m_l, nbrows[p]); } } } if(!use_xf){ MV_ColMat_double BB(B); B = MV_ColMat_double(m, icntl[Controls::block_size], 0); int pos = 0; for(size_t i = 0; i < partitionsSets[0].size(); i++){ int p = partitionsSets[0][i]; for(int j = 0; j < nbrows[p]; j++){ for(int k = 0; k < icntl[Controls::block_size]; k++){ B(pos, k) = BB(strow[p] + j, k); } pos++; } } } } else { int good_rhs; mpi::broadcast(inter_comm, good_rhs, 0); if (good_rhs != 0) { info[Controls::status] = good_rhs; stringstream err_msg; err_msg << "On process [" << comm.rank() << "], leaving due to an error on the master"; throw std::runtime_error(err_msg.str()); } Xf = MV_ColMat_double(n_o, 1, 0); double *xf_ptr = Xf.ptr(); inter_comm.recv(0, 171, xf_ptr, n_o); inter_comm.recv(0, 17, nrhs); int size_rhs = m*icntl[Controls::block_size]; rhs = new double[size_rhs]; for(int i = 0; i < m * icntl[Controls::block_size]; i++) rhs[i] = 0; B = MV_ColMat_double(m, icntl[Controls::block_size], 0); for(int j = 0; j < icntl[Controls::block_size]; j++) { int p = 0; for(int k = 0; k < nb_local_parts; k++){ inter_comm.recv(0, 18, rhs + p + j * m, partitions[k].dim(0)); p+= partitions[k].dim(0); } VECTOR_double t(rhs+j*m, m); B.setCol(t, j); } delete[] rhs; } // and distribute max iterations mpi::broadcast(inter_comm, icntl[Controls::itmax], 0); mpi::broadcast(inter_comm, dcntl[Controls::threshold], 0); #ifdef WIP mpi::broadcast(inter_comm, dcntl[Controls::aug_filter], 0); #endif //WIP // A = CompRow_Mat_double(); }
StringPtr inspect_range(const CodePtr& code, const inst_t* start, const inst_t* end){ int sz = 0; const inst_t* pc = start; StringPtr temp; MemoryStreamPtr ms = xnew<MemoryStream>(); for(; pc < end;){switch(XTAL_opc(pc)){ XTAL_NODEFAULT; #define XTAL_INST_CASE(x) XTAL_CASE(x::NUMBER){ temp = x::inspect(pc, code); sz = x::ISIZE; } //{INST_INSPECT{{ XTAL_INST_CASE(InstLine); XTAL_INST_CASE(InstLoadValue); XTAL_INST_CASE(InstLoadConstant); XTAL_INST_CASE(InstLoadInt1Byte); XTAL_INST_CASE(InstLoadFloat1Byte); XTAL_INST_CASE(InstLoadCallee); XTAL_INST_CASE(InstLoadThis); XTAL_INST_CASE(InstCopy); XTAL_INST_CASE(InstInc); XTAL_INST_CASE(InstDec); XTAL_INST_CASE(InstPos); XTAL_INST_CASE(InstNeg); XTAL_INST_CASE(InstCom); XTAL_INST_CASE(InstAdd); XTAL_INST_CASE(InstSub); XTAL_INST_CASE(InstCat); XTAL_INST_CASE(InstMul); XTAL_INST_CASE(InstDiv); XTAL_INST_CASE(InstMod); XTAL_INST_CASE(InstAnd); XTAL_INST_CASE(InstOr); XTAL_INST_CASE(InstXor); XTAL_INST_CASE(InstShl); XTAL_INST_CASE(InstShr); XTAL_INST_CASE(InstUshr); XTAL_INST_CASE(InstAt); XTAL_INST_CASE(InstSetAt); XTAL_INST_CASE(InstGoto); XTAL_INST_CASE(InstNot); XTAL_INST_CASE(InstIf); XTAL_INST_CASE(InstIfEq); XTAL_INST_CASE(InstIfLt); XTAL_INST_CASE(InstIfRawEq); XTAL_INST_CASE(InstIfIs); XTAL_INST_CASE(InstIfIn); XTAL_INST_CASE(InstIfUndefined); XTAL_INST_CASE(InstIfDebug); XTAL_INST_CASE(InstPush); XTAL_INST_CASE(InstPop); XTAL_INST_CASE(InstAdjustValues); XTAL_INST_CASE(InstLocalVariable); XTAL_INST_CASE(InstSetLocalVariable); XTAL_INST_CASE(InstInstanceVariable); XTAL_INST_CASE(InstSetInstanceVariable); XTAL_INST_CASE(InstInstanceVariableByName); XTAL_INST_CASE(InstSetInstanceVariableByName); XTAL_INST_CASE(InstFilelocalVariable); XTAL_INST_CASE(InstSetFilelocalVariable); XTAL_INST_CASE(InstFilelocalVariableByName); XTAL_INST_CASE(InstSetFilelocalVariableByName); XTAL_INST_CASE(InstMember); XTAL_INST_CASE(InstMemberEx); XTAL_INST_CASE(InstCall); XTAL_INST_CASE(InstCallEx); XTAL_INST_CASE(InstSend); XTAL_INST_CASE(InstSendEx); XTAL_INST_CASE(InstProperty); XTAL_INST_CASE(InstSetProperty); XTAL_INST_CASE(InstScopeBegin); XTAL_INST_CASE(InstScopeEnd); XTAL_INST_CASE(InstReturn); XTAL_INST_CASE(InstYield); XTAL_INST_CASE(InstExit); XTAL_INST_CASE(InstRange); XTAL_INST_CASE(InstOnce); XTAL_INST_CASE(InstSetOnce); XTAL_INST_CASE(InstMakeArray); XTAL_INST_CASE(InstArrayAppend); XTAL_INST_CASE(InstMakeMap); XTAL_INST_CASE(InstMapInsert); XTAL_INST_CASE(InstMapSetDefault); XTAL_INST_CASE(InstClassBegin); XTAL_INST_CASE(InstClassEnd); XTAL_INST_CASE(InstDefineClassMember); XTAL_INST_CASE(InstDefineMember); XTAL_INST_CASE(InstMakeFun); XTAL_INST_CASE(InstMakeInstanceVariableAccessor); XTAL_INST_CASE(InstTryBegin); XTAL_INST_CASE(InstTryEnd); XTAL_INST_CASE(InstPushGoto); XTAL_INST_CASE(InstPopGoto); XTAL_INST_CASE(InstThrow); XTAL_INST_CASE(InstAssert); XTAL_INST_CASE(InstBreakPoint); XTAL_INST_CASE(InstMAX); //}}INST_INSPECT} } ms->put_s(Xf("%04d(%04d):%s\n")->call((int_t)(pc-start), code->compliant_lineno(pc), temp)->to_s()); pc += sz; } ms->seek(0); return ms->get_s(ms->size()); }
bool connection_open_tcp(connection *con, const char *host, const char *service) { EXPECT_FATAL(con); EXPECT_FATAL(host); EXPECT_FATAL(service); EXPECT_FATAL(sizeof(con->mem) >= sizeof(SOCKET)); if (strnlen(host, 256) > 255) { X(bad_arg, XSTR_LIMIT": host must not exceed 255 octets"); } SOCKET s = INVALID_SOCKET; // method e.g. "GET" // host e.g. "example.org" // rsc e.g. "/index.html" // port e.g. 80 const struct addrinfo hints = { AI_NUMERICSERV | AI_ADDRCONFIG, // ai_flags AF_UNSPEC, // ai_family: AF_INET | AF_INET6 | AF_UNSPEC SOCK_STREAM, // ai_socktype (TCP) IPPROTO_TCP, // ai_protocol (TCP) 0, NULL, NULL, NULL, }; struct addrinfo *result; int ret = getaddrinfo(host, service, &hints, &result); if (ret != 0) { Xf(lookup_address, XSTR_NETWORK": (%s) %s", host, getaddrinfo_strerror(ret)); } for (struct addrinfo *current = result; current; current = current->ai_next) { s = socket(current->ai_family, current->ai_socktype, current->ai_protocol); if (s == INVALID_SOCKET) { Xf(socket, XSTR_NETWORK ": socket() errno=%d\n", socket_geterr()); } ret = socket_connect(s, current->ai_addr, current->ai_addrlen); if (ret != 0) { Xf(connect, XSTR_NETWORK ": connect() errno=%d\n", socket_geterr()); } memset(con->address, '\0', CFW_INET6_ADDRSTRLEN); # ifndef TARGET_WINDOWS if(!inet_ntop(current->ai_family, &((struct sockaddr_in *) current->ai_addr)->sin_addr, con->address, CFW_INET6_ADDRSTRLEN) ) { WARNING("inet_ntop() IP lookup failure"); } # endif // success break; // fallthru err_connect: socket_close(s); err_socket: continue; } freeaddrinfo(result); if (s == INVALID_SOCKET) { X(no_match, "No matching socket"); } memcpy(con, &s, sizeof(SOCKET)); strcpy(con->host, host); return true; err_no_match: freeaddrinfo(result); err_lookup_address: err_bad_arg: return false; }