Exemplo n.º 1
0
Arquivo: ASMs1D.C Projeto: OPM/IFEM
bool ASMs1D::tesselate (ElementBlock& grid, const int* npe) const
{
  // Compute parameter values of the nodal points
  RealArray gpar;
  if (!this->getGridParameters(gpar,npe[0]-1))
    return false;

  // Evaluate the spline curve at all points
  size_t nx = gpar.size();
  RealArray XYZ(curv->dimension()*nx);
  curv->gridEvaluator(XYZ,gpar);

  // Establish the block grid coordinates
  size_t i, j, l;
  grid.resize(nx);
  for (i = l = 0; i < grid.getNoNodes(); i++, l += curv->dimension())
    for (j = 0; j < nsd; j++)
      grid.setCoor(i,j,XYZ[l+j]);

  // Establish the block grid topology
  int nse1 = npe[0] - 1;
  int n[2], ie = 1, ip = 0;
  n[0] = 0;
  n[1] = n[0] + 1;

  for (i = 1; i < nx; i++)
  {
    for (l = 0; l < 2; l++)
      grid.setNode(ip++,n[l]++);
    grid.setElmId(i,ie);
    if (i%nse1 == 0) ie++;
  }

  return true;
}
Exemplo n.º 2
0
bool ASMs2DLag::tesselate (ElementBlock& grid, const int* npe) const
{
  if (p1 != npe[0] || p2 != npe[1])
  {
    int* newnpe = const_cast<int*>(npe);
    std::cout <<"\nLagrange elements: The number of visualization points are "
	      << p1 <<" "<< p2 <<" by default\n"<< std::endl;
    newnpe[0] = p1;
    newnpe[1] = p2;
  }

  if (!this->ASMs2D::tesselate(grid,npe))
    return false;

  // Adjust the element Id since each Lagrange element covers several knot-spans
  int i, ie, nse1 = p1-1;
  int j, je, nse2 = p2-1;
  int nelx = (nx-1)/nse1;
  for (j = je = 1; j < (int)ny; j++)
  {
    for (i = ie = 1; i < (int)nx; i++)
    {
      grid.setElmId((j-1)*(nx-1)+i,(je-1)*nelx+ie);
      if (i%nse1 == 0) ie++;
    }
    if (j%nse2 == 0) je++;
  }

  return true;
}
Exemplo n.º 3
0
Arquivo: ASMs3DLag.C Projeto: OPM/IFEM
bool ASMs3DLag::tesselate (ElementBlock& grid, const int* npe) const
{
  const int p1 = svol->order(0);
  const int p2 = svol->order(1);
  const int p3 = svol->order(2);
  if (p1 != npe[0] || p2 != npe[1] || p2 != npe[2])
  {
    int* newnpe = const_cast<int*>(npe);
    std::cout <<"\nLagrange elements: The number of visualization points are "
	      << p1 <<" "<< p2 <<" "<< p3 <<" by default\n"<< std::endl;
    newnpe[0] = p1;
    newnpe[1] = p2;
    newnpe[2] = p3;
  }

  if (!this->ASMs3D::tesselate(grid,npe))
    return false;

  // Adjust the element Id since each Lagrange element covers several knot-spans
  int i, ie, nse1 = p1-1;
  int j, je, nse2 = p2-1;
  int k, ke, nse3 = p3-1;
  int nelx = (nx-1)/nse1;
  int nely = (ny-1)/nse1;
  for (k = ke = 1; k < (int)nz; k++)
  {
    for (j = je = 1; j < (int)ny; j++)
    {
      for (i = ie = 1; i < (int)nx; i++)
      {
	grid.setElmId(((k-1)*(ny-1)+j-1)*(nx-1)+i,((ke-1)*nely+je-1)*nelx+ie);
	if (i%nse1 == 0) ie++;
      }
      if (j%nse2 == 0) je++;
    }
    if (k%nse3 == 0) ke++;
  }

  return true;
}