void syncBuffer() {
			clearInBuffer();
			allToAll(outBuffer);
			for (int i = 0; i < numPeers; ++i) {
				std::vector<BufferT> msgBuf = outBuffer[i];
				inBuffer.insert(inBuffer.end(), msgBuf.begin(), msgBuf.end());
			}
			for (int i = 0; i < numPeers; ++i) {
				outBuffer[i].clear();
			}
		}
Esempio n. 2
0
void velocity_solver_solve_stokes (double const* lowerSurface_F, double const* thickness_F,
    double const* beta_F, double const* temperature_F,
    double* u_normal_F,
    double* /*heatIntegral_F*/, double* /*viscosity_F*/)
{
  std::fill (u_normal_F, u_normal_F + nEdges_F * nLayers, 0.);

  if (!isDomainEmpty)
  {

    RegionMesh<LinearTetra>& mesh3D = * (iceProblemPtr->mesh3DPtr);
    //  RegionMesh<LinearTriangle>& mesh2D =  *(iceProblemPtr->mesh2DPtr);

    // Full Stokes solution
    //   [nvert+nedge][u|v|w]
    std::vector<Real> Velocity_FS (3 * mesh3D.numVertices()
        + 3 * mesh3D.numEdges() );
    // P1:   [u|v][nvert] using velocityOnVertices

    // P2:   [u|v][nvert+nedge]
    std::vector<Real> Velocity_P2 (2 * mesh3D.numVertices()
        + 2 * mesh3D.numEdges() );

    importP0Temperature (temperature_F);// import temperature to
    // temperatureOnTetra[numElements]
    import2DFields (lowerSurface_F, thickness_F, beta_F);// import surf, thick and beta
    // to [numVertices]

    // Note:
    // Grid is supposed to be layerwise to import beta
    phgSolveIceStokes (phgGrid,
        nLayers,
        &temperatureOnTetra[0],
        &betaData[0],
        &Velocity_FS[0]);

    unsigned int nEdges3D = mesh3D.numEdges();
    unsigned int numElements = mesh3D.numElements();
    GET_HERE;
    unsigned int nVertices3D = mesh3D.numVertices();
    assert (nEdges3D > 0);

    GET_HERE;
    for (unsigned int i = 0; i < numElements; i++)
    {

      // Vert
      for (unsigned int j = 0; j < 4; j++)
      {
        int v = mesh3D.element (i).point (j).localId();
        velocityOnVertices[v] = Velocity_FS[3 * v];
        velocityOnVertices[nVertices3D + v] = Velocity_FS[3 * v + 1];
        Velocity_P2[v] = Velocity_FS[3 * v];
        Velocity_P2[nVertices3D + nEdges3D + v] = Velocity_FS[3 * v + 1];
      }

      //  Life tet edge (ElementShapes)
      //  0, 1,
      //  1, 2,
      //  2, 0,
      //  0, 3,
      //  1, 3,
      //  2, 3
      //
      //  PHG tet face (utils.c)
      //  0, 1
      //  0, 2
      //  0, 3
      //  1, 2
      //  1, 3
      //  2, 3
      //
      //  map Life to PHG
      //  0, 3, 1, 2, 4, 5
      //  reverse
      //  0, 2, 3, 1, 4, 5
      //

      // for (unsigned int j = 0; j < 4; j++) {
      //  int e = mesh3D.element(i).edge(j).localId();
      //  Velocity_P1[e] =  Velocity_FS[3*e];
      //  Velocity_P1[nVertices + v]  = Velocity_FS[3*e + 1];
      //  Velocity_P2[e] =  Velocity_FS[3*v];
      //  Velocity_P2[nVertices+nEdges + e]  = Velocity_FS[3*e + 1];
      // }
    }

    //save velocity to be used as an initial guess next iteration
    GET_HERE;
    std::vector<int> mpasIndexToVertexID (nVertices);
    for (int i = 0; i < nVertices; i++)
    {
      mpasIndexToVertexID[i] = indexToCellID_F[vertexToFCell[i]];
    }
    get_tetraP1_velocity_on_FEdges (u_normal_F, velocityOnVertices, edgeToFEdge, mpasIndexToVertexID);

  }

  GET_HERE;
  mapVerticesToCells (velocityOnVertices, &velocityOnCells[0], 2, nLayers, LayerWise);

  GET_HERE;
  allToAll (u_normal_F, &sendEdgesListReversed, &recvEdgesListReversed, nLayers);

  GET_HERE;
  allToAll (u_normal_F, sendEdgesList_F, recvEdgesList_F, nLayers);
  GET_HERE;

  return;
}