コード例 #1
0
template<> Node* StructuredMesh<ElementShape::QUAD>::getNode( size_t id ) const
{
    _nod->setNodeID(id);
    getNodeCoordinates(id, const_cast<GeoLib::Point*>(_nod->getX()));

    return _nod;
};
コード例 #2
0
ファイル: AStarPathFinder.c プロジェクト: manojcrisdo/RoboLab
int32 processAStarPath(neighbourList* f_aStarPathList_pst)
{
	int32 moveResult_i32 = 0x00;

	if(!isNeighbourListEmpty(f_aStarPathList_pst))
	{
		neighbourListNode* nextMove_pst = NULL;

		neighbourListNode* neighbour_pst = f_aStarPathList_pst->head;

		for (; neighbour_pst != NULL; neighbour_pst = nextMove_pst)
		{
			nextMove_pst = neighbour_pst->next;

			node* moveNode_pst = neighbour_pst ->neighbourNode_pst;

			coordinates moveNodeCoord_st =  getNodeCoordinates(moveNode_pst);

			moveResult_i32 = Robot_Move(moveNodeCoord_st.x_Coordinate_i32, moveNodeCoord_st.y_Coordinate_i32);

			if (ROBOT_FAIL == moveResult_i32)
			{
				return moveResult_i32;
			}
		}
	}

	return moveResult_i32;
}
コード例 #3
0
ファイル: AStarPathFinder.c プロジェクト: manojcrisdo/RoboLab
int32 heuristicEstimate(node* f_startNode_pst, node* f_inputNode_pst, node* f_endNode_pst)
{
	coordinates startNodeCoord_st =  getNodeCoordinates(f_startNode_pst);
	coordinates inputNodeCoord_st =  getNodeCoordinates(f_inputNode_pst);
	coordinates endNodeCoord_st =  getNodeCoordinates(f_endNode_pst);

	// Manhattan heuristic with cross-product tie breaker
	int32 diff_x1 = inputNodeCoord_st.x_Coordinate_i32 - endNodeCoord_st.x_Coordinate_i32;
	int32 diff_y1 = inputNodeCoord_st.y_Coordinate_i32 - endNodeCoord_st.y_Coordinate_i32;

	int32 diff_x2 = startNodeCoord_st.x_Coordinate_i32 - endNodeCoord_st.x_Coordinate_i32;
	int32 diff_y2 = startNodeCoord_st.y_Coordinate_i32 - endNodeCoord_st.y_Coordinate_i32;

	int32 heuristic_i32  = abs(diff_x1) + abs(diff_y1);

	int32 crossProduct_i32 = abs((diff_x1 * diff_y2) - (diff_x2 * diff_y1));

	heuristic_i32 += crossProduct_i32;

	return heuristic_i32;
}
コード例 #4
0
ファイル: MazeArray.c プロジェクト: aswin2691/RoboLab
node* searchMazeArray(int32 f_xCord_i32, int32 f_yCord_i32)
{
	node* mazeArrayElement_pst = NULL;

	uint32 it = 0; // better to initialize here

	for(; it < mazeArrayElements_ui32; it++)
	{
		mazeArrayElement_pst = &mazeArray[it];

		if (NULL != mazeArrayElement_pst)
		{
			coordinates mazeElementCoordinate_st = getNodeCoordinates(mazeArrayElement_pst);

			if((f_xCord_i32 == mazeElementCoordinate_st.x_Coordinate_i32) &&
				(f_yCord_i32 == mazeElementCoordinate_st.y_Coordinate_i32))
			{
				if(NULLDIRECTION == getAvailableDirections(mazeArrayElement_pst))
				{
					return NULL;
				}

				break;
			}
			else
			{
				// Left Intentionally blank
			}
		}

	}

	if((NULL == mazeArrayElement_pst) || (mazeArrayElements_ui32 == it))
	{
		return NULL;
	}
	else
	{
		return mazeArrayElement_pst;
	}
}
コード例 #5
0
   bool ShockBaseClass::getLocalSurfaces(Real t,std::vector<LocalSurface>& localSurfaces,uint32_t& N_shockCells,int refinements) {
      // Create shock mesh:
      if (initializeMesh(t,refinements) == false) {
	 simClasses->logger << "(SEP SHOCK BASE) ERROR: Failed to create shock mesh" << endl << write;
	 return false;
      }

      uint64_t N_surfaces = 0;
      const vector<Real>& faceData = getFaceData(N_surfaces);
      const vector<Real>& nodeCoordinates = getNodeCoordinates();
      const vector<uint32_t>& cellConnectivity = getCellConnectivity();
      N_shockCells = N_surfaces;
      
      // Iterate over all shock surface elements. If the element is on a cell hosted on 
      // this process (determined by cell centroid), inject particles to it:
      size_t connIndex = 0;
      for (size_t s=0; s<N_surfaces; ++s) {
	 const size_t areaIndex = s * ucdmesh::facedataelement::SIZE;
	 const size_t connSize = cellConnectivity[connIndex+1]+2;
	 
	 const size_t node1 = cellConnectivity[connIndex+2];
	 const size_t node2 = cellConnectivity[connIndex+3];
	 const size_t node3 = cellConnectivity[connIndex+4];
	 
	 Real centroid[3];
	 centroid[0] = (nodeCoordinates[3*node1+0] + nodeCoordinates[3*node2+0] + nodeCoordinates[3*node3+0])/3;
	 centroid[1] = (nodeCoordinates[3*node1+1] + nodeCoordinates[3*node2+1] + nodeCoordinates[3*node3+1])/3;
	 centroid[2] = (nodeCoordinates[3*node1+2] + nodeCoordinates[3*node2+2] + nodeCoordinates[3*node3+2])/3;
	 
	 Real normal[3];
	 normal[0] = faceData[areaIndex + ucdmesh::facedataelement::NORMAL_X];
	 normal[1] = faceData[areaIndex + ucdmesh::facedataelement::NORMAL_Y];
	 normal[2] = faceData[areaIndex + ucdmesh::facedataelement::NORMAL_Z];
	 
	 // Convert centroid position to logical coordinates and check that it 
	 // is inside simulation domain (coords are not inf):
	 Real logical[3];
	 Real xy,r,theta,phi;
	 Real spherCentroid[3];
	 switch (simControl.coordinateSystem) {
	  case sep::UNKNOWN:
	    finalizeMesh();
	    return false;
	    break;
	  case sep::CARTESIAN:
	    getLogicalCoordinates(sim,centroid,logical);
	    if (logical[0] == numeric_limits<Real>::infinity()) {
	       connIndex += connSize;
	       continue;
	    }
	    break;
	  case sep::CYLINDRICAL:
	    finalizeMesh();
	    return false;
	    break;
	  case sep::SPHERICAL:
	    // Need to convert to spherical coordinates first:
	    xy = centroid[0]*centroid[0] + centroid[1]*centroid[1];
	    r = xy + centroid[2]*centroid[2];
	    r = sqrt(r);
	    xy = sqrt(xy);
	    
	    theta = acos(centroid[2]/r);
	    phi = acos(centroid[0] / xy);
	    if (centroid[1] < 0.0) phi = -phi;
	    
	    spherCentroid[0] = r;
	    spherCentroid[1] = theta;
	    spherCentroid[2] = phi;
	    
	    // Check logical coords:
	    getLogicalCoordinates(sim,spherCentroid,logical);
	    if (logical[0] == std::numeric_limits<Real>::infinity()) {
	       connIndex += connSize;
	       continue;
	    }
	    break;
	  default:
	    finalizeMesh();
	    return false;
	    break;
	 }
	 
	 // Check that injection position is in upstream side:
	 Real d_shock = getSquaredDistanceToShock(t,logical);
	 bool acceptSurface = true;
	 while (d_shock <= 1.0) {
	    // Move injection point to the direction of shock normal:
      	    for (int i=0; i<3; ++i) centroid[i] += (0.1+1.001*fabs(d_shock))*normal[i];

	    switch (simControl.coordinateSystem) {
	     case sep::UNKNOWN:
	       finalizeMesh();
	       return false;
	       break;
	     case sep::CARTESIAN:
	       getLogicalCoordinates(sim,centroid,logical);
	       if (logical[0] == std::numeric_limits<Real>::infinity()) {
		  acceptSurface = false;
	       }
	       break;
	     case sep::CYLINDRICAL:
	       finalizeMesh();
	       return false;
	       break;
	     case sep::SPHERICAL:
	       xy = centroid[0]*centroid[0] + centroid[1]*centroid[1];
	       r = sqrt(xy + centroid[2]*centroid[2]);
	       xy = sqrt(xy);
	       theta = acos(centroid[2]/r);
	       phi = acos(centroid[0] / xy);
	       if (centroid[1] < 0.0) phi = -phi;
	       
	       spherCentroid[0] = r;
	       spherCentroid[1] = theta;
	       spherCentroid[2] = phi;
	       
	       getLogicalCoordinates(sim,spherCentroid,logical);
	       if (logical[0] == numeric_limits<Real>::infinity()) acceptSurface = false;
	       break;
	     default:
	       finalizeMesh();
	       return false;
	       break;
	    }
	    
	    if (acceptSurface == false) break;
	    d_shock = simControl.shock->getSquaredDistanceToShock(t,logical);
	 }

	 if (acceptSurface == false) {
	    connIndex += connSize;
	    continue;
	 }
	 
	 // Calculate cell indices:
	 int32_t i_block = static_cast<int32_t>(logical[0]) / block::WIDTH_X;
	 int32_t j_block = static_cast<int32_t>(logical[1]) / block::WIDTH_Y;
	 int32_t k_block = static_cast<int32_t>(logical[2]) / block::WIDTH_Z;
	               
	 // Calculate block global index and check if this process has it:
	 pargrid::CellID blockGID = block::calculateGlobalIndex(*sim,i_block,j_block,k_block);
	 pargrid::CellID blockLID = simClasses->pargrid.getLocalID(blockGID);
	 if (blockLID == pargrid::INVALID_CELLID) {
	    connIndex += connSize;
	    continue;
	 }
	 if (simClasses->pargrid.getHosts()[blockLID] != sim->mpiRank) {
	    connIndex += connSize;
	    continue;
	 }

	 // Surface accepted, add to output vector:
	 LocalSurface surface;
	 surface.localID = blockLID;
	 surface.globalID = blockGID;
	 for (int i=0; i<3; ++i) surface.position[i] = logical[i];
	 surface.area = faceData[areaIndex+ucdmesh::facedataelement::AREA];
	 surface.zoneIndex = s;
	 localSurfaces.push_back(surface);

	 connIndex += connSize;
      }

      if (finalizeMesh() == false) return false;
      return true;
   }